]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.1-201307181236.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.1-201307181236.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 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,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 2fe6e76..3dd8184 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -2195,6 +2199,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 the specified number of seconds. This is to be used if
248 your oopses keep scrolling off the screen.
249
250 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
251 + virtualization environments that don't cope well with the
252 + expand down segment used by UDEREF on X86-32 or the frequent
253 + page table updates on X86-64.
254 +
255 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
256 +
257 + pax_extra_latent_entropy
258 + Enable a very simple form of latent entropy extraction
259 + from the first 4GB of memory as the bootmem allocator
260 + passes the memory pages to the buddy allocator.
261 +
262 pcbit= [HW,ISDN]
263
264 pcd. [PARIDE]
265 diff --git a/Makefile b/Makefile
266 index b75cc30..6abd111 100644
267 --- a/Makefile
268 +++ b/Makefile
269 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
270
271 HOSTCC = gcc
272 HOSTCXX = g++
273 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
274 -HOSTCXXFLAGS = -O2
275 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
276 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
277 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
278
279 # Decide whether to build built-in, modular, or both.
280 # Normally, just do built-in.
281 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
282 # Rules shared between *config targets and build targets
283
284 # Basic helpers built in scripts/
285 -PHONY += scripts_basic
286 -scripts_basic:
287 +PHONY += scripts_basic gcc-plugins
288 +scripts_basic: gcc-plugins
289 $(Q)$(MAKE) $(build)=scripts/basic
290 $(Q)rm -f .tmp_quiet_recordmcount
291
292 @@ -576,6 +577,65 @@ else
293 KBUILD_CFLAGS += -O2
294 endif
295
296 +ifndef DISABLE_PAX_PLUGINS
297 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
298 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
299 +else
300 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
301 +endif
302 +ifneq ($(PLUGINCC),)
303 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
304 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
305 +endif
306 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
307 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
308 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
309 +endif
310 +ifdef CONFIG_KALLOCSTAT_PLUGIN
311 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
312 +endif
313 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
314 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
315 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
316 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
317 +endif
318 +ifdef CONFIG_CHECKER_PLUGIN
319 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
320 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
321 +endif
322 +endif
323 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
324 +ifdef CONFIG_PAX_SIZE_OVERFLOW
325 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
326 +endif
327 +ifdef CONFIG_PAX_LATENT_ENTROPY
328 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
329 +endif
330 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
331 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
332 +endif
333 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
334 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
335 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
336 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
337 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
338 +ifeq ($(KBUILD_EXTMOD),)
339 +gcc-plugins:
340 + $(Q)$(MAKE) $(build)=tools/gcc
341 +else
342 +gcc-plugins: ;
343 +endif
344 +else
345 +gcc-plugins:
346 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
347 + $(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.))
348 +else
349 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
350 +endif
351 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
352 +endif
353 +endif
354 +
355 include $(srctree)/arch/$(SRCARCH)/Makefile
356
357 ifdef CONFIG_READABLE_ASM
358 @@ -733,7 +793,7 @@ export mod_sign_cmd
359
360
361 ifeq ($(KBUILD_EXTMOD),)
362 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
363 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
364
365 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
366 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
367 @@ -782,6 +842,8 @@ endif
368
369 # The actual objects are generated when descending,
370 # make sure no implicit rule kicks in
371 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
372 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
373 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
374
375 # Handle descending into subdirectories listed in $(vmlinux-dirs)
376 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
377 # Error messages still appears in the original language
378
379 PHONY += $(vmlinux-dirs)
380 -$(vmlinux-dirs): prepare scripts
381 +$(vmlinux-dirs): gcc-plugins prepare scripts
382 $(Q)$(MAKE) $(build)=$@
383
384 # Store (new) KERNELRELASE string in include/config/kernel.release
385 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
386 $(Q)$(MAKE) $(build)=.
387
388 # All the preparing..
389 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
390 prepare: prepare0
391
392 # Generate some files
393 @@ -942,6 +1005,8 @@ all: modules
394 # using awk while concatenating to the final file.
395
396 PHONY += modules
397 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
398 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
399 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
400 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
401 @$(kecho) ' Building modules, stage 2.';
402 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
403
404 # Target to prepare building external modules
405 PHONY += modules_prepare
406 -modules_prepare: prepare scripts
407 +modules_prepare: gcc-plugins prepare scripts
408
409 # Target to install modules
410 PHONY += modules_install
411 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
412 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
413 signing_key.priv signing_key.x509 x509.genkey \
414 extra_certificates signing_key.x509.keyid \
415 - signing_key.x509.signer
416 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
417
418 # clean - Delete most, but leave enough to build external modules
419 #
420 @@ -1063,6 +1128,7 @@ distclean: mrproper
421 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
422 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
423 -o -name '.*.rej' \
424 + -o -name '.*.rej' -o -name '*.so' \
425 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
426 -type f -print | xargs rm -f
427
428 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
429 $(module-dirs): crmodverdir $(objtree)/Module.symvers
430 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
431
432 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
433 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
434 modules: $(module-dirs)
435 @$(kecho) ' Building modules, stage 2.';
436 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
437 @@ -1359,17 +1427,21 @@ else
438 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
439 endif
440
441 -%.s: %.c prepare scripts FORCE
442 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
443 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
444 +%.s: %.c gcc-plugins prepare scripts FORCE
445 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
446 %.i: %.c prepare scripts FORCE
447 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
448 -%.o: %.c prepare scripts FORCE
449 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
450 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
451 +%.o: %.c gcc-plugins prepare scripts FORCE
452 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
453 %.lst: %.c prepare scripts FORCE
454 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
455 -%.s: %.S prepare scripts FORCE
456 +%.s: %.S gcc-plugins prepare scripts FORCE
457 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
458 -%.o: %.S prepare scripts FORCE
459 +%.o: %.S gcc-plugins prepare scripts FORCE
460 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
461 %.symtypes: %.c prepare scripts FORCE
462 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
463 @@ -1379,11 +1451,15 @@ endif
464 $(cmd_crmodverdir)
465 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
466 $(build)=$(build-dir)
467 -%/: prepare scripts FORCE
468 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
469 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
470 +%/: gcc-plugins prepare scripts FORCE
471 $(cmd_crmodverdir)
472 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
473 $(build)=$(build-dir)
474 -%.ko: prepare scripts FORCE
475 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
476 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
477 +%.ko: gcc-plugins prepare scripts FORCE
478 $(cmd_crmodverdir)
479 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
480 $(build)=$(build-dir) $(@:.ko=.o)
481 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
482 index c2cbe4f..f7264b4 100644
483 --- a/arch/alpha/include/asm/atomic.h
484 +++ b/arch/alpha/include/asm/atomic.h
485 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
486 #define atomic_dec(v) atomic_sub(1,(v))
487 #define atomic64_dec(v) atomic64_sub(1,(v))
488
489 +#define atomic64_read_unchecked(v) atomic64_read(v)
490 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
491 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
492 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
493 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
494 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
495 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
496 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
497 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
498 +
499 #define smp_mb__before_atomic_dec() smp_mb()
500 #define smp_mb__after_atomic_dec() smp_mb()
501 #define smp_mb__before_atomic_inc() smp_mb()
502 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
503 index ad368a9..fbe0f25 100644
504 --- a/arch/alpha/include/asm/cache.h
505 +++ b/arch/alpha/include/asm/cache.h
506 @@ -4,19 +4,19 @@
507 #ifndef __ARCH_ALPHA_CACHE_H
508 #define __ARCH_ALPHA_CACHE_H
509
510 +#include <linux/const.h>
511
512 /* Bytes per L1 (data) cache line. */
513 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
514 -# define L1_CACHE_BYTES 64
515 # define L1_CACHE_SHIFT 6
516 #else
517 /* Both EV4 and EV5 are write-through, read-allocate,
518 direct-mapped, physical.
519 */
520 -# define L1_CACHE_BYTES 32
521 # define L1_CACHE_SHIFT 5
522 #endif
523
524 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
526
527 #endif
528 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
529 index 968d999..d36b2df 100644
530 --- a/arch/alpha/include/asm/elf.h
531 +++ b/arch/alpha/include/asm/elf.h
532 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
533
534 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
535
536 +#ifdef CONFIG_PAX_ASLR
537 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
538 +
539 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
540 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
541 +#endif
542 +
543 /* $0 is set by ld.so to a pointer to a function which might be
544 registered using atexit. This provides a mean for the dynamic
545 linker to call DT_FINI functions for shared libraries that have
546 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
547 index bc2a0da..8ad11ee 100644
548 --- a/arch/alpha/include/asm/pgalloc.h
549 +++ b/arch/alpha/include/asm/pgalloc.h
550 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
551 pgd_set(pgd, pmd);
552 }
553
554 +static inline void
555 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
556 +{
557 + pgd_populate(mm, pgd, pmd);
558 +}
559 +
560 extern pgd_t *pgd_alloc(struct mm_struct *mm);
561
562 static inline void
563 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
564 index 81a4342..348b927 100644
565 --- a/arch/alpha/include/asm/pgtable.h
566 +++ b/arch/alpha/include/asm/pgtable.h
567 @@ -102,6 +102,17 @@ struct vm_area_struct;
568 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
569 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
570 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
571 +
572 +#ifdef CONFIG_PAX_PAGEEXEC
573 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
574 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
575 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
576 +#else
577 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
578 +# define PAGE_COPY_NOEXEC PAGE_COPY
579 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
580 +#endif
581 +
582 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
583
584 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
585 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
586 index 2fd00b7..cfd5069 100644
587 --- a/arch/alpha/kernel/module.c
588 +++ b/arch/alpha/kernel/module.c
589 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
590
591 /* The small sections were sorted to the end of the segment.
592 The following should definitely cover them. */
593 - gp = (u64)me->module_core + me->core_size - 0x8000;
594 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
595 got = sechdrs[me->arch.gotsecindex].sh_addr;
596
597 for (i = 0; i < n; i++) {
598 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
599 index b9e37ad..44c24e7 100644
600 --- a/arch/alpha/kernel/osf_sys.c
601 +++ b/arch/alpha/kernel/osf_sys.c
602 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
603 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
604
605 static unsigned long
606 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
607 - unsigned long limit)
608 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
609 + unsigned long limit, unsigned long flags)
610 {
611 struct vm_unmapped_area_info info;
612 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
613
614 info.flags = 0;
615 info.length = len;
616 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
617 info.high_limit = limit;
618 info.align_mask = 0;
619 info.align_offset = 0;
620 + info.threadstack_offset = offset;
621 return vm_unmapped_area(&info);
622 }
623
624 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
625 merely specific addresses, but regions of memory -- perhaps
626 this feature should be incorporated into all ports? */
627
628 +#ifdef CONFIG_PAX_RANDMMAP
629 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
630 +#endif
631 +
632 if (addr) {
633 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
634 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
635 if (addr != (unsigned long) -ENOMEM)
636 return addr;
637 }
638
639 /* Next, try allocating at TASK_UNMAPPED_BASE. */
640 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
641 - len, limit);
642 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
643 +
644 if (addr != (unsigned long) -ENOMEM)
645 return addr;
646
647 /* Finally, try allocating in low memory. */
648 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
649 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
650
651 return addr;
652 }
653 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
654 index 0c4132d..88f0d53 100644
655 --- a/arch/alpha/mm/fault.c
656 +++ b/arch/alpha/mm/fault.c
657 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
658 __reload_thread(pcb);
659 }
660
661 +#ifdef CONFIG_PAX_PAGEEXEC
662 +/*
663 + * PaX: decide what to do with offenders (regs->pc = fault address)
664 + *
665 + * returns 1 when task should be killed
666 + * 2 when patched PLT trampoline was detected
667 + * 3 when unpatched PLT trampoline was detected
668 + */
669 +static int pax_handle_fetch_fault(struct pt_regs *regs)
670 +{
671 +
672 +#ifdef CONFIG_PAX_EMUPLT
673 + int err;
674 +
675 + do { /* PaX: patched PLT emulation #1 */
676 + unsigned int ldah, ldq, jmp;
677 +
678 + err = get_user(ldah, (unsigned int *)regs->pc);
679 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
680 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
681 +
682 + if (err)
683 + break;
684 +
685 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
686 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
687 + jmp == 0x6BFB0000U)
688 + {
689 + unsigned long r27, addr;
690 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
691 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
692 +
693 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
694 + err = get_user(r27, (unsigned long *)addr);
695 + if (err)
696 + break;
697 +
698 + regs->r27 = r27;
699 + regs->pc = r27;
700 + return 2;
701 + }
702 + } while (0);
703 +
704 + do { /* PaX: patched PLT emulation #2 */
705 + unsigned int ldah, lda, br;
706 +
707 + err = get_user(ldah, (unsigned int *)regs->pc);
708 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
709 + err |= get_user(br, (unsigned int *)(regs->pc+8));
710 +
711 + if (err)
712 + break;
713 +
714 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
715 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
716 + (br & 0xFFE00000U) == 0xC3E00000U)
717 + {
718 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
719 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
720 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
721 +
722 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
723 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
724 + return 2;
725 + }
726 + } while (0);
727 +
728 + do { /* PaX: unpatched PLT emulation */
729 + unsigned int br;
730 +
731 + err = get_user(br, (unsigned int *)regs->pc);
732 +
733 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
734 + unsigned int br2, ldq, nop, jmp;
735 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
736 +
737 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
738 + err = get_user(br2, (unsigned int *)addr);
739 + err |= get_user(ldq, (unsigned int *)(addr+4));
740 + err |= get_user(nop, (unsigned int *)(addr+8));
741 + err |= get_user(jmp, (unsigned int *)(addr+12));
742 + err |= get_user(resolver, (unsigned long *)(addr+16));
743 +
744 + if (err)
745 + break;
746 +
747 + if (br2 == 0xC3600000U &&
748 + ldq == 0xA77B000CU &&
749 + nop == 0x47FF041FU &&
750 + jmp == 0x6B7B0000U)
751 + {
752 + regs->r28 = regs->pc+4;
753 + regs->r27 = addr+16;
754 + regs->pc = resolver;
755 + return 3;
756 + }
757 + }
758 + } while (0);
759 +#endif
760 +
761 + return 1;
762 +}
763 +
764 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
765 +{
766 + unsigned long i;
767 +
768 + printk(KERN_ERR "PAX: bytes at PC: ");
769 + for (i = 0; i < 5; i++) {
770 + unsigned int c;
771 + if (get_user(c, (unsigned int *)pc+i))
772 + printk(KERN_CONT "???????? ");
773 + else
774 + printk(KERN_CONT "%08x ", c);
775 + }
776 + printk("\n");
777 +}
778 +#endif
779
780 /*
781 * This routine handles page faults. It determines the address,
782 @@ -133,8 +251,29 @@ retry:
783 good_area:
784 si_code = SEGV_ACCERR;
785 if (cause < 0) {
786 - if (!(vma->vm_flags & VM_EXEC))
787 + if (!(vma->vm_flags & VM_EXEC)) {
788 +
789 +#ifdef CONFIG_PAX_PAGEEXEC
790 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
791 + goto bad_area;
792 +
793 + up_read(&mm->mmap_sem);
794 + switch (pax_handle_fetch_fault(regs)) {
795 +
796 +#ifdef CONFIG_PAX_EMUPLT
797 + case 2:
798 + case 3:
799 + return;
800 +#endif
801 +
802 + }
803 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
804 + do_group_exit(SIGKILL);
805 +#else
806 goto bad_area;
807 +#endif
808 +
809 + }
810 } else if (!cause) {
811 /* Allow reads even for write-only mappings */
812 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
813 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
814 index 136f263..f471277 100644
815 --- a/arch/arm/Kconfig
816 +++ b/arch/arm/Kconfig
817 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
818
819 config UACCESS_WITH_MEMCPY
820 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
821 - depends on MMU
822 + depends on MMU && !PAX_MEMORY_UDEREF
823 default y if CPU_FEROCEON
824 help
825 Implement faster copy_to_user and clear_user methods for CPU
826 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
827 index da1c77d..2ee6056 100644
828 --- a/arch/arm/include/asm/atomic.h
829 +++ b/arch/arm/include/asm/atomic.h
830 @@ -17,17 +17,35 @@
831 #include <asm/barrier.h>
832 #include <asm/cmpxchg.h>
833
834 +#ifdef CONFIG_GENERIC_ATOMIC64
835 +#include <asm-generic/atomic64.h>
836 +#endif
837 +
838 #define ATOMIC_INIT(i) { (i) }
839
840 #ifdef __KERNEL__
841
842 +#define _ASM_EXTABLE(from, to) \
843 +" .pushsection __ex_table,\"a\"\n"\
844 +" .align 3\n" \
845 +" .long " #from ", " #to"\n" \
846 +" .popsection"
847 +
848 /*
849 * On ARM, ordinary assignment (str instruction) doesn't clear the local
850 * strex/ldrex monitor on some implementations. The reason we can use it for
851 * atomic_set() is the clrex or dummy strex done on every exception return.
852 */
853 #define atomic_read(v) (*(volatile int *)&(v)->counter)
854 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
855 +{
856 + return v->counter;
857 +}
858 #define atomic_set(v,i) (((v)->counter) = (i))
859 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
860 +{
861 + v->counter = i;
862 +}
863
864 #if __LINUX_ARM_ARCH__ >= 6
865
866 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
867 int result;
868
869 __asm__ __volatile__("@ atomic_add\n"
870 +"1: ldrex %1, [%3]\n"
871 +" adds %0, %1, %4\n"
872 +
873 +#ifdef CONFIG_PAX_REFCOUNT
874 +" bvc 3f\n"
875 +"2: bkpt 0xf103\n"
876 +"3:\n"
877 +#endif
878 +
879 +" strex %1, %0, [%3]\n"
880 +" teq %1, #0\n"
881 +" bne 1b"
882 +
883 +#ifdef CONFIG_PAX_REFCOUNT
884 +"\n4:\n"
885 + _ASM_EXTABLE(2b, 4b)
886 +#endif
887 +
888 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
889 + : "r" (&v->counter), "Ir" (i)
890 + : "cc");
891 +}
892 +
893 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
894 +{
895 + unsigned long tmp;
896 + int result;
897 +
898 + __asm__ __volatile__("@ atomic_add_unchecked\n"
899 "1: ldrex %0, [%3]\n"
900 " add %0, %0, %4\n"
901 " strex %1, %0, [%3]\n"
902 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
903 smp_mb();
904
905 __asm__ __volatile__("@ atomic_add_return\n"
906 +"1: ldrex %1, [%3]\n"
907 +" adds %0, %1, %4\n"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +" bvc 3f\n"
911 +" mov %0, %1\n"
912 +"2: bkpt 0xf103\n"
913 +"3:\n"
914 +#endif
915 +
916 +" strex %1, %0, [%3]\n"
917 +" teq %1, #0\n"
918 +" bne 1b"
919 +
920 +#ifdef CONFIG_PAX_REFCOUNT
921 +"\n4:\n"
922 + _ASM_EXTABLE(2b, 4b)
923 +#endif
924 +
925 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
926 + : "r" (&v->counter), "Ir" (i)
927 + : "cc");
928 +
929 + smp_mb();
930 +
931 + return result;
932 +}
933 +
934 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
935 +{
936 + unsigned long tmp;
937 + int result;
938 +
939 + smp_mb();
940 +
941 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
942 "1: ldrex %0, [%3]\n"
943 " add %0, %0, %4\n"
944 " strex %1, %0, [%3]\n"
945 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
946 int result;
947
948 __asm__ __volatile__("@ atomic_sub\n"
949 +"1: ldrex %1, [%3]\n"
950 +" subs %0, %1, %4\n"
951 +
952 +#ifdef CONFIG_PAX_REFCOUNT
953 +" bvc 3f\n"
954 +"2: bkpt 0xf103\n"
955 +"3:\n"
956 +#endif
957 +
958 +" strex %1, %0, [%3]\n"
959 +" teq %1, #0\n"
960 +" bne 1b"
961 +
962 +#ifdef CONFIG_PAX_REFCOUNT
963 +"\n4:\n"
964 + _ASM_EXTABLE(2b, 4b)
965 +#endif
966 +
967 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
968 + : "r" (&v->counter), "Ir" (i)
969 + : "cc");
970 +}
971 +
972 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
973 +{
974 + unsigned long tmp;
975 + int result;
976 +
977 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
978 "1: ldrex %0, [%3]\n"
979 " sub %0, %0, %4\n"
980 " strex %1, %0, [%3]\n"
981 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
982 smp_mb();
983
984 __asm__ __volatile__("@ atomic_sub_return\n"
985 -"1: ldrex %0, [%3]\n"
986 -" sub %0, %0, %4\n"
987 +"1: ldrex %1, [%3]\n"
988 +" subs %0, %1, %4\n"
989 +
990 +#ifdef CONFIG_PAX_REFCOUNT
991 +" bvc 3f\n"
992 +" mov %0, %1\n"
993 +"2: bkpt 0xf103\n"
994 +"3:\n"
995 +#endif
996 +
997 " strex %1, %0, [%3]\n"
998 " teq %1, #0\n"
999 " bne 1b"
1000 +
1001 +#ifdef CONFIG_PAX_REFCOUNT
1002 +"\n4:\n"
1003 + _ASM_EXTABLE(2b, 4b)
1004 +#endif
1005 +
1006 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1007 : "r" (&v->counter), "Ir" (i)
1008 : "cc");
1009 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1010 return oldval;
1011 }
1012
1013 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1014 +{
1015 + unsigned long oldval, res;
1016 +
1017 + smp_mb();
1018 +
1019 + do {
1020 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1021 + "ldrex %1, [%3]\n"
1022 + "mov %0, #0\n"
1023 + "teq %1, %4\n"
1024 + "strexeq %0, %5, [%3]\n"
1025 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1026 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1027 + : "cc");
1028 + } while (res);
1029 +
1030 + smp_mb();
1031 +
1032 + return oldval;
1033 +}
1034 +
1035 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1036 {
1037 unsigned long tmp, tmp2;
1038 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1039
1040 return val;
1041 }
1042 +
1043 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1044 +{
1045 + return atomic_add_return(i, v);
1046 +}
1047 +
1048 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1049 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1050 +{
1051 + (void) atomic_add_return(i, v);
1052 +}
1053
1054 static inline int atomic_sub_return(int i, atomic_t *v)
1055 {
1056 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1057 return val;
1058 }
1059 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1060 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1061 +{
1062 + (void) atomic_sub_return(i, v);
1063 +}
1064
1065 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1066 {
1067 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1068 return ret;
1069 }
1070
1071 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1072 +{
1073 + return atomic_cmpxchg(v, old, new);
1074 +}
1075 +
1076 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1077 {
1078 unsigned long flags;
1079 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1080 #endif /* __LINUX_ARM_ARCH__ */
1081
1082 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1083 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1084 +{
1085 + return xchg(&v->counter, new);
1086 +}
1087
1088 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1089 {
1090 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1091 }
1092
1093 #define atomic_inc(v) atomic_add(1, v)
1094 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1095 +{
1096 + atomic_add_unchecked(1, v);
1097 +}
1098 #define atomic_dec(v) atomic_sub(1, v)
1099 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1100 +{
1101 + atomic_sub_unchecked(1, v);
1102 +}
1103
1104 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1105 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1106 +{
1107 + return atomic_add_return_unchecked(1, v) == 0;
1108 +}
1109 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1110 #define atomic_inc_return(v) (atomic_add_return(1, v))
1111 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1112 +{
1113 + return atomic_add_return_unchecked(1, v);
1114 +}
1115 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1116 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1117
1118 @@ -241,6 +428,14 @@ typedef struct {
1119 u64 __aligned(8) counter;
1120 } atomic64_t;
1121
1122 +#ifdef CONFIG_PAX_REFCOUNT
1123 +typedef struct {
1124 + u64 __aligned(8) counter;
1125 +} atomic64_unchecked_t;
1126 +#else
1127 +typedef atomic64_t atomic64_unchecked_t;
1128 +#endif
1129 +
1130 #define ATOMIC64_INIT(i) { (i) }
1131
1132 #ifdef CONFIG_ARM_LPAE
1133 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1134 return result;
1135 }
1136
1137 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1138 +{
1139 + u64 result;
1140 +
1141 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1142 +" ldrd %0, %H0, [%1]"
1143 + : "=&r" (result)
1144 + : "r" (&v->counter), "Qo" (v->counter)
1145 + );
1146 +
1147 + return result;
1148 +}
1149 +
1150 static inline void atomic64_set(atomic64_t *v, u64 i)
1151 {
1152 __asm__ __volatile__("@ atomic64_set\n"
1153 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1154 : "r" (&v->counter), "r" (i)
1155 );
1156 }
1157 +
1158 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1159 +{
1160 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1161 +" strd %2, %H2, [%1]"
1162 + : "=Qo" (v->counter)
1163 + : "r" (&v->counter), "r" (i)
1164 + );
1165 +}
1166 #else
1167 static inline u64 atomic64_read(const atomic64_t *v)
1168 {
1169 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1170 return result;
1171 }
1172
1173 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1174 +{
1175 + u64 result;
1176 +
1177 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1178 +" ldrexd %0, %H0, [%1]"
1179 + : "=&r" (result)
1180 + : "r" (&v->counter), "Qo" (v->counter)
1181 + );
1182 +
1183 + return result;
1184 +}
1185 +
1186 static inline void atomic64_set(atomic64_t *v, u64 i)
1187 {
1188 u64 tmp;
1189 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1190 : "r" (&v->counter), "r" (i)
1191 : "cc");
1192 }
1193 +
1194 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1195 +{
1196 + u64 tmp;
1197 +
1198 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1199 +"1: ldrexd %0, %H0, [%2]\n"
1200 +" strexd %0, %3, %H3, [%2]\n"
1201 +" teq %0, #0\n"
1202 +" bne 1b"
1203 + : "=&r" (tmp), "=Qo" (v->counter)
1204 + : "r" (&v->counter), "r" (i)
1205 + : "cc");
1206 +}
1207 +
1208 #endif
1209
1210 static inline void atomic64_add(u64 i, atomic64_t *v)
1211 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1212 __asm__ __volatile__("@ atomic64_add\n"
1213 "1: ldrexd %0, %H0, [%3]\n"
1214 " adds %0, %0, %4\n"
1215 +" adcs %H0, %H0, %H4\n"
1216 +
1217 +#ifdef CONFIG_PAX_REFCOUNT
1218 +" bvc 3f\n"
1219 +"2: bkpt 0xf103\n"
1220 +"3:\n"
1221 +#endif
1222 +
1223 +" strexd %1, %0, %H0, [%3]\n"
1224 +" teq %1, #0\n"
1225 +" bne 1b"
1226 +
1227 +#ifdef CONFIG_PAX_REFCOUNT
1228 +"\n4:\n"
1229 + _ASM_EXTABLE(2b, 4b)
1230 +#endif
1231 +
1232 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1233 + : "r" (&v->counter), "r" (i)
1234 + : "cc");
1235 +}
1236 +
1237 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1238 +{
1239 + u64 result;
1240 + unsigned long tmp;
1241 +
1242 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1243 +"1: ldrexd %0, %H0, [%3]\n"
1244 +" adds %0, %0, %4\n"
1245 " adc %H0, %H0, %H4\n"
1246 " strexd %1, %0, %H0, [%3]\n"
1247 " teq %1, #0\n"
1248 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1249
1250 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1251 {
1252 - u64 result;
1253 - unsigned long tmp;
1254 + u64 result, tmp;
1255
1256 smp_mb();
1257
1258 __asm__ __volatile__("@ atomic64_add_return\n"
1259 +"1: ldrexd %1, %H1, [%3]\n"
1260 +" adds %0, %1, %4\n"
1261 +" adcs %H0, %H1, %H4\n"
1262 +
1263 +#ifdef CONFIG_PAX_REFCOUNT
1264 +" bvc 3f\n"
1265 +" mov %0, %1\n"
1266 +" mov %H0, %H1\n"
1267 +"2: bkpt 0xf103\n"
1268 +"3:\n"
1269 +#endif
1270 +
1271 +" strexd %1, %0, %H0, [%3]\n"
1272 +" teq %1, #0\n"
1273 +" bne 1b"
1274 +
1275 +#ifdef CONFIG_PAX_REFCOUNT
1276 +"\n4:\n"
1277 + _ASM_EXTABLE(2b, 4b)
1278 +#endif
1279 +
1280 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1281 + : "r" (&v->counter), "r" (i)
1282 + : "cc");
1283 +
1284 + smp_mb();
1285 +
1286 + return result;
1287 +}
1288 +
1289 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1290 +{
1291 + u64 result;
1292 + unsigned long tmp;
1293 +
1294 + smp_mb();
1295 +
1296 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1297 "1: ldrexd %0, %H0, [%3]\n"
1298 " adds %0, %0, %4\n"
1299 " adc %H0, %H0, %H4\n"
1300 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1301 __asm__ __volatile__("@ atomic64_sub\n"
1302 "1: ldrexd %0, %H0, [%3]\n"
1303 " subs %0, %0, %4\n"
1304 +" sbcs %H0, %H0, %H4\n"
1305 +
1306 +#ifdef CONFIG_PAX_REFCOUNT
1307 +" bvc 3f\n"
1308 +"2: bkpt 0xf103\n"
1309 +"3:\n"
1310 +#endif
1311 +
1312 +" strexd %1, %0, %H0, [%3]\n"
1313 +" teq %1, #0\n"
1314 +" bne 1b"
1315 +
1316 +#ifdef CONFIG_PAX_REFCOUNT
1317 +"\n4:\n"
1318 + _ASM_EXTABLE(2b, 4b)
1319 +#endif
1320 +
1321 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1322 + : "r" (&v->counter), "r" (i)
1323 + : "cc");
1324 +}
1325 +
1326 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1327 +{
1328 + u64 result;
1329 + unsigned long tmp;
1330 +
1331 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1332 +"1: ldrexd %0, %H0, [%3]\n"
1333 +" subs %0, %0, %4\n"
1334 " sbc %H0, %H0, %H4\n"
1335 " strexd %1, %0, %H0, [%3]\n"
1336 " teq %1, #0\n"
1337 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1338
1339 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1340 {
1341 - u64 result;
1342 - unsigned long tmp;
1343 + u64 result, tmp;
1344
1345 smp_mb();
1346
1347 __asm__ __volatile__("@ atomic64_sub_return\n"
1348 -"1: ldrexd %0, %H0, [%3]\n"
1349 -" subs %0, %0, %4\n"
1350 -" sbc %H0, %H0, %H4\n"
1351 +"1: ldrexd %1, %H1, [%3]\n"
1352 +" subs %0, %1, %4\n"
1353 +" sbcs %H0, %H1, %H4\n"
1354 +
1355 +#ifdef CONFIG_PAX_REFCOUNT
1356 +" bvc 3f\n"
1357 +" mov %0, %1\n"
1358 +" mov %H0, %H1\n"
1359 +"2: bkpt 0xf103\n"
1360 +"3:\n"
1361 +#endif
1362 +
1363 " strexd %1, %0, %H0, [%3]\n"
1364 " teq %1, #0\n"
1365 " bne 1b"
1366 +
1367 +#ifdef CONFIG_PAX_REFCOUNT
1368 +"\n4:\n"
1369 + _ASM_EXTABLE(2b, 4b)
1370 +#endif
1371 +
1372 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1373 : "r" (&v->counter), "r" (i)
1374 : "cc");
1375 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1376 return oldval;
1377 }
1378
1379 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1380 +{
1381 + u64 oldval;
1382 + unsigned long res;
1383 +
1384 + smp_mb();
1385 +
1386 + do {
1387 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1388 + "ldrexd %1, %H1, [%3]\n"
1389 + "mov %0, #0\n"
1390 + "teq %1, %4\n"
1391 + "teqeq %H1, %H4\n"
1392 + "strexdeq %0, %5, %H5, [%3]"
1393 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1394 + : "r" (&ptr->counter), "r" (old), "r" (new)
1395 + : "cc");
1396 + } while (res);
1397 +
1398 + smp_mb();
1399 +
1400 + return oldval;
1401 +}
1402 +
1403 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404 {
1405 u64 result;
1406 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1407
1408 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1409 {
1410 - u64 result;
1411 - unsigned long tmp;
1412 + u64 result, tmp;
1413
1414 smp_mb();
1415
1416 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1417 -"1: ldrexd %0, %H0, [%3]\n"
1418 -" subs %0, %0, #1\n"
1419 -" sbc %H0, %H0, #0\n"
1420 +"1: ldrexd %1, %H1, [%3]\n"
1421 +" subs %0, %1, #1\n"
1422 +" sbcs %H0, %H1, #0\n"
1423 +
1424 +#ifdef CONFIG_PAX_REFCOUNT
1425 +" bvc 3f\n"
1426 +" mov %0, %1\n"
1427 +" mov %H0, %H1\n"
1428 +"2: bkpt 0xf103\n"
1429 +"3:\n"
1430 +#endif
1431 +
1432 " teq %H0, #0\n"
1433 -" bmi 2f\n"
1434 +" bmi 4f\n"
1435 " strexd %1, %0, %H0, [%3]\n"
1436 " teq %1, #0\n"
1437 " bne 1b\n"
1438 -"2:"
1439 +"4:\n"
1440 +
1441 +#ifdef CONFIG_PAX_REFCOUNT
1442 + _ASM_EXTABLE(2b, 4b)
1443 +#endif
1444 +
1445 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1446 : "r" (&v->counter)
1447 : "cc");
1448 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1449 " teq %0, %5\n"
1450 " teqeq %H0, %H5\n"
1451 " moveq %1, #0\n"
1452 -" beq 2f\n"
1453 +" beq 4f\n"
1454 " adds %0, %0, %6\n"
1455 -" adc %H0, %H0, %H6\n"
1456 +" adcs %H0, %H0, %H6\n"
1457 +
1458 +#ifdef CONFIG_PAX_REFCOUNT
1459 +" bvc 3f\n"
1460 +"2: bkpt 0xf103\n"
1461 +"3:\n"
1462 +#endif
1463 +
1464 " strexd %2, %0, %H0, [%4]\n"
1465 " teq %2, #0\n"
1466 " bne 1b\n"
1467 -"2:"
1468 +"4:\n"
1469 +
1470 +#ifdef CONFIG_PAX_REFCOUNT
1471 + _ASM_EXTABLE(2b, 4b)
1472 +#endif
1473 +
1474 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1475 : "r" (&v->counter), "r" (u), "r" (a)
1476 : "cc");
1477 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1478
1479 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1480 #define atomic64_inc(v) atomic64_add(1LL, (v))
1481 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1482 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1483 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1484 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1485 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1486 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1487 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1488 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1489 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1490 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1491 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1492 index 75fe66b..ba3dee4 100644
1493 --- a/arch/arm/include/asm/cache.h
1494 +++ b/arch/arm/include/asm/cache.h
1495 @@ -4,8 +4,10 @@
1496 #ifndef __ASMARM_CACHE_H
1497 #define __ASMARM_CACHE_H
1498
1499 +#include <linux/const.h>
1500 +
1501 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1502 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1503 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1504
1505 /*
1506 * Memory returned by kmalloc() may be used for DMA, so we must make
1507 @@ -24,5 +26,6 @@
1508 #endif
1509
1510 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1511 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1512
1513 #endif
1514 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1515 index 17d0ae8..014e350 100644
1516 --- a/arch/arm/include/asm/cacheflush.h
1517 +++ b/arch/arm/include/asm/cacheflush.h
1518 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1519 void (*dma_unmap_area)(const void *, size_t, int);
1520
1521 void (*dma_flush_range)(const void *, const void *);
1522 -};
1523 +} __no_const;
1524
1525 /*
1526 * Select the calling method
1527 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1528 index 6dcc164..b14d917 100644
1529 --- a/arch/arm/include/asm/checksum.h
1530 +++ b/arch/arm/include/asm/checksum.h
1531 @@ -37,7 +37,19 @@ __wsum
1532 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1533
1534 __wsum
1535 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1536 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1537 +
1538 +static inline __wsum
1539 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1540 +{
1541 + __wsum ret;
1542 + pax_open_userland();
1543 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1544 + pax_close_userland();
1545 + return ret;
1546 +}
1547 +
1548 +
1549
1550 /*
1551 * Fold a partial checksum without adding pseudo headers
1552 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1553 index 4f009c1..466c59b 100644
1554 --- a/arch/arm/include/asm/cmpxchg.h
1555 +++ b/arch/arm/include/asm/cmpxchg.h
1556 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1557
1558 #define xchg(ptr,x) \
1559 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1560 +#define xchg_unchecked(ptr,x) \
1561 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1562
1563 #include <asm-generic/cmpxchg-local.h>
1564
1565 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1566 index 6ddbe44..b5e38b1 100644
1567 --- a/arch/arm/include/asm/domain.h
1568 +++ b/arch/arm/include/asm/domain.h
1569 @@ -48,18 +48,37 @@
1570 * Domain types
1571 */
1572 #define DOMAIN_NOACCESS 0
1573 -#define DOMAIN_CLIENT 1
1574 #ifdef CONFIG_CPU_USE_DOMAINS
1575 +#define DOMAIN_USERCLIENT 1
1576 +#define DOMAIN_KERNELCLIENT 1
1577 #define DOMAIN_MANAGER 3
1578 +#define DOMAIN_VECTORS DOMAIN_USER
1579 #else
1580 +
1581 +#ifdef CONFIG_PAX_KERNEXEC
1582 #define DOMAIN_MANAGER 1
1583 +#define DOMAIN_KERNEXEC 3
1584 +#else
1585 +#define DOMAIN_MANAGER 1
1586 +#endif
1587 +
1588 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1589 +#define DOMAIN_USERCLIENT 0
1590 +#define DOMAIN_UDEREF 1
1591 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1592 +#else
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_VECTORS DOMAIN_USER
1595 +#endif
1596 +#define DOMAIN_KERNELCLIENT 1
1597 +
1598 #endif
1599
1600 #define domain_val(dom,type) ((type) << (2*(dom)))
1601
1602 #ifndef __ASSEMBLY__
1603
1604 -#ifdef CONFIG_CPU_USE_DOMAINS
1605 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1606 static inline void set_domain(unsigned val)
1607 {
1608 asm volatile(
1609 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1610 isb();
1611 }
1612
1613 -#define modify_domain(dom,type) \
1614 - do { \
1615 - struct thread_info *thread = current_thread_info(); \
1616 - unsigned int domain = thread->cpu_domain; \
1617 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1618 - thread->cpu_domain = domain | domain_val(dom, type); \
1619 - set_domain(thread->cpu_domain); \
1620 - } while (0)
1621 -
1622 +extern void modify_domain(unsigned int dom, unsigned int type);
1623 #else
1624 static inline void set_domain(unsigned val) { }
1625 static inline void modify_domain(unsigned dom, unsigned type) { }
1626 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1627 index 38050b1..9d90e8b 100644
1628 --- a/arch/arm/include/asm/elf.h
1629 +++ b/arch/arm/include/asm/elf.h
1630 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1631 the loader. We need to make sure that it is out of the way of the program
1632 that it will "exec", and that there is sufficient room for the brk. */
1633
1634 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1635 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1636 +
1637 +#ifdef CONFIG_PAX_ASLR
1638 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1639 +
1640 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1641 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1642 +#endif
1643
1644 /* When the program starts, a1 contains a pointer to a function to be
1645 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1646 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1647 extern void elf_set_personality(const struct elf32_hdr *);
1648 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1649
1650 -struct mm_struct;
1651 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1652 -#define arch_randomize_brk arch_randomize_brk
1653 -
1654 #endif
1655 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1656 index de53547..52b9a28 100644
1657 --- a/arch/arm/include/asm/fncpy.h
1658 +++ b/arch/arm/include/asm/fncpy.h
1659 @@ -81,7 +81,9 @@
1660 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1661 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1662 \
1663 + pax_open_kernel(); \
1664 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1665 + pax_close_kernel(); \
1666 flush_icache_range((unsigned long)(dest_buf), \
1667 (unsigned long)(dest_buf) + (size)); \
1668 \
1669 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1670 index e42cf59..7b94b8f 100644
1671 --- a/arch/arm/include/asm/futex.h
1672 +++ b/arch/arm/include/asm/futex.h
1673 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1674 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1675 return -EFAULT;
1676
1677 + pax_open_userland();
1678 +
1679 smp_mb();
1680 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1681 "1: ldrex %1, [%4]\n"
1682 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1683 : "cc", "memory");
1684 smp_mb();
1685
1686 + pax_close_userland();
1687 +
1688 *uval = val;
1689 return ret;
1690 }
1691 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1692 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1693 return -EFAULT;
1694
1695 + pax_open_userland();
1696 +
1697 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1698 "1: " TUSER(ldr) " %1, [%4]\n"
1699 " teq %1, %2\n"
1700 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1701 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1702 : "cc", "memory");
1703
1704 + pax_close_userland();
1705 +
1706 *uval = val;
1707 return ret;
1708 }
1709 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1710 return -EFAULT;
1711
1712 pagefault_disable(); /* implies preempt_disable() */
1713 + pax_open_userland();
1714
1715 switch (op) {
1716 case FUTEX_OP_SET:
1717 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1718 ret = -ENOSYS;
1719 }
1720
1721 + pax_close_userland();
1722 pagefault_enable(); /* subsumes preempt_enable() */
1723
1724 if (!ret) {
1725 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1726 index 83eb2f7..ed77159 100644
1727 --- a/arch/arm/include/asm/kmap_types.h
1728 +++ b/arch/arm/include/asm/kmap_types.h
1729 @@ -4,6 +4,6 @@
1730 /*
1731 * This is the "bare minimum". AIO seems to require this.
1732 */
1733 -#define KM_TYPE_NR 16
1734 +#define KM_TYPE_NR 17
1735
1736 #endif
1737 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1738 index 9e614a1..3302cca 100644
1739 --- a/arch/arm/include/asm/mach/dma.h
1740 +++ b/arch/arm/include/asm/mach/dma.h
1741 @@ -22,7 +22,7 @@ struct dma_ops {
1742 int (*residue)(unsigned int, dma_t *); /* optional */
1743 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1744 const char *type;
1745 -};
1746 +} __do_const;
1747
1748 struct dma_struct {
1749 void *addr; /* single DMA address */
1750 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1751 index 2fe141f..192dc01 100644
1752 --- a/arch/arm/include/asm/mach/map.h
1753 +++ b/arch/arm/include/asm/mach/map.h
1754 @@ -27,13 +27,16 @@ struct map_desc {
1755 #define MT_MINICLEAN 6
1756 #define MT_LOW_VECTORS 7
1757 #define MT_HIGH_VECTORS 8
1758 -#define MT_MEMORY 9
1759 +#define MT_MEMORY_RWX 9
1760 #define MT_ROM 10
1761 -#define MT_MEMORY_NONCACHED 11
1762 +#define MT_MEMORY_NONCACHED_RX 11
1763 #define MT_MEMORY_DTCM 12
1764 #define MT_MEMORY_ITCM 13
1765 #define MT_MEMORY_SO 14
1766 #define MT_MEMORY_DMA_READY 15
1767 +#define MT_MEMORY_RW 16
1768 +#define MT_MEMORY_RX 17
1769 +#define MT_MEMORY_NONCACHED_RW 18
1770
1771 #ifdef CONFIG_MMU
1772 extern void iotable_init(struct map_desc *, int);
1773 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1774 index 12f71a1..04e063c 100644
1775 --- a/arch/arm/include/asm/outercache.h
1776 +++ b/arch/arm/include/asm/outercache.h
1777 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1778 #endif
1779 void (*set_debug)(unsigned long);
1780 void (*resume)(void);
1781 -};
1782 +} __no_const;
1783
1784 #ifdef CONFIG_OUTER_CACHE
1785
1786 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1787 index 812a494..71fc0b6 100644
1788 --- a/arch/arm/include/asm/page.h
1789 +++ b/arch/arm/include/asm/page.h
1790 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1791 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1792 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1793 unsigned long vaddr, struct vm_area_struct *vma);
1794 -};
1795 +} __no_const;
1796
1797 #ifdef MULTI_USER
1798 extern struct cpu_user_fns cpu_user;
1799 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1800 index 943504f..c37a730 100644
1801 --- a/arch/arm/include/asm/pgalloc.h
1802 +++ b/arch/arm/include/asm/pgalloc.h
1803 @@ -17,6 +17,7 @@
1804 #include <asm/processor.h>
1805 #include <asm/cacheflush.h>
1806 #include <asm/tlbflush.h>
1807 +#include <asm/system_info.h>
1808
1809 #define check_pgt_cache() do { } while (0)
1810
1811 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1812 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1813 }
1814
1815 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1816 +{
1817 + pud_populate(mm, pud, pmd);
1818 +}
1819 +
1820 #else /* !CONFIG_ARM_LPAE */
1821
1822 /*
1823 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1824 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1825 #define pmd_free(mm, pmd) do { } while (0)
1826 #define pud_populate(mm,pmd,pte) BUG()
1827 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1828
1829 #endif /* CONFIG_ARM_LPAE */
1830
1831 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1832 __free_page(pte);
1833 }
1834
1835 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1836 +{
1837 +#ifdef CONFIG_ARM_LPAE
1838 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1839 +#else
1840 + if (addr & SECTION_SIZE)
1841 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1842 + else
1843 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1844 +#endif
1845 + flush_pmd_entry(pmdp);
1846 +}
1847 +
1848 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1849 pmdval_t prot)
1850 {
1851 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1852 static inline void
1853 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1854 {
1855 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1856 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1857 }
1858 #define pmd_pgtable(pmd) pmd_page(pmd)
1859
1860 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1861 index 5cfba15..f415e1a 100644
1862 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1863 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1864 @@ -20,12 +20,15 @@
1865 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1866 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1867 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1868 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1869 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1870 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1871 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1872 +
1873 /*
1874 * - section
1875 */
1876 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1877 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1878 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1879 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1880 @@ -37,6 +40,7 @@
1881 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1882 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1883 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1884 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1885
1886 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1887 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1888 @@ -66,6 +70,7 @@
1889 * - extended small page/tiny page
1890 */
1891 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1892 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1893 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1894 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1895 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1896 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1897 index f97ee02..07f1be5 100644
1898 --- a/arch/arm/include/asm/pgtable-2level.h
1899 +++ b/arch/arm/include/asm/pgtable-2level.h
1900 @@ -125,6 +125,7 @@
1901 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1902 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1903 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1904 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1905
1906 /*
1907 * These are the memory types, defined to be compatible with
1908 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1909 index 18f5cef..25b8f43 100644
1910 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1911 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1912 @@ -41,6 +41,7 @@
1913 */
1914 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1915 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1916 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1917 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1918 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1919 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1920 @@ -71,6 +72,7 @@
1921 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1922 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1923 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1924 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1925 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1926
1927 /*
1928 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1929 index 86b8fe3..e25f975 100644
1930 --- a/arch/arm/include/asm/pgtable-3level.h
1931 +++ b/arch/arm/include/asm/pgtable-3level.h
1932 @@ -74,6 +74,7 @@
1933 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1934 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1935 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1936 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1937 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1938 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1939 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1940 @@ -82,6 +83,7 @@
1941 /*
1942 * To be used in assembly code with the upper page attributes.
1943 */
1944 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1945 #define L_PTE_XN_HIGH (1 << (54 - 32))
1946 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1947
1948 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1949 index 9bcd262..fba731c 100644
1950 --- a/arch/arm/include/asm/pgtable.h
1951 +++ b/arch/arm/include/asm/pgtable.h
1952 @@ -30,6 +30,9 @@
1953 #include <asm/pgtable-2level.h>
1954 #endif
1955
1956 +#define ktla_ktva(addr) (addr)
1957 +#define ktva_ktla(addr) (addr)
1958 +
1959 /*
1960 * Just any arbitrary offset to the start of the vmalloc VM area: the
1961 * current 8MB value just means that there will be a 8MB "hole" after the
1962 @@ -45,6 +48,9 @@
1963 #define LIBRARY_TEXT_START 0x0c000000
1964
1965 #ifndef __ASSEMBLY__
1966 +extern pteval_t __supported_pte_mask;
1967 +extern pmdval_t __supported_pmd_mask;
1968 +
1969 extern void __pte_error(const char *file, int line, pte_t);
1970 extern void __pmd_error(const char *file, int line, pmd_t);
1971 extern void __pgd_error(const char *file, int line, pgd_t);
1972 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1973 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1974 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1975
1976 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1977 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1978 +
1979 +#ifdef CONFIG_PAX_KERNEXEC
1980 +#include <asm/domain.h>
1981 +#include <linux/thread_info.h>
1982 +#include <linux/preempt.h>
1983 +#endif
1984 +
1985 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1986 +static inline int test_domain(int domain, int domaintype)
1987 +{
1988 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1989 +}
1990 +#endif
1991 +
1992 +#ifdef CONFIG_PAX_KERNEXEC
1993 +static inline unsigned long pax_open_kernel(void) {
1994 +#ifdef CONFIG_ARM_LPAE
1995 + /* TODO */
1996 +#else
1997 + preempt_disable();
1998 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1999 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2000 +#endif
2001 + return 0;
2002 +}
2003 +
2004 +static inline unsigned long pax_close_kernel(void) {
2005 +#ifdef CONFIG_ARM_LPAE
2006 + /* TODO */
2007 +#else
2008 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2009 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2010 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2011 + preempt_enable_no_resched();
2012 +#endif
2013 + return 0;
2014 +}
2015 +#else
2016 +static inline unsigned long pax_open_kernel(void) { return 0; }
2017 +static inline unsigned long pax_close_kernel(void) { return 0; }
2018 +#endif
2019 +
2020 /*
2021 * This is the lowest virtual address we can permit any user space
2022 * mapping to be mapped at. This is particularly important for
2023 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2024 /*
2025 * The pgprot_* and protection_map entries will be fixed up in runtime
2026 * to include the cachable and bufferable bits based on memory policy,
2027 - * as well as any architecture dependent bits like global/ASID and SMP
2028 - * shared mapping bits.
2029 + * as well as any architecture dependent bits like global/ASID, PXN,
2030 + * and SMP shared mapping bits.
2031 */
2032 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2033
2034 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2035 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2036 {
2037 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2038 - L_PTE_NONE | L_PTE_VALID;
2039 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2040 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2041 return pte;
2042 }
2043 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2044 index f3628fb..a0672dd 100644
2045 --- a/arch/arm/include/asm/proc-fns.h
2046 +++ b/arch/arm/include/asm/proc-fns.h
2047 @@ -75,7 +75,7 @@ extern struct processor {
2048 unsigned int suspend_size;
2049 void (*do_suspend)(void *);
2050 void (*do_resume)(void *);
2051 -} processor;
2052 +} __do_const processor;
2053
2054 #ifndef MULTI_CPU
2055 extern void cpu_proc_init(void);
2056 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2057 index 06e7d50..8a8e251 100644
2058 --- a/arch/arm/include/asm/processor.h
2059 +++ b/arch/arm/include/asm/processor.h
2060 @@ -65,9 +65,8 @@ struct thread_struct {
2061 regs->ARM_cpsr |= PSR_ENDSTATE; \
2062 regs->ARM_pc = pc & ~1; /* pc */ \
2063 regs->ARM_sp = sp; /* sp */ \
2064 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2065 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2066 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2067 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2068 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2069 nommu_start_thread(regs); \
2070 })
2071
2072 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2073 index ce0dbe7..c085b6f 100644
2074 --- a/arch/arm/include/asm/psci.h
2075 +++ b/arch/arm/include/asm/psci.h
2076 @@ -29,7 +29,7 @@ struct psci_operations {
2077 int (*cpu_off)(struct psci_power_state state);
2078 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2079 int (*migrate)(unsigned long cpuid);
2080 -};
2081 +} __no_const;
2082
2083 extern struct psci_operations psci_ops;
2084
2085 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2086 index d3a22be..3a69ad5 100644
2087 --- a/arch/arm/include/asm/smp.h
2088 +++ b/arch/arm/include/asm/smp.h
2089 @@ -107,7 +107,7 @@ struct smp_operations {
2090 int (*cpu_disable)(unsigned int cpu);
2091 #endif
2092 #endif
2093 -};
2094 +} __no_const;
2095
2096 /*
2097 * set platform specific SMP operations
2098 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2099 index 1995d1a..76693a2 100644
2100 --- a/arch/arm/include/asm/thread_info.h
2101 +++ b/arch/arm/include/asm/thread_info.h
2102 @@ -77,9 +77,9 @@ struct thread_info {
2103 .flags = 0, \
2104 .preempt_count = INIT_PREEMPT_COUNT, \
2105 .addr_limit = KERNEL_DS, \
2106 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2107 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2108 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2109 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2110 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2111 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2112 .restart_block = { \
2113 .fn = do_no_restart_syscall, \
2114 }, \
2115 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2116 #define TIF_SYSCALL_AUDIT 9
2117 #define TIF_SYSCALL_TRACEPOINT 10
2118 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2119 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2120 +/* within 8 bits of TIF_SYSCALL_TRACE
2121 + * to meet flexible second operand requirements
2122 + */
2123 +#define TIF_GRSEC_SETXID 12
2124 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2125 #define TIF_USING_IWMMXT 17
2126 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2127 #define TIF_RESTORE_SIGMASK 20
2128 @@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2129 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2130 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2131 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2132 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2133
2134 /* Checks for any syscall work in entry-common.S */
2135 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2136 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2137 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2138
2139 /*
2140 * Change these and you break ASM code in entry-common.S
2141 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2142 index 7e1f760..d42d7f8 100644
2143 --- a/arch/arm/include/asm/uaccess.h
2144 +++ b/arch/arm/include/asm/uaccess.h
2145 @@ -18,6 +18,7 @@
2146 #include <asm/domain.h>
2147 #include <asm/unified.h>
2148 #include <asm/compiler.h>
2149 +#include <asm/pgtable.h>
2150
2151 #define VERIFY_READ 0
2152 #define VERIFY_WRITE 1
2153 @@ -63,11 +64,35 @@ extern int __put_user_bad(void);
2154 static inline void set_fs(mm_segment_t fs)
2155 {
2156 current_thread_info()->addr_limit = fs;
2157 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2158 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2159 }
2160
2161 #define segment_eq(a,b) ((a) == (b))
2162
2163 +static inline void pax_open_userland(void)
2164 +{
2165 +
2166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2167 + if (segment_eq(get_fs(), USER_DS)) {
2168 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2169 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2170 + }
2171 +#endif
2172 +
2173 +}
2174 +
2175 +static inline void pax_close_userland(void)
2176 +{
2177 +
2178 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2179 + if (segment_eq(get_fs(), USER_DS)) {
2180 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2181 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2182 + }
2183 +#endif
2184 +
2185 +}
2186 +
2187 #define __addr_ok(addr) ({ \
2188 unsigned long flag; \
2189 __asm__("cmp %2, %0; movlo %0, #0" \
2190 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2191
2192 #define get_user(x,p) \
2193 ({ \
2194 + int __e; \
2195 might_fault(); \
2196 - __get_user_check(x,p); \
2197 + pax_open_userland(); \
2198 + __e = __get_user_check(x,p); \
2199 + pax_close_userland(); \
2200 + __e; \
2201 })
2202
2203 extern int __put_user_1(void *, unsigned int);
2204 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2205
2206 #define put_user(x,p) \
2207 ({ \
2208 + int __e; \
2209 might_fault(); \
2210 - __put_user_check(x,p); \
2211 + pax_open_userland(); \
2212 + __e = __put_user_check(x,p); \
2213 + pax_close_userland(); \
2214 + __e; \
2215 })
2216
2217 #else /* CONFIG_MMU */
2218 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2219 #define __get_user(x,ptr) \
2220 ({ \
2221 long __gu_err = 0; \
2222 + pax_open_userland(); \
2223 __get_user_err((x),(ptr),__gu_err); \
2224 + pax_close_userland(); \
2225 __gu_err; \
2226 })
2227
2228 #define __get_user_error(x,ptr,err) \
2229 ({ \
2230 + pax_open_userland(); \
2231 __get_user_err((x),(ptr),err); \
2232 + pax_close_userland(); \
2233 (void) 0; \
2234 })
2235
2236 @@ -312,13 +349,17 @@ do { \
2237 #define __put_user(x,ptr) \
2238 ({ \
2239 long __pu_err = 0; \
2240 + pax_open_userland(); \
2241 __put_user_err((x),(ptr),__pu_err); \
2242 + pax_close_userland(); \
2243 __pu_err; \
2244 })
2245
2246 #define __put_user_error(x,ptr,err) \
2247 ({ \
2248 + pax_open_userland(); \
2249 __put_user_err((x),(ptr),err); \
2250 + pax_close_userland(); \
2251 (void) 0; \
2252 })
2253
2254 @@ -418,11 +459,44 @@ do { \
2255
2256
2257 #ifdef CONFIG_MMU
2258 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2259 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2261 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2262 +
2263 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2264 +{
2265 + unsigned long ret;
2266 +
2267 + check_object_size(to, n, false);
2268 + pax_open_userland();
2269 + ret = ___copy_from_user(to, from, n);
2270 + pax_close_userland();
2271 + return ret;
2272 +}
2273 +
2274 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2275 +{
2276 + unsigned long ret;
2277 +
2278 + check_object_size(from, n, true);
2279 + pax_open_userland();
2280 + ret = ___copy_to_user(to, from, n);
2281 + pax_close_userland();
2282 + return ret;
2283 +}
2284 +
2285 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2286 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2287 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2288 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2289 +
2290 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2291 +{
2292 + unsigned long ret;
2293 + pax_open_userland();
2294 + ret = ___clear_user(addr, n);
2295 + pax_close_userland();
2296 + return ret;
2297 +}
2298 +
2299 #else
2300 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2301 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2302 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2303
2304 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2305 {
2306 + if ((long)n < 0)
2307 + return n;
2308 +
2309 if (access_ok(VERIFY_READ, from, n))
2310 n = __copy_from_user(to, from, n);
2311 else /* security hole - plug it */
2312 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2313
2314 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2315 {
2316 + if ((long)n < 0)
2317 + return n;
2318 +
2319 if (access_ok(VERIFY_WRITE, to, n))
2320 n = __copy_to_user(to, from, n);
2321 return n;
2322 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2323 index 96ee092..37f1844 100644
2324 --- a/arch/arm/include/uapi/asm/ptrace.h
2325 +++ b/arch/arm/include/uapi/asm/ptrace.h
2326 @@ -73,7 +73,7 @@
2327 * ARMv7 groups of PSR bits
2328 */
2329 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2330 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2331 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2332 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2333 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2334
2335 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2336 index 60d3b73..e5a0f22 100644
2337 --- a/arch/arm/kernel/armksyms.c
2338 +++ b/arch/arm/kernel/armksyms.c
2339 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2340
2341 /* networking */
2342 EXPORT_SYMBOL(csum_partial);
2343 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2344 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2345 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2346 EXPORT_SYMBOL(__csum_ipv6_magic);
2347
2348 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2349 #ifdef CONFIG_MMU
2350 EXPORT_SYMBOL(copy_page);
2351
2352 -EXPORT_SYMBOL(__copy_from_user);
2353 -EXPORT_SYMBOL(__copy_to_user);
2354 -EXPORT_SYMBOL(__clear_user);
2355 +EXPORT_SYMBOL(___copy_from_user);
2356 +EXPORT_SYMBOL(___copy_to_user);
2357 +EXPORT_SYMBOL(___clear_user);
2358
2359 EXPORT_SYMBOL(__get_user_1);
2360 EXPORT_SYMBOL(__get_user_2);
2361 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2362 index 582b405..50351b7 100644
2363 --- a/arch/arm/kernel/entry-armv.S
2364 +++ b/arch/arm/kernel/entry-armv.S
2365 @@ -47,6 +47,87 @@
2366 9997:
2367 .endm
2368
2369 + .macro pax_enter_kernel
2370 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2371 + @ make aligned space for saved DACR
2372 + sub sp, sp, #8
2373 + @ save regs
2374 + stmdb sp!, {r1, r2}
2375 + @ read DACR from cpu_domain into r1
2376 + mov r2, sp
2377 + @ assume 8K pages, since we have to split the immediate in two
2378 + bic r2, r2, #(0x1fc0)
2379 + bic r2, r2, #(0x3f)
2380 + ldr r1, [r2, #TI_CPU_DOMAIN]
2381 + @ store old DACR on stack
2382 + str r1, [sp, #8]
2383 +#ifdef CONFIG_PAX_KERNEXEC
2384 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2385 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2386 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2387 +#endif
2388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2389 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2390 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2391 +#endif
2392 + @ write r1 to current_thread_info()->cpu_domain
2393 + str r1, [r2, #TI_CPU_DOMAIN]
2394 + @ write r1 to DACR
2395 + mcr p15, 0, r1, c3, c0, 0
2396 + @ instruction sync
2397 + instr_sync
2398 + @ restore regs
2399 + ldmia sp!, {r1, r2}
2400 +#endif
2401 + .endm
2402 +
2403 + .macro pax_open_userland
2404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2405 + @ save regs
2406 + stmdb sp!, {r0, r1}
2407 + @ read DACR from cpu_domain into r1
2408 + mov r0, sp
2409 + @ assume 8K pages, since we have to split the immediate in two
2410 + bic r0, r0, #(0x1fc0)
2411 + bic r0, r0, #(0x3f)
2412 + ldr r1, [r0, #TI_CPU_DOMAIN]
2413 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2414 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2415 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2416 + @ write r1 to current_thread_info()->cpu_domain
2417 + str r1, [r0, #TI_CPU_DOMAIN]
2418 + @ write r1 to DACR
2419 + mcr p15, 0, r1, c3, c0, 0
2420 + @ instruction sync
2421 + instr_sync
2422 + @ restore regs
2423 + ldmia sp!, {r0, r1}
2424 +#endif
2425 + .endm
2426 +
2427 + .macro pax_close_userland
2428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2429 + @ save regs
2430 + stmdb sp!, {r0, r1}
2431 + @ read DACR from cpu_domain into r1
2432 + mov r0, sp
2433 + @ assume 8K pages, since we have to split the immediate in two
2434 + bic r0, r0, #(0x1fc0)
2435 + bic r0, r0, #(0x3f)
2436 + ldr r1, [r0, #TI_CPU_DOMAIN]
2437 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2438 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2439 + @ write r1 to current_thread_info()->cpu_domain
2440 + str r1, [r0, #TI_CPU_DOMAIN]
2441 + @ write r1 to DACR
2442 + mcr p15, 0, r1, c3, c0, 0
2443 + @ instruction sync
2444 + instr_sync
2445 + @ restore regs
2446 + ldmia sp!, {r0, r1}
2447 +#endif
2448 + .endm
2449 +
2450 .macro pabt_helper
2451 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2452 #ifdef MULTI_PABORT
2453 @@ -89,11 +170,15 @@
2454 * Invalid mode handlers
2455 */
2456 .macro inv_entry, reason
2457 +
2458 + pax_enter_kernel
2459 +
2460 sub sp, sp, #S_FRAME_SIZE
2461 ARM( stmib sp, {r1 - lr} )
2462 THUMB( stmia sp, {r0 - r12} )
2463 THUMB( str sp, [sp, #S_SP] )
2464 THUMB( str lr, [sp, #S_LR] )
2465 +
2466 mov r1, #\reason
2467 .endm
2468
2469 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2470 .macro svc_entry, stack_hole=0
2471 UNWIND(.fnstart )
2472 UNWIND(.save {r0 - pc} )
2473 +
2474 + pax_enter_kernel
2475 +
2476 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2477 +
2478 #ifdef CONFIG_THUMB2_KERNEL
2479 SPFIX( str r0, [sp] ) @ temporarily saved
2480 SPFIX( mov r0, sp )
2481 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2482 ldmia r0, {r3 - r5}
2483 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2484 mov r6, #-1 @ "" "" "" ""
2485 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2486 + @ offset sp by 8 as done in pax_enter_kernel
2487 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2488 +#else
2489 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2490 +#endif
2491 SPFIX( addeq r2, r2, #4 )
2492 str r3, [sp, #-4]! @ save the "real" r0 copied
2493 @ from the exception stack
2494 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2495 .macro usr_entry
2496 UNWIND(.fnstart )
2497 UNWIND(.cantunwind ) @ don't unwind the user space
2498 +
2499 + pax_enter_kernel_user
2500 +
2501 sub sp, sp, #S_FRAME_SIZE
2502 ARM( stmib sp, {r1 - r12} )
2503 THUMB( stmia sp, {r0 - r12} )
2504 @@ -414,7 +511,9 @@ __und_usr:
2505 tst r3, #PSR_T_BIT @ Thumb mode?
2506 bne __und_usr_thumb
2507 sub r4, r2, #4 @ ARM instr at LR - 4
2508 + pax_open_userland
2509 1: ldrt r0, [r4]
2510 + pax_close_userland
2511 #ifdef CONFIG_CPU_ENDIAN_BE8
2512 rev r0, r0 @ little endian instruction
2513 #endif
2514 @@ -449,10 +548,14 @@ __und_usr_thumb:
2515 */
2516 .arch armv6t2
2517 #endif
2518 + pax_open_userland
2519 2: ldrht r5, [r4]
2520 + pax_close_userland
2521 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2522 blo __und_usr_fault_16 @ 16bit undefined instruction
2523 + pax_open_userland
2524 3: ldrht r0, [r2]
2525 + pax_close_userland
2526 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2527 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2528 orr r0, r0, r5, lsl #16
2529 @@ -690,7 +793,7 @@ ENTRY(__switch_to)
2530 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2531 THUMB( str sp, [ip], #4 )
2532 THUMB( str lr, [ip], #4 )
2533 -#ifdef CONFIG_CPU_USE_DOMAINS
2534 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2535 ldr r6, [r2, #TI_CPU_DOMAIN]
2536 #endif
2537 set_tls r3, r4, r5
2538 @@ -699,7 +802,7 @@ ENTRY(__switch_to)
2539 ldr r8, =__stack_chk_guard
2540 ldr r7, [r7, #TSK_STACK_CANARY]
2541 #endif
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2545 #endif
2546 mov r5, r0
2547 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2548 index bc5bc0a..d0998ca 100644
2549 --- a/arch/arm/kernel/entry-common.S
2550 +++ b/arch/arm/kernel/entry-common.S
2551 @@ -10,18 +10,46 @@
2552
2553 #include <asm/unistd.h>
2554 #include <asm/ftrace.h>
2555 +#include <asm/domain.h>
2556 #include <asm/unwind.h>
2557
2558 +#include "entry-header.S"
2559 +
2560 #ifdef CONFIG_NEED_RET_TO_USER
2561 #include <mach/entry-macro.S>
2562 #else
2563 .macro arch_ret_to_user, tmp1, tmp2
2564 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2565 + @ save regs
2566 + stmdb sp!, {r1, r2}
2567 + @ read DACR from cpu_domain into r1
2568 + mov r2, sp
2569 + @ assume 8K pages, since we have to split the immediate in two
2570 + bic r2, r2, #(0x1fc0)
2571 + bic r2, r2, #(0x3f)
2572 + ldr r1, [r2, #TI_CPU_DOMAIN]
2573 +#ifdef CONFIG_PAX_KERNEXEC
2574 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2575 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2576 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2577 +#endif
2578 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2579 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2580 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2581 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2582 +#endif
2583 + @ write r1 to current_thread_info()->cpu_domain
2584 + str r1, [r2, #TI_CPU_DOMAIN]
2585 + @ write r1 to DACR
2586 + mcr p15, 0, r1, c3, c0, 0
2587 + @ instruction sync
2588 + instr_sync
2589 + @ restore regs
2590 + ldmia sp!, {r1, r2}
2591 +#endif
2592 .endm
2593 #endif
2594
2595 -#include "entry-header.S"
2596 -
2597 -
2598 .align 5
2599 /*
2600 * This is the fast syscall return path. We do as little as
2601 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2602
2603 .align 5
2604 ENTRY(vector_swi)
2605 +
2606 sub sp, sp, #S_FRAME_SIZE
2607 stmia sp, {r0 - r12} @ Calling r0 - r12
2608 ARM( add r8, sp, #S_PC )
2609 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2610 ldr scno, [lr, #-4] @ get SWI instruction
2611 #endif
2612
2613 + /*
2614 + * do this here to avoid a performance hit of wrapping the code above
2615 + * that directly dereferences userland to parse the SWI instruction
2616 + */
2617 + pax_enter_kernel_user
2618 +
2619 #ifdef CONFIG_ALIGNMENT_TRAP
2620 ldr ip, __cr_alignment
2621 ldr ip, [ip]
2622 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2623 index 160f337..db67ee4 100644
2624 --- a/arch/arm/kernel/entry-header.S
2625 +++ b/arch/arm/kernel/entry-header.S
2626 @@ -73,6 +73,60 @@
2627 msr cpsr_c, \rtemp @ switch back to the SVC mode
2628 .endm
2629
2630 + .macro pax_enter_kernel_user
2631 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2632 + @ save regs
2633 + stmdb sp!, {r0, r1}
2634 + @ read DACR from cpu_domain into r1
2635 + mov r0, sp
2636 + @ assume 8K pages, since we have to split the immediate in two
2637 + bic r0, r0, #(0x1fc0)
2638 + bic r0, r0, #(0x3f)
2639 + ldr r1, [r0, #TI_CPU_DOMAIN]
2640 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2641 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2642 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2643 +#endif
2644 +#ifdef CONFIG_PAX_KERNEXEC
2645 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2646 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2647 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2648 +#endif
2649 + @ write r1 to current_thread_info()->cpu_domain
2650 + str r1, [r0, #TI_CPU_DOMAIN]
2651 + @ write r1 to DACR
2652 + mcr p15, 0, r1, c3, c0, 0
2653 + @ instruction sync
2654 + instr_sync
2655 + @ restore regs
2656 + ldmia sp!, {r0, r1}
2657 +#endif
2658 + .endm
2659 +
2660 + .macro pax_exit_kernel
2661 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2662 + @ save regs
2663 + stmdb sp!, {r0, r1}
2664 + @ read old DACR from stack into r1
2665 + ldr r1, [sp, #(8 + S_SP)]
2666 + sub r1, r1, #8
2667 + ldr r1, [r1]
2668 +
2669 + @ write r1 to current_thread_info()->cpu_domain
2670 + mov r0, sp
2671 + @ assume 8K pages, since we have to split the immediate in two
2672 + bic r0, r0, #(0x1fc0)
2673 + bic r0, r0, #(0x3f)
2674 + str r1, [r0, #TI_CPU_DOMAIN]
2675 + @ write r1 to DACR
2676 + mcr p15, 0, r1, c3, c0, 0
2677 + @ instruction sync
2678 + instr_sync
2679 + @ restore regs
2680 + ldmia sp!, {r0, r1}
2681 +#endif
2682 + .endm
2683 +
2684 #ifndef CONFIG_THUMB2_KERNEL
2685 .macro svc_exit, rpsr, irq = 0
2686 .if \irq != 0
2687 @@ -92,6 +146,9 @@
2688 blne trace_hardirqs_off
2689 #endif
2690 .endif
2691 +
2692 + pax_exit_kernel
2693 +
2694 msr spsr_cxsf, \rpsr
2695 #if defined(CONFIG_CPU_V6)
2696 ldr r0, [sp]
2697 @@ -155,6 +212,9 @@
2698 blne trace_hardirqs_off
2699 #endif
2700 .endif
2701 +
2702 + pax_exit_kernel
2703 +
2704 ldr lr, [sp, #S_SP] @ top of the stack
2705 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2706 clrex @ clear the exclusive monitor
2707 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2708 index 2adda11..7fbe958 100644
2709 --- a/arch/arm/kernel/fiq.c
2710 +++ b/arch/arm/kernel/fiq.c
2711 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2712 #if defined(CONFIG_CPU_USE_DOMAINS)
2713 memcpy((void *)0xffff001c, start, length);
2714 #else
2715 + pax_open_kernel();
2716 memcpy(vectors_page + 0x1c, start, length);
2717 + pax_close_kernel();
2718 #endif
2719 flush_icache_range(0xffff001c, 0xffff001c + length);
2720 if (!vectors_high())
2721 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2722 index 8bac553..caee108 100644
2723 --- a/arch/arm/kernel/head.S
2724 +++ b/arch/arm/kernel/head.S
2725 @@ -52,7 +52,9 @@
2726 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2727
2728 .macro pgtbl, rd, phys
2729 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2730 + mov \rd, #TEXT_OFFSET
2731 + sub \rd, #PG_DIR_SIZE
2732 + add \rd, \rd, \phys
2733 .endm
2734
2735 /*
2736 @@ -434,7 +436,7 @@ __enable_mmu:
2737 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2738 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2739 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2740 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2741 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2742 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2743 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2744 #endif
2745 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2746 index 1fd749e..47adb08 100644
2747 --- a/arch/arm/kernel/hw_breakpoint.c
2748 +++ b/arch/arm/kernel/hw_breakpoint.c
2749 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2750 return NOTIFY_OK;
2751 }
2752
2753 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2754 +static struct notifier_block dbg_reset_nb = {
2755 .notifier_call = dbg_reset_notify,
2756 };
2757
2758 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2759 index 1e9be5d..03edbc2 100644
2760 --- a/arch/arm/kernel/module.c
2761 +++ b/arch/arm/kernel/module.c
2762 @@ -37,12 +37,37 @@
2763 #endif
2764
2765 #ifdef CONFIG_MMU
2766 -void *module_alloc(unsigned long size)
2767 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2768 {
2769 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2770 + return NULL;
2771 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2772 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2773 + GFP_KERNEL, prot, -1,
2774 __builtin_return_address(0));
2775 }
2776 +
2777 +void *module_alloc(unsigned long size)
2778 +{
2779 +
2780 +#ifdef CONFIG_PAX_KERNEXEC
2781 + return __module_alloc(size, PAGE_KERNEL);
2782 +#else
2783 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2784 +#endif
2785 +
2786 +}
2787 +
2788 +#ifdef CONFIG_PAX_KERNEXEC
2789 +void module_free_exec(struct module *mod, void *module_region)
2790 +{
2791 + module_free(mod, module_region);
2792 +}
2793 +
2794 +void *module_alloc_exec(unsigned long size)
2795 +{
2796 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2797 +}
2798 +#endif
2799 #endif
2800
2801 int
2802 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2803 index 07314af..c46655c 100644
2804 --- a/arch/arm/kernel/patch.c
2805 +++ b/arch/arm/kernel/patch.c
2806 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2807 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2808 int size;
2809
2810 + pax_open_kernel();
2811 if (thumb2 && __opcode_is_thumb16(insn)) {
2812 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2813 size = sizeof(u16);
2814 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2815 *(u32 *)addr = insn;
2816 size = sizeof(u32);
2817 }
2818 + pax_close_kernel();
2819
2820 flush_icache_range((uintptr_t)(addr),
2821 (uintptr_t)(addr) + size);
2822 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2823 index 1f2740e..b36e225 100644
2824 --- a/arch/arm/kernel/perf_event_cpu.c
2825 +++ b/arch/arm/kernel/perf_event_cpu.c
2826 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2827 return NOTIFY_OK;
2828 }
2829
2830 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2831 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2832 .notifier_call = cpu_pmu_notify,
2833 };
2834
2835 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2836 index 6e8931c..82ec6a5 100644
2837 --- a/arch/arm/kernel/process.c
2838 +++ b/arch/arm/kernel/process.c
2839 @@ -28,7 +28,6 @@
2840 #include <linux/tick.h>
2841 #include <linux/utsname.h>
2842 #include <linux/uaccess.h>
2843 -#include <linux/random.h>
2844 #include <linux/hw_breakpoint.h>
2845 #include <linux/cpuidle.h>
2846 #include <linux/leds.h>
2847 @@ -223,6 +222,7 @@ void machine_power_off(void)
2848
2849 if (pm_power_off)
2850 pm_power_off();
2851 + BUG();
2852 }
2853
2854 /*
2855 @@ -236,7 +236,7 @@ void machine_power_off(void)
2856 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2857 * to use. Implementing such co-ordination would be essentially impossible.
2858 */
2859 -void machine_restart(char *cmd)
2860 +__noreturn void machine_restart(char *cmd)
2861 {
2862 smp_send_stop();
2863
2864 @@ -258,8 +258,8 @@ void __show_regs(struct pt_regs *regs)
2865
2866 show_regs_print_info(KERN_DEFAULT);
2867
2868 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2869 - print_symbol("LR is at %s\n", regs->ARM_lr);
2870 + printk("PC is at %pA\n", instruction_pointer(regs));
2871 + printk("LR is at %pA\n", regs->ARM_lr);
2872 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2873 "sp : %08lx ip : %08lx fp : %08lx\n",
2874 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2875 @@ -426,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2876 return 0;
2877 }
2878
2879 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2880 -{
2881 - unsigned long range_end = mm->brk + 0x02000000;
2882 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2883 -}
2884 -
2885 #ifdef CONFIG_MMU
2886 /*
2887 * The vectors page is always readable from user space for the
2888 @@ -441,12 +435,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
2889 static struct vm_area_struct gate_vma = {
2890 .vm_start = 0xffff0000,
2891 .vm_end = 0xffff0000 + PAGE_SIZE,
2892 - .vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC,
2893 + .vm_flags = VM_NONE,
2894 };
2895
2896 static int __init gate_vma_init(void)
2897 {
2898 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2899 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2900 return 0;
2901 }
2902 arch_initcall(gate_vma_init);
2903 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2904 index 3653164..d83e55d 100644
2905 --- a/arch/arm/kernel/psci.c
2906 +++ b/arch/arm/kernel/psci.c
2907 @@ -24,7 +24,7 @@
2908 #include <asm/opcodes-virt.h>
2909 #include <asm/psci.h>
2910
2911 -struct psci_operations psci_ops;
2912 +struct psci_operations psci_ops __read_only;
2913
2914 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2915
2916 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2917 index 03deeff..741ce88 100644
2918 --- a/arch/arm/kernel/ptrace.c
2919 +++ b/arch/arm/kernel/ptrace.c
2920 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2921 return current_thread_info()->syscall;
2922 }
2923
2924 +#ifdef CONFIG_GRKERNSEC_SETXID
2925 +extern void gr_delayed_cred_worker(void);
2926 +#endif
2927 +
2928 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2929 {
2930 current_thread_info()->syscall = scno;
2931
2932 +#ifdef CONFIG_GRKERNSEC_SETXID
2933 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2934 + gr_delayed_cred_worker();
2935 +#endif
2936 +
2937 /* Do the secure computing check first; failures should be fast. */
2938 if (secure_computing(scno) == -1)
2939 return -1;
2940 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2941 index b4b1d39..efdc9be 100644
2942 --- a/arch/arm/kernel/setup.c
2943 +++ b/arch/arm/kernel/setup.c
2944 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2945 unsigned int elf_hwcap __read_mostly;
2946 EXPORT_SYMBOL(elf_hwcap);
2947
2948 +pteval_t __supported_pte_mask __read_only;
2949 +pmdval_t __supported_pmd_mask __read_only;
2950
2951 #ifdef MULTI_CPU
2952 -struct processor processor __read_mostly;
2953 +struct processor processor;
2954 #endif
2955 #ifdef MULTI_TLB
2956 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2957 +struct cpu_tlb_fns cpu_tlb __read_only;
2958 #endif
2959 #ifdef MULTI_USER
2960 -struct cpu_user_fns cpu_user __read_mostly;
2961 +struct cpu_user_fns cpu_user __read_only;
2962 #endif
2963 #ifdef MULTI_CACHE
2964 -struct cpu_cache_fns cpu_cache __read_mostly;
2965 +struct cpu_cache_fns cpu_cache __read_only;
2966 #endif
2967 #ifdef CONFIG_OUTER_CACHE
2968 -struct outer_cache_fns outer_cache __read_mostly;
2969 +struct outer_cache_fns outer_cache __read_only;
2970 EXPORT_SYMBOL(outer_cache);
2971 #endif
2972
2973 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2974 asm("mrc p15, 0, %0, c0, c1, 4"
2975 : "=r" (mmfr0));
2976 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2977 - (mmfr0 & 0x000000f0) >= 0x00000030)
2978 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2979 cpu_arch = CPU_ARCH_ARMv7;
2980 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2981 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2982 + __supported_pte_mask |= L_PTE_PXN;
2983 + __supported_pmd_mask |= PMD_PXNTABLE;
2984 + }
2985 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2986 (mmfr0 & 0x000000f0) == 0x00000020)
2987 cpu_arch = CPU_ARCH_ARMv6;
2988 else
2989 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
2990 __cpu_architecture = __get_cpu_architecture();
2991
2992 #ifdef MULTI_CPU
2993 - processor = *list->proc;
2994 + memcpy((void *)&processor, list->proc, sizeof processor);
2995 #endif
2996 #ifdef MULTI_TLB
2997 cpu_tlb = *list->tlb;
2998 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2999 index 296786b..a8d4dd5 100644
3000 --- a/arch/arm/kernel/signal.c
3001 +++ b/arch/arm/kernel/signal.c
3002 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3003 __put_user(sigreturn_codes[idx+1], rc+1))
3004 return 1;
3005
3006 - if (cpsr & MODE32_BIT) {
3007 - /*
3008 - * 32-bit code can use the new high-page
3009 - * signal return code support.
3010 - */
3011 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3012 - } else {
3013 - /*
3014 - * Ensure that the instruction cache sees
3015 - * the return code written onto the stack.
3016 - */
3017 - flush_icache_range((unsigned long)rc,
3018 - (unsigned long)(rc + 2));
3019 + /*
3020 + * Ensure that the instruction cache sees
3021 + * the return code written onto the stack.
3022 + */
3023 + flush_icache_range((unsigned long)rc,
3024 + (unsigned long)(rc + 2));
3025
3026 - retcode = ((unsigned long)rc) + thumb;
3027 - }
3028 + retcode = ((unsigned long)rc) + thumb;
3029 }
3030
3031 regs->ARM_r0 = map_sig(ksig->sig);
3032 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3033 index 5919eb4..b5d6dfe 100644
3034 --- a/arch/arm/kernel/smp.c
3035 +++ b/arch/arm/kernel/smp.c
3036 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3037
3038 static DECLARE_COMPLETION(cpu_running);
3039
3040 -static struct smp_operations smp_ops;
3041 +static struct smp_operations smp_ops __read_only;
3042
3043 void __init smp_set_ops(struct smp_operations *ops)
3044 {
3045 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3046 index 18b32e8..b0c8dca 100644
3047 --- a/arch/arm/kernel/traps.c
3048 +++ b/arch/arm/kernel/traps.c
3049 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3050 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3051 {
3052 #ifdef CONFIG_KALLSYMS
3053 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3054 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3055 #else
3056 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3057 #endif
3058 @@ -259,6 +259,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3059 static int die_owner = -1;
3060 static unsigned int die_nest_count;
3061
3062 +extern void gr_handle_kernel_exploit(void);
3063 +
3064 static unsigned long oops_begin(void)
3065 {
3066 int cpu;
3067 @@ -301,6 +303,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3068 panic("Fatal exception in interrupt");
3069 if (panic_on_oops)
3070 panic("Fatal exception");
3071 +
3072 + gr_handle_kernel_exploit();
3073 +
3074 if (signr)
3075 do_exit(signr);
3076 }
3077 @@ -594,7 +599,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3078 * The user helper at 0xffff0fe0 must be used instead.
3079 * (see entry-armv.S for details)
3080 */
3081 + pax_open_kernel();
3082 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3083 + pax_close_kernel();
3084 }
3085 return 0;
3086
3087 @@ -834,13 +841,10 @@ void __init early_trap_init(void *vectors_base)
3088 */
3089 kuser_get_tls_init(vectors);
3090
3091 - /*
3092 - * Copy signal return handlers into the vector page, and
3093 - * set sigreturn to be a pointer to these.
3094 - */
3095 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3096 - sigreturn_codes, sizeof(sigreturn_codes));
3097 -
3098 flush_icache_range(vectors, vectors + PAGE_SIZE);
3099 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3100 +
3101 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3102 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3103 +#endif
3104 +
3105 }
3106 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3107 index a871b8e..123b00a 100644
3108 --- a/arch/arm/kernel/vmlinux.lds.S
3109 +++ b/arch/arm/kernel/vmlinux.lds.S
3110 @@ -8,7 +8,11 @@
3111 #include <asm/thread_info.h>
3112 #include <asm/memory.h>
3113 #include <asm/page.h>
3114 -
3115 +
3116 +#ifdef CONFIG_PAX_KERNEXEC
3117 +#include <asm/pgtable.h>
3118 +#endif
3119 +
3120 #define PROC_INFO \
3121 . = ALIGN(4); \
3122 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3123 @@ -94,6 +98,11 @@ SECTIONS
3124 _text = .;
3125 HEAD_TEXT
3126 }
3127 +
3128 +#ifdef CONFIG_PAX_KERNEXEC
3129 + . = ALIGN(1<<SECTION_SHIFT);
3130 +#endif
3131 +
3132 .text : { /* Real text segment */
3133 _stext = .; /* Text and read-only data */
3134 __exception_text_start = .;
3135 @@ -116,6 +125,8 @@ SECTIONS
3136 ARM_CPU_KEEP(PROC_INFO)
3137 }
3138
3139 + _etext = .; /* End of text section */
3140 +
3141 RO_DATA(PAGE_SIZE)
3142
3143 . = ALIGN(4);
3144 @@ -146,7 +157,9 @@ SECTIONS
3145
3146 NOTES
3147
3148 - _etext = .; /* End of text and rodata section */
3149 +#ifdef CONFIG_PAX_KERNEXEC
3150 + . = ALIGN(1<<SECTION_SHIFT);
3151 +#endif
3152
3153 #ifndef CONFIG_XIP_KERNEL
3154 . = ALIGN(PAGE_SIZE);
3155 @@ -207,6 +220,11 @@ SECTIONS
3156 . = PAGE_OFFSET + TEXT_OFFSET;
3157 #else
3158 __init_end = .;
3159 +
3160 +#ifdef CONFIG_PAX_KERNEXEC
3161 + . = ALIGN(1<<SECTION_SHIFT);
3162 +#endif
3163 +
3164 . = ALIGN(THREAD_SIZE);
3165 __data_loc = .;
3166 #endif
3167 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3168 index 14a0d98..7771a7d 100644
3169 --- a/arch/arm/lib/clear_user.S
3170 +++ b/arch/arm/lib/clear_user.S
3171 @@ -12,14 +12,14 @@
3172
3173 .text
3174
3175 -/* Prototype: int __clear_user(void *addr, size_t sz)
3176 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3177 * Purpose : clear some user memory
3178 * Params : addr - user memory address to clear
3179 * : sz - number of bytes to clear
3180 * Returns : number of bytes NOT cleared
3181 */
3182 ENTRY(__clear_user_std)
3183 -WEAK(__clear_user)
3184 +WEAK(___clear_user)
3185 stmfd sp!, {r1, lr}
3186 mov r2, #0
3187 cmp r1, #4
3188 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3189 USER( strnebt r2, [r0])
3190 mov r0, #0
3191 ldmfd sp!, {r1, pc}
3192 -ENDPROC(__clear_user)
3193 +ENDPROC(___clear_user)
3194 ENDPROC(__clear_user_std)
3195
3196 .pushsection .fixup,"ax"
3197 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3198 index 66a477a..bee61d3 100644
3199 --- a/arch/arm/lib/copy_from_user.S
3200 +++ b/arch/arm/lib/copy_from_user.S
3201 @@ -16,7 +16,7 @@
3202 /*
3203 * Prototype:
3204 *
3205 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3206 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3207 *
3208 * Purpose:
3209 *
3210 @@ -84,11 +84,11 @@
3211
3212 .text
3213
3214 -ENTRY(__copy_from_user)
3215 +ENTRY(___copy_from_user)
3216
3217 #include "copy_template.S"
3218
3219 -ENDPROC(__copy_from_user)
3220 +ENDPROC(___copy_from_user)
3221
3222 .pushsection .fixup,"ax"
3223 .align 0
3224 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3225 index 6ee2f67..d1cce76 100644
3226 --- a/arch/arm/lib/copy_page.S
3227 +++ b/arch/arm/lib/copy_page.S
3228 @@ -10,6 +10,7 @@
3229 * ASM optimised string functions
3230 */
3231 #include <linux/linkage.h>
3232 +#include <linux/const.h>
3233 #include <asm/assembler.h>
3234 #include <asm/asm-offsets.h>
3235 #include <asm/cache.h>
3236 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3237 index d066df6..df28194 100644
3238 --- a/arch/arm/lib/copy_to_user.S
3239 +++ b/arch/arm/lib/copy_to_user.S
3240 @@ -16,7 +16,7 @@
3241 /*
3242 * Prototype:
3243 *
3244 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3245 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3246 *
3247 * Purpose:
3248 *
3249 @@ -88,11 +88,11 @@
3250 .text
3251
3252 ENTRY(__copy_to_user_std)
3253 -WEAK(__copy_to_user)
3254 +WEAK(___copy_to_user)
3255
3256 #include "copy_template.S"
3257
3258 -ENDPROC(__copy_to_user)
3259 +ENDPROC(___copy_to_user)
3260 ENDPROC(__copy_to_user_std)
3261
3262 .pushsection .fixup,"ax"
3263 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3264 index 7d08b43..f7ca7ea 100644
3265 --- a/arch/arm/lib/csumpartialcopyuser.S
3266 +++ b/arch/arm/lib/csumpartialcopyuser.S
3267 @@ -57,8 +57,8 @@
3268 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3269 */
3270
3271 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3272 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3273 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3274 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3275
3276 #include "csumpartialcopygeneric.S"
3277
3278 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3279 index 64dbfa5..84a3fd9 100644
3280 --- a/arch/arm/lib/delay.c
3281 +++ b/arch/arm/lib/delay.c
3282 @@ -28,7 +28,7 @@
3283 /*
3284 * Default to the loop-based delay implementation.
3285 */
3286 -struct arm_delay_ops arm_delay_ops = {
3287 +struct arm_delay_ops arm_delay_ops __read_only = {
3288 .delay = __loop_delay,
3289 .const_udelay = __loop_const_udelay,
3290 .udelay = __loop_udelay,
3291 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3292 index 025f742..8432b08 100644
3293 --- a/arch/arm/lib/uaccess_with_memcpy.c
3294 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3295 @@ -104,7 +104,7 @@ out:
3296 }
3297
3298 unsigned long
3299 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3300 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3301 {
3302 /*
3303 * This test is stubbed out of the main function above to keep
3304 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3305 index f389228..592ef66 100644
3306 --- a/arch/arm/mach-kirkwood/common.c
3307 +++ b/arch/arm/mach-kirkwood/common.c
3308 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3309 clk_gate_ops.disable(hw);
3310 }
3311
3312 -static struct clk_ops clk_gate_fn_ops;
3313 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3314 +{
3315 + return clk_gate_ops.is_enabled(hw);
3316 +}
3317 +
3318 +static struct clk_ops clk_gate_fn_ops = {
3319 + .enable = clk_gate_fn_enable,
3320 + .disable = clk_gate_fn_disable,
3321 + .is_enabled = clk_gate_fn_is_enabled,
3322 +};
3323
3324 static struct clk __init *clk_register_gate_fn(struct device *dev,
3325 const char *name,
3326 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3327 gate_fn->fn_en = fn_en;
3328 gate_fn->fn_dis = fn_dis;
3329
3330 - /* ops is the gate ops, but with our enable/disable functions */
3331 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3332 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3333 - clk_gate_fn_ops = clk_gate_ops;
3334 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3335 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3336 - }
3337 -
3338 clk = clk_register(dev, &gate_fn->gate.hw);
3339
3340 if (IS_ERR(clk))
3341 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3342 index f6eeb87..cc90868 100644
3343 --- a/arch/arm/mach-omap2/board-n8x0.c
3344 +++ b/arch/arm/mach-omap2/board-n8x0.c
3345 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3346 }
3347 #endif
3348
3349 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3350 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3351 .late_init = n8x0_menelaus_late_init,
3352 };
3353
3354 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3355 index 6c4da12..d9ca72d 100644
3356 --- a/arch/arm/mach-omap2/gpmc.c
3357 +++ b/arch/arm/mach-omap2/gpmc.c
3358 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3359 };
3360
3361 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3362 -static struct irq_chip gpmc_irq_chip;
3363 static unsigned gpmc_irq_start;
3364
3365 static struct resource gpmc_mem_root;
3366 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3367
3368 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3369
3370 +static struct irq_chip gpmc_irq_chip = {
3371 + .name = "gpmc",
3372 + .irq_startup = gpmc_irq_noop_ret,
3373 + .irq_enable = gpmc_irq_enable,
3374 + .irq_disable = gpmc_irq_disable,
3375 + .irq_shutdown = gpmc_irq_noop,
3376 + .irq_ack = gpmc_irq_noop,
3377 + .irq_mask = gpmc_irq_noop,
3378 + .irq_unmask = gpmc_irq_noop,
3379 +
3380 +};
3381 +
3382 static int gpmc_setup_irq(void)
3383 {
3384 int i;
3385 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3386 return gpmc_irq_start;
3387 }
3388
3389 - gpmc_irq_chip.name = "gpmc";
3390 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3391 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3392 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3393 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3394 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3395 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3396 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3397 -
3398 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3399 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3400
3401 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3402 index f8bb3b9..831e7b8 100644
3403 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3404 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3405 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3406 return NOTIFY_OK;
3407 }
3408
3409 -static struct notifier_block __refdata irq_hotplug_notifier = {
3410 +static struct notifier_block irq_hotplug_notifier = {
3411 .notifier_call = irq_cpu_hotplug_notify,
3412 };
3413
3414 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3415 index e6d2307..d057195 100644
3416 --- a/arch/arm/mach-omap2/omap_device.c
3417 +++ b/arch/arm/mach-omap2/omap_device.c
3418 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3419 struct platform_device __init *omap_device_build(const char *pdev_name,
3420 int pdev_id,
3421 struct omap_hwmod *oh,
3422 - void *pdata, int pdata_len)
3423 + const void *pdata, int pdata_len)
3424 {
3425 struct omap_hwmod *ohs[] = { oh };
3426
3427 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3428 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3429 int pdev_id,
3430 struct omap_hwmod **ohs,
3431 - int oh_cnt, void *pdata,
3432 + int oh_cnt, const void *pdata,
3433 int pdata_len)
3434 {
3435 int ret = -ENOMEM;
3436 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3437 index 044c31d..2ee0861 100644
3438 --- a/arch/arm/mach-omap2/omap_device.h
3439 +++ b/arch/arm/mach-omap2/omap_device.h
3440 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3441 /* Core code interface */
3442
3443 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3444 - struct omap_hwmod *oh, void *pdata,
3445 + struct omap_hwmod *oh, const void *pdata,
3446 int pdata_len);
3447
3448 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3449 struct omap_hwmod **oh, int oh_cnt,
3450 - void *pdata, int pdata_len);
3451 + const void *pdata, int pdata_len);
3452
3453 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3454 struct omap_hwmod **ohs, int oh_cnt);
3455 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3456 index 7341eff..fd75e34 100644
3457 --- a/arch/arm/mach-omap2/omap_hwmod.c
3458 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3459 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3460 int (*init_clkdm)(struct omap_hwmod *oh);
3461 void (*update_context_lost)(struct omap_hwmod *oh);
3462 int (*get_context_lost)(struct omap_hwmod *oh);
3463 -};
3464 +} __no_const;
3465
3466 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3467 -static struct omap_hwmod_soc_ops soc_ops;
3468 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3469
3470 /* omap_hwmod_list contains all registered struct omap_hwmods */
3471 static LIST_HEAD(omap_hwmod_list);
3472 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3473 index d15c7bb..b2d1f0c 100644
3474 --- a/arch/arm/mach-omap2/wd_timer.c
3475 +++ b/arch/arm/mach-omap2/wd_timer.c
3476 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3477 struct omap_hwmod *oh;
3478 char *oh_name = "wd_timer2";
3479 char *dev_name = "omap_wdt";
3480 - struct omap_wd_timer_platform_data pdata;
3481 + static struct omap_wd_timer_platform_data pdata = {
3482 + .read_reset_sources = prm_read_reset_sources
3483 + };
3484
3485 if (!cpu_class_is_omap2() || of_have_populated_dt())
3486 return 0;
3487 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3488 return -EINVAL;
3489 }
3490
3491 - pdata.read_reset_sources = prm_read_reset_sources;
3492 -
3493 pdev = omap_device_build(dev_name, id, oh, &pdata,
3494 sizeof(struct omap_wd_timer_platform_data));
3495 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3496 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3497 index 0cdba8d..297993e 100644
3498 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3499 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3500 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3501 bool entered_lp2 = false;
3502
3503 if (tegra_pending_sgi())
3504 - ACCESS_ONCE(abort_flag) = true;
3505 + ACCESS_ONCE_RW(abort_flag) = true;
3506
3507 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3508
3509 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3510 index cad3ca86..1d79e0f 100644
3511 --- a/arch/arm/mach-ux500/setup.h
3512 +++ b/arch/arm/mach-ux500/setup.h
3513 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
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 35955b5..b475042 100644
3529 --- a/arch/arm/mm/Kconfig
3530 +++ b/arch/arm/mm/Kconfig
3531 @@ -432,7 +432,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 && !PAX_MEMORY_UDEREF
3537 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3538
3539 config CPU_32v6K
3540 @@ -581,6 +581,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 6f4585b..7b6f52b 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 9a5cdc0..a1182cf 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 @@ -726,7 +728,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 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
3856 #endif
3857 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3858 index 04d9006..c547d85 100644
3859 --- a/arch/arm/mm/ioremap.c
3860 +++ b/arch/arm/mm/ioremap.c
3861 @@ -392,9 +392,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..8695745 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 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3907 info.high_limit = TASK_SIZE;
3908 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3909 info.align_offset = pgoff << PAGE_SHIFT;
3910 + info.threadstack_offset = offset;
3911 return vm_unmapped_area(&info);
3912 }
3913
3914 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3915 unsigned long addr = addr0;
3916 int do_align = 0;
3917 int aliasing = cache_is_vipt_aliasing();
3918 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3919 struct vm_unmapped_area_info info;
3920
3921 /*
3922 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3923 return addr;
3924 }
3925
3926 +#ifdef CONFIG_PAX_RANDMMAP
3927 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3928 +#endif
3929 +
3930 /* requesting a specific address */
3931 if (addr) {
3932 if (do_align)
3933 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3934 else
3935 addr = PAGE_ALIGN(addr);
3936 vma = find_vma(mm, addr);
3937 - if (TASK_SIZE - len >= addr &&
3938 - (!vma || addr + len <= vma->vm_start))
3939 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3940 return addr;
3941 }
3942
3943 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3944 info.high_limit = mm->mmap_base;
3945 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3946 info.align_offset = pgoff << PAGE_SHIFT;
3947 + info.threadstack_offset = offset;
3948 addr = vm_unmapped_area(&info);
3949
3950 /*
3951 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3952 {
3953 unsigned long random_factor = 0UL;
3954
3955 +#ifdef CONFIG_PAX_RANDMMAP
3956 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3957 +#endif
3958 +
3959 /* 8 bits of randomness in 20 address space bits */
3960 if ((current->flags & PF_RANDOMIZE) &&
3961 !(current->personality & ADDR_NO_RANDOMIZE))
3962 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3963
3964 if (mmap_is_legacy()) {
3965 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3966 +
3967 +#ifdef CONFIG_PAX_RANDMMAP
3968 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3969 + mm->mmap_base += mm->delta_mmap;
3970 +#endif
3971 +
3972 mm->get_unmapped_area = arch_get_unmapped_area;
3973 mm->unmap_area = arch_unmap_area;
3974 } else {
3975 mm->mmap_base = mmap_base(random_factor);
3976 +
3977 +#ifdef CONFIG_PAX_RANDMMAP
3978 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3979 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3980 +#endif
3981 +
3982 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3983 mm->unmap_area = arch_unmap_area_topdown;
3984 }
3985 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3986 index 4d409e6..f375351 100644
3987 --- a/arch/arm/mm/mmu.c
3988 +++ b/arch/arm/mm/mmu.c
3989 @@ -36,6 +36,22 @@
3990 #include "mm.h"
3991 #include "tcm.h"
3992
3993 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3994 +void modify_domain(unsigned int dom, unsigned int type)
3995 +{
3996 + struct thread_info *thread = current_thread_info();
3997 + unsigned int domain = thread->cpu_domain;
3998 + /*
3999 + * DOMAIN_MANAGER might be defined to some other value,
4000 + * use the arch-defined constant
4001 + */
4002 + domain &= ~domain_val(dom, 3);
4003 + thread->cpu_domain = domain | domain_val(dom, type);
4004 + set_domain(thread->cpu_domain);
4005 +}
4006 +EXPORT_SYMBOL(modify_domain);
4007 +#endif
4008 +
4009 /*
4010 * empty_zero_page is a special page that is used for
4011 * zero-initialized data and COW.
4012 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4013
4014 #endif /* ifdef CONFIG_CPU_CP15 / else */
4015
4016 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4017 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4018 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4019
4020 -static struct mem_type mem_types[] = {
4021 +#ifdef CONFIG_PAX_KERNEXEC
4022 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4023 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4024 +#else
4025 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4026 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4027 +#endif
4028 +
4029 +static struct mem_type mem_types[] __read_only = {
4030 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4031 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4032 L_PTE_SHARED,
4033 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4034 [MT_UNCACHED] = {
4035 .prot_pte = PROT_PTE_DEVICE,
4036 .prot_l1 = PMD_TYPE_TABLE,
4037 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4038 + .prot_sect = PROT_SECT_DEVICE,
4039 .domain = DOMAIN_IO,
4040 },
4041 [MT_CACHECLEAN] = {
4042 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4043 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4044 .domain = DOMAIN_KERNEL,
4045 },
4046 #ifndef CONFIG_ARM_LPAE
4047 [MT_MINICLEAN] = {
4048 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4049 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4050 .domain = DOMAIN_KERNEL,
4051 },
4052 #endif
4053 @@ -277,36 +301,65 @@ static struct mem_type mem_types[] = {
4054 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4055 L_PTE_RDONLY,
4056 .prot_l1 = PMD_TYPE_TABLE,
4057 - .domain = DOMAIN_USER,
4058 + .domain = DOMAIN_VECTORS,
4059 },
4060 [MT_HIGH_VECTORS] = {
4061 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4062 - L_PTE_USER | L_PTE_RDONLY,
4063 + /* we always want the vector page to be noaccess for userland on archs with
4064 + XN where we can enforce some reasonable measure of security
4065 + therefore, when kernexec is disabled, instead of L_PTE_USER | L_PTE_RDONLY
4066 + which turns into supervisor rwx, userland rx, we instead omit that entirely,
4067 + leaving it as supervisor rwx only
4068 + */
4069 +#ifdef CONFIG_PAX_KERNEXEC
4070 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_RDONLY,
4071 +#elif __LINUX_ARM_ARCH__ >= 6
4072 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4073 +#else
4074 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_USER | L_PTE_RDONLY,
4075 +#endif
4076 .prot_l1 = PMD_TYPE_TABLE,
4077 - .domain = DOMAIN_USER,
4078 + .domain = DOMAIN_VECTORS,
4079 },
4080 - [MT_MEMORY] = {
4081 + [MT_MEMORY_RWX] = {
4082 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4083 .prot_l1 = PMD_TYPE_TABLE,
4084 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4085 .domain = DOMAIN_KERNEL,
4086 },
4087 + [MT_MEMORY_RW] = {
4088 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4089 + .prot_l1 = PMD_TYPE_TABLE,
4090 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4091 + .domain = DOMAIN_KERNEL,
4092 + },
4093 + [MT_MEMORY_RX] = {
4094 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4095 + .prot_l1 = PMD_TYPE_TABLE,
4096 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4097 + .domain = DOMAIN_KERNEL,
4098 + },
4099 [MT_ROM] = {
4100 - .prot_sect = PMD_TYPE_SECT,
4101 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4102 .domain = DOMAIN_KERNEL,
4103 },
4104 - [MT_MEMORY_NONCACHED] = {
4105 + [MT_MEMORY_NONCACHED_RW] = {
4106 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4107 L_PTE_MT_BUFFERABLE,
4108 .prot_l1 = PMD_TYPE_TABLE,
4109 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4110 .domain = DOMAIN_KERNEL,
4111 },
4112 + [MT_MEMORY_NONCACHED_RX] = {
4113 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4114 + L_PTE_MT_BUFFERABLE,
4115 + .prot_l1 = PMD_TYPE_TABLE,
4116 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4117 + .domain = DOMAIN_KERNEL,
4118 + },
4119 [MT_MEMORY_DTCM] = {
4120 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4121 - L_PTE_XN,
4122 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4123 .prot_l1 = PMD_TYPE_TABLE,
4124 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4125 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4126 .domain = DOMAIN_KERNEL,
4127 },
4128 [MT_MEMORY_ITCM] = {
4129 @@ -316,10 +369,10 @@ static struct mem_type mem_types[] = {
4130 },
4131 [MT_MEMORY_SO] = {
4132 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4133 - L_PTE_MT_UNCACHED | L_PTE_XN,
4134 + L_PTE_MT_UNCACHED,
4135 .prot_l1 = PMD_TYPE_TABLE,
4136 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4137 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4138 + PMD_SECT_UNCACHED,
4139 .domain = DOMAIN_KERNEL,
4140 },
4141 [MT_MEMORY_DMA_READY] = {
4142 @@ -405,9 +458,35 @@ static void __init build_mem_type_table(void)
4143 * to prevent speculative instruction fetches.
4144 */
4145 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4146 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4147 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4148 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4149 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4150 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4151 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4152 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4153 +
4154 + /* Mark other regions on ARMv6+ as execute-never */
4155 +
4156 +#ifdef CONFIG_PAX_KERNEXEC
4157 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4158 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4159 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4160 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4161 +#ifndef CONFIG_ARM_LPAE
4162 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4163 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4164 +#endif
4165 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4166 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4167 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4168 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4169 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4170 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4171 +#endif
4172 +
4173 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4174 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4175 }
4176 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4177 /*
4178 @@ -468,6 +547,9 @@ static void __init build_mem_type_table(void)
4179 * from SVC mode and no access from userspace.
4180 */
4181 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4182 +#ifdef CONFIG_PAX_KERNEXEC
4183 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4184 +#endif
4185 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4186 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4187 #endif
4188 @@ -485,11 +567,17 @@ static void __init build_mem_type_table(void)
4189 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4190 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4191 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4192 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4193 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4194 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4195 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4196 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4197 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4198 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4199 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4200 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4201 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4202 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4203 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4204 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4205 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4206 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4207 }
4208 }
4209
4210 @@ -500,15 +588,20 @@ static void __init build_mem_type_table(void)
4211 if (cpu_arch >= CPU_ARCH_ARMv6) {
4212 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4213 /* Non-cacheable Normal is XCB = 001 */
4214 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4215 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4216 + PMD_SECT_BUFFERED;
4217 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4218 PMD_SECT_BUFFERED;
4219 } else {
4220 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4221 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4222 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4223 + PMD_SECT_TEX(1);
4224 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4225 PMD_SECT_TEX(1);
4226 }
4227 } else {
4228 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4229 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4230 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4231 }
4232
4233 #ifdef CONFIG_ARM_LPAE
4234 @@ -524,6 +617,8 @@ static void __init build_mem_type_table(void)
4235 vecs_pgprot |= PTE_EXT_AF;
4236 #endif
4237
4238 + user_pgprot |= __supported_pte_mask;
4239 +
4240 for (i = 0; i < 16; i++) {
4241 pteval_t v = pgprot_val(protection_map[i]);
4242 protection_map[i] = __pgprot(v | user_pgprot);
4243 @@ -541,10 +636,15 @@ static void __init build_mem_type_table(void)
4244
4245 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4246 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4247 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4248 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4249 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4250 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4251 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4252 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4253 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4254 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4255 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4256 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4257 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4258 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4259 mem_types[MT_ROM].prot_sect |= cp->pmd;
4260
4261 switch (cp->pmd) {
4262 @@ -1166,18 +1266,15 @@ void __init arm_mm_memblock_reserve(void)
4263 * called function. This means you can't use any function or debugging
4264 * method which may touch any device, otherwise the kernel _will_ crash.
4265 */
4266 +
4267 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4268 +
4269 static void __init devicemaps_init(struct machine_desc *mdesc)
4270 {
4271 struct map_desc map;
4272 unsigned long addr;
4273 - void *vectors;
4274
4275 - /*
4276 - * Allocate the vector page early.
4277 - */
4278 - vectors = early_alloc(PAGE_SIZE);
4279 -
4280 - early_trap_init(vectors);
4281 + early_trap_init(&vectors);
4282
4283 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4284 pmd_clear(pmd_off_k(addr));
4285 @@ -1217,7 +1314,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4286 * location (0xffff0000). If we aren't using high-vectors, also
4287 * create a mapping at the low-vectors virtual address.
4288 */
4289 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4290 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4291 map.virtual = 0xffff0000;
4292 map.length = PAGE_SIZE;
4293 map.type = MT_HIGH_VECTORS;
4294 @@ -1275,8 +1372,39 @@ static void __init map_lowmem(void)
4295 map.pfn = __phys_to_pfn(start);
4296 map.virtual = __phys_to_virt(start);
4297 map.length = end - start;
4298 - map.type = MT_MEMORY;
4299
4300 +#ifdef CONFIG_PAX_KERNEXEC
4301 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4302 + struct map_desc kernel;
4303 + struct map_desc initmap;
4304 +
4305 + /* when freeing initmem we will make this RW */
4306 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4307 + initmap.virtual = (unsigned long)__init_begin;
4308 + initmap.length = _sdata - __init_begin;
4309 + initmap.type = MT_MEMORY_RWX;
4310 + create_mapping(&initmap);
4311 +
4312 + /* when freeing initmem we will make this RX */
4313 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4314 + kernel.virtual = (unsigned long)_stext;
4315 + kernel.length = __init_begin - _stext;
4316 + kernel.type = MT_MEMORY_RWX;
4317 + create_mapping(&kernel);
4318 +
4319 + if (map.virtual < (unsigned long)_stext) {
4320 + map.length = (unsigned long)_stext - map.virtual;
4321 + map.type = MT_MEMORY_RWX;
4322 + create_mapping(&map);
4323 + }
4324 +
4325 + map.pfn = __phys_to_pfn(__pa(_sdata));
4326 + map.virtual = (unsigned long)_sdata;
4327 + map.length = end - __pa(_sdata);
4328 + }
4329 +#endif
4330 +
4331 + map.type = MT_MEMORY_RW;
4332 create_mapping(&map);
4333 }
4334 }
4335 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4336 index 9704097..3e36dde 100644
4337 --- a/arch/arm/mm/proc-v7-2level.S
4338 +++ b/arch/arm/mm/proc-v7-2level.S
4339 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4340 tst r1, #L_PTE_XN
4341 orrne r3, r3, #PTE_EXT_XN
4342
4343 + tst r1, #L_PTE_PXN
4344 + orrne r3, r3, #PTE_EXT_PXN
4345 +
4346 tst r1, #L_PTE_YOUNG
4347 tstne r1, #L_PTE_VALID
4348 #ifndef CONFIG_CPU_USE_DOMAINS
4349 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4350 index a5bc92d..0bb4730 100644
4351 --- a/arch/arm/plat-omap/sram.c
4352 +++ b/arch/arm/plat-omap/sram.c
4353 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4354 * Looks like we need to preserve some bootloader code at the
4355 * beginning of SRAM for jumping to flash for reboot to work...
4356 */
4357 + pax_open_kernel();
4358 memset_io(omap_sram_base + omap_sram_skip, 0,
4359 omap_sram_size - omap_sram_skip);
4360 + pax_close_kernel();
4361 }
4362 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4363 index ce6d763..cfea917 100644
4364 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4365 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4366 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4367 int (*started)(unsigned ch);
4368 int (*flush)(unsigned ch);
4369 int (*stop)(unsigned ch);
4370 -};
4371 +} __no_const;
4372
4373 extern void *samsung_dmadev_get_ops(void);
4374 extern void *s3c_dma_get_ops(void);
4375 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4376 index f4726dc..39ed646 100644
4377 --- a/arch/arm64/kernel/debug-monitors.c
4378 +++ b/arch/arm64/kernel/debug-monitors.c
4379 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4380 return NOTIFY_OK;
4381 }
4382
4383 -static struct notifier_block __cpuinitdata os_lock_nb = {
4384 +static struct notifier_block os_lock_nb = {
4385 .notifier_call = os_lock_notify,
4386 };
4387
4388 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4389 index 5ab825c..96aaec8 100644
4390 --- a/arch/arm64/kernel/hw_breakpoint.c
4391 +++ b/arch/arm64/kernel/hw_breakpoint.c
4392 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4393 return NOTIFY_OK;
4394 }
4395
4396 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4397 +static struct notifier_block hw_breakpoint_reset_nb = {
4398 .notifier_call = hw_breakpoint_reset_notify,
4399 };
4400
4401 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4402 index c3a58a1..78fbf54 100644
4403 --- a/arch/avr32/include/asm/cache.h
4404 +++ b/arch/avr32/include/asm/cache.h
4405 @@ -1,8 +1,10 @@
4406 #ifndef __ASM_AVR32_CACHE_H
4407 #define __ASM_AVR32_CACHE_H
4408
4409 +#include <linux/const.h>
4410 +
4411 #define L1_CACHE_SHIFT 5
4412 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4413 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4414
4415 /*
4416 * Memory returned by kmalloc() may be used for DMA, so we must make
4417 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4418 index d232888..87c8df1 100644
4419 --- a/arch/avr32/include/asm/elf.h
4420 +++ b/arch/avr32/include/asm/elf.h
4421 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4422 the loader. We need to make sure that it is out of the way of the program
4423 that it will "exec", and that there is sufficient room for the brk. */
4424
4425 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4426 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4427
4428 +#ifdef CONFIG_PAX_ASLR
4429 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4430 +
4431 +#define PAX_DELTA_MMAP_LEN 15
4432 +#define PAX_DELTA_STACK_LEN 15
4433 +#endif
4434
4435 /* This yields a mask that user programs can use to figure out what
4436 instruction set this CPU supports. This could be done in user space,
4437 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4438 index 479330b..53717a8 100644
4439 --- a/arch/avr32/include/asm/kmap_types.h
4440 +++ b/arch/avr32/include/asm/kmap_types.h
4441 @@ -2,9 +2,9 @@
4442 #define __ASM_AVR32_KMAP_TYPES_H
4443
4444 #ifdef CONFIG_DEBUG_HIGHMEM
4445 -# define KM_TYPE_NR 29
4446 +# define KM_TYPE_NR 30
4447 #else
4448 -# define KM_TYPE_NR 14
4449 +# define KM_TYPE_NR 15
4450 #endif
4451
4452 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4453 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4454 index b2f2d2d..d1c85cb 100644
4455 --- a/arch/avr32/mm/fault.c
4456 +++ b/arch/avr32/mm/fault.c
4457 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4458
4459 int exception_trace = 1;
4460
4461 +#ifdef CONFIG_PAX_PAGEEXEC
4462 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4463 +{
4464 + unsigned long i;
4465 +
4466 + printk(KERN_ERR "PAX: bytes at PC: ");
4467 + for (i = 0; i < 20; i++) {
4468 + unsigned char c;
4469 + if (get_user(c, (unsigned char *)pc+i))
4470 + printk(KERN_CONT "???????? ");
4471 + else
4472 + printk(KERN_CONT "%02x ", c);
4473 + }
4474 + printk("\n");
4475 +}
4476 +#endif
4477 +
4478 /*
4479 * This routine handles page faults. It determines the address and the
4480 * problem, and then passes it off to one of the appropriate routines.
4481 @@ -174,6 +191,16 @@ bad_area:
4482 up_read(&mm->mmap_sem);
4483
4484 if (user_mode(regs)) {
4485 +
4486 +#ifdef CONFIG_PAX_PAGEEXEC
4487 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4488 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4489 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4490 + do_group_exit(SIGKILL);
4491 + }
4492 + }
4493 +#endif
4494 +
4495 if (exception_trace && printk_ratelimit())
4496 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4497 "sp %08lx ecr %lu\n",
4498 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4499 index 568885a..f8008df 100644
4500 --- a/arch/blackfin/include/asm/cache.h
4501 +++ b/arch/blackfin/include/asm/cache.h
4502 @@ -7,6 +7,7 @@
4503 #ifndef __ARCH_BLACKFIN_CACHE_H
4504 #define __ARCH_BLACKFIN_CACHE_H
4505
4506 +#include <linux/const.h>
4507 #include <linux/linkage.h> /* for asmlinkage */
4508
4509 /*
4510 @@ -14,7 +15,7 @@
4511 * Blackfin loads 32 bytes for cache
4512 */
4513 #define L1_CACHE_SHIFT 5
4514 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4515 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4516 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4517
4518 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4519 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4520 index aea2718..3639a60 100644
4521 --- a/arch/cris/include/arch-v10/arch/cache.h
4522 +++ b/arch/cris/include/arch-v10/arch/cache.h
4523 @@ -1,8 +1,9 @@
4524 #ifndef _ASM_ARCH_CACHE_H
4525 #define _ASM_ARCH_CACHE_H
4526
4527 +#include <linux/const.h>
4528 /* Etrax 100LX have 32-byte cache-lines. */
4529 -#define L1_CACHE_BYTES 32
4530 #define L1_CACHE_SHIFT 5
4531 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4532
4533 #endif /* _ASM_ARCH_CACHE_H */
4534 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4535 index 7caf25d..ee65ac5 100644
4536 --- a/arch/cris/include/arch-v32/arch/cache.h
4537 +++ b/arch/cris/include/arch-v32/arch/cache.h
4538 @@ -1,11 +1,12 @@
4539 #ifndef _ASM_CRIS_ARCH_CACHE_H
4540 #define _ASM_CRIS_ARCH_CACHE_H
4541
4542 +#include <linux/const.h>
4543 #include <arch/hwregs/dma.h>
4544
4545 /* A cache-line is 32 bytes. */
4546 -#define L1_CACHE_BYTES 32
4547 #define L1_CACHE_SHIFT 5
4548 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4549
4550 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4551
4552 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4553 index b86329d..6709906 100644
4554 --- a/arch/frv/include/asm/atomic.h
4555 +++ b/arch/frv/include/asm/atomic.h
4556 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4557 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4558 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4559
4560 +#define atomic64_read_unchecked(v) atomic64_read(v)
4561 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4562 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4563 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4564 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4565 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4566 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4567 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4568 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4569 +
4570 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4571 {
4572 int c, old;
4573 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4574 index 2797163..c2a401d 100644
4575 --- a/arch/frv/include/asm/cache.h
4576 +++ b/arch/frv/include/asm/cache.h
4577 @@ -12,10 +12,11 @@
4578 #ifndef __ASM_CACHE_H
4579 #define __ASM_CACHE_H
4580
4581 +#include <linux/const.h>
4582
4583 /* bytes per L1 cache line */
4584 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4585 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4586 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4587
4588 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4589 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4590 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4591 index 43901f2..0d8b865 100644
4592 --- a/arch/frv/include/asm/kmap_types.h
4593 +++ b/arch/frv/include/asm/kmap_types.h
4594 @@ -2,6 +2,6 @@
4595 #ifndef _ASM_KMAP_TYPES_H
4596 #define _ASM_KMAP_TYPES_H
4597
4598 -#define KM_TYPE_NR 17
4599 +#define KM_TYPE_NR 18
4600
4601 #endif
4602 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4603 index 836f147..4cf23f5 100644
4604 --- a/arch/frv/mm/elf-fdpic.c
4605 +++ b/arch/frv/mm/elf-fdpic.c
4606 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4607 {
4608 struct vm_area_struct *vma;
4609 struct vm_unmapped_area_info info;
4610 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4611
4612 if (len > TASK_SIZE)
4613 return -ENOMEM;
4614 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4615 if (addr) {
4616 addr = PAGE_ALIGN(addr);
4617 vma = find_vma(current->mm, addr);
4618 - if (TASK_SIZE - len >= addr &&
4619 - (!vma || addr + len <= vma->vm_start))
4620 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4621 goto success;
4622 }
4623
4624 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4625 info.high_limit = (current->mm->start_stack - 0x00200000);
4626 info.align_mask = 0;
4627 info.align_offset = 0;
4628 + info.threadstack_offset = offset;
4629 addr = vm_unmapped_area(&info);
4630 if (!(addr & ~PAGE_MASK))
4631 goto success;
4632 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4633 index f4ca594..adc72fd6 100644
4634 --- a/arch/hexagon/include/asm/cache.h
4635 +++ b/arch/hexagon/include/asm/cache.h
4636 @@ -21,9 +21,11 @@
4637 #ifndef __ASM_CACHE_H
4638 #define __ASM_CACHE_H
4639
4640 +#include <linux/const.h>
4641 +
4642 /* Bytes per L1 cache line */
4643 -#define L1_CACHE_SHIFT (5)
4644 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4645 +#define L1_CACHE_SHIFT 5
4646 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4647
4648 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4649 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4650 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4651 index 6e6fe18..a6ae668 100644
4652 --- a/arch/ia64/include/asm/atomic.h
4653 +++ b/arch/ia64/include/asm/atomic.h
4654 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4655 #define atomic64_inc(v) atomic64_add(1, (v))
4656 #define atomic64_dec(v) atomic64_sub(1, (v))
4657
4658 +#define atomic64_read_unchecked(v) atomic64_read(v)
4659 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4660 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4661 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4662 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4663 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4664 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4665 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4666 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4667 +
4668 /* Atomic operations are already serializing */
4669 #define smp_mb__before_atomic_dec() barrier()
4670 #define smp_mb__after_atomic_dec() barrier()
4671 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4672 index 988254a..e1ee885 100644
4673 --- a/arch/ia64/include/asm/cache.h
4674 +++ b/arch/ia64/include/asm/cache.h
4675 @@ -1,6 +1,7 @@
4676 #ifndef _ASM_IA64_CACHE_H
4677 #define _ASM_IA64_CACHE_H
4678
4679 +#include <linux/const.h>
4680
4681 /*
4682 * Copyright (C) 1998-2000 Hewlett-Packard Co
4683 @@ -9,7 +10,7 @@
4684
4685 /* Bytes per L1 (data) cache line. */
4686 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4687 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4688 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4689
4690 #ifdef CONFIG_SMP
4691 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4692 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4693 index 5a83c5c..4d7f553 100644
4694 --- a/arch/ia64/include/asm/elf.h
4695 +++ b/arch/ia64/include/asm/elf.h
4696 @@ -42,6 +42,13 @@
4697 */
4698 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4699
4700 +#ifdef CONFIG_PAX_ASLR
4701 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4702 +
4703 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4704 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4705 +#endif
4706 +
4707 #define PT_IA_64_UNWIND 0x70000001
4708
4709 /* IA-64 relocations: */
4710 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4711 index 96a8d92..617a1cf 100644
4712 --- a/arch/ia64/include/asm/pgalloc.h
4713 +++ b/arch/ia64/include/asm/pgalloc.h
4714 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4715 pgd_val(*pgd_entry) = __pa(pud);
4716 }
4717
4718 +static inline void
4719 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4720 +{
4721 + pgd_populate(mm, pgd_entry, pud);
4722 +}
4723 +
4724 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4725 {
4726 return quicklist_alloc(0, GFP_KERNEL, NULL);
4727 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4728 pud_val(*pud_entry) = __pa(pmd);
4729 }
4730
4731 +static inline void
4732 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4733 +{
4734 + pud_populate(mm, pud_entry, pmd);
4735 +}
4736 +
4737 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4738 {
4739 return quicklist_alloc(0, GFP_KERNEL, NULL);
4740 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4741 index 815810c..d60bd4c 100644
4742 --- a/arch/ia64/include/asm/pgtable.h
4743 +++ b/arch/ia64/include/asm/pgtable.h
4744 @@ -12,7 +12,7 @@
4745 * David Mosberger-Tang <davidm@hpl.hp.com>
4746 */
4747
4748 -
4749 +#include <linux/const.h>
4750 #include <asm/mman.h>
4751 #include <asm/page.h>
4752 #include <asm/processor.h>
4753 @@ -142,6 +142,17 @@
4754 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4755 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4756 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4757 +
4758 +#ifdef CONFIG_PAX_PAGEEXEC
4759 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4760 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4761 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4762 +#else
4763 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4764 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4765 +# define PAGE_COPY_NOEXEC PAGE_COPY
4766 +#endif
4767 +
4768 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4769 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4770 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4771 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4772 index 54ff557..70c88b7 100644
4773 --- a/arch/ia64/include/asm/spinlock.h
4774 +++ b/arch/ia64/include/asm/spinlock.h
4775 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4776 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4777
4778 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4779 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4780 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4781 }
4782
4783 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4784 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4785 index 449c8c0..18965fb 100644
4786 --- a/arch/ia64/include/asm/uaccess.h
4787 +++ b/arch/ia64/include/asm/uaccess.h
4788 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4789 static inline unsigned long
4790 __copy_to_user (void __user *to, const void *from, unsigned long count)
4791 {
4792 + if (count > INT_MAX)
4793 + return count;
4794 +
4795 + if (!__builtin_constant_p(count))
4796 + check_object_size(from, count, true);
4797 +
4798 return __copy_user(to, (__force void __user *) from, count);
4799 }
4800
4801 static inline unsigned long
4802 __copy_from_user (void *to, const void __user *from, unsigned long count)
4803 {
4804 + if (count > INT_MAX)
4805 + return count;
4806 +
4807 + if (!__builtin_constant_p(count))
4808 + check_object_size(to, count, false);
4809 +
4810 return __copy_user((__force void __user *) to, from, count);
4811 }
4812
4813 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4814 ({ \
4815 void __user *__cu_to = (to); \
4816 const void *__cu_from = (from); \
4817 - long __cu_len = (n); \
4818 + unsigned long __cu_len = (n); \
4819 \
4820 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4821 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4822 + if (!__builtin_constant_p(n)) \
4823 + check_object_size(__cu_from, __cu_len, true); \
4824 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4825 + } \
4826 __cu_len; \
4827 })
4828
4829 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4830 ({ \
4831 void *__cu_to = (to); \
4832 const void __user *__cu_from = (from); \
4833 - long __cu_len = (n); \
4834 + unsigned long __cu_len = (n); \
4835 \
4836 __chk_user_ptr(__cu_from); \
4837 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4838 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4839 + if (!__builtin_constant_p(n)) \
4840 + check_object_size(__cu_to, __cu_len, false); \
4841 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4842 + } \
4843 __cu_len; \
4844 })
4845
4846 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4847 index 2d67317..07d8bfa 100644
4848 --- a/arch/ia64/kernel/err_inject.c
4849 +++ b/arch/ia64/kernel/err_inject.c
4850 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4851 return NOTIFY_OK;
4852 }
4853
4854 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4855 +static struct notifier_block err_inject_cpu_notifier =
4856 {
4857 .notifier_call = err_inject_cpu_callback,
4858 };
4859 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4860 index d7396db..b33e873 100644
4861 --- a/arch/ia64/kernel/mca.c
4862 +++ b/arch/ia64/kernel/mca.c
4863 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4864 return NOTIFY_OK;
4865 }
4866
4867 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4868 +static struct notifier_block mca_cpu_notifier = {
4869 .notifier_call = mca_cpu_callback
4870 };
4871
4872 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4873 index 24603be..948052d 100644
4874 --- a/arch/ia64/kernel/module.c
4875 +++ b/arch/ia64/kernel/module.c
4876 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4877 void
4878 module_free (struct module *mod, void *module_region)
4879 {
4880 - if (mod && mod->arch.init_unw_table &&
4881 - module_region == mod->module_init) {
4882 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4883 unw_remove_unwind_table(mod->arch.init_unw_table);
4884 mod->arch.init_unw_table = NULL;
4885 }
4886 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4887 }
4888
4889 static inline int
4890 +in_init_rx (const struct module *mod, uint64_t addr)
4891 +{
4892 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4893 +}
4894 +
4895 +static inline int
4896 +in_init_rw (const struct module *mod, uint64_t addr)
4897 +{
4898 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4899 +}
4900 +
4901 +static inline int
4902 in_init (const struct module *mod, uint64_t addr)
4903 {
4904 - return addr - (uint64_t) mod->module_init < mod->init_size;
4905 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4906 +}
4907 +
4908 +static inline int
4909 +in_core_rx (const struct module *mod, uint64_t addr)
4910 +{
4911 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4912 +}
4913 +
4914 +static inline int
4915 +in_core_rw (const struct module *mod, uint64_t addr)
4916 +{
4917 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4918 }
4919
4920 static inline int
4921 in_core (const struct module *mod, uint64_t addr)
4922 {
4923 - return addr - (uint64_t) mod->module_core < mod->core_size;
4924 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4925 }
4926
4927 static inline int
4928 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4929 break;
4930
4931 case RV_BDREL:
4932 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4933 + if (in_init_rx(mod, val))
4934 + val -= (uint64_t) mod->module_init_rx;
4935 + else if (in_init_rw(mod, val))
4936 + val -= (uint64_t) mod->module_init_rw;
4937 + else if (in_core_rx(mod, val))
4938 + val -= (uint64_t) mod->module_core_rx;
4939 + else if (in_core_rw(mod, val))
4940 + val -= (uint64_t) mod->module_core_rw;
4941 break;
4942
4943 case RV_LTV:
4944 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4945 * addresses have been selected...
4946 */
4947 uint64_t gp;
4948 - if (mod->core_size > MAX_LTOFF)
4949 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4950 /*
4951 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4952 * at the end of the module.
4953 */
4954 - gp = mod->core_size - MAX_LTOFF / 2;
4955 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4956 else
4957 - gp = mod->core_size / 2;
4958 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4959 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4960 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4961 mod->arch.gp = gp;
4962 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4963 }
4964 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4965 index 2b3c2d7..a318d84 100644
4966 --- a/arch/ia64/kernel/palinfo.c
4967 +++ b/arch/ia64/kernel/palinfo.c
4968 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4969 return NOTIFY_OK;
4970 }
4971
4972 -static struct notifier_block __refdata palinfo_cpu_notifier =
4973 +static struct notifier_block palinfo_cpu_notifier =
4974 {
4975 .notifier_call = palinfo_cpu_callback,
4976 .priority = 0,
4977 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4978 index 4bc580a..7767f24 100644
4979 --- a/arch/ia64/kernel/salinfo.c
4980 +++ b/arch/ia64/kernel/salinfo.c
4981 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4982 return NOTIFY_OK;
4983 }
4984
4985 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4986 +static struct notifier_block salinfo_cpu_notifier =
4987 {
4988 .notifier_call = salinfo_cpu_callback,
4989 .priority = 0,
4990 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4991 index 41e33f8..65180b2 100644
4992 --- a/arch/ia64/kernel/sys_ia64.c
4993 +++ b/arch/ia64/kernel/sys_ia64.c
4994 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4995 unsigned long align_mask = 0;
4996 struct mm_struct *mm = current->mm;
4997 struct vm_unmapped_area_info info;
4998 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4999
5000 if (len > RGN_MAP_LIMIT)
5001 return -ENOMEM;
5002 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5003 if (REGION_NUMBER(addr) == RGN_HPAGE)
5004 addr = 0;
5005 #endif
5006 +
5007 +#ifdef CONFIG_PAX_RANDMMAP
5008 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5009 + addr = mm->free_area_cache;
5010 + else
5011 +#endif
5012 +
5013 if (!addr)
5014 addr = TASK_UNMAPPED_BASE;
5015
5016 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5017 info.high_limit = TASK_SIZE;
5018 info.align_mask = align_mask;
5019 info.align_offset = 0;
5020 + info.threadstack_offset = offset;
5021 return vm_unmapped_area(&info);
5022 }
5023
5024 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5025 index dc00b2c..cce53c2 100644
5026 --- a/arch/ia64/kernel/topology.c
5027 +++ b/arch/ia64/kernel/topology.c
5028 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5029 return NOTIFY_OK;
5030 }
5031
5032 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5033 +static struct notifier_block cache_cpu_notifier =
5034 {
5035 .notifier_call = cache_cpu_callback
5036 };
5037 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5038 index 0ccb28f..8992469 100644
5039 --- a/arch/ia64/kernel/vmlinux.lds.S
5040 +++ b/arch/ia64/kernel/vmlinux.lds.S
5041 @@ -198,7 +198,7 @@ SECTIONS {
5042 /* Per-cpu data: */
5043 . = ALIGN(PERCPU_PAGE_SIZE);
5044 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5045 - __phys_per_cpu_start = __per_cpu_load;
5046 + __phys_per_cpu_start = per_cpu_load;
5047 /*
5048 * ensure percpu data fits
5049 * into percpu page size
5050 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5051 index 6cf0341..d352594 100644
5052 --- a/arch/ia64/mm/fault.c
5053 +++ b/arch/ia64/mm/fault.c
5054 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5055 return pte_present(pte);
5056 }
5057
5058 +#ifdef CONFIG_PAX_PAGEEXEC
5059 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5060 +{
5061 + unsigned long i;
5062 +
5063 + printk(KERN_ERR "PAX: bytes at PC: ");
5064 + for (i = 0; i < 8; i++) {
5065 + unsigned int c;
5066 + if (get_user(c, (unsigned int *)pc+i))
5067 + printk(KERN_CONT "???????? ");
5068 + else
5069 + printk(KERN_CONT "%08x ", c);
5070 + }
5071 + printk("\n");
5072 +}
5073 +#endif
5074 +
5075 # define VM_READ_BIT 0
5076 # define VM_WRITE_BIT 1
5077 # define VM_EXEC_BIT 2
5078 @@ -149,8 +166,21 @@ retry:
5079 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5080 goto bad_area;
5081
5082 - if ((vma->vm_flags & mask) != mask)
5083 + if ((vma->vm_flags & mask) != mask) {
5084 +
5085 +#ifdef CONFIG_PAX_PAGEEXEC
5086 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5087 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5088 + goto bad_area;
5089 +
5090 + up_read(&mm->mmap_sem);
5091 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5092 + do_group_exit(SIGKILL);
5093 + }
5094 +#endif
5095 +
5096 goto bad_area;
5097 + }
5098
5099 /*
5100 * If for any reason at all we couldn't handle the fault, make
5101 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5102 index 76069c1..c2aa816 100644
5103 --- a/arch/ia64/mm/hugetlbpage.c
5104 +++ b/arch/ia64/mm/hugetlbpage.c
5105 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5106 unsigned long pgoff, unsigned long flags)
5107 {
5108 struct vm_unmapped_area_info info;
5109 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5110
5111 if (len > RGN_MAP_LIMIT)
5112 return -ENOMEM;
5113 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5114 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5115 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5116 info.align_offset = 0;
5117 + info.threadstack_offset = offset;
5118 return vm_unmapped_area(&info);
5119 }
5120
5121 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5122 index d1fe4b4..2628f37 100644
5123 --- a/arch/ia64/mm/init.c
5124 +++ b/arch/ia64/mm/init.c
5125 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5126 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5127 vma->vm_end = vma->vm_start + PAGE_SIZE;
5128 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5129 +
5130 +#ifdef CONFIG_PAX_PAGEEXEC
5131 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5132 + vma->vm_flags &= ~VM_EXEC;
5133 +
5134 +#ifdef CONFIG_PAX_MPROTECT
5135 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5136 + vma->vm_flags &= ~VM_MAYEXEC;
5137 +#endif
5138 +
5139 + }
5140 +#endif
5141 +
5142 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5143 down_write(&current->mm->mmap_sem);
5144 if (insert_vm_struct(current->mm, vma)) {
5145 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5146 index 40b3ee9..8c2c112 100644
5147 --- a/arch/m32r/include/asm/cache.h
5148 +++ b/arch/m32r/include/asm/cache.h
5149 @@ -1,8 +1,10 @@
5150 #ifndef _ASM_M32R_CACHE_H
5151 #define _ASM_M32R_CACHE_H
5152
5153 +#include <linux/const.h>
5154 +
5155 /* L1 cache line size */
5156 #define L1_CACHE_SHIFT 4
5157 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5158 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5159
5160 #endif /* _ASM_M32R_CACHE_H */
5161 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5162 index 82abd15..d95ae5d 100644
5163 --- a/arch/m32r/lib/usercopy.c
5164 +++ b/arch/m32r/lib/usercopy.c
5165 @@ -14,6 +14,9 @@
5166 unsigned long
5167 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5168 {
5169 + if ((long)n < 0)
5170 + return n;
5171 +
5172 prefetch(from);
5173 if (access_ok(VERIFY_WRITE, to, n))
5174 __copy_user(to,from,n);
5175 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5176 unsigned long
5177 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5178 {
5179 + if ((long)n < 0)
5180 + return n;
5181 +
5182 prefetchw(to);
5183 if (access_ok(VERIFY_READ, from, n))
5184 __copy_user_zeroing(to,from,n);
5185 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5186 index 0395c51..5f26031 100644
5187 --- a/arch/m68k/include/asm/cache.h
5188 +++ b/arch/m68k/include/asm/cache.h
5189 @@ -4,9 +4,11 @@
5190 #ifndef __ARCH_M68K_CACHE_H
5191 #define __ARCH_M68K_CACHE_H
5192
5193 +#include <linux/const.h>
5194 +
5195 /* bytes per L1 cache line */
5196 #define L1_CACHE_SHIFT 4
5197 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5198 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5199
5200 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5201
5202 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5203 index 3c52fa6..11b2ad8 100644
5204 --- a/arch/metag/mm/hugetlbpage.c
5205 +++ b/arch/metag/mm/hugetlbpage.c
5206 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5207 info.high_limit = TASK_SIZE;
5208 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5209 info.align_offset = 0;
5210 + info.threadstack_offset = 0;
5211 return vm_unmapped_area(&info);
5212 }
5213
5214 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5215 index 4efe96a..60e8699 100644
5216 --- a/arch/microblaze/include/asm/cache.h
5217 +++ b/arch/microblaze/include/asm/cache.h
5218 @@ -13,11 +13,12 @@
5219 #ifndef _ASM_MICROBLAZE_CACHE_H
5220 #define _ASM_MICROBLAZE_CACHE_H
5221
5222 +#include <linux/const.h>
5223 #include <asm/registers.h>
5224
5225 #define L1_CACHE_SHIFT 5
5226 /* word-granular cache in microblaze */
5227 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5228 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5229
5230 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5231
5232 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5233 index 08b6079..eb272cf 100644
5234 --- a/arch/mips/include/asm/atomic.h
5235 +++ b/arch/mips/include/asm/atomic.h
5236 @@ -21,6 +21,10 @@
5237 #include <asm/cmpxchg.h>
5238 #include <asm/war.h>
5239
5240 +#ifdef CONFIG_GENERIC_ATOMIC64
5241 +#include <asm-generic/atomic64.h>
5242 +#endif
5243 +
5244 #define ATOMIC_INIT(i) { (i) }
5245
5246 /*
5247 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5248 */
5249 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5250
5251 +#define atomic64_read_unchecked(v) atomic64_read(v)
5252 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5253 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5254 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5255 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5256 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5257 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5258 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5259 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5260 +
5261 #endif /* CONFIG_64BIT */
5262
5263 /*
5264 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5265 index b4db69f..8f3b093 100644
5266 --- a/arch/mips/include/asm/cache.h
5267 +++ b/arch/mips/include/asm/cache.h
5268 @@ -9,10 +9,11 @@
5269 #ifndef _ASM_CACHE_H
5270 #define _ASM_CACHE_H
5271
5272 +#include <linux/const.h>
5273 #include <kmalloc.h>
5274
5275 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5276 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5277 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5278
5279 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5280 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5281 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5282 index cf3ae24..238d22f 100644
5283 --- a/arch/mips/include/asm/elf.h
5284 +++ b/arch/mips/include/asm/elf.h
5285 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5286 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5287 #endif
5288
5289 +#ifdef CONFIG_PAX_ASLR
5290 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5291 +
5292 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5293 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5294 +#endif
5295 +
5296 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5297 struct linux_binprm;
5298 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5299 int uses_interp);
5300
5301 -struct mm_struct;
5302 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5303 -#define arch_randomize_brk arch_randomize_brk
5304 -
5305 #endif /* _ASM_ELF_H */
5306 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5307 index c1f6afa..38cc6e9 100644
5308 --- a/arch/mips/include/asm/exec.h
5309 +++ b/arch/mips/include/asm/exec.h
5310 @@ -12,6 +12,6 @@
5311 #ifndef _ASM_EXEC_H
5312 #define _ASM_EXEC_H
5313
5314 -extern unsigned long arch_align_stack(unsigned long sp);
5315 +#define arch_align_stack(x) ((x) & ~0xfUL)
5316
5317 #endif /* _ASM_EXEC_H */
5318 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5319 index f59552f..3abe9b9 100644
5320 --- a/arch/mips/include/asm/page.h
5321 +++ b/arch/mips/include/asm/page.h
5322 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5323 #ifdef CONFIG_CPU_MIPS32
5324 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5325 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5326 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5327 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5328 #else
5329 typedef struct { unsigned long long pte; } pte_t;
5330 #define pte_val(x) ((x).pte)
5331 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5332 index 881d18b..cea38bc 100644
5333 --- a/arch/mips/include/asm/pgalloc.h
5334 +++ b/arch/mips/include/asm/pgalloc.h
5335 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5336 {
5337 set_pud(pud, __pud((unsigned long)pmd));
5338 }
5339 +
5340 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5341 +{
5342 + pud_populate(mm, pud, pmd);
5343 +}
5344 #endif
5345
5346 /*
5347 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5348 index 895320e..bf63e10 100644
5349 --- a/arch/mips/include/asm/thread_info.h
5350 +++ b/arch/mips/include/asm/thread_info.h
5351 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5352 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5353 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5354 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5355 +/* li takes a 32bit immediate */
5356 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5357 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5358
5359 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5360 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5361 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5362 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5363 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5364 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5365 +
5366 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5367
5368 /* work to do in syscall_trace_leave() */
5369 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5370 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5371
5372 /* work to do on interrupt/exception return */
5373 #define _TIF_WORK_MASK \
5374 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5375 /* work to do on any return to u-space */
5376 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5377 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5378
5379 #endif /* __KERNEL__ */
5380
5381 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5382 index 1188e00..41cf144 100644
5383 --- a/arch/mips/kernel/binfmt_elfn32.c
5384 +++ b/arch/mips/kernel/binfmt_elfn32.c
5385 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5386 #undef ELF_ET_DYN_BASE
5387 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5388
5389 +#ifdef CONFIG_PAX_ASLR
5390 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5391 +
5392 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5393 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5394 +#endif
5395 +
5396 #include <asm/processor.h>
5397 #include <linux/module.h>
5398 #include <linux/elfcore.h>
5399 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5400 index 202e581..689ca79 100644
5401 --- a/arch/mips/kernel/binfmt_elfo32.c
5402 +++ b/arch/mips/kernel/binfmt_elfo32.c
5403 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5404 #undef ELF_ET_DYN_BASE
5405 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5406
5407 +#ifdef CONFIG_PAX_ASLR
5408 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5409 +
5410 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5411 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5412 +#endif
5413 +
5414 #include <asm/processor.h>
5415
5416 /*
5417 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5418 index c6a041d..b3e7318 100644
5419 --- a/arch/mips/kernel/process.c
5420 +++ b/arch/mips/kernel/process.c
5421 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5422 out:
5423 return pc;
5424 }
5425 -
5426 -/*
5427 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5428 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5429 - */
5430 -unsigned long arch_align_stack(unsigned long sp)
5431 -{
5432 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5433 - sp -= get_random_int() & ~PAGE_MASK;
5434 -
5435 - return sp & ALMASK;
5436 -}
5437 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5438 index 9c6299c..2fb4c22 100644
5439 --- a/arch/mips/kernel/ptrace.c
5440 +++ b/arch/mips/kernel/ptrace.c
5441 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5442 return arch;
5443 }
5444
5445 +#ifdef CONFIG_GRKERNSEC_SETXID
5446 +extern void gr_delayed_cred_worker(void);
5447 +#endif
5448 +
5449 /*
5450 * Notification of system call entry/exit
5451 * - triggered by current->work.syscall_trace
5452 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5453 /* do the secure computing check first */
5454 secure_computing_strict(regs->regs[2]);
5455
5456 +#ifdef CONFIG_GRKERNSEC_SETXID
5457 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5458 + gr_delayed_cred_worker();
5459 +#endif
5460 +
5461 if (!(current->ptrace & PT_PTRACED))
5462 goto out;
5463
5464 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5465 index 9b36424..e7f4154 100644
5466 --- a/arch/mips/kernel/scall32-o32.S
5467 +++ b/arch/mips/kernel/scall32-o32.S
5468 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5469
5470 stack_done:
5471 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5472 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5473 + li t1, _TIF_SYSCALL_WORK
5474 and t0, t1
5475 bnez t0, syscall_trace_entry # -> yes
5476
5477 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5478 index 97a5909..59622f8 100644
5479 --- a/arch/mips/kernel/scall64-64.S
5480 +++ b/arch/mips/kernel/scall64-64.S
5481 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5482
5483 sd a3, PT_R26(sp) # save a3 for syscall restarting
5484
5485 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5486 + li t1, _TIF_SYSCALL_WORK
5487 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5488 and t0, t1, t0
5489 bnez t0, syscall_trace_entry
5490 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5491 index edcb659..fb2ab09 100644
5492 --- a/arch/mips/kernel/scall64-n32.S
5493 +++ b/arch/mips/kernel/scall64-n32.S
5494 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5495
5496 sd a3, PT_R26(sp) # save a3 for syscall restarting
5497
5498 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5499 + li t1, _TIF_SYSCALL_WORK
5500 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5501 and t0, t1, t0
5502 bnez t0, n32_syscall_trace_entry
5503 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5504 index 74f485d..47d2c38 100644
5505 --- a/arch/mips/kernel/scall64-o32.S
5506 +++ b/arch/mips/kernel/scall64-o32.S
5507 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5508 PTR 4b, bad_stack
5509 .previous
5510
5511 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5512 + li t1, _TIF_SYSCALL_WORK
5513 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5514 and t0, t1, t0
5515 bnez t0, trace_a_syscall
5516 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5517 index 0fead53..a2c0fb5 100644
5518 --- a/arch/mips/mm/fault.c
5519 +++ b/arch/mips/mm/fault.c
5520 @@ -27,6 +27,23 @@
5521 #include <asm/highmem.h> /* For VMALLOC_END */
5522 #include <linux/kdebug.h>
5523
5524 +#ifdef CONFIG_PAX_PAGEEXEC
5525 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5526 +{
5527 + unsigned long i;
5528 +
5529 + printk(KERN_ERR "PAX: bytes at PC: ");
5530 + for (i = 0; i < 5; i++) {
5531 + unsigned int c;
5532 + if (get_user(c, (unsigned int *)pc+i))
5533 + printk(KERN_CONT "???????? ");
5534 + else
5535 + printk(KERN_CONT "%08x ", c);
5536 + }
5537 + printk("\n");
5538 +}
5539 +#endif
5540 +
5541 /*
5542 * This routine handles page faults. It determines the address,
5543 * and the problem, and then passes it off to one of the appropriate
5544 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5545 index 7e5fe27..9656513 100644
5546 --- a/arch/mips/mm/mmap.c
5547 +++ b/arch/mips/mm/mmap.c
5548 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5549 struct vm_area_struct *vma;
5550 unsigned long addr = addr0;
5551 int do_color_align;
5552 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5553 struct vm_unmapped_area_info info;
5554
5555 if (unlikely(len > TASK_SIZE))
5556 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5557 do_color_align = 1;
5558
5559 /* requesting a specific address */
5560 +
5561 +#ifdef CONFIG_PAX_RANDMMAP
5562 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5563 +#endif
5564 +
5565 if (addr) {
5566 if (do_color_align)
5567 addr = COLOUR_ALIGN(addr, pgoff);
5568 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5569 addr = PAGE_ALIGN(addr);
5570
5571 vma = find_vma(mm, addr);
5572 - if (TASK_SIZE - len >= addr &&
5573 - (!vma || addr + len <= vma->vm_start))
5574 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5575 return addr;
5576 }
5577
5578 info.length = len;
5579 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5580 info.align_offset = pgoff << PAGE_SHIFT;
5581 + info.threadstack_offset = offset;
5582
5583 if (dir == DOWN) {
5584 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5585 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5586 {
5587 unsigned long random_factor = 0UL;
5588
5589 +#ifdef CONFIG_PAX_RANDMMAP
5590 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5591 +#endif
5592 +
5593 if (current->flags & PF_RANDOMIZE) {
5594 random_factor = get_random_int();
5595 random_factor = random_factor << PAGE_SHIFT;
5596 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5597
5598 if (mmap_is_legacy()) {
5599 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5600 +
5601 +#ifdef CONFIG_PAX_RANDMMAP
5602 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5603 + mm->mmap_base += mm->delta_mmap;
5604 +#endif
5605 +
5606 mm->get_unmapped_area = arch_get_unmapped_area;
5607 mm->unmap_area = arch_unmap_area;
5608 } else {
5609 mm->mmap_base = mmap_base(random_factor);
5610 +
5611 +#ifdef CONFIG_PAX_RANDMMAP
5612 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5613 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5614 +#endif
5615 +
5616 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5617 mm->unmap_area = arch_unmap_area_topdown;
5618 }
5619 }
5620
5621 -static inline unsigned long brk_rnd(void)
5622 -{
5623 - unsigned long rnd = get_random_int();
5624 -
5625 - rnd = rnd << PAGE_SHIFT;
5626 - /* 8MB for 32bit, 256MB for 64bit */
5627 - if (TASK_IS_32BIT_ADDR)
5628 - rnd = rnd & 0x7ffffful;
5629 - else
5630 - rnd = rnd & 0xffffffful;
5631 -
5632 - return rnd;
5633 -}
5634 -
5635 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5636 -{
5637 - unsigned long base = mm->brk;
5638 - unsigned long ret;
5639 -
5640 - ret = PAGE_ALIGN(base + brk_rnd());
5641 -
5642 - if (ret < mm->brk)
5643 - return mm->brk;
5644 -
5645 - return ret;
5646 -}
5647 -
5648 int __virt_addr_valid(const volatile void *kaddr)
5649 {
5650 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5651 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5652 index 967d144..db12197 100644
5653 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5654 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5655 @@ -11,12 +11,14 @@
5656 #ifndef _ASM_PROC_CACHE_H
5657 #define _ASM_PROC_CACHE_H
5658
5659 +#include <linux/const.h>
5660 +
5661 /* L1 cache */
5662
5663 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5664 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5665 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5666 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5667 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5668 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5669
5670 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5671 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5672 index bcb5df2..84fabd2 100644
5673 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5674 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5675 @@ -16,13 +16,15 @@
5676 #ifndef _ASM_PROC_CACHE_H
5677 #define _ASM_PROC_CACHE_H
5678
5679 +#include <linux/const.h>
5680 +
5681 /*
5682 * L1 cache
5683 */
5684 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5685 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5686 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5687 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5688 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5689 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5690
5691 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5692 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5693 index 4ce7a01..449202a 100644
5694 --- a/arch/openrisc/include/asm/cache.h
5695 +++ b/arch/openrisc/include/asm/cache.h
5696 @@ -19,11 +19,13 @@
5697 #ifndef __ASM_OPENRISC_CACHE_H
5698 #define __ASM_OPENRISC_CACHE_H
5699
5700 +#include <linux/const.h>
5701 +
5702 /* FIXME: How can we replace these with values from the CPU...
5703 * they shouldn't be hard-coded!
5704 */
5705
5706 -#define L1_CACHE_BYTES 16
5707 #define L1_CACHE_SHIFT 4
5708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5709
5710 #endif /* __ASM_OPENRISC_CACHE_H */
5711 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5712 index 472886c..00e7df9 100644
5713 --- a/arch/parisc/include/asm/atomic.h
5714 +++ b/arch/parisc/include/asm/atomic.h
5715 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5716 return dec;
5717 }
5718
5719 +#define atomic64_read_unchecked(v) atomic64_read(v)
5720 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5721 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5722 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5723 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5724 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5725 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5726 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5727 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5728 +
5729 #endif /* !CONFIG_64BIT */
5730
5731
5732 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5733 index 47f11c7..3420df2 100644
5734 --- a/arch/parisc/include/asm/cache.h
5735 +++ b/arch/parisc/include/asm/cache.h
5736 @@ -5,6 +5,7 @@
5737 #ifndef __ARCH_PARISC_CACHE_H
5738 #define __ARCH_PARISC_CACHE_H
5739
5740 +#include <linux/const.h>
5741
5742 /*
5743 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5744 @@ -15,13 +16,13 @@
5745 * just ruin performance.
5746 */
5747 #ifdef CONFIG_PA20
5748 -#define L1_CACHE_BYTES 64
5749 #define L1_CACHE_SHIFT 6
5750 #else
5751 -#define L1_CACHE_BYTES 32
5752 #define L1_CACHE_SHIFT 5
5753 #endif
5754
5755 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5756 +
5757 #ifndef __ASSEMBLY__
5758
5759 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5760 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5761 index ad2b503..bdf1651 100644
5762 --- a/arch/parisc/include/asm/elf.h
5763 +++ b/arch/parisc/include/asm/elf.h
5764 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5765
5766 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5767
5768 +#ifdef CONFIG_PAX_ASLR
5769 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5770 +
5771 +#define PAX_DELTA_MMAP_LEN 16
5772 +#define PAX_DELTA_STACK_LEN 16
5773 +#endif
5774 +
5775 /* This yields a mask that user programs can use to figure out what
5776 instruction set this CPU supports. This could be done in user space,
5777 but it's not easy, and we've already done it here. */
5778 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5779 index fc987a1..6e068ef 100644
5780 --- a/arch/parisc/include/asm/pgalloc.h
5781 +++ b/arch/parisc/include/asm/pgalloc.h
5782 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5783 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5784 }
5785
5786 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5787 +{
5788 + pgd_populate(mm, pgd, pmd);
5789 +}
5790 +
5791 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5792 {
5793 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5794 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5795 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5796 #define pmd_free(mm, x) do { } while (0)
5797 #define pgd_populate(mm, pmd, pte) BUG()
5798 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5799
5800 #endif
5801
5802 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5803 index 1e40d7f..a3eb445 100644
5804 --- a/arch/parisc/include/asm/pgtable.h
5805 +++ b/arch/parisc/include/asm/pgtable.h
5806 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5807 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5808 #define PAGE_COPY PAGE_EXECREAD
5809 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5810 +
5811 +#ifdef CONFIG_PAX_PAGEEXEC
5812 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5813 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5814 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5815 +#else
5816 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5817 +# define PAGE_COPY_NOEXEC PAGE_COPY
5818 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5819 +#endif
5820 +
5821 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5822 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5823 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5824 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5825 index e0a8235..ce2f1e1 100644
5826 --- a/arch/parisc/include/asm/uaccess.h
5827 +++ b/arch/parisc/include/asm/uaccess.h
5828 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5829 const void __user *from,
5830 unsigned long n)
5831 {
5832 - int sz = __compiletime_object_size(to);
5833 + size_t sz = __compiletime_object_size(to);
5834 int ret = -EFAULT;
5835
5836 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5837 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5838 ret = __copy_from_user(to, from, n);
5839 else
5840 copy_from_user_overflow();
5841 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5842 index 2a625fb..9908930 100644
5843 --- a/arch/parisc/kernel/module.c
5844 +++ b/arch/parisc/kernel/module.c
5845 @@ -98,16 +98,38 @@
5846
5847 /* three functions to determine where in the module core
5848 * or init pieces the location is */
5849 +static inline int in_init_rx(struct module *me, void *loc)
5850 +{
5851 + return (loc >= me->module_init_rx &&
5852 + loc < (me->module_init_rx + me->init_size_rx));
5853 +}
5854 +
5855 +static inline int in_init_rw(struct module *me, void *loc)
5856 +{
5857 + return (loc >= me->module_init_rw &&
5858 + loc < (me->module_init_rw + me->init_size_rw));
5859 +}
5860 +
5861 static inline int in_init(struct module *me, void *loc)
5862 {
5863 - return (loc >= me->module_init &&
5864 - loc <= (me->module_init + me->init_size));
5865 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5866 +}
5867 +
5868 +static inline int in_core_rx(struct module *me, void *loc)
5869 +{
5870 + return (loc >= me->module_core_rx &&
5871 + loc < (me->module_core_rx + me->core_size_rx));
5872 +}
5873 +
5874 +static inline int in_core_rw(struct module *me, void *loc)
5875 +{
5876 + return (loc >= me->module_core_rw &&
5877 + loc < (me->module_core_rw + me->core_size_rw));
5878 }
5879
5880 static inline int in_core(struct module *me, void *loc)
5881 {
5882 - return (loc >= me->module_core &&
5883 - loc <= (me->module_core + me->core_size));
5884 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5885 }
5886
5887 static inline int in_local(struct module *me, void *loc)
5888 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5889 }
5890
5891 /* align things a bit */
5892 - me->core_size = ALIGN(me->core_size, 16);
5893 - me->arch.got_offset = me->core_size;
5894 - me->core_size += gots * sizeof(struct got_entry);
5895 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5896 + me->arch.got_offset = me->core_size_rw;
5897 + me->core_size_rw += gots * sizeof(struct got_entry);
5898
5899 - me->core_size = ALIGN(me->core_size, 16);
5900 - me->arch.fdesc_offset = me->core_size;
5901 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5902 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5903 + me->arch.fdesc_offset = me->core_size_rw;
5904 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5905
5906 me->arch.got_max = gots;
5907 me->arch.fdesc_max = fdescs;
5908 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5909
5910 BUG_ON(value == 0);
5911
5912 - got = me->module_core + me->arch.got_offset;
5913 + got = me->module_core_rw + me->arch.got_offset;
5914 for (i = 0; got[i].addr; i++)
5915 if (got[i].addr == value)
5916 goto out;
5917 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5918 #ifdef CONFIG_64BIT
5919 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5920 {
5921 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5922 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5923
5924 if (!value) {
5925 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5926 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5927
5928 /* Create new one */
5929 fdesc->addr = value;
5930 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5931 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5932 return (Elf_Addr)fdesc;
5933 }
5934 #endif /* CONFIG_64BIT */
5935 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5936
5937 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5938 end = table + sechdrs[me->arch.unwind_section].sh_size;
5939 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5940 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5941
5942 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5943 me->arch.unwind_section, table, end, gp);
5944 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5945 index 5dfd248..64914ac 100644
5946 --- a/arch/parisc/kernel/sys_parisc.c
5947 +++ b/arch/parisc/kernel/sys_parisc.c
5948 @@ -33,9 +33,11 @@
5949 #include <linux/utsname.h>
5950 #include <linux/personality.h>
5951
5952 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5953 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5954 + unsigned long flags)
5955 {
5956 struct vm_unmapped_area_info info;
5957 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5958
5959 info.flags = 0;
5960 info.length = len;
5961 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5962 info.high_limit = TASK_SIZE;
5963 info.align_mask = 0;
5964 info.align_offset = 0;
5965 + info.threadstack_offset = offset;
5966 return vm_unmapped_area(&info);
5967 }
5968
5969 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5970 return (unsigned long) mapping >> 8;
5971 }
5972
5973 -static unsigned long get_shared_area(struct address_space *mapping,
5974 - unsigned long addr, unsigned long len, unsigned long pgoff)
5975 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5976 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5977 {
5978 struct vm_unmapped_area_info info;
5979 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5980
5981 info.flags = 0;
5982 info.length = len;
5983 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5984 info.high_limit = TASK_SIZE;
5985 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5986 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5987 + info.threadstack_offset = offset;
5988 return vm_unmapped_area(&info);
5989 }
5990
5991 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5992 return -EINVAL;
5993 return addr;
5994 }
5995 - if (!addr)
5996 + if (!addr) {
5997 addr = TASK_UNMAPPED_BASE;
5998
5999 +#ifdef CONFIG_PAX_RANDMMAP
6000 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
6001 + addr += current->mm->delta_mmap;
6002 +#endif
6003 +
6004 + }
6005 +
6006 if (filp) {
6007 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6008 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6009 } else if(flags & MAP_SHARED) {
6010 - addr = get_shared_area(NULL, addr, len, pgoff);
6011 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6012 } else {
6013 - addr = get_unshared_area(addr, len);
6014 + addr = get_unshared_area(filp, addr, len, flags);
6015 }
6016 return addr;
6017 }
6018 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6019 index 04e47c6..7a8faf6 100644
6020 --- a/arch/parisc/kernel/traps.c
6021 +++ b/arch/parisc/kernel/traps.c
6022 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6023
6024 down_read(&current->mm->mmap_sem);
6025 vma = find_vma(current->mm,regs->iaoq[0]);
6026 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6027 - && (vma->vm_flags & VM_EXEC)) {
6028 -
6029 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6030 fault_address = regs->iaoq[0];
6031 fault_space = regs->iasq[0];
6032
6033 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6034 index f247a34..dc0f219 100644
6035 --- a/arch/parisc/mm/fault.c
6036 +++ b/arch/parisc/mm/fault.c
6037 @@ -15,6 +15,7 @@
6038 #include <linux/sched.h>
6039 #include <linux/interrupt.h>
6040 #include <linux/module.h>
6041 +#include <linux/unistd.h>
6042
6043 #include <asm/uaccess.h>
6044 #include <asm/traps.h>
6045 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6046 static unsigned long
6047 parisc_acctyp(unsigned long code, unsigned int inst)
6048 {
6049 - if (code == 6 || code == 16)
6050 + if (code == 6 || code == 7 || code == 16)
6051 return VM_EXEC;
6052
6053 switch (inst & 0xf0000000) {
6054 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6055 }
6056 #endif
6057
6058 +#ifdef CONFIG_PAX_PAGEEXEC
6059 +/*
6060 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6061 + *
6062 + * returns 1 when task should be killed
6063 + * 2 when rt_sigreturn trampoline was detected
6064 + * 3 when unpatched PLT trampoline was detected
6065 + */
6066 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6067 +{
6068 +
6069 +#ifdef CONFIG_PAX_EMUPLT
6070 + int err;
6071 +
6072 + do { /* PaX: unpatched PLT emulation */
6073 + unsigned int bl, depwi;
6074 +
6075 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6076 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6077 +
6078 + if (err)
6079 + break;
6080 +
6081 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6082 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6083 +
6084 + err = get_user(ldw, (unsigned int *)addr);
6085 + err |= get_user(bv, (unsigned int *)(addr+4));
6086 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6087 +
6088 + if (err)
6089 + break;
6090 +
6091 + if (ldw == 0x0E801096U &&
6092 + bv == 0xEAC0C000U &&
6093 + ldw2 == 0x0E881095U)
6094 + {
6095 + unsigned int resolver, map;
6096 +
6097 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6098 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6099 + if (err)
6100 + break;
6101 +
6102 + regs->gr[20] = instruction_pointer(regs)+8;
6103 + regs->gr[21] = map;
6104 + regs->gr[22] = resolver;
6105 + regs->iaoq[0] = resolver | 3UL;
6106 + regs->iaoq[1] = regs->iaoq[0] + 4;
6107 + return 3;
6108 + }
6109 + }
6110 + } while (0);
6111 +#endif
6112 +
6113 +#ifdef CONFIG_PAX_EMUTRAMP
6114 +
6115 +#ifndef CONFIG_PAX_EMUSIGRT
6116 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6117 + return 1;
6118 +#endif
6119 +
6120 + do { /* PaX: rt_sigreturn emulation */
6121 + unsigned int ldi1, ldi2, bel, nop;
6122 +
6123 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6124 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6125 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6126 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6127 +
6128 + if (err)
6129 + break;
6130 +
6131 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6132 + ldi2 == 0x3414015AU &&
6133 + bel == 0xE4008200U &&
6134 + nop == 0x08000240U)
6135 + {
6136 + regs->gr[25] = (ldi1 & 2) >> 1;
6137 + regs->gr[20] = __NR_rt_sigreturn;
6138 + regs->gr[31] = regs->iaoq[1] + 16;
6139 + regs->sr[0] = regs->iasq[1];
6140 + regs->iaoq[0] = 0x100UL;
6141 + regs->iaoq[1] = regs->iaoq[0] + 4;
6142 + regs->iasq[0] = regs->sr[2];
6143 + regs->iasq[1] = regs->sr[2];
6144 + return 2;
6145 + }
6146 + } while (0);
6147 +#endif
6148 +
6149 + return 1;
6150 +}
6151 +
6152 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6153 +{
6154 + unsigned long i;
6155 +
6156 + printk(KERN_ERR "PAX: bytes at PC: ");
6157 + for (i = 0; i < 5; i++) {
6158 + unsigned int c;
6159 + if (get_user(c, (unsigned int *)pc+i))
6160 + printk(KERN_CONT "???????? ");
6161 + else
6162 + printk(KERN_CONT "%08x ", c);
6163 + }
6164 + printk("\n");
6165 +}
6166 +#endif
6167 +
6168 int fixup_exception(struct pt_regs *regs)
6169 {
6170 const struct exception_table_entry *fix;
6171 @@ -194,8 +305,33 @@ good_area:
6172
6173 acc_type = parisc_acctyp(code,regs->iir);
6174
6175 - if ((vma->vm_flags & acc_type) != acc_type)
6176 + if ((vma->vm_flags & acc_type) != acc_type) {
6177 +
6178 +#ifdef CONFIG_PAX_PAGEEXEC
6179 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6180 + (address & ~3UL) == instruction_pointer(regs))
6181 + {
6182 + up_read(&mm->mmap_sem);
6183 + switch (pax_handle_fetch_fault(regs)) {
6184 +
6185 +#ifdef CONFIG_PAX_EMUPLT
6186 + case 3:
6187 + return;
6188 +#endif
6189 +
6190 +#ifdef CONFIG_PAX_EMUTRAMP
6191 + case 2:
6192 + return;
6193 +#endif
6194 +
6195 + }
6196 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6197 + do_group_exit(SIGKILL);
6198 + }
6199 +#endif
6200 +
6201 goto bad_area;
6202 + }
6203
6204 /*
6205 * If for any reason at all we couldn't handle the fault, make
6206 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6207 index e3b1d41..8e81edf 100644
6208 --- a/arch/powerpc/include/asm/atomic.h
6209 +++ b/arch/powerpc/include/asm/atomic.h
6210 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6211 return t1;
6212 }
6213
6214 +#define atomic64_read_unchecked(v) atomic64_read(v)
6215 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6216 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6217 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6218 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6219 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6220 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6221 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6222 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6223 +
6224 #endif /* __powerpc64__ */
6225
6226 #endif /* __KERNEL__ */
6227 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6228 index 9e495c9..b6878e5 100644
6229 --- a/arch/powerpc/include/asm/cache.h
6230 +++ b/arch/powerpc/include/asm/cache.h
6231 @@ -3,6 +3,7 @@
6232
6233 #ifdef __KERNEL__
6234
6235 +#include <linux/const.h>
6236
6237 /* bytes per L1 cache line */
6238 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6239 @@ -22,7 +23,7 @@
6240 #define L1_CACHE_SHIFT 7
6241 #endif
6242
6243 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6244 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6245
6246 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6247
6248 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6249 index cc0655a..13eac2e 100644
6250 --- a/arch/powerpc/include/asm/elf.h
6251 +++ b/arch/powerpc/include/asm/elf.h
6252 @@ -28,8 +28,19 @@
6253 the loader. We need to make sure that it is out of the way of the program
6254 that it will "exec", and that there is sufficient room for the brk. */
6255
6256 -extern unsigned long randomize_et_dyn(unsigned long base);
6257 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6258 +#define ELF_ET_DYN_BASE (0x20000000)
6259 +
6260 +#ifdef CONFIG_PAX_ASLR
6261 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6262 +
6263 +#ifdef __powerpc64__
6264 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6265 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6266 +#else
6267 +#define PAX_DELTA_MMAP_LEN 15
6268 +#define PAX_DELTA_STACK_LEN 15
6269 +#endif
6270 +#endif
6271
6272 /*
6273 * Our registers are always unsigned longs, whether we're a 32 bit
6274 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6275 (0x7ff >> (PAGE_SHIFT - 12)) : \
6276 (0x3ffff >> (PAGE_SHIFT - 12)))
6277
6278 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6279 -#define arch_randomize_brk arch_randomize_brk
6280 -
6281 -
6282 #ifdef CONFIG_SPU_BASE
6283 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6284 #define NT_SPU 1
6285 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6286 index 8196e9c..d83a9f3 100644
6287 --- a/arch/powerpc/include/asm/exec.h
6288 +++ b/arch/powerpc/include/asm/exec.h
6289 @@ -4,6 +4,6 @@
6290 #ifndef _ASM_POWERPC_EXEC_H
6291 #define _ASM_POWERPC_EXEC_H
6292
6293 -extern unsigned long arch_align_stack(unsigned long sp);
6294 +#define arch_align_stack(x) ((x) & ~0xfUL)
6295
6296 #endif /* _ASM_POWERPC_EXEC_H */
6297 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6298 index 5acabbd..7ea14fa 100644
6299 --- a/arch/powerpc/include/asm/kmap_types.h
6300 +++ b/arch/powerpc/include/asm/kmap_types.h
6301 @@ -10,7 +10,7 @@
6302 * 2 of the License, or (at your option) any later version.
6303 */
6304
6305 -#define KM_TYPE_NR 16
6306 +#define KM_TYPE_NR 17
6307
6308 #endif /* __KERNEL__ */
6309 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6310 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6311 index 8565c25..2865190 100644
6312 --- a/arch/powerpc/include/asm/mman.h
6313 +++ b/arch/powerpc/include/asm/mman.h
6314 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6315 }
6316 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6317
6318 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6319 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6320 {
6321 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6322 }
6323 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6324 index 988c812..63c7d70 100644
6325 --- a/arch/powerpc/include/asm/page.h
6326 +++ b/arch/powerpc/include/asm/page.h
6327 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6328 * and needs to be executable. This means the whole heap ends
6329 * up being executable.
6330 */
6331 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6332 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6333 +#define VM_DATA_DEFAULT_FLAGS32 \
6334 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6335 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6336
6337 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6338 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6339 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6340 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6341 #endif
6342
6343 +#define ktla_ktva(addr) (addr)
6344 +#define ktva_ktla(addr) (addr)
6345 +
6346 #ifndef CONFIG_PPC_BOOK3S_64
6347 /*
6348 * Use the top bit of the higher-level page table entries to indicate whether
6349 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6350 index 88693ce..ac6f9ab 100644
6351 --- a/arch/powerpc/include/asm/page_64.h
6352 +++ b/arch/powerpc/include/asm/page_64.h
6353 @@ -153,15 +153,18 @@ do { \
6354 * stack by default, so in the absence of a PT_GNU_STACK program header
6355 * we turn execute permission off.
6356 */
6357 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6358 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6359 +#define VM_STACK_DEFAULT_FLAGS32 \
6360 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6361 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6362
6363 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6364 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6365
6366 +#ifndef CONFIG_PAX_PAGEEXEC
6367 #define VM_STACK_DEFAULT_FLAGS \
6368 (is_32bit_task() ? \
6369 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6370 +#endif
6371
6372 #include <asm-generic/getorder.h>
6373
6374 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6375 index b66ae72..4a378cd 100644
6376 --- a/arch/powerpc/include/asm/pgalloc-64.h
6377 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6378 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6379 #ifndef CONFIG_PPC_64K_PAGES
6380
6381 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6382 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6383
6384 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6385 {
6386 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6387 pud_set(pud, (unsigned long)pmd);
6388 }
6389
6390 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6391 +{
6392 + pud_populate(mm, pud, pmd);
6393 +}
6394 +
6395 #define pmd_populate(mm, pmd, pte_page) \
6396 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6397 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6398 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6399 #endif
6400
6401 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6402 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6403
6404 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6405 pte_t *pte)
6406 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6407 index 7aeb955..19f748e 100644
6408 --- a/arch/powerpc/include/asm/pgtable.h
6409 +++ b/arch/powerpc/include/asm/pgtable.h
6410 @@ -2,6 +2,7 @@
6411 #define _ASM_POWERPC_PGTABLE_H
6412 #ifdef __KERNEL__
6413
6414 +#include <linux/const.h>
6415 #ifndef __ASSEMBLY__
6416 #include <asm/processor.h> /* For TASK_SIZE */
6417 #include <asm/mmu.h>
6418 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6419 index 4aad413..85d86bf 100644
6420 --- a/arch/powerpc/include/asm/pte-hash32.h
6421 +++ b/arch/powerpc/include/asm/pte-hash32.h
6422 @@ -21,6 +21,7 @@
6423 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6424 #define _PAGE_USER 0x004 /* usermode access allowed */
6425 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6426 +#define _PAGE_EXEC _PAGE_GUARDED
6427 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6428 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6429 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6430 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6431 index 4a9e408..724aa59 100644
6432 --- a/arch/powerpc/include/asm/reg.h
6433 +++ b/arch/powerpc/include/asm/reg.h
6434 @@ -234,6 +234,7 @@
6435 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6436 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6437 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6438 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6439 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6440 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6441 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6442 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6443 index ffbaabe..eabe843 100644
6444 --- a/arch/powerpc/include/asm/smp.h
6445 +++ b/arch/powerpc/include/asm/smp.h
6446 @@ -50,7 +50,7 @@ struct smp_ops_t {
6447 int (*cpu_disable)(void);
6448 void (*cpu_die)(unsigned int nr);
6449 int (*cpu_bootable)(unsigned int nr);
6450 -};
6451 +} __no_const;
6452
6453 extern void smp_send_debugger_break(void);
6454 extern void start_secondary_resume(void);
6455 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6456 index ba7b197..d292e26 100644
6457 --- a/arch/powerpc/include/asm/thread_info.h
6458 +++ b/arch/powerpc/include/asm/thread_info.h
6459 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6460 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6461 TIF_NEED_RESCHED */
6462 #define TIF_32BIT 4 /* 32 bit binary */
6463 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6464 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6465 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6466 #define TIF_SINGLESTEP 8 /* singlestepping active */
6467 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6468 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6469 for stack store? */
6470 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6471 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6472 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6473 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6474
6475 /* as above, but as bit values */
6476 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6477 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6478 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6479 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6480 #define _TIF_NOHZ (1<<TIF_NOHZ)
6481 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6482 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6483 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6484 - _TIF_NOHZ)
6485 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6486
6487 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6488 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6489 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6490 index 4db4959..aba5c41 100644
6491 --- a/arch/powerpc/include/asm/uaccess.h
6492 +++ b/arch/powerpc/include/asm/uaccess.h
6493 @@ -318,52 +318,6 @@ do { \
6494 extern unsigned long __copy_tofrom_user(void __user *to,
6495 const void __user *from, unsigned long size);
6496
6497 -#ifndef __powerpc64__
6498 -
6499 -static inline unsigned long copy_from_user(void *to,
6500 - const void __user *from, unsigned long n)
6501 -{
6502 - unsigned long over;
6503 -
6504 - if (access_ok(VERIFY_READ, from, n))
6505 - return __copy_tofrom_user((__force void __user *)to, from, n);
6506 - if ((unsigned long)from < TASK_SIZE) {
6507 - over = (unsigned long)from + n - TASK_SIZE;
6508 - return __copy_tofrom_user((__force void __user *)to, from,
6509 - n - over) + over;
6510 - }
6511 - return n;
6512 -}
6513 -
6514 -static inline unsigned long copy_to_user(void __user *to,
6515 - const void *from, unsigned long n)
6516 -{
6517 - unsigned long over;
6518 -
6519 - if (access_ok(VERIFY_WRITE, to, n))
6520 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6521 - if ((unsigned long)to < TASK_SIZE) {
6522 - over = (unsigned long)to + n - TASK_SIZE;
6523 - return __copy_tofrom_user(to, (__force void __user *)from,
6524 - n - over) + over;
6525 - }
6526 - return n;
6527 -}
6528 -
6529 -#else /* __powerpc64__ */
6530 -
6531 -#define __copy_in_user(to, from, size) \
6532 - __copy_tofrom_user((to), (from), (size))
6533 -
6534 -extern unsigned long copy_from_user(void *to, const void __user *from,
6535 - unsigned long n);
6536 -extern unsigned long copy_to_user(void __user *to, const void *from,
6537 - unsigned long n);
6538 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6539 - unsigned long n);
6540 -
6541 -#endif /* __powerpc64__ */
6542 -
6543 static inline unsigned long __copy_from_user_inatomic(void *to,
6544 const void __user *from, unsigned long n)
6545 {
6546 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6547 if (ret == 0)
6548 return 0;
6549 }
6550 +
6551 + if (!__builtin_constant_p(n))
6552 + check_object_size(to, n, false);
6553 +
6554 return __copy_tofrom_user((__force void __user *)to, from, n);
6555 }
6556
6557 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6558 if (ret == 0)
6559 return 0;
6560 }
6561 +
6562 + if (!__builtin_constant_p(n))
6563 + check_object_size(from, n, true);
6564 +
6565 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6566 }
6567
6568 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6569 return __copy_to_user_inatomic(to, from, size);
6570 }
6571
6572 +#ifndef __powerpc64__
6573 +
6574 +static inline unsigned long __must_check copy_from_user(void *to,
6575 + const void __user *from, unsigned long n)
6576 +{
6577 + unsigned long over;
6578 +
6579 + if ((long)n < 0)
6580 + return n;
6581 +
6582 + if (access_ok(VERIFY_READ, from, n)) {
6583 + if (!__builtin_constant_p(n))
6584 + check_object_size(to, n, false);
6585 + return __copy_tofrom_user((__force void __user *)to, from, n);
6586 + }
6587 + if ((unsigned long)from < TASK_SIZE) {
6588 + over = (unsigned long)from + n - TASK_SIZE;
6589 + if (!__builtin_constant_p(n - over))
6590 + check_object_size(to, n - over, false);
6591 + return __copy_tofrom_user((__force void __user *)to, from,
6592 + n - over) + over;
6593 + }
6594 + return n;
6595 +}
6596 +
6597 +static inline unsigned long __must_check copy_to_user(void __user *to,
6598 + const void *from, unsigned long n)
6599 +{
6600 + unsigned long over;
6601 +
6602 + if ((long)n < 0)
6603 + return n;
6604 +
6605 + if (access_ok(VERIFY_WRITE, to, n)) {
6606 + if (!__builtin_constant_p(n))
6607 + check_object_size(from, n, true);
6608 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6609 + }
6610 + if ((unsigned long)to < TASK_SIZE) {
6611 + over = (unsigned long)to + n - TASK_SIZE;
6612 + if (!__builtin_constant_p(n))
6613 + check_object_size(from, n - over, true);
6614 + return __copy_tofrom_user(to, (__force void __user *)from,
6615 + n - over) + over;
6616 + }
6617 + return n;
6618 +}
6619 +
6620 +#else /* __powerpc64__ */
6621 +
6622 +#define __copy_in_user(to, from, size) \
6623 + __copy_tofrom_user((to), (from), (size))
6624 +
6625 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6626 +{
6627 + if ((long)n < 0 || n > INT_MAX)
6628 + return n;
6629 +
6630 + if (!__builtin_constant_p(n))
6631 + check_object_size(to, n, false);
6632 +
6633 + if (likely(access_ok(VERIFY_READ, from, n)))
6634 + n = __copy_from_user(to, from, n);
6635 + else
6636 + memset(to, 0, n);
6637 + return n;
6638 +}
6639 +
6640 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6641 +{
6642 + if ((long)n < 0 || n > INT_MAX)
6643 + return n;
6644 +
6645 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6646 + if (!__builtin_constant_p(n))
6647 + check_object_size(from, n, true);
6648 + n = __copy_to_user(to, from, n);
6649 + }
6650 + return n;
6651 +}
6652 +
6653 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6654 + unsigned long n);
6655 +
6656 +#endif /* __powerpc64__ */
6657 +
6658 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6659
6660 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6661 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6662 index 645170a..6cf0271 100644
6663 --- a/arch/powerpc/kernel/exceptions-64e.S
6664 +++ b/arch/powerpc/kernel/exceptions-64e.S
6665 @@ -757,6 +757,7 @@ storage_fault_common:
6666 std r14,_DAR(r1)
6667 std r15,_DSISR(r1)
6668 addi r3,r1,STACK_FRAME_OVERHEAD
6669 + bl .save_nvgprs
6670 mr r4,r14
6671 mr r5,r15
6672 ld r14,PACA_EXGEN+EX_R14(r13)
6673 @@ -765,8 +766,7 @@ storage_fault_common:
6674 cmpdi r3,0
6675 bne- 1f
6676 b .ret_from_except_lite
6677 -1: bl .save_nvgprs
6678 - mr r5,r3
6679 +1: mr r5,r3
6680 addi r3,r1,STACK_FRAME_OVERHEAD
6681 ld r4,_DAR(r1)
6682 bl .bad_page_fault
6683 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6684 index 40e4a17..5a84b37 100644
6685 --- a/arch/powerpc/kernel/exceptions-64s.S
6686 +++ b/arch/powerpc/kernel/exceptions-64s.S
6687 @@ -1362,10 +1362,10 @@ handle_page_fault:
6688 11: ld r4,_DAR(r1)
6689 ld r5,_DSISR(r1)
6690 addi r3,r1,STACK_FRAME_OVERHEAD
6691 + bl .save_nvgprs
6692 bl .do_page_fault
6693 cmpdi r3,0
6694 beq+ 12f
6695 - bl .save_nvgprs
6696 mr r5,r3
6697 addi r3,r1,STACK_FRAME_OVERHEAD
6698 lwz r4,_DAR(r1)
6699 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6700 index 2e3200c..72095ce 100644
6701 --- a/arch/powerpc/kernel/module_32.c
6702 +++ b/arch/powerpc/kernel/module_32.c
6703 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6704 me->arch.core_plt_section = i;
6705 }
6706 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6707 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6708 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6709 return -ENOEXEC;
6710 }
6711
6712 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6713
6714 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6715 /* Init, or core PLT? */
6716 - if (location >= mod->module_core
6717 - && location < mod->module_core + mod->core_size)
6718 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6719 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6720 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6721 - else
6722 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6723 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6724 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6725 + else {
6726 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6727 + return ~0UL;
6728 + }
6729
6730 /* Find this entry, or if that fails, the next avail. entry */
6731 while (entry->jump[0]) {
6732 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6733 index 076d124..6cb2cbf 100644
6734 --- a/arch/powerpc/kernel/process.c
6735 +++ b/arch/powerpc/kernel/process.c
6736 @@ -874,8 +874,8 @@ void show_regs(struct pt_regs * regs)
6737 * Lookup NIP late so we have the best change of getting the
6738 * above info out without failing
6739 */
6740 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6741 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6742 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6743 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6744 #endif
6745 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6746 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6747 @@ -1335,10 +1335,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6748 newsp = stack[0];
6749 ip = stack[STACK_FRAME_LR_SAVE];
6750 if (!firstframe || ip != lr) {
6751 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6752 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6753 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6754 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6755 - printk(" (%pS)",
6756 + printk(" (%pA)",
6757 (void *)current->ret_stack[curr_frame].ret);
6758 curr_frame--;
6759 }
6760 @@ -1358,7 +1358,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6761 struct pt_regs *regs = (struct pt_regs *)
6762 (sp + STACK_FRAME_OVERHEAD);
6763 lr = regs->link;
6764 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6765 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6766 regs->trap, (void *)regs->nip, (void *)lr);
6767 firstframe = 1;
6768 }
6769 @@ -1394,58 +1394,3 @@ void notrace __ppc64_runlatch_off(void)
6770 mtspr(SPRN_CTRLT, ctrl);
6771 }
6772 #endif /* CONFIG_PPC64 */
6773 -
6774 -unsigned long arch_align_stack(unsigned long sp)
6775 -{
6776 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6777 - sp -= get_random_int() & ~PAGE_MASK;
6778 - return sp & ~0xf;
6779 -}
6780 -
6781 -static inline unsigned long brk_rnd(void)
6782 -{
6783 - unsigned long rnd = 0;
6784 -
6785 - /* 8MB for 32bit, 1GB for 64bit */
6786 - if (is_32bit_task())
6787 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6788 - else
6789 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6790 -
6791 - return rnd << PAGE_SHIFT;
6792 -}
6793 -
6794 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6795 -{
6796 - unsigned long base = mm->brk;
6797 - unsigned long ret;
6798 -
6799 -#ifdef CONFIG_PPC_STD_MMU_64
6800 - /*
6801 - * If we are using 1TB segments and we are allowed to randomise
6802 - * the heap, we can put it above 1TB so it is backed by a 1TB
6803 - * segment. Otherwise the heap will be in the bottom 1TB
6804 - * which always uses 256MB segments and this may result in a
6805 - * performance penalty.
6806 - */
6807 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6808 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6809 -#endif
6810 -
6811 - ret = PAGE_ALIGN(base + brk_rnd());
6812 -
6813 - if (ret < mm->brk)
6814 - return mm->brk;
6815 -
6816 - return ret;
6817 -}
6818 -
6819 -unsigned long randomize_et_dyn(unsigned long base)
6820 -{
6821 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6822 -
6823 - if (ret < base)
6824 - return base;
6825 -
6826 - return ret;
6827 -}
6828 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6829 index 98c2fc1..b73a4ca 100644
6830 --- a/arch/powerpc/kernel/ptrace.c
6831 +++ b/arch/powerpc/kernel/ptrace.c
6832 @@ -1781,6 +1781,10 @@ long arch_ptrace(struct task_struct *child, long request,
6833 return ret;
6834 }
6835
6836 +#ifdef CONFIG_GRKERNSEC_SETXID
6837 +extern void gr_delayed_cred_worker(void);
6838 +#endif
6839 +
6840 /*
6841 * We must return the syscall number to actually look up in the table.
6842 * This can be -1L to skip running any syscall at all.
6843 @@ -1793,6 +1797,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6844
6845 secure_computing_strict(regs->gpr[0]);
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 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6853 tracehook_report_syscall_entry(regs))
6854 /*
6855 @@ -1827,6 +1836,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6856 {
6857 int step;
6858
6859 +#ifdef CONFIG_GRKERNSEC_SETXID
6860 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6861 + gr_delayed_cred_worker();
6862 +#endif
6863 +
6864 audit_syscall_exit(regs);
6865
6866 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6867 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6868 index 201385c..0f01828 100644
6869 --- a/arch/powerpc/kernel/signal_32.c
6870 +++ b/arch/powerpc/kernel/signal_32.c
6871 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6872 /* Save user registers on the stack */
6873 frame = &rt_sf->uc.uc_mcontext;
6874 addr = frame;
6875 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6876 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6877 sigret = 0;
6878 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6879 } else {
6880 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6881 index 3459473..2d40783 100644
6882 --- a/arch/powerpc/kernel/signal_64.c
6883 +++ b/arch/powerpc/kernel/signal_64.c
6884 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6885 #endif
6886
6887 /* Set up to return from userspace. */
6888 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6889 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6890 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6891 } else {
6892 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6893 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6894 index e68a845..8b140e6 100644
6895 --- a/arch/powerpc/kernel/sysfs.c
6896 +++ b/arch/powerpc/kernel/sysfs.c
6897 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6898 return NOTIFY_OK;
6899 }
6900
6901 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6902 +static struct notifier_block sysfs_cpu_nb = {
6903 .notifier_call = sysfs_cpu_notify,
6904 };
6905
6906 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6907 index c0e5caf..68e8305 100644
6908 --- a/arch/powerpc/kernel/traps.c
6909 +++ b/arch/powerpc/kernel/traps.c
6910 @@ -143,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6911 return flags;
6912 }
6913
6914 +extern void gr_handle_kernel_exploit(void);
6915 +
6916 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6917 int signr)
6918 {
6919 @@ -192,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6920 panic("Fatal exception in interrupt");
6921 if (panic_on_oops)
6922 panic("Fatal exception");
6923 +
6924 + gr_handle_kernel_exploit();
6925 +
6926 do_exit(signr);
6927 }
6928
6929 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6930 index d4f463a..8fb7431 100644
6931 --- a/arch/powerpc/kernel/vdso.c
6932 +++ b/arch/powerpc/kernel/vdso.c
6933 @@ -34,6 +34,7 @@
6934 #include <asm/firmware.h>
6935 #include <asm/vdso.h>
6936 #include <asm/vdso_datapage.h>
6937 +#include <asm/mman.h>
6938
6939 #include "setup.h"
6940
6941 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6942 vdso_base = VDSO32_MBASE;
6943 #endif
6944
6945 - current->mm->context.vdso_base = 0;
6946 + current->mm->context.vdso_base = ~0UL;
6947
6948 /* vDSO has a problem and was disabled, just don't "enable" it for the
6949 * process
6950 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6951 vdso_base = get_unmapped_area(NULL, vdso_base,
6952 (vdso_pages << PAGE_SHIFT) +
6953 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6954 - 0, 0);
6955 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6956 if (IS_ERR_VALUE(vdso_base)) {
6957 rc = vdso_base;
6958 goto fail_mmapsem;
6959 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6960 index 5eea6f3..5d10396 100644
6961 --- a/arch/powerpc/lib/usercopy_64.c
6962 +++ b/arch/powerpc/lib/usercopy_64.c
6963 @@ -9,22 +9,6 @@
6964 #include <linux/module.h>
6965 #include <asm/uaccess.h>
6966
6967 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6968 -{
6969 - if (likely(access_ok(VERIFY_READ, from, n)))
6970 - n = __copy_from_user(to, from, n);
6971 - else
6972 - memset(to, 0, n);
6973 - return n;
6974 -}
6975 -
6976 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6977 -{
6978 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6979 - n = __copy_to_user(to, from, n);
6980 - return n;
6981 -}
6982 -
6983 unsigned long copy_in_user(void __user *to, const void __user *from,
6984 unsigned long n)
6985 {
6986 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6987 return n;
6988 }
6989
6990 -EXPORT_SYMBOL(copy_from_user);
6991 -EXPORT_SYMBOL(copy_to_user);
6992 EXPORT_SYMBOL(copy_in_user);
6993
6994 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6995 index 8726779..a33c512 100644
6996 --- a/arch/powerpc/mm/fault.c
6997 +++ b/arch/powerpc/mm/fault.c
6998 @@ -33,6 +33,10 @@
6999 #include <linux/magic.h>
7000 #include <linux/ratelimit.h>
7001 #include <linux/context_tracking.h>
7002 +#include <linux/slab.h>
7003 +#include <linux/pagemap.h>
7004 +#include <linux/compiler.h>
7005 +#include <linux/unistd.h>
7006
7007 #include <asm/firmware.h>
7008 #include <asm/page.h>
7009 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7010 }
7011 #endif
7012
7013 +#ifdef CONFIG_PAX_PAGEEXEC
7014 +/*
7015 + * PaX: decide what to do with offenders (regs->nip = fault address)
7016 + *
7017 + * returns 1 when task should be killed
7018 + */
7019 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7020 +{
7021 + return 1;
7022 +}
7023 +
7024 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7025 +{
7026 + unsigned long i;
7027 +
7028 + printk(KERN_ERR "PAX: bytes at PC: ");
7029 + for (i = 0; i < 5; i++) {
7030 + unsigned int c;
7031 + if (get_user(c, (unsigned int __user *)pc+i))
7032 + printk(KERN_CONT "???????? ");
7033 + else
7034 + printk(KERN_CONT "%08x ", c);
7035 + }
7036 + printk("\n");
7037 +}
7038 +#endif
7039 +
7040 /*
7041 * Check whether the instruction at regs->nip is a store using
7042 * an update addressing form which will update r1.
7043 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7044 * indicate errors in DSISR but can validly be set in SRR1.
7045 */
7046 if (trap == 0x400)
7047 - error_code &= 0x48200000;
7048 + error_code &= 0x58200000;
7049 else
7050 is_write = error_code & DSISR_ISSTORE;
7051 #else
7052 @@ -371,7 +402,7 @@ good_area:
7053 * "undefined". Of those that can be set, this is the only
7054 * one which seems bad.
7055 */
7056 - if (error_code & 0x10000000)
7057 + if (error_code & DSISR_GUARDED)
7058 /* Guarded storage error. */
7059 goto bad_area;
7060 #endif /* CONFIG_8xx */
7061 @@ -386,7 +417,7 @@ good_area:
7062 * processors use the same I/D cache coherency mechanism
7063 * as embedded.
7064 */
7065 - if (error_code & DSISR_PROTFAULT)
7066 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7067 goto bad_area;
7068 #endif /* CONFIG_PPC_STD_MMU */
7069
7070 @@ -471,6 +502,23 @@ bad_area:
7071 bad_area_nosemaphore:
7072 /* User mode accesses cause a SIGSEGV */
7073 if (user_mode(regs)) {
7074 +
7075 +#ifdef CONFIG_PAX_PAGEEXEC
7076 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7077 +#ifdef CONFIG_PPC_STD_MMU
7078 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7079 +#else
7080 + if (is_exec && regs->nip == address) {
7081 +#endif
7082 + switch (pax_handle_fetch_fault(regs)) {
7083 + }
7084 +
7085 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7086 + do_group_exit(SIGKILL);
7087 + }
7088 + }
7089 +#endif
7090 +
7091 _exception(SIGSEGV, regs, code, address);
7092 goto bail;
7093 }
7094 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7095 index 67a42ed..cd463e0 100644
7096 --- a/arch/powerpc/mm/mmap_64.c
7097 +++ b/arch/powerpc/mm/mmap_64.c
7098 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7099 {
7100 unsigned long rnd = 0;
7101
7102 +#ifdef CONFIG_PAX_RANDMMAP
7103 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7104 +#endif
7105 +
7106 if (current->flags & PF_RANDOMIZE) {
7107 /* 8MB for 32bit, 1GB for 64bit */
7108 if (is_32bit_task())
7109 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7110 */
7111 if (mmap_is_legacy()) {
7112 mm->mmap_base = TASK_UNMAPPED_BASE;
7113 +
7114 +#ifdef CONFIG_PAX_RANDMMAP
7115 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7116 + mm->mmap_base += mm->delta_mmap;
7117 +#endif
7118 +
7119 mm->get_unmapped_area = arch_get_unmapped_area;
7120 mm->unmap_area = arch_unmap_area;
7121 } else {
7122 mm->mmap_base = mmap_base();
7123 +
7124 +#ifdef CONFIG_PAX_RANDMMAP
7125 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7126 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7127 +#endif
7128 +
7129 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7130 mm->unmap_area = arch_unmap_area_topdown;
7131 }
7132 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7133 index e779642..e5bb889 100644
7134 --- a/arch/powerpc/mm/mmu_context_nohash.c
7135 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7136 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7137 return NOTIFY_OK;
7138 }
7139
7140 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7141 +static struct notifier_block mmu_context_cpu_nb = {
7142 .notifier_call = mmu_context_cpu_notify,
7143 };
7144
7145 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7146 index 88c0425..717feb8 100644
7147 --- a/arch/powerpc/mm/numa.c
7148 +++ b/arch/powerpc/mm/numa.c
7149 @@ -919,7 +919,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7150 return ret;
7151 }
7152
7153 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7154 +static struct notifier_block ppc64_numa_nb = {
7155 .notifier_call = cpu_numa_callback,
7156 .priority = 1 /* Must run before sched domains notifier. */
7157 };
7158 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7159 index 3e99c14..f00953c 100644
7160 --- a/arch/powerpc/mm/slice.c
7161 +++ b/arch/powerpc/mm/slice.c
7162 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7163 if ((mm->task_size - len) < addr)
7164 return 0;
7165 vma = find_vma(mm, addr);
7166 - return (!vma || (addr + len) <= vma->vm_start);
7167 + return check_heap_stack_gap(vma, addr, len, 0);
7168 }
7169
7170 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7171 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7172 info.align_offset = 0;
7173
7174 addr = TASK_UNMAPPED_BASE;
7175 +
7176 +#ifdef CONFIG_PAX_RANDMMAP
7177 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7178 + addr += mm->delta_mmap;
7179 +#endif
7180 +
7181 while (addr < TASK_SIZE) {
7182 info.low_limit = addr;
7183 if (!slice_scan_available(addr, available, 1, &addr))
7184 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7185 if (fixed && addr > (mm->task_size - len))
7186 return -EINVAL;
7187
7188 +#ifdef CONFIG_PAX_RANDMMAP
7189 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7190 + addr = 0;
7191 +#endif
7192 +
7193 /* If hint, make sure it matches our alignment restrictions */
7194 if (!fixed && addr) {
7195 addr = _ALIGN_UP(addr, 1ul << pshift);
7196 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7197 index 9098692..3d54cd1 100644
7198 --- a/arch/powerpc/platforms/cell/spufs/file.c
7199 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7200 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7201 return VM_FAULT_NOPAGE;
7202 }
7203
7204 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7205 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7206 unsigned long address,
7207 - void *buf, int len, int write)
7208 + void *buf, size_t len, int write)
7209 {
7210 struct spu_context *ctx = vma->vm_file->private_data;
7211 unsigned long offset = address - vma->vm_start;
7212 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7213 index bdb738a..49c9f95 100644
7214 --- a/arch/powerpc/platforms/powermac/smp.c
7215 +++ b/arch/powerpc/platforms/powermac/smp.c
7216 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7217 return NOTIFY_OK;
7218 }
7219
7220 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7221 +static struct notifier_block smp_core99_cpu_nb = {
7222 .notifier_call = smp_core99_cpu_notify,
7223 };
7224 #endif /* CONFIG_HOTPLUG_CPU */
7225 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7226 index c797832..ce575c8 100644
7227 --- a/arch/s390/include/asm/atomic.h
7228 +++ b/arch/s390/include/asm/atomic.h
7229 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7230 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7231 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7232
7233 +#define atomic64_read_unchecked(v) atomic64_read(v)
7234 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7235 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7236 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7237 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7238 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7239 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7240 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7241 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7242 +
7243 #define smp_mb__before_atomic_dec() smp_mb()
7244 #define smp_mb__after_atomic_dec() smp_mb()
7245 #define smp_mb__before_atomic_inc() smp_mb()
7246 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7247 index 4d7ccac..d03d0ad 100644
7248 --- a/arch/s390/include/asm/cache.h
7249 +++ b/arch/s390/include/asm/cache.h
7250 @@ -9,8 +9,10 @@
7251 #ifndef __ARCH_S390_CACHE_H
7252 #define __ARCH_S390_CACHE_H
7253
7254 -#define L1_CACHE_BYTES 256
7255 +#include <linux/const.h>
7256 +
7257 #define L1_CACHE_SHIFT 8
7258 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7259 #define NET_SKB_PAD 32
7260
7261 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7262 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7263 index 78f4f87..598ce39 100644
7264 --- a/arch/s390/include/asm/elf.h
7265 +++ b/arch/s390/include/asm/elf.h
7266 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7267 the loader. We need to make sure that it is out of the way of the program
7268 that it will "exec", and that there is sufficient room for the brk. */
7269
7270 -extern unsigned long randomize_et_dyn(unsigned long base);
7271 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7272 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7273 +
7274 +#ifdef CONFIG_PAX_ASLR
7275 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7276 +
7277 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7278 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7279 +#endif
7280
7281 /* This yields a mask that user programs can use to figure out what
7282 instruction set this CPU supports. */
7283 @@ -222,9 +228,6 @@ struct linux_binprm;
7284 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7285 int arch_setup_additional_pages(struct linux_binprm *, int);
7286
7287 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7288 -#define arch_randomize_brk arch_randomize_brk
7289 -
7290 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7291
7292 #endif
7293 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7294 index c4a93d6..4d2a9b4 100644
7295 --- a/arch/s390/include/asm/exec.h
7296 +++ b/arch/s390/include/asm/exec.h
7297 @@ -7,6 +7,6 @@
7298 #ifndef __ASM_EXEC_H
7299 #define __ASM_EXEC_H
7300
7301 -extern unsigned long arch_align_stack(unsigned long sp);
7302 +#define arch_align_stack(x) ((x) & ~0xfUL)
7303
7304 #endif /* __ASM_EXEC_H */
7305 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7306 index 9c33ed4..e40cbef 100644
7307 --- a/arch/s390/include/asm/uaccess.h
7308 +++ b/arch/s390/include/asm/uaccess.h
7309 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7310 copy_to_user(void __user *to, const void *from, unsigned long n)
7311 {
7312 might_fault();
7313 +
7314 + if ((long)n < 0)
7315 + return n;
7316 +
7317 return __copy_to_user(to, from, n);
7318 }
7319
7320 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7321 static inline unsigned long __must_check
7322 __copy_from_user(void *to, const void __user *from, unsigned long n)
7323 {
7324 + if ((long)n < 0)
7325 + return n;
7326 +
7327 if (__builtin_constant_p(n) && (n <= 256))
7328 return uaccess.copy_from_user_small(n, from, to);
7329 else
7330 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7331 static inline unsigned long __must_check
7332 copy_from_user(void *to, const void __user *from, unsigned long n)
7333 {
7334 - unsigned int sz = __compiletime_object_size(to);
7335 + size_t sz = __compiletime_object_size(to);
7336
7337 might_fault();
7338 - if (unlikely(sz != -1 && sz < n)) {
7339 +
7340 + if ((long)n < 0)
7341 + return n;
7342 +
7343 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7344 copy_from_user_overflow();
7345 return n;
7346 }
7347 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7348 index 7845e15..59c4353 100644
7349 --- a/arch/s390/kernel/module.c
7350 +++ b/arch/s390/kernel/module.c
7351 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7352
7353 /* Increase core size by size of got & plt and set start
7354 offsets for got and plt. */
7355 - me->core_size = ALIGN(me->core_size, 4);
7356 - me->arch.got_offset = me->core_size;
7357 - me->core_size += me->arch.got_size;
7358 - me->arch.plt_offset = me->core_size;
7359 - me->core_size += me->arch.plt_size;
7360 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7361 + me->arch.got_offset = me->core_size_rw;
7362 + me->core_size_rw += me->arch.got_size;
7363 + me->arch.plt_offset = me->core_size_rx;
7364 + me->core_size_rx += me->arch.plt_size;
7365 return 0;
7366 }
7367
7368 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7369 if (info->got_initialized == 0) {
7370 Elf_Addr *gotent;
7371
7372 - gotent = me->module_core + me->arch.got_offset +
7373 + gotent = me->module_core_rw + me->arch.got_offset +
7374 info->got_offset;
7375 *gotent = val;
7376 info->got_initialized = 1;
7377 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7378 rc = apply_rela_bits(loc, val, 0, 64, 0);
7379 else if (r_type == R_390_GOTENT ||
7380 r_type == R_390_GOTPLTENT) {
7381 - val += (Elf_Addr) me->module_core - loc;
7382 + val += (Elf_Addr) me->module_core_rw - loc;
7383 rc = apply_rela_bits(loc, val, 1, 32, 1);
7384 }
7385 break;
7386 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7387 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7388 if (info->plt_initialized == 0) {
7389 unsigned int *ip;
7390 - ip = me->module_core + me->arch.plt_offset +
7391 + ip = me->module_core_rx + me->arch.plt_offset +
7392 info->plt_offset;
7393 #ifndef CONFIG_64BIT
7394 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7395 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7396 val - loc + 0xffffUL < 0x1ffffeUL) ||
7397 (r_type == R_390_PLT32DBL &&
7398 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7399 - val = (Elf_Addr) me->module_core +
7400 + val = (Elf_Addr) me->module_core_rx +
7401 me->arch.plt_offset +
7402 info->plt_offset;
7403 val += rela->r_addend - loc;
7404 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7405 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7406 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7407 val = val + rela->r_addend -
7408 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7409 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7410 if (r_type == R_390_GOTOFF16)
7411 rc = apply_rela_bits(loc, val, 0, 16, 0);
7412 else if (r_type == R_390_GOTOFF32)
7413 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7414 break;
7415 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7416 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7417 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7418 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7419 rela->r_addend - loc;
7420 if (r_type == R_390_GOTPC)
7421 rc = apply_rela_bits(loc, val, 1, 32, 0);
7422 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7423 index 2bc3edd..ab9d598 100644
7424 --- a/arch/s390/kernel/process.c
7425 +++ b/arch/s390/kernel/process.c
7426 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7427 }
7428 return 0;
7429 }
7430 -
7431 -unsigned long arch_align_stack(unsigned long sp)
7432 -{
7433 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7434 - sp -= get_random_int() & ~PAGE_MASK;
7435 - return sp & ~0xf;
7436 -}
7437 -
7438 -static inline unsigned long brk_rnd(void)
7439 -{
7440 - /* 8MB for 32bit, 1GB for 64bit */
7441 - if (is_32bit_task())
7442 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7443 - else
7444 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7445 -}
7446 -
7447 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7448 -{
7449 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7450 -
7451 - if (ret < mm->brk)
7452 - return mm->brk;
7453 - return ret;
7454 -}
7455 -
7456 -unsigned long randomize_et_dyn(unsigned long base)
7457 -{
7458 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7459 -
7460 - if (!(current->flags & PF_RANDOMIZE))
7461 - return base;
7462 - if (ret < base)
7463 - return base;
7464 - return ret;
7465 -}
7466 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7467 index 06bafec..2bca531 100644
7468 --- a/arch/s390/mm/mmap.c
7469 +++ b/arch/s390/mm/mmap.c
7470 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7471 */
7472 if (mmap_is_legacy()) {
7473 mm->mmap_base = TASK_UNMAPPED_BASE;
7474 +
7475 +#ifdef CONFIG_PAX_RANDMMAP
7476 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7477 + mm->mmap_base += mm->delta_mmap;
7478 +#endif
7479 +
7480 mm->get_unmapped_area = arch_get_unmapped_area;
7481 mm->unmap_area = arch_unmap_area;
7482 } else {
7483 mm->mmap_base = mmap_base();
7484 +
7485 +#ifdef CONFIG_PAX_RANDMMAP
7486 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7487 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7488 +#endif
7489 +
7490 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7491 mm->unmap_area = arch_unmap_area_topdown;
7492 }
7493 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7494 */
7495 if (mmap_is_legacy()) {
7496 mm->mmap_base = TASK_UNMAPPED_BASE;
7497 +
7498 +#ifdef CONFIG_PAX_RANDMMAP
7499 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7500 + mm->mmap_base += mm->delta_mmap;
7501 +#endif
7502 +
7503 mm->get_unmapped_area = s390_get_unmapped_area;
7504 mm->unmap_area = arch_unmap_area;
7505 } else {
7506 mm->mmap_base = mmap_base();
7507 +
7508 +#ifdef CONFIG_PAX_RANDMMAP
7509 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7510 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7511 +#endif
7512 +
7513 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7514 mm->unmap_area = arch_unmap_area_topdown;
7515 }
7516 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7517 index ae3d59f..f65f075 100644
7518 --- a/arch/score/include/asm/cache.h
7519 +++ b/arch/score/include/asm/cache.h
7520 @@ -1,7 +1,9 @@
7521 #ifndef _ASM_SCORE_CACHE_H
7522 #define _ASM_SCORE_CACHE_H
7523
7524 +#include <linux/const.h>
7525 +
7526 #define L1_CACHE_SHIFT 4
7527 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7528 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7529
7530 #endif /* _ASM_SCORE_CACHE_H */
7531 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7532 index f9f3cd5..58ff438 100644
7533 --- a/arch/score/include/asm/exec.h
7534 +++ b/arch/score/include/asm/exec.h
7535 @@ -1,6 +1,6 @@
7536 #ifndef _ASM_SCORE_EXEC_H
7537 #define _ASM_SCORE_EXEC_H
7538
7539 -extern unsigned long arch_align_stack(unsigned long sp);
7540 +#define arch_align_stack(x) (x)
7541
7542 #endif /* _ASM_SCORE_EXEC_H */
7543 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7544 index f4c6d02..e9355c3 100644
7545 --- a/arch/score/kernel/process.c
7546 +++ b/arch/score/kernel/process.c
7547 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7548
7549 return task_pt_regs(task)->cp0_epc;
7550 }
7551 -
7552 -unsigned long arch_align_stack(unsigned long sp)
7553 -{
7554 - return sp;
7555 -}
7556 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7557 index ef9e555..331bd29 100644
7558 --- a/arch/sh/include/asm/cache.h
7559 +++ b/arch/sh/include/asm/cache.h
7560 @@ -9,10 +9,11 @@
7561 #define __ASM_SH_CACHE_H
7562 #ifdef __KERNEL__
7563
7564 +#include <linux/const.h>
7565 #include <linux/init.h>
7566 #include <cpu/cache.h>
7567
7568 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7569 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7570
7571 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7572
7573 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7574 index 03f2b55..b0270327 100644
7575 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7576 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7577 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7578 return NOTIFY_OK;
7579 }
7580
7581 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7582 +static struct notifier_block shx3_cpu_notifier = {
7583 .notifier_call = shx3_cpu_callback,
7584 };
7585
7586 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7587 index 6777177..cb5e44f 100644
7588 --- a/arch/sh/mm/mmap.c
7589 +++ b/arch/sh/mm/mmap.c
7590 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7591 struct mm_struct *mm = current->mm;
7592 struct vm_area_struct *vma;
7593 int do_colour_align;
7594 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7595 struct vm_unmapped_area_info info;
7596
7597 if (flags & MAP_FIXED) {
7598 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7599 if (filp || (flags & MAP_SHARED))
7600 do_colour_align = 1;
7601
7602 +#ifdef CONFIG_PAX_RANDMMAP
7603 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7604 +#endif
7605 +
7606 if (addr) {
7607 if (do_colour_align)
7608 addr = COLOUR_ALIGN(addr, pgoff);
7609 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7610 addr = PAGE_ALIGN(addr);
7611
7612 vma = find_vma(mm, addr);
7613 - if (TASK_SIZE - len >= addr &&
7614 - (!vma || addr + len <= vma->vm_start))
7615 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7616 return addr;
7617 }
7618
7619 info.flags = 0;
7620 info.length = len;
7621 - info.low_limit = TASK_UNMAPPED_BASE;
7622 + info.low_limit = mm->mmap_base;
7623 info.high_limit = TASK_SIZE;
7624 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7625 info.align_offset = pgoff << PAGE_SHIFT;
7626 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7627 struct mm_struct *mm = current->mm;
7628 unsigned long addr = addr0;
7629 int do_colour_align;
7630 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7631 struct vm_unmapped_area_info info;
7632
7633 if (flags & MAP_FIXED) {
7634 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7635 if (filp || (flags & MAP_SHARED))
7636 do_colour_align = 1;
7637
7638 +#ifdef CONFIG_PAX_RANDMMAP
7639 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7640 +#endif
7641 +
7642 /* requesting a specific address */
7643 if (addr) {
7644 if (do_colour_align)
7645 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7646 addr = PAGE_ALIGN(addr);
7647
7648 vma = find_vma(mm, addr);
7649 - if (TASK_SIZE - len >= addr &&
7650 - (!vma || addr + len <= vma->vm_start))
7651 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7652 return addr;
7653 }
7654
7655 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7656 VM_BUG_ON(addr != -ENOMEM);
7657 info.flags = 0;
7658 info.low_limit = TASK_UNMAPPED_BASE;
7659 +
7660 +#ifdef CONFIG_PAX_RANDMMAP
7661 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7662 + info.low_limit += mm->delta_mmap;
7663 +#endif
7664 +
7665 info.high_limit = TASK_SIZE;
7666 addr = vm_unmapped_area(&info);
7667 }
7668 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7669 index be56a24..443328f 100644
7670 --- a/arch/sparc/include/asm/atomic_64.h
7671 +++ b/arch/sparc/include/asm/atomic_64.h
7672 @@ -14,18 +14,40 @@
7673 #define ATOMIC64_INIT(i) { (i) }
7674
7675 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7676 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7677 +{
7678 + return v->counter;
7679 +}
7680 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7681 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7682 +{
7683 + return v->counter;
7684 +}
7685
7686 #define atomic_set(v, i) (((v)->counter) = i)
7687 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7688 +{
7689 + v->counter = i;
7690 +}
7691 #define atomic64_set(v, i) (((v)->counter) = i)
7692 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7693 +{
7694 + v->counter = i;
7695 +}
7696
7697 extern void atomic_add(int, atomic_t *);
7698 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7699 extern void atomic64_add(long, atomic64_t *);
7700 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7701 extern void atomic_sub(int, atomic_t *);
7702 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7703 extern void atomic64_sub(long, atomic64_t *);
7704 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7705
7706 extern int atomic_add_ret(int, atomic_t *);
7707 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7708 extern long atomic64_add_ret(long, atomic64_t *);
7709 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7710 extern int atomic_sub_ret(int, atomic_t *);
7711 extern long atomic64_sub_ret(long, atomic64_t *);
7712
7713 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7714 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7715
7716 #define atomic_inc_return(v) atomic_add_ret(1, v)
7717 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7718 +{
7719 + return atomic_add_ret_unchecked(1, v);
7720 +}
7721 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7722 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7723 +{
7724 + return atomic64_add_ret_unchecked(1, v);
7725 +}
7726
7727 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7728 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7729
7730 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7731 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7732 +{
7733 + return atomic_add_ret_unchecked(i, v);
7734 +}
7735 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7736 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7737 +{
7738 + return atomic64_add_ret_unchecked(i, v);
7739 +}
7740
7741 /*
7742 * atomic_inc_and_test - increment and test
7743 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7744 * other cases.
7745 */
7746 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7747 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7748 +{
7749 + return atomic_inc_return_unchecked(v) == 0;
7750 +}
7751 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7752
7753 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7754 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7755 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7756
7757 #define atomic_inc(v) atomic_add(1, v)
7758 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7759 +{
7760 + atomic_add_unchecked(1, v);
7761 +}
7762 #define atomic64_inc(v) atomic64_add(1, v)
7763 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7764 +{
7765 + atomic64_add_unchecked(1, v);
7766 +}
7767
7768 #define atomic_dec(v) atomic_sub(1, v)
7769 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7770 +{
7771 + atomic_sub_unchecked(1, v);
7772 +}
7773 #define atomic64_dec(v) atomic64_sub(1, v)
7774 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7775 +{
7776 + atomic64_sub_unchecked(1, v);
7777 +}
7778
7779 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7780 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7781
7782 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7783 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7784 +{
7785 + return cmpxchg(&v->counter, old, new);
7786 +}
7787 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7788 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7789 +{
7790 + return xchg(&v->counter, new);
7791 +}
7792
7793 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7794 {
7795 - int c, old;
7796 + int c, old, new;
7797 c = atomic_read(v);
7798 for (;;) {
7799 - if (unlikely(c == (u)))
7800 + if (unlikely(c == u))
7801 break;
7802 - old = atomic_cmpxchg((v), c, c + (a));
7803 +
7804 + asm volatile("addcc %2, %0, %0\n"
7805 +
7806 +#ifdef CONFIG_PAX_REFCOUNT
7807 + "tvs %%icc, 6\n"
7808 +#endif
7809 +
7810 + : "=r" (new)
7811 + : "0" (c), "ir" (a)
7812 + : "cc");
7813 +
7814 + old = atomic_cmpxchg(v, c, new);
7815 if (likely(old == c))
7816 break;
7817 c = old;
7818 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7819 #define atomic64_cmpxchg(v, o, n) \
7820 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7821 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7822 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7823 +{
7824 + return xchg(&v->counter, new);
7825 +}
7826
7827 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7828 {
7829 - long c, old;
7830 + long c, old, new;
7831 c = atomic64_read(v);
7832 for (;;) {
7833 - if (unlikely(c == (u)))
7834 + if (unlikely(c == u))
7835 break;
7836 - old = atomic64_cmpxchg((v), c, c + (a));
7837 +
7838 + asm volatile("addcc %2, %0, %0\n"
7839 +
7840 +#ifdef CONFIG_PAX_REFCOUNT
7841 + "tvs %%xcc, 6\n"
7842 +#endif
7843 +
7844 + : "=r" (new)
7845 + : "0" (c), "ir" (a)
7846 + : "cc");
7847 +
7848 + old = atomic64_cmpxchg(v, c, new);
7849 if (likely(old == c))
7850 break;
7851 c = old;
7852 }
7853 - return c != (u);
7854 + return c != u;
7855 }
7856
7857 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7858 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7859 index 5bb6991..5c2132e 100644
7860 --- a/arch/sparc/include/asm/cache.h
7861 +++ b/arch/sparc/include/asm/cache.h
7862 @@ -7,10 +7,12 @@
7863 #ifndef _SPARC_CACHE_H
7864 #define _SPARC_CACHE_H
7865
7866 +#include <linux/const.h>
7867 +
7868 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7869
7870 #define L1_CACHE_SHIFT 5
7871 -#define L1_CACHE_BYTES 32
7872 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7873
7874 #ifdef CONFIG_SPARC32
7875 #define SMP_CACHE_BYTES_SHIFT 5
7876 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7877 index a24e41f..47677ff 100644
7878 --- a/arch/sparc/include/asm/elf_32.h
7879 +++ b/arch/sparc/include/asm/elf_32.h
7880 @@ -114,6 +114,13 @@ typedef struct {
7881
7882 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7883
7884 +#ifdef CONFIG_PAX_ASLR
7885 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7886 +
7887 +#define PAX_DELTA_MMAP_LEN 16
7888 +#define PAX_DELTA_STACK_LEN 16
7889 +#endif
7890 +
7891 /* This yields a mask that user programs can use to figure out what
7892 instruction set this cpu supports. This can NOT be done in userspace
7893 on Sparc. */
7894 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7895 index 370ca1e..d4f4a98 100644
7896 --- a/arch/sparc/include/asm/elf_64.h
7897 +++ b/arch/sparc/include/asm/elf_64.h
7898 @@ -189,6 +189,13 @@ typedef struct {
7899 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7900 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7901
7902 +#ifdef CONFIG_PAX_ASLR
7903 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7904 +
7905 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7906 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7907 +#endif
7908 +
7909 extern unsigned long sparc64_elf_hwcap;
7910 #define ELF_HWCAP sparc64_elf_hwcap
7911
7912 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7913 index 9b1c36d..209298b 100644
7914 --- a/arch/sparc/include/asm/pgalloc_32.h
7915 +++ b/arch/sparc/include/asm/pgalloc_32.h
7916 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7917 }
7918
7919 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7920 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7921
7922 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7923 unsigned long address)
7924 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7925 index bcfe063..b333142 100644
7926 --- a/arch/sparc/include/asm/pgalloc_64.h
7927 +++ b/arch/sparc/include/asm/pgalloc_64.h
7928 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7929 }
7930
7931 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7932 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7933
7934 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7935 {
7936 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7937 index 6fc1348..390c50a 100644
7938 --- a/arch/sparc/include/asm/pgtable_32.h
7939 +++ b/arch/sparc/include/asm/pgtable_32.h
7940 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7941 #define PAGE_SHARED SRMMU_PAGE_SHARED
7942 #define PAGE_COPY SRMMU_PAGE_COPY
7943 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7944 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7945 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7946 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7947 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7948
7949 /* Top-level page directory - dummy used by init-mm.
7950 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7951
7952 /* xwr */
7953 #define __P000 PAGE_NONE
7954 -#define __P001 PAGE_READONLY
7955 -#define __P010 PAGE_COPY
7956 -#define __P011 PAGE_COPY
7957 +#define __P001 PAGE_READONLY_NOEXEC
7958 +#define __P010 PAGE_COPY_NOEXEC
7959 +#define __P011 PAGE_COPY_NOEXEC
7960 #define __P100 PAGE_READONLY
7961 #define __P101 PAGE_READONLY
7962 #define __P110 PAGE_COPY
7963 #define __P111 PAGE_COPY
7964
7965 #define __S000 PAGE_NONE
7966 -#define __S001 PAGE_READONLY
7967 -#define __S010 PAGE_SHARED
7968 -#define __S011 PAGE_SHARED
7969 +#define __S001 PAGE_READONLY_NOEXEC
7970 +#define __S010 PAGE_SHARED_NOEXEC
7971 +#define __S011 PAGE_SHARED_NOEXEC
7972 #define __S100 PAGE_READONLY
7973 #define __S101 PAGE_READONLY
7974 #define __S110 PAGE_SHARED
7975 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7976 index 79da178..c2eede8 100644
7977 --- a/arch/sparc/include/asm/pgtsrmmu.h
7978 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7979 @@ -115,6 +115,11 @@
7980 SRMMU_EXEC | SRMMU_REF)
7981 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7982 SRMMU_EXEC | SRMMU_REF)
7983 +
7984 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7985 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7986 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7987 +
7988 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7989 SRMMU_DIRTY | SRMMU_REF)
7990
7991 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7992 index 9689176..63c18ea 100644
7993 --- a/arch/sparc/include/asm/spinlock_64.h
7994 +++ b/arch/sparc/include/asm/spinlock_64.h
7995 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7996
7997 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7998
7999 -static void inline arch_read_lock(arch_rwlock_t *lock)
8000 +static inline void arch_read_lock(arch_rwlock_t *lock)
8001 {
8002 unsigned long tmp1, tmp2;
8003
8004 __asm__ __volatile__ (
8005 "1: ldsw [%2], %0\n"
8006 " brlz,pn %0, 2f\n"
8007 -"4: add %0, 1, %1\n"
8008 +"4: addcc %0, 1, %1\n"
8009 +
8010 +#ifdef CONFIG_PAX_REFCOUNT
8011 +" tvs %%icc, 6\n"
8012 +#endif
8013 +
8014 " cas [%2], %0, %1\n"
8015 " cmp %0, %1\n"
8016 " bne,pn %%icc, 1b\n"
8017 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8018 " .previous"
8019 : "=&r" (tmp1), "=&r" (tmp2)
8020 : "r" (lock)
8021 - : "memory");
8022 + : "memory", "cc");
8023 }
8024
8025 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8026 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8027 {
8028 int tmp1, tmp2;
8029
8030 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8031 "1: ldsw [%2], %0\n"
8032 " brlz,a,pn %0, 2f\n"
8033 " mov 0, %0\n"
8034 -" add %0, 1, %1\n"
8035 +" addcc %0, 1, %1\n"
8036 +
8037 +#ifdef CONFIG_PAX_REFCOUNT
8038 +" tvs %%icc, 6\n"
8039 +#endif
8040 +
8041 " cas [%2], %0, %1\n"
8042 " cmp %0, %1\n"
8043 " bne,pn %%icc, 1b\n"
8044 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8045 return tmp1;
8046 }
8047
8048 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8049 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8050 {
8051 unsigned long tmp1, tmp2;
8052
8053 __asm__ __volatile__(
8054 "1: lduw [%2], %0\n"
8055 -" sub %0, 1, %1\n"
8056 +" subcc %0, 1, %1\n"
8057 +
8058 +#ifdef CONFIG_PAX_REFCOUNT
8059 +" tvs %%icc, 6\n"
8060 +#endif
8061 +
8062 " cas [%2], %0, %1\n"
8063 " cmp %0, %1\n"
8064 " bne,pn %%xcc, 1b\n"
8065 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8066 : "memory");
8067 }
8068
8069 -static void inline arch_write_lock(arch_rwlock_t *lock)
8070 +static inline void arch_write_lock(arch_rwlock_t *lock)
8071 {
8072 unsigned long mask, tmp1, tmp2;
8073
8074 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8075 : "memory");
8076 }
8077
8078 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8079 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8080 {
8081 __asm__ __volatile__(
8082 " stw %%g0, [%0]"
8083 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8084 : "memory");
8085 }
8086
8087 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8088 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8089 {
8090 unsigned long mask, tmp1, tmp2, result;
8091
8092 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8093 index dd38075..e7cac83 100644
8094 --- a/arch/sparc/include/asm/thread_info_32.h
8095 +++ b/arch/sparc/include/asm/thread_info_32.h
8096 @@ -49,6 +49,8 @@ struct thread_info {
8097 unsigned long w_saved;
8098
8099 struct restart_block restart_block;
8100 +
8101 + unsigned long lowest_stack;
8102 };
8103
8104 /*
8105 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8106 index d5e5042..9bfee76 100644
8107 --- a/arch/sparc/include/asm/thread_info_64.h
8108 +++ b/arch/sparc/include/asm/thread_info_64.h
8109 @@ -63,6 +63,8 @@ struct thread_info {
8110 struct pt_regs *kern_una_regs;
8111 unsigned int kern_una_insn;
8112
8113 + unsigned long lowest_stack;
8114 +
8115 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8116 };
8117
8118 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8119 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8120 /* flag bit 6 is available */
8121 #define TIF_32BIT 7 /* 32-bit binary */
8122 -/* flag bit 8 is available */
8123 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8124 #define TIF_SECCOMP 9 /* secure computing */
8125 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8126 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8127 +
8128 /* NOTE: Thread flags >= 12 should be ones we have no interest
8129 * in using in assembly, else we can't use the mask as
8130 * an immediate value in instructions such as andcc.
8131 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8132 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8133 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8134 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8135 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8136
8137 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8138 _TIF_DO_NOTIFY_RESUME_MASK | \
8139 _TIF_NEED_RESCHED)
8140 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8141
8142 +#define _TIF_WORK_SYSCALL \
8143 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8144 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8145 +
8146 +
8147 /*
8148 * Thread-synchronous status.
8149 *
8150 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8151 index 0167d26..767bb0c 100644
8152 --- a/arch/sparc/include/asm/uaccess.h
8153 +++ b/arch/sparc/include/asm/uaccess.h
8154 @@ -1,5 +1,6 @@
8155 #ifndef ___ASM_SPARC_UACCESS_H
8156 #define ___ASM_SPARC_UACCESS_H
8157 +
8158 #if defined(__sparc__) && defined(__arch64__)
8159 #include <asm/uaccess_64.h>
8160 #else
8161 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8162 index 53a28dd..50c38c3 100644
8163 --- a/arch/sparc/include/asm/uaccess_32.h
8164 +++ b/arch/sparc/include/asm/uaccess_32.h
8165 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8166
8167 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8168 {
8169 - if (n && __access_ok((unsigned long) to, n))
8170 + if ((long)n < 0)
8171 + return n;
8172 +
8173 + if (n && __access_ok((unsigned long) to, n)) {
8174 + if (!__builtin_constant_p(n))
8175 + check_object_size(from, n, true);
8176 return __copy_user(to, (__force void __user *) from, n);
8177 - else
8178 + } else
8179 return n;
8180 }
8181
8182 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8183 {
8184 + if ((long)n < 0)
8185 + return n;
8186 +
8187 + if (!__builtin_constant_p(n))
8188 + check_object_size(from, n, true);
8189 +
8190 return __copy_user(to, (__force void __user *) from, n);
8191 }
8192
8193 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8194 {
8195 - if (n && __access_ok((unsigned long) from, n))
8196 + if ((long)n < 0)
8197 + return n;
8198 +
8199 + if (n && __access_ok((unsigned long) from, n)) {
8200 + if (!__builtin_constant_p(n))
8201 + check_object_size(to, n, false);
8202 return __copy_user((__force void __user *) to, from, n);
8203 - else
8204 + } else
8205 return n;
8206 }
8207
8208 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8209 {
8210 + if ((long)n < 0)
8211 + return n;
8212 +
8213 return __copy_user((__force void __user *) to, from, n);
8214 }
8215
8216 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8217 index e562d3c..191f176 100644
8218 --- a/arch/sparc/include/asm/uaccess_64.h
8219 +++ b/arch/sparc/include/asm/uaccess_64.h
8220 @@ -10,6 +10,7 @@
8221 #include <linux/compiler.h>
8222 #include <linux/string.h>
8223 #include <linux/thread_info.h>
8224 +#include <linux/kernel.h>
8225 #include <asm/asi.h>
8226 #include <asm/spitfire.h>
8227 #include <asm-generic/uaccess-unaligned.h>
8228 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8229 static inline unsigned long __must_check
8230 copy_from_user(void *to, const void __user *from, unsigned long size)
8231 {
8232 - unsigned long ret = ___copy_from_user(to, from, size);
8233 + unsigned long ret;
8234
8235 + if ((long)size < 0 || size > INT_MAX)
8236 + return size;
8237 +
8238 + if (!__builtin_constant_p(size))
8239 + check_object_size(to, size, false);
8240 +
8241 + ret = ___copy_from_user(to, from, size);
8242 if (unlikely(ret))
8243 ret = copy_from_user_fixup(to, from, size);
8244
8245 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8246 static inline unsigned long __must_check
8247 copy_to_user(void __user *to, const void *from, unsigned long size)
8248 {
8249 - unsigned long ret = ___copy_to_user(to, from, size);
8250 + unsigned long ret;
8251
8252 + if ((long)size < 0 || size > INT_MAX)
8253 + return size;
8254 +
8255 + if (!__builtin_constant_p(size))
8256 + check_object_size(from, size, true);
8257 +
8258 + ret = ___copy_to_user(to, from, size);
8259 if (unlikely(ret))
8260 ret = copy_to_user_fixup(to, from, size);
8261 return ret;
8262 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8263 index d432fb2..6056af1 100644
8264 --- a/arch/sparc/kernel/Makefile
8265 +++ b/arch/sparc/kernel/Makefile
8266 @@ -3,7 +3,7 @@
8267 #
8268
8269 asflags-y := -ansi
8270 -ccflags-y := -Werror
8271 +#ccflags-y := -Werror
8272
8273 extra-y := head_$(BITS).o
8274
8275 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8276 index 5ef48da..11d460f 100644
8277 --- a/arch/sparc/kernel/ds.c
8278 +++ b/arch/sparc/kernel/ds.c
8279 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8280 char *base, *p;
8281 int msg_len, loops;
8282
8283 + if (strlen(var) + strlen(value) + 2 >
8284 + sizeof(pkt) - sizeof(pkt.header)) {
8285 + printk(KERN_ERR PFX
8286 + "contents length: %zu, which more than max: %lu,"
8287 + "so could not set (%s) variable to (%s).\n",
8288 + strlen(var) + strlen(value) + 2,
8289 + sizeof(pkt) - sizeof(pkt.header), var, value);
8290 + return;
8291 + }
8292 +
8293 memset(&pkt, 0, sizeof(pkt));
8294 pkt.header.data.tag.type = DS_DATA;
8295 pkt.header.data.handle = cp->handle;
8296 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8297 index fdd819d..5af08c8 100644
8298 --- a/arch/sparc/kernel/process_32.c
8299 +++ b/arch/sparc/kernel/process_32.c
8300 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8301
8302 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8303 r->psr, r->pc, r->npc, r->y, print_tainted());
8304 - printk("PC: <%pS>\n", (void *) r->pc);
8305 + printk("PC: <%pA>\n", (void *) r->pc);
8306 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8307 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8308 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8309 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8310 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8311 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8312 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8313 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8314
8315 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8316 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8317 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8318 rw = (struct reg_window32 *) fp;
8319 pc = rw->ins[7];
8320 printk("[%08lx : ", pc);
8321 - printk("%pS ] ", (void *) pc);
8322 + printk("%pA ] ", (void *) pc);
8323 fp = rw->ins[6];
8324 } while (++count < 16);
8325 printk("\n");
8326 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8327 index baebab2..9cd13b1 100644
8328 --- a/arch/sparc/kernel/process_64.c
8329 +++ b/arch/sparc/kernel/process_64.c
8330 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8331 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8332 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8333 if (regs->tstate & TSTATE_PRIV)
8334 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8335 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8336 }
8337
8338 void show_regs(struct pt_regs *regs)
8339 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8340
8341 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8342 regs->tpc, regs->tnpc, regs->y, print_tainted());
8343 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8344 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8345 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8346 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8347 regs->u_regs[3]);
8348 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8349 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8350 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8351 regs->u_regs[15]);
8352 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8353 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8354 show_regwindow(regs);
8355 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8356 }
8357 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8358 ((tp && tp->task) ? tp->task->pid : -1));
8359
8360 if (gp->tstate & TSTATE_PRIV) {
8361 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8362 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8363 (void *) gp->tpc,
8364 (void *) gp->o7,
8365 (void *) gp->i7,
8366 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8367 index 79cc0d1..ec62734 100644
8368 --- a/arch/sparc/kernel/prom_common.c
8369 +++ b/arch/sparc/kernel/prom_common.c
8370 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8371
8372 unsigned int prom_early_allocated __initdata;
8373
8374 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8375 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8376 .nextprop = prom_common_nextprop,
8377 .getproplen = prom_getproplen,
8378 .getproperty = prom_getproperty,
8379 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8380 index 7ff45e4..a58f271 100644
8381 --- a/arch/sparc/kernel/ptrace_64.c
8382 +++ b/arch/sparc/kernel/ptrace_64.c
8383 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8384 return ret;
8385 }
8386
8387 +#ifdef CONFIG_GRKERNSEC_SETXID
8388 +extern void gr_delayed_cred_worker(void);
8389 +#endif
8390 +
8391 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8392 {
8393 int ret = 0;
8394 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8395 /* do the secure computing check first */
8396 secure_computing_strict(regs->u_regs[UREG_G1]);
8397
8398 +#ifdef CONFIG_GRKERNSEC_SETXID
8399 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8400 + gr_delayed_cred_worker();
8401 +#endif
8402 +
8403 if (test_thread_flag(TIF_SYSCALL_TRACE))
8404 ret = tracehook_report_syscall_entry(regs);
8405
8406 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8407
8408 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8409 {
8410 +#ifdef CONFIG_GRKERNSEC_SETXID
8411 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8412 + gr_delayed_cred_worker();
8413 +#endif
8414 +
8415 audit_syscall_exit(regs);
8416
8417 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8418 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8419 index 3a8d184..49498a8 100644
8420 --- a/arch/sparc/kernel/sys_sparc_32.c
8421 +++ b/arch/sparc/kernel/sys_sparc_32.c
8422 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8423 if (len > TASK_SIZE - PAGE_SIZE)
8424 return -ENOMEM;
8425 if (!addr)
8426 - addr = TASK_UNMAPPED_BASE;
8427 + addr = current->mm->mmap_base;
8428
8429 info.flags = 0;
8430 info.length = len;
8431 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8432 index 2daaaa6..4fb84dc 100644
8433 --- a/arch/sparc/kernel/sys_sparc_64.c
8434 +++ b/arch/sparc/kernel/sys_sparc_64.c
8435 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8436 struct vm_area_struct * vma;
8437 unsigned long task_size = TASK_SIZE;
8438 int do_color_align;
8439 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8440 struct vm_unmapped_area_info info;
8441
8442 if (flags & MAP_FIXED) {
8443 /* We do not accept a shared mapping if it would violate
8444 * cache aliasing constraints.
8445 */
8446 - if ((flags & MAP_SHARED) &&
8447 + if ((filp || (flags & MAP_SHARED)) &&
8448 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8449 return -EINVAL;
8450 return addr;
8451 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8452 if (filp || (flags & MAP_SHARED))
8453 do_color_align = 1;
8454
8455 +#ifdef CONFIG_PAX_RANDMMAP
8456 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8457 +#endif
8458 +
8459 if (addr) {
8460 if (do_color_align)
8461 addr = COLOR_ALIGN(addr, pgoff);
8462 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8463 addr = PAGE_ALIGN(addr);
8464
8465 vma = find_vma(mm, addr);
8466 - if (task_size - len >= addr &&
8467 - (!vma || addr + len <= vma->vm_start))
8468 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8469 return addr;
8470 }
8471
8472 info.flags = 0;
8473 info.length = len;
8474 - info.low_limit = TASK_UNMAPPED_BASE;
8475 + info.low_limit = mm->mmap_base;
8476 info.high_limit = min(task_size, VA_EXCLUDE_START);
8477 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8478 info.align_offset = pgoff << PAGE_SHIFT;
8479 + info.threadstack_offset = offset;
8480 addr = vm_unmapped_area(&info);
8481
8482 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8483 VM_BUG_ON(addr != -ENOMEM);
8484 info.low_limit = VA_EXCLUDE_END;
8485 +
8486 +#ifdef CONFIG_PAX_RANDMMAP
8487 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8488 + info.low_limit += mm->delta_mmap;
8489 +#endif
8490 +
8491 info.high_limit = task_size;
8492 addr = vm_unmapped_area(&info);
8493 }
8494 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8495 unsigned long task_size = STACK_TOP32;
8496 unsigned long addr = addr0;
8497 int do_color_align;
8498 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8499 struct vm_unmapped_area_info info;
8500
8501 /* This should only ever run for 32-bit processes. */
8502 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8503 /* We do not accept a shared mapping if it would violate
8504 * cache aliasing constraints.
8505 */
8506 - if ((flags & MAP_SHARED) &&
8507 + if ((filp || (flags & MAP_SHARED)) &&
8508 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8509 return -EINVAL;
8510 return addr;
8511 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8512 if (filp || (flags & MAP_SHARED))
8513 do_color_align = 1;
8514
8515 +#ifdef CONFIG_PAX_RANDMMAP
8516 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8517 +#endif
8518 +
8519 /* requesting a specific address */
8520 if (addr) {
8521 if (do_color_align)
8522 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8523 addr = PAGE_ALIGN(addr);
8524
8525 vma = find_vma(mm, addr);
8526 - if (task_size - len >= addr &&
8527 - (!vma || addr + len <= vma->vm_start))
8528 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8529 return addr;
8530 }
8531
8532 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8533 info.high_limit = mm->mmap_base;
8534 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8535 info.align_offset = pgoff << PAGE_SHIFT;
8536 + info.threadstack_offset = offset;
8537 addr = vm_unmapped_area(&info);
8538
8539 /*
8540 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8541 VM_BUG_ON(addr != -ENOMEM);
8542 info.flags = 0;
8543 info.low_limit = TASK_UNMAPPED_BASE;
8544 +
8545 +#ifdef CONFIG_PAX_RANDMMAP
8546 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8547 + info.low_limit += mm->delta_mmap;
8548 +#endif
8549 +
8550 info.high_limit = STACK_TOP32;
8551 addr = vm_unmapped_area(&info);
8552 }
8553 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
8554 EXPORT_SYMBOL(get_fb_unmapped_area);
8555
8556 /* Essentially the same as PowerPC. */
8557 -static unsigned long mmap_rnd(void)
8558 +static unsigned long mmap_rnd(struct mm_struct *mm)
8559 {
8560 unsigned long rnd = 0UL;
8561
8562 +#ifdef CONFIG_PAX_RANDMMAP
8563 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8564 +#endif
8565 +
8566 if (current->flags & PF_RANDOMIZE) {
8567 unsigned long val = get_random_int();
8568 if (test_thread_flag(TIF_32BIT))
8569 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
8570
8571 void arch_pick_mmap_layout(struct mm_struct *mm)
8572 {
8573 - unsigned long random_factor = mmap_rnd();
8574 + unsigned long random_factor = mmap_rnd(mm);
8575 unsigned long gap;
8576
8577 /*
8578 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8579 gap == RLIM_INFINITY ||
8580 sysctl_legacy_va_layout) {
8581 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8582 +
8583 +#ifdef CONFIG_PAX_RANDMMAP
8584 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8585 + mm->mmap_base += mm->delta_mmap;
8586 +#endif
8587 +
8588 mm->get_unmapped_area = arch_get_unmapped_area;
8589 mm->unmap_area = arch_unmap_area;
8590 } else {
8591 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8592 gap = (task_size / 6 * 5);
8593
8594 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8595 +
8596 +#ifdef CONFIG_PAX_RANDMMAP
8597 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8598 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8599 +#endif
8600 +
8601 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8602 mm->unmap_area = arch_unmap_area_topdown;
8603 }
8604 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8605 index 22a1098..6255eb9 100644
8606 --- a/arch/sparc/kernel/syscalls.S
8607 +++ b/arch/sparc/kernel/syscalls.S
8608 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8609 #endif
8610 .align 32
8611 1: ldx [%g6 + TI_FLAGS], %l5
8612 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8613 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8614 be,pt %icc, rtrap
8615 nop
8616 call syscall_trace_leave
8617 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8618
8619 srl %i5, 0, %o5 ! IEU1
8620 srl %i2, 0, %o2 ! IEU0 Group
8621 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8622 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8623 bne,pn %icc, linux_syscall_trace32 ! CTI
8624 mov %i0, %l5 ! IEU1
8625 call %l7 ! CTI Group brk forced
8626 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8627
8628 mov %i3, %o3 ! IEU1
8629 mov %i4, %o4 ! IEU0 Group
8630 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8631 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8632 bne,pn %icc, linux_syscall_trace ! CTI Group
8633 mov %i0, %l5 ! IEU0
8634 2: call %l7 ! CTI Group brk forced
8635 @@ -223,7 +223,7 @@ ret_sys_call:
8636
8637 cmp %o0, -ERESTART_RESTARTBLOCK
8638 bgeu,pn %xcc, 1f
8639 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8640 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8641 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8642
8643 2:
8644 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8645 index 654e8aa..45f431b 100644
8646 --- a/arch/sparc/kernel/sysfs.c
8647 +++ b/arch/sparc/kernel/sysfs.c
8648 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8649 return NOTIFY_OK;
8650 }
8651
8652 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8653 +static struct notifier_block sysfs_cpu_nb = {
8654 .notifier_call = sysfs_cpu_notify,
8655 };
8656
8657 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8658 index 6629829..036032d 100644
8659 --- a/arch/sparc/kernel/traps_32.c
8660 +++ b/arch/sparc/kernel/traps_32.c
8661 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8662 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8663 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8664
8665 +extern void gr_handle_kernel_exploit(void);
8666 +
8667 void die_if_kernel(char *str, struct pt_regs *regs)
8668 {
8669 static int die_counter;
8670 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8671 count++ < 30 &&
8672 (((unsigned long) rw) >= PAGE_OFFSET) &&
8673 !(((unsigned long) rw) & 0x7)) {
8674 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8675 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8676 (void *) rw->ins[7]);
8677 rw = (struct reg_window32 *)rw->ins[6];
8678 }
8679 }
8680 printk("Instruction DUMP:");
8681 instruction_dump ((unsigned long *) regs->pc);
8682 - if(regs->psr & PSR_PS)
8683 + if(regs->psr & PSR_PS) {
8684 + gr_handle_kernel_exploit();
8685 do_exit(SIGKILL);
8686 + }
8687 do_exit(SIGSEGV);
8688 }
8689
8690 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8691 index b3f833a..ac74b2d 100644
8692 --- a/arch/sparc/kernel/traps_64.c
8693 +++ b/arch/sparc/kernel/traps_64.c
8694 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8695 i + 1,
8696 p->trapstack[i].tstate, p->trapstack[i].tpc,
8697 p->trapstack[i].tnpc, p->trapstack[i].tt);
8698 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8699 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8700 }
8701 }
8702
8703 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8704
8705 lvl -= 0x100;
8706 if (regs->tstate & TSTATE_PRIV) {
8707 +
8708 +#ifdef CONFIG_PAX_REFCOUNT
8709 + if (lvl == 6)
8710 + pax_report_refcount_overflow(regs);
8711 +#endif
8712 +
8713 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8714 die_if_kernel(buffer, regs);
8715 }
8716 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8717 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8718 {
8719 char buffer[32];
8720 -
8721 +
8722 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8723 0, lvl, SIGTRAP) == NOTIFY_STOP)
8724 return;
8725
8726 +#ifdef CONFIG_PAX_REFCOUNT
8727 + if (lvl == 6)
8728 + pax_report_refcount_overflow(regs);
8729 +#endif
8730 +
8731 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8732
8733 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8734 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8735 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8736 printk("%s" "ERROR(%d): ",
8737 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8738 - printk("TPC<%pS>\n", (void *) regs->tpc);
8739 + printk("TPC<%pA>\n", (void *) regs->tpc);
8740 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8741 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8742 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8743 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8744 smp_processor_id(),
8745 (type & 0x1) ? 'I' : 'D',
8746 regs->tpc);
8747 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8748 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8749 panic("Irrecoverable Cheetah+ parity error.");
8750 }
8751
8752 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8753 smp_processor_id(),
8754 (type & 0x1) ? 'I' : 'D',
8755 regs->tpc);
8756 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8757 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8758 }
8759
8760 struct sun4v_error_entry {
8761 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8762
8763 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8764 regs->tpc, tl);
8765 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8766 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8767 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8768 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8769 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8770 (void *) regs->u_regs[UREG_I7]);
8771 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8772 "pte[%lx] error[%lx]\n",
8773 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8774
8775 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8776 regs->tpc, tl);
8777 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8778 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8779 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8780 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8781 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8782 (void *) regs->u_regs[UREG_I7]);
8783 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8784 "pte[%lx] error[%lx]\n",
8785 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8786 fp = (unsigned long)sf->fp + STACK_BIAS;
8787 }
8788
8789 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8790 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8791 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8792 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8793 int index = tsk->curr_ret_stack;
8794 if (tsk->ret_stack && index >= graph) {
8795 pc = tsk->ret_stack[index - graph].ret;
8796 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8797 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8798 graph++;
8799 }
8800 }
8801 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8802 return (struct reg_window *) (fp + STACK_BIAS);
8803 }
8804
8805 +extern void gr_handle_kernel_exploit(void);
8806 +
8807 void die_if_kernel(char *str, struct pt_regs *regs)
8808 {
8809 static int die_counter;
8810 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8811 while (rw &&
8812 count++ < 30 &&
8813 kstack_valid(tp, (unsigned long) rw)) {
8814 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8815 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8816 (void *) rw->ins[7]);
8817
8818 rw = kernel_stack_up(rw);
8819 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8820 }
8821 user_instruction_dump ((unsigned int __user *) regs->tpc);
8822 }
8823 - if (regs->tstate & TSTATE_PRIV)
8824 + if (regs->tstate & TSTATE_PRIV) {
8825 + gr_handle_kernel_exploit();
8826 do_exit(SIGKILL);
8827 + }
8828 do_exit(SIGSEGV);
8829 }
8830 EXPORT_SYMBOL(die_if_kernel);
8831 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8832 index 8201c25e..072a2a7 100644
8833 --- a/arch/sparc/kernel/unaligned_64.c
8834 +++ b/arch/sparc/kernel/unaligned_64.c
8835 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8836 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8837
8838 if (__ratelimit(&ratelimit)) {
8839 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8840 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8841 regs->tpc, (void *) regs->tpc);
8842 }
8843 }
8844 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8845 index dbe119b..089c7c1 100644
8846 --- a/arch/sparc/lib/Makefile
8847 +++ b/arch/sparc/lib/Makefile
8848 @@ -2,7 +2,7 @@
8849 #
8850
8851 asflags-y := -ansi -DST_DIV0=0x02
8852 -ccflags-y := -Werror
8853 +#ccflags-y := -Werror
8854
8855 lib-$(CONFIG_SPARC32) += ashrdi3.o
8856 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8857 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8858 index 85c233d..68500e0 100644
8859 --- a/arch/sparc/lib/atomic_64.S
8860 +++ b/arch/sparc/lib/atomic_64.S
8861 @@ -17,7 +17,12 @@
8862 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8863 BACKOFF_SETUP(%o2)
8864 1: lduw [%o1], %g1
8865 - add %g1, %o0, %g7
8866 + addcc %g1, %o0, %g7
8867 +
8868 +#ifdef CONFIG_PAX_REFCOUNT
8869 + tvs %icc, 6
8870 +#endif
8871 +
8872 cas [%o1], %g1, %g7
8873 cmp %g1, %g7
8874 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8875 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8876 2: BACKOFF_SPIN(%o2, %o3, 1b)
8877 ENDPROC(atomic_add)
8878
8879 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8880 + BACKOFF_SETUP(%o2)
8881 +1: lduw [%o1], %g1
8882 + add %g1, %o0, %g7
8883 + cas [%o1], %g1, %g7
8884 + cmp %g1, %g7
8885 + bne,pn %icc, 2f
8886 + nop
8887 + retl
8888 + nop
8889 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8890 +ENDPROC(atomic_add_unchecked)
8891 +
8892 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8893 BACKOFF_SETUP(%o2)
8894 1: lduw [%o1], %g1
8895 - sub %g1, %o0, %g7
8896 + subcc %g1, %o0, %g7
8897 +
8898 +#ifdef CONFIG_PAX_REFCOUNT
8899 + tvs %icc, 6
8900 +#endif
8901 +
8902 cas [%o1], %g1, %g7
8903 cmp %g1, %g7
8904 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8905 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8906 2: BACKOFF_SPIN(%o2, %o3, 1b)
8907 ENDPROC(atomic_sub)
8908
8909 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8910 + BACKOFF_SETUP(%o2)
8911 +1: lduw [%o1], %g1
8912 + sub %g1, %o0, %g7
8913 + cas [%o1], %g1, %g7
8914 + cmp %g1, %g7
8915 + bne,pn %icc, 2f
8916 + nop
8917 + retl
8918 + nop
8919 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8920 +ENDPROC(atomic_sub_unchecked)
8921 +
8922 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8923 BACKOFF_SETUP(%o2)
8924 1: lduw [%o1], %g1
8925 - add %g1, %o0, %g7
8926 + addcc %g1, %o0, %g7
8927 +
8928 +#ifdef CONFIG_PAX_REFCOUNT
8929 + tvs %icc, 6
8930 +#endif
8931 +
8932 cas [%o1], %g1, %g7
8933 cmp %g1, %g7
8934 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8935 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8936 2: BACKOFF_SPIN(%o2, %o3, 1b)
8937 ENDPROC(atomic_add_ret)
8938
8939 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8940 + BACKOFF_SETUP(%o2)
8941 +1: lduw [%o1], %g1
8942 + addcc %g1, %o0, %g7
8943 + cas [%o1], %g1, %g7
8944 + cmp %g1, %g7
8945 + bne,pn %icc, 2f
8946 + add %g7, %o0, %g7
8947 + sra %g7, 0, %o0
8948 + retl
8949 + nop
8950 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8951 +ENDPROC(atomic_add_ret_unchecked)
8952 +
8953 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8954 BACKOFF_SETUP(%o2)
8955 1: lduw [%o1], %g1
8956 - sub %g1, %o0, %g7
8957 + subcc %g1, %o0, %g7
8958 +
8959 +#ifdef CONFIG_PAX_REFCOUNT
8960 + tvs %icc, 6
8961 +#endif
8962 +
8963 cas [%o1], %g1, %g7
8964 cmp %g1, %g7
8965 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8966 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8967 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8968 BACKOFF_SETUP(%o2)
8969 1: ldx [%o1], %g1
8970 - add %g1, %o0, %g7
8971 + addcc %g1, %o0, %g7
8972 +
8973 +#ifdef CONFIG_PAX_REFCOUNT
8974 + tvs %xcc, 6
8975 +#endif
8976 +
8977 casx [%o1], %g1, %g7
8978 cmp %g1, %g7
8979 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8980 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8981 2: BACKOFF_SPIN(%o2, %o3, 1b)
8982 ENDPROC(atomic64_add)
8983
8984 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8985 + BACKOFF_SETUP(%o2)
8986 +1: ldx [%o1], %g1
8987 + addcc %g1, %o0, %g7
8988 + casx [%o1], %g1, %g7
8989 + cmp %g1, %g7
8990 + bne,pn %xcc, 2f
8991 + nop
8992 + retl
8993 + nop
8994 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8995 +ENDPROC(atomic64_add_unchecked)
8996 +
8997 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8998 BACKOFF_SETUP(%o2)
8999 1: ldx [%o1], %g1
9000 - sub %g1, %o0, %g7
9001 + subcc %g1, %o0, %g7
9002 +
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + tvs %xcc, 6
9005 +#endif
9006 +
9007 casx [%o1], %g1, %g7
9008 cmp %g1, %g7
9009 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9010 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9011 2: BACKOFF_SPIN(%o2, %o3, 1b)
9012 ENDPROC(atomic64_sub)
9013
9014 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9015 + BACKOFF_SETUP(%o2)
9016 +1: ldx [%o1], %g1
9017 + subcc %g1, %o0, %g7
9018 + casx [%o1], %g1, %g7
9019 + cmp %g1, %g7
9020 + bne,pn %xcc, 2f
9021 + nop
9022 + retl
9023 + nop
9024 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9025 +ENDPROC(atomic64_sub_unchecked)
9026 +
9027 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9028 BACKOFF_SETUP(%o2)
9029 1: ldx [%o1], %g1
9030 - add %g1, %o0, %g7
9031 + addcc %g1, %o0, %g7
9032 +
9033 +#ifdef CONFIG_PAX_REFCOUNT
9034 + tvs %xcc, 6
9035 +#endif
9036 +
9037 casx [%o1], %g1, %g7
9038 cmp %g1, %g7
9039 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9040 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9041 2: BACKOFF_SPIN(%o2, %o3, 1b)
9042 ENDPROC(atomic64_add_ret)
9043
9044 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9045 + BACKOFF_SETUP(%o2)
9046 +1: ldx [%o1], %g1
9047 + addcc %g1, %o0, %g7
9048 + casx [%o1], %g1, %g7
9049 + cmp %g1, %g7
9050 + bne,pn %xcc, 2f
9051 + add %g7, %o0, %g7
9052 + mov %g7, %o0
9053 + retl
9054 + nop
9055 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9056 +ENDPROC(atomic64_add_ret_unchecked)
9057 +
9058 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9059 BACKOFF_SETUP(%o2)
9060 1: ldx [%o1], %g1
9061 - sub %g1, %o0, %g7
9062 + subcc %g1, %o0, %g7
9063 +
9064 +#ifdef CONFIG_PAX_REFCOUNT
9065 + tvs %xcc, 6
9066 +#endif
9067 +
9068 casx [%o1], %g1, %g7
9069 cmp %g1, %g7
9070 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9071 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9072 index 0c4e35e..745d3e4 100644
9073 --- a/arch/sparc/lib/ksyms.c
9074 +++ b/arch/sparc/lib/ksyms.c
9075 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9076
9077 /* Atomic counter implementation. */
9078 EXPORT_SYMBOL(atomic_add);
9079 +EXPORT_SYMBOL(atomic_add_unchecked);
9080 EXPORT_SYMBOL(atomic_add_ret);
9081 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9082 EXPORT_SYMBOL(atomic_sub);
9083 +EXPORT_SYMBOL(atomic_sub_unchecked);
9084 EXPORT_SYMBOL(atomic_sub_ret);
9085 EXPORT_SYMBOL(atomic64_add);
9086 +EXPORT_SYMBOL(atomic64_add_unchecked);
9087 EXPORT_SYMBOL(atomic64_add_ret);
9088 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9089 EXPORT_SYMBOL(atomic64_sub);
9090 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9091 EXPORT_SYMBOL(atomic64_sub_ret);
9092 EXPORT_SYMBOL(atomic64_dec_if_positive);
9093
9094 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9095 index 30c3ecc..736f015 100644
9096 --- a/arch/sparc/mm/Makefile
9097 +++ b/arch/sparc/mm/Makefile
9098 @@ -2,7 +2,7 @@
9099 #
9100
9101 asflags-y := -ansi
9102 -ccflags-y := -Werror
9103 +#ccflags-y := -Werror
9104
9105 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9106 obj-y += fault_$(BITS).o
9107 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9108 index e98bfda..ea8d221 100644
9109 --- a/arch/sparc/mm/fault_32.c
9110 +++ b/arch/sparc/mm/fault_32.c
9111 @@ -21,6 +21,9 @@
9112 #include <linux/perf_event.h>
9113 #include <linux/interrupt.h>
9114 #include <linux/kdebug.h>
9115 +#include <linux/slab.h>
9116 +#include <linux/pagemap.h>
9117 +#include <linux/compiler.h>
9118
9119 #include <asm/page.h>
9120 #include <asm/pgtable.h>
9121 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9122 return safe_compute_effective_address(regs, insn);
9123 }
9124
9125 +#ifdef CONFIG_PAX_PAGEEXEC
9126 +#ifdef CONFIG_PAX_DLRESOLVE
9127 +static void pax_emuplt_close(struct vm_area_struct *vma)
9128 +{
9129 + vma->vm_mm->call_dl_resolve = 0UL;
9130 +}
9131 +
9132 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9133 +{
9134 + unsigned int *kaddr;
9135 +
9136 + vmf->page = alloc_page(GFP_HIGHUSER);
9137 + if (!vmf->page)
9138 + return VM_FAULT_OOM;
9139 +
9140 + kaddr = kmap(vmf->page);
9141 + memset(kaddr, 0, PAGE_SIZE);
9142 + kaddr[0] = 0x9DE3BFA8U; /* save */
9143 + flush_dcache_page(vmf->page);
9144 + kunmap(vmf->page);
9145 + return VM_FAULT_MAJOR;
9146 +}
9147 +
9148 +static const struct vm_operations_struct pax_vm_ops = {
9149 + .close = pax_emuplt_close,
9150 + .fault = pax_emuplt_fault
9151 +};
9152 +
9153 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9154 +{
9155 + int ret;
9156 +
9157 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9158 + vma->vm_mm = current->mm;
9159 + vma->vm_start = addr;
9160 + vma->vm_end = addr + PAGE_SIZE;
9161 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9162 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9163 + vma->vm_ops = &pax_vm_ops;
9164 +
9165 + ret = insert_vm_struct(current->mm, vma);
9166 + if (ret)
9167 + return ret;
9168 +
9169 + ++current->mm->total_vm;
9170 + return 0;
9171 +}
9172 +#endif
9173 +
9174 +/*
9175 + * PaX: decide what to do with offenders (regs->pc = fault address)
9176 + *
9177 + * returns 1 when task should be killed
9178 + * 2 when patched PLT trampoline was detected
9179 + * 3 when unpatched PLT trampoline was detected
9180 + */
9181 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9182 +{
9183 +
9184 +#ifdef CONFIG_PAX_EMUPLT
9185 + int err;
9186 +
9187 + do { /* PaX: patched PLT emulation #1 */
9188 + unsigned int sethi1, sethi2, jmpl;
9189 +
9190 + err = get_user(sethi1, (unsigned int *)regs->pc);
9191 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9192 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9193 +
9194 + if (err)
9195 + break;
9196 +
9197 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9198 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9199 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9200 + {
9201 + unsigned int addr;
9202 +
9203 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9204 + addr = regs->u_regs[UREG_G1];
9205 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9206 + regs->pc = addr;
9207 + regs->npc = addr+4;
9208 + return 2;
9209 + }
9210 + } while (0);
9211 +
9212 + do { /* PaX: patched PLT emulation #2 */
9213 + unsigned int ba;
9214 +
9215 + err = get_user(ba, (unsigned int *)regs->pc);
9216 +
9217 + if (err)
9218 + break;
9219 +
9220 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9221 + unsigned int addr;
9222 +
9223 + if ((ba & 0xFFC00000U) == 0x30800000U)
9224 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9225 + else
9226 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9227 + regs->pc = addr;
9228 + regs->npc = addr+4;
9229 + return 2;
9230 + }
9231 + } while (0);
9232 +
9233 + do { /* PaX: patched PLT emulation #3 */
9234 + unsigned int sethi, bajmpl, nop;
9235 +
9236 + err = get_user(sethi, (unsigned int *)regs->pc);
9237 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9238 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9239 +
9240 + if (err)
9241 + break;
9242 +
9243 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9244 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9245 + nop == 0x01000000U)
9246 + {
9247 + unsigned int addr;
9248 +
9249 + addr = (sethi & 0x003FFFFFU) << 10;
9250 + regs->u_regs[UREG_G1] = addr;
9251 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9252 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9253 + else
9254 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9255 + regs->pc = addr;
9256 + regs->npc = addr+4;
9257 + return 2;
9258 + }
9259 + } while (0);
9260 +
9261 + do { /* PaX: unpatched PLT emulation step 1 */
9262 + unsigned int sethi, ba, nop;
9263 +
9264 + err = get_user(sethi, (unsigned int *)regs->pc);
9265 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9266 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9267 +
9268 + if (err)
9269 + break;
9270 +
9271 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9272 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9273 + nop == 0x01000000U)
9274 + {
9275 + unsigned int addr, save, call;
9276 +
9277 + if ((ba & 0xFFC00000U) == 0x30800000U)
9278 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9279 + else
9280 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9281 +
9282 + err = get_user(save, (unsigned int *)addr);
9283 + err |= get_user(call, (unsigned int *)(addr+4));
9284 + err |= get_user(nop, (unsigned int *)(addr+8));
9285 + if (err)
9286 + break;
9287 +
9288 +#ifdef CONFIG_PAX_DLRESOLVE
9289 + if (save == 0x9DE3BFA8U &&
9290 + (call & 0xC0000000U) == 0x40000000U &&
9291 + nop == 0x01000000U)
9292 + {
9293 + struct vm_area_struct *vma;
9294 + unsigned long call_dl_resolve;
9295 +
9296 + down_read(&current->mm->mmap_sem);
9297 + call_dl_resolve = current->mm->call_dl_resolve;
9298 + up_read(&current->mm->mmap_sem);
9299 + if (likely(call_dl_resolve))
9300 + goto emulate;
9301 +
9302 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9303 +
9304 + down_write(&current->mm->mmap_sem);
9305 + if (current->mm->call_dl_resolve) {
9306 + call_dl_resolve = current->mm->call_dl_resolve;
9307 + up_write(&current->mm->mmap_sem);
9308 + if (vma)
9309 + kmem_cache_free(vm_area_cachep, vma);
9310 + goto emulate;
9311 + }
9312 +
9313 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9314 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9315 + up_write(&current->mm->mmap_sem);
9316 + if (vma)
9317 + kmem_cache_free(vm_area_cachep, vma);
9318 + return 1;
9319 + }
9320 +
9321 + if (pax_insert_vma(vma, call_dl_resolve)) {
9322 + up_write(&current->mm->mmap_sem);
9323 + kmem_cache_free(vm_area_cachep, vma);
9324 + return 1;
9325 + }
9326 +
9327 + current->mm->call_dl_resolve = call_dl_resolve;
9328 + up_write(&current->mm->mmap_sem);
9329 +
9330 +emulate:
9331 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9332 + regs->pc = call_dl_resolve;
9333 + regs->npc = addr+4;
9334 + return 3;
9335 + }
9336 +#endif
9337 +
9338 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9339 + if ((save & 0xFFC00000U) == 0x05000000U &&
9340 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9341 + nop == 0x01000000U)
9342 + {
9343 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9344 + regs->u_regs[UREG_G2] = addr + 4;
9345 + addr = (save & 0x003FFFFFU) << 10;
9346 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9347 + regs->pc = addr;
9348 + regs->npc = addr+4;
9349 + return 3;
9350 + }
9351 + }
9352 + } while (0);
9353 +
9354 + do { /* PaX: unpatched PLT emulation step 2 */
9355 + unsigned int save, call, nop;
9356 +
9357 + err = get_user(save, (unsigned int *)(regs->pc-4));
9358 + err |= get_user(call, (unsigned int *)regs->pc);
9359 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9360 + if (err)
9361 + break;
9362 +
9363 + if (save == 0x9DE3BFA8U &&
9364 + (call & 0xC0000000U) == 0x40000000U &&
9365 + nop == 0x01000000U)
9366 + {
9367 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9368 +
9369 + regs->u_regs[UREG_RETPC] = regs->pc;
9370 + regs->pc = dl_resolve;
9371 + regs->npc = dl_resolve+4;
9372 + return 3;
9373 + }
9374 + } while (0);
9375 +#endif
9376 +
9377 + return 1;
9378 +}
9379 +
9380 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9381 +{
9382 + unsigned long i;
9383 +
9384 + printk(KERN_ERR "PAX: bytes at PC: ");
9385 + for (i = 0; i < 8; i++) {
9386 + unsigned int c;
9387 + if (get_user(c, (unsigned int *)pc+i))
9388 + printk(KERN_CONT "???????? ");
9389 + else
9390 + printk(KERN_CONT "%08x ", c);
9391 + }
9392 + printk("\n");
9393 +}
9394 +#endif
9395 +
9396 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9397 int text_fault)
9398 {
9399 @@ -230,6 +504,24 @@ good_area:
9400 if (!(vma->vm_flags & VM_WRITE))
9401 goto bad_area;
9402 } else {
9403 +
9404 +#ifdef CONFIG_PAX_PAGEEXEC
9405 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9406 + up_read(&mm->mmap_sem);
9407 + switch (pax_handle_fetch_fault(regs)) {
9408 +
9409 +#ifdef CONFIG_PAX_EMUPLT
9410 + case 2:
9411 + case 3:
9412 + return;
9413 +#endif
9414 +
9415 + }
9416 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9417 + do_group_exit(SIGKILL);
9418 + }
9419 +#endif
9420 +
9421 /* Allow reads even for write-only mappings */
9422 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9423 goto bad_area;
9424 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9425 index 5062ff3..e0b75f3 100644
9426 --- a/arch/sparc/mm/fault_64.c
9427 +++ b/arch/sparc/mm/fault_64.c
9428 @@ -21,6 +21,9 @@
9429 #include <linux/kprobes.h>
9430 #include <linux/kdebug.h>
9431 #include <linux/percpu.h>
9432 +#include <linux/slab.h>
9433 +#include <linux/pagemap.h>
9434 +#include <linux/compiler.h>
9435
9436 #include <asm/page.h>
9437 #include <asm/pgtable.h>
9438 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9439 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9440 regs->tpc);
9441 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9442 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9443 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9444 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9445 dump_stack();
9446 unhandled_fault(regs->tpc, current, regs);
9447 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9448 show_regs(regs);
9449 }
9450
9451 +#ifdef CONFIG_PAX_PAGEEXEC
9452 +#ifdef CONFIG_PAX_DLRESOLVE
9453 +static void pax_emuplt_close(struct vm_area_struct *vma)
9454 +{
9455 + vma->vm_mm->call_dl_resolve = 0UL;
9456 +}
9457 +
9458 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9459 +{
9460 + unsigned int *kaddr;
9461 +
9462 + vmf->page = alloc_page(GFP_HIGHUSER);
9463 + if (!vmf->page)
9464 + return VM_FAULT_OOM;
9465 +
9466 + kaddr = kmap(vmf->page);
9467 + memset(kaddr, 0, PAGE_SIZE);
9468 + kaddr[0] = 0x9DE3BFA8U; /* save */
9469 + flush_dcache_page(vmf->page);
9470 + kunmap(vmf->page);
9471 + return VM_FAULT_MAJOR;
9472 +}
9473 +
9474 +static const struct vm_operations_struct pax_vm_ops = {
9475 + .close = pax_emuplt_close,
9476 + .fault = pax_emuplt_fault
9477 +};
9478 +
9479 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9480 +{
9481 + int ret;
9482 +
9483 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9484 + vma->vm_mm = current->mm;
9485 + vma->vm_start = addr;
9486 + vma->vm_end = addr + PAGE_SIZE;
9487 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9488 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9489 + vma->vm_ops = &pax_vm_ops;
9490 +
9491 + ret = insert_vm_struct(current->mm, vma);
9492 + if (ret)
9493 + return ret;
9494 +
9495 + ++current->mm->total_vm;
9496 + return 0;
9497 +}
9498 +#endif
9499 +
9500 +/*
9501 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9502 + *
9503 + * returns 1 when task should be killed
9504 + * 2 when patched PLT trampoline was detected
9505 + * 3 when unpatched PLT trampoline was detected
9506 + */
9507 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9508 +{
9509 +
9510 +#ifdef CONFIG_PAX_EMUPLT
9511 + int err;
9512 +
9513 + do { /* PaX: patched PLT emulation #1 */
9514 + unsigned int sethi1, sethi2, jmpl;
9515 +
9516 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9517 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9518 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9519 +
9520 + if (err)
9521 + break;
9522 +
9523 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9524 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9525 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9526 + {
9527 + unsigned long addr;
9528 +
9529 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9530 + addr = regs->u_regs[UREG_G1];
9531 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9532 +
9533 + if (test_thread_flag(TIF_32BIT))
9534 + addr &= 0xFFFFFFFFUL;
9535 +
9536 + regs->tpc = addr;
9537 + regs->tnpc = addr+4;
9538 + return 2;
9539 + }
9540 + } while (0);
9541 +
9542 + do { /* PaX: patched PLT emulation #2 */
9543 + unsigned int ba;
9544 +
9545 + err = get_user(ba, (unsigned int *)regs->tpc);
9546 +
9547 + if (err)
9548 + break;
9549 +
9550 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9551 + unsigned long addr;
9552 +
9553 + if ((ba & 0xFFC00000U) == 0x30800000U)
9554 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9555 + else
9556 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9557 +
9558 + if (test_thread_flag(TIF_32BIT))
9559 + addr &= 0xFFFFFFFFUL;
9560 +
9561 + regs->tpc = addr;
9562 + regs->tnpc = addr+4;
9563 + return 2;
9564 + }
9565 + } while (0);
9566 +
9567 + do { /* PaX: patched PLT emulation #3 */
9568 + unsigned int sethi, bajmpl, nop;
9569 +
9570 + err = get_user(sethi, (unsigned int *)regs->tpc);
9571 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9572 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9573 +
9574 + if (err)
9575 + break;
9576 +
9577 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9578 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9579 + nop == 0x01000000U)
9580 + {
9581 + unsigned long addr;
9582 +
9583 + addr = (sethi & 0x003FFFFFU) << 10;
9584 + regs->u_regs[UREG_G1] = addr;
9585 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9586 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9587 + else
9588 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9589 +
9590 + if (test_thread_flag(TIF_32BIT))
9591 + addr &= 0xFFFFFFFFUL;
9592 +
9593 + regs->tpc = addr;
9594 + regs->tnpc = addr+4;
9595 + return 2;
9596 + }
9597 + } while (0);
9598 +
9599 + do { /* PaX: patched PLT emulation #4 */
9600 + unsigned int sethi, mov1, call, mov2;
9601 +
9602 + err = get_user(sethi, (unsigned int *)regs->tpc);
9603 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9604 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9605 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9606 +
9607 + if (err)
9608 + break;
9609 +
9610 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9611 + mov1 == 0x8210000FU &&
9612 + (call & 0xC0000000U) == 0x40000000U &&
9613 + mov2 == 0x9E100001U)
9614 + {
9615 + unsigned long addr;
9616 +
9617 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9618 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9619 +
9620 + if (test_thread_flag(TIF_32BIT))
9621 + addr &= 0xFFFFFFFFUL;
9622 +
9623 + regs->tpc = addr;
9624 + regs->tnpc = addr+4;
9625 + return 2;
9626 + }
9627 + } while (0);
9628 +
9629 + do { /* PaX: patched PLT emulation #5 */
9630 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9631 +
9632 + err = get_user(sethi, (unsigned int *)regs->tpc);
9633 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9634 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9635 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9636 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9637 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9638 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9639 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9640 +
9641 + if (err)
9642 + break;
9643 +
9644 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9645 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9646 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9647 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9648 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9649 + sllx == 0x83287020U &&
9650 + jmpl == 0x81C04005U &&
9651 + nop == 0x01000000U)
9652 + {
9653 + unsigned long addr;
9654 +
9655 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9656 + regs->u_regs[UREG_G1] <<= 32;
9657 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9658 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9659 + regs->tpc = addr;
9660 + regs->tnpc = addr+4;
9661 + return 2;
9662 + }
9663 + } while (0);
9664 +
9665 + do { /* PaX: patched PLT emulation #6 */
9666 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9667 +
9668 + err = get_user(sethi, (unsigned int *)regs->tpc);
9669 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9670 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9671 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9672 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9673 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9674 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9675 +
9676 + if (err)
9677 + break;
9678 +
9679 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9680 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9681 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9682 + sllx == 0x83287020U &&
9683 + (or & 0xFFFFE000U) == 0x8A116000U &&
9684 + jmpl == 0x81C04005U &&
9685 + nop == 0x01000000U)
9686 + {
9687 + unsigned long addr;
9688 +
9689 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9690 + regs->u_regs[UREG_G1] <<= 32;
9691 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9692 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9693 + regs->tpc = addr;
9694 + regs->tnpc = addr+4;
9695 + return 2;
9696 + }
9697 + } while (0);
9698 +
9699 + do { /* PaX: unpatched PLT emulation step 1 */
9700 + unsigned int sethi, ba, nop;
9701 +
9702 + err = get_user(sethi, (unsigned int *)regs->tpc);
9703 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9704 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9705 +
9706 + if (err)
9707 + break;
9708 +
9709 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9710 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9711 + nop == 0x01000000U)
9712 + {
9713 + unsigned long addr;
9714 + unsigned int save, call;
9715 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9716 +
9717 + if ((ba & 0xFFC00000U) == 0x30800000U)
9718 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9719 + else
9720 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9721 +
9722 + if (test_thread_flag(TIF_32BIT))
9723 + addr &= 0xFFFFFFFFUL;
9724 +
9725 + err = get_user(save, (unsigned int *)addr);
9726 + err |= get_user(call, (unsigned int *)(addr+4));
9727 + err |= get_user(nop, (unsigned int *)(addr+8));
9728 + if (err)
9729 + break;
9730 +
9731 +#ifdef CONFIG_PAX_DLRESOLVE
9732 + if (save == 0x9DE3BFA8U &&
9733 + (call & 0xC0000000U) == 0x40000000U &&
9734 + nop == 0x01000000U)
9735 + {
9736 + struct vm_area_struct *vma;
9737 + unsigned long call_dl_resolve;
9738 +
9739 + down_read(&current->mm->mmap_sem);
9740 + call_dl_resolve = current->mm->call_dl_resolve;
9741 + up_read(&current->mm->mmap_sem);
9742 + if (likely(call_dl_resolve))
9743 + goto emulate;
9744 +
9745 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9746 +
9747 + down_write(&current->mm->mmap_sem);
9748 + if (current->mm->call_dl_resolve) {
9749 + call_dl_resolve = current->mm->call_dl_resolve;
9750 + up_write(&current->mm->mmap_sem);
9751 + if (vma)
9752 + kmem_cache_free(vm_area_cachep, vma);
9753 + goto emulate;
9754 + }
9755 +
9756 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9757 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9758 + up_write(&current->mm->mmap_sem);
9759 + if (vma)
9760 + kmem_cache_free(vm_area_cachep, vma);
9761 + return 1;
9762 + }
9763 +
9764 + if (pax_insert_vma(vma, call_dl_resolve)) {
9765 + up_write(&current->mm->mmap_sem);
9766 + kmem_cache_free(vm_area_cachep, vma);
9767 + return 1;
9768 + }
9769 +
9770 + current->mm->call_dl_resolve = call_dl_resolve;
9771 + up_write(&current->mm->mmap_sem);
9772 +
9773 +emulate:
9774 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9775 + regs->tpc = call_dl_resolve;
9776 + regs->tnpc = addr+4;
9777 + return 3;
9778 + }
9779 +#endif
9780 +
9781 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9782 + if ((save & 0xFFC00000U) == 0x05000000U &&
9783 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9784 + nop == 0x01000000U)
9785 + {
9786 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9787 + regs->u_regs[UREG_G2] = addr + 4;
9788 + addr = (save & 0x003FFFFFU) << 10;
9789 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9790 +
9791 + if (test_thread_flag(TIF_32BIT))
9792 + addr &= 0xFFFFFFFFUL;
9793 +
9794 + regs->tpc = addr;
9795 + regs->tnpc = addr+4;
9796 + return 3;
9797 + }
9798 +
9799 + /* PaX: 64-bit PLT stub */
9800 + err = get_user(sethi1, (unsigned int *)addr);
9801 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9802 + err |= get_user(or1, (unsigned int *)(addr+8));
9803 + err |= get_user(or2, (unsigned int *)(addr+12));
9804 + err |= get_user(sllx, (unsigned int *)(addr+16));
9805 + err |= get_user(add, (unsigned int *)(addr+20));
9806 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9807 + err |= get_user(nop, (unsigned int *)(addr+28));
9808 + if (err)
9809 + break;
9810 +
9811 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9812 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9813 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9814 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9815 + sllx == 0x89293020U &&
9816 + add == 0x8A010005U &&
9817 + jmpl == 0x89C14000U &&
9818 + nop == 0x01000000U)
9819 + {
9820 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9821 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9822 + regs->u_regs[UREG_G4] <<= 32;
9823 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9824 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9825 + regs->u_regs[UREG_G4] = addr + 24;
9826 + addr = regs->u_regs[UREG_G5];
9827 + regs->tpc = addr;
9828 + regs->tnpc = addr+4;
9829 + return 3;
9830 + }
9831 + }
9832 + } while (0);
9833 +
9834 +#ifdef CONFIG_PAX_DLRESOLVE
9835 + do { /* PaX: unpatched PLT emulation step 2 */
9836 + unsigned int save, call, nop;
9837 +
9838 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9839 + err |= get_user(call, (unsigned int *)regs->tpc);
9840 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9841 + if (err)
9842 + break;
9843 +
9844 + if (save == 0x9DE3BFA8U &&
9845 + (call & 0xC0000000U) == 0x40000000U &&
9846 + nop == 0x01000000U)
9847 + {
9848 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9849 +
9850 + if (test_thread_flag(TIF_32BIT))
9851 + dl_resolve &= 0xFFFFFFFFUL;
9852 +
9853 + regs->u_regs[UREG_RETPC] = regs->tpc;
9854 + regs->tpc = dl_resolve;
9855 + regs->tnpc = dl_resolve+4;
9856 + return 3;
9857 + }
9858 + } while (0);
9859 +#endif
9860 +
9861 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9862 + unsigned int sethi, ba, nop;
9863 +
9864 + err = get_user(sethi, (unsigned int *)regs->tpc);
9865 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9866 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9867 +
9868 + if (err)
9869 + break;
9870 +
9871 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9872 + (ba & 0xFFF00000U) == 0x30600000U &&
9873 + nop == 0x01000000U)
9874 + {
9875 + unsigned long addr;
9876 +
9877 + addr = (sethi & 0x003FFFFFU) << 10;
9878 + regs->u_regs[UREG_G1] = addr;
9879 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9880 +
9881 + if (test_thread_flag(TIF_32BIT))
9882 + addr &= 0xFFFFFFFFUL;
9883 +
9884 + regs->tpc = addr;
9885 + regs->tnpc = addr+4;
9886 + return 2;
9887 + }
9888 + } while (0);
9889 +
9890 +#endif
9891 +
9892 + return 1;
9893 +}
9894 +
9895 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9896 +{
9897 + unsigned long i;
9898 +
9899 + printk(KERN_ERR "PAX: bytes at PC: ");
9900 + for (i = 0; i < 8; i++) {
9901 + unsigned int c;
9902 + if (get_user(c, (unsigned int *)pc+i))
9903 + printk(KERN_CONT "???????? ");
9904 + else
9905 + printk(KERN_CONT "%08x ", c);
9906 + }
9907 + printk("\n");
9908 +}
9909 +#endif
9910 +
9911 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9912 {
9913 struct mm_struct *mm = current->mm;
9914 @@ -341,6 +804,29 @@ retry:
9915 if (!vma)
9916 goto bad_area;
9917
9918 +#ifdef CONFIG_PAX_PAGEEXEC
9919 + /* PaX: detect ITLB misses on non-exec pages */
9920 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9921 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9922 + {
9923 + if (address != regs->tpc)
9924 + goto good_area;
9925 +
9926 + up_read(&mm->mmap_sem);
9927 + switch (pax_handle_fetch_fault(regs)) {
9928 +
9929 +#ifdef CONFIG_PAX_EMUPLT
9930 + case 2:
9931 + case 3:
9932 + return;
9933 +#endif
9934 +
9935 + }
9936 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9937 + do_group_exit(SIGKILL);
9938 + }
9939 +#endif
9940 +
9941 /* Pure DTLB misses do not tell us whether the fault causing
9942 * load/store/atomic was a write or not, it only says that there
9943 * was no match. So in such a case we (carefully) read the
9944 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9945 index d2b5944..bd813f2 100644
9946 --- a/arch/sparc/mm/hugetlbpage.c
9947 +++ b/arch/sparc/mm/hugetlbpage.c
9948 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9949
9950 info.flags = 0;
9951 info.length = len;
9952 - info.low_limit = TASK_UNMAPPED_BASE;
9953 + info.low_limit = mm->mmap_base;
9954 info.high_limit = min(task_size, VA_EXCLUDE_START);
9955 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9956 info.align_offset = 0;
9957 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9958 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9959 VM_BUG_ON(addr != -ENOMEM);
9960 info.low_limit = VA_EXCLUDE_END;
9961 +
9962 +#ifdef CONFIG_PAX_RANDMMAP
9963 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9964 + info.low_limit += mm->delta_mmap;
9965 +#endif
9966 +
9967 info.high_limit = task_size;
9968 addr = vm_unmapped_area(&info);
9969 }
9970 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9971 VM_BUG_ON(addr != -ENOMEM);
9972 info.flags = 0;
9973 info.low_limit = TASK_UNMAPPED_BASE;
9974 +
9975 +#ifdef CONFIG_PAX_RANDMMAP
9976 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9977 + info.low_limit += mm->delta_mmap;
9978 +#endif
9979 +
9980 info.high_limit = STACK_TOP32;
9981 addr = vm_unmapped_area(&info);
9982 }
9983 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9984 struct mm_struct *mm = current->mm;
9985 struct vm_area_struct *vma;
9986 unsigned long task_size = TASK_SIZE;
9987 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9988
9989 if (test_thread_flag(TIF_32BIT))
9990 task_size = STACK_TOP32;
9991 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9992 return addr;
9993 }
9994
9995 +#ifdef CONFIG_PAX_RANDMMAP
9996 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9997 +#endif
9998 +
9999 if (addr) {
10000 addr = ALIGN(addr, HPAGE_SIZE);
10001 vma = find_vma(mm, addr);
10002 - if (task_size - len >= addr &&
10003 - (!vma || addr + len <= vma->vm_start))
10004 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10005 return addr;
10006 }
10007 if (mm->get_unmapped_area == arch_get_unmapped_area)
10008 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10009 index f4500c6..889656c 100644
10010 --- a/arch/tile/include/asm/atomic_64.h
10011 +++ b/arch/tile/include/asm/atomic_64.h
10012 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10013
10014 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10015
10016 +#define atomic64_read_unchecked(v) atomic64_read(v)
10017 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10018 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10019 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10020 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10021 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10022 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10023 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10024 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10025 +
10026 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10027 #define smp_mb__before_atomic_dec() smp_mb()
10028 #define smp_mb__after_atomic_dec() smp_mb()
10029 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10030 index a9a5299..0fce79e 100644
10031 --- a/arch/tile/include/asm/cache.h
10032 +++ b/arch/tile/include/asm/cache.h
10033 @@ -15,11 +15,12 @@
10034 #ifndef _ASM_TILE_CACHE_H
10035 #define _ASM_TILE_CACHE_H
10036
10037 +#include <linux/const.h>
10038 #include <arch/chip.h>
10039
10040 /* bytes per L1 data cache line */
10041 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10042 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10043 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10044
10045 /* bytes per L2 cache line */
10046 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10047 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10048 index 8a082bc..7a6bf87 100644
10049 --- a/arch/tile/include/asm/uaccess.h
10050 +++ b/arch/tile/include/asm/uaccess.h
10051 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10052 const void __user *from,
10053 unsigned long n)
10054 {
10055 - int sz = __compiletime_object_size(to);
10056 + size_t sz = __compiletime_object_size(to);
10057
10058 - if (likely(sz == -1 || sz >= n))
10059 + if (likely(sz == (size_t)-1 || sz >= n))
10060 n = _copy_from_user(to, from, n);
10061 else
10062 copy_from_user_overflow();
10063 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10064 index 650ccff..45fe2d6 100644
10065 --- a/arch/tile/mm/hugetlbpage.c
10066 +++ b/arch/tile/mm/hugetlbpage.c
10067 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10068 info.high_limit = TASK_SIZE;
10069 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10070 info.align_offset = 0;
10071 + info.threadstack_offset = 0;
10072 return vm_unmapped_area(&info);
10073 }
10074
10075 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10076 info.high_limit = current->mm->mmap_base;
10077 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10078 info.align_offset = 0;
10079 + info.threadstack_offset = 0;
10080 addr = vm_unmapped_area(&info);
10081
10082 /*
10083 diff --git a/arch/um/Makefile b/arch/um/Makefile
10084 index 133f7de..1d6f2f1 100644
10085 --- a/arch/um/Makefile
10086 +++ b/arch/um/Makefile
10087 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10088 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10089 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10090
10091 +ifdef CONSTIFY_PLUGIN
10092 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10093 +endif
10094 +
10095 #This will adjust *FLAGS accordingly to the platform.
10096 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10097
10098 diff --git a/arch/um/defconfig b/arch/um/defconfig
10099 index 08107a7..ab22afe 100644
10100 --- a/arch/um/defconfig
10101 +++ b/arch/um/defconfig
10102 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10103 CONFIG_X86_L1_CACHE_SHIFT=5
10104 CONFIG_X86_XADD=y
10105 CONFIG_X86_PPRO_FENCE=y
10106 -CONFIG_X86_WP_WORKS_OK=y
10107 CONFIG_X86_INVLPG=y
10108 CONFIG_X86_BSWAP=y
10109 CONFIG_X86_POPAD_OK=y
10110 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10111 index 19e1bdd..3665b77 100644
10112 --- a/arch/um/include/asm/cache.h
10113 +++ b/arch/um/include/asm/cache.h
10114 @@ -1,6 +1,7 @@
10115 #ifndef __UM_CACHE_H
10116 #define __UM_CACHE_H
10117
10118 +#include <linux/const.h>
10119
10120 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10121 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10122 @@ -12,6 +13,6 @@
10123 # define L1_CACHE_SHIFT 5
10124 #endif
10125
10126 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10127 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10128
10129 #endif
10130 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10131 index 2e0a6b1..a64d0f5 100644
10132 --- a/arch/um/include/asm/kmap_types.h
10133 +++ b/arch/um/include/asm/kmap_types.h
10134 @@ -8,6 +8,6 @@
10135
10136 /* No more #include "asm/arch/kmap_types.h" ! */
10137
10138 -#define KM_TYPE_NR 14
10139 +#define KM_TYPE_NR 15
10140
10141 #endif
10142 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10143 index 5ff53d9..5850cdf 100644
10144 --- a/arch/um/include/asm/page.h
10145 +++ b/arch/um/include/asm/page.h
10146 @@ -14,6 +14,9 @@
10147 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10148 #define PAGE_MASK (~(PAGE_SIZE-1))
10149
10150 +#define ktla_ktva(addr) (addr)
10151 +#define ktva_ktla(addr) (addr)
10152 +
10153 #ifndef __ASSEMBLY__
10154
10155 struct page;
10156 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10157 index 0032f92..cd151e0 100644
10158 --- a/arch/um/include/asm/pgtable-3level.h
10159 +++ b/arch/um/include/asm/pgtable-3level.h
10160 @@ -58,6 +58,7 @@
10161 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10162 #define pud_populate(mm, pud, pmd) \
10163 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10164 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10165
10166 #ifdef CONFIG_64BIT
10167 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10168 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10169 index bbcef52..6a2a483 100644
10170 --- a/arch/um/kernel/process.c
10171 +++ b/arch/um/kernel/process.c
10172 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10173 return 2;
10174 }
10175
10176 -/*
10177 - * Only x86 and x86_64 have an arch_align_stack().
10178 - * All other arches have "#define arch_align_stack(x) (x)"
10179 - * in their asm/system.h
10180 - * As this is included in UML from asm-um/system-generic.h,
10181 - * we can use it to behave as the subarch does.
10182 - */
10183 -#ifndef arch_align_stack
10184 -unsigned long arch_align_stack(unsigned long sp)
10185 -{
10186 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10187 - sp -= get_random_int() % 8192;
10188 - return sp & ~0xf;
10189 -}
10190 -#endif
10191 -
10192 unsigned long get_wchan(struct task_struct *p)
10193 {
10194 unsigned long stack_page, sp, ip;
10195 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10196 index ad8f795..2c7eec6 100644
10197 --- a/arch/unicore32/include/asm/cache.h
10198 +++ b/arch/unicore32/include/asm/cache.h
10199 @@ -12,8 +12,10 @@
10200 #ifndef __UNICORE_CACHE_H__
10201 #define __UNICORE_CACHE_H__
10202
10203 -#define L1_CACHE_SHIFT (5)
10204 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10205 +#include <linux/const.h>
10206 +
10207 +#define L1_CACHE_SHIFT 5
10208 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10209
10210 /*
10211 * Memory returned by kmalloc() may be used for DMA, so we must make
10212 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10213 index fe120da..24177f7 100644
10214 --- a/arch/x86/Kconfig
10215 +++ b/arch/x86/Kconfig
10216 @@ -239,7 +239,7 @@ config X86_HT
10217
10218 config X86_32_LAZY_GS
10219 def_bool y
10220 - depends on X86_32 && !CC_STACKPROTECTOR
10221 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10222
10223 config ARCH_HWEIGHT_CFLAGS
10224 string
10225 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10226
10227 config X86_MSR
10228 tristate "/dev/cpu/*/msr - Model-specific register support"
10229 + depends on !GRKERNSEC_KMEM
10230 ---help---
10231 This device gives privileged processes access to the x86
10232 Model-Specific Registers (MSRs). It is a character device with
10233 @@ -1096,7 +1097,7 @@ choice
10234
10235 config NOHIGHMEM
10236 bool "off"
10237 - depends on !X86_NUMAQ
10238 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10239 ---help---
10240 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10241 However, the address space of 32-bit x86 processors is only 4
10242 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10243
10244 config HIGHMEM4G
10245 bool "4GB"
10246 - depends on !X86_NUMAQ
10247 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10248 ---help---
10249 Select this if you have a 32-bit processor and between 1 and 4
10250 gigabytes of physical RAM.
10251 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10252 hex
10253 default 0xB0000000 if VMSPLIT_3G_OPT
10254 default 0x80000000 if VMSPLIT_2G
10255 - default 0x78000000 if VMSPLIT_2G_OPT
10256 + default 0x70000000 if VMSPLIT_2G_OPT
10257 default 0x40000000 if VMSPLIT_1G
10258 default 0xC0000000
10259 depends on X86_32
10260 @@ -1584,6 +1585,7 @@ config SECCOMP
10261
10262 config CC_STACKPROTECTOR
10263 bool "Enable -fstack-protector buffer overflow detection"
10264 + depends on X86_64 || !PAX_MEMORY_UDEREF
10265 ---help---
10266 This option turns on the -fstack-protector GCC feature. This
10267 feature puts, at the beginning of functions, a canary value on
10268 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10269 config PHYSICAL_ALIGN
10270 hex "Alignment value to which kernel should be aligned" if X86_32
10271 default "0x1000000"
10272 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10273 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10274 range 0x2000 0x1000000
10275 ---help---
10276 This value puts the alignment restrictions on physical address
10277 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10278 If unsure, say N.
10279
10280 config COMPAT_VDSO
10281 - def_bool y
10282 + def_bool n
10283 prompt "Compat VDSO support"
10284 depends on X86_32 || IA32_EMULATION
10285 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10286 ---help---
10287 Map the 32-bit VDSO to the predictable old-style address too.
10288
10289 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10290 index c026cca..14657ae 100644
10291 --- a/arch/x86/Kconfig.cpu
10292 +++ b/arch/x86/Kconfig.cpu
10293 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10294
10295 config X86_F00F_BUG
10296 def_bool y
10297 - depends on M586MMX || M586TSC || M586 || M486
10298 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10299
10300 config X86_INVD_BUG
10301 def_bool y
10302 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10303
10304 config X86_ALIGNMENT_16
10305 def_bool y
10306 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10307 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10308
10309 config X86_INTEL_USERCOPY
10310 def_bool y
10311 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10312 # generates cmov.
10313 config X86_CMOV
10314 def_bool y
10315 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10316 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10317
10318 config X86_MINIMUM_CPU_FAMILY
10319 int
10320 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10321 index c198b7e..63eea60 100644
10322 --- a/arch/x86/Kconfig.debug
10323 +++ b/arch/x86/Kconfig.debug
10324 @@ -84,7 +84,7 @@ config X86_PTDUMP
10325 config DEBUG_RODATA
10326 bool "Write protect kernel read-only data structures"
10327 default y
10328 - depends on DEBUG_KERNEL
10329 + depends on DEBUG_KERNEL && BROKEN
10330 ---help---
10331 Mark the kernel read-only data as write-protected in the pagetables,
10332 in order to catch accidental (and incorrect) writes to such const
10333 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10334
10335 config DEBUG_SET_MODULE_RONX
10336 bool "Set loadable kernel module data as NX and text as RO"
10337 - depends on MODULES
10338 + depends on MODULES && BROKEN
10339 ---help---
10340 This option helps catch unintended modifications to loadable
10341 kernel module's text and read-only data. It also prevents execution
10342 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10343 index 5c47726..8c4fa67 100644
10344 --- a/arch/x86/Makefile
10345 +++ b/arch/x86/Makefile
10346 @@ -54,6 +54,7 @@ else
10347 UTS_MACHINE := x86_64
10348 CHECKFLAGS += -D__x86_64__ -m64
10349
10350 + biarch := $(call cc-option,-m64)
10351 KBUILD_AFLAGS += -m64
10352 KBUILD_CFLAGS += -m64
10353
10354 @@ -234,3 +235,12 @@ define archhelp
10355 echo ' FDARGS="..." arguments for the booted kernel'
10356 echo ' FDINITRD=file initrd for the booted kernel'
10357 endef
10358 +
10359 +define OLD_LD
10360 +
10361 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10362 +*** Please upgrade your binutils to 2.18 or newer
10363 +endef
10364 +
10365 +archprepare:
10366 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10367 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10368 index 379814b..add62ce 100644
10369 --- a/arch/x86/boot/Makefile
10370 +++ b/arch/x86/boot/Makefile
10371 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10372 $(call cc-option, -fno-stack-protector) \
10373 $(call cc-option, -mpreferred-stack-boundary=2)
10374 KBUILD_CFLAGS += $(call cc-option, -m32)
10375 +ifdef CONSTIFY_PLUGIN
10376 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10377 +endif
10378 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10379 GCOV_PROFILE := n
10380
10381 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10382 index 878e4b9..20537ab 100644
10383 --- a/arch/x86/boot/bitops.h
10384 +++ b/arch/x86/boot/bitops.h
10385 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10386 u8 v;
10387 const u32 *p = (const u32 *)addr;
10388
10389 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10390 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10391 return v;
10392 }
10393
10394 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10395
10396 static inline void set_bit(int nr, void *addr)
10397 {
10398 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10399 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10400 }
10401
10402 #endif /* BOOT_BITOPS_H */
10403 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10404 index 5b75319..331a4ca 100644
10405 --- a/arch/x86/boot/boot.h
10406 +++ b/arch/x86/boot/boot.h
10407 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10408 static inline u16 ds(void)
10409 {
10410 u16 seg;
10411 - asm("movw %%ds,%0" : "=rm" (seg));
10412 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10413 return seg;
10414 }
10415
10416 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10417 static inline int memcmp(const void *s1, const void *s2, size_t len)
10418 {
10419 u8 diff;
10420 - asm("repe; cmpsb; setnz %0"
10421 + asm volatile("repe; cmpsb; setnz %0"
10422 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10423 return diff;
10424 }
10425 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10426 index 5ef205c..342191d 100644
10427 --- a/arch/x86/boot/compressed/Makefile
10428 +++ b/arch/x86/boot/compressed/Makefile
10429 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10430 KBUILD_CFLAGS += $(cflags-y)
10431 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10432 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10433 +ifdef CONSTIFY_PLUGIN
10434 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10435 +endif
10436
10437 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10438 GCOV_PROFILE := n
10439 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10440 index c205035..5853587 100644
10441 --- a/arch/x86/boot/compressed/eboot.c
10442 +++ b/arch/x86/boot/compressed/eboot.c
10443 @@ -150,7 +150,6 @@ again:
10444 *addr = max_addr;
10445 }
10446
10447 -free_pool:
10448 efi_call_phys1(sys_table->boottime->free_pool, map);
10449
10450 fail:
10451 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10452 if (i == map_size / desc_size)
10453 status = EFI_NOT_FOUND;
10454
10455 -free_pool:
10456 efi_call_phys1(sys_table->boottime->free_pool, map);
10457 fail:
10458 return status;
10459 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10460 index a53440e..c3dbf1e 100644
10461 --- a/arch/x86/boot/compressed/efi_stub_32.S
10462 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10463 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10464 * parameter 2, ..., param n. To make things easy, we save the return
10465 * address of efi_call_phys in a global variable.
10466 */
10467 - popl %ecx
10468 - movl %ecx, saved_return_addr(%edx)
10469 - /* get the function pointer into ECX*/
10470 - popl %ecx
10471 - movl %ecx, efi_rt_function_ptr(%edx)
10472 + popl saved_return_addr(%edx)
10473 + popl efi_rt_function_ptr(%edx)
10474
10475 /*
10476 * 3. Call the physical function.
10477 */
10478 - call *%ecx
10479 + call *efi_rt_function_ptr(%edx)
10480
10481 /*
10482 * 4. Balance the stack. And because EAX contain the return value,
10483 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10484 1: popl %edx
10485 subl $1b, %edx
10486
10487 - movl efi_rt_function_ptr(%edx), %ecx
10488 - pushl %ecx
10489 + pushl efi_rt_function_ptr(%edx)
10490
10491 /*
10492 * 10. Push the saved return address onto the stack and return.
10493 */
10494 - movl saved_return_addr(%edx), %ecx
10495 - pushl %ecx
10496 - ret
10497 + jmpl *saved_return_addr(%edx)
10498 ENDPROC(efi_call_phys)
10499 .previous
10500
10501 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10502 index 1e3184f..0d11e2e 100644
10503 --- a/arch/x86/boot/compressed/head_32.S
10504 +++ b/arch/x86/boot/compressed/head_32.S
10505 @@ -118,7 +118,7 @@ preferred_addr:
10506 notl %eax
10507 andl %eax, %ebx
10508 #else
10509 - movl $LOAD_PHYSICAL_ADDR, %ebx
10510 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10511 #endif
10512
10513 /* Target address to relocate to for decompression */
10514 @@ -204,7 +204,7 @@ relocated:
10515 * and where it was actually loaded.
10516 */
10517 movl %ebp, %ebx
10518 - subl $LOAD_PHYSICAL_ADDR, %ebx
10519 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10520 jz 2f /* Nothing to be done if loaded at compiled addr. */
10521 /*
10522 * Process relocations.
10523 @@ -212,8 +212,7 @@ relocated:
10524
10525 1: subl $4, %edi
10526 movl (%edi), %ecx
10527 - testl %ecx, %ecx
10528 - jz 2f
10529 + jecxz 2f
10530 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10531 jmp 1b
10532 2:
10533 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10534 index 16f24e6..47491a3 100644
10535 --- a/arch/x86/boot/compressed/head_64.S
10536 +++ b/arch/x86/boot/compressed/head_64.S
10537 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10538 notl %eax
10539 andl %eax, %ebx
10540 #else
10541 - movl $LOAD_PHYSICAL_ADDR, %ebx
10542 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10543 #endif
10544
10545 /* Target address to relocate to for decompression */
10546 @@ -272,7 +272,7 @@ preferred_addr:
10547 notq %rax
10548 andq %rax, %rbp
10549 #else
10550 - movq $LOAD_PHYSICAL_ADDR, %rbp
10551 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10552 #endif
10553
10554 /* Target address to relocate to for decompression */
10555 @@ -363,8 +363,8 @@ gdt:
10556 .long gdt
10557 .word 0
10558 .quad 0x0000000000000000 /* NULL descriptor */
10559 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10560 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10561 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10562 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10563 .quad 0x0080890000000000 /* TS descriptor */
10564 .quad 0x0000000000000000 /* TS continued */
10565 gdt_end:
10566 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10567 index 7cb56c6..d382d84 100644
10568 --- a/arch/x86/boot/compressed/misc.c
10569 +++ b/arch/x86/boot/compressed/misc.c
10570 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10571 case PT_LOAD:
10572 #ifdef CONFIG_RELOCATABLE
10573 dest = output;
10574 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10575 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10576 #else
10577 dest = (void *)(phdr->p_paddr);
10578 #endif
10579 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10580 error("Destination address too large");
10581 #endif
10582 #ifndef CONFIG_RELOCATABLE
10583 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10584 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10585 error("Wrong destination address");
10586 #endif
10587
10588 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10589 index 4d3ff03..e4972ff 100644
10590 --- a/arch/x86/boot/cpucheck.c
10591 +++ b/arch/x86/boot/cpucheck.c
10592 @@ -74,7 +74,7 @@ static int has_fpu(void)
10593 u16 fcw = -1, fsw = -1;
10594 u32 cr0;
10595
10596 - asm("movl %%cr0,%0" : "=r" (cr0));
10597 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10598 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10599 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10600 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10601 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10602 {
10603 u32 f0, f1;
10604
10605 - asm("pushfl ; "
10606 + asm volatile("pushfl ; "
10607 "pushfl ; "
10608 "popl %0 ; "
10609 "movl %0,%1 ; "
10610 @@ -115,7 +115,7 @@ static void get_flags(void)
10611 set_bit(X86_FEATURE_FPU, cpu.flags);
10612
10613 if (has_eflag(X86_EFLAGS_ID)) {
10614 - asm("cpuid"
10615 + asm volatile("cpuid"
10616 : "=a" (max_intel_level),
10617 "=b" (cpu_vendor[0]),
10618 "=d" (cpu_vendor[1]),
10619 @@ -124,7 +124,7 @@ static void get_flags(void)
10620
10621 if (max_intel_level >= 0x00000001 &&
10622 max_intel_level <= 0x0000ffff) {
10623 - asm("cpuid"
10624 + asm volatile("cpuid"
10625 : "=a" (tfms),
10626 "=c" (cpu.flags[4]),
10627 "=d" (cpu.flags[0])
10628 @@ -136,7 +136,7 @@ static void get_flags(void)
10629 cpu.model += ((tfms >> 16) & 0xf) << 4;
10630 }
10631
10632 - asm("cpuid"
10633 + asm volatile("cpuid"
10634 : "=a" (max_amd_level)
10635 : "a" (0x80000000)
10636 : "ebx", "ecx", "edx");
10637 @@ -144,7 +144,7 @@ static void get_flags(void)
10638 if (max_amd_level >= 0x80000001 &&
10639 max_amd_level <= 0x8000ffff) {
10640 u32 eax = 0x80000001;
10641 - asm("cpuid"
10642 + asm volatile("cpuid"
10643 : "+a" (eax),
10644 "=c" (cpu.flags[6]),
10645 "=d" (cpu.flags[1])
10646 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10647 u32 ecx = MSR_K7_HWCR;
10648 u32 eax, edx;
10649
10650 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10651 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10652 eax &= ~(1 << 15);
10653 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10654 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10655
10656 get_flags(); /* Make sure it really did something */
10657 err = check_flags();
10658 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10659 u32 ecx = MSR_VIA_FCR;
10660 u32 eax, edx;
10661
10662 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10663 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10664 eax |= (1<<1)|(1<<7);
10665 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10666 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10667
10668 set_bit(X86_FEATURE_CX8, cpu.flags);
10669 err = check_flags();
10670 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10671 u32 eax, edx;
10672 u32 level = 1;
10673
10674 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10675 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10676 - asm("cpuid"
10677 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10678 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10679 + asm volatile("cpuid"
10680 : "+a" (level), "=d" (cpu.flags[0])
10681 : : "ecx", "ebx");
10682 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10683 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10684
10685 err = check_flags();
10686 }
10687 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10688 index 9ec06a1..2c25e79 100644
10689 --- a/arch/x86/boot/header.S
10690 +++ b/arch/x86/boot/header.S
10691 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10692 # single linked list of
10693 # struct setup_data
10694
10695 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10696 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10697
10698 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10699 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10700 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10701 +#else
10702 #define VO_INIT_SIZE (VO__end - VO__text)
10703 +#endif
10704 #if ZO_INIT_SIZE > VO_INIT_SIZE
10705 #define INIT_SIZE ZO_INIT_SIZE
10706 #else
10707 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10708 index db75d07..8e6d0af 100644
10709 --- a/arch/x86/boot/memory.c
10710 +++ b/arch/x86/boot/memory.c
10711 @@ -19,7 +19,7 @@
10712
10713 static int detect_memory_e820(void)
10714 {
10715 - int count = 0;
10716 + unsigned int count = 0;
10717 struct biosregs ireg, oreg;
10718 struct e820entry *desc = boot_params.e820_map;
10719 static struct e820entry buf; /* static so it is zeroed */
10720 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10721 index 11e8c6e..fdbb1ed 100644
10722 --- a/arch/x86/boot/video-vesa.c
10723 +++ b/arch/x86/boot/video-vesa.c
10724 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10725
10726 boot_params.screen_info.vesapm_seg = oreg.es;
10727 boot_params.screen_info.vesapm_off = oreg.di;
10728 + boot_params.screen_info.vesapm_size = oreg.cx;
10729 }
10730
10731 /*
10732 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10733 index 43eda28..5ab5fdb 100644
10734 --- a/arch/x86/boot/video.c
10735 +++ b/arch/x86/boot/video.c
10736 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10737 static unsigned int get_entry(void)
10738 {
10739 char entry_buf[4];
10740 - int i, len = 0;
10741 + unsigned int i, len = 0;
10742 int key;
10743 unsigned int v;
10744
10745 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10746 index 9105655..5e37f27 100644
10747 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10748 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10749 @@ -8,6 +8,8 @@
10750 * including this sentence is retained in full.
10751 */
10752
10753 +#include <asm/alternative-asm.h>
10754 +
10755 .extern crypto_ft_tab
10756 .extern crypto_it_tab
10757 .extern crypto_fl_tab
10758 @@ -70,6 +72,8 @@
10759 je B192; \
10760 leaq 32(r9),r9;
10761
10762 +#define ret pax_force_retaddr 0, 1; ret
10763 +
10764 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10765 movq r1,r2; \
10766 movq r3,r4; \
10767 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10768 index 477e9d7..3ab339f 100644
10769 --- a/arch/x86/crypto/aesni-intel_asm.S
10770 +++ b/arch/x86/crypto/aesni-intel_asm.S
10771 @@ -31,6 +31,7 @@
10772
10773 #include <linux/linkage.h>
10774 #include <asm/inst.h>
10775 +#include <asm/alternative-asm.h>
10776
10777 #ifdef __x86_64__
10778 .data
10779 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
10780 pop %r14
10781 pop %r13
10782 pop %r12
10783 + pax_force_retaddr 0, 1
10784 ret
10785 ENDPROC(aesni_gcm_dec)
10786
10787 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
10788 pop %r14
10789 pop %r13
10790 pop %r12
10791 + pax_force_retaddr 0, 1
10792 ret
10793 ENDPROC(aesni_gcm_enc)
10794
10795 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
10796 pxor %xmm1, %xmm0
10797 movaps %xmm0, (TKEYP)
10798 add $0x10, TKEYP
10799 + pax_force_retaddr_bts
10800 ret
10801 ENDPROC(_key_expansion_128)
10802 ENDPROC(_key_expansion_256a)
10803 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
10804 shufps $0b01001110, %xmm2, %xmm1
10805 movaps %xmm1, 0x10(TKEYP)
10806 add $0x20, TKEYP
10807 + pax_force_retaddr_bts
10808 ret
10809 ENDPROC(_key_expansion_192a)
10810
10811 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
10812
10813 movaps %xmm0, (TKEYP)
10814 add $0x10, TKEYP
10815 + pax_force_retaddr_bts
10816 ret
10817 ENDPROC(_key_expansion_192b)
10818
10819 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
10820 pxor %xmm1, %xmm2
10821 movaps %xmm2, (TKEYP)
10822 add $0x10, TKEYP
10823 + pax_force_retaddr_bts
10824 ret
10825 ENDPROC(_key_expansion_256b)
10826
10827 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
10828 #ifndef __x86_64__
10829 popl KEYP
10830 #endif
10831 + pax_force_retaddr 0, 1
10832 ret
10833 ENDPROC(aesni_set_key)
10834
10835 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
10836 popl KLEN
10837 popl KEYP
10838 #endif
10839 + pax_force_retaddr 0, 1
10840 ret
10841 ENDPROC(aesni_enc)
10842
10843 @@ -1974,6 +1983,7 @@ _aesni_enc1:
10844 AESENC KEY STATE
10845 movaps 0x70(TKEYP), KEY
10846 AESENCLAST KEY STATE
10847 + pax_force_retaddr_bts
10848 ret
10849 ENDPROC(_aesni_enc1)
10850
10851 @@ -2083,6 +2093,7 @@ _aesni_enc4:
10852 AESENCLAST KEY STATE2
10853 AESENCLAST KEY STATE3
10854 AESENCLAST KEY STATE4
10855 + pax_force_retaddr_bts
10856 ret
10857 ENDPROC(_aesni_enc4)
10858
10859 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
10860 popl KLEN
10861 popl KEYP
10862 #endif
10863 + pax_force_retaddr 0, 1
10864 ret
10865 ENDPROC(aesni_dec)
10866
10867 @@ -2164,6 +2176,7 @@ _aesni_dec1:
10868 AESDEC KEY STATE
10869 movaps 0x70(TKEYP), KEY
10870 AESDECLAST KEY STATE
10871 + pax_force_retaddr_bts
10872 ret
10873 ENDPROC(_aesni_dec1)
10874
10875 @@ -2273,6 +2286,7 @@ _aesni_dec4:
10876 AESDECLAST KEY STATE2
10877 AESDECLAST KEY STATE3
10878 AESDECLAST KEY STATE4
10879 + pax_force_retaddr_bts
10880 ret
10881 ENDPROC(_aesni_dec4)
10882
10883 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
10884 popl KEYP
10885 popl LEN
10886 #endif
10887 + pax_force_retaddr 0, 1
10888 ret
10889 ENDPROC(aesni_ecb_enc)
10890
10891 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
10892 popl KEYP
10893 popl LEN
10894 #endif
10895 + pax_force_retaddr 0, 1
10896 ret
10897 ENDPROC(aesni_ecb_dec)
10898
10899 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
10900 popl LEN
10901 popl IVP
10902 #endif
10903 + pax_force_retaddr 0, 1
10904 ret
10905 ENDPROC(aesni_cbc_enc)
10906
10907 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
10908 popl LEN
10909 popl IVP
10910 #endif
10911 + pax_force_retaddr 0, 1
10912 ret
10913 ENDPROC(aesni_cbc_dec)
10914
10915 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
10916 mov $1, TCTR_LOW
10917 MOVQ_R64_XMM TCTR_LOW INC
10918 MOVQ_R64_XMM CTR TCTR_LOW
10919 + pax_force_retaddr_bts
10920 ret
10921 ENDPROC(_aesni_inc_init)
10922
10923 @@ -2579,6 +2598,7 @@ _aesni_inc:
10924 .Linc_low:
10925 movaps CTR, IV
10926 PSHUFB_XMM BSWAP_MASK IV
10927 + pax_force_retaddr_bts
10928 ret
10929 ENDPROC(_aesni_inc)
10930
10931 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
10932 .Lctr_enc_ret:
10933 movups IV, (IVP)
10934 .Lctr_enc_just_ret:
10935 + pax_force_retaddr 0, 1
10936 ret
10937 ENDPROC(aesni_ctr_enc)
10938
10939 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
10940 pxor INC, STATE4
10941 movdqu STATE4, 0x70(OUTP)
10942
10943 + pax_force_retaddr 0, 1
10944 ret
10945 ENDPROC(aesni_xts_crypt8)
10946
10947 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10948 index 246c670..4d1ed00 100644
10949 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10950 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10951 @@ -21,6 +21,7 @@
10952 */
10953
10954 #include <linux/linkage.h>
10955 +#include <asm/alternative-asm.h>
10956
10957 .file "blowfish-x86_64-asm.S"
10958 .text
10959 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10960 jnz .L__enc_xor;
10961
10962 write_block();
10963 + pax_force_retaddr 0, 1
10964 ret;
10965 .L__enc_xor:
10966 xor_block();
10967 + pax_force_retaddr 0, 1
10968 ret;
10969 ENDPROC(__blowfish_enc_blk)
10970
10971 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10972
10973 movq %r11, %rbp;
10974
10975 + pax_force_retaddr 0, 1
10976 ret;
10977 ENDPROC(blowfish_dec_blk)
10978
10979 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10980
10981 popq %rbx;
10982 popq %rbp;
10983 + pax_force_retaddr 0, 1
10984 ret;
10985
10986 .L__enc_xor4:
10987 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10988
10989 popq %rbx;
10990 popq %rbp;
10991 + pax_force_retaddr 0, 1
10992 ret;
10993 ENDPROC(__blowfish_enc_blk_4way)
10994
10995 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10996 popq %rbx;
10997 popq %rbp;
10998
10999 + pax_force_retaddr 0, 1
11000 ret;
11001 ENDPROC(blowfish_dec_blk_4way)
11002 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11003 index 310319c..ce174a4 100644
11004 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11005 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11006 @@ -21,6 +21,7 @@
11007 */
11008
11009 #include <linux/linkage.h>
11010 +#include <asm/alternative-asm.h>
11011
11012 .file "camellia-x86_64-asm_64.S"
11013 .text
11014 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11015 enc_outunpack(mov, RT1);
11016
11017 movq RRBP, %rbp;
11018 + pax_force_retaddr 0, 1
11019 ret;
11020
11021 .L__enc_xor:
11022 enc_outunpack(xor, RT1);
11023
11024 movq RRBP, %rbp;
11025 + pax_force_retaddr 0, 1
11026 ret;
11027 ENDPROC(__camellia_enc_blk)
11028
11029 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11030 dec_outunpack();
11031
11032 movq RRBP, %rbp;
11033 + pax_force_retaddr 0, 1
11034 ret;
11035 ENDPROC(camellia_dec_blk)
11036
11037 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11038
11039 movq RRBP, %rbp;
11040 popq %rbx;
11041 + pax_force_retaddr 0, 1
11042 ret;
11043
11044 .L__enc2_xor:
11045 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11046
11047 movq RRBP, %rbp;
11048 popq %rbx;
11049 + pax_force_retaddr 0, 1
11050 ret;
11051 ENDPROC(__camellia_enc_blk_2way)
11052
11053 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11054
11055 movq RRBP, %rbp;
11056 movq RXOR, %rbx;
11057 + pax_force_retaddr 0, 1
11058 ret;
11059 ENDPROC(camellia_dec_blk_2way)
11060 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11061 index c35fd5d..c1ee236 100644
11062 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11063 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11064 @@ -24,6 +24,7 @@
11065 */
11066
11067 #include <linux/linkage.h>
11068 +#include <asm/alternative-asm.h>
11069
11070 .file "cast5-avx-x86_64-asm_64.S"
11071
11072 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11073 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11074 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11075
11076 + pax_force_retaddr 0, 1
11077 ret;
11078 ENDPROC(__cast5_enc_blk16)
11079
11080 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11081 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11082 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11083
11084 + pax_force_retaddr 0, 1
11085 ret;
11086
11087 .L__skip_dec:
11088 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11089 vmovdqu RR4, (6*4*4)(%r11);
11090 vmovdqu RL4, (7*4*4)(%r11);
11091
11092 + pax_force_retaddr
11093 ret;
11094 ENDPROC(cast5_ecb_enc_16way)
11095
11096 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11097 vmovdqu RR4, (6*4*4)(%r11);
11098 vmovdqu RL4, (7*4*4)(%r11);
11099
11100 + pax_force_retaddr
11101 ret;
11102 ENDPROC(cast5_ecb_dec_16way)
11103
11104 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11105
11106 popq %r12;
11107
11108 + pax_force_retaddr
11109 ret;
11110 ENDPROC(cast5_cbc_dec_16way)
11111
11112 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11113
11114 popq %r12;
11115
11116 + pax_force_retaddr
11117 ret;
11118 ENDPROC(cast5_ctr_16way)
11119 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11120 index e3531f8..18ded3a 100644
11121 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11122 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11123 @@ -24,6 +24,7 @@
11124 */
11125
11126 #include <linux/linkage.h>
11127 +#include <asm/alternative-asm.h>
11128 #include "glue_helper-asm-avx.S"
11129
11130 .file "cast6-avx-x86_64-asm_64.S"
11131 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11132 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11133 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11134
11135 + pax_force_retaddr 0, 1
11136 ret;
11137 ENDPROC(__cast6_enc_blk8)
11138
11139 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11140 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11141 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11142
11143 + pax_force_retaddr 0, 1
11144 ret;
11145 ENDPROC(__cast6_dec_blk8)
11146
11147 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11148
11149 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11150
11151 + pax_force_retaddr
11152 ret;
11153 ENDPROC(cast6_ecb_enc_8way)
11154
11155 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11156
11157 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11158
11159 + pax_force_retaddr
11160 ret;
11161 ENDPROC(cast6_ecb_dec_8way)
11162
11163 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11164
11165 popq %r12;
11166
11167 + pax_force_retaddr
11168 ret;
11169 ENDPROC(cast6_cbc_dec_8way)
11170
11171 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11172
11173 popq %r12;
11174
11175 + pax_force_retaddr
11176 ret;
11177 ENDPROC(cast6_ctr_8way)
11178
11179 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11180 /* dst <= regs xor IVs(in dst) */
11181 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11182
11183 + pax_force_retaddr
11184 ret;
11185 ENDPROC(cast6_xts_enc_8way)
11186
11187 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11188 /* dst <= regs xor IVs(in dst) */
11189 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11190
11191 + pax_force_retaddr
11192 ret;
11193 ENDPROC(cast6_xts_dec_8way)
11194 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11195 index 9279e0b..9270820 100644
11196 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11197 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11198 @@ -1,4 +1,5 @@
11199 #include <linux/linkage.h>
11200 +#include <asm/alternative-asm.h>
11201
11202 # enter salsa20_encrypt_bytes
11203 ENTRY(salsa20_encrypt_bytes)
11204 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11205 add %r11,%rsp
11206 mov %rdi,%rax
11207 mov %rsi,%rdx
11208 + pax_force_retaddr 0, 1
11209 ret
11210 # bytesatleast65:
11211 ._bytesatleast65:
11212 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11213 add %r11,%rsp
11214 mov %rdi,%rax
11215 mov %rsi,%rdx
11216 + pax_force_retaddr
11217 ret
11218 ENDPROC(salsa20_keysetup)
11219
11220 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11221 add %r11,%rsp
11222 mov %rdi,%rax
11223 mov %rsi,%rdx
11224 + pax_force_retaddr
11225 ret
11226 ENDPROC(salsa20_ivsetup)
11227 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11228 index 2f202f4..d9164d6 100644
11229 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11230 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11231 @@ -24,6 +24,7 @@
11232 */
11233
11234 #include <linux/linkage.h>
11235 +#include <asm/alternative-asm.h>
11236 #include "glue_helper-asm-avx.S"
11237
11238 .file "serpent-avx-x86_64-asm_64.S"
11239 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11240 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11241 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11242
11243 + pax_force_retaddr
11244 ret;
11245 ENDPROC(__serpent_enc_blk8_avx)
11246
11247 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11248 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11249 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11250
11251 + pax_force_retaddr
11252 ret;
11253 ENDPROC(__serpent_dec_blk8_avx)
11254
11255 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11256
11257 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11258
11259 + pax_force_retaddr
11260 ret;
11261 ENDPROC(serpent_ecb_enc_8way_avx)
11262
11263 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11264
11265 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11266
11267 + pax_force_retaddr
11268 ret;
11269 ENDPROC(serpent_ecb_dec_8way_avx)
11270
11271 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11272
11273 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11274
11275 + pax_force_retaddr
11276 ret;
11277 ENDPROC(serpent_cbc_dec_8way_avx)
11278
11279 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11280
11281 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11282
11283 + pax_force_retaddr
11284 ret;
11285 ENDPROC(serpent_ctr_8way_avx)
11286
11287 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11288 /* dst <= regs xor IVs(in dst) */
11289 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11290
11291 + pax_force_retaddr
11292 ret;
11293 ENDPROC(serpent_xts_enc_8way_avx)
11294
11295 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11296 /* dst <= regs xor IVs(in dst) */
11297 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11298
11299 + pax_force_retaddr
11300 ret;
11301 ENDPROC(serpent_xts_dec_8way_avx)
11302 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11303 index acc066c..1559cc4 100644
11304 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11305 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11306 @@ -25,6 +25,7 @@
11307 */
11308
11309 #include <linux/linkage.h>
11310 +#include <asm/alternative-asm.h>
11311
11312 .file "serpent-sse2-x86_64-asm_64.S"
11313 .text
11314 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11315 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11316 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11317
11318 + pax_force_retaddr
11319 ret;
11320
11321 .L__enc_xor8:
11322 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11323 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11324
11325 + pax_force_retaddr
11326 ret;
11327 ENDPROC(__serpent_enc_blk_8way)
11328
11329 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11330 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11331 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11332
11333 + pax_force_retaddr
11334 ret;
11335 ENDPROC(serpent_dec_blk_8way)
11336 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11337 index a410950..3356d42 100644
11338 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11339 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11340 @@ -29,6 +29,7 @@
11341 */
11342
11343 #include <linux/linkage.h>
11344 +#include <asm/alternative-asm.h>
11345
11346 #define CTX %rdi // arg1
11347 #define BUF %rsi // arg2
11348 @@ -104,6 +105,7 @@
11349 pop %r12
11350 pop %rbp
11351 pop %rbx
11352 + pax_force_retaddr 0, 1
11353 ret
11354
11355 ENDPROC(\name)
11356 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11357 index 0505813..63b1d00 100644
11358 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11359 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11360 @@ -24,6 +24,7 @@
11361 */
11362
11363 #include <linux/linkage.h>
11364 +#include <asm/alternative-asm.h>
11365 #include "glue_helper-asm-avx.S"
11366
11367 .file "twofish-avx-x86_64-asm_64.S"
11368 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
11369 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11370 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11371
11372 + pax_force_retaddr 0, 1
11373 ret;
11374 ENDPROC(__twofish_enc_blk8)
11375
11376 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
11377 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11378 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11379
11380 + pax_force_retaddr 0, 1
11381 ret;
11382 ENDPROC(__twofish_dec_blk8)
11383
11384 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
11385
11386 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11387
11388 + pax_force_retaddr 0, 1
11389 ret;
11390 ENDPROC(twofish_ecb_enc_8way)
11391
11392 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
11393
11394 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11395
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(twofish_ecb_dec_8way)
11399
11400 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
11401
11402 popq %r12;
11403
11404 + pax_force_retaddr 0, 1
11405 ret;
11406 ENDPROC(twofish_cbc_dec_8way)
11407
11408 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
11409
11410 popq %r12;
11411
11412 + pax_force_retaddr 0, 1
11413 ret;
11414 ENDPROC(twofish_ctr_8way)
11415
11416 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
11417 /* dst <= regs xor IVs(in dst) */
11418 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11419
11420 + pax_force_retaddr 0, 1
11421 ret;
11422 ENDPROC(twofish_xts_enc_8way)
11423
11424 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
11425 /* dst <= regs xor IVs(in dst) */
11426 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11427
11428 + pax_force_retaddr 0, 1
11429 ret;
11430 ENDPROC(twofish_xts_dec_8way)
11431 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11432 index 1c3b7ce..b365c5e 100644
11433 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11434 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11435 @@ -21,6 +21,7 @@
11436 */
11437
11438 #include <linux/linkage.h>
11439 +#include <asm/alternative-asm.h>
11440
11441 .file "twofish-x86_64-asm-3way.S"
11442 .text
11443 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11444 popq %r13;
11445 popq %r14;
11446 popq %r15;
11447 + pax_force_retaddr 0, 1
11448 ret;
11449
11450 .L__enc_xor3:
11451 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11452 popq %r13;
11453 popq %r14;
11454 popq %r15;
11455 + pax_force_retaddr 0, 1
11456 ret;
11457 ENDPROC(__twofish_enc_blk_3way)
11458
11459 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11460 popq %r13;
11461 popq %r14;
11462 popq %r15;
11463 + pax_force_retaddr 0, 1
11464 ret;
11465 ENDPROC(twofish_dec_blk_3way)
11466 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11467 index a039d21..29e7615 100644
11468 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11469 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11470 @@ -22,6 +22,7 @@
11471
11472 #include <linux/linkage.h>
11473 #include <asm/asm-offsets.h>
11474 +#include <asm/alternative-asm.h>
11475
11476 #define a_offset 0
11477 #define b_offset 4
11478 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11479
11480 popq R1
11481 movq $1,%rax
11482 + pax_force_retaddr 0, 1
11483 ret
11484 ENDPROC(twofish_enc_blk)
11485
11486 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11487
11488 popq R1
11489 movq $1,%rax
11490 + pax_force_retaddr 0, 1
11491 ret
11492 ENDPROC(twofish_dec_blk)
11493 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11494 index 52ff81c..98af645 100644
11495 --- a/arch/x86/ia32/ia32_aout.c
11496 +++ b/arch/x86/ia32/ia32_aout.c
11497 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11498 unsigned long dump_start, dump_size;
11499 struct user32 dump;
11500
11501 + memset(&dump, 0, sizeof(dump));
11502 +
11503 fs = get_fs();
11504 set_fs(KERNEL_DS);
11505 has_dumped = 1;
11506 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11507 index cf1a471..3bc4cf8 100644
11508 --- a/arch/x86/ia32/ia32_signal.c
11509 +++ b/arch/x86/ia32/ia32_signal.c
11510 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11511 sp -= frame_size;
11512 /* Align the stack pointer according to the i386 ABI,
11513 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11514 - sp = ((sp + 4) & -16ul) - 4;
11515 + sp = ((sp - 12) & -16ul) - 4;
11516 return (void __user *) sp;
11517 }
11518
11519 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11520 * These are actually not used anymore, but left because some
11521 * gdb versions depend on them as a marker.
11522 */
11523 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11524 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11525 } put_user_catch(err);
11526
11527 if (err)
11528 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11529 0xb8,
11530 __NR_ia32_rt_sigreturn,
11531 0x80cd,
11532 - 0,
11533 + 0
11534 };
11535
11536 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11537 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11538
11539 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11540 restorer = ksig->ka.sa.sa_restorer;
11541 + else if (current->mm->context.vdso)
11542 + /* Return stub is in 32bit vsyscall page */
11543 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11544 else
11545 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11546 - rt_sigreturn);
11547 + restorer = &frame->retcode;
11548 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11549
11550 /*
11551 * Not actually used anymore, but left because some gdb
11552 * versions need it.
11553 */
11554 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11555 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11556 } put_user_catch(err);
11557
11558 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11559 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11560 index 474dc1b..24aaa3e 100644
11561 --- a/arch/x86/ia32/ia32entry.S
11562 +++ b/arch/x86/ia32/ia32entry.S
11563 @@ -15,8 +15,10 @@
11564 #include <asm/irqflags.h>
11565 #include <asm/asm.h>
11566 #include <asm/smap.h>
11567 +#include <asm/pgtable.h>
11568 #include <linux/linkage.h>
11569 #include <linux/err.h>
11570 +#include <asm/alternative-asm.h>
11571
11572 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11573 #include <linux/elf-em.h>
11574 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11575 ENDPROC(native_irq_enable_sysexit)
11576 #endif
11577
11578 + .macro pax_enter_kernel_user
11579 + pax_set_fptr_mask
11580 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11581 + call pax_enter_kernel_user
11582 +#endif
11583 + .endm
11584 +
11585 + .macro pax_exit_kernel_user
11586 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11587 + call pax_exit_kernel_user
11588 +#endif
11589 +#ifdef CONFIG_PAX_RANDKSTACK
11590 + pushq %rax
11591 + pushq %r11
11592 + call pax_randomize_kstack
11593 + popq %r11
11594 + popq %rax
11595 +#endif
11596 + .endm
11597 +
11598 + .macro pax_erase_kstack
11599 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11600 + call pax_erase_kstack
11601 +#endif
11602 + .endm
11603 +
11604 /*
11605 * 32bit SYSENTER instruction entry.
11606 *
11607 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11608 CFI_REGISTER rsp,rbp
11609 SWAPGS_UNSAFE_STACK
11610 movq PER_CPU_VAR(kernel_stack), %rsp
11611 - addq $(KERNEL_STACK_OFFSET),%rsp
11612 - /*
11613 - * No need to follow this irqs on/off section: the syscall
11614 - * disabled irqs, here we enable it straight after entry:
11615 - */
11616 - ENABLE_INTERRUPTS(CLBR_NONE)
11617 movl %ebp,%ebp /* zero extension */
11618 pushq_cfi $__USER32_DS
11619 /*CFI_REL_OFFSET ss,0*/
11620 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11621 CFI_REL_OFFSET rsp,0
11622 pushfq_cfi
11623 /*CFI_REL_OFFSET rflags,0*/
11624 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11625 - CFI_REGISTER rip,r10
11626 + orl $X86_EFLAGS_IF,(%rsp)
11627 + GET_THREAD_INFO(%r11)
11628 + movl TI_sysenter_return(%r11), %r11d
11629 + CFI_REGISTER rip,r11
11630 pushq_cfi $__USER32_CS
11631 /*CFI_REL_OFFSET cs,0*/
11632 movl %eax, %eax
11633 - pushq_cfi %r10
11634 + pushq_cfi %r11
11635 CFI_REL_OFFSET rip,0
11636 pushq_cfi %rax
11637 cld
11638 SAVE_ARGS 0,1,0
11639 + pax_enter_kernel_user
11640 +
11641 +#ifdef CONFIG_PAX_RANDKSTACK
11642 + pax_erase_kstack
11643 +#endif
11644 +
11645 + /*
11646 + * No need to follow this irqs on/off section: the syscall
11647 + * disabled irqs, here we enable it straight after entry:
11648 + */
11649 + ENABLE_INTERRUPTS(CLBR_NONE)
11650 /* no need to do an access_ok check here because rbp has been
11651 32bit zero extended */
11652 +
11653 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11654 + mov pax_user_shadow_base,%r11
11655 + add %r11,%rbp
11656 +#endif
11657 +
11658 ASM_STAC
11659 1: movl (%rbp),%ebp
11660 _ASM_EXTABLE(1b,ia32_badarg)
11661 ASM_CLAC
11662 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11663 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11664 + GET_THREAD_INFO(%r11)
11665 + orl $TS_COMPAT,TI_status(%r11)
11666 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11667 CFI_REMEMBER_STATE
11668 jnz sysenter_tracesys
11669 cmpq $(IA32_NR_syscalls-1),%rax
11670 @@ -162,12 +204,15 @@ sysenter_do_call:
11671 sysenter_dispatch:
11672 call *ia32_sys_call_table(,%rax,8)
11673 movq %rax,RAX-ARGOFFSET(%rsp)
11674 + GET_THREAD_INFO(%r11)
11675 DISABLE_INTERRUPTS(CLBR_NONE)
11676 TRACE_IRQS_OFF
11677 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11678 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11679 jnz sysexit_audit
11680 sysexit_from_sys_call:
11681 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11682 + pax_exit_kernel_user
11683 + pax_erase_kstack
11684 + andl $~TS_COMPAT,TI_status(%r11)
11685 /* clear IF, that popfq doesn't enable interrupts early */
11686 andl $~0x200,EFLAGS-R11(%rsp)
11687 movl RIP-R11(%rsp),%edx /* User %eip */
11688 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11689 movl %eax,%esi /* 2nd arg: syscall number */
11690 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11691 call __audit_syscall_entry
11692 +
11693 + pax_erase_kstack
11694 +
11695 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11696 cmpq $(IA32_NR_syscalls-1),%rax
11697 ja ia32_badsys
11698 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11699 .endm
11700
11701 .macro auditsys_exit exit
11702 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11703 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11704 jnz ia32_ret_from_sys_call
11705 TRACE_IRQS_ON
11706 ENABLE_INTERRUPTS(CLBR_NONE)
11707 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11708 1: setbe %al /* 1 if error, 0 if not */
11709 movzbl %al,%edi /* zero-extend that into %edi */
11710 call __audit_syscall_exit
11711 + GET_THREAD_INFO(%r11)
11712 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11713 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11714 DISABLE_INTERRUPTS(CLBR_NONE)
11715 TRACE_IRQS_OFF
11716 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11717 + testl %edi,TI_flags(%r11)
11718 jz \exit
11719 CLEAR_RREGS -ARGOFFSET
11720 jmp int_with_check
11721 @@ -237,7 +286,7 @@ sysexit_audit:
11722
11723 sysenter_tracesys:
11724 #ifdef CONFIG_AUDITSYSCALL
11725 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11726 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11727 jz sysenter_auditsys
11728 #endif
11729 SAVE_REST
11730 @@ -249,6 +298,9 @@ sysenter_tracesys:
11731 RESTORE_REST
11732 cmpq $(IA32_NR_syscalls-1),%rax
11733 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11734 +
11735 + pax_erase_kstack
11736 +
11737 jmp sysenter_do_call
11738 CFI_ENDPROC
11739 ENDPROC(ia32_sysenter_target)
11740 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11741 ENTRY(ia32_cstar_target)
11742 CFI_STARTPROC32 simple
11743 CFI_SIGNAL_FRAME
11744 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11745 + CFI_DEF_CFA rsp,0
11746 CFI_REGISTER rip,rcx
11747 /*CFI_REGISTER rflags,r11*/
11748 SWAPGS_UNSAFE_STACK
11749 movl %esp,%r8d
11750 CFI_REGISTER rsp,r8
11751 movq PER_CPU_VAR(kernel_stack),%rsp
11752 + SAVE_ARGS 8*6,0,0
11753 + pax_enter_kernel_user
11754 +
11755 +#ifdef CONFIG_PAX_RANDKSTACK
11756 + pax_erase_kstack
11757 +#endif
11758 +
11759 /*
11760 * No need to follow this irqs on/off section: the syscall
11761 * disabled irqs and here we enable it straight after entry:
11762 */
11763 ENABLE_INTERRUPTS(CLBR_NONE)
11764 - SAVE_ARGS 8,0,0
11765 movl %eax,%eax /* zero extension */
11766 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11767 movq %rcx,RIP-ARGOFFSET(%rsp)
11768 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11769 /* no need to do an access_ok check here because r8 has been
11770 32bit zero extended */
11771 /* hardware stack frame is complete now */
11772 +
11773 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11774 + mov pax_user_shadow_base,%r11
11775 + add %r11,%r8
11776 +#endif
11777 +
11778 ASM_STAC
11779 1: movl (%r8),%r9d
11780 _ASM_EXTABLE(1b,ia32_badarg)
11781 ASM_CLAC
11782 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11783 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11784 + GET_THREAD_INFO(%r11)
11785 + orl $TS_COMPAT,TI_status(%r11)
11786 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11787 CFI_REMEMBER_STATE
11788 jnz cstar_tracesys
11789 cmpq $IA32_NR_syscalls-1,%rax
11790 @@ -319,12 +384,15 @@ cstar_do_call:
11791 cstar_dispatch:
11792 call *ia32_sys_call_table(,%rax,8)
11793 movq %rax,RAX-ARGOFFSET(%rsp)
11794 + GET_THREAD_INFO(%r11)
11795 DISABLE_INTERRUPTS(CLBR_NONE)
11796 TRACE_IRQS_OFF
11797 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11798 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11799 jnz sysretl_audit
11800 sysretl_from_sys_call:
11801 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11802 + pax_exit_kernel_user
11803 + pax_erase_kstack
11804 + andl $~TS_COMPAT,TI_status(%r11)
11805 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11806 movl RIP-ARGOFFSET(%rsp),%ecx
11807 CFI_REGISTER rip,rcx
11808 @@ -352,7 +420,7 @@ sysretl_audit:
11809
11810 cstar_tracesys:
11811 #ifdef CONFIG_AUDITSYSCALL
11812 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11813 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11814 jz cstar_auditsys
11815 #endif
11816 xchgl %r9d,%ebp
11817 @@ -366,6 +434,9 @@ cstar_tracesys:
11818 xchgl %ebp,%r9d
11819 cmpq $(IA32_NR_syscalls-1),%rax
11820 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11821 +
11822 + pax_erase_kstack
11823 +
11824 jmp cstar_do_call
11825 END(ia32_cstar_target)
11826
11827 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11828 CFI_REL_OFFSET rip,RIP-RIP
11829 PARAVIRT_ADJUST_EXCEPTION_FRAME
11830 SWAPGS
11831 - /*
11832 - * No need to follow this irqs on/off section: the syscall
11833 - * disabled irqs and here we enable it straight after entry:
11834 - */
11835 - ENABLE_INTERRUPTS(CLBR_NONE)
11836 movl %eax,%eax
11837 pushq_cfi %rax
11838 cld
11839 /* note the registers are not zero extended to the sf.
11840 this could be a problem. */
11841 SAVE_ARGS 0,1,0
11842 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11843 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11844 + pax_enter_kernel_user
11845 +
11846 +#ifdef CONFIG_PAX_RANDKSTACK
11847 + pax_erase_kstack
11848 +#endif
11849 +
11850 + /*
11851 + * No need to follow this irqs on/off section: the syscall
11852 + * disabled irqs and here we enable it straight after entry:
11853 + */
11854 + ENABLE_INTERRUPTS(CLBR_NONE)
11855 + GET_THREAD_INFO(%r11)
11856 + orl $TS_COMPAT,TI_status(%r11)
11857 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11858 jnz ia32_tracesys
11859 cmpq $(IA32_NR_syscalls-1),%rax
11860 ja ia32_badsys
11861 @@ -442,6 +520,9 @@ ia32_tracesys:
11862 RESTORE_REST
11863 cmpq $(IA32_NR_syscalls-1),%rax
11864 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11865 +
11866 + pax_erase_kstack
11867 +
11868 jmp ia32_do_call
11869 END(ia32_syscall)
11870
11871 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11872 index 8e0ceec..af13504 100644
11873 --- a/arch/x86/ia32/sys_ia32.c
11874 +++ b/arch/x86/ia32/sys_ia32.c
11875 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11876 */
11877 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11878 {
11879 - typeof(ubuf->st_uid) uid = 0;
11880 - typeof(ubuf->st_gid) gid = 0;
11881 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11882 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11883 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11884 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11885 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11886 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11887 index 372231c..a5aa1a1 100644
11888 --- a/arch/x86/include/asm/alternative-asm.h
11889 +++ b/arch/x86/include/asm/alternative-asm.h
11890 @@ -18,6 +18,45 @@
11891 .endm
11892 #endif
11893
11894 +#ifdef KERNEXEC_PLUGIN
11895 + .macro pax_force_retaddr_bts rip=0
11896 + btsq $63,\rip(%rsp)
11897 + .endm
11898 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11899 + .macro pax_force_retaddr rip=0, reload=0
11900 + btsq $63,\rip(%rsp)
11901 + .endm
11902 + .macro pax_force_fptr ptr
11903 + btsq $63,\ptr
11904 + .endm
11905 + .macro pax_set_fptr_mask
11906 + .endm
11907 +#endif
11908 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11909 + .macro pax_force_retaddr rip=0, reload=0
11910 + .if \reload
11911 + pax_set_fptr_mask
11912 + .endif
11913 + orq %r10,\rip(%rsp)
11914 + .endm
11915 + .macro pax_force_fptr ptr
11916 + orq %r10,\ptr
11917 + .endm
11918 + .macro pax_set_fptr_mask
11919 + movabs $0x8000000000000000,%r10
11920 + .endm
11921 +#endif
11922 +#else
11923 + .macro pax_force_retaddr rip=0, reload=0
11924 + .endm
11925 + .macro pax_force_fptr ptr
11926 + .endm
11927 + .macro pax_force_retaddr_bts rip=0
11928 + .endm
11929 + .macro pax_set_fptr_mask
11930 + .endm
11931 +#endif
11932 +
11933 .macro altinstruction_entry orig alt feature orig_len alt_len
11934 .long \orig - .
11935 .long \alt - .
11936 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11937 index 58ed6d9..f1cbe58 100644
11938 --- a/arch/x86/include/asm/alternative.h
11939 +++ b/arch/x86/include/asm/alternative.h
11940 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11941 ".pushsection .discard,\"aw\",@progbits\n" \
11942 DISCARD_ENTRY(1) \
11943 ".popsection\n" \
11944 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11945 + ".pushsection .altinstr_replacement, \"a\"\n" \
11946 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11947 ".popsection"
11948
11949 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11950 DISCARD_ENTRY(1) \
11951 DISCARD_ENTRY(2) \
11952 ".popsection\n" \
11953 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11954 + ".pushsection .altinstr_replacement, \"a\"\n" \
11955 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11956 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11957 ".popsection"
11958 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11959 index 3388034..050f0b9 100644
11960 --- a/arch/x86/include/asm/apic.h
11961 +++ b/arch/x86/include/asm/apic.h
11962 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11963
11964 #ifdef CONFIG_X86_LOCAL_APIC
11965
11966 -extern unsigned int apic_verbosity;
11967 +extern int apic_verbosity;
11968 extern int local_apic_timer_c2_ok;
11969
11970 extern int disable_apic;
11971 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11972 index 20370c6..a2eb9b0 100644
11973 --- a/arch/x86/include/asm/apm.h
11974 +++ b/arch/x86/include/asm/apm.h
11975 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11976 __asm__ __volatile__(APM_DO_ZERO_SEGS
11977 "pushl %%edi\n\t"
11978 "pushl %%ebp\n\t"
11979 - "lcall *%%cs:apm_bios_entry\n\t"
11980 + "lcall *%%ss:apm_bios_entry\n\t"
11981 "setc %%al\n\t"
11982 "popl %%ebp\n\t"
11983 "popl %%edi\n\t"
11984 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11985 __asm__ __volatile__(APM_DO_ZERO_SEGS
11986 "pushl %%edi\n\t"
11987 "pushl %%ebp\n\t"
11988 - "lcall *%%cs:apm_bios_entry\n\t"
11989 + "lcall *%%ss:apm_bios_entry\n\t"
11990 "setc %%bl\n\t"
11991 "popl %%ebp\n\t"
11992 "popl %%edi\n\t"
11993 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11994 index 722aa3b..3a0bb27 100644
11995 --- a/arch/x86/include/asm/atomic.h
11996 +++ b/arch/x86/include/asm/atomic.h
11997 @@ -22,7 +22,18 @@
11998 */
11999 static inline int atomic_read(const atomic_t *v)
12000 {
12001 - return (*(volatile int *)&(v)->counter);
12002 + return (*(volatile const int *)&(v)->counter);
12003 +}
12004 +
12005 +/**
12006 + * atomic_read_unchecked - read atomic variable
12007 + * @v: pointer of type atomic_unchecked_t
12008 + *
12009 + * Atomically reads the value of @v.
12010 + */
12011 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12012 +{
12013 + return (*(volatile const int *)&(v)->counter);
12014 }
12015
12016 /**
12017 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12018 }
12019
12020 /**
12021 + * atomic_set_unchecked - set atomic variable
12022 + * @v: pointer of type atomic_unchecked_t
12023 + * @i: required value
12024 + *
12025 + * Atomically sets the value of @v to @i.
12026 + */
12027 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12028 +{
12029 + v->counter = i;
12030 +}
12031 +
12032 +/**
12033 * atomic_add - add integer to atomic variable
12034 * @i: integer value to add
12035 * @v: pointer of type atomic_t
12036 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12037 */
12038 static inline void atomic_add(int i, atomic_t *v)
12039 {
12040 - asm volatile(LOCK_PREFIX "addl %1,%0"
12041 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12042 +
12043 +#ifdef CONFIG_PAX_REFCOUNT
12044 + "jno 0f\n"
12045 + LOCK_PREFIX "subl %1,%0\n"
12046 + "int $4\n0:\n"
12047 + _ASM_EXTABLE(0b, 0b)
12048 +#endif
12049 +
12050 + : "+m" (v->counter)
12051 + : "ir" (i));
12052 +}
12053 +
12054 +/**
12055 + * atomic_add_unchecked - add integer to atomic variable
12056 + * @i: integer value to add
12057 + * @v: pointer of type atomic_unchecked_t
12058 + *
12059 + * Atomically adds @i to @v.
12060 + */
12061 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12062 +{
12063 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12064 : "+m" (v->counter)
12065 : "ir" (i));
12066 }
12067 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12068 */
12069 static inline void atomic_sub(int i, atomic_t *v)
12070 {
12071 - asm volatile(LOCK_PREFIX "subl %1,%0"
12072 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12073 +
12074 +#ifdef CONFIG_PAX_REFCOUNT
12075 + "jno 0f\n"
12076 + LOCK_PREFIX "addl %1,%0\n"
12077 + "int $4\n0:\n"
12078 + _ASM_EXTABLE(0b, 0b)
12079 +#endif
12080 +
12081 + : "+m" (v->counter)
12082 + : "ir" (i));
12083 +}
12084 +
12085 +/**
12086 + * atomic_sub_unchecked - subtract integer from atomic variable
12087 + * @i: integer value to subtract
12088 + * @v: pointer of type atomic_unchecked_t
12089 + *
12090 + * Atomically subtracts @i from @v.
12091 + */
12092 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12093 +{
12094 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12095 : "+m" (v->counter)
12096 : "ir" (i));
12097 }
12098 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12099 {
12100 unsigned char c;
12101
12102 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12103 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12104 +
12105 +#ifdef CONFIG_PAX_REFCOUNT
12106 + "jno 0f\n"
12107 + LOCK_PREFIX "addl %2,%0\n"
12108 + "int $4\n0:\n"
12109 + _ASM_EXTABLE(0b, 0b)
12110 +#endif
12111 +
12112 + "sete %1\n"
12113 : "+m" (v->counter), "=qm" (c)
12114 : "ir" (i) : "memory");
12115 return c;
12116 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12117 */
12118 static inline void atomic_inc(atomic_t *v)
12119 {
12120 - asm volatile(LOCK_PREFIX "incl %0"
12121 + asm volatile(LOCK_PREFIX "incl %0\n"
12122 +
12123 +#ifdef CONFIG_PAX_REFCOUNT
12124 + "jno 0f\n"
12125 + LOCK_PREFIX "decl %0\n"
12126 + "int $4\n0:\n"
12127 + _ASM_EXTABLE(0b, 0b)
12128 +#endif
12129 +
12130 + : "+m" (v->counter));
12131 +}
12132 +
12133 +/**
12134 + * atomic_inc_unchecked - increment atomic variable
12135 + * @v: pointer of type atomic_unchecked_t
12136 + *
12137 + * Atomically increments @v by 1.
12138 + */
12139 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12140 +{
12141 + asm volatile(LOCK_PREFIX "incl %0\n"
12142 : "+m" (v->counter));
12143 }
12144
12145 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12146 */
12147 static inline void atomic_dec(atomic_t *v)
12148 {
12149 - asm volatile(LOCK_PREFIX "decl %0"
12150 + asm volatile(LOCK_PREFIX "decl %0\n"
12151 +
12152 +#ifdef CONFIG_PAX_REFCOUNT
12153 + "jno 0f\n"
12154 + LOCK_PREFIX "incl %0\n"
12155 + "int $4\n0:\n"
12156 + _ASM_EXTABLE(0b, 0b)
12157 +#endif
12158 +
12159 + : "+m" (v->counter));
12160 +}
12161 +
12162 +/**
12163 + * atomic_dec_unchecked - decrement atomic variable
12164 + * @v: pointer of type atomic_unchecked_t
12165 + *
12166 + * Atomically decrements @v by 1.
12167 + */
12168 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12169 +{
12170 + asm volatile(LOCK_PREFIX "decl %0\n"
12171 : "+m" (v->counter));
12172 }
12173
12174 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12175 {
12176 unsigned char c;
12177
12178 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12179 + asm volatile(LOCK_PREFIX "decl %0\n"
12180 +
12181 +#ifdef CONFIG_PAX_REFCOUNT
12182 + "jno 0f\n"
12183 + LOCK_PREFIX "incl %0\n"
12184 + "int $4\n0:\n"
12185 + _ASM_EXTABLE(0b, 0b)
12186 +#endif
12187 +
12188 + "sete %1\n"
12189 : "+m" (v->counter), "=qm" (c)
12190 : : "memory");
12191 return c != 0;
12192 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12193 {
12194 unsigned char c;
12195
12196 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12197 + asm volatile(LOCK_PREFIX "incl %0\n"
12198 +
12199 +#ifdef CONFIG_PAX_REFCOUNT
12200 + "jno 0f\n"
12201 + LOCK_PREFIX "decl %0\n"
12202 + "int $4\n0:\n"
12203 + _ASM_EXTABLE(0b, 0b)
12204 +#endif
12205 +
12206 + "sete %1\n"
12207 + : "+m" (v->counter), "=qm" (c)
12208 + : : "memory");
12209 + return c != 0;
12210 +}
12211 +
12212 +/**
12213 + * atomic_inc_and_test_unchecked - increment and test
12214 + * @v: pointer of type atomic_unchecked_t
12215 + *
12216 + * Atomically increments @v by 1
12217 + * and returns true if the result is zero, or false for all
12218 + * other cases.
12219 + */
12220 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12221 +{
12222 + unsigned char c;
12223 +
12224 + asm volatile(LOCK_PREFIX "incl %0\n"
12225 + "sete %1\n"
12226 : "+m" (v->counter), "=qm" (c)
12227 : : "memory");
12228 return c != 0;
12229 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12230 {
12231 unsigned char c;
12232
12233 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12234 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12235 +
12236 +#ifdef CONFIG_PAX_REFCOUNT
12237 + "jno 0f\n"
12238 + LOCK_PREFIX "subl %2,%0\n"
12239 + "int $4\n0:\n"
12240 + _ASM_EXTABLE(0b, 0b)
12241 +#endif
12242 +
12243 + "sets %1\n"
12244 : "+m" (v->counter), "=qm" (c)
12245 : "ir" (i) : "memory");
12246 return c;
12247 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12248 */
12249 static inline int atomic_add_return(int i, atomic_t *v)
12250 {
12251 + return i + xadd_check_overflow(&v->counter, i);
12252 +}
12253 +
12254 +/**
12255 + * atomic_add_return_unchecked - add integer and return
12256 + * @i: integer value to add
12257 + * @v: pointer of type atomic_unchecked_t
12258 + *
12259 + * Atomically adds @i to @v and returns @i + @v
12260 + */
12261 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12262 +{
12263 return i + xadd(&v->counter, i);
12264 }
12265
12266 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12267 }
12268
12269 #define atomic_inc_return(v) (atomic_add_return(1, v))
12270 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12271 +{
12272 + return atomic_add_return_unchecked(1, v);
12273 +}
12274 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12275
12276 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12277 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12278 return cmpxchg(&v->counter, old, new);
12279 }
12280
12281 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12282 +{
12283 + return cmpxchg(&v->counter, old, new);
12284 +}
12285 +
12286 static inline int atomic_xchg(atomic_t *v, int new)
12287 {
12288 return xchg(&v->counter, new);
12289 }
12290
12291 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12292 +{
12293 + return xchg(&v->counter, new);
12294 +}
12295 +
12296 /**
12297 * __atomic_add_unless - add unless the number is already a given value
12298 * @v: pointer of type atomic_t
12299 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12300 */
12301 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12302 {
12303 - int c, old;
12304 + int c, old, new;
12305 c = atomic_read(v);
12306 for (;;) {
12307 - if (unlikely(c == (u)))
12308 + if (unlikely(c == u))
12309 break;
12310 - old = atomic_cmpxchg((v), c, c + (a));
12311 +
12312 + asm volatile("addl %2,%0\n"
12313 +
12314 +#ifdef CONFIG_PAX_REFCOUNT
12315 + "jno 0f\n"
12316 + "subl %2,%0\n"
12317 + "int $4\n0:\n"
12318 + _ASM_EXTABLE(0b, 0b)
12319 +#endif
12320 +
12321 + : "=r" (new)
12322 + : "0" (c), "ir" (a));
12323 +
12324 + old = atomic_cmpxchg(v, c, new);
12325 if (likely(old == c))
12326 break;
12327 c = old;
12328 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12329 }
12330
12331 /**
12332 + * atomic_inc_not_zero_hint - increment if not null
12333 + * @v: pointer of type atomic_t
12334 + * @hint: probable value of the atomic before the increment
12335 + *
12336 + * This version of atomic_inc_not_zero() gives a hint of probable
12337 + * value of the atomic. This helps processor to not read the memory
12338 + * before doing the atomic read/modify/write cycle, lowering
12339 + * number of bus transactions on some arches.
12340 + *
12341 + * Returns: 0 if increment was not done, 1 otherwise.
12342 + */
12343 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12344 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12345 +{
12346 + int val, c = hint, new;
12347 +
12348 + /* sanity test, should be removed by compiler if hint is a constant */
12349 + if (!hint)
12350 + return __atomic_add_unless(v, 1, 0);
12351 +
12352 + do {
12353 + asm volatile("incl %0\n"
12354 +
12355 +#ifdef CONFIG_PAX_REFCOUNT
12356 + "jno 0f\n"
12357 + "decl %0\n"
12358 + "int $4\n0:\n"
12359 + _ASM_EXTABLE(0b, 0b)
12360 +#endif
12361 +
12362 + : "=r" (new)
12363 + : "0" (c));
12364 +
12365 + val = atomic_cmpxchg(v, c, new);
12366 + if (val == c)
12367 + return 1;
12368 + c = val;
12369 + } while (c);
12370 +
12371 + return 0;
12372 +}
12373 +
12374 +/**
12375 * atomic_inc_short - increment of a short integer
12376 * @v: pointer to type int
12377 *
12378 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12379 #endif
12380
12381 /* These are x86-specific, used by some header files */
12382 -#define atomic_clear_mask(mask, addr) \
12383 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12384 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12385 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12386 +{
12387 + asm volatile(LOCK_PREFIX "andl %1,%0"
12388 + : "+m" (v->counter)
12389 + : "r" (~(mask))
12390 + : "memory");
12391 +}
12392
12393 -#define atomic_set_mask(mask, addr) \
12394 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12395 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12396 - : "memory")
12397 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12398 +{
12399 + asm volatile(LOCK_PREFIX "andl %1,%0"
12400 + : "+m" (v->counter)
12401 + : "r" (~(mask))
12402 + : "memory");
12403 +}
12404 +
12405 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12406 +{
12407 + asm volatile(LOCK_PREFIX "orl %1,%0"
12408 + : "+m" (v->counter)
12409 + : "r" (mask)
12410 + : "memory");
12411 +}
12412 +
12413 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12414 +{
12415 + asm volatile(LOCK_PREFIX "orl %1,%0"
12416 + : "+m" (v->counter)
12417 + : "r" (mask)
12418 + : "memory");
12419 +}
12420
12421 /* Atomic operations are already serializing on x86 */
12422 #define smp_mb__before_atomic_dec() barrier()
12423 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12424 index b154de7..aadebd8 100644
12425 --- a/arch/x86/include/asm/atomic64_32.h
12426 +++ b/arch/x86/include/asm/atomic64_32.h
12427 @@ -12,6 +12,14 @@ typedef struct {
12428 u64 __aligned(8) counter;
12429 } atomic64_t;
12430
12431 +#ifdef CONFIG_PAX_REFCOUNT
12432 +typedef struct {
12433 + u64 __aligned(8) counter;
12434 +} atomic64_unchecked_t;
12435 +#else
12436 +typedef atomic64_t atomic64_unchecked_t;
12437 +#endif
12438 +
12439 #define ATOMIC64_INIT(val) { (val) }
12440
12441 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12442 @@ -37,21 +45,31 @@ typedef struct {
12443 ATOMIC64_DECL_ONE(sym##_386)
12444
12445 ATOMIC64_DECL_ONE(add_386);
12446 +ATOMIC64_DECL_ONE(add_unchecked_386);
12447 ATOMIC64_DECL_ONE(sub_386);
12448 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12449 ATOMIC64_DECL_ONE(inc_386);
12450 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12451 ATOMIC64_DECL_ONE(dec_386);
12452 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12453 #endif
12454
12455 #define alternative_atomic64(f, out, in...) \
12456 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12457
12458 ATOMIC64_DECL(read);
12459 +ATOMIC64_DECL(read_unchecked);
12460 ATOMIC64_DECL(set);
12461 +ATOMIC64_DECL(set_unchecked);
12462 ATOMIC64_DECL(xchg);
12463 ATOMIC64_DECL(add_return);
12464 +ATOMIC64_DECL(add_return_unchecked);
12465 ATOMIC64_DECL(sub_return);
12466 +ATOMIC64_DECL(sub_return_unchecked);
12467 ATOMIC64_DECL(inc_return);
12468 +ATOMIC64_DECL(inc_return_unchecked);
12469 ATOMIC64_DECL(dec_return);
12470 +ATOMIC64_DECL(dec_return_unchecked);
12471 ATOMIC64_DECL(dec_if_positive);
12472 ATOMIC64_DECL(inc_not_zero);
12473 ATOMIC64_DECL(add_unless);
12474 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12475 }
12476
12477 /**
12478 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12479 + * @p: pointer to type atomic64_unchecked_t
12480 + * @o: expected value
12481 + * @n: new value
12482 + *
12483 + * Atomically sets @v to @n if it was equal to @o and returns
12484 + * the old value.
12485 + */
12486 +
12487 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12488 +{
12489 + return cmpxchg64(&v->counter, o, n);
12490 +}
12491 +
12492 +/**
12493 * atomic64_xchg - xchg atomic64 variable
12494 * @v: pointer to type atomic64_t
12495 * @n: value to assign
12496 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12497 }
12498
12499 /**
12500 + * atomic64_set_unchecked - set atomic64 variable
12501 + * @v: pointer to type atomic64_unchecked_t
12502 + * @n: value to assign
12503 + *
12504 + * Atomically sets the value of @v to @n.
12505 + */
12506 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12507 +{
12508 + unsigned high = (unsigned)(i >> 32);
12509 + unsigned low = (unsigned)i;
12510 + alternative_atomic64(set, /* no output */,
12511 + "S" (v), "b" (low), "c" (high)
12512 + : "eax", "edx", "memory");
12513 +}
12514 +
12515 +/**
12516 * atomic64_read - read atomic64 variable
12517 * @v: pointer to type atomic64_t
12518 *
12519 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12520 }
12521
12522 /**
12523 + * atomic64_read_unchecked - read atomic64 variable
12524 + * @v: pointer to type atomic64_unchecked_t
12525 + *
12526 + * Atomically reads the value of @v and returns it.
12527 + */
12528 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12529 +{
12530 + long long r;
12531 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12532 + return r;
12533 + }
12534 +
12535 +/**
12536 * atomic64_add_return - add and return
12537 * @i: integer value to add
12538 * @v: pointer to type atomic64_t
12539 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12540 return i;
12541 }
12542
12543 +/**
12544 + * atomic64_add_return_unchecked - add and return
12545 + * @i: integer value to add
12546 + * @v: pointer to type atomic64_unchecked_t
12547 + *
12548 + * Atomically adds @i to @v and returns @i + *@v
12549 + */
12550 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12551 +{
12552 + alternative_atomic64(add_return_unchecked,
12553 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12554 + ASM_NO_INPUT_CLOBBER("memory"));
12555 + return i;
12556 +}
12557 +
12558 /*
12559 * Other variants with different arithmetic operators:
12560 */
12561 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12562 return a;
12563 }
12564
12565 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12566 +{
12567 + long long a;
12568 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12569 + "S" (v) : "memory", "ecx");
12570 + return a;
12571 +}
12572 +
12573 static inline long long atomic64_dec_return(atomic64_t *v)
12574 {
12575 long long a;
12576 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12577 }
12578
12579 /**
12580 + * atomic64_add_unchecked - add integer to atomic64 variable
12581 + * @i: integer value to add
12582 + * @v: pointer to type atomic64_unchecked_t
12583 + *
12584 + * Atomically adds @i to @v.
12585 + */
12586 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12587 +{
12588 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12589 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12590 + ASM_NO_INPUT_CLOBBER("memory"));
12591 + return i;
12592 +}
12593 +
12594 +/**
12595 * atomic64_sub - subtract the atomic64 variable
12596 * @i: integer value to subtract
12597 * @v: pointer to type atomic64_t
12598 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12599 index 0e1cbfc..5623683 100644
12600 --- a/arch/x86/include/asm/atomic64_64.h
12601 +++ b/arch/x86/include/asm/atomic64_64.h
12602 @@ -18,7 +18,19 @@
12603 */
12604 static inline long atomic64_read(const atomic64_t *v)
12605 {
12606 - return (*(volatile long *)&(v)->counter);
12607 + return (*(volatile const long *)&(v)->counter);
12608 +}
12609 +
12610 +/**
12611 + * atomic64_read_unchecked - read atomic64 variable
12612 + * @v: pointer of type atomic64_unchecked_t
12613 + *
12614 + * Atomically reads the value of @v.
12615 + * Doesn't imply a read memory barrier.
12616 + */
12617 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12618 +{
12619 + return (*(volatile const long *)&(v)->counter);
12620 }
12621
12622 /**
12623 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12624 }
12625
12626 /**
12627 + * atomic64_set_unchecked - set atomic64 variable
12628 + * @v: pointer to type atomic64_unchecked_t
12629 + * @i: required value
12630 + *
12631 + * Atomically sets the value of @v to @i.
12632 + */
12633 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12634 +{
12635 + v->counter = i;
12636 +}
12637 +
12638 +/**
12639 * atomic64_add - add integer to atomic64 variable
12640 * @i: integer value to add
12641 * @v: pointer to type atomic64_t
12642 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12643 */
12644 static inline void atomic64_add(long i, atomic64_t *v)
12645 {
12646 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12647 +
12648 +#ifdef CONFIG_PAX_REFCOUNT
12649 + "jno 0f\n"
12650 + LOCK_PREFIX "subq %1,%0\n"
12651 + "int $4\n0:\n"
12652 + _ASM_EXTABLE(0b, 0b)
12653 +#endif
12654 +
12655 + : "=m" (v->counter)
12656 + : "er" (i), "m" (v->counter));
12657 +}
12658 +
12659 +/**
12660 + * atomic64_add_unchecked - add integer to atomic64 variable
12661 + * @i: integer value to add
12662 + * @v: pointer to type atomic64_unchecked_t
12663 + *
12664 + * Atomically adds @i to @v.
12665 + */
12666 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12667 +{
12668 asm volatile(LOCK_PREFIX "addq %1,%0"
12669 : "=m" (v->counter)
12670 : "er" (i), "m" (v->counter));
12671 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12672 */
12673 static inline void atomic64_sub(long i, atomic64_t *v)
12674 {
12675 - asm volatile(LOCK_PREFIX "subq %1,%0"
12676 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12677 +
12678 +#ifdef CONFIG_PAX_REFCOUNT
12679 + "jno 0f\n"
12680 + LOCK_PREFIX "addq %1,%0\n"
12681 + "int $4\n0:\n"
12682 + _ASM_EXTABLE(0b, 0b)
12683 +#endif
12684 +
12685 + : "=m" (v->counter)
12686 + : "er" (i), "m" (v->counter));
12687 +}
12688 +
12689 +/**
12690 + * atomic64_sub_unchecked - subtract the atomic64 variable
12691 + * @i: integer value to subtract
12692 + * @v: pointer to type atomic64_unchecked_t
12693 + *
12694 + * Atomically subtracts @i from @v.
12695 + */
12696 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12697 +{
12698 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12699 : "=m" (v->counter)
12700 : "er" (i), "m" (v->counter));
12701 }
12702 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12703 {
12704 unsigned char c;
12705
12706 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12707 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12708 +
12709 +#ifdef CONFIG_PAX_REFCOUNT
12710 + "jno 0f\n"
12711 + LOCK_PREFIX "addq %2,%0\n"
12712 + "int $4\n0:\n"
12713 + _ASM_EXTABLE(0b, 0b)
12714 +#endif
12715 +
12716 + "sete %1\n"
12717 : "=m" (v->counter), "=qm" (c)
12718 : "er" (i), "m" (v->counter) : "memory");
12719 return c;
12720 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12721 */
12722 static inline void atomic64_inc(atomic64_t *v)
12723 {
12724 + asm volatile(LOCK_PREFIX "incq %0\n"
12725 +
12726 +#ifdef CONFIG_PAX_REFCOUNT
12727 + "jno 0f\n"
12728 + LOCK_PREFIX "decq %0\n"
12729 + "int $4\n0:\n"
12730 + _ASM_EXTABLE(0b, 0b)
12731 +#endif
12732 +
12733 + : "=m" (v->counter)
12734 + : "m" (v->counter));
12735 +}
12736 +
12737 +/**
12738 + * atomic64_inc_unchecked - increment atomic64 variable
12739 + * @v: pointer to type atomic64_unchecked_t
12740 + *
12741 + * Atomically increments @v by 1.
12742 + */
12743 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12744 +{
12745 asm volatile(LOCK_PREFIX "incq %0"
12746 : "=m" (v->counter)
12747 : "m" (v->counter));
12748 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12749 */
12750 static inline void atomic64_dec(atomic64_t *v)
12751 {
12752 - asm volatile(LOCK_PREFIX "decq %0"
12753 + asm volatile(LOCK_PREFIX "decq %0\n"
12754 +
12755 +#ifdef CONFIG_PAX_REFCOUNT
12756 + "jno 0f\n"
12757 + LOCK_PREFIX "incq %0\n"
12758 + "int $4\n0:\n"
12759 + _ASM_EXTABLE(0b, 0b)
12760 +#endif
12761 +
12762 + : "=m" (v->counter)
12763 + : "m" (v->counter));
12764 +}
12765 +
12766 +/**
12767 + * atomic64_dec_unchecked - decrement atomic64 variable
12768 + * @v: pointer to type atomic64_t
12769 + *
12770 + * Atomically decrements @v by 1.
12771 + */
12772 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12773 +{
12774 + asm volatile(LOCK_PREFIX "decq %0\n"
12775 : "=m" (v->counter)
12776 : "m" (v->counter));
12777 }
12778 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12779 {
12780 unsigned char c;
12781
12782 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12783 + asm volatile(LOCK_PREFIX "decq %0\n"
12784 +
12785 +#ifdef CONFIG_PAX_REFCOUNT
12786 + "jno 0f\n"
12787 + LOCK_PREFIX "incq %0\n"
12788 + "int $4\n0:\n"
12789 + _ASM_EXTABLE(0b, 0b)
12790 +#endif
12791 +
12792 + "sete %1\n"
12793 : "=m" (v->counter), "=qm" (c)
12794 : "m" (v->counter) : "memory");
12795 return c != 0;
12796 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12797 {
12798 unsigned char c;
12799
12800 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12801 + asm volatile(LOCK_PREFIX "incq %0\n"
12802 +
12803 +#ifdef CONFIG_PAX_REFCOUNT
12804 + "jno 0f\n"
12805 + LOCK_PREFIX "decq %0\n"
12806 + "int $4\n0:\n"
12807 + _ASM_EXTABLE(0b, 0b)
12808 +#endif
12809 +
12810 + "sete %1\n"
12811 : "=m" (v->counter), "=qm" (c)
12812 : "m" (v->counter) : "memory");
12813 return c != 0;
12814 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12815 {
12816 unsigned char c;
12817
12818 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12819 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12820 +
12821 +#ifdef CONFIG_PAX_REFCOUNT
12822 + "jno 0f\n"
12823 + LOCK_PREFIX "subq %2,%0\n"
12824 + "int $4\n0:\n"
12825 + _ASM_EXTABLE(0b, 0b)
12826 +#endif
12827 +
12828 + "sets %1\n"
12829 : "=m" (v->counter), "=qm" (c)
12830 : "er" (i), "m" (v->counter) : "memory");
12831 return c;
12832 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12833 */
12834 static inline long atomic64_add_return(long i, atomic64_t *v)
12835 {
12836 + return i + xadd_check_overflow(&v->counter, i);
12837 +}
12838 +
12839 +/**
12840 + * atomic64_add_return_unchecked - add and return
12841 + * @i: integer value to add
12842 + * @v: pointer to type atomic64_unchecked_t
12843 + *
12844 + * Atomically adds @i to @v and returns @i + @v
12845 + */
12846 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12847 +{
12848 return i + xadd(&v->counter, i);
12849 }
12850
12851 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12852 }
12853
12854 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12855 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12856 +{
12857 + return atomic64_add_return_unchecked(1, v);
12858 +}
12859 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12860
12861 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12862 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12863 return cmpxchg(&v->counter, old, new);
12864 }
12865
12866 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12867 +{
12868 + return cmpxchg(&v->counter, old, new);
12869 +}
12870 +
12871 static inline long atomic64_xchg(atomic64_t *v, long new)
12872 {
12873 return xchg(&v->counter, new);
12874 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12875 */
12876 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12877 {
12878 - long c, old;
12879 + long c, old, new;
12880 c = atomic64_read(v);
12881 for (;;) {
12882 - if (unlikely(c == (u)))
12883 + if (unlikely(c == u))
12884 break;
12885 - old = atomic64_cmpxchg((v), c, c + (a));
12886 +
12887 + asm volatile("add %2,%0\n"
12888 +
12889 +#ifdef CONFIG_PAX_REFCOUNT
12890 + "jno 0f\n"
12891 + "sub %2,%0\n"
12892 + "int $4\n0:\n"
12893 + _ASM_EXTABLE(0b, 0b)
12894 +#endif
12895 +
12896 + : "=r" (new)
12897 + : "0" (c), "ir" (a));
12898 +
12899 + old = atomic64_cmpxchg(v, c, new);
12900 if (likely(old == c))
12901 break;
12902 c = old;
12903 }
12904 - return c != (u);
12905 + return c != u;
12906 }
12907
12908 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12909 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12910 index 6dfd019..28e188d 100644
12911 --- a/arch/x86/include/asm/bitops.h
12912 +++ b/arch/x86/include/asm/bitops.h
12913 @@ -40,7 +40,7 @@
12914 * a mask operation on a byte.
12915 */
12916 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12917 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12918 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12919 #define CONST_MASK(nr) (1 << ((nr) & 7))
12920
12921 /**
12922 @@ -486,7 +486,7 @@ static inline int fls(int x)
12923 * at position 64.
12924 */
12925 #ifdef CONFIG_X86_64
12926 -static __always_inline int fls64(__u64 x)
12927 +static __always_inline long fls64(__u64 x)
12928 {
12929 int bitpos = -1;
12930 /*
12931 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12932 index 4fa687a..60f2d39 100644
12933 --- a/arch/x86/include/asm/boot.h
12934 +++ b/arch/x86/include/asm/boot.h
12935 @@ -6,10 +6,15 @@
12936 #include <uapi/asm/boot.h>
12937
12938 /* Physical address where kernel should be loaded. */
12939 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12940 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12941 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12942 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12943
12944 +#ifndef __ASSEMBLY__
12945 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12946 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12947 +#endif
12948 +
12949 /* Minimum kernel alignment, as a power of two */
12950 #ifdef CONFIG_X86_64
12951 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12952 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12953 index 48f99f1..d78ebf9 100644
12954 --- a/arch/x86/include/asm/cache.h
12955 +++ b/arch/x86/include/asm/cache.h
12956 @@ -5,12 +5,13 @@
12957
12958 /* L1 cache line size */
12959 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12960 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12961 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12962
12963 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12964 +#define __read_only __attribute__((__section__(".data..read_only")))
12965
12966 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12967 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12968 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12969
12970 #ifdef CONFIG_X86_VSMP
12971 #ifdef CONFIG_SMP
12972 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12973 index 9863ee3..4a1f8e1 100644
12974 --- a/arch/x86/include/asm/cacheflush.h
12975 +++ b/arch/x86/include/asm/cacheflush.h
12976 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12977 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12978
12979 if (pg_flags == _PGMT_DEFAULT)
12980 - return -1;
12981 + return ~0UL;
12982 else if (pg_flags == _PGMT_WC)
12983 return _PAGE_CACHE_WC;
12984 else if (pg_flags == _PGMT_UC_MINUS)
12985 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12986 index 46fc474..b02b0f9 100644
12987 --- a/arch/x86/include/asm/checksum_32.h
12988 +++ b/arch/x86/include/asm/checksum_32.h
12989 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12990 int len, __wsum sum,
12991 int *src_err_ptr, int *dst_err_ptr);
12992
12993 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12994 + int len, __wsum sum,
12995 + int *src_err_ptr, int *dst_err_ptr);
12996 +
12997 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12998 + int len, __wsum sum,
12999 + int *src_err_ptr, int *dst_err_ptr);
13000 +
13001 /*
13002 * Note: when you get a NULL pointer exception here this means someone
13003 * passed in an incorrect kernel address to one of these functions.
13004 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13005 int *err_ptr)
13006 {
13007 might_sleep();
13008 - return csum_partial_copy_generic((__force void *)src, dst,
13009 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13010 len, sum, err_ptr, NULL);
13011 }
13012
13013 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13014 {
13015 might_sleep();
13016 if (access_ok(VERIFY_WRITE, dst, len))
13017 - return csum_partial_copy_generic(src, (__force void *)dst,
13018 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13019 len, sum, NULL, err_ptr);
13020
13021 if (len)
13022 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13023 index d47786a..ce1b05d 100644
13024 --- a/arch/x86/include/asm/cmpxchg.h
13025 +++ b/arch/x86/include/asm/cmpxchg.h
13026 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13027 __compiletime_error("Bad argument size for cmpxchg");
13028 extern void __xadd_wrong_size(void)
13029 __compiletime_error("Bad argument size for xadd");
13030 +extern void __xadd_check_overflow_wrong_size(void)
13031 + __compiletime_error("Bad argument size for xadd_check_overflow");
13032 extern void __add_wrong_size(void)
13033 __compiletime_error("Bad argument size for add");
13034 +extern void __add_check_overflow_wrong_size(void)
13035 + __compiletime_error("Bad argument size for add_check_overflow");
13036
13037 /*
13038 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13039 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13040 __ret; \
13041 })
13042
13043 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13044 + ({ \
13045 + __typeof__ (*(ptr)) __ret = (arg); \
13046 + switch (sizeof(*(ptr))) { \
13047 + case __X86_CASE_L: \
13048 + asm volatile (lock #op "l %0, %1\n" \
13049 + "jno 0f\n" \
13050 + "mov %0,%1\n" \
13051 + "int $4\n0:\n" \
13052 + _ASM_EXTABLE(0b, 0b) \
13053 + : "+r" (__ret), "+m" (*(ptr)) \
13054 + : : "memory", "cc"); \
13055 + break; \
13056 + case __X86_CASE_Q: \
13057 + asm volatile (lock #op "q %q0, %1\n" \
13058 + "jno 0f\n" \
13059 + "mov %0,%1\n" \
13060 + "int $4\n0:\n" \
13061 + _ASM_EXTABLE(0b, 0b) \
13062 + : "+r" (__ret), "+m" (*(ptr)) \
13063 + : : "memory", "cc"); \
13064 + break; \
13065 + default: \
13066 + __ ## op ## _check_overflow_wrong_size(); \
13067 + } \
13068 + __ret; \
13069 + })
13070 +
13071 /*
13072 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13073 * Since this is generally used to protect other memory information, we
13074 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13075 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13076 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13077
13078 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13079 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13080 +
13081 #define __add(ptr, inc, lock) \
13082 ({ \
13083 __typeof__ (*(ptr)) __ret = (inc); \
13084 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13085 index 59c6c40..5e0b22c 100644
13086 --- a/arch/x86/include/asm/compat.h
13087 +++ b/arch/x86/include/asm/compat.h
13088 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13089 typedef u32 compat_uint_t;
13090 typedef u32 compat_ulong_t;
13091 typedef u64 __attribute__((aligned(4))) compat_u64;
13092 -typedef u32 compat_uptr_t;
13093 +typedef u32 __user compat_uptr_t;
13094
13095 struct compat_timespec {
13096 compat_time_t tv_sec;
13097 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13098 index e99ac27..e89e28c 100644
13099 --- a/arch/x86/include/asm/cpufeature.h
13100 +++ b/arch/x86/include/asm/cpufeature.h
13101 @@ -211,7 +211,7 @@
13102 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13103 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13104 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13105 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13106 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13107 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13108 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13109 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13110 @@ -394,7 +394,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13111 ".section .discard,\"aw\",@progbits\n"
13112 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13113 ".previous\n"
13114 - ".section .altinstr_replacement,\"ax\"\n"
13115 + ".section .altinstr_replacement,\"a\"\n"
13116 "3: movb $1,%0\n"
13117 "4:\n"
13118 ".previous\n"
13119 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13120 index 8bf1c06..b6ae785 100644
13121 --- a/arch/x86/include/asm/desc.h
13122 +++ b/arch/x86/include/asm/desc.h
13123 @@ -4,6 +4,7 @@
13124 #include <asm/desc_defs.h>
13125 #include <asm/ldt.h>
13126 #include <asm/mmu.h>
13127 +#include <asm/pgtable.h>
13128
13129 #include <linux/smp.h>
13130 #include <linux/percpu.h>
13131 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13132
13133 desc->type = (info->read_exec_only ^ 1) << 1;
13134 desc->type |= info->contents << 2;
13135 + desc->type |= info->seg_not_present ^ 1;
13136
13137 desc->s = 1;
13138 desc->dpl = 0x3;
13139 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13140 }
13141
13142 extern struct desc_ptr idt_descr;
13143 -extern gate_desc idt_table[];
13144 extern struct desc_ptr nmi_idt_descr;
13145 -extern gate_desc nmi_idt_table[];
13146 -
13147 -struct gdt_page {
13148 - struct desc_struct gdt[GDT_ENTRIES];
13149 -} __attribute__((aligned(PAGE_SIZE)));
13150 -
13151 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13152 +extern gate_desc idt_table[256];
13153 +extern gate_desc nmi_idt_table[256];
13154
13155 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13156 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13157 {
13158 - return per_cpu(gdt_page, cpu).gdt;
13159 + return cpu_gdt_table[cpu];
13160 }
13161
13162 #ifdef CONFIG_X86_64
13163 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13164 unsigned long base, unsigned dpl, unsigned flags,
13165 unsigned short seg)
13166 {
13167 - gate->a = (seg << 16) | (base & 0xffff);
13168 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13169 + gate->gate.offset_low = base;
13170 + gate->gate.seg = seg;
13171 + gate->gate.reserved = 0;
13172 + gate->gate.type = type;
13173 + gate->gate.s = 0;
13174 + gate->gate.dpl = dpl;
13175 + gate->gate.p = 1;
13176 + gate->gate.offset_high = base >> 16;
13177 }
13178
13179 #endif
13180 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13181
13182 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13183 {
13184 + pax_open_kernel();
13185 memcpy(&idt[entry], gate, sizeof(*gate));
13186 + pax_close_kernel();
13187 }
13188
13189 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13190 {
13191 + pax_open_kernel();
13192 memcpy(&ldt[entry], desc, 8);
13193 + pax_close_kernel();
13194 }
13195
13196 static inline void
13197 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13198 default: size = sizeof(*gdt); break;
13199 }
13200
13201 + pax_open_kernel();
13202 memcpy(&gdt[entry], desc, size);
13203 + pax_close_kernel();
13204 }
13205
13206 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13207 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13208
13209 static inline void native_load_tr_desc(void)
13210 {
13211 + pax_open_kernel();
13212 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13213 + pax_close_kernel();
13214 }
13215
13216 static inline void native_load_gdt(const struct desc_ptr *dtr)
13217 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13218 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13219 unsigned int i;
13220
13221 + pax_open_kernel();
13222 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13223 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13224 + pax_close_kernel();
13225 }
13226
13227 #define _LDT_empty(info) \
13228 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13229 preempt_enable();
13230 }
13231
13232 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13233 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13234 {
13235 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13236 }
13237 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13238 }
13239
13240 #ifdef CONFIG_X86_64
13241 -static inline void set_nmi_gate(int gate, void *addr)
13242 +static inline void set_nmi_gate(int gate, const void *addr)
13243 {
13244 gate_desc s;
13245
13246 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13247 }
13248 #endif
13249
13250 -static inline void _set_gate(int gate, unsigned type, void *addr,
13251 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13252 unsigned dpl, unsigned ist, unsigned seg)
13253 {
13254 gate_desc s;
13255 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13256 * Pentium F0 0F bugfix can have resulted in the mapped
13257 * IDT being write-protected.
13258 */
13259 -static inline void set_intr_gate(unsigned int n, void *addr)
13260 +static inline void set_intr_gate(unsigned int n, const void *addr)
13261 {
13262 BUG_ON((unsigned)n > 0xFF);
13263 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13264 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13265 /*
13266 * This routine sets up an interrupt gate at directory privilege level 3.
13267 */
13268 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13269 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13270 {
13271 BUG_ON((unsigned)n > 0xFF);
13272 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13273 }
13274
13275 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13276 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13277 {
13278 BUG_ON((unsigned)n > 0xFF);
13279 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13280 }
13281
13282 -static inline void set_trap_gate(unsigned int n, void *addr)
13283 +static inline void set_trap_gate(unsigned int n, const void *addr)
13284 {
13285 BUG_ON((unsigned)n > 0xFF);
13286 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13287 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13288 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13289 {
13290 BUG_ON((unsigned)n > 0xFF);
13291 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13292 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13293 }
13294
13295 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13296 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13297 {
13298 BUG_ON((unsigned)n > 0xFF);
13299 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13300 }
13301
13302 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13303 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13304 {
13305 BUG_ON((unsigned)n > 0xFF);
13306 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13307 }
13308
13309 +#ifdef CONFIG_X86_32
13310 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13311 +{
13312 + struct desc_struct d;
13313 +
13314 + if (likely(limit))
13315 + limit = (limit - 1UL) >> PAGE_SHIFT;
13316 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13317 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13318 +}
13319 +#endif
13320 +
13321 #endif /* _ASM_X86_DESC_H */
13322 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13323 index 278441f..b95a174 100644
13324 --- a/arch/x86/include/asm/desc_defs.h
13325 +++ b/arch/x86/include/asm/desc_defs.h
13326 @@ -31,6 +31,12 @@ struct desc_struct {
13327 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13328 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13329 };
13330 + struct {
13331 + u16 offset_low;
13332 + u16 seg;
13333 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13334 + unsigned offset_high: 16;
13335 + } gate;
13336 };
13337 } __attribute__((packed));
13338
13339 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13340 index ced283a..ffe04cc 100644
13341 --- a/arch/x86/include/asm/div64.h
13342 +++ b/arch/x86/include/asm/div64.h
13343 @@ -39,7 +39,7 @@
13344 __mod; \
13345 })
13346
13347 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13348 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13349 {
13350 union {
13351 u64 v64;
13352 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13353 index 9c999c1..3860cb8 100644
13354 --- a/arch/x86/include/asm/elf.h
13355 +++ b/arch/x86/include/asm/elf.h
13356 @@ -243,7 +243,25 @@ extern int force_personality32;
13357 the loader. We need to make sure that it is out of the way of the program
13358 that it will "exec", and that there is sufficient room for the brk. */
13359
13360 +#ifdef CONFIG_PAX_SEGMEXEC
13361 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13362 +#else
13363 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13364 +#endif
13365 +
13366 +#ifdef CONFIG_PAX_ASLR
13367 +#ifdef CONFIG_X86_32
13368 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13369 +
13370 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13371 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13372 +#else
13373 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13374 +
13375 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13376 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13377 +#endif
13378 +#endif
13379
13380 /* This yields a mask that user programs can use to figure out what
13381 instruction set this CPU supports. This could be done in user space,
13382 @@ -296,16 +314,12 @@ do { \
13383
13384 #define ARCH_DLINFO \
13385 do { \
13386 - if (vdso_enabled) \
13387 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13388 - (unsigned long)current->mm->context.vdso); \
13389 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13390 } while (0)
13391
13392 #define ARCH_DLINFO_X32 \
13393 do { \
13394 - if (vdso_enabled) \
13395 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13396 - (unsigned long)current->mm->context.vdso); \
13397 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13398 } while (0)
13399
13400 #define AT_SYSINFO 32
13401 @@ -320,7 +334,7 @@ else \
13402
13403 #endif /* !CONFIG_X86_32 */
13404
13405 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13406 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13407
13408 #define VDSO_ENTRY \
13409 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13410 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13411 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13412 #define compat_arch_setup_additional_pages syscall32_setup_pages
13413
13414 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13415 -#define arch_randomize_brk arch_randomize_brk
13416 -
13417 /*
13418 * True on X86_32 or when emulating IA32 on X86_64
13419 */
13420 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13421 index 75ce3f4..882e801 100644
13422 --- a/arch/x86/include/asm/emergency-restart.h
13423 +++ b/arch/x86/include/asm/emergency-restart.h
13424 @@ -13,6 +13,6 @@ enum reboot_type {
13425
13426 extern enum reboot_type reboot_type;
13427
13428 -extern void machine_emergency_restart(void);
13429 +extern void machine_emergency_restart(void) __noreturn;
13430
13431 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13432 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13433 index e25cc33..425d099 100644
13434 --- a/arch/x86/include/asm/fpu-internal.h
13435 +++ b/arch/x86/include/asm/fpu-internal.h
13436 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13437 ({ \
13438 int err; \
13439 asm volatile(ASM_STAC "\n" \
13440 - "1:" #insn "\n\t" \
13441 + "1:" \
13442 + __copyuser_seg \
13443 + #insn "\n\t" \
13444 "2: " ASM_CLAC "\n" \
13445 ".section .fixup,\"ax\"\n" \
13446 "3: movl $-1,%[err]\n" \
13447 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13448 "emms\n\t" /* clear stack tags */
13449 "fildl %P[addr]", /* set F?P to defined value */
13450 X86_FEATURE_FXSAVE_LEAK,
13451 - [addr] "m" (tsk->thread.fpu.has_fpu));
13452 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13453
13454 return fpu_restore_checking(&tsk->thread.fpu);
13455 }
13456 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13457 index be27ba1..8f13ff9 100644
13458 --- a/arch/x86/include/asm/futex.h
13459 +++ b/arch/x86/include/asm/futex.h
13460 @@ -12,6 +12,7 @@
13461 #include <asm/smap.h>
13462
13463 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13464 + typecheck(u32 __user *, uaddr); \
13465 asm volatile("\t" ASM_STAC "\n" \
13466 "1:\t" insn "\n" \
13467 "2:\t" ASM_CLAC "\n" \
13468 @@ -20,15 +21,16 @@
13469 "\tjmp\t2b\n" \
13470 "\t.previous\n" \
13471 _ASM_EXTABLE(1b, 3b) \
13472 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13473 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13474 : "i" (-EFAULT), "0" (oparg), "1" (0))
13475
13476 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13477 + typecheck(u32 __user *, uaddr); \
13478 asm volatile("\t" ASM_STAC "\n" \
13479 "1:\tmovl %2, %0\n" \
13480 "\tmovl\t%0, %3\n" \
13481 "\t" insn "\n" \
13482 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13483 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13484 "\tjnz\t1b\n" \
13485 "3:\t" ASM_CLAC "\n" \
13486 "\t.section .fixup,\"ax\"\n" \
13487 @@ -38,7 +40,7 @@
13488 _ASM_EXTABLE(1b, 4b) \
13489 _ASM_EXTABLE(2b, 4b) \
13490 : "=&a" (oldval), "=&r" (ret), \
13491 - "+m" (*uaddr), "=&r" (tem) \
13492 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13493 : "r" (oparg), "i" (-EFAULT), "1" (0))
13494
13495 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13496 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13497
13498 switch (op) {
13499 case FUTEX_OP_SET:
13500 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13501 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13502 break;
13503 case FUTEX_OP_ADD:
13504 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13505 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13506 uaddr, oparg);
13507 break;
13508 case FUTEX_OP_OR:
13509 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13510 return -EFAULT;
13511
13512 asm volatile("\t" ASM_STAC "\n"
13513 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13514 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13515 "2:\t" ASM_CLAC "\n"
13516 "\t.section .fixup, \"ax\"\n"
13517 "3:\tmov %3, %0\n"
13518 "\tjmp 2b\n"
13519 "\t.previous\n"
13520 _ASM_EXTABLE(1b, 3b)
13521 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13522 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13523 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13524 : "memory"
13525 );
13526 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13527 index 1da97ef..9c2ebff 100644
13528 --- a/arch/x86/include/asm/hw_irq.h
13529 +++ b/arch/x86/include/asm/hw_irq.h
13530 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
13531 extern void enable_IO_APIC(void);
13532
13533 /* Statistics */
13534 -extern atomic_t irq_err_count;
13535 -extern atomic_t irq_mis_count;
13536 +extern atomic_unchecked_t irq_err_count;
13537 +extern atomic_unchecked_t irq_mis_count;
13538
13539 /* EISA */
13540 extern void eisa_set_level_irq(unsigned int irq);
13541 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13542 index a203659..9889f1c 100644
13543 --- a/arch/x86/include/asm/i8259.h
13544 +++ b/arch/x86/include/asm/i8259.h
13545 @@ -62,7 +62,7 @@ struct legacy_pic {
13546 void (*init)(int auto_eoi);
13547 int (*irq_pending)(unsigned int irq);
13548 void (*make_irq)(unsigned int irq);
13549 -};
13550 +} __do_const;
13551
13552 extern struct legacy_pic *legacy_pic;
13553 extern struct legacy_pic null_legacy_pic;
13554 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13555 index d8e8eef..1765f78 100644
13556 --- a/arch/x86/include/asm/io.h
13557 +++ b/arch/x86/include/asm/io.h
13558 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13559 "m" (*(volatile type __force *)addr) barrier); }
13560
13561 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13562 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13563 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13564 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13565 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13566
13567 build_mmio_read(__readb, "b", unsigned char, "=q", )
13568 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13569 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13570 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13571 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13572
13573 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13574 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13575 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13576 return ioremap_nocache(offset, size);
13577 }
13578
13579 -extern void iounmap(volatile void __iomem *addr);
13580 +extern void iounmap(const volatile void __iomem *addr);
13581
13582 extern void set_iounmap_nonlazy(void);
13583
13584 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13585
13586 #include <linux/vmalloc.h>
13587
13588 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13589 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13590 +{
13591 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13592 +}
13593 +
13594 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13595 +{
13596 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13597 +}
13598 +
13599 /*
13600 * Convert a virtual cached pointer to an uncached pointer
13601 */
13602 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13603 index bba3cf8..06bc8da 100644
13604 --- a/arch/x86/include/asm/irqflags.h
13605 +++ b/arch/x86/include/asm/irqflags.h
13606 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13607 sti; \
13608 sysexit
13609
13610 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13611 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13612 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13613 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13614 +
13615 #else
13616 #define INTERRUPT_RETURN iret
13617 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13618 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13619 index 5a6d287..f815789 100644
13620 --- a/arch/x86/include/asm/kprobes.h
13621 +++ b/arch/x86/include/asm/kprobes.h
13622 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13623 #define RELATIVEJUMP_SIZE 5
13624 #define RELATIVECALL_OPCODE 0xe8
13625 #define RELATIVE_ADDR_SIZE 4
13626 -#define MAX_STACK_SIZE 64
13627 -#define MIN_STACK_SIZE(ADDR) \
13628 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13629 - THREAD_SIZE - (unsigned long)(ADDR))) \
13630 - ? (MAX_STACK_SIZE) \
13631 - : (((unsigned long)current_thread_info()) + \
13632 - THREAD_SIZE - (unsigned long)(ADDR)))
13633 +#define MAX_STACK_SIZE 64UL
13634 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13635
13636 #define flush_insn_slot(p) do { } while (0)
13637
13638 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13639 index 2d89e39..baee879 100644
13640 --- a/arch/x86/include/asm/local.h
13641 +++ b/arch/x86/include/asm/local.h
13642 @@ -10,33 +10,97 @@ typedef struct {
13643 atomic_long_t a;
13644 } local_t;
13645
13646 +typedef struct {
13647 + atomic_long_unchecked_t a;
13648 +} local_unchecked_t;
13649 +
13650 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13651
13652 #define local_read(l) atomic_long_read(&(l)->a)
13653 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13654 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13655 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13656
13657 static inline void local_inc(local_t *l)
13658 {
13659 - asm volatile(_ASM_INC "%0"
13660 + asm volatile(_ASM_INC "%0\n"
13661 +
13662 +#ifdef CONFIG_PAX_REFCOUNT
13663 + "jno 0f\n"
13664 + _ASM_DEC "%0\n"
13665 + "int $4\n0:\n"
13666 + _ASM_EXTABLE(0b, 0b)
13667 +#endif
13668 +
13669 + : "+m" (l->a.counter));
13670 +}
13671 +
13672 +static inline void local_inc_unchecked(local_unchecked_t *l)
13673 +{
13674 + asm volatile(_ASM_INC "%0\n"
13675 : "+m" (l->a.counter));
13676 }
13677
13678 static inline void local_dec(local_t *l)
13679 {
13680 - asm volatile(_ASM_DEC "%0"
13681 + asm volatile(_ASM_DEC "%0\n"
13682 +
13683 +#ifdef CONFIG_PAX_REFCOUNT
13684 + "jno 0f\n"
13685 + _ASM_INC "%0\n"
13686 + "int $4\n0:\n"
13687 + _ASM_EXTABLE(0b, 0b)
13688 +#endif
13689 +
13690 + : "+m" (l->a.counter));
13691 +}
13692 +
13693 +static inline void local_dec_unchecked(local_unchecked_t *l)
13694 +{
13695 + asm volatile(_ASM_DEC "%0\n"
13696 : "+m" (l->a.counter));
13697 }
13698
13699 static inline void local_add(long i, local_t *l)
13700 {
13701 - asm volatile(_ASM_ADD "%1,%0"
13702 + asm volatile(_ASM_ADD "%1,%0\n"
13703 +
13704 +#ifdef CONFIG_PAX_REFCOUNT
13705 + "jno 0f\n"
13706 + _ASM_SUB "%1,%0\n"
13707 + "int $4\n0:\n"
13708 + _ASM_EXTABLE(0b, 0b)
13709 +#endif
13710 +
13711 + : "+m" (l->a.counter)
13712 + : "ir" (i));
13713 +}
13714 +
13715 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13716 +{
13717 + asm volatile(_ASM_ADD "%1,%0\n"
13718 : "+m" (l->a.counter)
13719 : "ir" (i));
13720 }
13721
13722 static inline void local_sub(long i, local_t *l)
13723 {
13724 - asm volatile(_ASM_SUB "%1,%0"
13725 + asm volatile(_ASM_SUB "%1,%0\n"
13726 +
13727 +#ifdef CONFIG_PAX_REFCOUNT
13728 + "jno 0f\n"
13729 + _ASM_ADD "%1,%0\n"
13730 + "int $4\n0:\n"
13731 + _ASM_EXTABLE(0b, 0b)
13732 +#endif
13733 +
13734 + : "+m" (l->a.counter)
13735 + : "ir" (i));
13736 +}
13737 +
13738 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13739 +{
13740 + asm volatile(_ASM_SUB "%1,%0\n"
13741 : "+m" (l->a.counter)
13742 : "ir" (i));
13743 }
13744 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13745 {
13746 unsigned char c;
13747
13748 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13749 + asm volatile(_ASM_SUB "%2,%0\n"
13750 +
13751 +#ifdef CONFIG_PAX_REFCOUNT
13752 + "jno 0f\n"
13753 + _ASM_ADD "%2,%0\n"
13754 + "int $4\n0:\n"
13755 + _ASM_EXTABLE(0b, 0b)
13756 +#endif
13757 +
13758 + "sete %1\n"
13759 : "+m" (l->a.counter), "=qm" (c)
13760 : "ir" (i) : "memory");
13761 return c;
13762 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13763 {
13764 unsigned char c;
13765
13766 - asm volatile(_ASM_DEC "%0; sete %1"
13767 + asm volatile(_ASM_DEC "%0\n"
13768 +
13769 +#ifdef CONFIG_PAX_REFCOUNT
13770 + "jno 0f\n"
13771 + _ASM_INC "%0\n"
13772 + "int $4\n0:\n"
13773 + _ASM_EXTABLE(0b, 0b)
13774 +#endif
13775 +
13776 + "sete %1\n"
13777 : "+m" (l->a.counter), "=qm" (c)
13778 : : "memory");
13779 return c != 0;
13780 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13781 {
13782 unsigned char c;
13783
13784 - asm volatile(_ASM_INC "%0; sete %1"
13785 + asm volatile(_ASM_INC "%0\n"
13786 +
13787 +#ifdef CONFIG_PAX_REFCOUNT
13788 + "jno 0f\n"
13789 + _ASM_DEC "%0\n"
13790 + "int $4\n0:\n"
13791 + _ASM_EXTABLE(0b, 0b)
13792 +#endif
13793 +
13794 + "sete %1\n"
13795 : "+m" (l->a.counter), "=qm" (c)
13796 : : "memory");
13797 return c != 0;
13798 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13799 {
13800 unsigned char c;
13801
13802 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13803 + asm volatile(_ASM_ADD "%2,%0\n"
13804 +
13805 +#ifdef CONFIG_PAX_REFCOUNT
13806 + "jno 0f\n"
13807 + _ASM_SUB "%2,%0\n"
13808 + "int $4\n0:\n"
13809 + _ASM_EXTABLE(0b, 0b)
13810 +#endif
13811 +
13812 + "sets %1\n"
13813 : "+m" (l->a.counter), "=qm" (c)
13814 : "ir" (i) : "memory");
13815 return c;
13816 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13817 static inline long local_add_return(long i, local_t *l)
13818 {
13819 long __i = i;
13820 + asm volatile(_ASM_XADD "%0, %1\n"
13821 +
13822 +#ifdef CONFIG_PAX_REFCOUNT
13823 + "jno 0f\n"
13824 + _ASM_MOV "%0,%1\n"
13825 + "int $4\n0:\n"
13826 + _ASM_EXTABLE(0b, 0b)
13827 +#endif
13828 +
13829 + : "+r" (i), "+m" (l->a.counter)
13830 + : : "memory");
13831 + return i + __i;
13832 +}
13833 +
13834 +/**
13835 + * local_add_return_unchecked - add and return
13836 + * @i: integer value to add
13837 + * @l: pointer to type local_unchecked_t
13838 + *
13839 + * Atomically adds @i to @l and returns @i + @l
13840 + */
13841 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13842 +{
13843 + long __i = i;
13844 asm volatile(_ASM_XADD "%0, %1;"
13845 : "+r" (i), "+m" (l->a.counter)
13846 : : "memory");
13847 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13848
13849 #define local_cmpxchg(l, o, n) \
13850 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13851 +#define local_cmpxchg_unchecked(l, o, n) \
13852 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13853 /* Always has a lock prefix */
13854 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13855
13856 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13857 new file mode 100644
13858 index 0000000..2bfd3ba
13859 --- /dev/null
13860 +++ b/arch/x86/include/asm/mman.h
13861 @@ -0,0 +1,15 @@
13862 +#ifndef _X86_MMAN_H
13863 +#define _X86_MMAN_H
13864 +
13865 +#include <uapi/asm/mman.h>
13866 +
13867 +#ifdef __KERNEL__
13868 +#ifndef __ASSEMBLY__
13869 +#ifdef CONFIG_X86_32
13870 +#define arch_mmap_check i386_mmap_check
13871 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13872 +#endif
13873 +#endif
13874 +#endif
13875 +
13876 +#endif /* X86_MMAN_H */
13877 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13878 index 5f55e69..e20bfb1 100644
13879 --- a/arch/x86/include/asm/mmu.h
13880 +++ b/arch/x86/include/asm/mmu.h
13881 @@ -9,7 +9,7 @@
13882 * we put the segment information here.
13883 */
13884 typedef struct {
13885 - void *ldt;
13886 + struct desc_struct *ldt;
13887 int size;
13888
13889 #ifdef CONFIG_X86_64
13890 @@ -18,7 +18,19 @@ typedef struct {
13891 #endif
13892
13893 struct mutex lock;
13894 - void *vdso;
13895 + unsigned long vdso;
13896 +
13897 +#ifdef CONFIG_X86_32
13898 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13899 + unsigned long user_cs_base;
13900 + unsigned long user_cs_limit;
13901 +
13902 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13903 + cpumask_t cpu_user_cs_mask;
13904 +#endif
13905 +
13906 +#endif
13907 +#endif
13908 } mm_context_t;
13909
13910 #ifdef CONFIG_SMP
13911 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13912 index cdbf367..adb37ac 100644
13913 --- a/arch/x86/include/asm/mmu_context.h
13914 +++ b/arch/x86/include/asm/mmu_context.h
13915 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13916
13917 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13918 {
13919 +
13920 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13921 + unsigned int i;
13922 + pgd_t *pgd;
13923 +
13924 + pax_open_kernel();
13925 + pgd = get_cpu_pgd(smp_processor_id());
13926 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13927 + set_pgd_batched(pgd+i, native_make_pgd(0));
13928 + pax_close_kernel();
13929 +#endif
13930 +
13931 #ifdef CONFIG_SMP
13932 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13933 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13934 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13935 struct task_struct *tsk)
13936 {
13937 unsigned cpu = smp_processor_id();
13938 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13939 + int tlbstate = TLBSTATE_OK;
13940 +#endif
13941
13942 if (likely(prev != next)) {
13943 #ifdef CONFIG_SMP
13944 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13945 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13946 +#endif
13947 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13948 this_cpu_write(cpu_tlbstate.active_mm, next);
13949 #endif
13950 cpumask_set_cpu(cpu, mm_cpumask(next));
13951
13952 /* Re-load page tables */
13953 +#ifdef CONFIG_PAX_PER_CPU_PGD
13954 + pax_open_kernel();
13955 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13956 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13957 + pax_close_kernel();
13958 + load_cr3(get_cpu_pgd(cpu));
13959 +#else
13960 load_cr3(next->pgd);
13961 +#endif
13962
13963 /* stop flush ipis for the previous mm */
13964 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13965 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13966 */
13967 if (unlikely(prev->context.ldt != next->context.ldt))
13968 load_LDT_nolock(&next->context);
13969 - }
13970 +
13971 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13972 + if (!(__supported_pte_mask & _PAGE_NX)) {
13973 + smp_mb__before_clear_bit();
13974 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13975 + smp_mb__after_clear_bit();
13976 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13977 + }
13978 +#endif
13979 +
13980 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13981 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13982 + prev->context.user_cs_limit != next->context.user_cs_limit))
13983 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13984 #ifdef CONFIG_SMP
13985 + else if (unlikely(tlbstate != TLBSTATE_OK))
13986 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13987 +#endif
13988 +#endif
13989 +
13990 + }
13991 else {
13992 +
13993 +#ifdef CONFIG_PAX_PER_CPU_PGD
13994 + pax_open_kernel();
13995 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13996 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13997 + pax_close_kernel();
13998 + load_cr3(get_cpu_pgd(cpu));
13999 +#endif
14000 +
14001 +#ifdef CONFIG_SMP
14002 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14003 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14004
14005 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14006 * tlb flush IPI delivery. We must reload CR3
14007 * to make sure to use no freed page tables.
14008 */
14009 +
14010 +#ifndef CONFIG_PAX_PER_CPU_PGD
14011 load_cr3(next->pgd);
14012 +#endif
14013 +
14014 load_LDT_nolock(&next->context);
14015 +
14016 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14017 + if (!(__supported_pte_mask & _PAGE_NX))
14018 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14019 +#endif
14020 +
14021 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14022 +#ifdef CONFIG_PAX_PAGEEXEC
14023 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14024 +#endif
14025 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14026 +#endif
14027 +
14028 }
14029 +#endif
14030 }
14031 -#endif
14032 }
14033
14034 #define activate_mm(prev, next) \
14035 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14036 index e3b7819..b257c64 100644
14037 --- a/arch/x86/include/asm/module.h
14038 +++ b/arch/x86/include/asm/module.h
14039 @@ -5,6 +5,7 @@
14040
14041 #ifdef CONFIG_X86_64
14042 /* X86_64 does not define MODULE_PROC_FAMILY */
14043 +#define MODULE_PROC_FAMILY ""
14044 #elif defined CONFIG_M486
14045 #define MODULE_PROC_FAMILY "486 "
14046 #elif defined CONFIG_M586
14047 @@ -57,8 +58,20 @@
14048 #error unknown processor family
14049 #endif
14050
14051 -#ifdef CONFIG_X86_32
14052 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14053 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14054 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14055 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14056 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14057 +#else
14058 +#define MODULE_PAX_KERNEXEC ""
14059 #endif
14060
14061 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14062 +#define MODULE_PAX_UDEREF "UDEREF "
14063 +#else
14064 +#define MODULE_PAX_UDEREF ""
14065 +#endif
14066 +
14067 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14068 +
14069 #endif /* _ASM_X86_MODULE_H */
14070 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14071 index 86f9301..b365cda 100644
14072 --- a/arch/x86/include/asm/nmi.h
14073 +++ b/arch/x86/include/asm/nmi.h
14074 @@ -40,11 +40,11 @@ struct nmiaction {
14075 nmi_handler_t handler;
14076 unsigned long flags;
14077 const char *name;
14078 -};
14079 +} __do_const;
14080
14081 #define register_nmi_handler(t, fn, fg, n, init...) \
14082 ({ \
14083 - static struct nmiaction init fn##_na = { \
14084 + static const struct nmiaction init fn##_na = { \
14085 .handler = (fn), \
14086 .name = (n), \
14087 .flags = (fg), \
14088 @@ -52,7 +52,7 @@ struct nmiaction {
14089 __register_nmi_handler((t), &fn##_na); \
14090 })
14091
14092 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14093 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14094
14095 void unregister_nmi_handler(unsigned int, const char *);
14096
14097 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
14098 index c878924..21f4889 100644
14099 --- a/arch/x86/include/asm/page.h
14100 +++ b/arch/x86/include/asm/page.h
14101 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
14102 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
14103
14104 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
14105 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
14106
14107 #define __boot_va(x) __va(x)
14108 #define __boot_pa(x) __pa(x)
14109 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14110 index 0f1ddee..e2fc3d1 100644
14111 --- a/arch/x86/include/asm/page_64.h
14112 +++ b/arch/x86/include/asm/page_64.h
14113 @@ -7,9 +7,9 @@
14114
14115 /* duplicated to the one in bootmem.h */
14116 extern unsigned long max_pfn;
14117 -extern unsigned long phys_base;
14118 +extern const unsigned long phys_base;
14119
14120 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14121 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14122 {
14123 unsigned long y = x - __START_KERNEL_map;
14124
14125 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14126 index cfdc9ee..3f7b5d6 100644
14127 --- a/arch/x86/include/asm/paravirt.h
14128 +++ b/arch/x86/include/asm/paravirt.h
14129 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
14130 return (pmd_t) { ret };
14131 }
14132
14133 -static inline pmdval_t pmd_val(pmd_t pmd)
14134 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14135 {
14136 pmdval_t ret;
14137
14138 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14139 val);
14140 }
14141
14142 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14143 +{
14144 + pgdval_t val = native_pgd_val(pgd);
14145 +
14146 + if (sizeof(pgdval_t) > sizeof(long))
14147 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14148 + val, (u64)val >> 32);
14149 + else
14150 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14151 + val);
14152 +}
14153 +
14154 static inline void pgd_clear(pgd_t *pgdp)
14155 {
14156 set_pgd(pgdp, __pgd(0));
14157 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14158 pv_mmu_ops.set_fixmap(idx, phys, flags);
14159 }
14160
14161 +#ifdef CONFIG_PAX_KERNEXEC
14162 +static inline unsigned long pax_open_kernel(void)
14163 +{
14164 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14165 +}
14166 +
14167 +static inline unsigned long pax_close_kernel(void)
14168 +{
14169 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14170 +}
14171 +#else
14172 +static inline unsigned long pax_open_kernel(void) { return 0; }
14173 +static inline unsigned long pax_close_kernel(void) { return 0; }
14174 +#endif
14175 +
14176 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14177
14178 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14179 @@ -926,7 +953,7 @@ extern void default_banner(void);
14180
14181 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14182 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14183 -#define PARA_INDIRECT(addr) *%cs:addr
14184 +#define PARA_INDIRECT(addr) *%ss:addr
14185 #endif
14186
14187 #define INTERRUPT_RETURN \
14188 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
14189 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14190 CLBR_NONE, \
14191 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14192 +
14193 +#define GET_CR0_INTO_RDI \
14194 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14195 + mov %rax,%rdi
14196 +
14197 +#define SET_RDI_INTO_CR0 \
14198 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14199 +
14200 +#define GET_CR3_INTO_RDI \
14201 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14202 + mov %rax,%rdi
14203 +
14204 +#define SET_RDI_INTO_CR3 \
14205 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14206 +
14207 #endif /* CONFIG_X86_32 */
14208
14209 #endif /* __ASSEMBLY__ */
14210 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14211 index 0db1fca..52310cc 100644
14212 --- a/arch/x86/include/asm/paravirt_types.h
14213 +++ b/arch/x86/include/asm/paravirt_types.h
14214 @@ -84,7 +84,7 @@ struct pv_init_ops {
14215 */
14216 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14217 unsigned long addr, unsigned len);
14218 -};
14219 +} __no_const;
14220
14221
14222 struct pv_lazy_ops {
14223 @@ -98,7 +98,7 @@ struct pv_time_ops {
14224 unsigned long long (*sched_clock)(void);
14225 unsigned long long (*steal_clock)(int cpu);
14226 unsigned long (*get_tsc_khz)(void);
14227 -};
14228 +} __no_const;
14229
14230 struct pv_cpu_ops {
14231 /* hooks for various privileged instructions */
14232 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14233
14234 void (*start_context_switch)(struct task_struct *prev);
14235 void (*end_context_switch)(struct task_struct *next);
14236 -};
14237 +} __no_const;
14238
14239 struct pv_irq_ops {
14240 /*
14241 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14242 unsigned long start_eip,
14243 unsigned long start_esp);
14244 #endif
14245 -};
14246 +} __no_const;
14247
14248 struct pv_mmu_ops {
14249 unsigned long (*read_cr2)(void);
14250 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14251 struct paravirt_callee_save make_pud;
14252
14253 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14254 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14255 #endif /* PAGETABLE_LEVELS == 4 */
14256 #endif /* PAGETABLE_LEVELS >= 3 */
14257
14258 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14259 an mfn. We can tell which is which from the index. */
14260 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14261 phys_addr_t phys, pgprot_t flags);
14262 +
14263 +#ifdef CONFIG_PAX_KERNEXEC
14264 + unsigned long (*pax_open_kernel)(void);
14265 + unsigned long (*pax_close_kernel)(void);
14266 +#endif
14267 +
14268 };
14269
14270 struct arch_spinlock;
14271 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14272 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14273 int (*spin_trylock)(struct arch_spinlock *lock);
14274 void (*spin_unlock)(struct arch_spinlock *lock);
14275 -};
14276 +} __no_const;
14277
14278 /* This contains all the paravirt structures: we get a convenient
14279 * number for each function using the offset which we use to indicate
14280 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14281 index b4389a4..7024269 100644
14282 --- a/arch/x86/include/asm/pgalloc.h
14283 +++ b/arch/x86/include/asm/pgalloc.h
14284 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14285 pmd_t *pmd, pte_t *pte)
14286 {
14287 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14288 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14289 +}
14290 +
14291 +static inline void pmd_populate_user(struct mm_struct *mm,
14292 + pmd_t *pmd, pte_t *pte)
14293 +{
14294 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14295 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14296 }
14297
14298 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14299
14300 #ifdef CONFIG_X86_PAE
14301 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14302 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14303 +{
14304 + pud_populate(mm, pudp, pmd);
14305 +}
14306 #else /* !CONFIG_X86_PAE */
14307 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14308 {
14309 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14310 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14311 }
14312 +
14313 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14314 +{
14315 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14316 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14317 +}
14318 #endif /* CONFIG_X86_PAE */
14319
14320 #if PAGETABLE_LEVELS > 3
14321 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14322 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14323 }
14324
14325 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14326 +{
14327 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14328 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14329 +}
14330 +
14331 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14332 {
14333 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14334 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14335 index f2b489c..4f7e2e5 100644
14336 --- a/arch/x86/include/asm/pgtable-2level.h
14337 +++ b/arch/x86/include/asm/pgtable-2level.h
14338 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14339
14340 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14341 {
14342 + pax_open_kernel();
14343 *pmdp = pmd;
14344 + pax_close_kernel();
14345 }
14346
14347 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14348 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14349 index 4cc9f2b..5fd9226 100644
14350 --- a/arch/x86/include/asm/pgtable-3level.h
14351 +++ b/arch/x86/include/asm/pgtable-3level.h
14352 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14353
14354 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14355 {
14356 + pax_open_kernel();
14357 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14358 + pax_close_kernel();
14359 }
14360
14361 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14362 {
14363 + pax_open_kernel();
14364 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14365 + pax_close_kernel();
14366 }
14367
14368 /*
14369 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14370 index 1e67223..dd6e7ea 100644
14371 --- a/arch/x86/include/asm/pgtable.h
14372 +++ b/arch/x86/include/asm/pgtable.h
14373 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14374
14375 #ifndef __PAGETABLE_PUD_FOLDED
14376 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14377 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14378 #define pgd_clear(pgd) native_pgd_clear(pgd)
14379 #endif
14380
14381 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14382
14383 #define arch_end_context_switch(prev) do {} while(0)
14384
14385 +#define pax_open_kernel() native_pax_open_kernel()
14386 +#define pax_close_kernel() native_pax_close_kernel()
14387 #endif /* CONFIG_PARAVIRT */
14388
14389 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14390 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14391 +
14392 +#ifdef CONFIG_PAX_KERNEXEC
14393 +static inline unsigned long native_pax_open_kernel(void)
14394 +{
14395 + unsigned long cr0;
14396 +
14397 + preempt_disable();
14398 + barrier();
14399 + cr0 = read_cr0() ^ X86_CR0_WP;
14400 + BUG_ON(cr0 & X86_CR0_WP);
14401 + write_cr0(cr0);
14402 + return cr0 ^ X86_CR0_WP;
14403 +}
14404 +
14405 +static inline unsigned long native_pax_close_kernel(void)
14406 +{
14407 + unsigned long cr0;
14408 +
14409 + cr0 = read_cr0() ^ X86_CR0_WP;
14410 + BUG_ON(!(cr0 & X86_CR0_WP));
14411 + write_cr0(cr0);
14412 + barrier();
14413 + preempt_enable_no_resched();
14414 + return cr0 ^ X86_CR0_WP;
14415 +}
14416 +#else
14417 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14418 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14419 +#endif
14420 +
14421 /*
14422 * The following only work if pte_present() is true.
14423 * Undefined behaviour if not..
14424 */
14425 +static inline int pte_user(pte_t pte)
14426 +{
14427 + return pte_val(pte) & _PAGE_USER;
14428 +}
14429 +
14430 static inline int pte_dirty(pte_t pte)
14431 {
14432 return pte_flags(pte) & _PAGE_DIRTY;
14433 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14434 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14435 }
14436
14437 +static inline unsigned long pgd_pfn(pgd_t pgd)
14438 +{
14439 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14440 +}
14441 +
14442 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14443
14444 static inline int pmd_large(pmd_t pte)
14445 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14446 return pte_clear_flags(pte, _PAGE_RW);
14447 }
14448
14449 +static inline pte_t pte_mkread(pte_t pte)
14450 +{
14451 + return __pte(pte_val(pte) | _PAGE_USER);
14452 +}
14453 +
14454 static inline pte_t pte_mkexec(pte_t pte)
14455 {
14456 - return pte_clear_flags(pte, _PAGE_NX);
14457 +#ifdef CONFIG_X86_PAE
14458 + if (__supported_pte_mask & _PAGE_NX)
14459 + return pte_clear_flags(pte, _PAGE_NX);
14460 + else
14461 +#endif
14462 + return pte_set_flags(pte, _PAGE_USER);
14463 +}
14464 +
14465 +static inline pte_t pte_exprotect(pte_t pte)
14466 +{
14467 +#ifdef CONFIG_X86_PAE
14468 + if (__supported_pte_mask & _PAGE_NX)
14469 + return pte_set_flags(pte, _PAGE_NX);
14470 + else
14471 +#endif
14472 + return pte_clear_flags(pte, _PAGE_USER);
14473 }
14474
14475 static inline pte_t pte_mkdirty(pte_t pte)
14476 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14477 #endif
14478
14479 #ifndef __ASSEMBLY__
14480 +
14481 +#ifdef CONFIG_PAX_PER_CPU_PGD
14482 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14483 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14484 +{
14485 + return cpu_pgd[cpu];
14486 +}
14487 +#endif
14488 +
14489 #include <linux/mm_types.h>
14490 #include <linux/log2.h>
14491
14492 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14493 * Currently stuck as a macro due to indirect forward reference to
14494 * linux/mmzone.h's __section_mem_map_addr() definition:
14495 */
14496 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14497 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14498
14499 /* Find an entry in the second-level page table.. */
14500 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14501 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14502 * Currently stuck as a macro due to indirect forward reference to
14503 * linux/mmzone.h's __section_mem_map_addr() definition:
14504 */
14505 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14506 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14507
14508 /* to find an entry in a page-table-directory. */
14509 static inline unsigned long pud_index(unsigned long address)
14510 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14511
14512 static inline int pgd_bad(pgd_t pgd)
14513 {
14514 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14515 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14516 }
14517
14518 static inline int pgd_none(pgd_t pgd)
14519 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14520 * pgd_offset() returns a (pgd_t *)
14521 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14522 */
14523 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14524 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14525 +
14526 +#ifdef CONFIG_PAX_PER_CPU_PGD
14527 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14528 +#endif
14529 +
14530 /*
14531 * a shortcut which implies the use of the kernel's pgd, instead
14532 * of a process's
14533 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14534 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14535 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14536
14537 +#ifdef CONFIG_X86_32
14538 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14539 +#else
14540 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14541 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14542 +
14543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14544 +#ifdef __ASSEMBLY__
14545 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14546 +#else
14547 +extern unsigned long pax_user_shadow_base;
14548 +#endif
14549 +#endif
14550 +
14551 +#endif
14552 +
14553 #ifndef __ASSEMBLY__
14554
14555 extern int direct_gbpages;
14556 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14557 * dst and src can be on the same page, but the range must not overlap,
14558 * and must not cross a page boundary.
14559 */
14560 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14561 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14562 {
14563 - memcpy(dst, src, count * sizeof(pgd_t));
14564 + pax_open_kernel();
14565 + while (count--)
14566 + *dst++ = *src++;
14567 + pax_close_kernel();
14568 }
14569
14570 +#ifdef CONFIG_PAX_PER_CPU_PGD
14571 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14572 +#endif
14573 +
14574 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14575 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14576 +#else
14577 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14578 +#endif
14579 +
14580 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14581 static inline int page_level_shift(enum pg_level level)
14582 {
14583 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14584 index 9ee3221..b979c6b 100644
14585 --- a/arch/x86/include/asm/pgtable_32.h
14586 +++ b/arch/x86/include/asm/pgtable_32.h
14587 @@ -25,9 +25,6 @@
14588 struct mm_struct;
14589 struct vm_area_struct;
14590
14591 -extern pgd_t swapper_pg_dir[1024];
14592 -extern pgd_t initial_page_table[1024];
14593 -
14594 static inline void pgtable_cache_init(void) { }
14595 static inline void check_pgt_cache(void) { }
14596 void paging_init(void);
14597 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14598 # include <asm/pgtable-2level.h>
14599 #endif
14600
14601 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14602 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14603 +#ifdef CONFIG_X86_PAE
14604 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14605 +#endif
14606 +
14607 #if defined(CONFIG_HIGHPTE)
14608 #define pte_offset_map(dir, address) \
14609 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14610 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14611 /* Clear a kernel PTE and flush it from the TLB */
14612 #define kpte_clear_flush(ptep, vaddr) \
14613 do { \
14614 + pax_open_kernel(); \
14615 pte_clear(&init_mm, (vaddr), (ptep)); \
14616 + pax_close_kernel(); \
14617 __flush_tlb_one((vaddr)); \
14618 } while (0)
14619
14620 #endif /* !__ASSEMBLY__ */
14621
14622 +#define HAVE_ARCH_UNMAPPED_AREA
14623 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14624 +
14625 /*
14626 * kern_addr_valid() is (1) for FLATMEM and (0) for
14627 * SPARSEMEM and DISCONTIGMEM
14628 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14629 index ed5903b..c7fe163 100644
14630 --- a/arch/x86/include/asm/pgtable_32_types.h
14631 +++ b/arch/x86/include/asm/pgtable_32_types.h
14632 @@ -8,7 +8,7 @@
14633 */
14634 #ifdef CONFIG_X86_PAE
14635 # include <asm/pgtable-3level_types.h>
14636 -# define PMD_SIZE (1UL << PMD_SHIFT)
14637 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14638 # define PMD_MASK (~(PMD_SIZE - 1))
14639 #else
14640 # include <asm/pgtable-2level_types.h>
14641 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14642 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14643 #endif
14644
14645 +#ifdef CONFIG_PAX_KERNEXEC
14646 +#ifndef __ASSEMBLY__
14647 +extern unsigned char MODULES_EXEC_VADDR[];
14648 +extern unsigned char MODULES_EXEC_END[];
14649 +#endif
14650 +#include <asm/boot.h>
14651 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14652 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14653 +#else
14654 +#define ktla_ktva(addr) (addr)
14655 +#define ktva_ktla(addr) (addr)
14656 +#endif
14657 +
14658 #define MODULES_VADDR VMALLOC_START
14659 #define MODULES_END VMALLOC_END
14660 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14661 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14662 index e22c1db..23a625a 100644
14663 --- a/arch/x86/include/asm/pgtable_64.h
14664 +++ b/arch/x86/include/asm/pgtable_64.h
14665 @@ -16,10 +16,14 @@
14666
14667 extern pud_t level3_kernel_pgt[512];
14668 extern pud_t level3_ident_pgt[512];
14669 +extern pud_t level3_vmalloc_start_pgt[512];
14670 +extern pud_t level3_vmalloc_end_pgt[512];
14671 +extern pud_t level3_vmemmap_pgt[512];
14672 +extern pud_t level2_vmemmap_pgt[512];
14673 extern pmd_t level2_kernel_pgt[512];
14674 extern pmd_t level2_fixmap_pgt[512];
14675 -extern pmd_t level2_ident_pgt[512];
14676 -extern pgd_t init_level4_pgt[];
14677 +extern pmd_t level2_ident_pgt[512*2];
14678 +extern pgd_t init_level4_pgt[512];
14679
14680 #define swapper_pg_dir init_level4_pgt
14681
14682 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14683
14684 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14685 {
14686 + pax_open_kernel();
14687 *pmdp = pmd;
14688 + pax_close_kernel();
14689 }
14690
14691 static inline void native_pmd_clear(pmd_t *pmd)
14692 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14693
14694 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14695 {
14696 + pax_open_kernel();
14697 *pudp = pud;
14698 + pax_close_kernel();
14699 }
14700
14701 static inline void native_pud_clear(pud_t *pud)
14702 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14703
14704 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14705 {
14706 + pax_open_kernel();
14707 + *pgdp = pgd;
14708 + pax_close_kernel();
14709 +}
14710 +
14711 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14712 +{
14713 *pgdp = pgd;
14714 }
14715
14716 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14717 index 2d88344..4679fc3 100644
14718 --- a/arch/x86/include/asm/pgtable_64_types.h
14719 +++ b/arch/x86/include/asm/pgtable_64_types.h
14720 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14721 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14722 #define MODULES_END _AC(0xffffffffff000000, UL)
14723 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14724 +#define MODULES_EXEC_VADDR MODULES_VADDR
14725 +#define MODULES_EXEC_END MODULES_END
14726 +
14727 +#define ktla_ktva(addr) (addr)
14728 +#define ktva_ktla(addr) (addr)
14729
14730 #define EARLY_DYNAMIC_PAGE_TABLES 64
14731
14732 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14733 index e642300..0ef8f31 100644
14734 --- a/arch/x86/include/asm/pgtable_types.h
14735 +++ b/arch/x86/include/asm/pgtable_types.h
14736 @@ -16,13 +16,12 @@
14737 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14738 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14739 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14740 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14741 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14742 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14743 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14744 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14745 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14746 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14747 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14748 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14749 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14750 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14751
14752 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14753 @@ -40,7 +39,6 @@
14754 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14755 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14756 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14757 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14758 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14759 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14760 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14761 @@ -57,8 +55,10 @@
14762
14763 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14764 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14765 -#else
14766 +#elif defined(CONFIG_KMEMCHECK)
14767 #define _PAGE_NX (_AT(pteval_t, 0))
14768 +#else
14769 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14770 #endif
14771
14772 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14773 @@ -116,6 +116,9 @@
14774 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14775 _PAGE_ACCESSED)
14776
14777 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14778 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14779 +
14780 #define __PAGE_KERNEL_EXEC \
14781 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14782 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14783 @@ -126,7 +129,7 @@
14784 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14785 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14786 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14787 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14788 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14789 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14790 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14791 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14792 @@ -188,8 +191,8 @@
14793 * bits are combined, this will alow user to access the high address mapped
14794 * VDSO in the presence of CONFIG_COMPAT_VDSO
14795 */
14796 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14797 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14798 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14799 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14800 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14801 #endif
14802
14803 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14804 {
14805 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14806 }
14807 +#endif
14808
14809 +#if PAGETABLE_LEVELS == 3
14810 +#include <asm-generic/pgtable-nopud.h>
14811 +#endif
14812 +
14813 +#if PAGETABLE_LEVELS == 2
14814 +#include <asm-generic/pgtable-nopmd.h>
14815 +#endif
14816 +
14817 +#ifndef __ASSEMBLY__
14818 #if PAGETABLE_LEVELS > 3
14819 typedef struct { pudval_t pud; } pud_t;
14820
14821 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14822 return pud.pud;
14823 }
14824 #else
14825 -#include <asm-generic/pgtable-nopud.h>
14826 -
14827 static inline pudval_t native_pud_val(pud_t pud)
14828 {
14829 return native_pgd_val(pud.pgd);
14830 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14831 return pmd.pmd;
14832 }
14833 #else
14834 -#include <asm-generic/pgtable-nopmd.h>
14835 -
14836 static inline pmdval_t native_pmd_val(pmd_t pmd)
14837 {
14838 return native_pgd_val(pmd.pud.pgd);
14839 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14840
14841 extern pteval_t __supported_pte_mask;
14842 extern void set_nx(void);
14843 -extern int nx_enabled;
14844
14845 #define pgprot_writecombine pgprot_writecombine
14846 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14847 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14848 index 22224b3..4080dab 100644
14849 --- a/arch/x86/include/asm/processor.h
14850 +++ b/arch/x86/include/asm/processor.h
14851 @@ -282,7 +282,7 @@ struct tss_struct {
14852
14853 } ____cacheline_aligned;
14854
14855 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14856 +extern struct tss_struct init_tss[NR_CPUS];
14857
14858 /*
14859 * Save the original ist values for checking stack pointers during debugging
14860 @@ -823,11 +823,18 @@ static inline void spin_lock_prefetch(const void *x)
14861 */
14862 #define TASK_SIZE PAGE_OFFSET
14863 #define TASK_SIZE_MAX TASK_SIZE
14864 +
14865 +#ifdef CONFIG_PAX_SEGMEXEC
14866 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14867 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14868 +#else
14869 #define STACK_TOP TASK_SIZE
14870 -#define STACK_TOP_MAX STACK_TOP
14871 +#endif
14872 +
14873 +#define STACK_TOP_MAX TASK_SIZE
14874
14875 #define INIT_THREAD { \
14876 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14877 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14878 .vm86_info = NULL, \
14879 .sysenter_cs = __KERNEL_CS, \
14880 .io_bitmap_ptr = NULL, \
14881 @@ -841,7 +848,7 @@ static inline void spin_lock_prefetch(const void *x)
14882 */
14883 #define INIT_TSS { \
14884 .x86_tss = { \
14885 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14886 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14887 .ss0 = __KERNEL_DS, \
14888 .ss1 = __KERNEL_CS, \
14889 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14890 @@ -852,11 +859,7 @@ static inline void spin_lock_prefetch(const void *x)
14891 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14892
14893 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14894 -#define KSTK_TOP(info) \
14895 -({ \
14896 - unsigned long *__ptr = (unsigned long *)(info); \
14897 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14898 -})
14899 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14900
14901 /*
14902 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14903 @@ -871,7 +874,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14904 #define task_pt_regs(task) \
14905 ({ \
14906 struct pt_regs *__regs__; \
14907 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14908 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14909 __regs__ - 1; \
14910 })
14911
14912 @@ -881,13 +884,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14913 /*
14914 * User space process size. 47bits minus one guard page.
14915 */
14916 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14917 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14918
14919 /* This decides where the kernel will search for a free chunk of vm
14920 * space during mmap's.
14921 */
14922 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14923 - 0xc0000000 : 0xFFFFe000)
14924 + 0xc0000000 : 0xFFFFf000)
14925
14926 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14927 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14928 @@ -898,11 +901,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14929 #define STACK_TOP_MAX TASK_SIZE_MAX
14930
14931 #define INIT_THREAD { \
14932 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14933 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14934 }
14935
14936 #define INIT_TSS { \
14937 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14938 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14939 }
14940
14941 /*
14942 @@ -930,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14943 */
14944 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14945
14946 +#ifdef CONFIG_PAX_SEGMEXEC
14947 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14948 +#endif
14949 +
14950 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14951
14952 /* Get/set a process' ability to use the timestamp counter instruction */
14953 @@ -970,7 +977,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
14954 return ratio;
14955 }
14956
14957 -extern unsigned long arch_align_stack(unsigned long sp);
14958 +#define arch_align_stack(x) ((x) & ~0xfUL)
14959 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14960
14961 void default_idle(void);
14962 @@ -980,6 +987,6 @@ bool xen_set_default_idle(void);
14963 #define xen_set_default_idle 0
14964 #endif
14965
14966 -void stop_this_cpu(void *dummy);
14967 +void stop_this_cpu(void *dummy) __noreturn;
14968
14969 #endif /* _ASM_X86_PROCESSOR_H */
14970 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14971 index 942a086..6c26446 100644
14972 --- a/arch/x86/include/asm/ptrace.h
14973 +++ b/arch/x86/include/asm/ptrace.h
14974 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14975 }
14976
14977 /*
14978 - * user_mode_vm(regs) determines whether a register set came from user mode.
14979 + * user_mode(regs) determines whether a register set came from user mode.
14980 * This is true if V8086 mode was enabled OR if the register set was from
14981 * protected mode with RPL-3 CS value. This tricky test checks that with
14982 * one comparison. Many places in the kernel can bypass this full check
14983 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14984 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14985 + * be used.
14986 */
14987 -static inline int user_mode(struct pt_regs *regs)
14988 +static inline int user_mode_novm(struct pt_regs *regs)
14989 {
14990 #ifdef CONFIG_X86_32
14991 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14992 #else
14993 - return !!(regs->cs & 3);
14994 + return !!(regs->cs & SEGMENT_RPL_MASK);
14995 #endif
14996 }
14997
14998 -static inline int user_mode_vm(struct pt_regs *regs)
14999 +static inline int user_mode(struct pt_regs *regs)
15000 {
15001 #ifdef CONFIG_X86_32
15002 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15003 USER_RPL;
15004 #else
15005 - return user_mode(regs);
15006 + return user_mode_novm(regs);
15007 #endif
15008 }
15009
15010 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15011 #ifdef CONFIG_X86_64
15012 static inline bool user_64bit_mode(struct pt_regs *regs)
15013 {
15014 + unsigned long cs = regs->cs & 0xffff;
15015 #ifndef CONFIG_PARAVIRT
15016 /*
15017 * On non-paravirt systems, this is the only long mode CPL 3
15018 * selector. We do not allow long mode selectors in the LDT.
15019 */
15020 - return regs->cs == __USER_CS;
15021 + return cs == __USER_CS;
15022 #else
15023 /* Headers are too twisted for this to go in paravirt.h. */
15024 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15025 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15026 #endif
15027 }
15028
15029 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15030 * Traps from the kernel do not save sp and ss.
15031 * Use the helper function to retrieve sp.
15032 */
15033 - if (offset == offsetof(struct pt_regs, sp) &&
15034 - regs->cs == __KERNEL_CS)
15035 - return kernel_stack_pointer(regs);
15036 + if (offset == offsetof(struct pt_regs, sp)) {
15037 + unsigned long cs = regs->cs & 0xffff;
15038 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15039 + return kernel_stack_pointer(regs);
15040 + }
15041 #endif
15042 return *(unsigned long *)((unsigned long)regs + offset);
15043 }
15044 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15045 index 9c6b890..5305f53 100644
15046 --- a/arch/x86/include/asm/realmode.h
15047 +++ b/arch/x86/include/asm/realmode.h
15048 @@ -22,16 +22,14 @@ struct real_mode_header {
15049 #endif
15050 /* APM/BIOS reboot */
15051 u32 machine_real_restart_asm;
15052 -#ifdef CONFIG_X86_64
15053 u32 machine_real_restart_seg;
15054 -#endif
15055 };
15056
15057 /* This must match data at trampoline_32/64.S */
15058 struct trampoline_header {
15059 #ifdef CONFIG_X86_32
15060 u32 start;
15061 - u16 gdt_pad;
15062 + u16 boot_cs;
15063 u16 gdt_limit;
15064 u32 gdt_base;
15065 #else
15066 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15067 index a82c4f1..ac45053 100644
15068 --- a/arch/x86/include/asm/reboot.h
15069 +++ b/arch/x86/include/asm/reboot.h
15070 @@ -6,13 +6,13 @@
15071 struct pt_regs;
15072
15073 struct machine_ops {
15074 - void (*restart)(char *cmd);
15075 - void (*halt)(void);
15076 - void (*power_off)(void);
15077 + void (* __noreturn restart)(char *cmd);
15078 + void (* __noreturn halt)(void);
15079 + void (* __noreturn power_off)(void);
15080 void (*shutdown)(void);
15081 void (*crash_shutdown)(struct pt_regs *);
15082 - void (*emergency_restart)(void);
15083 -};
15084 + void (* __noreturn emergency_restart)(void);
15085 +} __no_const;
15086
15087 extern struct machine_ops machine_ops;
15088
15089 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15090 index cad82c9..2e5c5c1 100644
15091 --- a/arch/x86/include/asm/rwsem.h
15092 +++ b/arch/x86/include/asm/rwsem.h
15093 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15094 {
15095 asm volatile("# beginning down_read\n\t"
15096 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15097 +
15098 +#ifdef CONFIG_PAX_REFCOUNT
15099 + "jno 0f\n"
15100 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15101 + "int $4\n0:\n"
15102 + _ASM_EXTABLE(0b, 0b)
15103 +#endif
15104 +
15105 /* adds 0x00000001 */
15106 " jns 1f\n"
15107 " call call_rwsem_down_read_failed\n"
15108 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15109 "1:\n\t"
15110 " mov %1,%2\n\t"
15111 " add %3,%2\n\t"
15112 +
15113 +#ifdef CONFIG_PAX_REFCOUNT
15114 + "jno 0f\n"
15115 + "sub %3,%2\n"
15116 + "int $4\n0:\n"
15117 + _ASM_EXTABLE(0b, 0b)
15118 +#endif
15119 +
15120 " jle 2f\n\t"
15121 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15122 " jnz 1b\n\t"
15123 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15124 long tmp;
15125 asm volatile("# beginning down_write\n\t"
15126 LOCK_PREFIX " xadd %1,(%2)\n\t"
15127 +
15128 +#ifdef CONFIG_PAX_REFCOUNT
15129 + "jno 0f\n"
15130 + "mov %1,(%2)\n"
15131 + "int $4\n0:\n"
15132 + _ASM_EXTABLE(0b, 0b)
15133 +#endif
15134 +
15135 /* adds 0xffff0001, returns the old value */
15136 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
15137 /* was the active mask 0 before? */
15138 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15139 long tmp;
15140 asm volatile("# beginning __up_read\n\t"
15141 LOCK_PREFIX " xadd %1,(%2)\n\t"
15142 +
15143 +#ifdef CONFIG_PAX_REFCOUNT
15144 + "jno 0f\n"
15145 + "mov %1,(%2)\n"
15146 + "int $4\n0:\n"
15147 + _ASM_EXTABLE(0b, 0b)
15148 +#endif
15149 +
15150 /* subtracts 1, returns the old value */
15151 " jns 1f\n\t"
15152 " call call_rwsem_wake\n" /* expects old value in %edx */
15153 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15154 long tmp;
15155 asm volatile("# beginning __up_write\n\t"
15156 LOCK_PREFIX " xadd %1,(%2)\n\t"
15157 +
15158 +#ifdef CONFIG_PAX_REFCOUNT
15159 + "jno 0f\n"
15160 + "mov %1,(%2)\n"
15161 + "int $4\n0:\n"
15162 + _ASM_EXTABLE(0b, 0b)
15163 +#endif
15164 +
15165 /* subtracts 0xffff0001, returns the old value */
15166 " jns 1f\n\t"
15167 " call call_rwsem_wake\n" /* expects old value in %edx */
15168 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15169 {
15170 asm volatile("# beginning __downgrade_write\n\t"
15171 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15172 +
15173 +#ifdef CONFIG_PAX_REFCOUNT
15174 + "jno 0f\n"
15175 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15176 + "int $4\n0:\n"
15177 + _ASM_EXTABLE(0b, 0b)
15178 +#endif
15179 +
15180 /*
15181 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15182 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15183 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15184 */
15185 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15186 {
15187 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15188 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15189 +
15190 +#ifdef CONFIG_PAX_REFCOUNT
15191 + "jno 0f\n"
15192 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15193 + "int $4\n0:\n"
15194 + _ASM_EXTABLE(0b, 0b)
15195 +#endif
15196 +
15197 : "+m" (sem->count)
15198 : "er" (delta));
15199 }
15200 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15201 */
15202 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15203 {
15204 - return delta + xadd(&sem->count, delta);
15205 + return delta + xadd_check_overflow(&sem->count, delta);
15206 }
15207
15208 #endif /* __KERNEL__ */
15209 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15210 index c48a950..c6d7468 100644
15211 --- a/arch/x86/include/asm/segment.h
15212 +++ b/arch/x86/include/asm/segment.h
15213 @@ -64,10 +64,15 @@
15214 * 26 - ESPFIX small SS
15215 * 27 - per-cpu [ offset to per-cpu data area ]
15216 * 28 - stack_canary-20 [ for stack protector ]
15217 - * 29 - unused
15218 - * 30 - unused
15219 + * 29 - PCI BIOS CS
15220 + * 30 - PCI BIOS DS
15221 * 31 - TSS for double fault handler
15222 */
15223 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15224 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15225 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15226 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15227 +
15228 #define GDT_ENTRY_TLS_MIN 6
15229 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15230
15231 @@ -79,6 +84,8 @@
15232
15233 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15234
15235 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15236 +
15237 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15238
15239 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15240 @@ -104,6 +111,12 @@
15241 #define __KERNEL_STACK_CANARY 0
15242 #endif
15243
15244 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15245 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15246 +
15247 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15248 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15249 +
15250 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15251
15252 /*
15253 @@ -141,7 +154,7 @@
15254 */
15255
15256 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15257 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15258 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15259
15260
15261 #else
15262 @@ -165,6 +178,8 @@
15263 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15264 #define __USER32_DS __USER_DS
15265
15266 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15267 +
15268 #define GDT_ENTRY_TSS 8 /* needs two entries */
15269 #define GDT_ENTRY_LDT 10 /* needs two entries */
15270 #define GDT_ENTRY_TLS_MIN 12
15271 @@ -185,6 +200,7 @@
15272 #endif
15273
15274 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15275 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15276 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15277 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15278 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15279 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15280 {
15281 unsigned long __limit;
15282 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15283 - return __limit + 1;
15284 + return __limit;
15285 }
15286
15287 #endif /* !__ASSEMBLY__ */
15288 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15289 index b073aae..39f9bdd 100644
15290 --- a/arch/x86/include/asm/smp.h
15291 +++ b/arch/x86/include/asm/smp.h
15292 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15293 /* cpus sharing the last level cache: */
15294 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15295 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15296 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15297 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15298
15299 static inline struct cpumask *cpu_sibling_mask(int cpu)
15300 {
15301 @@ -79,7 +79,7 @@ struct smp_ops {
15302
15303 void (*send_call_func_ipi)(const struct cpumask *mask);
15304 void (*send_call_func_single_ipi)(int cpu);
15305 -};
15306 +} __no_const;
15307
15308 /* Globals due to paravirt */
15309 extern void set_cpu_sibling_map(int cpu);
15310 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15311 extern int safe_smp_processor_id(void);
15312
15313 #elif defined(CONFIG_X86_64_SMP)
15314 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15315 -
15316 -#define stack_smp_processor_id() \
15317 -({ \
15318 - struct thread_info *ti; \
15319 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15320 - ti->cpu; \
15321 -})
15322 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15323 +#define stack_smp_processor_id() raw_smp_processor_id()
15324 #define safe_smp_processor_id() smp_processor_id()
15325
15326 #endif
15327 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15328 index 33692ea..350a534 100644
15329 --- a/arch/x86/include/asm/spinlock.h
15330 +++ b/arch/x86/include/asm/spinlock.h
15331 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15332 static inline void arch_read_lock(arch_rwlock_t *rw)
15333 {
15334 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15335 +
15336 +#ifdef CONFIG_PAX_REFCOUNT
15337 + "jno 0f\n"
15338 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15339 + "int $4\n0:\n"
15340 + _ASM_EXTABLE(0b, 0b)
15341 +#endif
15342 +
15343 "jns 1f\n"
15344 "call __read_lock_failed\n\t"
15345 "1:\n"
15346 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15347 static inline void arch_write_lock(arch_rwlock_t *rw)
15348 {
15349 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15350 +
15351 +#ifdef CONFIG_PAX_REFCOUNT
15352 + "jno 0f\n"
15353 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15354 + "int $4\n0:\n"
15355 + _ASM_EXTABLE(0b, 0b)
15356 +#endif
15357 +
15358 "jz 1f\n"
15359 "call __write_lock_failed\n\t"
15360 "1:\n"
15361 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15362
15363 static inline void arch_read_unlock(arch_rwlock_t *rw)
15364 {
15365 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15366 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15367 +
15368 +#ifdef CONFIG_PAX_REFCOUNT
15369 + "jno 0f\n"
15370 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15371 + "int $4\n0:\n"
15372 + _ASM_EXTABLE(0b, 0b)
15373 +#endif
15374 +
15375 :"+m" (rw->lock) : : "memory");
15376 }
15377
15378 static inline void arch_write_unlock(arch_rwlock_t *rw)
15379 {
15380 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15381 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15382 +
15383 +#ifdef CONFIG_PAX_REFCOUNT
15384 + "jno 0f\n"
15385 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15386 + "int $4\n0:\n"
15387 + _ASM_EXTABLE(0b, 0b)
15388 +#endif
15389 +
15390 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15391 }
15392
15393 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15394 index 6a99859..03cb807 100644
15395 --- a/arch/x86/include/asm/stackprotector.h
15396 +++ b/arch/x86/include/asm/stackprotector.h
15397 @@ -47,7 +47,7 @@
15398 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15399 */
15400 #define GDT_STACK_CANARY_INIT \
15401 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15402 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15403
15404 /*
15405 * Initialize the stackprotector canary value.
15406 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15407
15408 static inline void load_stack_canary_segment(void)
15409 {
15410 -#ifdef CONFIG_X86_32
15411 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15412 asm volatile ("mov %0, %%gs" : : "r" (0));
15413 #endif
15414 }
15415 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15416 index 70bbe39..4ae2bd4 100644
15417 --- a/arch/x86/include/asm/stacktrace.h
15418 +++ b/arch/x86/include/asm/stacktrace.h
15419 @@ -11,28 +11,20 @@
15420
15421 extern int kstack_depth_to_print;
15422
15423 -struct thread_info;
15424 +struct task_struct;
15425 struct stacktrace_ops;
15426
15427 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15428 - unsigned long *stack,
15429 - unsigned long bp,
15430 - const struct stacktrace_ops *ops,
15431 - void *data,
15432 - unsigned long *end,
15433 - int *graph);
15434 +typedef unsigned long walk_stack_t(struct task_struct *task,
15435 + void *stack_start,
15436 + unsigned long *stack,
15437 + unsigned long bp,
15438 + const struct stacktrace_ops *ops,
15439 + void *data,
15440 + unsigned long *end,
15441 + int *graph);
15442
15443 -extern unsigned long
15444 -print_context_stack(struct thread_info *tinfo,
15445 - unsigned long *stack, unsigned long bp,
15446 - const struct stacktrace_ops *ops, void *data,
15447 - unsigned long *end, int *graph);
15448 -
15449 -extern unsigned long
15450 -print_context_stack_bp(struct thread_info *tinfo,
15451 - unsigned long *stack, unsigned long bp,
15452 - const struct stacktrace_ops *ops, void *data,
15453 - unsigned long *end, int *graph);
15454 +extern walk_stack_t print_context_stack;
15455 +extern walk_stack_t print_context_stack_bp;
15456
15457 /* Generic stack tracer with callbacks */
15458
15459 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15460 void (*address)(void *data, unsigned long address, int reliable);
15461 /* On negative return stop dumping */
15462 int (*stack)(void *data, char *name);
15463 - walk_stack_t walk_stack;
15464 + walk_stack_t *walk_stack;
15465 };
15466
15467 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15468 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15469 index 4ec45b3..a4f0a8a 100644
15470 --- a/arch/x86/include/asm/switch_to.h
15471 +++ b/arch/x86/include/asm/switch_to.h
15472 @@ -108,7 +108,7 @@ do { \
15473 "call __switch_to\n\t" \
15474 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15475 __switch_canary \
15476 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15477 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15478 "movq %%rax,%%rdi\n\t" \
15479 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15480 "jnz ret_from_fork\n\t" \
15481 @@ -119,7 +119,7 @@ do { \
15482 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15483 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15484 [_tif_fork] "i" (_TIF_FORK), \
15485 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15486 + [thread_info] "m" (current_tinfo), \
15487 [current_task] "m" (current_task) \
15488 __switch_canary_iparam \
15489 : "memory", "cc" __EXTRA_CLOBBER)
15490 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15491 index a1df6e8..e002940 100644
15492 --- a/arch/x86/include/asm/thread_info.h
15493 +++ b/arch/x86/include/asm/thread_info.h
15494 @@ -10,6 +10,7 @@
15495 #include <linux/compiler.h>
15496 #include <asm/page.h>
15497 #include <asm/types.h>
15498 +#include <asm/percpu.h>
15499
15500 /*
15501 * low level task data that entry.S needs immediate access to
15502 @@ -23,7 +24,6 @@ struct exec_domain;
15503 #include <linux/atomic.h>
15504
15505 struct thread_info {
15506 - struct task_struct *task; /* main task structure */
15507 struct exec_domain *exec_domain; /* execution domain */
15508 __u32 flags; /* low level flags */
15509 __u32 status; /* thread synchronous flags */
15510 @@ -33,19 +33,13 @@ struct thread_info {
15511 mm_segment_t addr_limit;
15512 struct restart_block restart_block;
15513 void __user *sysenter_return;
15514 -#ifdef CONFIG_X86_32
15515 - unsigned long previous_esp; /* ESP of the previous stack in
15516 - case of nested (IRQ) stacks
15517 - */
15518 - __u8 supervisor_stack[0];
15519 -#endif
15520 + unsigned long lowest_stack;
15521 unsigned int sig_on_uaccess_error:1;
15522 unsigned int uaccess_err:1; /* uaccess failed */
15523 };
15524
15525 -#define INIT_THREAD_INFO(tsk) \
15526 +#define INIT_THREAD_INFO \
15527 { \
15528 - .task = &tsk, \
15529 .exec_domain = &default_exec_domain, \
15530 .flags = 0, \
15531 .cpu = 0, \
15532 @@ -56,7 +50,7 @@ struct thread_info {
15533 }, \
15534 }
15535
15536 -#define init_thread_info (init_thread_union.thread_info)
15537 +#define init_thread_info (init_thread_union.stack)
15538 #define init_stack (init_thread_union.stack)
15539
15540 #else /* !__ASSEMBLY__ */
15541 @@ -97,6 +91,7 @@ struct thread_info {
15542 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15543 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15544 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15545 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15546
15547 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15548 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15549 @@ -121,17 +116,18 @@ struct thread_info {
15550 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15551 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15552 #define _TIF_X32 (1 << TIF_X32)
15553 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15554
15555 /* work to do in syscall_trace_enter() */
15556 #define _TIF_WORK_SYSCALL_ENTRY \
15557 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15558 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15559 - _TIF_NOHZ)
15560 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15561
15562 /* work to do in syscall_trace_leave() */
15563 #define _TIF_WORK_SYSCALL_EXIT \
15564 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15565 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15566 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15567
15568 /* work to do on interrupt/exception return */
15569 #define _TIF_WORK_MASK \
15570 @@ -142,7 +138,7 @@ struct thread_info {
15571 /* work to do on any return to user space */
15572 #define _TIF_ALLWORK_MASK \
15573 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15574 - _TIF_NOHZ)
15575 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15576
15577 /* Only used for 64 bit */
15578 #define _TIF_DO_NOTIFY_MASK \
15579 @@ -158,45 +154,40 @@ struct thread_info {
15580
15581 #define PREEMPT_ACTIVE 0x10000000
15582
15583 -#ifdef CONFIG_X86_32
15584 -
15585 -#define STACK_WARN (THREAD_SIZE/8)
15586 -/*
15587 - * macros/functions for gaining access to the thread information structure
15588 - *
15589 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15590 - */
15591 -#ifndef __ASSEMBLY__
15592 -
15593 -
15594 -/* how to get the current stack pointer from C */
15595 -register unsigned long current_stack_pointer asm("esp") __used;
15596 -
15597 -/* how to get the thread information struct from C */
15598 -static inline struct thread_info *current_thread_info(void)
15599 -{
15600 - return (struct thread_info *)
15601 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15602 -}
15603 -
15604 -#else /* !__ASSEMBLY__ */
15605 -
15606 +#ifdef __ASSEMBLY__
15607 /* how to get the thread information struct from ASM */
15608 #define GET_THREAD_INFO(reg) \
15609 - movl $-THREAD_SIZE, reg; \
15610 - andl %esp, reg
15611 + mov PER_CPU_VAR(current_tinfo), reg
15612
15613 /* use this one if reg already contains %esp */
15614 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15615 - andl $-THREAD_SIZE, reg
15616 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15617 +#else
15618 +/* how to get the thread information struct from C */
15619 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15620 +
15621 +static __always_inline struct thread_info *current_thread_info(void)
15622 +{
15623 + return this_cpu_read_stable(current_tinfo);
15624 +}
15625 +#endif
15626 +
15627 +#ifdef CONFIG_X86_32
15628 +
15629 +#define STACK_WARN (THREAD_SIZE/8)
15630 +/*
15631 + * macros/functions for gaining access to the thread information structure
15632 + *
15633 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15634 + */
15635 +#ifndef __ASSEMBLY__
15636 +
15637 +/* how to get the current stack pointer from C */
15638 +register unsigned long current_stack_pointer asm("esp") __used;
15639
15640 #endif
15641
15642 #else /* X86_32 */
15643
15644 -#include <asm/percpu.h>
15645 -#define KERNEL_STACK_OFFSET (5*8)
15646 -
15647 /*
15648 * macros/functions for gaining access to the thread information structure
15649 * preempt_count needs to be 1 initially, until the scheduler is functional.
15650 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15651 #ifndef __ASSEMBLY__
15652 DECLARE_PER_CPU(unsigned long, kernel_stack);
15653
15654 -static inline struct thread_info *current_thread_info(void)
15655 -{
15656 - struct thread_info *ti;
15657 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15658 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15659 - return ti;
15660 -}
15661 -
15662 -#else /* !__ASSEMBLY__ */
15663 -
15664 -/* how to get the thread information struct from ASM */
15665 -#define GET_THREAD_INFO(reg) \
15666 - movq PER_CPU_VAR(kernel_stack),reg ; \
15667 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15668 -
15669 -/*
15670 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15671 - * a certain register (to be used in assembler memory operands).
15672 - */
15673 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15674 -
15675 +/* how to get the current stack pointer from C */
15676 +register unsigned long current_stack_pointer asm("rsp") __used;
15677 #endif
15678
15679 #endif /* !X86_32 */
15680 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
15681 extern void arch_task_cache_init(void);
15682 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15683 extern void arch_release_task_struct(struct task_struct *tsk);
15684 +
15685 +#define __HAVE_THREAD_FUNCTIONS
15686 +#define task_thread_info(task) (&(task)->tinfo)
15687 +#define task_stack_page(task) ((task)->stack)
15688 +#define setup_thread_stack(p, org) do {} while (0)
15689 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15690 +
15691 #endif
15692 #endif /* _ASM_X86_THREAD_INFO_H */
15693 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15694 index 5ee2687..70d5895 100644
15695 --- a/arch/x86/include/asm/uaccess.h
15696 +++ b/arch/x86/include/asm/uaccess.h
15697 @@ -7,6 +7,7 @@
15698 #include <linux/compiler.h>
15699 #include <linux/thread_info.h>
15700 #include <linux/string.h>
15701 +#include <linux/sched.h>
15702 #include <asm/asm.h>
15703 #include <asm/page.h>
15704 #include <asm/smap.h>
15705 @@ -29,7 +30,12 @@
15706
15707 #define get_ds() (KERNEL_DS)
15708 #define get_fs() (current_thread_info()->addr_limit)
15709 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15710 +void __set_fs(mm_segment_t x);
15711 +void set_fs(mm_segment_t x);
15712 +#else
15713 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15714 +#endif
15715
15716 #define segment_eq(a, b) ((a).seg == (b).seg)
15717
15718 @@ -77,8 +83,33 @@
15719 * checks that the pointer is in the user space range - after calling
15720 * this function, memory access functions may still return -EFAULT.
15721 */
15722 -#define access_ok(type, addr, size) \
15723 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15724 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15725 +#define access_ok(type, addr, size) \
15726 +({ \
15727 + long __size = size; \
15728 + unsigned long __addr = (unsigned long)addr; \
15729 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15730 + unsigned long __end_ao = __addr + __size - 1; \
15731 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15732 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15733 + while(__addr_ao <= __end_ao) { \
15734 + char __c_ao; \
15735 + __addr_ao += PAGE_SIZE; \
15736 + if (__size > PAGE_SIZE) \
15737 + cond_resched(); \
15738 + if (__get_user(__c_ao, (char __user *)__addr)) \
15739 + break; \
15740 + if (type != VERIFY_WRITE) { \
15741 + __addr = __addr_ao; \
15742 + continue; \
15743 + } \
15744 + if (__put_user(__c_ao, (char __user *)__addr)) \
15745 + break; \
15746 + __addr = __addr_ao; \
15747 + } \
15748 + } \
15749 + __ret_ao; \
15750 +})
15751
15752 /*
15753 * The exception table consists of pairs of addresses relative to the
15754 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15755 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15756 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15757
15758 -
15759 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15760 +#define __copyuser_seg "gs;"
15761 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15762 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15763 +#else
15764 +#define __copyuser_seg
15765 +#define __COPYUSER_SET_ES
15766 +#define __COPYUSER_RESTORE_ES
15767 +#endif
15768
15769 #ifdef CONFIG_X86_32
15770 #define __put_user_asm_u64(x, addr, err, errret) \
15771 asm volatile(ASM_STAC "\n" \
15772 - "1: movl %%eax,0(%2)\n" \
15773 - "2: movl %%edx,4(%2)\n" \
15774 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15775 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15776 "3: " ASM_CLAC "\n" \
15777 ".section .fixup,\"ax\"\n" \
15778 "4: movl %3,%0\n" \
15779 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15780
15781 #define __put_user_asm_ex_u64(x, addr) \
15782 asm volatile(ASM_STAC "\n" \
15783 - "1: movl %%eax,0(%1)\n" \
15784 - "2: movl %%edx,4(%1)\n" \
15785 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15786 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15787 "3: " ASM_CLAC "\n" \
15788 _ASM_EXTABLE_EX(1b, 2b) \
15789 _ASM_EXTABLE_EX(2b, 3b) \
15790 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15791 __typeof__(*(ptr)) __pu_val; \
15792 __chk_user_ptr(ptr); \
15793 might_fault(); \
15794 - __pu_val = x; \
15795 + __pu_val = (x); \
15796 switch (sizeof(*(ptr))) { \
15797 case 1: \
15798 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15799 @@ -345,7 +384,7 @@ do { \
15800
15801 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15802 asm volatile(ASM_STAC "\n" \
15803 - "1: mov"itype" %2,%"rtype"1\n" \
15804 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15805 "2: " ASM_CLAC "\n" \
15806 ".section .fixup,\"ax\"\n" \
15807 "3: mov %3,%0\n" \
15808 @@ -353,7 +392,7 @@ do { \
15809 " jmp 2b\n" \
15810 ".previous\n" \
15811 _ASM_EXTABLE(1b, 3b) \
15812 - : "=r" (err), ltype(x) \
15813 + : "=r" (err), ltype (x) \
15814 : "m" (__m(addr)), "i" (errret), "0" (err))
15815
15816 #define __get_user_size_ex(x, ptr, size) \
15817 @@ -378,7 +417,7 @@ do { \
15818 } while (0)
15819
15820 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15821 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15822 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15823 "2:\n" \
15824 _ASM_EXTABLE_EX(1b, 2b) \
15825 : ltype(x) : "m" (__m(addr)))
15826 @@ -395,13 +434,24 @@ do { \
15827 int __gu_err; \
15828 unsigned long __gu_val; \
15829 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15830 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15831 + (x) = (__typeof__(*(ptr)))__gu_val; \
15832 __gu_err; \
15833 })
15834
15835 /* FIXME: this hack is definitely wrong -AK */
15836 struct __large_struct { unsigned long buf[100]; };
15837 -#define __m(x) (*(struct __large_struct __user *)(x))
15838 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15839 +#define ____m(x) \
15840 +({ \
15841 + unsigned long ____x = (unsigned long)(x); \
15842 + if (____x < pax_user_shadow_base) \
15843 + ____x += pax_user_shadow_base; \
15844 + (typeof(x))____x; \
15845 +})
15846 +#else
15847 +#define ____m(x) (x)
15848 +#endif
15849 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15850
15851 /*
15852 * Tell gcc we read from memory instead of writing: this is because
15853 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15854 */
15855 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15856 asm volatile(ASM_STAC "\n" \
15857 - "1: mov"itype" %"rtype"1,%2\n" \
15858 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15859 "2: " ASM_CLAC "\n" \
15860 ".section .fixup,\"ax\"\n" \
15861 "3: mov %3,%0\n" \
15862 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15863 ".previous\n" \
15864 _ASM_EXTABLE(1b, 3b) \
15865 : "=r"(err) \
15866 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15867 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15868
15869 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15870 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15871 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15872 "2:\n" \
15873 _ASM_EXTABLE_EX(1b, 2b) \
15874 : : ltype(x), "m" (__m(addr)))
15875 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15876 * On error, the variable @x is set to zero.
15877 */
15878
15879 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15880 +#define __get_user(x, ptr) get_user((x), (ptr))
15881 +#else
15882 #define __get_user(x, ptr) \
15883 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15884 +#endif
15885
15886 /**
15887 * __put_user: - Write a simple value into user space, with less checking.
15888 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15889 * Returns zero on success, or -EFAULT on error.
15890 */
15891
15892 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15893 +#define __put_user(x, ptr) put_user((x), (ptr))
15894 +#else
15895 #define __put_user(x, ptr) \
15896 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15897 +#endif
15898
15899 #define __get_user_unaligned __get_user
15900 #define __put_user_unaligned __put_user
15901 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15902 #define get_user_ex(x, ptr) do { \
15903 unsigned long __gue_val; \
15904 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15905 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15906 + (x) = (__typeof__(*(ptr)))__gue_val; \
15907 } while (0)
15908
15909 #define put_user_try uaccess_try
15910 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15911 extern __must_check long strlen_user(const char __user *str);
15912 extern __must_check long strnlen_user(const char __user *str, long n);
15913
15914 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15915 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15916 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15917 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15918
15919 /*
15920 * movsl can be slow when source and dest are not both 8-byte aligned
15921 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15922 index 7f760a9..04b1c65 100644
15923 --- a/arch/x86/include/asm/uaccess_32.h
15924 +++ b/arch/x86/include/asm/uaccess_32.h
15925 @@ -11,15 +11,15 @@
15926 #include <asm/page.h>
15927
15928 unsigned long __must_check __copy_to_user_ll
15929 - (void __user *to, const void *from, unsigned long n);
15930 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15931 unsigned long __must_check __copy_from_user_ll
15932 - (void *to, const void __user *from, unsigned long n);
15933 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15934 unsigned long __must_check __copy_from_user_ll_nozero
15935 - (void *to, const void __user *from, unsigned long n);
15936 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15937 unsigned long __must_check __copy_from_user_ll_nocache
15938 - (void *to, const void __user *from, unsigned long n);
15939 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15940 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15941 - (void *to, const void __user *from, unsigned long n);
15942 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15943
15944 /**
15945 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15946 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15947 static __always_inline unsigned long __must_check
15948 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15949 {
15950 + if ((long)n < 0)
15951 + return n;
15952 +
15953 + check_object_size(from, n, true);
15954 +
15955 if (__builtin_constant_p(n)) {
15956 unsigned long ret;
15957
15958 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15959 __copy_to_user(void __user *to, const void *from, unsigned long n)
15960 {
15961 might_fault();
15962 +
15963 return __copy_to_user_inatomic(to, from, n);
15964 }
15965
15966 static __always_inline unsigned long
15967 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15968 {
15969 + if ((long)n < 0)
15970 + return n;
15971 +
15972 /* Avoid zeroing the tail if the copy fails..
15973 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15974 * but as the zeroing behaviour is only significant when n is not
15975 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15976 __copy_from_user(void *to, const void __user *from, unsigned long n)
15977 {
15978 might_fault();
15979 +
15980 + if ((long)n < 0)
15981 + return n;
15982 +
15983 + check_object_size(to, n, false);
15984 +
15985 if (__builtin_constant_p(n)) {
15986 unsigned long ret;
15987
15988 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15989 const void __user *from, unsigned long n)
15990 {
15991 might_fault();
15992 +
15993 + if ((long)n < 0)
15994 + return n;
15995 +
15996 if (__builtin_constant_p(n)) {
15997 unsigned long ret;
15998
15999 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16000 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16001 unsigned long n)
16002 {
16003 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16004 + if ((long)n < 0)
16005 + return n;
16006 +
16007 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16008 }
16009
16010 -unsigned long __must_check copy_to_user(void __user *to,
16011 - const void *from, unsigned long n);
16012 -unsigned long __must_check _copy_from_user(void *to,
16013 - const void __user *from,
16014 - unsigned long n);
16015 -
16016 +extern void copy_to_user_overflow(void)
16017 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16018 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16019 +#else
16020 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16021 +#endif
16022 +;
16023
16024 extern void copy_from_user_overflow(void)
16025 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16026 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16027 #endif
16028 ;
16029
16030 -static inline unsigned long __must_check copy_from_user(void *to,
16031 - const void __user *from,
16032 - unsigned long n)
16033 +/**
16034 + * copy_to_user: - Copy a block of data into user space.
16035 + * @to: Destination address, in user space.
16036 + * @from: Source address, in kernel space.
16037 + * @n: Number of bytes to copy.
16038 + *
16039 + * Context: User context only. This function may sleep.
16040 + *
16041 + * Copy data from kernel space to user space.
16042 + *
16043 + * Returns number of bytes that could not be copied.
16044 + * On success, this will be zero.
16045 + */
16046 +static inline unsigned long __must_check
16047 +copy_to_user(void __user *to, const void *from, unsigned long n)
16048 {
16049 - int sz = __compiletime_object_size(to);
16050 + size_t sz = __compiletime_object_size(from);
16051
16052 - if (likely(sz == -1 || sz >= n))
16053 - n = _copy_from_user(to, from, n);
16054 - else
16055 + if (unlikely(sz != (size_t)-1 && sz < n))
16056 + copy_to_user_overflow();
16057 + else if (access_ok(VERIFY_WRITE, to, n))
16058 + n = __copy_to_user(to, from, n);
16059 + return n;
16060 +}
16061 +
16062 +/**
16063 + * copy_from_user: - Copy a block of data from user space.
16064 + * @to: Destination address, in kernel space.
16065 + * @from: Source address, in user space.
16066 + * @n: Number of bytes to copy.
16067 + *
16068 + * Context: User context only. This function may sleep.
16069 + *
16070 + * Copy data from user space to kernel space.
16071 + *
16072 + * Returns number of bytes that could not be copied.
16073 + * On success, this will be zero.
16074 + *
16075 + * If some data could not be copied, this function will pad the copied
16076 + * data to the requested size using zero bytes.
16077 + */
16078 +static inline unsigned long __must_check
16079 +copy_from_user(void *to, const void __user *from, unsigned long n)
16080 +{
16081 + size_t sz = __compiletime_object_size(to);
16082 +
16083 + check_object_size(to, n, false);
16084 +
16085 + if (unlikely(sz != (size_t)-1 && sz < n))
16086 copy_from_user_overflow();
16087 -
16088 + else if (access_ok(VERIFY_READ, from, n))
16089 + n = __copy_from_user(to, from, n);
16090 + else if ((long)n > 0)
16091 + memset(to, 0, n);
16092 return n;
16093 }
16094
16095 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16096 index 142810c..1f2a0a7 100644
16097 --- a/arch/x86/include/asm/uaccess_64.h
16098 +++ b/arch/x86/include/asm/uaccess_64.h
16099 @@ -10,6 +10,9 @@
16100 #include <asm/alternative.h>
16101 #include <asm/cpufeature.h>
16102 #include <asm/page.h>
16103 +#include <asm/pgtable.h>
16104 +
16105 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16106
16107 /*
16108 * Copy To/From Userspace
16109 @@ -17,13 +20,13 @@
16110
16111 /* Handles exceptions in both to and from, but doesn't do access_ok */
16112 __must_check unsigned long
16113 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16114 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16115 __must_check unsigned long
16116 -copy_user_generic_string(void *to, const void *from, unsigned len);
16117 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16118 __must_check unsigned long
16119 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16120 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16121
16122 -static __always_inline __must_check unsigned long
16123 +static __always_inline __must_check __size_overflow(3) unsigned long
16124 copy_user_generic(void *to, const void *from, unsigned len)
16125 {
16126 unsigned ret;
16127 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16128 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16129 "=d" (len)),
16130 "1" (to), "2" (from), "3" (len)
16131 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16132 + : "memory", "rcx", "r8", "r9", "r11");
16133 return ret;
16134 }
16135
16136 +static __always_inline __must_check unsigned long
16137 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16138 +static __always_inline __must_check unsigned long
16139 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16140 __must_check unsigned long
16141 -_copy_to_user(void __user *to, const void *from, unsigned len);
16142 -__must_check unsigned long
16143 -_copy_from_user(void *to, const void __user *from, unsigned len);
16144 -__must_check unsigned long
16145 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16146 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16147 +
16148 +extern void copy_to_user_overflow(void)
16149 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16150 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16151 +#else
16152 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16153 +#endif
16154 +;
16155 +
16156 +extern void copy_from_user_overflow(void)
16157 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16158 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16159 +#else
16160 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16161 +#endif
16162 +;
16163
16164 static inline unsigned long __must_check copy_from_user(void *to,
16165 const void __user *from,
16166 unsigned long n)
16167 {
16168 - int sz = __compiletime_object_size(to);
16169 -
16170 might_fault();
16171 - if (likely(sz == -1 || sz >= n))
16172 - n = _copy_from_user(to, from, n);
16173 -#ifdef CONFIG_DEBUG_VM
16174 - else
16175 - WARN(1, "Buffer overflow detected!\n");
16176 -#endif
16177 +
16178 + check_object_size(to, n, false);
16179 +
16180 + if (access_ok(VERIFY_READ, from, n))
16181 + n = __copy_from_user(to, from, n);
16182 + else if (n < INT_MAX)
16183 + memset(to, 0, n);
16184 return n;
16185 }
16186
16187 static __always_inline __must_check
16188 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16189 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16190 {
16191 might_fault();
16192
16193 - return _copy_to_user(dst, src, size);
16194 + if (access_ok(VERIFY_WRITE, dst, size))
16195 + size = __copy_to_user(dst, src, size);
16196 + return size;
16197 }
16198
16199 static __always_inline __must_check
16200 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16201 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16202 {
16203 - int ret = 0;
16204 + size_t sz = __compiletime_object_size(dst);
16205 + unsigned ret = 0;
16206
16207 might_fault();
16208 +
16209 + if (size > INT_MAX)
16210 + return size;
16211 +
16212 + check_object_size(dst, size, false);
16213 +
16214 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16215 + if (!__access_ok(VERIFY_READ, src, size))
16216 + return size;
16217 +#endif
16218 +
16219 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16220 + copy_from_user_overflow();
16221 + return size;
16222 + }
16223 +
16224 if (!__builtin_constant_p(size))
16225 - return copy_user_generic(dst, (__force void *)src, size);
16226 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16227 switch (size) {
16228 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16229 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16230 ret, "b", "b", "=q", 1);
16231 return ret;
16232 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16233 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16234 ret, "w", "w", "=r", 2);
16235 return ret;
16236 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16237 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16238 ret, "l", "k", "=r", 4);
16239 return ret;
16240 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16241 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16242 ret, "q", "", "=r", 8);
16243 return ret;
16244 case 10:
16245 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16246 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16247 ret, "q", "", "=r", 10);
16248 if (unlikely(ret))
16249 return ret;
16250 __get_user_asm(*(u16 *)(8 + (char *)dst),
16251 - (u16 __user *)(8 + (char __user *)src),
16252 + (const u16 __user *)(8 + (const char __user *)src),
16253 ret, "w", "w", "=r", 2);
16254 return ret;
16255 case 16:
16256 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16257 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16258 ret, "q", "", "=r", 16);
16259 if (unlikely(ret))
16260 return ret;
16261 __get_user_asm(*(u64 *)(8 + (char *)dst),
16262 - (u64 __user *)(8 + (char __user *)src),
16263 + (const u64 __user *)(8 + (const char __user *)src),
16264 ret, "q", "", "=r", 8);
16265 return ret;
16266 default:
16267 - return copy_user_generic(dst, (__force void *)src, size);
16268 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16269 }
16270 }
16271
16272 static __always_inline __must_check
16273 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16274 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16275 {
16276 - int ret = 0;
16277 + size_t sz = __compiletime_object_size(src);
16278 + unsigned ret = 0;
16279
16280 might_fault();
16281 +
16282 + if (size > INT_MAX)
16283 + return size;
16284 +
16285 + check_object_size(src, size, true);
16286 +
16287 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16288 + if (!__access_ok(VERIFY_WRITE, dst, size))
16289 + return size;
16290 +#endif
16291 +
16292 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16293 + copy_to_user_overflow();
16294 + return size;
16295 + }
16296 +
16297 if (!__builtin_constant_p(size))
16298 - return copy_user_generic((__force void *)dst, src, size);
16299 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16300 switch (size) {
16301 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16302 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16303 ret, "b", "b", "iq", 1);
16304 return ret;
16305 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16306 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16307 ret, "w", "w", "ir", 2);
16308 return ret;
16309 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16310 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16311 ret, "l", "k", "ir", 4);
16312 return ret;
16313 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16314 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16315 ret, "q", "", "er", 8);
16316 return ret;
16317 case 10:
16318 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16319 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16320 ret, "q", "", "er", 10);
16321 if (unlikely(ret))
16322 return ret;
16323 asm("":::"memory");
16324 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16325 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16326 ret, "w", "w", "ir", 2);
16327 return ret;
16328 case 16:
16329 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16330 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16331 ret, "q", "", "er", 16);
16332 if (unlikely(ret))
16333 return ret;
16334 asm("":::"memory");
16335 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16336 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16337 ret, "q", "", "er", 8);
16338 return ret;
16339 default:
16340 - return copy_user_generic((__force void *)dst, src, size);
16341 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16342 }
16343 }
16344
16345 static __always_inline __must_check
16346 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16347 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16348 {
16349 - int ret = 0;
16350 + unsigned ret = 0;
16351
16352 might_fault();
16353 +
16354 + if (size > INT_MAX)
16355 + return size;
16356 +
16357 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16358 + if (!__access_ok(VERIFY_READ, src, size))
16359 + return size;
16360 + if (!__access_ok(VERIFY_WRITE, dst, size))
16361 + return size;
16362 +#endif
16363 +
16364 if (!__builtin_constant_p(size))
16365 - return copy_user_generic((__force void *)dst,
16366 - (__force void *)src, size);
16367 + return copy_user_generic((__force_kernel void *)____m(dst),
16368 + (__force_kernel const void *)____m(src), size);
16369 switch (size) {
16370 case 1: {
16371 u8 tmp;
16372 - __get_user_asm(tmp, (u8 __user *)src,
16373 + __get_user_asm(tmp, (const u8 __user *)src,
16374 ret, "b", "b", "=q", 1);
16375 if (likely(!ret))
16376 __put_user_asm(tmp, (u8 __user *)dst,
16377 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16378 }
16379 case 2: {
16380 u16 tmp;
16381 - __get_user_asm(tmp, (u16 __user *)src,
16382 + __get_user_asm(tmp, (const u16 __user *)src,
16383 ret, "w", "w", "=r", 2);
16384 if (likely(!ret))
16385 __put_user_asm(tmp, (u16 __user *)dst,
16386 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16387
16388 case 4: {
16389 u32 tmp;
16390 - __get_user_asm(tmp, (u32 __user *)src,
16391 + __get_user_asm(tmp, (const u32 __user *)src,
16392 ret, "l", "k", "=r", 4);
16393 if (likely(!ret))
16394 __put_user_asm(tmp, (u32 __user *)dst,
16395 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16396 }
16397 case 8: {
16398 u64 tmp;
16399 - __get_user_asm(tmp, (u64 __user *)src,
16400 + __get_user_asm(tmp, (const u64 __user *)src,
16401 ret, "q", "", "=r", 8);
16402 if (likely(!ret))
16403 __put_user_asm(tmp, (u64 __user *)dst,
16404 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16405 return ret;
16406 }
16407 default:
16408 - return copy_user_generic((__force void *)dst,
16409 - (__force void *)src, size);
16410 + return copy_user_generic((__force_kernel void *)____m(dst),
16411 + (__force_kernel const void *)____m(src), size);
16412 }
16413 }
16414
16415 static __must_check __always_inline int
16416 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16417 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16418 {
16419 - return copy_user_generic(dst, (__force const void *)src, size);
16420 + if (size > INT_MAX)
16421 + return size;
16422 +
16423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16424 + if (!__access_ok(VERIFY_READ, src, size))
16425 + return size;
16426 +#endif
16427 +
16428 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16429 }
16430
16431 -static __must_check __always_inline int
16432 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16433 +static __must_check __always_inline unsigned long
16434 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16435 {
16436 - return copy_user_generic((__force void *)dst, src, size);
16437 + if (size > INT_MAX)
16438 + return size;
16439 +
16440 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16441 + if (!__access_ok(VERIFY_WRITE, dst, size))
16442 + return size;
16443 +#endif
16444 +
16445 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16446 }
16447
16448 -extern long __copy_user_nocache(void *dst, const void __user *src,
16449 - unsigned size, int zerorest);
16450 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16451 + unsigned long size, int zerorest) __size_overflow(3);
16452
16453 -static inline int
16454 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16455 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16456 {
16457 might_sleep();
16458 +
16459 + if (size > INT_MAX)
16460 + return size;
16461 +
16462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16463 + if (!__access_ok(VERIFY_READ, src, size))
16464 + return size;
16465 +#endif
16466 +
16467 return __copy_user_nocache(dst, src, size, 1);
16468 }
16469
16470 -static inline int
16471 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16472 - unsigned size)
16473 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16474 + unsigned long size)
16475 {
16476 + if (size > INT_MAX)
16477 + return size;
16478 +
16479 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16480 + if (!__access_ok(VERIFY_READ, src, size))
16481 + return size;
16482 +#endif
16483 +
16484 return __copy_user_nocache(dst, src, size, 0);
16485 }
16486
16487 -unsigned long
16488 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16489 +extern unsigned long
16490 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16491
16492 #endif /* _ASM_X86_UACCESS_64_H */
16493 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16494 index 5b238981..77fdd78 100644
16495 --- a/arch/x86/include/asm/word-at-a-time.h
16496 +++ b/arch/x86/include/asm/word-at-a-time.h
16497 @@ -11,7 +11,7 @@
16498 * and shift, for example.
16499 */
16500 struct word_at_a_time {
16501 - const unsigned long one_bits, high_bits;
16502 + unsigned long one_bits, high_bits;
16503 };
16504
16505 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16506 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16507 index d8d9922..bf6cecb 100644
16508 --- a/arch/x86/include/asm/x86_init.h
16509 +++ b/arch/x86/include/asm/x86_init.h
16510 @@ -129,7 +129,7 @@ struct x86_init_ops {
16511 struct x86_init_timers timers;
16512 struct x86_init_iommu iommu;
16513 struct x86_init_pci pci;
16514 -};
16515 +} __no_const;
16516
16517 /**
16518 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16519 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16520 void (*setup_percpu_clockev)(void);
16521 void (*early_percpu_clock_init)(void);
16522 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16523 -};
16524 +} __no_const;
16525
16526 /**
16527 * struct x86_platform_ops - platform specific runtime functions
16528 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16529 void (*save_sched_clock_state)(void);
16530 void (*restore_sched_clock_state)(void);
16531 void (*apic_post_init)(void);
16532 -};
16533 +} __no_const;
16534
16535 struct pci_dev;
16536 struct msi_msg;
16537 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16538 void (*teardown_msi_irqs)(struct pci_dev *dev);
16539 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16540 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16541 -};
16542 +} __no_const;
16543
16544 struct IO_APIC_route_entry;
16545 struct io_apic_irq_attr;
16546 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16547 unsigned int destination, int vector,
16548 struct io_apic_irq_attr *attr);
16549 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16550 -};
16551 +} __no_const;
16552
16553 extern struct x86_init_ops x86_init;
16554 extern struct x86_cpuinit_ops x86_cpuinit;
16555 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16556 index 0415cda..b43d877 100644
16557 --- a/arch/x86/include/asm/xsave.h
16558 +++ b/arch/x86/include/asm/xsave.h
16559 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16560 return -EFAULT;
16561
16562 __asm__ __volatile__(ASM_STAC "\n"
16563 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16564 + "1:"
16565 + __copyuser_seg
16566 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16567 "2: " ASM_CLAC "\n"
16568 ".section .fixup,\"ax\"\n"
16569 "3: movl $-1,%[err]\n"
16570 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16571 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16572 {
16573 int err;
16574 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16575 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16576 u32 lmask = mask;
16577 u32 hmask = mask >> 32;
16578
16579 __asm__ __volatile__(ASM_STAC "\n"
16580 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16581 + "1:"
16582 + __copyuser_seg
16583 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16584 "2: " ASM_CLAC "\n"
16585 ".section .fixup,\"ax\"\n"
16586 "3: movl $-1,%[err]\n"
16587 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16588 index bbae024..e1528f9 100644
16589 --- a/arch/x86/include/uapi/asm/e820.h
16590 +++ b/arch/x86/include/uapi/asm/e820.h
16591 @@ -63,7 +63,7 @@ struct e820map {
16592 #define ISA_START_ADDRESS 0xa0000
16593 #define ISA_END_ADDRESS 0x100000
16594
16595 -#define BIOS_BEGIN 0x000a0000
16596 +#define BIOS_BEGIN 0x000c0000
16597 #define BIOS_END 0x00100000
16598
16599 #define BIOS_ROM_BASE 0xffe00000
16600 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16601 index 7bd3bd3..5dac791 100644
16602 --- a/arch/x86/kernel/Makefile
16603 +++ b/arch/x86/kernel/Makefile
16604 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16605 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16606 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16607 obj-y += probe_roms.o
16608 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16609 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16610 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16611 obj-y += syscall_$(BITS).o
16612 obj-$(CONFIG_X86_64) += vsyscall_64.o
16613 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16614 index 230c8ea..f915130 100644
16615 --- a/arch/x86/kernel/acpi/boot.c
16616 +++ b/arch/x86/kernel/acpi/boot.c
16617 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16618 * If your system is blacklisted here, but you find that acpi=force
16619 * works for you, please contact linux-acpi@vger.kernel.org
16620 */
16621 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16622 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16623 /*
16624 * Boxes that need ACPI disabled
16625 */
16626 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16627 };
16628
16629 /* second table for DMI checks that should run after early-quirks */
16630 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16631 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16632 /*
16633 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16634 * which includes some code which overrides all temperature
16635 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16636 index b44577b..27d8443 100644
16637 --- a/arch/x86/kernel/acpi/sleep.c
16638 +++ b/arch/x86/kernel/acpi/sleep.c
16639 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16640 #else /* CONFIG_64BIT */
16641 #ifdef CONFIG_SMP
16642 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16643 +
16644 + pax_open_kernel();
16645 early_gdt_descr.address =
16646 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16647 + pax_close_kernel();
16648 +
16649 initial_gs = per_cpu_offset(smp_processor_id());
16650 #endif
16651 initial_code = (unsigned long)wakeup_long64;
16652 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16653 index d1daa66..59fecba 100644
16654 --- a/arch/x86/kernel/acpi/wakeup_32.S
16655 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16656 @@ -29,13 +29,11 @@ wakeup_pmode_return:
16657 # and restore the stack ... but you need gdt for this to work
16658 movl saved_context_esp, %esp
16659
16660 - movl %cs:saved_magic, %eax
16661 - cmpl $0x12345678, %eax
16662 + cmpl $0x12345678, saved_magic
16663 jne bogus_magic
16664
16665 # jump to place where we left off
16666 - movl saved_eip, %eax
16667 - jmp *%eax
16668 + jmp *(saved_eip)
16669
16670 bogus_magic:
16671 jmp bogus_magic
16672 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16673 index c15cf9a..0e63558 100644
16674 --- a/arch/x86/kernel/alternative.c
16675 +++ b/arch/x86/kernel/alternative.c
16676 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16677 */
16678 for (a = start; a < end; a++) {
16679 instr = (u8 *)&a->instr_offset + a->instr_offset;
16680 +
16681 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16682 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16683 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16684 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16685 +#endif
16686 +
16687 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16688 BUG_ON(a->replacementlen > a->instrlen);
16689 BUG_ON(a->instrlen > sizeof(insnbuf));
16690 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16691 for (poff = start; poff < end; poff++) {
16692 u8 *ptr = (u8 *)poff + *poff;
16693
16694 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16695 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16696 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16697 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16698 +#endif
16699 +
16700 if (!*poff || ptr < text || ptr >= text_end)
16701 continue;
16702 /* turn DS segment override prefix into lock prefix */
16703 - if (*ptr == 0x3e)
16704 + if (*ktla_ktva(ptr) == 0x3e)
16705 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16706 }
16707 mutex_unlock(&text_mutex);
16708 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16709 for (poff = start; poff < end; poff++) {
16710 u8 *ptr = (u8 *)poff + *poff;
16711
16712 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16713 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16714 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16715 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16716 +#endif
16717 +
16718 if (!*poff || ptr < text || ptr >= text_end)
16719 continue;
16720 /* turn lock prefix into DS segment override prefix */
16721 - if (*ptr == 0xf0)
16722 + if (*ktla_ktva(ptr) == 0xf0)
16723 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16724 }
16725 mutex_unlock(&text_mutex);
16726 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16727
16728 BUG_ON(p->len > MAX_PATCH_LEN);
16729 /* prep the buffer with the original instructions */
16730 - memcpy(insnbuf, p->instr, p->len);
16731 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16732 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16733 (unsigned long)p->instr, p->len);
16734
16735 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16736 if (!uniproc_patched || num_possible_cpus() == 1)
16737 free_init_pages("SMP alternatives",
16738 (unsigned long)__smp_locks,
16739 - (unsigned long)__smp_locks_end);
16740 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16741 #endif
16742
16743 apply_paravirt(__parainstructions, __parainstructions_end);
16744 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16745 * instructions. And on the local CPU you need to be protected again NMI or MCE
16746 * handlers seeing an inconsistent instruction while you patch.
16747 */
16748 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16749 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16750 size_t len)
16751 {
16752 unsigned long flags;
16753 local_irq_save(flags);
16754 - memcpy(addr, opcode, len);
16755 +
16756 + pax_open_kernel();
16757 + memcpy(ktla_ktva(addr), opcode, len);
16758 sync_core();
16759 + pax_close_kernel();
16760 +
16761 local_irq_restore(flags);
16762 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16763 that causes hangs on some VIA CPUs. */
16764 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16765 */
16766 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16767 {
16768 - unsigned long flags;
16769 - char *vaddr;
16770 + unsigned char *vaddr = ktla_ktva(addr);
16771 struct page *pages[2];
16772 - int i;
16773 + size_t i;
16774
16775 if (!core_kernel_text((unsigned long)addr)) {
16776 - pages[0] = vmalloc_to_page(addr);
16777 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16778 + pages[0] = vmalloc_to_page(vaddr);
16779 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16780 } else {
16781 - pages[0] = virt_to_page(addr);
16782 + pages[0] = virt_to_page(vaddr);
16783 WARN_ON(!PageReserved(pages[0]));
16784 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16785 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16786 }
16787 BUG_ON(!pages[0]);
16788 - local_irq_save(flags);
16789 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16790 - if (pages[1])
16791 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16792 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16793 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16794 - clear_fixmap(FIX_TEXT_POKE0);
16795 - if (pages[1])
16796 - clear_fixmap(FIX_TEXT_POKE1);
16797 - local_flush_tlb();
16798 - sync_core();
16799 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16800 - that causes hangs on some VIA CPUs. */
16801 + text_poke_early(addr, opcode, len);
16802 for (i = 0; i < len; i++)
16803 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16804 - local_irq_restore(flags);
16805 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16806 return addr;
16807 }
16808
16809 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16810 index 904611b..004dde6 100644
16811 --- a/arch/x86/kernel/apic/apic.c
16812 +++ b/arch/x86/kernel/apic/apic.c
16813 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16814 /*
16815 * Debug level, exported for io_apic.c
16816 */
16817 -unsigned int apic_verbosity;
16818 +int apic_verbosity;
16819
16820 int pic_mode;
16821
16822 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16823 apic_write(APIC_ESR, 0);
16824 v1 = apic_read(APIC_ESR);
16825 ack_APIC_irq();
16826 - atomic_inc(&irq_err_count);
16827 + atomic_inc_unchecked(&irq_err_count);
16828
16829 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16830 smp_processor_id(), v0 , v1);
16831 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16832 index 00c77cf..2dc6a2d 100644
16833 --- a/arch/x86/kernel/apic/apic_flat_64.c
16834 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16835 @@ -157,7 +157,7 @@ static int flat_probe(void)
16836 return 1;
16837 }
16838
16839 -static struct apic apic_flat = {
16840 +static struct apic apic_flat __read_only = {
16841 .name = "flat",
16842 .probe = flat_probe,
16843 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16844 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16845 return 0;
16846 }
16847
16848 -static struct apic apic_physflat = {
16849 +static struct apic apic_physflat __read_only = {
16850
16851 .name = "physical flat",
16852 .probe = physflat_probe,
16853 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16854 index e145f28..2752888 100644
16855 --- a/arch/x86/kernel/apic/apic_noop.c
16856 +++ b/arch/x86/kernel/apic/apic_noop.c
16857 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16858 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16859 }
16860
16861 -struct apic apic_noop = {
16862 +struct apic apic_noop __read_only = {
16863 .name = "noop",
16864 .probe = noop_probe,
16865 .acpi_madt_oem_check = NULL,
16866 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16867 index d50e364..543bee3 100644
16868 --- a/arch/x86/kernel/apic/bigsmp_32.c
16869 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16870 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16871 return dmi_bigsmp;
16872 }
16873
16874 -static struct apic apic_bigsmp = {
16875 +static struct apic apic_bigsmp __read_only = {
16876
16877 .name = "bigsmp",
16878 .probe = probe_bigsmp,
16879 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16880 index 0874799..a7a7892 100644
16881 --- a/arch/x86/kernel/apic/es7000_32.c
16882 +++ b/arch/x86/kernel/apic/es7000_32.c
16883 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16884 return ret && es7000_apic_is_cluster();
16885 }
16886
16887 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16888 -static struct apic __refdata apic_es7000_cluster = {
16889 +static struct apic apic_es7000_cluster __read_only = {
16890
16891 .name = "es7000",
16892 .probe = probe_es7000,
16893 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16894 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16895 };
16896
16897 -static struct apic __refdata apic_es7000 = {
16898 +static struct apic apic_es7000 __read_only = {
16899
16900 .name = "es7000",
16901 .probe = probe_es7000,
16902 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16903 index 9ed796c..e930fe4 100644
16904 --- a/arch/x86/kernel/apic/io_apic.c
16905 +++ b/arch/x86/kernel/apic/io_apic.c
16906 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16907 }
16908 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16909
16910 -void lock_vector_lock(void)
16911 +void lock_vector_lock(void) __acquires(vector_lock)
16912 {
16913 /* Used to the online set of cpus does not change
16914 * during assign_irq_vector.
16915 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16916 raw_spin_lock(&vector_lock);
16917 }
16918
16919 -void unlock_vector_lock(void)
16920 +void unlock_vector_lock(void) __releases(vector_lock)
16921 {
16922 raw_spin_unlock(&vector_lock);
16923 }
16924 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16925 ack_APIC_irq();
16926 }
16927
16928 -atomic_t irq_mis_count;
16929 +atomic_unchecked_t irq_mis_count;
16930
16931 #ifdef CONFIG_GENERIC_PENDING_IRQ
16932 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16933 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16934 * at the cpu.
16935 */
16936 if (!(v & (1 << (i & 0x1f)))) {
16937 - atomic_inc(&irq_mis_count);
16938 + atomic_inc_unchecked(&irq_mis_count);
16939
16940 eoi_ioapic_irq(irq, cfg);
16941 }
16942 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16943 index d661ee9..791fd33 100644
16944 --- a/arch/x86/kernel/apic/numaq_32.c
16945 +++ b/arch/x86/kernel/apic/numaq_32.c
16946 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16947 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16948 }
16949
16950 -/* Use __refdata to keep false positive warning calm. */
16951 -static struct apic __refdata apic_numaq = {
16952 +static struct apic apic_numaq __read_only = {
16953
16954 .name = "NUMAQ",
16955 .probe = probe_numaq,
16956 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16957 index eb35ef9..f184a21 100644
16958 --- a/arch/x86/kernel/apic/probe_32.c
16959 +++ b/arch/x86/kernel/apic/probe_32.c
16960 @@ -72,7 +72,7 @@ static int probe_default(void)
16961 return 1;
16962 }
16963
16964 -static struct apic apic_default = {
16965 +static struct apic apic_default __read_only = {
16966
16967 .name = "default",
16968 .probe = probe_default,
16969 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16970 index 77c95c0..434f8a4 100644
16971 --- a/arch/x86/kernel/apic/summit_32.c
16972 +++ b/arch/x86/kernel/apic/summit_32.c
16973 @@ -486,7 +486,7 @@ void setup_summit(void)
16974 }
16975 #endif
16976
16977 -static struct apic apic_summit = {
16978 +static struct apic apic_summit __read_only = {
16979
16980 .name = "summit",
16981 .probe = probe_summit,
16982 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16983 index c88baa4..757aee1 100644
16984 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16985 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16986 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16987 return notifier_from_errno(err);
16988 }
16989
16990 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16991 +static struct notifier_block x2apic_cpu_notifier = {
16992 .notifier_call = update_clusterinfo,
16993 };
16994
16995 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16996 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16997 }
16998
16999 -static struct apic apic_x2apic_cluster = {
17000 +static struct apic apic_x2apic_cluster __read_only = {
17001
17002 .name = "cluster x2apic",
17003 .probe = x2apic_cluster_probe,
17004 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17005 index 562a76d..a003c0f 100644
17006 --- a/arch/x86/kernel/apic/x2apic_phys.c
17007 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17008 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17009 return apic == &apic_x2apic_phys;
17010 }
17011
17012 -static struct apic apic_x2apic_phys = {
17013 +static struct apic apic_x2apic_phys __read_only = {
17014
17015 .name = "physical x2apic",
17016 .probe = x2apic_phys_probe,
17017 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17018 index 794f6eb..67e1db2 100644
17019 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17020 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17021 @@ -342,7 +342,7 @@ static int uv_probe(void)
17022 return apic == &apic_x2apic_uv_x;
17023 }
17024
17025 -static struct apic __refdata apic_x2apic_uv_x = {
17026 +static struct apic apic_x2apic_uv_x __read_only = {
17027
17028 .name = "UV large system",
17029 .probe = uv_probe,
17030 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17031 index 53a4e27..038760a 100644
17032 --- a/arch/x86/kernel/apm_32.c
17033 +++ b/arch/x86/kernel/apm_32.c
17034 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
17035 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17036 * even though they are called in protected mode.
17037 */
17038 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17039 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17040 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17041
17042 static const char driver_version[] = "1.16ac"; /* no spaces */
17043 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
17044 BUG_ON(cpu != 0);
17045 gdt = get_cpu_gdt_table(cpu);
17046 save_desc_40 = gdt[0x40 / 8];
17047 +
17048 + pax_open_kernel();
17049 gdt[0x40 / 8] = bad_bios_desc;
17050 + pax_close_kernel();
17051
17052 apm_irq_save(flags);
17053 APM_DO_SAVE_SEGS;
17054 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
17055 &call->esi);
17056 APM_DO_RESTORE_SEGS;
17057 apm_irq_restore(flags);
17058 +
17059 + pax_open_kernel();
17060 gdt[0x40 / 8] = save_desc_40;
17061 + pax_close_kernel();
17062 +
17063 put_cpu();
17064
17065 return call->eax & 0xff;
17066 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
17067 BUG_ON(cpu != 0);
17068 gdt = get_cpu_gdt_table(cpu);
17069 save_desc_40 = gdt[0x40 / 8];
17070 +
17071 + pax_open_kernel();
17072 gdt[0x40 / 8] = bad_bios_desc;
17073 + pax_close_kernel();
17074
17075 apm_irq_save(flags);
17076 APM_DO_SAVE_SEGS;
17077 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
17078 &call->eax);
17079 APM_DO_RESTORE_SEGS;
17080 apm_irq_restore(flags);
17081 +
17082 + pax_open_kernel();
17083 gdt[0x40 / 8] = save_desc_40;
17084 + pax_close_kernel();
17085 +
17086 put_cpu();
17087 return error;
17088 }
17089 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
17090 * code to that CPU.
17091 */
17092 gdt = get_cpu_gdt_table(0);
17093 +
17094 + pax_open_kernel();
17095 set_desc_base(&gdt[APM_CS >> 3],
17096 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17097 set_desc_base(&gdt[APM_CS_16 >> 3],
17098 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17099 set_desc_base(&gdt[APM_DS >> 3],
17100 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17101 + pax_close_kernel();
17102
17103 proc_create("apm", 0, NULL, &apm_file_ops);
17104
17105 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17106 index 2861082..6d4718e 100644
17107 --- a/arch/x86/kernel/asm-offsets.c
17108 +++ b/arch/x86/kernel/asm-offsets.c
17109 @@ -33,6 +33,8 @@ void common(void) {
17110 OFFSET(TI_status, thread_info, status);
17111 OFFSET(TI_addr_limit, thread_info, addr_limit);
17112 OFFSET(TI_preempt_count, thread_info, preempt_count);
17113 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17114 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17115
17116 BLANK();
17117 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17118 @@ -53,8 +55,26 @@ void common(void) {
17119 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17120 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17121 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17122 +
17123 +#ifdef CONFIG_PAX_KERNEXEC
17124 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17125 #endif
17126
17127 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17128 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17129 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17130 +#ifdef CONFIG_X86_64
17131 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17132 +#endif
17133 +#endif
17134 +
17135 +#endif
17136 +
17137 + BLANK();
17138 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17139 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17140 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17141 +
17142 #ifdef CONFIG_XEN
17143 BLANK();
17144 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17145 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17146 index e7c798b..2b2019b 100644
17147 --- a/arch/x86/kernel/asm-offsets_64.c
17148 +++ b/arch/x86/kernel/asm-offsets_64.c
17149 @@ -77,6 +77,7 @@ int main(void)
17150 BLANK();
17151 #undef ENTRY
17152
17153 + DEFINE(TSS_size, sizeof(struct tss_struct));
17154 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17155 BLANK();
17156
17157 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17158 index b0684e4..22ccfd7 100644
17159 --- a/arch/x86/kernel/cpu/Makefile
17160 +++ b/arch/x86/kernel/cpu/Makefile
17161 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17162 CFLAGS_REMOVE_perf_event.o = -pg
17163 endif
17164
17165 -# Make sure load_percpu_segment has no stackprotector
17166 -nostackp := $(call cc-option, -fno-stack-protector)
17167 -CFLAGS_common.o := $(nostackp)
17168 -
17169 obj-y := intel_cacheinfo.o scattered.o topology.o
17170 obj-y += proc.o capflags.o powerflags.o common.o
17171 obj-y += rdrand.o
17172 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17173 index 5013a48..0782c53 100644
17174 --- a/arch/x86/kernel/cpu/amd.c
17175 +++ b/arch/x86/kernel/cpu/amd.c
17176 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17177 unsigned int size)
17178 {
17179 /* AMD errata T13 (order #21922) */
17180 - if ((c->x86 == 6)) {
17181 + if (c->x86 == 6) {
17182 /* Duron Rev A0 */
17183 if (c->x86_model == 3 && c->x86_mask == 0)
17184 size = 64;
17185 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17186 index 22018f7..bc6f5e3 100644
17187 --- a/arch/x86/kernel/cpu/common.c
17188 +++ b/arch/x86/kernel/cpu/common.c
17189 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17190
17191 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17192
17193 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17194 -#ifdef CONFIG_X86_64
17195 - /*
17196 - * We need valid kernel segments for data and code in long mode too
17197 - * IRET will check the segment types kkeil 2000/10/28
17198 - * Also sysret mandates a special GDT layout
17199 - *
17200 - * TLS descriptors are currently at a different place compared to i386.
17201 - * Hopefully nobody expects them at a fixed place (Wine?)
17202 - */
17203 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17204 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17205 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17206 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17207 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17208 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17209 -#else
17210 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17211 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17212 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17213 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17214 - /*
17215 - * Segments used for calling PnP BIOS have byte granularity.
17216 - * They code segments and data segments have fixed 64k limits,
17217 - * the transfer segment sizes are set at run time.
17218 - */
17219 - /* 32-bit code */
17220 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17221 - /* 16-bit code */
17222 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17223 - /* 16-bit data */
17224 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17225 - /* 16-bit data */
17226 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17227 - /* 16-bit data */
17228 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17229 - /*
17230 - * The APM segments have byte granularity and their bases
17231 - * are set at run time. All have 64k limits.
17232 - */
17233 - /* 32-bit code */
17234 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17235 - /* 16-bit code */
17236 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17237 - /* data */
17238 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17239 -
17240 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17241 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17242 - GDT_STACK_CANARY_INIT
17243 -#endif
17244 -} };
17245 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17246 -
17247 static int __init x86_xsave_setup(char *s)
17248 {
17249 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17250 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17251 {
17252 struct desc_ptr gdt_descr;
17253
17254 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17255 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17256 gdt_descr.size = GDT_SIZE - 1;
17257 load_gdt(&gdt_descr);
17258 /* Reload the per-cpu base */
17259 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17260 /* Filter out anything that depends on CPUID levels we don't have */
17261 filter_cpuid_features(c, true);
17262
17263 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17264 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17265 +#endif
17266 +
17267 /* If the model name is still unset, do table lookup. */
17268 if (!c->x86_model_id[0]) {
17269 const char *p;
17270 @@ -1069,10 +1019,12 @@ static __init int setup_disablecpuid(char *arg)
17271 }
17272 __setup("clearcpuid=", setup_disablecpuid);
17273
17274 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17275 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17276 +
17277 #ifdef CONFIG_X86_64
17278 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17279 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17280 - (unsigned long) nmi_idt_table };
17281 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17282
17283 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17284 irq_stack_union) __aligned(PAGE_SIZE);
17285 @@ -1086,7 +1038,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17286 EXPORT_PER_CPU_SYMBOL(current_task);
17287
17288 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17289 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17290 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17291 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17292
17293 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17294 @@ -1231,7 +1183,7 @@ void __cpuinit cpu_init(void)
17295 load_ucode_ap();
17296
17297 cpu = stack_smp_processor_id();
17298 - t = &per_cpu(init_tss, cpu);
17299 + t = init_tss + cpu;
17300 oist = &per_cpu(orig_ist, cpu);
17301
17302 #ifdef CONFIG_NUMA
17303 @@ -1257,7 +1209,7 @@ void __cpuinit cpu_init(void)
17304 switch_to_new_gdt(cpu);
17305 loadsegment(fs, 0);
17306
17307 - load_idt((const struct desc_ptr *)&idt_descr);
17308 + load_idt(&idt_descr);
17309
17310 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17311 syscall_init();
17312 @@ -1266,7 +1218,6 @@ void __cpuinit cpu_init(void)
17313 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17314 barrier();
17315
17316 - x86_configure_nx();
17317 enable_x2apic();
17318
17319 /*
17320 @@ -1318,7 +1269,7 @@ void __cpuinit cpu_init(void)
17321 {
17322 int cpu = smp_processor_id();
17323 struct task_struct *curr = current;
17324 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17325 + struct tss_struct *t = init_tss + cpu;
17326 struct thread_struct *thread = &curr->thread;
17327
17328 show_ucode_info_early();
17329 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17330 index 7c6f7d5..8cac382 100644
17331 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17332 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17333 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17334 };
17335
17336 #ifdef CONFIG_AMD_NB
17337 +static struct attribute *default_attrs_amd_nb[] = {
17338 + &type.attr,
17339 + &level.attr,
17340 + &coherency_line_size.attr,
17341 + &physical_line_partition.attr,
17342 + &ways_of_associativity.attr,
17343 + &number_of_sets.attr,
17344 + &size.attr,
17345 + &shared_cpu_map.attr,
17346 + &shared_cpu_list.attr,
17347 + NULL,
17348 + NULL,
17349 + NULL,
17350 + NULL
17351 +};
17352 +
17353 static struct attribute ** __cpuinit amd_l3_attrs(void)
17354 {
17355 static struct attribute **attrs;
17356 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17357
17358 n = ARRAY_SIZE(default_attrs);
17359
17360 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17361 - n += 2;
17362 -
17363 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17364 - n += 1;
17365 -
17366 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17367 - if (attrs == NULL)
17368 - return attrs = default_attrs;
17369 -
17370 - for (n = 0; default_attrs[n]; n++)
17371 - attrs[n] = default_attrs[n];
17372 + attrs = default_attrs_amd_nb;
17373
17374 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17375 attrs[n++] = &cache_disable_0.attr;
17376 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17377 .default_attrs = default_attrs,
17378 };
17379
17380 +#ifdef CONFIG_AMD_NB
17381 +static struct kobj_type ktype_cache_amd_nb = {
17382 + .sysfs_ops = &sysfs_ops,
17383 + .default_attrs = default_attrs_amd_nb,
17384 +};
17385 +#endif
17386 +
17387 static struct kobj_type ktype_percpu_entry = {
17388 .sysfs_ops = &sysfs_ops,
17389 };
17390 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17391 return retval;
17392 }
17393
17394 +#ifdef CONFIG_AMD_NB
17395 + amd_l3_attrs();
17396 +#endif
17397 +
17398 for (i = 0; i < num_cache_leaves; i++) {
17399 + struct kobj_type *ktype;
17400 +
17401 this_object = INDEX_KOBJECT_PTR(cpu, i);
17402 this_object->cpu = cpu;
17403 this_object->index = i;
17404
17405 this_leaf = CPUID4_INFO_IDX(cpu, i);
17406
17407 - ktype_cache.default_attrs = default_attrs;
17408 + ktype = &ktype_cache;
17409 #ifdef CONFIG_AMD_NB
17410 if (this_leaf->base.nb)
17411 - ktype_cache.default_attrs = amd_l3_attrs();
17412 + ktype = &ktype_cache_amd_nb;
17413 #endif
17414 retval = kobject_init_and_add(&(this_object->kobj),
17415 - &ktype_cache,
17416 + ktype,
17417 per_cpu(ici_cache_kobject, cpu),
17418 "index%1lu", i);
17419 if (unlikely(retval)) {
17420 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17421 return NOTIFY_OK;
17422 }
17423
17424 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17425 +static struct notifier_block cacheinfo_cpu_notifier = {
17426 .notifier_call = cacheinfo_cpu_callback,
17427 };
17428
17429 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17430 index 9239504..b2471ce 100644
17431 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17432 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17433 @@ -45,6 +45,7 @@
17434 #include <asm/processor.h>
17435 #include <asm/mce.h>
17436 #include <asm/msr.h>
17437 +#include <asm/local.h>
17438
17439 #include "mce-internal.h"
17440
17441 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17442 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17443 m->cs, m->ip);
17444
17445 - if (m->cs == __KERNEL_CS)
17446 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17447 print_symbol("{%s}", m->ip);
17448 pr_cont("\n");
17449 }
17450 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17451
17452 #define PANIC_TIMEOUT 5 /* 5 seconds */
17453
17454 -static atomic_t mce_paniced;
17455 +static atomic_unchecked_t mce_paniced;
17456
17457 static int fake_panic;
17458 -static atomic_t mce_fake_paniced;
17459 +static atomic_unchecked_t mce_fake_paniced;
17460
17461 /* Panic in progress. Enable interrupts and wait for final IPI */
17462 static void wait_for_panic(void)
17463 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17464 /*
17465 * Make sure only one CPU runs in machine check panic
17466 */
17467 - if (atomic_inc_return(&mce_paniced) > 1)
17468 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17469 wait_for_panic();
17470 barrier();
17471
17472 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17473 console_verbose();
17474 } else {
17475 /* Don't log too much for fake panic */
17476 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17477 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17478 return;
17479 }
17480 /* First print corrected ones that are still unlogged */
17481 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17482 if (!fake_panic) {
17483 if (panic_timeout == 0)
17484 panic_timeout = mca_cfg.panic_timeout;
17485 - panic(msg);
17486 + panic("%s", msg);
17487 } else
17488 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17489 }
17490 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17491 * might have been modified by someone else.
17492 */
17493 rmb();
17494 - if (atomic_read(&mce_paniced))
17495 + if (atomic_read_unchecked(&mce_paniced))
17496 wait_for_panic();
17497 if (!mca_cfg.monarch_timeout)
17498 goto out;
17499 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17500 }
17501
17502 /* Call the installed machine check handler for this CPU setup. */
17503 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17504 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17505 unexpected_machine_check;
17506
17507 /*
17508 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17509 return;
17510 }
17511
17512 + pax_open_kernel();
17513 machine_check_vector = do_machine_check;
17514 + pax_close_kernel();
17515
17516 __mcheck_cpu_init_generic();
17517 __mcheck_cpu_init_vendor(c);
17518 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17519 */
17520
17521 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17522 -static int mce_chrdev_open_count; /* #times opened */
17523 +static local_t mce_chrdev_open_count; /* #times opened */
17524 static int mce_chrdev_open_exclu; /* already open exclusive? */
17525
17526 static int mce_chrdev_open(struct inode *inode, struct file *file)
17527 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17528 spin_lock(&mce_chrdev_state_lock);
17529
17530 if (mce_chrdev_open_exclu ||
17531 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17532 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17533 spin_unlock(&mce_chrdev_state_lock);
17534
17535 return -EBUSY;
17536 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17537
17538 if (file->f_flags & O_EXCL)
17539 mce_chrdev_open_exclu = 1;
17540 - mce_chrdev_open_count++;
17541 + local_inc(&mce_chrdev_open_count);
17542
17543 spin_unlock(&mce_chrdev_state_lock);
17544
17545 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17546 {
17547 spin_lock(&mce_chrdev_state_lock);
17548
17549 - mce_chrdev_open_count--;
17550 + local_dec(&mce_chrdev_open_count);
17551 mce_chrdev_open_exclu = 0;
17552
17553 spin_unlock(&mce_chrdev_state_lock);
17554 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17555 return NOTIFY_OK;
17556 }
17557
17558 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17559 +static struct notifier_block mce_cpu_notifier = {
17560 .notifier_call = mce_cpu_callback,
17561 };
17562
17563 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17564
17565 for (i = 0; i < mca_cfg.banks; i++) {
17566 struct mce_bank *b = &mce_banks[i];
17567 - struct device_attribute *a = &b->attr;
17568 + device_attribute_no_const *a = &b->attr;
17569
17570 sysfs_attr_init(&a->attr);
17571 a->attr.name = b->attrname;
17572 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17573 static void mce_reset(void)
17574 {
17575 cpu_missing = 0;
17576 - atomic_set(&mce_fake_paniced, 0);
17577 + atomic_set_unchecked(&mce_fake_paniced, 0);
17578 atomic_set(&mce_executing, 0);
17579 atomic_set(&mce_callin, 0);
17580 atomic_set(&global_nwo, 0);
17581 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17582 index 1c044b1..37a2a43 100644
17583 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17584 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17585 @@ -11,6 +11,7 @@
17586 #include <asm/processor.h>
17587 #include <asm/mce.h>
17588 #include <asm/msr.h>
17589 +#include <asm/pgtable.h>
17590
17591 /* By default disabled */
17592 int mce_p5_enabled __read_mostly;
17593 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17594 if (!cpu_has(c, X86_FEATURE_MCE))
17595 return;
17596
17597 + pax_open_kernel();
17598 machine_check_vector = pentium_machine_check;
17599 + pax_close_kernel();
17600 /* Make sure the vector pointer is visible before we enable MCEs: */
17601 wmb();
17602
17603 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17604 index 47a1870..8c019a7 100644
17605 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17606 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17607 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17608 return notifier_from_errno(err);
17609 }
17610
17611 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17612 +static struct notifier_block thermal_throttle_cpu_notifier =
17613 {
17614 .notifier_call = thermal_throttle_cpu_callback,
17615 };
17616 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17617 index e9a701a..35317d6 100644
17618 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17619 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17620 @@ -10,6 +10,7 @@
17621 #include <asm/processor.h>
17622 #include <asm/mce.h>
17623 #include <asm/msr.h>
17624 +#include <asm/pgtable.h>
17625
17626 /* Machine check handler for WinChip C6: */
17627 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17628 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17629 {
17630 u32 lo, hi;
17631
17632 + pax_open_kernel();
17633 machine_check_vector = winchip_machine_check;
17634 + pax_close_kernel();
17635 /* Make sure the vector pointer is visible before we enable MCEs: */
17636 wmb();
17637
17638 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17639 index 726bf96..81f0526 100644
17640 --- a/arch/x86/kernel/cpu/mtrr/main.c
17641 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17642 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17643 u64 size_or_mask, size_and_mask;
17644 static bool mtrr_aps_delayed_init;
17645
17646 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17647 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17648
17649 const struct mtrr_ops *mtrr_if;
17650
17651 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17652 index df5e41f..816c719 100644
17653 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17654 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17655 @@ -25,7 +25,7 @@ struct mtrr_ops {
17656 int (*validate_add_page)(unsigned long base, unsigned long size,
17657 unsigned int type);
17658 int (*have_wrcomb)(void);
17659 -};
17660 +} __do_const;
17661
17662 extern int generic_get_free_region(unsigned long base, unsigned long size,
17663 int replace_reg);
17664 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17665 index 1025f3c..824f677 100644
17666 --- a/arch/x86/kernel/cpu/perf_event.c
17667 +++ b/arch/x86/kernel/cpu/perf_event.c
17668 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
17669 pr_info("no hardware sampling interrupt available.\n");
17670 }
17671
17672 -static struct attribute_group x86_pmu_format_group = {
17673 +static attribute_group_no_const x86_pmu_format_group = {
17674 .name = "format",
17675 .attrs = NULL,
17676 };
17677 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
17678 NULL,
17679 };
17680
17681 -static struct attribute_group x86_pmu_events_group = {
17682 +static attribute_group_no_const x86_pmu_events_group = {
17683 .name = "events",
17684 .attrs = events_attr,
17685 };
17686 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
17687 if (idx > GDT_ENTRIES)
17688 return 0;
17689
17690 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17691 + desc = get_cpu_gdt_table(smp_processor_id());
17692 }
17693
17694 return get_desc_base(desc + idx);
17695 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17696 break;
17697
17698 perf_callchain_store(entry, frame.return_address);
17699 - fp = frame.next_frame;
17700 + fp = (const void __force_user *)frame.next_frame;
17701 }
17702 }
17703
17704 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17705 index a9e2207..d70c83a 100644
17706 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17707 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17708 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
17709 * v2 and above have a perf capabilities MSR
17710 */
17711 if (version > 1) {
17712 - u64 capabilities;
17713 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17714
17715 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17716 - x86_pmu.intel_cap.capabilities = capabilities;
17717 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17718 + x86_pmu.intel_cap.capabilities = capabilities;
17719 }
17720
17721 intel_ds_init();
17722 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17723 index 52441a2..f94fae8 100644
17724 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17725 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17726 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17727 static int __init uncore_type_init(struct intel_uncore_type *type)
17728 {
17729 struct intel_uncore_pmu *pmus;
17730 - struct attribute_group *attr_group;
17731 + attribute_group_no_const *attr_group;
17732 struct attribute **attrs;
17733 int i, j;
17734
17735 @@ -3518,7 +3518,7 @@ static int
17736 return NOTIFY_OK;
17737 }
17738
17739 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17740 +static struct notifier_block uncore_cpu_nb = {
17741 .notifier_call = uncore_cpu_notifier,
17742 /*
17743 * to migrate uncore events, our notifier should be executed
17744 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17745 index f952891..4722ad4 100644
17746 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17747 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17748 @@ -488,7 +488,7 @@ struct intel_uncore_box {
17749 struct uncore_event_desc {
17750 struct kobj_attribute attr;
17751 const char *config;
17752 -};
17753 +} __do_const;
17754
17755 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17756 { \
17757 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17758 index 1e4dbcf..b9a34c2 100644
17759 --- a/arch/x86/kernel/cpuid.c
17760 +++ b/arch/x86/kernel/cpuid.c
17761 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17762 return notifier_from_errno(err);
17763 }
17764
17765 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17766 +static struct notifier_block cpuid_class_cpu_notifier =
17767 {
17768 .notifier_call = cpuid_class_cpu_callback,
17769 };
17770 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17771 index 74467fe..18793d5 100644
17772 --- a/arch/x86/kernel/crash.c
17773 +++ b/arch/x86/kernel/crash.c
17774 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17775 {
17776 #ifdef CONFIG_X86_32
17777 struct pt_regs fixed_regs;
17778 -#endif
17779
17780 -#ifdef CONFIG_X86_32
17781 - if (!user_mode_vm(regs)) {
17782 + if (!user_mode(regs)) {
17783 crash_fixup_ss_esp(&fixed_regs, regs);
17784 regs = &fixed_regs;
17785 }
17786 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17787 index afa64ad..dce67dd 100644
17788 --- a/arch/x86/kernel/crash_dump_64.c
17789 +++ b/arch/x86/kernel/crash_dump_64.c
17790 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17791 return -ENOMEM;
17792
17793 if (userbuf) {
17794 - if (copy_to_user(buf, vaddr + offset, csize)) {
17795 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17796 iounmap(vaddr);
17797 return -EFAULT;
17798 }
17799 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17800 index 155a13f..1672b9b 100644
17801 --- a/arch/x86/kernel/doublefault_32.c
17802 +++ b/arch/x86/kernel/doublefault_32.c
17803 @@ -11,7 +11,7 @@
17804
17805 #define DOUBLEFAULT_STACKSIZE (1024)
17806 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17807 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17808 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17809
17810 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17811
17812 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17813 unsigned long gdt, tss;
17814
17815 native_store_gdt(&gdt_desc);
17816 - gdt = gdt_desc.address;
17817 + gdt = (unsigned long)gdt_desc.address;
17818
17819 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17820
17821 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17822 /* 0x2 bit is always set */
17823 .flags = X86_EFLAGS_SF | 0x2,
17824 .sp = STACK_START,
17825 - .es = __USER_DS,
17826 + .es = __KERNEL_DS,
17827 .cs = __KERNEL_CS,
17828 .ss = __KERNEL_DS,
17829 - .ds = __USER_DS,
17830 + .ds = __KERNEL_DS,
17831 .fs = __KERNEL_PERCPU,
17832
17833 .__cr3 = __pa_nodebug(swapper_pg_dir),
17834 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17835 index deb6421..622e0ed 100644
17836 --- a/arch/x86/kernel/dumpstack.c
17837 +++ b/arch/x86/kernel/dumpstack.c
17838 @@ -2,6 +2,9 @@
17839 * Copyright (C) 1991, 1992 Linus Torvalds
17840 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17841 */
17842 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17843 +#define __INCLUDED_BY_HIDESYM 1
17844 +#endif
17845 #include <linux/kallsyms.h>
17846 #include <linux/kprobes.h>
17847 #include <linux/uaccess.h>
17848 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17849 static void
17850 print_ftrace_graph_addr(unsigned long addr, void *data,
17851 const struct stacktrace_ops *ops,
17852 - struct thread_info *tinfo, int *graph)
17853 + struct task_struct *task, int *graph)
17854 {
17855 - struct task_struct *task;
17856 unsigned long ret_addr;
17857 int index;
17858
17859 if (addr != (unsigned long)return_to_handler)
17860 return;
17861
17862 - task = tinfo->task;
17863 index = task->curr_ret_stack;
17864
17865 if (!task->ret_stack || index < *graph)
17866 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17867 static inline void
17868 print_ftrace_graph_addr(unsigned long addr, void *data,
17869 const struct stacktrace_ops *ops,
17870 - struct thread_info *tinfo, int *graph)
17871 + struct task_struct *task, int *graph)
17872 { }
17873 #endif
17874
17875 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17876 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17877 */
17878
17879 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17880 - void *p, unsigned int size, void *end)
17881 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17882 {
17883 - void *t = tinfo;
17884 if (end) {
17885 if (p < end && p >= (end-THREAD_SIZE))
17886 return 1;
17887 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17888 }
17889
17890 unsigned long
17891 -print_context_stack(struct thread_info *tinfo,
17892 +print_context_stack(struct task_struct *task, void *stack_start,
17893 unsigned long *stack, unsigned long bp,
17894 const struct stacktrace_ops *ops, void *data,
17895 unsigned long *end, int *graph)
17896 {
17897 struct stack_frame *frame = (struct stack_frame *)bp;
17898
17899 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17900 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17901 unsigned long addr;
17902
17903 addr = *stack;
17904 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17905 } else {
17906 ops->address(data, addr, 0);
17907 }
17908 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17909 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17910 }
17911 stack++;
17912 }
17913 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17914 EXPORT_SYMBOL_GPL(print_context_stack);
17915
17916 unsigned long
17917 -print_context_stack_bp(struct thread_info *tinfo,
17918 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17919 unsigned long *stack, unsigned long bp,
17920 const struct stacktrace_ops *ops, void *data,
17921 unsigned long *end, int *graph)
17922 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17923 struct stack_frame *frame = (struct stack_frame *)bp;
17924 unsigned long *ret_addr = &frame->return_address;
17925
17926 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17927 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17928 unsigned long addr = *ret_addr;
17929
17930 if (!__kernel_text_address(addr))
17931 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17932 ops->address(data, addr, 1);
17933 frame = frame->next_frame;
17934 ret_addr = &frame->return_address;
17935 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17936 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17937 }
17938
17939 return (unsigned long)frame;
17940 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
17941 }
17942 EXPORT_SYMBOL_GPL(oops_begin);
17943
17944 +extern void gr_handle_kernel_exploit(void);
17945 +
17946 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17947 {
17948 if (regs && kexec_should_crash(current))
17949 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17950 panic("Fatal exception in interrupt");
17951 if (panic_on_oops)
17952 panic("Fatal exception");
17953 - do_exit(signr);
17954 +
17955 + gr_handle_kernel_exploit();
17956 +
17957 + do_group_exit(signr);
17958 }
17959
17960 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17961 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17962 print_modules();
17963 show_regs(regs);
17964 #ifdef CONFIG_X86_32
17965 - if (user_mode_vm(regs)) {
17966 + if (user_mode(regs)) {
17967 sp = regs->sp;
17968 ss = regs->ss & 0xffff;
17969 } else {
17970 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17971 unsigned long flags = oops_begin();
17972 int sig = SIGSEGV;
17973
17974 - if (!user_mode_vm(regs))
17975 + if (!user_mode(regs))
17976 report_bug(regs->ip, regs);
17977
17978 if (__die(str, regs, err))
17979 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17980 index f2a1770..540657f 100644
17981 --- a/arch/x86/kernel/dumpstack_32.c
17982 +++ b/arch/x86/kernel/dumpstack_32.c
17983 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17984 bp = stack_frame(task, regs);
17985
17986 for (;;) {
17987 - struct thread_info *context;
17988 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17989
17990 - context = (struct thread_info *)
17991 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17992 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17993 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17994
17995 - stack = (unsigned long *)context->previous_esp;
17996 - if (!stack)
17997 + if (stack_start == task_stack_page(task))
17998 break;
17999 + stack = *(unsigned long **)stack_start;
18000 if (ops->stack(data, "IRQ") < 0)
18001 break;
18002 touch_nmi_watchdog();
18003 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
18004 int i;
18005
18006 show_regs_print_info(KERN_EMERG);
18007 - __show_regs(regs, !user_mode_vm(regs));
18008 + __show_regs(regs, !user_mode(regs));
18009
18010 /*
18011 * When in-kernel, we also print out the stack and code at the
18012 * time of the fault..
18013 */
18014 - if (!user_mode_vm(regs)) {
18015 + if (!user_mode(regs)) {
18016 unsigned int code_prologue = code_bytes * 43 / 64;
18017 unsigned int code_len = code_bytes;
18018 unsigned char c;
18019 u8 *ip;
18020 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18021
18022 pr_emerg("Stack:\n");
18023 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18024
18025 pr_emerg("Code:");
18026
18027 - ip = (u8 *)regs->ip - code_prologue;
18028 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18029 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18030 /* try starting at IP */
18031 - ip = (u8 *)regs->ip;
18032 + ip = (u8 *)regs->ip + cs_base;
18033 code_len = code_len - code_prologue + 1;
18034 }
18035 for (i = 0; i < code_len; i++, ip++) {
18036 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
18037 pr_cont(" Bad EIP value.");
18038 break;
18039 }
18040 - if (ip == (u8 *)regs->ip)
18041 + if (ip == (u8 *)regs->ip + cs_base)
18042 pr_cont(" <%02x>", c);
18043 else
18044 pr_cont(" %02x", c);
18045 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
18046 {
18047 unsigned short ud2;
18048
18049 + ip = ktla_ktva(ip);
18050 if (ip < PAGE_OFFSET)
18051 return 0;
18052 if (probe_kernel_address((unsigned short *)ip, ud2))
18053 @@ -136,3 +136,15 @@ 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_left;
18062 +
18063 + /* all kernel stacks are of the same size */
18064 + stack_left = sp & (THREAD_SIZE - 1);
18065 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18066 +}
18067 +EXPORT_SYMBOL(pax_check_alloca);
18068 +#endif
18069 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18070 index addb207..99635fa 100644
18071 --- a/arch/x86/kernel/dumpstack_64.c
18072 +++ b/arch/x86/kernel/dumpstack_64.c
18073 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18074 unsigned long *irq_stack_end =
18075 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18076 unsigned used = 0;
18077 - struct thread_info *tinfo;
18078 int graph = 0;
18079 unsigned long dummy;
18080 + void *stack_start;
18081
18082 if (!task)
18083 task = current;
18084 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18085 * current stack address. If the stacks consist of nested
18086 * exceptions
18087 */
18088 - tinfo = task_thread_info(task);
18089 for (;;) {
18090 char *id;
18091 unsigned long *estack_end;
18092 +
18093 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18094 &used, &id);
18095
18096 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18097 if (ops->stack(data, id) < 0)
18098 break;
18099
18100 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18101 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18102 data, estack_end, &graph);
18103 ops->stack(data, "<EOE>");
18104 /*
18105 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18106 * second-to-last pointer (index -2 to end) in the
18107 * exception stack:
18108 */
18109 + if ((u16)estack_end[-1] != __KERNEL_DS)
18110 + goto out;
18111 stack = (unsigned long *) estack_end[-2];
18112 continue;
18113 }
18114 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18115 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18116 if (ops->stack(data, "IRQ") < 0)
18117 break;
18118 - bp = ops->walk_stack(tinfo, stack, bp,
18119 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18120 ops, data, irq_stack_end, &graph);
18121 /*
18122 * We link to the next stack (which would be
18123 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18124 /*
18125 * This handles the process stack:
18126 */
18127 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18128 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18129 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18130 +out:
18131 put_cpu();
18132 }
18133 EXPORT_SYMBOL(dump_trace);
18134 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
18135
18136 return ud2 == 0x0b0f;
18137 }
18138 +
18139 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18140 +void pax_check_alloca(unsigned long size)
18141 +{
18142 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18143 + unsigned cpu, used;
18144 + char *id;
18145 +
18146 + /* check the process stack first */
18147 + stack_start = (unsigned long)task_stack_page(current);
18148 + stack_end = stack_start + THREAD_SIZE;
18149 + if (likely(stack_start <= sp && sp < stack_end)) {
18150 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18151 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18152 + return;
18153 + }
18154 +
18155 + cpu = get_cpu();
18156 +
18157 + /* check the irq stacks */
18158 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18159 + stack_start = stack_end - IRQ_STACK_SIZE;
18160 + if (stack_start <= sp && sp < stack_end) {
18161 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18162 + put_cpu();
18163 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18164 + return;
18165 + }
18166 +
18167 + /* check the exception stacks */
18168 + used = 0;
18169 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18170 + stack_start = stack_end - EXCEPTION_STKSZ;
18171 + if (stack_end && stack_start <= sp && sp < stack_end) {
18172 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18173 + put_cpu();
18174 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18175 + return;
18176 + }
18177 +
18178 + put_cpu();
18179 +
18180 + /* unknown stack */
18181 + BUG();
18182 +}
18183 +EXPORT_SYMBOL(pax_check_alloca);
18184 +#endif
18185 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18186 index d32abea..74daf4f 100644
18187 --- a/arch/x86/kernel/e820.c
18188 +++ b/arch/x86/kernel/e820.c
18189 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18190
18191 static void early_panic(char *msg)
18192 {
18193 - early_printk(msg);
18194 - panic(msg);
18195 + early_printk("%s", msg);
18196 + panic("%s", msg);
18197 }
18198
18199 static int userdef __initdata;
18200 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18201 index d15f575..d692043 100644
18202 --- a/arch/x86/kernel/early_printk.c
18203 +++ b/arch/x86/kernel/early_printk.c
18204 @@ -7,6 +7,7 @@
18205 #include <linux/pci_regs.h>
18206 #include <linux/pci_ids.h>
18207 #include <linux/errno.h>
18208 +#include <linux/sched.h>
18209 #include <asm/io.h>
18210 #include <asm/processor.h>
18211 #include <asm/fcntl.h>
18212 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18213 index 8f3e2de..caecc4e 100644
18214 --- a/arch/x86/kernel/entry_32.S
18215 +++ b/arch/x86/kernel/entry_32.S
18216 @@ -177,13 +177,153 @@
18217 /*CFI_REL_OFFSET gs, PT_GS*/
18218 .endm
18219 .macro SET_KERNEL_GS reg
18220 +
18221 +#ifdef CONFIG_CC_STACKPROTECTOR
18222 movl $(__KERNEL_STACK_CANARY), \reg
18223 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18224 + movl $(__USER_DS), \reg
18225 +#else
18226 + xorl \reg, \reg
18227 +#endif
18228 +
18229 movl \reg, %gs
18230 .endm
18231
18232 #endif /* CONFIG_X86_32_LAZY_GS */
18233
18234 -.macro SAVE_ALL
18235 +.macro pax_enter_kernel
18236 +#ifdef CONFIG_PAX_KERNEXEC
18237 + call pax_enter_kernel
18238 +#endif
18239 +.endm
18240 +
18241 +.macro pax_exit_kernel
18242 +#ifdef CONFIG_PAX_KERNEXEC
18243 + call pax_exit_kernel
18244 +#endif
18245 +.endm
18246 +
18247 +#ifdef CONFIG_PAX_KERNEXEC
18248 +ENTRY(pax_enter_kernel)
18249 +#ifdef CONFIG_PARAVIRT
18250 + pushl %eax
18251 + pushl %ecx
18252 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18253 + mov %eax, %esi
18254 +#else
18255 + mov %cr0, %esi
18256 +#endif
18257 + bts $16, %esi
18258 + jnc 1f
18259 + mov %cs, %esi
18260 + cmp $__KERNEL_CS, %esi
18261 + jz 3f
18262 + ljmp $__KERNEL_CS, $3f
18263 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18264 +2:
18265 +#ifdef CONFIG_PARAVIRT
18266 + mov %esi, %eax
18267 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18268 +#else
18269 + mov %esi, %cr0
18270 +#endif
18271 +3:
18272 +#ifdef CONFIG_PARAVIRT
18273 + popl %ecx
18274 + popl %eax
18275 +#endif
18276 + ret
18277 +ENDPROC(pax_enter_kernel)
18278 +
18279 +ENTRY(pax_exit_kernel)
18280 +#ifdef CONFIG_PARAVIRT
18281 + pushl %eax
18282 + pushl %ecx
18283 +#endif
18284 + mov %cs, %esi
18285 + cmp $__KERNEXEC_KERNEL_CS, %esi
18286 + jnz 2f
18287 +#ifdef CONFIG_PARAVIRT
18288 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18289 + mov %eax, %esi
18290 +#else
18291 + mov %cr0, %esi
18292 +#endif
18293 + btr $16, %esi
18294 + ljmp $__KERNEL_CS, $1f
18295 +1:
18296 +#ifdef CONFIG_PARAVIRT
18297 + mov %esi, %eax
18298 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18299 +#else
18300 + mov %esi, %cr0
18301 +#endif
18302 +2:
18303 +#ifdef CONFIG_PARAVIRT
18304 + popl %ecx
18305 + popl %eax
18306 +#endif
18307 + ret
18308 +ENDPROC(pax_exit_kernel)
18309 +#endif
18310 +
18311 + .macro pax_erase_kstack
18312 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18313 + call pax_erase_kstack
18314 +#endif
18315 + .endm
18316 +
18317 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18318 +/*
18319 + * ebp: thread_info
18320 + */
18321 +ENTRY(pax_erase_kstack)
18322 + pushl %edi
18323 + pushl %ecx
18324 + pushl %eax
18325 +
18326 + mov TI_lowest_stack(%ebp), %edi
18327 + mov $-0xBEEF, %eax
18328 + std
18329 +
18330 +1: mov %edi, %ecx
18331 + and $THREAD_SIZE_asm - 1, %ecx
18332 + shr $2, %ecx
18333 + repne scasl
18334 + jecxz 2f
18335 +
18336 + cmp $2*16, %ecx
18337 + jc 2f
18338 +
18339 + mov $2*16, %ecx
18340 + repe scasl
18341 + jecxz 2f
18342 + jne 1b
18343 +
18344 +2: cld
18345 + mov %esp, %ecx
18346 + sub %edi, %ecx
18347 +
18348 + cmp $THREAD_SIZE_asm, %ecx
18349 + jb 3f
18350 + ud2
18351 +3:
18352 +
18353 + shr $2, %ecx
18354 + rep stosl
18355 +
18356 + mov TI_task_thread_sp0(%ebp), %edi
18357 + sub $128, %edi
18358 + mov %edi, TI_lowest_stack(%ebp)
18359 +
18360 + popl %eax
18361 + popl %ecx
18362 + popl %edi
18363 + ret
18364 +ENDPROC(pax_erase_kstack)
18365 +#endif
18366 +
18367 +.macro __SAVE_ALL _DS
18368 cld
18369 PUSH_GS
18370 pushl_cfi %fs
18371 @@ -206,7 +346,7 @@
18372 CFI_REL_OFFSET ecx, 0
18373 pushl_cfi %ebx
18374 CFI_REL_OFFSET ebx, 0
18375 - movl $(__USER_DS), %edx
18376 + movl $\_DS, %edx
18377 movl %edx, %ds
18378 movl %edx, %es
18379 movl $(__KERNEL_PERCPU), %edx
18380 @@ -214,6 +354,15 @@
18381 SET_KERNEL_GS %edx
18382 .endm
18383
18384 +.macro SAVE_ALL
18385 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18386 + __SAVE_ALL __KERNEL_DS
18387 + pax_enter_kernel
18388 +#else
18389 + __SAVE_ALL __USER_DS
18390 +#endif
18391 +.endm
18392 +
18393 .macro RESTORE_INT_REGS
18394 popl_cfi %ebx
18395 CFI_RESTORE ebx
18396 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18397 popfl_cfi
18398 jmp syscall_exit
18399 CFI_ENDPROC
18400 -END(ret_from_fork)
18401 +ENDPROC(ret_from_fork)
18402
18403 ENTRY(ret_from_kernel_thread)
18404 CFI_STARTPROC
18405 @@ -344,7 +493,15 @@ ret_from_intr:
18406 andl $SEGMENT_RPL_MASK, %eax
18407 #endif
18408 cmpl $USER_RPL, %eax
18409 +
18410 +#ifdef CONFIG_PAX_KERNEXEC
18411 + jae resume_userspace
18412 +
18413 + pax_exit_kernel
18414 + jmp resume_kernel
18415 +#else
18416 jb resume_kernel # not returning to v8086 or userspace
18417 +#endif
18418
18419 ENTRY(resume_userspace)
18420 LOCKDEP_SYS_EXIT
18421 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18422 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18423 # int/exception return?
18424 jne work_pending
18425 - jmp restore_all
18426 -END(ret_from_exception)
18427 + jmp restore_all_pax
18428 +ENDPROC(ret_from_exception)
18429
18430 #ifdef CONFIG_PREEMPT
18431 ENTRY(resume_kernel)
18432 @@ -372,7 +529,7 @@ need_resched:
18433 jz restore_all
18434 call preempt_schedule_irq
18435 jmp need_resched
18436 -END(resume_kernel)
18437 +ENDPROC(resume_kernel)
18438 #endif
18439 CFI_ENDPROC
18440 /*
18441 @@ -406,30 +563,45 @@ sysenter_past_esp:
18442 /*CFI_REL_OFFSET cs, 0*/
18443 /*
18444 * Push current_thread_info()->sysenter_return to the stack.
18445 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18446 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18447 */
18448 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18449 + pushl_cfi $0
18450 CFI_REL_OFFSET eip, 0
18451
18452 pushl_cfi %eax
18453 SAVE_ALL
18454 + GET_THREAD_INFO(%ebp)
18455 + movl TI_sysenter_return(%ebp),%ebp
18456 + movl %ebp,PT_EIP(%esp)
18457 ENABLE_INTERRUPTS(CLBR_NONE)
18458
18459 /*
18460 * Load the potential sixth argument from user stack.
18461 * Careful about security.
18462 */
18463 + movl PT_OLDESP(%esp),%ebp
18464 +
18465 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18466 + mov PT_OLDSS(%esp),%ds
18467 +1: movl %ds:(%ebp),%ebp
18468 + push %ss
18469 + pop %ds
18470 +#else
18471 cmpl $__PAGE_OFFSET-3,%ebp
18472 jae syscall_fault
18473 ASM_STAC
18474 1: movl (%ebp),%ebp
18475 ASM_CLAC
18476 +#endif
18477 +
18478 movl %ebp,PT_EBP(%esp)
18479 _ASM_EXTABLE(1b,syscall_fault)
18480
18481 GET_THREAD_INFO(%ebp)
18482
18483 +#ifdef CONFIG_PAX_RANDKSTACK
18484 + pax_erase_kstack
18485 +#endif
18486 +
18487 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18488 jnz sysenter_audit
18489 sysenter_do_call:
18490 @@ -444,12 +616,24 @@ sysenter_do_call:
18491 testl $_TIF_ALLWORK_MASK, %ecx
18492 jne sysexit_audit
18493 sysenter_exit:
18494 +
18495 +#ifdef CONFIG_PAX_RANDKSTACK
18496 + pushl_cfi %eax
18497 + movl %esp, %eax
18498 + call pax_randomize_kstack
18499 + popl_cfi %eax
18500 +#endif
18501 +
18502 + pax_erase_kstack
18503 +
18504 /* if something modifies registers it must also disable sysexit */
18505 movl PT_EIP(%esp), %edx
18506 movl PT_OLDESP(%esp), %ecx
18507 xorl %ebp,%ebp
18508 TRACE_IRQS_ON
18509 1: mov PT_FS(%esp), %fs
18510 +2: mov PT_DS(%esp), %ds
18511 +3: mov PT_ES(%esp), %es
18512 PTGS_TO_GS
18513 ENABLE_INTERRUPTS_SYSEXIT
18514
18515 @@ -466,6 +650,9 @@ sysenter_audit:
18516 movl %eax,%edx /* 2nd arg: syscall number */
18517 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18518 call __audit_syscall_entry
18519 +
18520 + pax_erase_kstack
18521 +
18522 pushl_cfi %ebx
18523 movl PT_EAX(%esp),%eax /* reload syscall number */
18524 jmp sysenter_do_call
18525 @@ -491,10 +678,16 @@ sysexit_audit:
18526
18527 CFI_ENDPROC
18528 .pushsection .fixup,"ax"
18529 -2: movl $0,PT_FS(%esp)
18530 +4: movl $0,PT_FS(%esp)
18531 + jmp 1b
18532 +5: movl $0,PT_DS(%esp)
18533 + jmp 1b
18534 +6: movl $0,PT_ES(%esp)
18535 jmp 1b
18536 .popsection
18537 - _ASM_EXTABLE(1b,2b)
18538 + _ASM_EXTABLE(1b,4b)
18539 + _ASM_EXTABLE(2b,5b)
18540 + _ASM_EXTABLE(3b,6b)
18541 PTGS_TO_GS_EX
18542 ENDPROC(ia32_sysenter_target)
18543
18544 @@ -509,6 +702,11 @@ ENTRY(system_call)
18545 pushl_cfi %eax # save orig_eax
18546 SAVE_ALL
18547 GET_THREAD_INFO(%ebp)
18548 +
18549 +#ifdef CONFIG_PAX_RANDKSTACK
18550 + pax_erase_kstack
18551 +#endif
18552 +
18553 # system call tracing in operation / emulation
18554 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18555 jnz syscall_trace_entry
18556 @@ -527,6 +725,15 @@ syscall_exit:
18557 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18558 jne syscall_exit_work
18559
18560 +restore_all_pax:
18561 +
18562 +#ifdef CONFIG_PAX_RANDKSTACK
18563 + movl %esp, %eax
18564 + call pax_randomize_kstack
18565 +#endif
18566 +
18567 + pax_erase_kstack
18568 +
18569 restore_all:
18570 TRACE_IRQS_IRET
18571 restore_all_notrace:
18572 @@ -583,14 +790,34 @@ ldt_ss:
18573 * compensating for the offset by changing to the ESPFIX segment with
18574 * a base address that matches for the difference.
18575 */
18576 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18577 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18578 mov %esp, %edx /* load kernel esp */
18579 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18580 mov %dx, %ax /* eax: new kernel esp */
18581 sub %eax, %edx /* offset (low word is 0) */
18582 +#ifdef CONFIG_SMP
18583 + movl PER_CPU_VAR(cpu_number), %ebx
18584 + shll $PAGE_SHIFT_asm, %ebx
18585 + addl $cpu_gdt_table, %ebx
18586 +#else
18587 + movl $cpu_gdt_table, %ebx
18588 +#endif
18589 shr $16, %edx
18590 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18591 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18592 +
18593 +#ifdef CONFIG_PAX_KERNEXEC
18594 + mov %cr0, %esi
18595 + btr $16, %esi
18596 + mov %esi, %cr0
18597 +#endif
18598 +
18599 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18600 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18601 +
18602 +#ifdef CONFIG_PAX_KERNEXEC
18603 + bts $16, %esi
18604 + mov %esi, %cr0
18605 +#endif
18606 +
18607 pushl_cfi $__ESPFIX_SS
18608 pushl_cfi %eax /* new kernel esp */
18609 /* Disable interrupts, but do not irqtrace this section: we
18610 @@ -619,20 +846,18 @@ work_resched:
18611 movl TI_flags(%ebp), %ecx
18612 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18613 # than syscall tracing?
18614 - jz restore_all
18615 + jz restore_all_pax
18616 testb $_TIF_NEED_RESCHED, %cl
18617 jnz work_resched
18618
18619 work_notifysig: # deal with pending signals and
18620 # notify-resume requests
18621 + movl %esp, %eax
18622 #ifdef CONFIG_VM86
18623 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18624 - movl %esp, %eax
18625 jne work_notifysig_v86 # returning to kernel-space or
18626 # vm86-space
18627 1:
18628 -#else
18629 - movl %esp, %eax
18630 #endif
18631 TRACE_IRQS_ON
18632 ENABLE_INTERRUPTS(CLBR_NONE)
18633 @@ -653,7 +878,7 @@ work_notifysig_v86:
18634 movl %eax, %esp
18635 jmp 1b
18636 #endif
18637 -END(work_pending)
18638 +ENDPROC(work_pending)
18639
18640 # perform syscall exit tracing
18641 ALIGN
18642 @@ -661,11 +886,14 @@ syscall_trace_entry:
18643 movl $-ENOSYS,PT_EAX(%esp)
18644 movl %esp, %eax
18645 call syscall_trace_enter
18646 +
18647 + pax_erase_kstack
18648 +
18649 /* What it returned is what we'll actually use. */
18650 cmpl $(NR_syscalls), %eax
18651 jnae syscall_call
18652 jmp syscall_exit
18653 -END(syscall_trace_entry)
18654 +ENDPROC(syscall_trace_entry)
18655
18656 # perform syscall exit tracing
18657 ALIGN
18658 @@ -678,21 +906,25 @@ syscall_exit_work:
18659 movl %esp, %eax
18660 call syscall_trace_leave
18661 jmp resume_userspace
18662 -END(syscall_exit_work)
18663 +ENDPROC(syscall_exit_work)
18664 CFI_ENDPROC
18665
18666 RING0_INT_FRAME # can't unwind into user space anyway
18667 syscall_fault:
18668 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18669 + push %ss
18670 + pop %ds
18671 +#endif
18672 ASM_CLAC
18673 GET_THREAD_INFO(%ebp)
18674 movl $-EFAULT,PT_EAX(%esp)
18675 jmp resume_userspace
18676 -END(syscall_fault)
18677 +ENDPROC(syscall_fault)
18678
18679 syscall_badsys:
18680 movl $-ENOSYS,PT_EAX(%esp)
18681 jmp resume_userspace
18682 -END(syscall_badsys)
18683 +ENDPROC(syscall_badsys)
18684 CFI_ENDPROC
18685 /*
18686 * End of kprobes section
18687 @@ -708,8 +940,15 @@ END(syscall_badsys)
18688 * normal stack and adjusts ESP with the matching offset.
18689 */
18690 /* fixup the stack */
18691 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18692 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18693 +#ifdef CONFIG_SMP
18694 + movl PER_CPU_VAR(cpu_number), %ebx
18695 + shll $PAGE_SHIFT_asm, %ebx
18696 + addl $cpu_gdt_table, %ebx
18697 +#else
18698 + movl $cpu_gdt_table, %ebx
18699 +#endif
18700 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18701 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18702 shl $16, %eax
18703 addl %esp, %eax /* the adjusted stack pointer */
18704 pushl_cfi $__KERNEL_DS
18705 @@ -762,7 +1001,7 @@ vector=vector+1
18706 .endr
18707 2: jmp common_interrupt
18708 .endr
18709 -END(irq_entries_start)
18710 +ENDPROC(irq_entries_start)
18711
18712 .previous
18713 END(interrupt)
18714 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18715 pushl_cfi $do_coprocessor_error
18716 jmp error_code
18717 CFI_ENDPROC
18718 -END(coprocessor_error)
18719 +ENDPROC(coprocessor_error)
18720
18721 ENTRY(simd_coprocessor_error)
18722 RING0_INT_FRAME
18723 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18724 #endif
18725 jmp error_code
18726 CFI_ENDPROC
18727 -END(simd_coprocessor_error)
18728 +ENDPROC(simd_coprocessor_error)
18729
18730 ENTRY(device_not_available)
18731 RING0_INT_FRAME
18732 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18733 pushl_cfi $do_device_not_available
18734 jmp error_code
18735 CFI_ENDPROC
18736 -END(device_not_available)
18737 +ENDPROC(device_not_available)
18738
18739 #ifdef CONFIG_PARAVIRT
18740 ENTRY(native_iret)
18741 iret
18742 _ASM_EXTABLE(native_iret, iret_exc)
18743 -END(native_iret)
18744 +ENDPROC(native_iret)
18745
18746 ENTRY(native_irq_enable_sysexit)
18747 sti
18748 sysexit
18749 -END(native_irq_enable_sysexit)
18750 +ENDPROC(native_irq_enable_sysexit)
18751 #endif
18752
18753 ENTRY(overflow)
18754 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18755 pushl_cfi $do_overflow
18756 jmp error_code
18757 CFI_ENDPROC
18758 -END(overflow)
18759 +ENDPROC(overflow)
18760
18761 ENTRY(bounds)
18762 RING0_INT_FRAME
18763 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18764 pushl_cfi $do_bounds
18765 jmp error_code
18766 CFI_ENDPROC
18767 -END(bounds)
18768 +ENDPROC(bounds)
18769
18770 ENTRY(invalid_op)
18771 RING0_INT_FRAME
18772 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18773 pushl_cfi $do_invalid_op
18774 jmp error_code
18775 CFI_ENDPROC
18776 -END(invalid_op)
18777 +ENDPROC(invalid_op)
18778
18779 ENTRY(coprocessor_segment_overrun)
18780 RING0_INT_FRAME
18781 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18782 pushl_cfi $do_coprocessor_segment_overrun
18783 jmp error_code
18784 CFI_ENDPROC
18785 -END(coprocessor_segment_overrun)
18786 +ENDPROC(coprocessor_segment_overrun)
18787
18788 ENTRY(invalid_TSS)
18789 RING0_EC_FRAME
18790 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18791 pushl_cfi $do_invalid_TSS
18792 jmp error_code
18793 CFI_ENDPROC
18794 -END(invalid_TSS)
18795 +ENDPROC(invalid_TSS)
18796
18797 ENTRY(segment_not_present)
18798 RING0_EC_FRAME
18799 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18800 pushl_cfi $do_segment_not_present
18801 jmp error_code
18802 CFI_ENDPROC
18803 -END(segment_not_present)
18804 +ENDPROC(segment_not_present)
18805
18806 ENTRY(stack_segment)
18807 RING0_EC_FRAME
18808 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18809 pushl_cfi $do_stack_segment
18810 jmp error_code
18811 CFI_ENDPROC
18812 -END(stack_segment)
18813 +ENDPROC(stack_segment)
18814
18815 ENTRY(alignment_check)
18816 RING0_EC_FRAME
18817 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18818 pushl_cfi $do_alignment_check
18819 jmp error_code
18820 CFI_ENDPROC
18821 -END(alignment_check)
18822 +ENDPROC(alignment_check)
18823
18824 ENTRY(divide_error)
18825 RING0_INT_FRAME
18826 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18827 pushl_cfi $do_divide_error
18828 jmp error_code
18829 CFI_ENDPROC
18830 -END(divide_error)
18831 +ENDPROC(divide_error)
18832
18833 #ifdef CONFIG_X86_MCE
18834 ENTRY(machine_check)
18835 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18836 pushl_cfi machine_check_vector
18837 jmp error_code
18838 CFI_ENDPROC
18839 -END(machine_check)
18840 +ENDPROC(machine_check)
18841 #endif
18842
18843 ENTRY(spurious_interrupt_bug)
18844 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18845 pushl_cfi $do_spurious_interrupt_bug
18846 jmp error_code
18847 CFI_ENDPROC
18848 -END(spurious_interrupt_bug)
18849 +ENDPROC(spurious_interrupt_bug)
18850 /*
18851 * End of kprobes section
18852 */
18853 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18854
18855 ENTRY(mcount)
18856 ret
18857 -END(mcount)
18858 +ENDPROC(mcount)
18859
18860 ENTRY(ftrace_caller)
18861 cmpl $0, function_trace_stop
18862 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18863 .globl ftrace_stub
18864 ftrace_stub:
18865 ret
18866 -END(ftrace_caller)
18867 +ENDPROC(ftrace_caller)
18868
18869 ENTRY(ftrace_regs_caller)
18870 pushf /* push flags before compare (in cs location) */
18871 @@ -1197,7 +1436,7 @@ trace:
18872 popl %ecx
18873 popl %eax
18874 jmp ftrace_stub
18875 -END(mcount)
18876 +ENDPROC(mcount)
18877 #endif /* CONFIG_DYNAMIC_FTRACE */
18878 #endif /* CONFIG_FUNCTION_TRACER */
18879
18880 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18881 popl %ecx
18882 popl %eax
18883 ret
18884 -END(ftrace_graph_caller)
18885 +ENDPROC(ftrace_graph_caller)
18886
18887 .globl return_to_handler
18888 return_to_handler:
18889 @@ -1271,15 +1510,18 @@ error_code:
18890 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18891 REG_TO_PTGS %ecx
18892 SET_KERNEL_GS %ecx
18893 - movl $(__USER_DS), %ecx
18894 + movl $(__KERNEL_DS), %ecx
18895 movl %ecx, %ds
18896 movl %ecx, %es
18897 +
18898 + pax_enter_kernel
18899 +
18900 TRACE_IRQS_OFF
18901 movl %esp,%eax # pt_regs pointer
18902 call *%edi
18903 jmp ret_from_exception
18904 CFI_ENDPROC
18905 -END(page_fault)
18906 +ENDPROC(page_fault)
18907
18908 /*
18909 * Debug traps and NMI can happen at the one SYSENTER instruction
18910 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18911 call do_debug
18912 jmp ret_from_exception
18913 CFI_ENDPROC
18914 -END(debug)
18915 +ENDPROC(debug)
18916
18917 /*
18918 * NMI is doubly nasty. It can happen _while_ we're handling
18919 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18920 xorl %edx,%edx # zero error code
18921 movl %esp,%eax # pt_regs pointer
18922 call do_nmi
18923 +
18924 + pax_exit_kernel
18925 +
18926 jmp restore_all_notrace
18927 CFI_ENDPROC
18928
18929 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18930 FIXUP_ESPFIX_STACK # %eax == %esp
18931 xorl %edx,%edx # zero error code
18932 call do_nmi
18933 +
18934 + pax_exit_kernel
18935 +
18936 RESTORE_REGS
18937 lss 12+4(%esp), %esp # back to espfix stack
18938 CFI_ADJUST_CFA_OFFSET -24
18939 jmp irq_return
18940 CFI_ENDPROC
18941 -END(nmi)
18942 +ENDPROC(nmi)
18943
18944 ENTRY(int3)
18945 RING0_INT_FRAME
18946 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18947 call do_int3
18948 jmp ret_from_exception
18949 CFI_ENDPROC
18950 -END(int3)
18951 +ENDPROC(int3)
18952
18953 ENTRY(general_protection)
18954 RING0_EC_FRAME
18955 pushl_cfi $do_general_protection
18956 jmp error_code
18957 CFI_ENDPROC
18958 -END(general_protection)
18959 +ENDPROC(general_protection)
18960
18961 #ifdef CONFIG_KVM_GUEST
18962 ENTRY(async_page_fault)
18963 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18964 pushl_cfi $do_async_page_fault
18965 jmp error_code
18966 CFI_ENDPROC
18967 -END(async_page_fault)
18968 +ENDPROC(async_page_fault)
18969 #endif
18970
18971 /*
18972 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18973 index 7272089..6204f9c5 100644
18974 --- a/arch/x86/kernel/entry_64.S
18975 +++ b/arch/x86/kernel/entry_64.S
18976 @@ -59,6 +59,8 @@
18977 #include <asm/context_tracking.h>
18978 #include <asm/smap.h>
18979 #include <linux/err.h>
18980 +#include <asm/pgtable.h>
18981 +#include <asm/alternative-asm.h>
18982
18983 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18984 #include <linux/elf-em.h>
18985 @@ -80,8 +82,9 @@
18986 #ifdef CONFIG_DYNAMIC_FTRACE
18987
18988 ENTRY(function_hook)
18989 + pax_force_retaddr
18990 retq
18991 -END(function_hook)
18992 +ENDPROC(function_hook)
18993
18994 /* skip is set if stack has been adjusted */
18995 .macro ftrace_caller_setup skip=0
18996 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18997 #endif
18998
18999 GLOBAL(ftrace_stub)
19000 + pax_force_retaddr
19001 retq
19002 -END(ftrace_caller)
19003 +ENDPROC(ftrace_caller)
19004
19005 ENTRY(ftrace_regs_caller)
19006 /* Save the current flags before compare (in SS location)*/
19007 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19008 popfq
19009 jmp ftrace_stub
19010
19011 -END(ftrace_regs_caller)
19012 +ENDPROC(ftrace_regs_caller)
19013
19014
19015 #else /* ! CONFIG_DYNAMIC_FTRACE */
19016 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19017 #endif
19018
19019 GLOBAL(ftrace_stub)
19020 + pax_force_retaddr
19021 retq
19022
19023 trace:
19024 @@ -225,12 +230,13 @@ trace:
19025 #endif
19026 subq $MCOUNT_INSN_SIZE, %rdi
19027
19028 + pax_force_fptr ftrace_trace_function
19029 call *ftrace_trace_function
19030
19031 MCOUNT_RESTORE_FRAME
19032
19033 jmp ftrace_stub
19034 -END(function_hook)
19035 +ENDPROC(function_hook)
19036 #endif /* CONFIG_DYNAMIC_FTRACE */
19037 #endif /* CONFIG_FUNCTION_TRACER */
19038
19039 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19040
19041 MCOUNT_RESTORE_FRAME
19042
19043 + pax_force_retaddr
19044 retq
19045 -END(ftrace_graph_caller)
19046 +ENDPROC(ftrace_graph_caller)
19047
19048 GLOBAL(return_to_handler)
19049 subq $24, %rsp
19050 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19051 movq 8(%rsp), %rdx
19052 movq (%rsp), %rax
19053 addq $24, %rsp
19054 + pax_force_fptr %rdi
19055 jmp *%rdi
19056 +ENDPROC(return_to_handler)
19057 #endif
19058
19059
19060 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19061 ENDPROC(native_usergs_sysret64)
19062 #endif /* CONFIG_PARAVIRT */
19063
19064 + .macro ljmpq sel, off
19065 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19066 + .byte 0x48; ljmp *1234f(%rip)
19067 + .pushsection .rodata
19068 + .align 16
19069 + 1234: .quad \off; .word \sel
19070 + .popsection
19071 +#else
19072 + pushq $\sel
19073 + pushq $\off
19074 + lretq
19075 +#endif
19076 + .endm
19077 +
19078 + .macro pax_enter_kernel
19079 + pax_set_fptr_mask
19080 +#ifdef CONFIG_PAX_KERNEXEC
19081 + call pax_enter_kernel
19082 +#endif
19083 + .endm
19084 +
19085 + .macro pax_exit_kernel
19086 +#ifdef CONFIG_PAX_KERNEXEC
19087 + call pax_exit_kernel
19088 +#endif
19089 + .endm
19090 +
19091 +#ifdef CONFIG_PAX_KERNEXEC
19092 +ENTRY(pax_enter_kernel)
19093 + pushq %rdi
19094 +
19095 +#ifdef CONFIG_PARAVIRT
19096 + PV_SAVE_REGS(CLBR_RDI)
19097 +#endif
19098 +
19099 + GET_CR0_INTO_RDI
19100 + bts $16,%rdi
19101 + jnc 3f
19102 + mov %cs,%edi
19103 + cmp $__KERNEL_CS,%edi
19104 + jnz 2f
19105 +1:
19106 +
19107 +#ifdef CONFIG_PARAVIRT
19108 + PV_RESTORE_REGS(CLBR_RDI)
19109 +#endif
19110 +
19111 + popq %rdi
19112 + pax_force_retaddr
19113 + retq
19114 +
19115 +2: ljmpq __KERNEL_CS,1b
19116 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19117 +4: SET_RDI_INTO_CR0
19118 + jmp 1b
19119 +ENDPROC(pax_enter_kernel)
19120 +
19121 +ENTRY(pax_exit_kernel)
19122 + pushq %rdi
19123 +
19124 +#ifdef CONFIG_PARAVIRT
19125 + PV_SAVE_REGS(CLBR_RDI)
19126 +#endif
19127 +
19128 + mov %cs,%rdi
19129 + cmp $__KERNEXEC_KERNEL_CS,%edi
19130 + jz 2f
19131 + GET_CR0_INTO_RDI
19132 + bts $16,%rdi
19133 + jnc 4f
19134 +1:
19135 +
19136 +#ifdef CONFIG_PARAVIRT
19137 + PV_RESTORE_REGS(CLBR_RDI);
19138 +#endif
19139 +
19140 + popq %rdi
19141 + pax_force_retaddr
19142 + retq
19143 +
19144 +2: GET_CR0_INTO_RDI
19145 + btr $16,%rdi
19146 + jnc 4f
19147 + ljmpq __KERNEL_CS,3f
19148 +3: SET_RDI_INTO_CR0
19149 + jmp 1b
19150 +4: ud2
19151 + jmp 4b
19152 +ENDPROC(pax_exit_kernel)
19153 +#endif
19154 +
19155 + .macro pax_enter_kernel_user
19156 + pax_set_fptr_mask
19157 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19158 + call pax_enter_kernel_user
19159 +#endif
19160 + .endm
19161 +
19162 + .macro pax_exit_kernel_user
19163 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19164 + call pax_exit_kernel_user
19165 +#endif
19166 +#ifdef CONFIG_PAX_RANDKSTACK
19167 + pushq %rax
19168 + pushq %r11
19169 + call pax_randomize_kstack
19170 + popq %r11
19171 + popq %rax
19172 +#endif
19173 + .endm
19174 +
19175 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19176 +ENTRY(pax_enter_kernel_user)
19177 + pushq %rdi
19178 + pushq %rbx
19179 +
19180 +#ifdef CONFIG_PARAVIRT
19181 + PV_SAVE_REGS(CLBR_RDI)
19182 +#endif
19183 +
19184 + GET_CR3_INTO_RDI
19185 + mov %rdi,%rbx
19186 + add $__START_KERNEL_map,%rbx
19187 + sub phys_base(%rip),%rbx
19188 +
19189 +#ifdef CONFIG_PARAVIRT
19190 + cmpl $0, pv_info+PARAVIRT_enabled
19191 + jz 1f
19192 + pushq %rdi
19193 + i = 0
19194 + .rept USER_PGD_PTRS
19195 + mov i*8(%rbx),%rsi
19196 + mov $0,%sil
19197 + lea i*8(%rbx),%rdi
19198 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19199 + i = i + 1
19200 + .endr
19201 + popq %rdi
19202 + jmp 2f
19203 +1:
19204 +#endif
19205 +
19206 + i = 0
19207 + .rept USER_PGD_PTRS
19208 + movb $0,i*8(%rbx)
19209 + i = i + 1
19210 + .endr
19211 +
19212 +#ifdef CONFIG_PARAVIRT
19213 +2:
19214 +#endif
19215 + SET_RDI_INTO_CR3
19216 +
19217 +#ifdef CONFIG_PAX_KERNEXEC
19218 + GET_CR0_INTO_RDI
19219 + bts $16,%rdi
19220 + SET_RDI_INTO_CR0
19221 +#endif
19222 +
19223 +#ifdef CONFIG_PARAVIRT
19224 + PV_RESTORE_REGS(CLBR_RDI)
19225 +#endif
19226 +
19227 + popq %rbx
19228 + popq %rdi
19229 + pax_force_retaddr
19230 + retq
19231 +ENDPROC(pax_enter_kernel_user)
19232 +
19233 +ENTRY(pax_exit_kernel_user)
19234 + pushq %rdi
19235 + pushq %rbx
19236 +
19237 +#ifdef CONFIG_PARAVIRT
19238 + PV_SAVE_REGS(CLBR_RDI)
19239 +#endif
19240 +
19241 +#ifdef CONFIG_PAX_KERNEXEC
19242 + GET_CR0_INTO_RDI
19243 + btr $16,%rdi
19244 + jnc 3f
19245 + SET_RDI_INTO_CR0
19246 +#endif
19247 +
19248 + GET_CR3_INTO_RDI
19249 + mov %rdi,%rbx
19250 + add $__START_KERNEL_map,%rbx
19251 + sub phys_base(%rip),%rbx
19252 +
19253 +#ifdef CONFIG_PARAVIRT
19254 + cmpl $0, pv_info+PARAVIRT_enabled
19255 + jz 1f
19256 + i = 0
19257 + .rept USER_PGD_PTRS
19258 + mov i*8(%rbx),%rsi
19259 + mov $0x67,%sil
19260 + lea i*8(%rbx),%rdi
19261 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19262 + i = i + 1
19263 + .endr
19264 + jmp 2f
19265 +1:
19266 +#endif
19267 +
19268 + i = 0
19269 + .rept USER_PGD_PTRS
19270 + movb $0x67,i*8(%rbx)
19271 + i = i + 1
19272 + .endr
19273 +
19274 +#ifdef CONFIG_PARAVIRT
19275 +2: PV_RESTORE_REGS(CLBR_RDI)
19276 +#endif
19277 +
19278 + popq %rbx
19279 + popq %rdi
19280 + pax_force_retaddr
19281 + retq
19282 +3: ud2
19283 + jmp 3b
19284 +ENDPROC(pax_exit_kernel_user)
19285 +#endif
19286 +
19287 + .macro pax_enter_kernel_nmi
19288 + pax_set_fptr_mask
19289 +
19290 +#ifdef CONFIG_PAX_KERNEXEC
19291 + GET_CR0_INTO_RDI
19292 + bts $16,%rdi
19293 + jc 110f
19294 + SET_RDI_INTO_CR0
19295 + or $2,%ebx
19296 +110:
19297 +#endif
19298 + .endm
19299 +
19300 + .macro pax_exit_kernel_nmi
19301 +#ifdef CONFIG_PAX_KERNEXEC
19302 + btr $1,%ebx
19303 + jnc 110f
19304 + GET_CR0_INTO_RDI
19305 + btr $16,%rdi
19306 + SET_RDI_INTO_CR0
19307 +110:
19308 +#endif
19309 + .endm
19310 +
19311 + .macro pax_erase_kstack
19312 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19313 + call pax_erase_kstack
19314 +#endif
19315 + .endm
19316 +
19317 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19318 +ENTRY(pax_erase_kstack)
19319 + pushq %rdi
19320 + pushq %rcx
19321 + pushq %rax
19322 + pushq %r11
19323 +
19324 + GET_THREAD_INFO(%r11)
19325 + mov TI_lowest_stack(%r11), %rdi
19326 + mov $-0xBEEF, %rax
19327 + std
19328 +
19329 +1: mov %edi, %ecx
19330 + and $THREAD_SIZE_asm - 1, %ecx
19331 + shr $3, %ecx
19332 + repne scasq
19333 + jecxz 2f
19334 +
19335 + cmp $2*8, %ecx
19336 + jc 2f
19337 +
19338 + mov $2*8, %ecx
19339 + repe scasq
19340 + jecxz 2f
19341 + jne 1b
19342 +
19343 +2: cld
19344 + mov %esp, %ecx
19345 + sub %edi, %ecx
19346 +
19347 + cmp $THREAD_SIZE_asm, %rcx
19348 + jb 3f
19349 + ud2
19350 +3:
19351 +
19352 + shr $3, %ecx
19353 + rep stosq
19354 +
19355 + mov TI_task_thread_sp0(%r11), %rdi
19356 + sub $256, %rdi
19357 + mov %rdi, TI_lowest_stack(%r11)
19358 +
19359 + popq %r11
19360 + popq %rax
19361 + popq %rcx
19362 + popq %rdi
19363 + pax_force_retaddr
19364 + ret
19365 +ENDPROC(pax_erase_kstack)
19366 +#endif
19367
19368 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19369 #ifdef CONFIG_TRACE_IRQFLAGS
19370 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19371 .endm
19372
19373 .macro UNFAKE_STACK_FRAME
19374 - addq $8*6, %rsp
19375 - CFI_ADJUST_CFA_OFFSET -(6*8)
19376 + addq $8*6 + ARG_SKIP, %rsp
19377 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19378 .endm
19379
19380 /*
19381 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19382 movq %rsp, %rsi
19383
19384 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19385 - testl $3, CS-RBP(%rsi)
19386 + testb $3, CS-RBP(%rsi)
19387 je 1f
19388 SWAPGS
19389 /*
19390 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19391 movq_cfi r15, R15+16
19392 movq %r11, 8(%rsp) /* return address */
19393 FIXUP_TOP_OF_STACK %r11, 16
19394 + pax_force_retaddr
19395 ret
19396 CFI_ENDPROC
19397 -END(save_rest)
19398 +ENDPROC(save_rest)
19399
19400 /* save complete stack frame */
19401 .pushsection .kprobes.text, "ax"
19402 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19403 js 1f /* negative -> in kernel */
19404 SWAPGS
19405 xorl %ebx,%ebx
19406 -1: ret
19407 +1: pax_force_retaddr_bts
19408 + ret
19409 CFI_ENDPROC
19410 -END(save_paranoid)
19411 +ENDPROC(save_paranoid)
19412 .popsection
19413
19414 /*
19415 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19416
19417 RESTORE_REST
19418
19419 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19420 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19421 jz 1f
19422
19423 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19424 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19425 RESTORE_REST
19426 jmp int_ret_from_sys_call
19427 CFI_ENDPROC
19428 -END(ret_from_fork)
19429 +ENDPROC(ret_from_fork)
19430
19431 /*
19432 * System call entry. Up to 6 arguments in registers are supported.
19433 @@ -608,7 +922,7 @@ END(ret_from_fork)
19434 ENTRY(system_call)
19435 CFI_STARTPROC simple
19436 CFI_SIGNAL_FRAME
19437 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19438 + CFI_DEF_CFA rsp,0
19439 CFI_REGISTER rip,rcx
19440 /*CFI_REGISTER rflags,r11*/
19441 SWAPGS_UNSAFE_STACK
19442 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19443
19444 movq %rsp,PER_CPU_VAR(old_rsp)
19445 movq PER_CPU_VAR(kernel_stack),%rsp
19446 + SAVE_ARGS 8*6,0
19447 + pax_enter_kernel_user
19448 +
19449 +#ifdef CONFIG_PAX_RANDKSTACK
19450 + pax_erase_kstack
19451 +#endif
19452 +
19453 /*
19454 * No need to follow this irqs off/on section - it's straight
19455 * and short:
19456 */
19457 ENABLE_INTERRUPTS(CLBR_NONE)
19458 - SAVE_ARGS 8,0
19459 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19460 movq %rcx,RIP-ARGOFFSET(%rsp)
19461 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19462 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19463 + GET_THREAD_INFO(%rcx)
19464 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19465 jnz tracesys
19466 system_call_fastpath:
19467 #if __SYSCALL_MASK == ~0
19468 @@ -640,7 +961,7 @@ system_call_fastpath:
19469 cmpl $__NR_syscall_max,%eax
19470 #endif
19471 ja badsys
19472 - movq %r10,%rcx
19473 + movq R10-ARGOFFSET(%rsp),%rcx
19474 call *sys_call_table(,%rax,8) # XXX: rip relative
19475 movq %rax,RAX-ARGOFFSET(%rsp)
19476 /*
19477 @@ -654,10 +975,13 @@ sysret_check:
19478 LOCKDEP_SYS_EXIT
19479 DISABLE_INTERRUPTS(CLBR_NONE)
19480 TRACE_IRQS_OFF
19481 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19482 + GET_THREAD_INFO(%rcx)
19483 + movl TI_flags(%rcx),%edx
19484 andl %edi,%edx
19485 jnz sysret_careful
19486 CFI_REMEMBER_STATE
19487 + pax_exit_kernel_user
19488 + pax_erase_kstack
19489 /*
19490 * sysretq will re-enable interrupts:
19491 */
19492 @@ -709,14 +1033,18 @@ badsys:
19493 * jump back to the normal fast path.
19494 */
19495 auditsys:
19496 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19497 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19498 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19499 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19500 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19501 movq %rax,%rsi /* 2nd arg: syscall number */
19502 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19503 call __audit_syscall_entry
19504 +
19505 + pax_erase_kstack
19506 +
19507 LOAD_ARGS 0 /* reload call-clobbered registers */
19508 + pax_set_fptr_mask
19509 jmp system_call_fastpath
19510
19511 /*
19512 @@ -737,7 +1065,7 @@ sysret_audit:
19513 /* Do syscall tracing */
19514 tracesys:
19515 #ifdef CONFIG_AUDITSYSCALL
19516 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19517 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19518 jz auditsys
19519 #endif
19520 SAVE_REST
19521 @@ -745,12 +1073,16 @@ tracesys:
19522 FIXUP_TOP_OF_STACK %rdi
19523 movq %rsp,%rdi
19524 call syscall_trace_enter
19525 +
19526 + pax_erase_kstack
19527 +
19528 /*
19529 * Reload arg registers from stack in case ptrace changed them.
19530 * We don't reload %rax because syscall_trace_enter() returned
19531 * the value it wants us to use in the table lookup.
19532 */
19533 LOAD_ARGS ARGOFFSET, 1
19534 + pax_set_fptr_mask
19535 RESTORE_REST
19536 #if __SYSCALL_MASK == ~0
19537 cmpq $__NR_syscall_max,%rax
19538 @@ -759,7 +1091,7 @@ tracesys:
19539 cmpl $__NR_syscall_max,%eax
19540 #endif
19541 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19542 - movq %r10,%rcx /* fixup for C */
19543 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19544 call *sys_call_table(,%rax,8)
19545 movq %rax,RAX-ARGOFFSET(%rsp)
19546 /* Use IRET because user could have changed frame */
19547 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19548 andl %edi,%edx
19549 jnz int_careful
19550 andl $~TS_COMPAT,TI_status(%rcx)
19551 - jmp retint_swapgs
19552 + pax_exit_kernel_user
19553 + pax_erase_kstack
19554 + jmp retint_swapgs_pax
19555
19556 /* Either reschedule or signal or syscall exit tracking needed. */
19557 /* First do a reschedule test. */
19558 @@ -826,7 +1160,7 @@ int_restore_rest:
19559 TRACE_IRQS_OFF
19560 jmp int_with_check
19561 CFI_ENDPROC
19562 -END(system_call)
19563 +ENDPROC(system_call)
19564
19565 .macro FORK_LIKE func
19566 ENTRY(stub_\func)
19567 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19568 DEFAULT_FRAME 0 8 /* offset 8: return address */
19569 call sys_\func
19570 RESTORE_TOP_OF_STACK %r11, 8
19571 + pax_force_retaddr
19572 ret $REST_SKIP /* pop extended registers */
19573 CFI_ENDPROC
19574 -END(stub_\func)
19575 +ENDPROC(stub_\func)
19576 .endm
19577
19578 .macro FIXED_FRAME label,func
19579 @@ -851,9 +1186,10 @@ ENTRY(\label)
19580 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19581 call \func
19582 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19583 + pax_force_retaddr
19584 ret
19585 CFI_ENDPROC
19586 -END(\label)
19587 +ENDPROC(\label)
19588 .endm
19589
19590 FORK_LIKE clone
19591 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19592 movq_cfi_restore R12+8, r12
19593 movq_cfi_restore RBP+8, rbp
19594 movq_cfi_restore RBX+8, rbx
19595 + pax_force_retaddr
19596 ret $REST_SKIP /* pop extended registers */
19597 CFI_ENDPROC
19598 -END(ptregscall_common)
19599 +ENDPROC(ptregscall_common)
19600
19601 ENTRY(stub_execve)
19602 CFI_STARTPROC
19603 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19604 RESTORE_REST
19605 jmp int_ret_from_sys_call
19606 CFI_ENDPROC
19607 -END(stub_execve)
19608 +ENDPROC(stub_execve)
19609
19610 /*
19611 * sigreturn is special because it needs to restore all registers on return.
19612 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19613 RESTORE_REST
19614 jmp int_ret_from_sys_call
19615 CFI_ENDPROC
19616 -END(stub_rt_sigreturn)
19617 +ENDPROC(stub_rt_sigreturn)
19618
19619 #ifdef CONFIG_X86_X32_ABI
19620 ENTRY(stub_x32_rt_sigreturn)
19621 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19622 RESTORE_REST
19623 jmp int_ret_from_sys_call
19624 CFI_ENDPROC
19625 -END(stub_x32_rt_sigreturn)
19626 +ENDPROC(stub_x32_rt_sigreturn)
19627
19628 ENTRY(stub_x32_execve)
19629 CFI_STARTPROC
19630 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19631 RESTORE_REST
19632 jmp int_ret_from_sys_call
19633 CFI_ENDPROC
19634 -END(stub_x32_execve)
19635 +ENDPROC(stub_x32_execve)
19636
19637 #endif
19638
19639 @@ -967,7 +1304,7 @@ vector=vector+1
19640 2: jmp common_interrupt
19641 .endr
19642 CFI_ENDPROC
19643 -END(irq_entries_start)
19644 +ENDPROC(irq_entries_start)
19645
19646 .previous
19647 END(interrupt)
19648 @@ -987,6 +1324,16 @@ END(interrupt)
19649 subq $ORIG_RAX-RBP, %rsp
19650 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19651 SAVE_ARGS_IRQ
19652 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19653 + testb $3, CS(%rdi)
19654 + jnz 1f
19655 + pax_enter_kernel
19656 + jmp 2f
19657 +1: pax_enter_kernel_user
19658 +2:
19659 +#else
19660 + pax_enter_kernel
19661 +#endif
19662 call \func
19663 .endm
19664
19665 @@ -1019,7 +1366,7 @@ ret_from_intr:
19666
19667 exit_intr:
19668 GET_THREAD_INFO(%rcx)
19669 - testl $3,CS-ARGOFFSET(%rsp)
19670 + testb $3,CS-ARGOFFSET(%rsp)
19671 je retint_kernel
19672
19673 /* Interrupt came from user space */
19674 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19675 * The iretq could re-enable interrupts:
19676 */
19677 DISABLE_INTERRUPTS(CLBR_ANY)
19678 + pax_exit_kernel_user
19679 +retint_swapgs_pax:
19680 TRACE_IRQS_IRETQ
19681 SWAPGS
19682 jmp restore_args
19683
19684 retint_restore_args: /* return to kernel space */
19685 DISABLE_INTERRUPTS(CLBR_ANY)
19686 + pax_exit_kernel
19687 + pax_force_retaddr (RIP-ARGOFFSET)
19688 /*
19689 * The iretq could re-enable interrupts:
19690 */
19691 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19692 #endif
19693
19694 CFI_ENDPROC
19695 -END(common_interrupt)
19696 +ENDPROC(common_interrupt)
19697 /*
19698 * End of kprobes section
19699 */
19700 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19701 interrupt \do_sym
19702 jmp ret_from_intr
19703 CFI_ENDPROC
19704 -END(\sym)
19705 +ENDPROC(\sym)
19706 .endm
19707
19708 #ifdef CONFIG_SMP
19709 @@ -1208,12 +1559,22 @@ ENTRY(\sym)
19710 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19711 call error_entry
19712 DEFAULT_FRAME 0
19713 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19714 + testb $3, CS(%rsp)
19715 + jnz 1f
19716 + pax_enter_kernel
19717 + jmp 2f
19718 +1: pax_enter_kernel_user
19719 +2:
19720 +#else
19721 + pax_enter_kernel
19722 +#endif
19723 movq %rsp,%rdi /* pt_regs pointer */
19724 xorl %esi,%esi /* no error code */
19725 call \do_sym
19726 jmp error_exit /* %ebx: no swapgs flag */
19727 CFI_ENDPROC
19728 -END(\sym)
19729 +ENDPROC(\sym)
19730 .endm
19731
19732 .macro paranoidzeroentry sym do_sym
19733 @@ -1226,15 +1587,25 @@ ENTRY(\sym)
19734 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19735 call save_paranoid
19736 TRACE_IRQS_OFF
19737 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19738 + testb $3, CS(%rsp)
19739 + jnz 1f
19740 + pax_enter_kernel
19741 + jmp 2f
19742 +1: pax_enter_kernel_user
19743 +2:
19744 +#else
19745 + pax_enter_kernel
19746 +#endif
19747 movq %rsp,%rdi /* pt_regs pointer */
19748 xorl %esi,%esi /* no error code */
19749 call \do_sym
19750 jmp paranoid_exit /* %ebx: no swapgs flag */
19751 CFI_ENDPROC
19752 -END(\sym)
19753 +ENDPROC(\sym)
19754 .endm
19755
19756 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19757 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19758 .macro paranoidzeroentry_ist sym do_sym ist
19759 ENTRY(\sym)
19760 INTR_FRAME
19761 @@ -1245,14 +1616,30 @@ ENTRY(\sym)
19762 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19763 call save_paranoid
19764 TRACE_IRQS_OFF_DEBUG
19765 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19766 + testb $3, CS(%rsp)
19767 + jnz 1f
19768 + pax_enter_kernel
19769 + jmp 2f
19770 +1: pax_enter_kernel_user
19771 +2:
19772 +#else
19773 + pax_enter_kernel
19774 +#endif
19775 movq %rsp,%rdi /* pt_regs pointer */
19776 xorl %esi,%esi /* no error code */
19777 +#ifdef CONFIG_SMP
19778 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19779 + lea init_tss(%r12), %r12
19780 +#else
19781 + lea init_tss(%rip), %r12
19782 +#endif
19783 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19784 call \do_sym
19785 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19786 jmp paranoid_exit /* %ebx: no swapgs flag */
19787 CFI_ENDPROC
19788 -END(\sym)
19789 +ENDPROC(\sym)
19790 .endm
19791
19792 .macro errorentry sym do_sym
19793 @@ -1264,13 +1651,23 @@ ENTRY(\sym)
19794 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19795 call error_entry
19796 DEFAULT_FRAME 0
19797 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19798 + testb $3, CS(%rsp)
19799 + jnz 1f
19800 + pax_enter_kernel
19801 + jmp 2f
19802 +1: pax_enter_kernel_user
19803 +2:
19804 +#else
19805 + pax_enter_kernel
19806 +#endif
19807 movq %rsp,%rdi /* pt_regs pointer */
19808 movq ORIG_RAX(%rsp),%rsi /* get error code */
19809 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19810 call \do_sym
19811 jmp error_exit /* %ebx: no swapgs flag */
19812 CFI_ENDPROC
19813 -END(\sym)
19814 +ENDPROC(\sym)
19815 .endm
19816
19817 /* error code is on the stack already */
19818 @@ -1284,13 +1681,23 @@ ENTRY(\sym)
19819 call save_paranoid
19820 DEFAULT_FRAME 0
19821 TRACE_IRQS_OFF
19822 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19823 + testb $3, CS(%rsp)
19824 + jnz 1f
19825 + pax_enter_kernel
19826 + jmp 2f
19827 +1: pax_enter_kernel_user
19828 +2:
19829 +#else
19830 + pax_enter_kernel
19831 +#endif
19832 movq %rsp,%rdi /* pt_regs pointer */
19833 movq ORIG_RAX(%rsp),%rsi /* get error code */
19834 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19835 call \do_sym
19836 jmp paranoid_exit /* %ebx: no swapgs flag */
19837 CFI_ENDPROC
19838 -END(\sym)
19839 +ENDPROC(\sym)
19840 .endm
19841
19842 zeroentry divide_error do_divide_error
19843 @@ -1320,9 +1727,10 @@ gs_change:
19844 2: mfence /* workaround */
19845 SWAPGS
19846 popfq_cfi
19847 + pax_force_retaddr
19848 ret
19849 CFI_ENDPROC
19850 -END(native_load_gs_index)
19851 +ENDPROC(native_load_gs_index)
19852
19853 _ASM_EXTABLE(gs_change,bad_gs)
19854 .section .fixup,"ax"
19855 @@ -1350,9 +1758,10 @@ ENTRY(call_softirq)
19856 CFI_DEF_CFA_REGISTER rsp
19857 CFI_ADJUST_CFA_OFFSET -8
19858 decl PER_CPU_VAR(irq_count)
19859 + pax_force_retaddr
19860 ret
19861 CFI_ENDPROC
19862 -END(call_softirq)
19863 +ENDPROC(call_softirq)
19864
19865 #ifdef CONFIG_XEN
19866 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19867 @@ -1390,7 +1799,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19868 decl PER_CPU_VAR(irq_count)
19869 jmp error_exit
19870 CFI_ENDPROC
19871 -END(xen_do_hypervisor_callback)
19872 +ENDPROC(xen_do_hypervisor_callback)
19873
19874 /*
19875 * Hypervisor uses this for application faults while it executes.
19876 @@ -1449,7 +1858,7 @@ ENTRY(xen_failsafe_callback)
19877 SAVE_ALL
19878 jmp error_exit
19879 CFI_ENDPROC
19880 -END(xen_failsafe_callback)
19881 +ENDPROC(xen_failsafe_callback)
19882
19883 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19884 xen_hvm_callback_vector xen_evtchn_do_upcall
19885 @@ -1501,18 +1910,33 @@ ENTRY(paranoid_exit)
19886 DEFAULT_FRAME
19887 DISABLE_INTERRUPTS(CLBR_NONE)
19888 TRACE_IRQS_OFF_DEBUG
19889 - testl %ebx,%ebx /* swapgs needed? */
19890 + testl $1,%ebx /* swapgs needed? */
19891 jnz paranoid_restore
19892 - testl $3,CS(%rsp)
19893 + testb $3,CS(%rsp)
19894 jnz paranoid_userspace
19895 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19896 + pax_exit_kernel
19897 + TRACE_IRQS_IRETQ 0
19898 + SWAPGS_UNSAFE_STACK
19899 + RESTORE_ALL 8
19900 + pax_force_retaddr_bts
19901 + jmp irq_return
19902 +#endif
19903 paranoid_swapgs:
19904 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19905 + pax_exit_kernel_user
19906 +#else
19907 + pax_exit_kernel
19908 +#endif
19909 TRACE_IRQS_IRETQ 0
19910 SWAPGS_UNSAFE_STACK
19911 RESTORE_ALL 8
19912 jmp irq_return
19913 paranoid_restore:
19914 + pax_exit_kernel
19915 TRACE_IRQS_IRETQ_DEBUG 0
19916 RESTORE_ALL 8
19917 + pax_force_retaddr_bts
19918 jmp irq_return
19919 paranoid_userspace:
19920 GET_THREAD_INFO(%rcx)
19921 @@ -1541,7 +1965,7 @@ paranoid_schedule:
19922 TRACE_IRQS_OFF
19923 jmp paranoid_userspace
19924 CFI_ENDPROC
19925 -END(paranoid_exit)
19926 +ENDPROC(paranoid_exit)
19927
19928 /*
19929 * Exception entry point. This expects an error code/orig_rax on the stack.
19930 @@ -1568,12 +1992,13 @@ ENTRY(error_entry)
19931 movq_cfi r14, R14+8
19932 movq_cfi r15, R15+8
19933 xorl %ebx,%ebx
19934 - testl $3,CS+8(%rsp)
19935 + testb $3,CS+8(%rsp)
19936 je error_kernelspace
19937 error_swapgs:
19938 SWAPGS
19939 error_sti:
19940 TRACE_IRQS_OFF
19941 + pax_force_retaddr_bts
19942 ret
19943
19944 /*
19945 @@ -1600,7 +2025,7 @@ bstep_iret:
19946 movq %rcx,RIP+8(%rsp)
19947 jmp error_swapgs
19948 CFI_ENDPROC
19949 -END(error_entry)
19950 +ENDPROC(error_entry)
19951
19952
19953 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19954 @@ -1611,7 +2036,7 @@ ENTRY(error_exit)
19955 DISABLE_INTERRUPTS(CLBR_NONE)
19956 TRACE_IRQS_OFF
19957 GET_THREAD_INFO(%rcx)
19958 - testl %eax,%eax
19959 + testl $1,%eax
19960 jne retint_kernel
19961 LOCKDEP_SYS_EXIT_IRQ
19962 movl TI_flags(%rcx),%edx
19963 @@ -1620,7 +2045,7 @@ ENTRY(error_exit)
19964 jnz retint_careful
19965 jmp retint_swapgs
19966 CFI_ENDPROC
19967 -END(error_exit)
19968 +ENDPROC(error_exit)
19969
19970 /*
19971 * Test if a given stack is an NMI stack or not.
19972 @@ -1678,9 +2103,11 @@ ENTRY(nmi)
19973 * If %cs was not the kernel segment, then the NMI triggered in user
19974 * space, which means it is definitely not nested.
19975 */
19976 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19977 + je 1f
19978 cmpl $__KERNEL_CS, 16(%rsp)
19979 jne first_nmi
19980 -
19981 +1:
19982 /*
19983 * Check the special variable on the stack to see if NMIs are
19984 * executing.
19985 @@ -1714,8 +2141,7 @@ nested_nmi:
19986
19987 1:
19988 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19989 - leaq -1*8(%rsp), %rdx
19990 - movq %rdx, %rsp
19991 + subq $8, %rsp
19992 CFI_ADJUST_CFA_OFFSET 1*8
19993 leaq -10*8(%rsp), %rdx
19994 pushq_cfi $__KERNEL_DS
19995 @@ -1733,6 +2159,7 @@ nested_nmi_out:
19996 CFI_RESTORE rdx
19997
19998 /* No need to check faults here */
19999 +# pax_force_retaddr_bts
20000 INTERRUPT_RETURN
20001
20002 CFI_RESTORE_STATE
20003 @@ -1849,6 +2276,8 @@ end_repeat_nmi:
20004 */
20005 movq %cr2, %r12
20006
20007 + pax_enter_kernel_nmi
20008 +
20009 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20010 movq %rsp,%rdi
20011 movq $-1,%rsi
20012 @@ -1861,26 +2290,31 @@ end_repeat_nmi:
20013 movq %r12, %cr2
20014 1:
20015
20016 - testl %ebx,%ebx /* swapgs needed? */
20017 + testl $1,%ebx /* swapgs needed? */
20018 jnz nmi_restore
20019 nmi_swapgs:
20020 SWAPGS_UNSAFE_STACK
20021 nmi_restore:
20022 + pax_exit_kernel_nmi
20023 /* Pop the extra iret frame at once */
20024 RESTORE_ALL 6*8
20025 + testb $3, 8(%rsp)
20026 + jnz 1f
20027 + pax_force_retaddr_bts
20028 +1:
20029
20030 /* Clear the NMI executing stack variable */
20031 movq $0, 5*8(%rsp)
20032 jmp irq_return
20033 CFI_ENDPROC
20034 -END(nmi)
20035 +ENDPROC(nmi)
20036
20037 ENTRY(ignore_sysret)
20038 CFI_STARTPROC
20039 mov $-ENOSYS,%eax
20040 sysret
20041 CFI_ENDPROC
20042 -END(ignore_sysret)
20043 +ENDPROC(ignore_sysret)
20044
20045 /*
20046 * End of kprobes section
20047 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20048 index 42a392a..fbbd930 100644
20049 --- a/arch/x86/kernel/ftrace.c
20050 +++ b/arch/x86/kernel/ftrace.c
20051 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20052 {
20053 unsigned char replaced[MCOUNT_INSN_SIZE];
20054
20055 + ip = ktla_ktva(ip);
20056 +
20057 /*
20058 * Note: Due to modules and __init, code can
20059 * disappear and change, we need to protect against faulting
20060 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20061 unsigned char old[MCOUNT_INSN_SIZE], *new;
20062 int ret;
20063
20064 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20065 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20066 new = ftrace_call_replace(ip, (unsigned long)func);
20067
20068 /* See comment above by declaration of modifying_ftrace_code */
20069 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20070 /* Also update the regs callback function */
20071 if (!ret) {
20072 ip = (unsigned long)(&ftrace_regs_call);
20073 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20074 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20075 new = ftrace_call_replace(ip, (unsigned long)func);
20076 ret = ftrace_modify_code(ip, old, new);
20077 }
20078 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20079 * kernel identity mapping to modify code.
20080 */
20081 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20082 - ip = (unsigned long)__va(__pa_symbol(ip));
20083 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20084
20085 return probe_kernel_write((void *)ip, val, size);
20086 }
20087 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20088 unsigned char replaced[MCOUNT_INSN_SIZE];
20089 unsigned char brk = BREAKPOINT_INSTRUCTION;
20090
20091 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20092 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20093 return -EFAULT;
20094
20095 /* Make sure it is what we expect it to be */
20096 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20097 return ret;
20098
20099 fail_update:
20100 - probe_kernel_write((void *)ip, &old_code[0], 1);
20101 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20102 goto out;
20103 }
20104
20105 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20106 {
20107 unsigned char code[MCOUNT_INSN_SIZE];
20108
20109 + ip = ktla_ktva(ip);
20110 +
20111 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20112 return -EFAULT;
20113
20114 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20115 index 55b6761..a6456fc 100644
20116 --- a/arch/x86/kernel/head64.c
20117 +++ b/arch/x86/kernel/head64.c
20118 @@ -67,12 +67,12 @@ again:
20119 pgd = *pgd_p;
20120
20121 /*
20122 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
20123 - * critical -- __PAGE_OFFSET would point us back into the dynamic
20124 + * The use of __early_va rather than __va here is critical:
20125 + * __va would point us back into the dynamic
20126 * range and we might end up looping forever...
20127 */
20128 if (pgd)
20129 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20130 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
20131 else {
20132 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20133 reset_early_page_tables();
20134 @@ -82,13 +82,13 @@ again:
20135 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
20136 for (i = 0; i < PTRS_PER_PUD; i++)
20137 pud_p[i] = 0;
20138 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20139 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
20140 }
20141 pud_p += pud_index(address);
20142 pud = *pud_p;
20143
20144 if (pud)
20145 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20146 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
20147 else {
20148 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20149 reset_early_page_tables();
20150 @@ -98,7 +98,7 @@ again:
20151 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
20152 for (i = 0; i < PTRS_PER_PMD; i++)
20153 pmd_p[i] = 0;
20154 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20155 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
20156 }
20157 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
20158 pmd_p[pmd_index(address)] = pmd;
20159 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20160 if (console_loglevel == 10)
20161 early_printk("Kernel alive\n");
20162
20163 - clear_page(init_level4_pgt);
20164 /* set init_level4_pgt kernel high mapping*/
20165 init_level4_pgt[511] = early_level4_pgt[511];
20166
20167 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20168 index 73afd11..d1670f5 100644
20169 --- a/arch/x86/kernel/head_32.S
20170 +++ b/arch/x86/kernel/head_32.S
20171 @@ -26,6 +26,12 @@
20172 /* Physical address */
20173 #define pa(X) ((X) - __PAGE_OFFSET)
20174
20175 +#ifdef CONFIG_PAX_KERNEXEC
20176 +#define ta(X) (X)
20177 +#else
20178 +#define ta(X) ((X) - __PAGE_OFFSET)
20179 +#endif
20180 +
20181 /*
20182 * References to members of the new_cpu_data structure.
20183 */
20184 @@ -55,11 +61,7 @@
20185 * and small than max_low_pfn, otherwise will waste some page table entries
20186 */
20187
20188 -#if PTRS_PER_PMD > 1
20189 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20190 -#else
20191 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20192 -#endif
20193 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20194
20195 /* Number of possible pages in the lowmem region */
20196 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20197 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20198 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20199
20200 /*
20201 + * Real beginning of normal "text" segment
20202 + */
20203 +ENTRY(stext)
20204 +ENTRY(_stext)
20205 +
20206 +/*
20207 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20208 * %esi points to the real-mode code as a 32-bit pointer.
20209 * CS and DS must be 4 GB flat segments, but we don't depend on
20210 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20211 * can.
20212 */
20213 __HEAD
20214 +
20215 +#ifdef CONFIG_PAX_KERNEXEC
20216 + jmp startup_32
20217 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20218 +.fill PAGE_SIZE-5,1,0xcc
20219 +#endif
20220 +
20221 ENTRY(startup_32)
20222 movl pa(stack_start),%ecx
20223
20224 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20225 2:
20226 leal -__PAGE_OFFSET(%ecx),%esp
20227
20228 +#ifdef CONFIG_SMP
20229 + movl $pa(cpu_gdt_table),%edi
20230 + movl $__per_cpu_load,%eax
20231 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20232 + rorl $16,%eax
20233 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20234 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20235 + movl $__per_cpu_end - 1,%eax
20236 + subl $__per_cpu_start,%eax
20237 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20238 +#endif
20239 +
20240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20241 + movl $NR_CPUS,%ecx
20242 + movl $pa(cpu_gdt_table),%edi
20243 +1:
20244 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20245 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20246 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20247 + addl $PAGE_SIZE_asm,%edi
20248 + loop 1b
20249 +#endif
20250 +
20251 +#ifdef CONFIG_PAX_KERNEXEC
20252 + movl $pa(boot_gdt),%edi
20253 + movl $__LOAD_PHYSICAL_ADDR,%eax
20254 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20255 + rorl $16,%eax
20256 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20257 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20258 + rorl $16,%eax
20259 +
20260 + ljmp $(__BOOT_CS),$1f
20261 +1:
20262 +
20263 + movl $NR_CPUS,%ecx
20264 + movl $pa(cpu_gdt_table),%edi
20265 + addl $__PAGE_OFFSET,%eax
20266 +1:
20267 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20268 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20269 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20270 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20271 + rorl $16,%eax
20272 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20273 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20274 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20275 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20276 + rorl $16,%eax
20277 + addl $PAGE_SIZE_asm,%edi
20278 + loop 1b
20279 +#endif
20280 +
20281 /*
20282 * Clear BSS first so that there are no surprises...
20283 */
20284 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20285 movl %eax, pa(max_pfn_mapped)
20286
20287 /* Do early initialization of the fixmap area */
20288 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20289 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20290 +#ifdef CONFIG_COMPAT_VDSO
20291 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20292 +#else
20293 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20294 +#endif
20295 #else /* Not PAE */
20296
20297 page_pde_offset = (__PAGE_OFFSET >> 20);
20298 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20299 movl %eax, pa(max_pfn_mapped)
20300
20301 /* Do early initialization of the fixmap area */
20302 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20303 - movl %eax,pa(initial_page_table+0xffc)
20304 +#ifdef CONFIG_COMPAT_VDSO
20305 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20306 +#else
20307 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20308 +#endif
20309 #endif
20310
20311 #ifdef CONFIG_PARAVIRT
20312 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20313 cmpl $num_subarch_entries, %eax
20314 jae bad_subarch
20315
20316 - movl pa(subarch_entries)(,%eax,4), %eax
20317 - subl $__PAGE_OFFSET, %eax
20318 - jmp *%eax
20319 + jmp *pa(subarch_entries)(,%eax,4)
20320
20321 bad_subarch:
20322 WEAK(lguest_entry)
20323 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20324 __INITDATA
20325
20326 subarch_entries:
20327 - .long default_entry /* normal x86/PC */
20328 - .long lguest_entry /* lguest hypervisor */
20329 - .long xen_entry /* Xen hypervisor */
20330 - .long default_entry /* Moorestown MID */
20331 + .long ta(default_entry) /* normal x86/PC */
20332 + .long ta(lguest_entry) /* lguest hypervisor */
20333 + .long ta(xen_entry) /* Xen hypervisor */
20334 + .long ta(default_entry) /* Moorestown MID */
20335 num_subarch_entries = (. - subarch_entries) / 4
20336 .previous
20337 #else
20338 @@ -355,6 +427,7 @@ default_entry:
20339 movl pa(mmu_cr4_features),%eax
20340 movl %eax,%cr4
20341
20342 +#ifdef CONFIG_X86_PAE
20343 testb $X86_CR4_PAE, %al # check if PAE is enabled
20344 jz enable_paging
20345
20346 @@ -383,6 +456,9 @@ default_entry:
20347 /* Make changes effective */
20348 wrmsr
20349
20350 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20351 +#endif
20352 +
20353 enable_paging:
20354
20355 /*
20356 @@ -451,14 +527,20 @@ is486:
20357 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20358 movl %eax,%ss # after changing gdt.
20359
20360 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20361 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20362 movl %eax,%ds
20363 movl %eax,%es
20364
20365 movl $(__KERNEL_PERCPU), %eax
20366 movl %eax,%fs # set this cpu's percpu
20367
20368 +#ifdef CONFIG_CC_STACKPROTECTOR
20369 movl $(__KERNEL_STACK_CANARY),%eax
20370 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20371 + movl $(__USER_DS),%eax
20372 +#else
20373 + xorl %eax,%eax
20374 +#endif
20375 movl %eax,%gs
20376
20377 xorl %eax,%eax # Clear LDT
20378 @@ -534,8 +616,11 @@ setup_once:
20379 * relocation. Manually set base address in stack canary
20380 * segment descriptor.
20381 */
20382 - movl $gdt_page,%eax
20383 + movl $cpu_gdt_table,%eax
20384 movl $stack_canary,%ecx
20385 +#ifdef CONFIG_SMP
20386 + addl $__per_cpu_load,%ecx
20387 +#endif
20388 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20389 shrl $16, %ecx
20390 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20391 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20392 /* This is global to keep gas from relaxing the jumps */
20393 ENTRY(early_idt_handler)
20394 cld
20395 - cmpl $2,%ss:early_recursion_flag
20396 + cmpl $1,%ss:early_recursion_flag
20397 je hlt_loop
20398 incl %ss:early_recursion_flag
20399
20400 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20401 pushl (20+6*4)(%esp) /* trapno */
20402 pushl $fault_msg
20403 call printk
20404 -#endif
20405 call dump_stack
20406 +#endif
20407 hlt_loop:
20408 hlt
20409 jmp hlt_loop
20410 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20411 /* This is the default interrupt "handler" :-) */
20412 ALIGN
20413 ignore_int:
20414 - cld
20415 #ifdef CONFIG_PRINTK
20416 + cmpl $2,%ss:early_recursion_flag
20417 + je hlt_loop
20418 + incl %ss:early_recursion_flag
20419 + cld
20420 pushl %eax
20421 pushl %ecx
20422 pushl %edx
20423 @@ -634,9 +722,6 @@ ignore_int:
20424 movl $(__KERNEL_DS),%eax
20425 movl %eax,%ds
20426 movl %eax,%es
20427 - cmpl $2,early_recursion_flag
20428 - je hlt_loop
20429 - incl early_recursion_flag
20430 pushl 16(%esp)
20431 pushl 24(%esp)
20432 pushl 32(%esp)
20433 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20434 /*
20435 * BSS section
20436 */
20437 -__PAGE_ALIGNED_BSS
20438 - .align PAGE_SIZE
20439 #ifdef CONFIG_X86_PAE
20440 +.section .initial_pg_pmd,"a",@progbits
20441 initial_pg_pmd:
20442 .fill 1024*KPMDS,4,0
20443 #else
20444 +.section .initial_page_table,"a",@progbits
20445 ENTRY(initial_page_table)
20446 .fill 1024,4,0
20447 #endif
20448 +.section .initial_pg_fixmap,"a",@progbits
20449 initial_pg_fixmap:
20450 .fill 1024,4,0
20451 +.section .empty_zero_page,"a",@progbits
20452 ENTRY(empty_zero_page)
20453 .fill 4096,1,0
20454 +.section .swapper_pg_dir,"a",@progbits
20455 ENTRY(swapper_pg_dir)
20456 +#ifdef CONFIG_X86_PAE
20457 + .fill 4,8,0
20458 +#else
20459 .fill 1024,4,0
20460 +#endif
20461 +
20462 +/*
20463 + * The IDT has to be page-aligned to simplify the Pentium
20464 + * F0 0F bug workaround.. We have a special link segment
20465 + * for this.
20466 + */
20467 +.section .idt,"a",@progbits
20468 +ENTRY(idt_table)
20469 + .fill 256,8,0
20470
20471 /*
20472 * This starts the data section.
20473 */
20474 #ifdef CONFIG_X86_PAE
20475 -__PAGE_ALIGNED_DATA
20476 - /* Page-aligned for the benefit of paravirt? */
20477 - .align PAGE_SIZE
20478 +.section .initial_page_table,"a",@progbits
20479 ENTRY(initial_page_table)
20480 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20481 # if KPMDS == 3
20482 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20483 # error "Kernel PMDs should be 1, 2 or 3"
20484 # endif
20485 .align PAGE_SIZE /* needs to be page-sized too */
20486 +
20487 +#ifdef CONFIG_PAX_PER_CPU_PGD
20488 +ENTRY(cpu_pgd)
20489 + .rept NR_CPUS
20490 + .fill 4,8,0
20491 + .endr
20492 +#endif
20493 +
20494 #endif
20495
20496 .data
20497 .balign 4
20498 ENTRY(stack_start)
20499 - .long init_thread_union+THREAD_SIZE
20500 + .long init_thread_union+THREAD_SIZE-8
20501
20502 __INITRODATA
20503 int_msg:
20504 @@ -744,7 +851,7 @@ fault_msg:
20505 * segment size, and 32-bit linear address value:
20506 */
20507
20508 - .data
20509 +.section .rodata,"a",@progbits
20510 .globl boot_gdt_descr
20511 .globl idt_descr
20512
20513 @@ -753,7 +860,7 @@ fault_msg:
20514 .word 0 # 32 bit align gdt_desc.address
20515 boot_gdt_descr:
20516 .word __BOOT_DS+7
20517 - .long boot_gdt - __PAGE_OFFSET
20518 + .long pa(boot_gdt)
20519
20520 .word 0 # 32-bit align idt_desc.address
20521 idt_descr:
20522 @@ -764,7 +871,7 @@ idt_descr:
20523 .word 0 # 32 bit align gdt_desc.address
20524 ENTRY(early_gdt_descr)
20525 .word GDT_ENTRIES*8-1
20526 - .long gdt_page /* Overwritten for secondary CPUs */
20527 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20528
20529 /*
20530 * The boot_gdt must mirror the equivalent in setup.S and is
20531 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20532 .align L1_CACHE_BYTES
20533 ENTRY(boot_gdt)
20534 .fill GDT_ENTRY_BOOT_CS,8,0
20535 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20536 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20537 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20538 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20539 +
20540 + .align PAGE_SIZE_asm
20541 +ENTRY(cpu_gdt_table)
20542 + .rept NR_CPUS
20543 + .quad 0x0000000000000000 /* NULL descriptor */
20544 + .quad 0x0000000000000000 /* 0x0b reserved */
20545 + .quad 0x0000000000000000 /* 0x13 reserved */
20546 + .quad 0x0000000000000000 /* 0x1b reserved */
20547 +
20548 +#ifdef CONFIG_PAX_KERNEXEC
20549 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20550 +#else
20551 + .quad 0x0000000000000000 /* 0x20 unused */
20552 +#endif
20553 +
20554 + .quad 0x0000000000000000 /* 0x28 unused */
20555 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20556 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20557 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20558 + .quad 0x0000000000000000 /* 0x4b reserved */
20559 + .quad 0x0000000000000000 /* 0x53 reserved */
20560 + .quad 0x0000000000000000 /* 0x5b reserved */
20561 +
20562 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20563 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20564 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20565 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20566 +
20567 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20568 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20569 +
20570 + /*
20571 + * Segments used for calling PnP BIOS have byte granularity.
20572 + * The code segments and data segments have fixed 64k limits,
20573 + * the transfer segment sizes are set at run time.
20574 + */
20575 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20576 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20577 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20578 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20579 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20580 +
20581 + /*
20582 + * The APM segments have byte granularity and their bases
20583 + * are set at run time. All have 64k limits.
20584 + */
20585 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20586 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20587 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20588 +
20589 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20590 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20591 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20592 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20593 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20594 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20595 +
20596 + /* Be sure this is zeroed to avoid false validations in Xen */
20597 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20598 + .endr
20599 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20600 index 321d65e..863089b 100644
20601 --- a/arch/x86/kernel/head_64.S
20602 +++ b/arch/x86/kernel/head_64.S
20603 @@ -20,6 +20,8 @@
20604 #include <asm/processor-flags.h>
20605 #include <asm/percpu.h>
20606 #include <asm/nops.h>
20607 +#include <asm/cpufeature.h>
20608 +#include <asm/alternative-asm.h>
20609
20610 #ifdef CONFIG_PARAVIRT
20611 #include <asm/asm-offsets.h>
20612 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20613 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20614 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20615 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20616 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20617 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20618 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20619 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20620 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20621 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20622
20623 .text
20624 __HEAD
20625 @@ -89,11 +97,23 @@ startup_64:
20626 * Fixup the physical addresses in the page table
20627 */
20628 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20629 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20630 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20631 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20632 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20633 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20634
20635 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20636 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20637 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
20638 +#ifndef CONFIG_XEN
20639 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
20640 +#endif
20641
20642 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20643 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20644 +
20645 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20646 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
20647 +
20648 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20649
20650 /*
20651 * Set up the identity mapping for the switchover. These
20652 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
20653 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20654 1:
20655
20656 - /* Enable PAE mode and PGE */
20657 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20658 + /* Enable PAE mode and PSE/PGE */
20659 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20660 movq %rcx, %cr4
20661
20662 /* Setup early boot stage 4 level pagetables. */
20663 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
20664 movl $MSR_EFER, %ecx
20665 rdmsr
20666 btsl $_EFER_SCE, %eax /* Enable System Call */
20667 - btl $20,%edi /* No Execute supported? */
20668 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20669 jnc 1f
20670 btsl $_EFER_NX, %eax
20671 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20672 + leaq init_level4_pgt(%rip), %rdi
20673 +#ifndef CONFIG_EFI
20674 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20675 +#endif
20676 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20677 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20678 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20679 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20680 1: wrmsr /* Make changes effective */
20681
20682 /* Setup cr0 */
20683 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
20684 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20685 * address given in m16:64.
20686 */
20687 + pax_set_fptr_mask
20688 movq initial_code(%rip),%rax
20689 pushq $0 # fake return address to stop unwinder
20690 pushq $__KERNEL_CS # set correct cs
20691 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
20692 call dump_stack
20693 #ifdef CONFIG_KALLSYMS
20694 leaq early_idt_ripmsg(%rip),%rdi
20695 - movq 40(%rsp),%rsi # %rip again
20696 + movq 88(%rsp),%rsi # %rip again
20697 call __print_symbol
20698 #endif
20699 #endif /* EARLY_PRINTK */
20700 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
20701 early_recursion_flag:
20702 .long 0
20703
20704 + .section .rodata,"a",@progbits
20705 #ifdef CONFIG_EARLY_PRINTK
20706 early_idt_msg:
20707 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20708 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
20709 NEXT_PAGE(early_dynamic_pgts)
20710 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
20711
20712 - .data
20713 + .section .rodata,"a",@progbits
20714
20715 -#ifndef CONFIG_XEN
20716 NEXT_PAGE(init_level4_pgt)
20717 - .fill 512,8,0
20718 -#else
20719 -NEXT_PAGE(init_level4_pgt)
20720 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20721 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20722 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20723 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20724 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20725 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20726 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20727 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20728 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20729 .org init_level4_pgt + L4_START_KERNEL*8, 0
20730 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20731 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20732
20733 +#ifdef CONFIG_PAX_PER_CPU_PGD
20734 +NEXT_PAGE(cpu_pgd)
20735 + .rept NR_CPUS
20736 + .fill 512,8,0
20737 + .endr
20738 +#endif
20739 +
20740 NEXT_PAGE(level3_ident_pgt)
20741 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20742 +#ifdef CONFIG_XEN
20743 .fill 511, 8, 0
20744 +#else
20745 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20746 + .fill 510,8,0
20747 +#endif
20748 +
20749 +NEXT_PAGE(level3_vmalloc_start_pgt)
20750 + .fill 512,8,0
20751 +
20752 +NEXT_PAGE(level3_vmalloc_end_pgt)
20753 + .fill 512,8,0
20754 +
20755 +NEXT_PAGE(level3_vmemmap_pgt)
20756 + .fill L3_VMEMMAP_START,8,0
20757 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20758 +
20759 NEXT_PAGE(level2_ident_pgt)
20760 - /* Since I easily can, map the first 1G.
20761 + /* Since I easily can, map the first 2G.
20762 * Don't set NX because code runs from these pages.
20763 */
20764 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20765 -#endif
20766 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20767
20768 NEXT_PAGE(level3_kernel_pgt)
20769 .fill L3_START_KERNEL,8,0
20770 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
20771 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20772 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20773
20774 +NEXT_PAGE(level2_vmemmap_pgt)
20775 + .fill 512,8,0
20776 +
20777 NEXT_PAGE(level2_kernel_pgt)
20778 /*
20779 * 512 MB kernel mapping. We spend a full page on this pagetable
20780 @@ -488,39 +544,64 @@ NEXT_PAGE(level2_kernel_pgt)
20781 KERNEL_IMAGE_SIZE/PMD_SIZE)
20782
20783 NEXT_PAGE(level2_fixmap_pgt)
20784 - .fill 506,8,0
20785 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20786 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20787 - .fill 5,8,0
20788 + .fill 507,8,0
20789 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20790 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20791 + .fill 4,8,0
20792
20793 -NEXT_PAGE(level1_fixmap_pgt)
20794 +NEXT_PAGE(level1_vsyscall_pgt)
20795 .fill 512,8,0
20796
20797 #undef PMDS
20798
20799 - .data
20800 + .align PAGE_SIZE
20801 +ENTRY(cpu_gdt_table)
20802 + .rept NR_CPUS
20803 + .quad 0x0000000000000000 /* NULL descriptor */
20804 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20805 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20806 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20807 + .quad 0x00cffb000000ffff /* __USER32_CS */
20808 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20809 + .quad 0x00affb000000ffff /* __USER_CS */
20810 +
20811 +#ifdef CONFIG_PAX_KERNEXEC
20812 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20813 +#else
20814 + .quad 0x0 /* unused */
20815 +#endif
20816 +
20817 + .quad 0,0 /* TSS */
20818 + .quad 0,0 /* LDT */
20819 + .quad 0,0,0 /* three TLS descriptors */
20820 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20821 + /* asm/segment.h:GDT_ENTRIES must match this */
20822 +
20823 + /* zero the remaining page */
20824 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20825 + .endr
20826 +
20827 .align 16
20828 .globl early_gdt_descr
20829 early_gdt_descr:
20830 .word GDT_ENTRIES*8-1
20831 early_gdt_descr_base:
20832 - .quad INIT_PER_CPU_VAR(gdt_page)
20833 + .quad cpu_gdt_table
20834
20835 ENTRY(phys_base)
20836 /* This must match the first entry in level2_kernel_pgt */
20837 .quad 0x0000000000000000
20838
20839 #include "../../x86/xen/xen-head.S"
20840 -
20841 - .section .bss, "aw", @nobits
20842 - .align L1_CACHE_BYTES
20843 -ENTRY(idt_table)
20844 - .skip IDT_ENTRIES * 16
20845
20846 - .align L1_CACHE_BYTES
20847 -ENTRY(nmi_idt_table)
20848 - .skip IDT_ENTRIES * 16
20849 -
20850 - __PAGE_ALIGNED_BSS
20851 + .section .rodata,"a",@progbits
20852 NEXT_PAGE(empty_zero_page)
20853 .skip PAGE_SIZE
20854 +
20855 + .align L1_CACHE_BYTES
20856 +ENTRY(idt_table)
20857 + .fill 512,8,0
20858 +
20859 + .align L1_CACHE_BYTES
20860 +ENTRY(nmi_idt_table)
20861 + .fill 512,8,0
20862 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20863 index 0fa6912..37fce70 100644
20864 --- a/arch/x86/kernel/i386_ksyms_32.c
20865 +++ b/arch/x86/kernel/i386_ksyms_32.c
20866 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20867 EXPORT_SYMBOL(cmpxchg8b_emu);
20868 #endif
20869
20870 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20871 +
20872 /* Networking helper routines. */
20873 EXPORT_SYMBOL(csum_partial_copy_generic);
20874 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20875 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20876
20877 EXPORT_SYMBOL(__get_user_1);
20878 EXPORT_SYMBOL(__get_user_2);
20879 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20880
20881 EXPORT_SYMBOL(csum_partial);
20882 EXPORT_SYMBOL(empty_zero_page);
20883 +
20884 +#ifdef CONFIG_PAX_KERNEXEC
20885 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20886 +#endif
20887 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20888 index cb33909..1163b40 100644
20889 --- a/arch/x86/kernel/i387.c
20890 +++ b/arch/x86/kernel/i387.c
20891 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20892 static inline bool interrupted_user_mode(void)
20893 {
20894 struct pt_regs *regs = get_irq_regs();
20895 - return regs && user_mode_vm(regs);
20896 + return regs && user_mode(regs);
20897 }
20898
20899 /*
20900 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20901 index 9a5c460..84868423 100644
20902 --- a/arch/x86/kernel/i8259.c
20903 +++ b/arch/x86/kernel/i8259.c
20904 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20905 static void make_8259A_irq(unsigned int irq)
20906 {
20907 disable_irq_nosync(irq);
20908 - io_apic_irqs &= ~(1<<irq);
20909 + io_apic_irqs &= ~(1UL<<irq);
20910 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20911 i8259A_chip.name);
20912 enable_irq(irq);
20913 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20914 "spurious 8259A interrupt: IRQ%d.\n", irq);
20915 spurious_irq_mask |= irqmask;
20916 }
20917 - atomic_inc(&irq_err_count);
20918 + atomic_inc_unchecked(&irq_err_count);
20919 /*
20920 * Theoretically we do not have to handle this IRQ,
20921 * but in Linux this does not cause problems and is
20922 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20923 /* (slave's support for AEOI in flat mode is to be investigated) */
20924 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20925
20926 + pax_open_kernel();
20927 if (auto_eoi)
20928 /*
20929 * In AEOI mode we just have to mask the interrupt
20930 * when acking.
20931 */
20932 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20933 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20934 else
20935 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20936 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20937 + pax_close_kernel();
20938
20939 udelay(100); /* wait for 8259A to initialize */
20940
20941 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20942 index a979b5b..1d6db75 100644
20943 --- a/arch/x86/kernel/io_delay.c
20944 +++ b/arch/x86/kernel/io_delay.c
20945 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20946 * Quirk table for systems that misbehave (lock up, etc.) if port
20947 * 0x80 is used:
20948 */
20949 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20950 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20951 {
20952 .callback = dmi_io_delay_0xed_port,
20953 .ident = "Compaq Presario V6000",
20954 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20955 index 4ddaf66..6292f4e 100644
20956 --- a/arch/x86/kernel/ioport.c
20957 +++ b/arch/x86/kernel/ioport.c
20958 @@ -6,6 +6,7 @@
20959 #include <linux/sched.h>
20960 #include <linux/kernel.h>
20961 #include <linux/capability.h>
20962 +#include <linux/security.h>
20963 #include <linux/errno.h>
20964 #include <linux/types.h>
20965 #include <linux/ioport.h>
20966 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20967
20968 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20969 return -EINVAL;
20970 +#ifdef CONFIG_GRKERNSEC_IO
20971 + if (turn_on && grsec_disable_privio) {
20972 + gr_handle_ioperm();
20973 + return -EPERM;
20974 + }
20975 +#endif
20976 if (turn_on && !capable(CAP_SYS_RAWIO))
20977 return -EPERM;
20978
20979 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20980 * because the ->io_bitmap_max value must match the bitmap
20981 * contents:
20982 */
20983 - tss = &per_cpu(init_tss, get_cpu());
20984 + tss = init_tss + get_cpu();
20985
20986 if (turn_on)
20987 bitmap_clear(t->io_bitmap_ptr, from, num);
20988 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20989 return -EINVAL;
20990 /* Trying to gain more privileges? */
20991 if (level > old) {
20992 +#ifdef CONFIG_GRKERNSEC_IO
20993 + if (grsec_disable_privio) {
20994 + gr_handle_iopl();
20995 + return -EPERM;
20996 + }
20997 +#endif
20998 if (!capable(CAP_SYS_RAWIO))
20999 return -EPERM;
21000 }
21001 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21002 index ac0631d..ff7cb62 100644
21003 --- a/arch/x86/kernel/irq.c
21004 +++ b/arch/x86/kernel/irq.c
21005 @@ -18,7 +18,7 @@
21006 #include <asm/mce.h>
21007 #include <asm/hw_irq.h>
21008
21009 -atomic_t irq_err_count;
21010 +atomic_unchecked_t irq_err_count;
21011
21012 /* Function pointer for generic interrupt vector handling */
21013 void (*x86_platform_ipi_callback)(void) = NULL;
21014 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21015 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21016 seq_printf(p, " Machine check polls\n");
21017 #endif
21018 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21019 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21020 #if defined(CONFIG_X86_IO_APIC)
21021 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21022 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21023 #endif
21024 return 0;
21025 }
21026 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21027
21028 u64 arch_irq_stat(void)
21029 {
21030 - u64 sum = atomic_read(&irq_err_count);
21031 + u64 sum = atomic_read_unchecked(&irq_err_count);
21032 return sum;
21033 }
21034
21035 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21036 index 344faf8..355f60d 100644
21037 --- a/arch/x86/kernel/irq_32.c
21038 +++ b/arch/x86/kernel/irq_32.c
21039 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21040 __asm__ __volatile__("andl %%esp,%0" :
21041 "=r" (sp) : "0" (THREAD_SIZE - 1));
21042
21043 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21044 + return sp < STACK_WARN;
21045 }
21046
21047 static void print_stack_overflow(void)
21048 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21049 * per-CPU IRQ handling contexts (thread information and stack)
21050 */
21051 union irq_ctx {
21052 - struct thread_info tinfo;
21053 - u32 stack[THREAD_SIZE/sizeof(u32)];
21054 + unsigned long previous_esp;
21055 + u32 stack[THREAD_SIZE/sizeof(u32)];
21056 } __attribute__((aligned(THREAD_SIZE)));
21057
21058 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21059 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21060 static inline int
21061 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21062 {
21063 - union irq_ctx *curctx, *irqctx;
21064 + union irq_ctx *irqctx;
21065 u32 *isp, arg1, arg2;
21066
21067 - curctx = (union irq_ctx *) current_thread_info();
21068 irqctx = __this_cpu_read(hardirq_ctx);
21069
21070 /*
21071 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21072 * handler) we can't do that and just have to keep using the
21073 * current stack (which is the irq stack already after all)
21074 */
21075 - if (unlikely(curctx == irqctx))
21076 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21077 return 0;
21078
21079 /* build the stack frame on the IRQ stack */
21080 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21081 - irqctx->tinfo.task = curctx->tinfo.task;
21082 - irqctx->tinfo.previous_esp = current_stack_pointer;
21083 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21084 + irqctx->previous_esp = current_stack_pointer;
21085
21086 - /* Copy the preempt_count so that the [soft]irq checks work. */
21087 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21088 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21089 + __set_fs(MAKE_MM_SEG(0));
21090 +#endif
21091
21092 if (unlikely(overflow))
21093 call_on_stack(print_stack_overflow, isp);
21094 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21095 : "0" (irq), "1" (desc), "2" (isp),
21096 "D" (desc->handle_irq)
21097 : "memory", "cc", "ecx");
21098 +
21099 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21100 + __set_fs(current_thread_info()->addr_limit);
21101 +#endif
21102 +
21103 return 1;
21104 }
21105
21106 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21107 */
21108 void __cpuinit irq_ctx_init(int cpu)
21109 {
21110 - union irq_ctx *irqctx;
21111 -
21112 if (per_cpu(hardirq_ctx, cpu))
21113 return;
21114
21115 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21116 - THREADINFO_GFP,
21117 - THREAD_SIZE_ORDER));
21118 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21119 - irqctx->tinfo.cpu = cpu;
21120 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21121 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21122 -
21123 - per_cpu(hardirq_ctx, cpu) = irqctx;
21124 -
21125 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21126 - THREADINFO_GFP,
21127 - THREAD_SIZE_ORDER));
21128 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21129 - irqctx->tinfo.cpu = cpu;
21130 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21131 -
21132 - per_cpu(softirq_ctx, cpu) = irqctx;
21133 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21134 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21135 +
21136 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21137 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21138
21139 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21140 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21141 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21142 asmlinkage void do_softirq(void)
21143 {
21144 unsigned long flags;
21145 - struct thread_info *curctx;
21146 union irq_ctx *irqctx;
21147 u32 *isp;
21148
21149 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21150 local_irq_save(flags);
21151
21152 if (local_softirq_pending()) {
21153 - curctx = current_thread_info();
21154 irqctx = __this_cpu_read(softirq_ctx);
21155 - irqctx->tinfo.task = curctx->task;
21156 - irqctx->tinfo.previous_esp = current_stack_pointer;
21157 + irqctx->previous_esp = current_stack_pointer;
21158
21159 /* build the stack frame on the softirq stack */
21160 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21161 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21162 +
21163 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21164 + __set_fs(MAKE_MM_SEG(0));
21165 +#endif
21166
21167 call_on_stack(__do_softirq, isp);
21168 +
21169 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21170 + __set_fs(current_thread_info()->addr_limit);
21171 +#endif
21172 +
21173 /*
21174 * Shouldn't happen, we returned above if in_interrupt():
21175 */
21176 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21177 if (unlikely(!desc))
21178 return false;
21179
21180 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21181 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21182 if (unlikely(overflow))
21183 print_stack_overflow();
21184 desc->handle_irq(irq, desc);
21185 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21186 index d04d3ec..ea4b374 100644
21187 --- a/arch/x86/kernel/irq_64.c
21188 +++ b/arch/x86/kernel/irq_64.c
21189 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21190 u64 estack_top, estack_bottom;
21191 u64 curbase = (u64)task_stack_page(current);
21192
21193 - if (user_mode_vm(regs))
21194 + if (user_mode(regs))
21195 return;
21196
21197 if (regs->sp >= curbase + sizeof(struct thread_info) +
21198 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21199 index dc1404b..bbc43e7 100644
21200 --- a/arch/x86/kernel/kdebugfs.c
21201 +++ b/arch/x86/kernel/kdebugfs.c
21202 @@ -27,7 +27,7 @@ struct setup_data_node {
21203 u32 len;
21204 };
21205
21206 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21207 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21208 size_t count, loff_t *ppos)
21209 {
21210 struct setup_data_node *node = file->private_data;
21211 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21212 index 836f832..a8bda67 100644
21213 --- a/arch/x86/kernel/kgdb.c
21214 +++ b/arch/x86/kernel/kgdb.c
21215 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21216 #ifdef CONFIG_X86_32
21217 switch (regno) {
21218 case GDB_SS:
21219 - if (!user_mode_vm(regs))
21220 + if (!user_mode(regs))
21221 *(unsigned long *)mem = __KERNEL_DS;
21222 break;
21223 case GDB_SP:
21224 - if (!user_mode_vm(regs))
21225 + if (!user_mode(regs))
21226 *(unsigned long *)mem = kernel_stack_pointer(regs);
21227 break;
21228 case GDB_GS:
21229 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21230 bp->attr.bp_addr = breakinfo[breakno].addr;
21231 bp->attr.bp_len = breakinfo[breakno].len;
21232 bp->attr.bp_type = breakinfo[breakno].type;
21233 - info->address = breakinfo[breakno].addr;
21234 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21235 + info->address = ktla_ktva(breakinfo[breakno].addr);
21236 + else
21237 + info->address = breakinfo[breakno].addr;
21238 info->len = breakinfo[breakno].len;
21239 info->type = breakinfo[breakno].type;
21240 val = arch_install_hw_breakpoint(bp);
21241 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21242 case 'k':
21243 /* clear the trace bit */
21244 linux_regs->flags &= ~X86_EFLAGS_TF;
21245 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21246 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21247
21248 /* set the trace bit if we're stepping */
21249 if (remcomInBuffer[0] == 's') {
21250 linux_regs->flags |= X86_EFLAGS_TF;
21251 - atomic_set(&kgdb_cpu_doing_single_step,
21252 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21253 raw_smp_processor_id());
21254 }
21255
21256 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21257
21258 switch (cmd) {
21259 case DIE_DEBUG:
21260 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21261 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21262 if (user_mode(regs))
21263 return single_step_cont(regs, args);
21264 break;
21265 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21266 #endif /* CONFIG_DEBUG_RODATA */
21267
21268 bpt->type = BP_BREAKPOINT;
21269 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21270 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21271 BREAK_INSTR_SIZE);
21272 if (err)
21273 return err;
21274 - err = probe_kernel_write((char *)bpt->bpt_addr,
21275 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21276 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21277 #ifdef CONFIG_DEBUG_RODATA
21278 if (!err)
21279 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21280 return -EBUSY;
21281 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21282 BREAK_INSTR_SIZE);
21283 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21284 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21285 if (err)
21286 return err;
21287 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21288 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21289 if (mutex_is_locked(&text_mutex))
21290 goto knl_write;
21291 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21292 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21293 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21294 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21295 goto knl_write;
21296 return err;
21297 knl_write:
21298 #endif /* CONFIG_DEBUG_RODATA */
21299 - return probe_kernel_write((char *)bpt->bpt_addr,
21300 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21301 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21302 }
21303
21304 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21305 index 211bce4..6e2580a 100644
21306 --- a/arch/x86/kernel/kprobes/core.c
21307 +++ b/arch/x86/kernel/kprobes/core.c
21308 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21309 s32 raddr;
21310 } __packed *insn;
21311
21312 - insn = (struct __arch_relative_insn *)from;
21313 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21314 +
21315 + pax_open_kernel();
21316 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21317 insn->op = op;
21318 + pax_close_kernel();
21319 }
21320
21321 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21322 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21323 kprobe_opcode_t opcode;
21324 kprobe_opcode_t *orig_opcodes = opcodes;
21325
21326 - if (search_exception_tables((unsigned long)opcodes))
21327 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21328 return 0; /* Page fault may occur on this address. */
21329
21330 retry:
21331 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21332 * for the first byte, we can recover the original instruction
21333 * from it and kp->opcode.
21334 */
21335 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21336 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21337 buf[0] = kp->opcode;
21338 - return (unsigned long)buf;
21339 + return ktva_ktla((unsigned long)buf);
21340 }
21341
21342 /*
21343 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21344 /* Another subsystem puts a breakpoint, failed to recover */
21345 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21346 return 0;
21347 + pax_open_kernel();
21348 memcpy(dest, insn.kaddr, insn.length);
21349 + pax_close_kernel();
21350
21351 #ifdef CONFIG_X86_64
21352 if (insn_rip_relative(&insn)) {
21353 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21354 return 0;
21355 }
21356 disp = (u8 *) dest + insn_offset_displacement(&insn);
21357 + pax_open_kernel();
21358 *(s32 *) disp = (s32) newdisp;
21359 + pax_close_kernel();
21360 }
21361 #endif
21362 return insn.length;
21363 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21364 * nor set current_kprobe, because it doesn't use single
21365 * stepping.
21366 */
21367 - regs->ip = (unsigned long)p->ainsn.insn;
21368 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21369 preempt_enable_no_resched();
21370 return;
21371 }
21372 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21373 regs->flags &= ~X86_EFLAGS_IF;
21374 /* single step inline if the instruction is an int3 */
21375 if (p->opcode == BREAKPOINT_INSTRUCTION)
21376 - regs->ip = (unsigned long)p->addr;
21377 + regs->ip = ktla_ktva((unsigned long)p->addr);
21378 else
21379 - regs->ip = (unsigned long)p->ainsn.insn;
21380 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21381 }
21382
21383 /*
21384 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21385 setup_singlestep(p, regs, kcb, 0);
21386 return 1;
21387 }
21388 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21389 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21390 /*
21391 * The breakpoint instruction was removed right
21392 * after we hit it. Another cpu has removed
21393 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21394 " movq %rax, 152(%rsp)\n"
21395 RESTORE_REGS_STRING
21396 " popfq\n"
21397 +#ifdef KERNEXEC_PLUGIN
21398 + " btsq $63,(%rsp)\n"
21399 +#endif
21400 #else
21401 " pushf\n"
21402 SAVE_REGS_STRING
21403 @@ -779,7 +789,7 @@ static void __kprobes
21404 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21405 {
21406 unsigned long *tos = stack_addr(regs);
21407 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21408 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21409 unsigned long orig_ip = (unsigned long)p->addr;
21410 kprobe_opcode_t *insn = p->ainsn.insn;
21411
21412 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21413 struct die_args *args = data;
21414 int ret = NOTIFY_DONE;
21415
21416 - if (args->regs && user_mode_vm(args->regs))
21417 + if (args->regs && user_mode(args->regs))
21418 return ret;
21419
21420 switch (val) {
21421 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21422 index 76dc6f0..66bdfc3 100644
21423 --- a/arch/x86/kernel/kprobes/opt.c
21424 +++ b/arch/x86/kernel/kprobes/opt.c
21425 @@ -79,6 +79,7 @@ found:
21426 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21427 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21428 {
21429 + pax_open_kernel();
21430 #ifdef CONFIG_X86_64
21431 *addr++ = 0x48;
21432 *addr++ = 0xbf;
21433 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21434 *addr++ = 0xb8;
21435 #endif
21436 *(unsigned long *)addr = val;
21437 + pax_close_kernel();
21438 }
21439
21440 static void __used __kprobes kprobes_optinsn_template_holder(void)
21441 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21442 * Verify if the address gap is in 2GB range, because this uses
21443 * a relative jump.
21444 */
21445 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21446 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21447 if (abs(rel) > 0x7fffffff)
21448 return -ERANGE;
21449
21450 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21451 op->optinsn.size = ret;
21452
21453 /* Copy arch-dep-instance from template */
21454 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21455 + pax_open_kernel();
21456 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21457 + pax_close_kernel();
21458
21459 /* Set probe information */
21460 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21461
21462 /* Set probe function call */
21463 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21464 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21465
21466 /* Set returning jmp instruction at the tail of out-of-line buffer */
21467 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21468 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21469 (u8 *)op->kp.addr + op->optinsn.size);
21470
21471 flush_icache_range((unsigned long) buf,
21472 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21473 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21474
21475 /* Backup instructions which will be replaced by jump address */
21476 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21477 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21478 RELATIVE_ADDR_SIZE);
21479
21480 insn_buf[0] = RELATIVEJUMP_OPCODE;
21481 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21482 /* This kprobe is really able to run optimized path. */
21483 op = container_of(p, struct optimized_kprobe, kp);
21484 /* Detour through copied instructions */
21485 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21486 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21487 if (!reenter)
21488 reset_current_kprobe();
21489 preempt_enable_no_resched();
21490 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21491 index cd6d9a5..16245a4 100644
21492 --- a/arch/x86/kernel/kvm.c
21493 +++ b/arch/x86/kernel/kvm.c
21494 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21495 return NOTIFY_OK;
21496 }
21497
21498 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21499 +static struct notifier_block kvm_cpu_notifier = {
21500 .notifier_call = kvm_cpu_notify,
21501 };
21502 #endif
21503 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21504 index ebc9873..1b9724b 100644
21505 --- a/arch/x86/kernel/ldt.c
21506 +++ b/arch/x86/kernel/ldt.c
21507 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21508 if (reload) {
21509 #ifdef CONFIG_SMP
21510 preempt_disable();
21511 - load_LDT(pc);
21512 + load_LDT_nolock(pc);
21513 if (!cpumask_equal(mm_cpumask(current->mm),
21514 cpumask_of(smp_processor_id())))
21515 smp_call_function(flush_ldt, current->mm, 1);
21516 preempt_enable();
21517 #else
21518 - load_LDT(pc);
21519 + load_LDT_nolock(pc);
21520 #endif
21521 }
21522 if (oldsize) {
21523 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21524 return err;
21525
21526 for (i = 0; i < old->size; i++)
21527 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21528 + write_ldt_entry(new->ldt, i, old->ldt + i);
21529 return 0;
21530 }
21531
21532 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21533 retval = copy_ldt(&mm->context, &old_mm->context);
21534 mutex_unlock(&old_mm->context.lock);
21535 }
21536 +
21537 + if (tsk == current) {
21538 + mm->context.vdso = 0;
21539 +
21540 +#ifdef CONFIG_X86_32
21541 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21542 + mm->context.user_cs_base = 0UL;
21543 + mm->context.user_cs_limit = ~0UL;
21544 +
21545 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21546 + cpus_clear(mm->context.cpu_user_cs_mask);
21547 +#endif
21548 +
21549 +#endif
21550 +#endif
21551 +
21552 + }
21553 +
21554 return retval;
21555 }
21556
21557 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21558 }
21559 }
21560
21561 +#ifdef CONFIG_PAX_SEGMEXEC
21562 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21563 + error = -EINVAL;
21564 + goto out_unlock;
21565 + }
21566 +#endif
21567 +
21568 fill_ldt(&ldt, &ldt_info);
21569 if (oldmode)
21570 ldt.avl = 0;
21571 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21572 index 5b19e4d..6476a76 100644
21573 --- a/arch/x86/kernel/machine_kexec_32.c
21574 +++ b/arch/x86/kernel/machine_kexec_32.c
21575 @@ -26,7 +26,7 @@
21576 #include <asm/cacheflush.h>
21577 #include <asm/debugreg.h>
21578
21579 -static void set_idt(void *newidt, __u16 limit)
21580 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21581 {
21582 struct desc_ptr curidt;
21583
21584 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21585 }
21586
21587
21588 -static void set_gdt(void *newgdt, __u16 limit)
21589 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21590 {
21591 struct desc_ptr curgdt;
21592
21593 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21594 }
21595
21596 control_page = page_address(image->control_code_page);
21597 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21598 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21599
21600 relocate_kernel_ptr = control_page;
21601 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21602 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21603 index 22db92b..d546bec 100644
21604 --- a/arch/x86/kernel/microcode_core.c
21605 +++ b/arch/x86/kernel/microcode_core.c
21606 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21607 return NOTIFY_OK;
21608 }
21609
21610 -static struct notifier_block __refdata mc_cpu_notifier = {
21611 +static struct notifier_block mc_cpu_notifier = {
21612 .notifier_call = mc_cpu_callback,
21613 };
21614
21615 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21616 index 5fb2ceb..3ae90bb 100644
21617 --- a/arch/x86/kernel/microcode_intel.c
21618 +++ b/arch/x86/kernel/microcode_intel.c
21619 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21620
21621 static int get_ucode_user(void *to, const void *from, size_t n)
21622 {
21623 - return copy_from_user(to, from, n);
21624 + return copy_from_user(to, (const void __force_user *)from, n);
21625 }
21626
21627 static enum ucode_state
21628 request_microcode_user(int cpu, const void __user *buf, size_t size)
21629 {
21630 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21631 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21632 }
21633
21634 static void microcode_fini_cpu(int cpu)
21635 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21636 index 216a4d7..228255a 100644
21637 --- a/arch/x86/kernel/module.c
21638 +++ b/arch/x86/kernel/module.c
21639 @@ -43,15 +43,60 @@ do { \
21640 } while (0)
21641 #endif
21642
21643 -void *module_alloc(unsigned long size)
21644 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21645 {
21646 - if (PAGE_ALIGN(size) > MODULES_LEN)
21647 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21648 return NULL;
21649 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21650 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21651 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21652 -1, __builtin_return_address(0));
21653 }
21654
21655 +void *module_alloc(unsigned long size)
21656 +{
21657 +
21658 +#ifdef CONFIG_PAX_KERNEXEC
21659 + return __module_alloc(size, PAGE_KERNEL);
21660 +#else
21661 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21662 +#endif
21663 +
21664 +}
21665 +
21666 +#ifdef CONFIG_PAX_KERNEXEC
21667 +#ifdef CONFIG_X86_32
21668 +void *module_alloc_exec(unsigned long size)
21669 +{
21670 + struct vm_struct *area;
21671 +
21672 + if (size == 0)
21673 + return NULL;
21674 +
21675 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21676 + return area ? area->addr : NULL;
21677 +}
21678 +EXPORT_SYMBOL(module_alloc_exec);
21679 +
21680 +void module_free_exec(struct module *mod, void *module_region)
21681 +{
21682 + vunmap(module_region);
21683 +}
21684 +EXPORT_SYMBOL(module_free_exec);
21685 +#else
21686 +void module_free_exec(struct module *mod, void *module_region)
21687 +{
21688 + module_free(mod, module_region);
21689 +}
21690 +EXPORT_SYMBOL(module_free_exec);
21691 +
21692 +void *module_alloc_exec(unsigned long size)
21693 +{
21694 + return __module_alloc(size, PAGE_KERNEL_RX);
21695 +}
21696 +EXPORT_SYMBOL(module_alloc_exec);
21697 +#endif
21698 +#endif
21699 +
21700 #ifdef CONFIG_X86_32
21701 int apply_relocate(Elf32_Shdr *sechdrs,
21702 const char *strtab,
21703 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21704 unsigned int i;
21705 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21706 Elf32_Sym *sym;
21707 - uint32_t *location;
21708 + uint32_t *plocation, location;
21709
21710 DEBUGP("Applying relocate section %u to %u\n",
21711 relsec, sechdrs[relsec].sh_info);
21712 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21713 /* This is where to make the change */
21714 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21715 - + rel[i].r_offset;
21716 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21717 + location = (uint32_t)plocation;
21718 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21719 + plocation = ktla_ktva((void *)plocation);
21720 /* This is the symbol it is referring to. Note that all
21721 undefined symbols have been resolved. */
21722 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21723 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21724 switch (ELF32_R_TYPE(rel[i].r_info)) {
21725 case R_386_32:
21726 /* We add the value into the location given */
21727 - *location += sym->st_value;
21728 + pax_open_kernel();
21729 + *plocation += sym->st_value;
21730 + pax_close_kernel();
21731 break;
21732 case R_386_PC32:
21733 /* Add the value, subtract its position */
21734 - *location += sym->st_value - (uint32_t)location;
21735 + pax_open_kernel();
21736 + *plocation += sym->st_value - location;
21737 + pax_close_kernel();
21738 break;
21739 default:
21740 pr_err("%s: Unknown relocation: %u\n",
21741 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21742 case R_X86_64_NONE:
21743 break;
21744 case R_X86_64_64:
21745 + pax_open_kernel();
21746 *(u64 *)loc = val;
21747 + pax_close_kernel();
21748 break;
21749 case R_X86_64_32:
21750 + pax_open_kernel();
21751 *(u32 *)loc = val;
21752 + pax_close_kernel();
21753 if (val != *(u32 *)loc)
21754 goto overflow;
21755 break;
21756 case R_X86_64_32S:
21757 + pax_open_kernel();
21758 *(s32 *)loc = val;
21759 + pax_close_kernel();
21760 if ((s64)val != *(s32 *)loc)
21761 goto overflow;
21762 break;
21763 case R_X86_64_PC32:
21764 val -= (u64)loc;
21765 + pax_open_kernel();
21766 *(u32 *)loc = val;
21767 + pax_close_kernel();
21768 +
21769 #if 0
21770 if ((s64)val != *(s32 *)loc)
21771 goto overflow;
21772 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21773 index ce13049..e2e9c3c 100644
21774 --- a/arch/x86/kernel/msr.c
21775 +++ b/arch/x86/kernel/msr.c
21776 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21777 return notifier_from_errno(err);
21778 }
21779
21780 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21781 +static struct notifier_block msr_class_cpu_notifier = {
21782 .notifier_call = msr_class_cpu_callback,
21783 };
21784
21785 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21786 index 6030805..2d33f21 100644
21787 --- a/arch/x86/kernel/nmi.c
21788 +++ b/arch/x86/kernel/nmi.c
21789 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21790 return handled;
21791 }
21792
21793 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21794 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21795 {
21796 struct nmi_desc *desc = nmi_to_desc(type);
21797 unsigned long flags;
21798 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21799 * event confuses some handlers (kdump uses this flag)
21800 */
21801 if (action->flags & NMI_FLAG_FIRST)
21802 - list_add_rcu(&action->list, &desc->head);
21803 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21804 else
21805 - list_add_tail_rcu(&action->list, &desc->head);
21806 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21807
21808 spin_unlock_irqrestore(&desc->lock, flags);
21809 return 0;
21810 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21811 if (!strcmp(n->name, name)) {
21812 WARN(in_nmi(),
21813 "Trying to free NMI (%s) from NMI context!\n", n->name);
21814 - list_del_rcu(&n->list);
21815 + pax_list_del_rcu((struct list_head *)&n->list);
21816 break;
21817 }
21818 }
21819 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21820 dotraplinkage notrace __kprobes void
21821 do_nmi(struct pt_regs *regs, long error_code)
21822 {
21823 +
21824 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21825 + if (!user_mode(regs)) {
21826 + unsigned long cs = regs->cs & 0xFFFF;
21827 + unsigned long ip = ktva_ktla(regs->ip);
21828 +
21829 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21830 + regs->ip = ip;
21831 + }
21832 +#endif
21833 +
21834 nmi_nesting_preprocess(regs);
21835
21836 nmi_enter();
21837 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21838 index 6d9582e..f746287 100644
21839 --- a/arch/x86/kernel/nmi_selftest.c
21840 +++ b/arch/x86/kernel/nmi_selftest.c
21841 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21842 {
21843 /* trap all the unknown NMIs we may generate */
21844 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21845 - __initdata);
21846 + __initconst);
21847 }
21848
21849 static void __init cleanup_nmi_testsuite(void)
21850 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21851 unsigned long timeout;
21852
21853 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21854 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21855 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21856 nmi_fail = FAILURE;
21857 return;
21858 }
21859 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21860 index 676b8c7..870ba04 100644
21861 --- a/arch/x86/kernel/paravirt-spinlocks.c
21862 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21863 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21864 arch_spin_lock(lock);
21865 }
21866
21867 -struct pv_lock_ops pv_lock_ops = {
21868 +struct pv_lock_ops pv_lock_ops __read_only = {
21869 #ifdef CONFIG_SMP
21870 .spin_is_locked = __ticket_spin_is_locked,
21871 .spin_is_contended = __ticket_spin_is_contended,
21872 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21873 index cd6de64..27c6af0 100644
21874 --- a/arch/x86/kernel/paravirt.c
21875 +++ b/arch/x86/kernel/paravirt.c
21876 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21877 {
21878 return x;
21879 }
21880 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21881 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21882 +#endif
21883
21884 void __init default_banner(void)
21885 {
21886 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21887 if (opfunc == NULL)
21888 /* If there's no function, patch it with a ud2a (BUG) */
21889 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21890 - else if (opfunc == _paravirt_nop)
21891 + else if (opfunc == (void *)_paravirt_nop)
21892 /* If the operation is a nop, then nop the callsite */
21893 ret = paravirt_patch_nop();
21894
21895 /* identity functions just return their single argument */
21896 - else if (opfunc == _paravirt_ident_32)
21897 + else if (opfunc == (void *)_paravirt_ident_32)
21898 ret = paravirt_patch_ident_32(insnbuf, len);
21899 - else if (opfunc == _paravirt_ident_64)
21900 + else if (opfunc == (void *)_paravirt_ident_64)
21901 ret = paravirt_patch_ident_64(insnbuf, len);
21902 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21903 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21904 + ret = paravirt_patch_ident_64(insnbuf, len);
21905 +#endif
21906
21907 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21908 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21909 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21910 if (insn_len > len || start == NULL)
21911 insn_len = len;
21912 else
21913 - memcpy(insnbuf, start, insn_len);
21914 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21915
21916 return insn_len;
21917 }
21918 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21919 return this_cpu_read(paravirt_lazy_mode);
21920 }
21921
21922 -struct pv_info pv_info = {
21923 +struct pv_info pv_info __read_only = {
21924 .name = "bare hardware",
21925 .paravirt_enabled = 0,
21926 .kernel_rpl = 0,
21927 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21928 #endif
21929 };
21930
21931 -struct pv_init_ops pv_init_ops = {
21932 +struct pv_init_ops pv_init_ops __read_only = {
21933 .patch = native_patch,
21934 };
21935
21936 -struct pv_time_ops pv_time_ops = {
21937 +struct pv_time_ops pv_time_ops __read_only = {
21938 .sched_clock = native_sched_clock,
21939 .steal_clock = native_steal_clock,
21940 };
21941
21942 -struct pv_irq_ops pv_irq_ops = {
21943 +struct pv_irq_ops pv_irq_ops __read_only = {
21944 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21945 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21946 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21947 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21948 #endif
21949 };
21950
21951 -struct pv_cpu_ops pv_cpu_ops = {
21952 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21953 .cpuid = native_cpuid,
21954 .get_debugreg = native_get_debugreg,
21955 .set_debugreg = native_set_debugreg,
21956 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21957 .end_context_switch = paravirt_nop,
21958 };
21959
21960 -struct pv_apic_ops pv_apic_ops = {
21961 +struct pv_apic_ops pv_apic_ops __read_only= {
21962 #ifdef CONFIG_X86_LOCAL_APIC
21963 .startup_ipi_hook = paravirt_nop,
21964 #endif
21965 };
21966
21967 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21968 +#ifdef CONFIG_X86_32
21969 +#ifdef CONFIG_X86_PAE
21970 +/* 64-bit pagetable entries */
21971 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21972 +#else
21973 /* 32-bit pagetable entries */
21974 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21975 +#endif
21976 #else
21977 /* 64-bit pagetable entries */
21978 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21979 #endif
21980
21981 -struct pv_mmu_ops pv_mmu_ops = {
21982 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21983
21984 .read_cr2 = native_read_cr2,
21985 .write_cr2 = native_write_cr2,
21986 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21987 .make_pud = PTE_IDENT,
21988
21989 .set_pgd = native_set_pgd,
21990 + .set_pgd_batched = native_set_pgd_batched,
21991 #endif
21992 #endif /* PAGETABLE_LEVELS >= 3 */
21993
21994 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21995 },
21996
21997 .set_fixmap = native_set_fixmap,
21998 +
21999 +#ifdef CONFIG_PAX_KERNEXEC
22000 + .pax_open_kernel = native_pax_open_kernel,
22001 + .pax_close_kernel = native_pax_close_kernel,
22002 +#endif
22003 +
22004 };
22005
22006 EXPORT_SYMBOL_GPL(pv_time_ops);
22007 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22008 index 299d493..2ccb0ee 100644
22009 --- a/arch/x86/kernel/pci-calgary_64.c
22010 +++ b/arch/x86/kernel/pci-calgary_64.c
22011 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22012 tce_space = be64_to_cpu(readq(target));
22013 tce_space = tce_space & TAR_SW_BITS;
22014
22015 - tce_space = tce_space & (~specified_table_size);
22016 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22017 info->tce_space = (u64 *)__va(tce_space);
22018 }
22019 }
22020 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22021 index 35ccf75..7a15747 100644
22022 --- a/arch/x86/kernel/pci-iommu_table.c
22023 +++ b/arch/x86/kernel/pci-iommu_table.c
22024 @@ -2,7 +2,7 @@
22025 #include <asm/iommu_table.h>
22026 #include <linux/string.h>
22027 #include <linux/kallsyms.h>
22028 -
22029 +#include <linux/sched.h>
22030
22031 #define DEBUG 1
22032
22033 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22034 index 6c483ba..d10ce2f 100644
22035 --- a/arch/x86/kernel/pci-swiotlb.c
22036 +++ b/arch/x86/kernel/pci-swiotlb.c
22037 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22038 void *vaddr, dma_addr_t dma_addr,
22039 struct dma_attrs *attrs)
22040 {
22041 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22042 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22043 }
22044
22045 static struct dma_map_ops swiotlb_dma_ops = {
22046 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22047 index 81a5f5e..20f8b58 100644
22048 --- a/arch/x86/kernel/process.c
22049 +++ b/arch/x86/kernel/process.c
22050 @@ -36,7 +36,8 @@
22051 * section. Since TSS's are completely CPU-local, we want them
22052 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22053 */
22054 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22055 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22056 +EXPORT_SYMBOL(init_tss);
22057
22058 #ifdef CONFIG_X86_64
22059 static DEFINE_PER_CPU(unsigned char, is_idle);
22060 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22061 task_xstate_cachep =
22062 kmem_cache_create("task_xstate", xstate_size,
22063 __alignof__(union thread_xstate),
22064 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22065 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22066 }
22067
22068 /*
22069 @@ -105,7 +106,7 @@ void exit_thread(void)
22070 unsigned long *bp = t->io_bitmap_ptr;
22071
22072 if (bp) {
22073 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22074 + struct tss_struct *tss = init_tss + get_cpu();
22075
22076 t->io_bitmap_ptr = NULL;
22077 clear_thread_flag(TIF_IO_BITMAP);
22078 @@ -125,6 +126,9 @@ void flush_thread(void)
22079 {
22080 struct task_struct *tsk = current;
22081
22082 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22083 + loadsegment(gs, 0);
22084 +#endif
22085 flush_ptrace_hw_breakpoint(tsk);
22086 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22087 drop_init_fpu(tsk);
22088 @@ -271,7 +275,7 @@ static void __exit_idle(void)
22089 void exit_idle(void)
22090 {
22091 /* idle loop has pid 0 */
22092 - if (current->pid)
22093 + if (task_pid_nr(current))
22094 return;
22095 __exit_idle();
22096 }
22097 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
22098 return ret;
22099 }
22100 #endif
22101 -void stop_this_cpu(void *dummy)
22102 +__noreturn void stop_this_cpu(void *dummy)
22103 {
22104 local_irq_disable();
22105 /*
22106 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
22107 }
22108 early_param("idle", idle_setup);
22109
22110 -unsigned long arch_align_stack(unsigned long sp)
22111 +#ifdef CONFIG_PAX_RANDKSTACK
22112 +void pax_randomize_kstack(struct pt_regs *regs)
22113 {
22114 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22115 - sp -= get_random_int() % 8192;
22116 - return sp & ~0xf;
22117 -}
22118 + struct thread_struct *thread = &current->thread;
22119 + unsigned long time;
22120
22121 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22122 -{
22123 - unsigned long range_end = mm->brk + 0x02000000;
22124 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22125 -}
22126 + if (!randomize_va_space)
22127 + return;
22128 +
22129 + if (v8086_mode(regs))
22130 + return;
22131
22132 + rdtscl(time);
22133 +
22134 + /* P4 seems to return a 0 LSB, ignore it */
22135 +#ifdef CONFIG_MPENTIUM4
22136 + time &= 0x3EUL;
22137 + time <<= 2;
22138 +#elif defined(CONFIG_X86_64)
22139 + time &= 0xFUL;
22140 + time <<= 4;
22141 +#else
22142 + time &= 0x1FUL;
22143 + time <<= 3;
22144 +#endif
22145 +
22146 + thread->sp0 ^= time;
22147 + load_sp0(init_tss + smp_processor_id(), thread);
22148 +
22149 +#ifdef CONFIG_X86_64
22150 + this_cpu_write(kernel_stack, thread->sp0);
22151 +#endif
22152 +}
22153 +#endif
22154 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22155 index 7305f7d..22f73d6 100644
22156 --- a/arch/x86/kernel/process_32.c
22157 +++ b/arch/x86/kernel/process_32.c
22158 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22159 unsigned long thread_saved_pc(struct task_struct *tsk)
22160 {
22161 return ((unsigned long *)tsk->thread.sp)[3];
22162 +//XXX return tsk->thread.eip;
22163 }
22164
22165 void __show_regs(struct pt_regs *regs, int all)
22166 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
22167 unsigned long sp;
22168 unsigned short ss, gs;
22169
22170 - if (user_mode_vm(regs)) {
22171 + if (user_mode(regs)) {
22172 sp = regs->sp;
22173 ss = regs->ss & 0xffff;
22174 - gs = get_user_gs(regs);
22175 } else {
22176 sp = kernel_stack_pointer(regs);
22177 savesegment(ss, ss);
22178 - savesegment(gs, gs);
22179 }
22180 + gs = get_user_gs(regs);
22181
22182 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22183 (u16)regs->cs, regs->ip, regs->flags,
22184 - smp_processor_id());
22185 + raw_smp_processor_id());
22186 print_symbol("EIP is at %s\n", regs->ip);
22187
22188 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22189 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
22190 int copy_thread(unsigned long clone_flags, unsigned long sp,
22191 unsigned long arg, struct task_struct *p)
22192 {
22193 - struct pt_regs *childregs = task_pt_regs(p);
22194 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22195 struct task_struct *tsk;
22196 int err;
22197
22198 p->thread.sp = (unsigned long) childregs;
22199 p->thread.sp0 = (unsigned long) (childregs+1);
22200 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22201
22202 if (unlikely(p->flags & PF_KTHREAD)) {
22203 /* kernel thread */
22204 memset(childregs, 0, sizeof(struct pt_regs));
22205 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22206 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22207 - childregs->ds = __USER_DS;
22208 - childregs->es = __USER_DS;
22209 + savesegment(gs, childregs->gs);
22210 + childregs->ds = __KERNEL_DS;
22211 + childregs->es = __KERNEL_DS;
22212 childregs->fs = __KERNEL_PERCPU;
22213 childregs->bx = sp; /* function */
22214 childregs->bp = arg;
22215 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22216 struct thread_struct *prev = &prev_p->thread,
22217 *next = &next_p->thread;
22218 int cpu = smp_processor_id();
22219 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22220 + struct tss_struct *tss = init_tss + cpu;
22221 fpu_switch_t fpu;
22222
22223 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22224 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22225 */
22226 lazy_save_gs(prev->gs);
22227
22228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22229 + __set_fs(task_thread_info(next_p)->addr_limit);
22230 +#endif
22231 +
22232 /*
22233 * Load the per-thread Thread-Local Storage descriptor.
22234 */
22235 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22236 */
22237 arch_end_context_switch(next_p);
22238
22239 + this_cpu_write(current_task, next_p);
22240 + this_cpu_write(current_tinfo, &next_p->tinfo);
22241 +
22242 /*
22243 * Restore %gs if needed (which is common)
22244 */
22245 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22246
22247 switch_fpu_finish(next_p, fpu);
22248
22249 - this_cpu_write(current_task, next_p);
22250 -
22251 return prev_p;
22252 }
22253
22254 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
22255 } while (count++ < 16);
22256 return 0;
22257 }
22258 -
22259 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22260 index 355ae06..4530766 100644
22261 --- a/arch/x86/kernel/process_64.c
22262 +++ b/arch/x86/kernel/process_64.c
22263 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22264 struct pt_regs *childregs;
22265 struct task_struct *me = current;
22266
22267 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22268 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22269 childregs = task_pt_regs(p);
22270 p->thread.sp = (unsigned long) childregs;
22271 p->thread.usersp = me->thread.usersp;
22272 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22273 set_tsk_thread_flag(p, TIF_FORK);
22274 p->fpu_counter = 0;
22275 p->thread.io_bitmap_ptr = NULL;
22276 @@ -273,7 +274,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22277 struct thread_struct *prev = &prev_p->thread;
22278 struct thread_struct *next = &next_p->thread;
22279 int cpu = smp_processor_id();
22280 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22281 + struct tss_struct *tss = init_tss + cpu;
22282 unsigned fsindex, gsindex;
22283 fpu_switch_t fpu;
22284
22285 @@ -355,10 +356,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22286 prev->usersp = this_cpu_read(old_rsp);
22287 this_cpu_write(old_rsp, next->usersp);
22288 this_cpu_write(current_task, next_p);
22289 + this_cpu_write(current_tinfo, &next_p->tinfo);
22290
22291 - this_cpu_write(kernel_stack,
22292 - (unsigned long)task_stack_page(next_p) +
22293 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22294 + this_cpu_write(kernel_stack, next->sp0);
22295
22296 /*
22297 * Now maybe reload the debug registers and handle I/O bitmaps
22298 @@ -427,12 +427,11 @@ unsigned long get_wchan(struct task_struct *p)
22299 if (!p || p == current || p->state == TASK_RUNNING)
22300 return 0;
22301 stack = (unsigned long)task_stack_page(p);
22302 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22303 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22304 return 0;
22305 fp = *(u64 *)(p->thread.sp);
22306 do {
22307 - if (fp < (unsigned long)stack ||
22308 - fp >= (unsigned long)stack+THREAD_SIZE)
22309 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22310 return 0;
22311 ip = *(u64 *)(fp+8);
22312 if (!in_sched_functions(ip))
22313 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22314 index 29a8120..a50b5ee 100644
22315 --- a/arch/x86/kernel/ptrace.c
22316 +++ b/arch/x86/kernel/ptrace.c
22317 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22318 {
22319 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22320 unsigned long sp = (unsigned long)&regs->sp;
22321 - struct thread_info *tinfo;
22322
22323 - if (context == (sp & ~(THREAD_SIZE - 1)))
22324 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22325 return sp;
22326
22327 - tinfo = (struct thread_info *)context;
22328 - if (tinfo->previous_esp)
22329 - return tinfo->previous_esp;
22330 + sp = *(unsigned long *)context;
22331 + if (sp)
22332 + return sp;
22333
22334 return (unsigned long)regs;
22335 }
22336 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22337 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22338 {
22339 int i;
22340 - int dr7 = 0;
22341 + unsigned long dr7 = 0;
22342 struct arch_hw_breakpoint *info;
22343
22344 for (i = 0; i < HBP_NUM; i++) {
22345 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22346 unsigned long addr, unsigned long data)
22347 {
22348 int ret;
22349 - unsigned long __user *datap = (unsigned long __user *)data;
22350 + unsigned long __user *datap = (__force unsigned long __user *)data;
22351
22352 switch (request) {
22353 /* read the word at location addr in the USER area. */
22354 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22355 if ((int) addr < 0)
22356 return -EIO;
22357 ret = do_get_thread_area(child, addr,
22358 - (struct user_desc __user *)data);
22359 + (__force struct user_desc __user *) data);
22360 break;
22361
22362 case PTRACE_SET_THREAD_AREA:
22363 if ((int) addr < 0)
22364 return -EIO;
22365 ret = do_set_thread_area(child, addr,
22366 - (struct user_desc __user *)data, 0);
22367 + (__force struct user_desc __user *) data, 0);
22368 break;
22369 #endif
22370
22371 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22372
22373 #ifdef CONFIG_X86_64
22374
22375 -static struct user_regset x86_64_regsets[] __read_mostly = {
22376 +static user_regset_no_const x86_64_regsets[] __read_only = {
22377 [REGSET_GENERAL] = {
22378 .core_note_type = NT_PRSTATUS,
22379 .n = sizeof(struct user_regs_struct) / sizeof(long),
22380 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22381 #endif /* CONFIG_X86_64 */
22382
22383 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22384 -static struct user_regset x86_32_regsets[] __read_mostly = {
22385 +static user_regset_no_const x86_32_regsets[] __read_only = {
22386 [REGSET_GENERAL] = {
22387 .core_note_type = NT_PRSTATUS,
22388 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22389 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22390 */
22391 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22392
22393 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22394 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22395 {
22396 #ifdef CONFIG_X86_64
22397 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22398 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22399 memset(info, 0, sizeof(*info));
22400 info->si_signo = SIGTRAP;
22401 info->si_code = si_code;
22402 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22403 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22404 }
22405
22406 void user_single_step_siginfo(struct task_struct *tsk,
22407 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22408 # define IS_IA32 0
22409 #endif
22410
22411 +#ifdef CONFIG_GRKERNSEC_SETXID
22412 +extern void gr_delayed_cred_worker(void);
22413 +#endif
22414 +
22415 /*
22416 * We must return the syscall number to actually look up in the table.
22417 * This can be -1L to skip running any syscall at all.
22418 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22419
22420 user_exit();
22421
22422 +#ifdef CONFIG_GRKERNSEC_SETXID
22423 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22424 + gr_delayed_cred_worker();
22425 +#endif
22426 +
22427 /*
22428 * If we stepped into a sysenter/syscall insn, it trapped in
22429 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22430 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22431 */
22432 user_exit();
22433
22434 +#ifdef CONFIG_GRKERNSEC_SETXID
22435 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22436 + gr_delayed_cred_worker();
22437 +#endif
22438 +
22439 audit_syscall_exit(regs);
22440
22441 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22442 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22443 index 2cb9470..ff1fd80 100644
22444 --- a/arch/x86/kernel/pvclock.c
22445 +++ b/arch/x86/kernel/pvclock.c
22446 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22447 return pv_tsc_khz;
22448 }
22449
22450 -static atomic64_t last_value = ATOMIC64_INIT(0);
22451 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22452
22453 void pvclock_resume(void)
22454 {
22455 - atomic64_set(&last_value, 0);
22456 + atomic64_set_unchecked(&last_value, 0);
22457 }
22458
22459 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22460 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22461 * updating at the same time, and one of them could be slightly behind,
22462 * making the assumption that last_value always go forward fail to hold.
22463 */
22464 - last = atomic64_read(&last_value);
22465 + last = atomic64_read_unchecked(&last_value);
22466 do {
22467 if (ret < last)
22468 return last;
22469 - last = atomic64_cmpxchg(&last_value, last, ret);
22470 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22471 } while (unlikely(last != ret));
22472
22473 return ret;
22474 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22475 index 76fa1e9..abf09ea 100644
22476 --- a/arch/x86/kernel/reboot.c
22477 +++ b/arch/x86/kernel/reboot.c
22478 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22479 EXPORT_SYMBOL(pm_power_off);
22480
22481 static const struct desc_ptr no_idt = {};
22482 -static int reboot_mode;
22483 +static unsigned short reboot_mode;
22484 enum reboot_type reboot_type = BOOT_ACPI;
22485 int reboot_force;
22486
22487 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22488
22489 void __noreturn machine_real_restart(unsigned int type)
22490 {
22491 +
22492 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22493 + struct desc_struct *gdt;
22494 +#endif
22495 +
22496 local_irq_disable();
22497
22498 /*
22499 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22500
22501 /* Jump to the identity-mapped low memory code */
22502 #ifdef CONFIG_X86_32
22503 - asm volatile("jmpl *%0" : :
22504 +
22505 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22506 + gdt = get_cpu_gdt_table(smp_processor_id());
22507 + pax_open_kernel();
22508 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22509 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22510 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22511 + loadsegment(ds, __KERNEL_DS);
22512 + loadsegment(es, __KERNEL_DS);
22513 + loadsegment(ss, __KERNEL_DS);
22514 +#endif
22515 +#ifdef CONFIG_PAX_KERNEXEC
22516 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22517 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22518 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22519 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22520 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22521 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22522 +#endif
22523 + pax_close_kernel();
22524 +#endif
22525 +
22526 + asm volatile("ljmpl *%0" : :
22527 "rm" (real_mode_header->machine_real_restart_asm),
22528 "a" (type));
22529 #else
22530 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22531 * try to force a triple fault and then cycle between hitting the keyboard
22532 * controller and doing that
22533 */
22534 -static void native_machine_emergency_restart(void)
22535 +static void __noreturn native_machine_emergency_restart(void)
22536 {
22537 int i;
22538 int attempt = 0;
22539 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22540 #endif
22541 }
22542
22543 -static void __machine_emergency_restart(int emergency)
22544 +static void __noreturn __machine_emergency_restart(int emergency)
22545 {
22546 reboot_emergency = emergency;
22547 machine_ops.emergency_restart();
22548 }
22549
22550 -static void native_machine_restart(char *__unused)
22551 +static void __noreturn native_machine_restart(char *__unused)
22552 {
22553 pr_notice("machine restart\n");
22554
22555 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22556 __machine_emergency_restart(0);
22557 }
22558
22559 -static void native_machine_halt(void)
22560 +static void __noreturn native_machine_halt(void)
22561 {
22562 /* Stop other cpus and apics */
22563 machine_shutdown();
22564 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22565 stop_this_cpu(NULL);
22566 }
22567
22568 -static void native_machine_power_off(void)
22569 +static void __noreturn native_machine_power_off(void)
22570 {
22571 if (pm_power_off) {
22572 if (!reboot_force)
22573 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22574 }
22575 /* A fallback in case there is no PM info available */
22576 tboot_shutdown(TB_SHUTDOWN_HALT);
22577 + unreachable();
22578 }
22579
22580 -struct machine_ops machine_ops = {
22581 +struct machine_ops machine_ops __read_only = {
22582 .power_off = native_machine_power_off,
22583 .shutdown = native_machine_shutdown,
22584 .emergency_restart = native_machine_emergency_restart,
22585 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22586 index f2bb9c9..bed145d7 100644
22587 --- a/arch/x86/kernel/relocate_kernel_64.S
22588 +++ b/arch/x86/kernel/relocate_kernel_64.S
22589 @@ -11,6 +11,7 @@
22590 #include <asm/kexec.h>
22591 #include <asm/processor-flags.h>
22592 #include <asm/pgtable_types.h>
22593 +#include <asm/alternative-asm.h>
22594
22595 /*
22596 * Must be relocatable PIC code callable as a C function
22597 @@ -167,6 +168,7 @@ identity_mapped:
22598 xorq %r14, %r14
22599 xorq %r15, %r15
22600
22601 + pax_force_retaddr 0, 1
22602 ret
22603
22604 1:
22605 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22606 index 56f7fcf..fa229f4 100644
22607 --- a/arch/x86/kernel/setup.c
22608 +++ b/arch/x86/kernel/setup.c
22609 @@ -110,6 +110,7 @@
22610 #include <asm/mce.h>
22611 #include <asm/alternative.h>
22612 #include <asm/prom.h>
22613 +#include <asm/boot.h>
22614
22615 /*
22616 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22617 @@ -444,7 +445,7 @@ static void __init parse_setup_data(void)
22618
22619 switch (data->type) {
22620 case SETUP_E820_EXT:
22621 - parse_e820_ext(data);
22622 + parse_e820_ext((struct setup_data __force_kernel *)data);
22623 break;
22624 case SETUP_DTB:
22625 add_dtb(pa_data);
22626 @@ -771,7 +772,7 @@ static void __init trim_bios_range(void)
22627 * area (640->1Mb) as ram even though it is not.
22628 * take them out.
22629 */
22630 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22631 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22632
22633 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22634 }
22635 @@ -779,7 +780,7 @@ static void __init trim_bios_range(void)
22636 /* called before trim_bios_range() to spare extra sanitize */
22637 static void __init e820_add_kernel_range(void)
22638 {
22639 - u64 start = __pa_symbol(_text);
22640 + u64 start = __pa_symbol(ktla_ktva(_text));
22641 u64 size = __pa_symbol(_end) - start;
22642
22643 /*
22644 @@ -841,8 +842,12 @@ static void __init trim_low_memory_range(void)
22645
22646 void __init setup_arch(char **cmdline_p)
22647 {
22648 +#ifdef CONFIG_X86_32
22649 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22650 +#else
22651 memblock_reserve(__pa_symbol(_text),
22652 (unsigned long)__bss_stop - (unsigned long)_text);
22653 +#endif
22654
22655 early_reserve_initrd();
22656
22657 @@ -934,14 +939,14 @@ void __init setup_arch(char **cmdline_p)
22658
22659 if (!boot_params.hdr.root_flags)
22660 root_mountflags &= ~MS_RDONLY;
22661 - init_mm.start_code = (unsigned long) _text;
22662 - init_mm.end_code = (unsigned long) _etext;
22663 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22664 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22665 init_mm.end_data = (unsigned long) _edata;
22666 init_mm.brk = _brk_end;
22667
22668 - code_resource.start = __pa_symbol(_text);
22669 - code_resource.end = __pa_symbol(_etext)-1;
22670 - data_resource.start = __pa_symbol(_etext);
22671 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22672 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22673 + data_resource.start = __pa_symbol(_sdata);
22674 data_resource.end = __pa_symbol(_edata)-1;
22675 bss_resource.start = __pa_symbol(__bss_start);
22676 bss_resource.end = __pa_symbol(__bss_stop)-1;
22677 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22678 index 5cdff03..80fa283 100644
22679 --- a/arch/x86/kernel/setup_percpu.c
22680 +++ b/arch/x86/kernel/setup_percpu.c
22681 @@ -21,19 +21,17 @@
22682 #include <asm/cpu.h>
22683 #include <asm/stackprotector.h>
22684
22685 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22686 +#ifdef CONFIG_SMP
22687 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22688 EXPORT_PER_CPU_SYMBOL(cpu_number);
22689 +#endif
22690
22691 -#ifdef CONFIG_X86_64
22692 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22693 -#else
22694 -#define BOOT_PERCPU_OFFSET 0
22695 -#endif
22696
22697 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22698 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22699
22700 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22701 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22702 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22703 };
22704 EXPORT_SYMBOL(__per_cpu_offset);
22705 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22706 {
22707 #ifdef CONFIG_NEED_MULTIPLE_NODES
22708 pg_data_t *last = NULL;
22709 - unsigned int cpu;
22710 + int cpu;
22711
22712 for_each_possible_cpu(cpu) {
22713 int node = early_cpu_to_node(cpu);
22714 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22715 {
22716 #ifdef CONFIG_X86_32
22717 struct desc_struct gdt;
22718 + unsigned long base = per_cpu_offset(cpu);
22719
22720 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22721 - 0x2 | DESCTYPE_S, 0x8);
22722 - gdt.s = 1;
22723 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22724 + 0x83 | DESCTYPE_S, 0xC);
22725 write_gdt_entry(get_cpu_gdt_table(cpu),
22726 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22727 #endif
22728 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22729 /* alrighty, percpu areas up and running */
22730 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22731 for_each_possible_cpu(cpu) {
22732 +#ifdef CONFIG_CC_STACKPROTECTOR
22733 +#ifdef CONFIG_X86_32
22734 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22735 +#endif
22736 +#endif
22737 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22738 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22739 per_cpu(cpu_number, cpu) = cpu;
22740 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22741 */
22742 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22743 #endif
22744 +#ifdef CONFIG_CC_STACKPROTECTOR
22745 +#ifdef CONFIG_X86_32
22746 + if (!cpu)
22747 + per_cpu(stack_canary.canary, cpu) = canary;
22748 +#endif
22749 +#endif
22750 /*
22751 * Up to this point, the boot CPU has been using .init.data
22752 * area. Reload any changed state for the boot CPU.
22753 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22754 index 6956299..f20beae 100644
22755 --- a/arch/x86/kernel/signal.c
22756 +++ b/arch/x86/kernel/signal.c
22757 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22758 * Align the stack pointer according to the i386 ABI,
22759 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22760 */
22761 - sp = ((sp + 4) & -16ul) - 4;
22762 + sp = ((sp - 12) & -16ul) - 4;
22763 #else /* !CONFIG_X86_32 */
22764 sp = round_down(sp, 16) - 8;
22765 #endif
22766 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22767 }
22768
22769 if (current->mm->context.vdso)
22770 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22771 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22772 else
22773 - restorer = &frame->retcode;
22774 + restorer = (void __user *)&frame->retcode;
22775 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22776 restorer = ksig->ka.sa.sa_restorer;
22777
22778 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22779 * reasons and because gdb uses it as a signature to notice
22780 * signal handler stack frames.
22781 */
22782 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22783 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22784
22785 if (err)
22786 return -EFAULT;
22787 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22788 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22789
22790 /* Set up to return from userspace. */
22791 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22792 + if (current->mm->context.vdso)
22793 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22794 + else
22795 + restorer = (void __user *)&frame->retcode;
22796 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22797 restorer = ksig->ka.sa.sa_restorer;
22798 put_user_ex(restorer, &frame->pretcode);
22799 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22800 * reasons and because gdb uses it as a signature to notice
22801 * signal handler stack frames.
22802 */
22803 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22804 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22805 } put_user_catch(err);
22806
22807 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22808 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22809 {
22810 int usig = signr_convert(ksig->sig);
22811 sigset_t *set = sigmask_to_save();
22812 - compat_sigset_t *cset = (compat_sigset_t *) set;
22813 + sigset_t sigcopy;
22814 + compat_sigset_t *cset;
22815 +
22816 + sigcopy = *set;
22817 +
22818 + cset = (compat_sigset_t *) &sigcopy;
22819
22820 /* Set up the stack frame */
22821 if (is_ia32_frame()) {
22822 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22823 } else if (is_x32_frame()) {
22824 return x32_setup_rt_frame(ksig, cset, regs);
22825 } else {
22826 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22827 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22828 }
22829 }
22830
22831 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22832 index 48d2b7d..90d328a 100644
22833 --- a/arch/x86/kernel/smp.c
22834 +++ b/arch/x86/kernel/smp.c
22835 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22836
22837 __setup("nonmi_ipi", nonmi_ipi_setup);
22838
22839 -struct smp_ops smp_ops = {
22840 +struct smp_ops smp_ops __read_only = {
22841 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22842 .smp_prepare_cpus = native_smp_prepare_cpus,
22843 .smp_cpus_done = native_smp_cpus_done,
22844 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22845 index bfd348e..4816ad8 100644
22846 --- a/arch/x86/kernel/smpboot.c
22847 +++ b/arch/x86/kernel/smpboot.c
22848 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22849 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22850 (THREAD_SIZE + task_stack_page(idle))) - 1);
22851 per_cpu(current_task, cpu) = idle;
22852 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22853
22854 #ifdef CONFIG_X86_32
22855 /* Stack for startup_32 can be just as for start_secondary onwards */
22856 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22857 #else
22858 clear_tsk_thread_flag(idle, TIF_FORK);
22859 initial_gs = per_cpu_offset(cpu);
22860 - per_cpu(kernel_stack, cpu) =
22861 - (unsigned long)task_stack_page(idle) -
22862 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22863 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22864 #endif
22865 +
22866 + pax_open_kernel();
22867 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22868 + pax_close_kernel();
22869 +
22870 initial_code = (unsigned long)start_secondary;
22871 stack_start = idle->thread.sp;
22872
22873 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22874 /* the FPU context is blank, nobody can own it */
22875 __cpu_disable_lazy_restore(cpu);
22876
22877 +#ifdef CONFIG_PAX_PER_CPU_PGD
22878 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22879 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22880 + KERNEL_PGD_PTRS);
22881 +#endif
22882 +
22883 + /* the FPU context is blank, nobody can own it */
22884 + __cpu_disable_lazy_restore(cpu);
22885 +
22886 err = do_boot_cpu(apicid, cpu, tidle);
22887 if (err) {
22888 pr_debug("do_boot_cpu failed %d\n", err);
22889 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22890 index 9b4d51d..5d28b58 100644
22891 --- a/arch/x86/kernel/step.c
22892 +++ b/arch/x86/kernel/step.c
22893 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22894 struct desc_struct *desc;
22895 unsigned long base;
22896
22897 - seg &= ~7UL;
22898 + seg >>= 3;
22899
22900 mutex_lock(&child->mm->context.lock);
22901 - if (unlikely((seg >> 3) >= child->mm->context.size))
22902 + if (unlikely(seg >= child->mm->context.size))
22903 addr = -1L; /* bogus selector, access would fault */
22904 else {
22905 desc = child->mm->context.ldt + seg;
22906 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22907 addr += base;
22908 }
22909 mutex_unlock(&child->mm->context.lock);
22910 - }
22911 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22912 + addr = ktla_ktva(addr);
22913
22914 return addr;
22915 }
22916 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22917 unsigned char opcode[15];
22918 unsigned long addr = convert_ip_to_linear(child, regs);
22919
22920 + if (addr == -EINVAL)
22921 + return 0;
22922 +
22923 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22924 for (i = 0; i < copied; i++) {
22925 switch (opcode[i]) {
22926 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22927 new file mode 100644
22928 index 0000000..5877189
22929 --- /dev/null
22930 +++ b/arch/x86/kernel/sys_i386_32.c
22931 @@ -0,0 +1,189 @@
22932 +/*
22933 + * This file contains various random system calls that
22934 + * have a non-standard calling sequence on the Linux/i386
22935 + * platform.
22936 + */
22937 +
22938 +#include <linux/errno.h>
22939 +#include <linux/sched.h>
22940 +#include <linux/mm.h>
22941 +#include <linux/fs.h>
22942 +#include <linux/smp.h>
22943 +#include <linux/sem.h>
22944 +#include <linux/msg.h>
22945 +#include <linux/shm.h>
22946 +#include <linux/stat.h>
22947 +#include <linux/syscalls.h>
22948 +#include <linux/mman.h>
22949 +#include <linux/file.h>
22950 +#include <linux/utsname.h>
22951 +#include <linux/ipc.h>
22952 +#include <linux/elf.h>
22953 +
22954 +#include <linux/uaccess.h>
22955 +#include <linux/unistd.h>
22956 +
22957 +#include <asm/syscalls.h>
22958 +
22959 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22960 +{
22961 + unsigned long pax_task_size = TASK_SIZE;
22962 +
22963 +#ifdef CONFIG_PAX_SEGMEXEC
22964 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22965 + pax_task_size = SEGMEXEC_TASK_SIZE;
22966 +#endif
22967 +
22968 + if (flags & MAP_FIXED)
22969 + if (len > pax_task_size || addr > pax_task_size - len)
22970 + return -EINVAL;
22971 +
22972 + return 0;
22973 +}
22974 +
22975 +/*
22976 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
22977 + */
22978 +static unsigned long get_align_mask(void)
22979 +{
22980 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
22981 + return 0;
22982 +
22983 + if (!(current->flags & PF_RANDOMIZE))
22984 + return 0;
22985 +
22986 + return va_align.mask;
22987 +}
22988 +
22989 +unsigned long
22990 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22991 + unsigned long len, unsigned long pgoff, unsigned long flags)
22992 +{
22993 + struct mm_struct *mm = current->mm;
22994 + struct vm_area_struct *vma;
22995 + unsigned long pax_task_size = TASK_SIZE;
22996 + struct vm_unmapped_area_info info;
22997 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22998 +
22999 +#ifdef CONFIG_PAX_SEGMEXEC
23000 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23001 + pax_task_size = SEGMEXEC_TASK_SIZE;
23002 +#endif
23003 +
23004 + pax_task_size -= PAGE_SIZE;
23005 +
23006 + if (len > pax_task_size)
23007 + return -ENOMEM;
23008 +
23009 + if (flags & MAP_FIXED)
23010 + return addr;
23011 +
23012 +#ifdef CONFIG_PAX_RANDMMAP
23013 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23014 +#endif
23015 +
23016 + if (addr) {
23017 + addr = PAGE_ALIGN(addr);
23018 + if (pax_task_size - len >= addr) {
23019 + vma = find_vma(mm, addr);
23020 + if (check_heap_stack_gap(vma, addr, len, offset))
23021 + return addr;
23022 + }
23023 + }
23024 +
23025 + info.flags = 0;
23026 + info.length = len;
23027 + info.align_mask = filp ? get_align_mask() : 0;
23028 + info.align_offset = pgoff << PAGE_SHIFT;
23029 + info.threadstack_offset = offset;
23030 +
23031 +#ifdef CONFIG_PAX_PAGEEXEC
23032 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
23033 + info.low_limit = 0x00110000UL;
23034 + info.high_limit = mm->start_code;
23035 +
23036 +#ifdef CONFIG_PAX_RANDMMAP
23037 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23038 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
23039 +#endif
23040 +
23041 + if (info.low_limit < info.high_limit) {
23042 + addr = vm_unmapped_area(&info);
23043 + if (!IS_ERR_VALUE(addr))
23044 + return addr;
23045 + }
23046 + } else
23047 +#endif
23048 +
23049 + info.low_limit = mm->mmap_base;
23050 + info.high_limit = pax_task_size;
23051 +
23052 + return vm_unmapped_area(&info);
23053 +}
23054 +
23055 +unsigned long
23056 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23057 + const unsigned long len, const unsigned long pgoff,
23058 + const unsigned long flags)
23059 +{
23060 + struct vm_area_struct *vma;
23061 + struct mm_struct *mm = current->mm;
23062 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23063 + struct vm_unmapped_area_info info;
23064 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23065 +
23066 +#ifdef CONFIG_PAX_SEGMEXEC
23067 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23068 + pax_task_size = SEGMEXEC_TASK_SIZE;
23069 +#endif
23070 +
23071 + pax_task_size -= PAGE_SIZE;
23072 +
23073 + /* requested length too big for entire address space */
23074 + if (len > pax_task_size)
23075 + return -ENOMEM;
23076 +
23077 + if (flags & MAP_FIXED)
23078 + return addr;
23079 +
23080 +#ifdef CONFIG_PAX_PAGEEXEC
23081 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23082 + goto bottomup;
23083 +#endif
23084 +
23085 +#ifdef CONFIG_PAX_RANDMMAP
23086 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23087 +#endif
23088 +
23089 + /* requesting a specific address */
23090 + if (addr) {
23091 + addr = PAGE_ALIGN(addr);
23092 + if (pax_task_size - len >= addr) {
23093 + vma = find_vma(mm, addr);
23094 + if (check_heap_stack_gap(vma, addr, len, offset))
23095 + return addr;
23096 + }
23097 + }
23098 +
23099 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23100 + info.length = len;
23101 + info.low_limit = PAGE_SIZE;
23102 + info.high_limit = mm->mmap_base;
23103 + info.align_mask = filp ? get_align_mask() : 0;
23104 + info.align_offset = pgoff << PAGE_SHIFT;
23105 + info.threadstack_offset = offset;
23106 +
23107 + addr = vm_unmapped_area(&info);
23108 + if (!(addr & ~PAGE_MASK))
23109 + return addr;
23110 + VM_BUG_ON(addr != -ENOMEM);
23111 +
23112 +bottomup:
23113 + /*
23114 + * A failed mmap() very likely causes application failure,
23115 + * so fall back to the bottom-up function here. This scenario
23116 + * can happen with large stack limits and large mmap()
23117 + * allocations.
23118 + */
23119 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23120 +}
23121 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23122 index dbded5a..ace2781 100644
23123 --- a/arch/x86/kernel/sys_x86_64.c
23124 +++ b/arch/x86/kernel/sys_x86_64.c
23125 @@ -81,8 +81,8 @@ out:
23126 return error;
23127 }
23128
23129 -static void find_start_end(unsigned long flags, unsigned long *begin,
23130 - unsigned long *end)
23131 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23132 + unsigned long *begin, unsigned long *end)
23133 {
23134 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23135 unsigned long new_begin;
23136 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23137 *begin = new_begin;
23138 }
23139 } else {
23140 - *begin = TASK_UNMAPPED_BASE;
23141 + *begin = mm->mmap_base;
23142 *end = TASK_SIZE;
23143 }
23144 }
23145 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23146 struct vm_area_struct *vma;
23147 struct vm_unmapped_area_info info;
23148 unsigned long begin, end;
23149 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23150
23151 if (flags & MAP_FIXED)
23152 return addr;
23153
23154 - find_start_end(flags, &begin, &end);
23155 + find_start_end(mm, flags, &begin, &end);
23156
23157 if (len > end)
23158 return -ENOMEM;
23159
23160 +#ifdef CONFIG_PAX_RANDMMAP
23161 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23162 +#endif
23163 +
23164 if (addr) {
23165 addr = PAGE_ALIGN(addr);
23166 vma = find_vma(mm, addr);
23167 - if (end - len >= addr &&
23168 - (!vma || addr + len <= vma->vm_start))
23169 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23170 return addr;
23171 }
23172
23173 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23174 info.high_limit = end;
23175 info.align_mask = filp ? get_align_mask() : 0;
23176 info.align_offset = pgoff << PAGE_SHIFT;
23177 + info.threadstack_offset = offset;
23178 return vm_unmapped_area(&info);
23179 }
23180
23181 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23182 struct mm_struct *mm = current->mm;
23183 unsigned long addr = addr0;
23184 struct vm_unmapped_area_info info;
23185 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23186
23187 /* requested length too big for entire address space */
23188 if (len > TASK_SIZE)
23189 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23190 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23191 goto bottomup;
23192
23193 +#ifdef CONFIG_PAX_RANDMMAP
23194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23195 +#endif
23196 +
23197 /* requesting a specific address */
23198 if (addr) {
23199 addr = PAGE_ALIGN(addr);
23200 vma = find_vma(mm, addr);
23201 - if (TASK_SIZE - len >= addr &&
23202 - (!vma || addr + len <= vma->vm_start))
23203 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23204 return addr;
23205 }
23206
23207 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23208 info.high_limit = mm->mmap_base;
23209 info.align_mask = filp ? get_align_mask() : 0;
23210 info.align_offset = pgoff << PAGE_SHIFT;
23211 + info.threadstack_offset = offset;
23212 addr = vm_unmapped_area(&info);
23213 if (!(addr & ~PAGE_MASK))
23214 return addr;
23215 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23216 index f84fe00..f41d9f1 100644
23217 --- a/arch/x86/kernel/tboot.c
23218 +++ b/arch/x86/kernel/tboot.c
23219 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23220
23221 void tboot_shutdown(u32 shutdown_type)
23222 {
23223 - void (*shutdown)(void);
23224 + void (* __noreturn shutdown)(void);
23225
23226 if (!tboot_enabled())
23227 return;
23228 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23229
23230 switch_to_tboot_pt();
23231
23232 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23233 + shutdown = (void *)tboot->shutdown_entry;
23234 shutdown();
23235
23236 /* should not reach here */
23237 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23238 return 0;
23239 }
23240
23241 -static atomic_t ap_wfs_count;
23242 +static atomic_unchecked_t ap_wfs_count;
23243
23244 static int tboot_wait_for_aps(int num_aps)
23245 {
23246 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23247 {
23248 switch (action) {
23249 case CPU_DYING:
23250 - atomic_inc(&ap_wfs_count);
23251 + atomic_inc_unchecked(&ap_wfs_count);
23252 if (num_online_cpus() == 1)
23253 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23254 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23255 return NOTIFY_BAD;
23256 break;
23257 }
23258 return NOTIFY_OK;
23259 }
23260
23261 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23262 +static struct notifier_block tboot_cpu_notifier =
23263 {
23264 .notifier_call = tboot_cpu_callback,
23265 };
23266 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23267
23268 tboot_create_trampoline();
23269
23270 - atomic_set(&ap_wfs_count, 0);
23271 + atomic_set_unchecked(&ap_wfs_count, 0);
23272 register_hotcpu_notifier(&tboot_cpu_notifier);
23273
23274 acpi_os_set_prepare_sleep(&tboot_sleep);
23275 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23276 index 24d3c91..d06b473 100644
23277 --- a/arch/x86/kernel/time.c
23278 +++ b/arch/x86/kernel/time.c
23279 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23280 {
23281 unsigned long pc = instruction_pointer(regs);
23282
23283 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23284 + if (!user_mode(regs) && in_lock_functions(pc)) {
23285 #ifdef CONFIG_FRAME_POINTER
23286 - return *(unsigned long *)(regs->bp + sizeof(long));
23287 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23288 #else
23289 unsigned long *sp =
23290 (unsigned long *)kernel_stack_pointer(regs);
23291 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23292 * or above a saved flags. Eflags has bits 22-31 zero,
23293 * kernel addresses don't.
23294 */
23295 +
23296 +#ifdef CONFIG_PAX_KERNEXEC
23297 + return ktla_ktva(sp[0]);
23298 +#else
23299 if (sp[0] >> 22)
23300 return sp[0];
23301 if (sp[1] >> 22)
23302 return sp[1];
23303 #endif
23304 +
23305 +#endif
23306 }
23307 return pc;
23308 }
23309 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23310 index f7fec09..9991981 100644
23311 --- a/arch/x86/kernel/tls.c
23312 +++ b/arch/x86/kernel/tls.c
23313 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23314 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23315 return -EINVAL;
23316
23317 +#ifdef CONFIG_PAX_SEGMEXEC
23318 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23319 + return -EINVAL;
23320 +#endif
23321 +
23322 set_tls_desc(p, idx, &info, 1);
23323
23324 return 0;
23325 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23326
23327 if (kbuf)
23328 info = kbuf;
23329 - else if (__copy_from_user(infobuf, ubuf, count))
23330 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23331 return -EFAULT;
23332 else
23333 info = infobuf;
23334 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23335 index 772e2a8..bad5bf6 100644
23336 --- a/arch/x86/kernel/traps.c
23337 +++ b/arch/x86/kernel/traps.c
23338 @@ -68,12 +68,6 @@
23339 #include <asm/setup.h>
23340
23341 asmlinkage int system_call(void);
23342 -
23343 -/*
23344 - * The IDT has to be page-aligned to simplify the Pentium
23345 - * F0 0F bug workaround.
23346 - */
23347 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23348 #endif
23349
23350 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23351 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23352 }
23353
23354 static int __kprobes
23355 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23356 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23357 struct pt_regs *regs, long error_code)
23358 {
23359 #ifdef CONFIG_X86_32
23360 - if (regs->flags & X86_VM_MASK) {
23361 + if (v8086_mode(regs)) {
23362 /*
23363 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23364 * On nmi (interrupt 2), do_trap should not be called.
23365 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23366 return -1;
23367 }
23368 #endif
23369 - if (!user_mode(regs)) {
23370 + if (!user_mode_novm(regs)) {
23371 if (!fixup_exception(regs)) {
23372 tsk->thread.error_code = error_code;
23373 tsk->thread.trap_nr = trapnr;
23374 +
23375 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23376 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23377 + str = "PAX: suspicious stack segment fault";
23378 +#endif
23379 +
23380 die(str, regs, error_code);
23381 }
23382 +
23383 +#ifdef CONFIG_PAX_REFCOUNT
23384 + if (trapnr == 4)
23385 + pax_report_refcount_overflow(regs);
23386 +#endif
23387 +
23388 return 0;
23389 }
23390
23391 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23392 }
23393
23394 static void __kprobes
23395 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23396 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23397 long error_code, siginfo_t *info)
23398 {
23399 struct task_struct *tsk = current;
23400 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23401 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23402 printk_ratelimit()) {
23403 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23404 - tsk->comm, tsk->pid, str,
23405 + tsk->comm, task_pid_nr(tsk), str,
23406 regs->ip, regs->sp, error_code);
23407 print_vma_addr(" in ", regs->ip);
23408 pr_cont("\n");
23409 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23410 conditional_sti(regs);
23411
23412 #ifdef CONFIG_X86_32
23413 - if (regs->flags & X86_VM_MASK) {
23414 + if (v8086_mode(regs)) {
23415 local_irq_enable();
23416 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23417 goto exit;
23418 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23419 #endif
23420
23421 tsk = current;
23422 - if (!user_mode(regs)) {
23423 + if (!user_mode_novm(regs)) {
23424 if (fixup_exception(regs))
23425 goto exit;
23426
23427 tsk->thread.error_code = error_code;
23428 tsk->thread.trap_nr = X86_TRAP_GP;
23429 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23430 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23431 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23432 +
23433 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23434 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23435 + die("PAX: suspicious general protection fault", regs, error_code);
23436 + else
23437 +#endif
23438 +
23439 die("general protection fault", regs, error_code);
23440 + }
23441 goto exit;
23442 }
23443
23444 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23445 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23446 + struct mm_struct *mm = tsk->mm;
23447 + unsigned long limit;
23448 +
23449 + down_write(&mm->mmap_sem);
23450 + limit = mm->context.user_cs_limit;
23451 + if (limit < TASK_SIZE) {
23452 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23453 + up_write(&mm->mmap_sem);
23454 + return;
23455 + }
23456 + up_write(&mm->mmap_sem);
23457 + }
23458 +#endif
23459 +
23460 tsk->thread.error_code = error_code;
23461 tsk->thread.trap_nr = X86_TRAP_GP;
23462
23463 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23464 /* It's safe to allow irq's after DR6 has been saved */
23465 preempt_conditional_sti(regs);
23466
23467 - if (regs->flags & X86_VM_MASK) {
23468 + if (v8086_mode(regs)) {
23469 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23470 X86_TRAP_DB);
23471 preempt_conditional_cli(regs);
23472 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23473 * We already checked v86 mode above, so we can check for kernel mode
23474 * by just checking the CPL of CS.
23475 */
23476 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23477 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23478 tsk->thread.debugreg6 &= ~DR_STEP;
23479 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23480 regs->flags &= ~X86_EFLAGS_TF;
23481 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23482 return;
23483 conditional_sti(regs);
23484
23485 - if (!user_mode_vm(regs))
23486 + if (!user_mode(regs))
23487 {
23488 if (!fixup_exception(regs)) {
23489 task->thread.error_code = error_code;
23490 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23491 index 2ed8459..7cf329f 100644
23492 --- a/arch/x86/kernel/uprobes.c
23493 +++ b/arch/x86/kernel/uprobes.c
23494 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23495 int ret = NOTIFY_DONE;
23496
23497 /* We are only interested in userspace traps */
23498 - if (regs && !user_mode_vm(regs))
23499 + if (regs && !user_mode(regs))
23500 return NOTIFY_DONE;
23501
23502 switch (val) {
23503 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
23504
23505 if (ncopied != rasize) {
23506 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
23507 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
23508 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
23509
23510 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
23511 }
23512 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23513 index b9242ba..50c5edd 100644
23514 --- a/arch/x86/kernel/verify_cpu.S
23515 +++ b/arch/x86/kernel/verify_cpu.S
23516 @@ -20,6 +20,7 @@
23517 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23518 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23519 * arch/x86/kernel/head_32.S: processor startup
23520 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23521 *
23522 * verify_cpu, returns the status of longmode and SSE in register %eax.
23523 * 0: Success 1: Failure
23524 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23525 index e8edcf5..27f9344 100644
23526 --- a/arch/x86/kernel/vm86_32.c
23527 +++ b/arch/x86/kernel/vm86_32.c
23528 @@ -44,6 +44,7 @@
23529 #include <linux/ptrace.h>
23530 #include <linux/audit.h>
23531 #include <linux/stddef.h>
23532 +#include <linux/grsecurity.h>
23533
23534 #include <asm/uaccess.h>
23535 #include <asm/io.h>
23536 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23537 do_exit(SIGSEGV);
23538 }
23539
23540 - tss = &per_cpu(init_tss, get_cpu());
23541 + tss = init_tss + get_cpu();
23542 current->thread.sp0 = current->thread.saved_sp0;
23543 current->thread.sysenter_cs = __KERNEL_CS;
23544 load_sp0(tss, &current->thread);
23545 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23546
23547 if (tsk->thread.saved_sp0)
23548 return -EPERM;
23549 +
23550 +#ifdef CONFIG_GRKERNSEC_VM86
23551 + if (!capable(CAP_SYS_RAWIO)) {
23552 + gr_handle_vm86();
23553 + return -EPERM;
23554 + }
23555 +#endif
23556 +
23557 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23558 offsetof(struct kernel_vm86_struct, vm86plus) -
23559 sizeof(info.regs));
23560 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23561 int tmp;
23562 struct vm86plus_struct __user *v86;
23563
23564 +#ifdef CONFIG_GRKERNSEC_VM86
23565 + if (!capable(CAP_SYS_RAWIO)) {
23566 + gr_handle_vm86();
23567 + return -EPERM;
23568 + }
23569 +#endif
23570 +
23571 tsk = current;
23572 switch (cmd) {
23573 case VM86_REQUEST_IRQ:
23574 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23575 tsk->thread.saved_fs = info->regs32->fs;
23576 tsk->thread.saved_gs = get_user_gs(info->regs32);
23577
23578 - tss = &per_cpu(init_tss, get_cpu());
23579 + tss = init_tss + get_cpu();
23580 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23581 if (cpu_has_sep)
23582 tsk->thread.sysenter_cs = 0;
23583 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23584 goto cannot_handle;
23585 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23586 goto cannot_handle;
23587 - intr_ptr = (unsigned long __user *) (i << 2);
23588 + intr_ptr = (__force unsigned long __user *) (i << 2);
23589 if (get_user(segoffs, intr_ptr))
23590 goto cannot_handle;
23591 if ((segoffs >> 16) == BIOSSEG)
23592 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23593 index 10c4f30..57377c2 100644
23594 --- a/arch/x86/kernel/vmlinux.lds.S
23595 +++ b/arch/x86/kernel/vmlinux.lds.S
23596 @@ -26,6 +26,13 @@
23597 #include <asm/page_types.h>
23598 #include <asm/cache.h>
23599 #include <asm/boot.h>
23600 +#include <asm/segment.h>
23601 +
23602 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23603 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23604 +#else
23605 +#define __KERNEL_TEXT_OFFSET 0
23606 +#endif
23607
23608 #undef i386 /* in case the preprocessor is a 32bit one */
23609
23610 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23611
23612 PHDRS {
23613 text PT_LOAD FLAGS(5); /* R_E */
23614 +#ifdef CONFIG_X86_32
23615 + module PT_LOAD FLAGS(5); /* R_E */
23616 +#endif
23617 +#ifdef CONFIG_XEN
23618 + rodata PT_LOAD FLAGS(5); /* R_E */
23619 +#else
23620 + rodata PT_LOAD FLAGS(4); /* R__ */
23621 +#endif
23622 data PT_LOAD FLAGS(6); /* RW_ */
23623 -#ifdef CONFIG_X86_64
23624 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23625 #ifdef CONFIG_SMP
23626 percpu PT_LOAD FLAGS(6); /* RW_ */
23627 #endif
23628 + text.init PT_LOAD FLAGS(5); /* R_E */
23629 + text.exit PT_LOAD FLAGS(5); /* R_E */
23630 init PT_LOAD FLAGS(7); /* RWE */
23631 -#endif
23632 note PT_NOTE FLAGS(0); /* ___ */
23633 }
23634
23635 SECTIONS
23636 {
23637 #ifdef CONFIG_X86_32
23638 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23639 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23640 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23641 #else
23642 - . = __START_KERNEL;
23643 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23644 + . = __START_KERNEL;
23645 #endif
23646
23647 /* Text and read-only data */
23648 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23649 - _text = .;
23650 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23651 /* bootstrapping code */
23652 +#ifdef CONFIG_X86_32
23653 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23654 +#else
23655 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23656 +#endif
23657 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23658 + _text = .;
23659 HEAD_TEXT
23660 . = ALIGN(8);
23661 _stext = .;
23662 @@ -104,13 +124,48 @@ SECTIONS
23663 IRQENTRY_TEXT
23664 *(.fixup)
23665 *(.gnu.warning)
23666 - /* End of text section */
23667 - _etext = .;
23668 } :text = 0x9090
23669
23670 - NOTES :text :note
23671 + . += __KERNEL_TEXT_OFFSET;
23672
23673 - EXCEPTION_TABLE(16) :text = 0x9090
23674 +#ifdef CONFIG_X86_32
23675 + . = ALIGN(PAGE_SIZE);
23676 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23677 +
23678 +#ifdef CONFIG_PAX_KERNEXEC
23679 + MODULES_EXEC_VADDR = .;
23680 + BYTE(0)
23681 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23682 + . = ALIGN(HPAGE_SIZE) - 1;
23683 + MODULES_EXEC_END = .;
23684 +#endif
23685 +
23686 + } :module
23687 +#endif
23688 +
23689 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23690 + /* End of text section */
23691 + BYTE(0)
23692 + _etext = . - __KERNEL_TEXT_OFFSET;
23693 + }
23694 +
23695 +#ifdef CONFIG_X86_32
23696 + . = ALIGN(PAGE_SIZE);
23697 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23698 + *(.idt)
23699 + . = ALIGN(PAGE_SIZE);
23700 + *(.empty_zero_page)
23701 + *(.initial_pg_fixmap)
23702 + *(.initial_pg_pmd)
23703 + *(.initial_page_table)
23704 + *(.swapper_pg_dir)
23705 + } :rodata
23706 +#endif
23707 +
23708 + . = ALIGN(PAGE_SIZE);
23709 + NOTES :rodata :note
23710 +
23711 + EXCEPTION_TABLE(16) :rodata
23712
23713 #if defined(CONFIG_DEBUG_RODATA)
23714 /* .text should occupy whole number of pages */
23715 @@ -122,16 +177,20 @@ SECTIONS
23716
23717 /* Data */
23718 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23719 +
23720 +#ifdef CONFIG_PAX_KERNEXEC
23721 + . = ALIGN(HPAGE_SIZE);
23722 +#else
23723 + . = ALIGN(PAGE_SIZE);
23724 +#endif
23725 +
23726 /* Start of data section */
23727 _sdata = .;
23728
23729 /* init_task */
23730 INIT_TASK_DATA(THREAD_SIZE)
23731
23732 -#ifdef CONFIG_X86_32
23733 - /* 32 bit has nosave before _edata */
23734 NOSAVE_DATA
23735 -#endif
23736
23737 PAGE_ALIGNED_DATA(PAGE_SIZE)
23738
23739 @@ -172,12 +231,19 @@ SECTIONS
23740 #endif /* CONFIG_X86_64 */
23741
23742 /* Init code and data - will be freed after init */
23743 - . = ALIGN(PAGE_SIZE);
23744 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23745 + BYTE(0)
23746 +
23747 +#ifdef CONFIG_PAX_KERNEXEC
23748 + . = ALIGN(HPAGE_SIZE);
23749 +#else
23750 + . = ALIGN(PAGE_SIZE);
23751 +#endif
23752 +
23753 __init_begin = .; /* paired with __init_end */
23754 - }
23755 + } :init.begin
23756
23757 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23758 +#ifdef CONFIG_SMP
23759 /*
23760 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23761 * output PHDR, so the next output section - .init.text - should
23762 @@ -186,12 +252,27 @@ SECTIONS
23763 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23764 #endif
23765
23766 - INIT_TEXT_SECTION(PAGE_SIZE)
23767 -#ifdef CONFIG_X86_64
23768 - :init
23769 -#endif
23770 + . = ALIGN(PAGE_SIZE);
23771 + init_begin = .;
23772 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23773 + VMLINUX_SYMBOL(_sinittext) = .;
23774 + INIT_TEXT
23775 + VMLINUX_SYMBOL(_einittext) = .;
23776 + . = ALIGN(PAGE_SIZE);
23777 + } :text.init
23778
23779 - INIT_DATA_SECTION(16)
23780 + /*
23781 + * .exit.text is discard at runtime, not link time, to deal with
23782 + * references from .altinstructions and .eh_frame
23783 + */
23784 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23785 + EXIT_TEXT
23786 + . = ALIGN(16);
23787 + } :text.exit
23788 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23789 +
23790 + . = ALIGN(PAGE_SIZE);
23791 + INIT_DATA_SECTION(16) :init
23792
23793 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23794 __x86_cpu_dev_start = .;
23795 @@ -253,19 +334,12 @@ SECTIONS
23796 }
23797
23798 . = ALIGN(8);
23799 - /*
23800 - * .exit.text is discard at runtime, not link time, to deal with
23801 - * references from .altinstructions and .eh_frame
23802 - */
23803 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23804 - EXIT_TEXT
23805 - }
23806
23807 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23808 EXIT_DATA
23809 }
23810
23811 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23812 +#ifndef CONFIG_SMP
23813 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23814 #endif
23815
23816 @@ -284,16 +358,10 @@ SECTIONS
23817 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23818 __smp_locks = .;
23819 *(.smp_locks)
23820 - . = ALIGN(PAGE_SIZE);
23821 __smp_locks_end = .;
23822 + . = ALIGN(PAGE_SIZE);
23823 }
23824
23825 -#ifdef CONFIG_X86_64
23826 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23827 - NOSAVE_DATA
23828 - }
23829 -#endif
23830 -
23831 /* BSS */
23832 . = ALIGN(PAGE_SIZE);
23833 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23834 @@ -309,6 +377,7 @@ SECTIONS
23835 __brk_base = .;
23836 . += 64 * 1024; /* 64k alignment slop space */
23837 *(.brk_reservation) /* areas brk users have reserved */
23838 + . = ALIGN(HPAGE_SIZE);
23839 __brk_limit = .;
23840 }
23841
23842 @@ -335,13 +404,12 @@ SECTIONS
23843 * for the boot processor.
23844 */
23845 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23846 -INIT_PER_CPU(gdt_page);
23847 INIT_PER_CPU(irq_stack_union);
23848
23849 /*
23850 * Build-time check on the image size:
23851 */
23852 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23853 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23854 "kernel image bigger than KERNEL_IMAGE_SIZE");
23855
23856 #ifdef CONFIG_SMP
23857 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23858 index 9a907a6..f83f921 100644
23859 --- a/arch/x86/kernel/vsyscall_64.c
23860 +++ b/arch/x86/kernel/vsyscall_64.c
23861 @@ -56,15 +56,13 @@
23862 DEFINE_VVAR(int, vgetcpu_mode);
23863 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23864
23865 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23866 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23867
23868 static int __init vsyscall_setup(char *str)
23869 {
23870 if (str) {
23871 if (!strcmp("emulate", str))
23872 vsyscall_mode = EMULATE;
23873 - else if (!strcmp("native", str))
23874 - vsyscall_mode = NATIVE;
23875 else if (!strcmp("none", str))
23876 vsyscall_mode = NONE;
23877 else
23878 @@ -323,8 +321,7 @@ do_ret:
23879 return true;
23880
23881 sigsegv:
23882 - force_sig(SIGSEGV, current);
23883 - return true;
23884 + do_group_exit(SIGKILL);
23885 }
23886
23887 /*
23888 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23889 extern char __vvar_page;
23890 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23891
23892 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23893 - vsyscall_mode == NATIVE
23894 - ? PAGE_KERNEL_VSYSCALL
23895 - : PAGE_KERNEL_VVAR);
23896 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23897 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23898 (unsigned long)VSYSCALL_START);
23899
23900 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23901 index b014d94..6d6ca7b 100644
23902 --- a/arch/x86/kernel/x8664_ksyms_64.c
23903 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23904 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23905 EXPORT_SYMBOL(copy_user_generic_unrolled);
23906 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23907 EXPORT_SYMBOL(__copy_user_nocache);
23908 -EXPORT_SYMBOL(_copy_from_user);
23909 -EXPORT_SYMBOL(_copy_to_user);
23910
23911 EXPORT_SYMBOL(copy_page);
23912 EXPORT_SYMBOL(clear_page);
23913 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23914 index 45a14db..075bb9b 100644
23915 --- a/arch/x86/kernel/x86_init.c
23916 +++ b/arch/x86/kernel/x86_init.c
23917 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23918 },
23919 };
23920
23921 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23922 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23923 .early_percpu_clock_init = x86_init_noop,
23924 .setup_percpu_clockev = setup_secondary_APIC_clock,
23925 };
23926 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23927 static void default_nmi_init(void) { };
23928 static int default_i8042_detect(void) { return 1; };
23929
23930 -struct x86_platform_ops x86_platform = {
23931 +struct x86_platform_ops x86_platform __read_only = {
23932 .calibrate_tsc = native_calibrate_tsc,
23933 .get_wallclock = mach_get_cmos_time,
23934 .set_wallclock = mach_set_rtc_mmss,
23935 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23936 };
23937
23938 EXPORT_SYMBOL_GPL(x86_platform);
23939 -struct x86_msi_ops x86_msi = {
23940 +struct x86_msi_ops x86_msi __read_only = {
23941 .setup_msi_irqs = native_setup_msi_irqs,
23942 .compose_msi_msg = native_compose_msi_msg,
23943 .teardown_msi_irq = native_teardown_msi_irq,
23944 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23945 .setup_hpet_msi = default_setup_hpet_msi,
23946 };
23947
23948 -struct x86_io_apic_ops x86_io_apic_ops = {
23949 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23950 .init = native_io_apic_init_mappings,
23951 .read = native_io_apic_read,
23952 .write = native_io_apic_write,
23953 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23954 index ada87a3..afea76d 100644
23955 --- a/arch/x86/kernel/xsave.c
23956 +++ b/arch/x86/kernel/xsave.c
23957 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23958 {
23959 int err;
23960
23961 + buf = (struct xsave_struct __user *)____m(buf);
23962 if (use_xsave())
23963 err = xsave_user(buf);
23964 else if (use_fxsr())
23965 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23966 */
23967 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23968 {
23969 + buf = (void __user *)____m(buf);
23970 if (use_xsave()) {
23971 if ((unsigned long)buf % 64 || fx_only) {
23972 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23973 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23974 index a20ecb5..d0e2194 100644
23975 --- a/arch/x86/kvm/cpuid.c
23976 +++ b/arch/x86/kvm/cpuid.c
23977 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23978 struct kvm_cpuid2 *cpuid,
23979 struct kvm_cpuid_entry2 __user *entries)
23980 {
23981 - int r;
23982 + int r, i;
23983
23984 r = -E2BIG;
23985 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23986 goto out;
23987 r = -EFAULT;
23988 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23989 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23990 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23991 goto out;
23992 + for (i = 0; i < cpuid->nent; ++i) {
23993 + struct kvm_cpuid_entry2 cpuid_entry;
23994 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23995 + goto out;
23996 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23997 + }
23998 vcpu->arch.cpuid_nent = cpuid->nent;
23999 kvm_apic_set_version(vcpu);
24000 kvm_x86_ops->cpuid_update(vcpu);
24001 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24002 struct kvm_cpuid2 *cpuid,
24003 struct kvm_cpuid_entry2 __user *entries)
24004 {
24005 - int r;
24006 + int r, i;
24007
24008 r = -E2BIG;
24009 if (cpuid->nent < vcpu->arch.cpuid_nent)
24010 goto out;
24011 r = -EFAULT;
24012 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24013 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24014 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24015 goto out;
24016 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24017 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24018 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24019 + goto out;
24020 + }
24021 return 0;
24022
24023 out:
24024 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24025 index 5953dce..f11a7d2 100644
24026 --- a/arch/x86/kvm/emulate.c
24027 +++ b/arch/x86/kvm/emulate.c
24028 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24029
24030 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24031 do { \
24032 + unsigned long _tmp; \
24033 __asm__ __volatile__ ( \
24034 _PRE_EFLAGS("0", "4", "2") \
24035 _op _suffix " %"_x"3,%1; " \
24036 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24037 /* Raw emulation: instruction has two explicit operands. */
24038 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24039 do { \
24040 - unsigned long _tmp; \
24041 - \
24042 switch ((ctxt)->dst.bytes) { \
24043 case 2: \
24044 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24045 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24046
24047 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24048 do { \
24049 - unsigned long _tmp; \
24050 switch ((ctxt)->dst.bytes) { \
24051 case 1: \
24052 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24053 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24054 index 0eee2c8..94a32c3 100644
24055 --- a/arch/x86/kvm/lapic.c
24056 +++ b/arch/x86/kvm/lapic.c
24057 @@ -55,7 +55,7 @@
24058 #define APIC_BUS_CYCLE_NS 1
24059
24060 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24061 -#define apic_debug(fmt, arg...)
24062 +#define apic_debug(fmt, arg...) do {} while (0)
24063
24064 #define APIC_LVT_NUM 6
24065 /* 14 is the version for Xeon and Pentium 8.4.8*/
24066 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24067 index da20860..d19fdf5 100644
24068 --- a/arch/x86/kvm/paging_tmpl.h
24069 +++ b/arch/x86/kvm/paging_tmpl.h
24070 @@ -208,7 +208,7 @@ retry_walk:
24071 if (unlikely(kvm_is_error_hva(host_addr)))
24072 goto error;
24073
24074 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24075 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24076 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24077 goto error;
24078 walker->ptep_user[walker->level - 1] = ptep_user;
24079 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24080 index a14a6ea..dc86cf0 100644
24081 --- a/arch/x86/kvm/svm.c
24082 +++ b/arch/x86/kvm/svm.c
24083 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24084 int cpu = raw_smp_processor_id();
24085
24086 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24087 +
24088 + pax_open_kernel();
24089 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24090 + pax_close_kernel();
24091 +
24092 load_TR_desc();
24093 }
24094
24095 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24096 #endif
24097 #endif
24098
24099 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24100 + __set_fs(current_thread_info()->addr_limit);
24101 +#endif
24102 +
24103 reload_tss(vcpu);
24104
24105 local_irq_disable();
24106 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24107 index 5402c94..c3bdeee 100644
24108 --- a/arch/x86/kvm/vmx.c
24109 +++ b/arch/x86/kvm/vmx.c
24110 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24111 #endif
24112 }
24113
24114 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24115 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24116 {
24117 vmcs_writel(field, vmcs_readl(field) & ~mask);
24118 }
24119
24120 -static void vmcs_set_bits(unsigned long field, u32 mask)
24121 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24122 {
24123 vmcs_writel(field, vmcs_readl(field) | mask);
24124 }
24125 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
24126 struct desc_struct *descs;
24127
24128 descs = (void *)gdt->address;
24129 +
24130 + pax_open_kernel();
24131 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24132 + pax_close_kernel();
24133 +
24134 load_TR_desc();
24135 }
24136
24137 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24138 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24139 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24140
24141 +#ifdef CONFIG_PAX_PER_CPU_PGD
24142 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24143 +#endif
24144 +
24145 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24146 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24147 vmx->loaded_vmcs->cpu = cpu;
24148 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
24149 if (!cpu_has_vmx_flexpriority())
24150 flexpriority_enabled = 0;
24151
24152 - if (!cpu_has_vmx_tpr_shadow())
24153 - kvm_x86_ops->update_cr8_intercept = NULL;
24154 + if (!cpu_has_vmx_tpr_shadow()) {
24155 + pax_open_kernel();
24156 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24157 + pax_close_kernel();
24158 + }
24159
24160 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24161 kvm_disable_largepages();
24162 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
24163 if (!cpu_has_vmx_apicv())
24164 enable_apicv = 0;
24165
24166 + pax_open_kernel();
24167 if (enable_apicv)
24168 - kvm_x86_ops->update_cr8_intercept = NULL;
24169 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24170 else {
24171 - kvm_x86_ops->hwapic_irr_update = NULL;
24172 - kvm_x86_ops->deliver_posted_interrupt = NULL;
24173 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24174 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24175 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
24176 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24177 }
24178 + pax_close_kernel();
24179
24180 if (nested)
24181 nested_vmx_setup_ctls_msrs();
24182 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24183
24184 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24185 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24186 +
24187 +#ifndef CONFIG_PAX_PER_CPU_PGD
24188 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24189 +#endif
24190
24191 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24192 #ifdef CONFIG_X86_64
24193 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24194 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24195 vmx->host_idt_base = dt.address;
24196
24197 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24198 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24199
24200 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24201 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24202 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24203 "jmp 2f \n\t"
24204 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24205 "2: "
24206 +
24207 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24208 + "ljmp %[cs],$3f\n\t"
24209 + "3: "
24210 +#endif
24211 +
24212 /* Save guest registers, load host registers, keep flags */
24213 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24214 "pop %0 \n\t"
24215 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24216 #endif
24217 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24218 [wordsize]"i"(sizeof(ulong))
24219 +
24220 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24221 + ,[cs]"i"(__KERNEL_CS)
24222 +#endif
24223 +
24224 : "cc", "memory"
24225 #ifdef CONFIG_X86_64
24226 , "rax", "rbx", "rdi", "rsi"
24227 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24228 if (debugctlmsr)
24229 update_debugctlmsr(debugctlmsr);
24230
24231 -#ifndef CONFIG_X86_64
24232 +#ifdef CONFIG_X86_32
24233 /*
24234 * The sysexit path does not restore ds/es, so we must set them to
24235 * a reasonable value ourselves.
24236 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24237 * may be executed in interrupt context, which saves and restore segments
24238 * around it, nullifying its effect.
24239 */
24240 - loadsegment(ds, __USER_DS);
24241 - loadsegment(es, __USER_DS);
24242 + loadsegment(ds, __KERNEL_DS);
24243 + loadsegment(es, __KERNEL_DS);
24244 + loadsegment(ss, __KERNEL_DS);
24245 +
24246 +#ifdef CONFIG_PAX_KERNEXEC
24247 + loadsegment(fs, __KERNEL_PERCPU);
24248 +#endif
24249 +
24250 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24251 + __set_fs(current_thread_info()->addr_limit);
24252 +#endif
24253 +
24254 #endif
24255
24256 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24257 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24258 index e8ba99c..ee9d7d9 100644
24259 --- a/arch/x86/kvm/x86.c
24260 +++ b/arch/x86/kvm/x86.c
24261 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24262 {
24263 struct kvm *kvm = vcpu->kvm;
24264 int lm = is_long_mode(vcpu);
24265 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24266 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24267 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24268 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24269 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24270 : kvm->arch.xen_hvm_config.blob_size_32;
24271 u32 page_num = data & ~PAGE_MASK;
24272 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24273 if (n < msr_list.nmsrs)
24274 goto out;
24275 r = -EFAULT;
24276 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24277 + goto out;
24278 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24279 num_msrs_to_save * sizeof(u32)))
24280 goto out;
24281 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24282 };
24283 #endif
24284
24285 -int kvm_arch_init(void *opaque)
24286 +int kvm_arch_init(const void *opaque)
24287 {
24288 int r;
24289 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24290 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24291 index 7114c63..a1018fc 100644
24292 --- a/arch/x86/lguest/boot.c
24293 +++ b/arch/x86/lguest/boot.c
24294 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24295 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24296 * Launcher to reboot us.
24297 */
24298 -static void lguest_restart(char *reason)
24299 +static __noreturn void lguest_restart(char *reason)
24300 {
24301 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24302 + BUG();
24303 }
24304
24305 /*G:050
24306 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24307 index 00933d5..3a64af9 100644
24308 --- a/arch/x86/lib/atomic64_386_32.S
24309 +++ b/arch/x86/lib/atomic64_386_32.S
24310 @@ -48,6 +48,10 @@ BEGIN(read)
24311 movl (v), %eax
24312 movl 4(v), %edx
24313 RET_ENDP
24314 +BEGIN(read_unchecked)
24315 + movl (v), %eax
24316 + movl 4(v), %edx
24317 +RET_ENDP
24318 #undef v
24319
24320 #define v %esi
24321 @@ -55,6 +59,10 @@ BEGIN(set)
24322 movl %ebx, (v)
24323 movl %ecx, 4(v)
24324 RET_ENDP
24325 +BEGIN(set_unchecked)
24326 + movl %ebx, (v)
24327 + movl %ecx, 4(v)
24328 +RET_ENDP
24329 #undef v
24330
24331 #define v %esi
24332 @@ -70,6 +78,20 @@ RET_ENDP
24333 BEGIN(add)
24334 addl %eax, (v)
24335 adcl %edx, 4(v)
24336 +
24337 +#ifdef CONFIG_PAX_REFCOUNT
24338 + jno 0f
24339 + subl %eax, (v)
24340 + sbbl %edx, 4(v)
24341 + int $4
24342 +0:
24343 + _ASM_EXTABLE(0b, 0b)
24344 +#endif
24345 +
24346 +RET_ENDP
24347 +BEGIN(add_unchecked)
24348 + addl %eax, (v)
24349 + adcl %edx, 4(v)
24350 RET_ENDP
24351 #undef v
24352
24353 @@ -77,6 +99,24 @@ RET_ENDP
24354 BEGIN(add_return)
24355 addl (v), %eax
24356 adcl 4(v), %edx
24357 +
24358 +#ifdef CONFIG_PAX_REFCOUNT
24359 + into
24360 +1234:
24361 + _ASM_EXTABLE(1234b, 2f)
24362 +#endif
24363 +
24364 + movl %eax, (v)
24365 + movl %edx, 4(v)
24366 +
24367 +#ifdef CONFIG_PAX_REFCOUNT
24368 +2:
24369 +#endif
24370 +
24371 +RET_ENDP
24372 +BEGIN(add_return_unchecked)
24373 + addl (v), %eax
24374 + adcl 4(v), %edx
24375 movl %eax, (v)
24376 movl %edx, 4(v)
24377 RET_ENDP
24378 @@ -86,6 +126,20 @@ RET_ENDP
24379 BEGIN(sub)
24380 subl %eax, (v)
24381 sbbl %edx, 4(v)
24382 +
24383 +#ifdef CONFIG_PAX_REFCOUNT
24384 + jno 0f
24385 + addl %eax, (v)
24386 + adcl %edx, 4(v)
24387 + int $4
24388 +0:
24389 + _ASM_EXTABLE(0b, 0b)
24390 +#endif
24391 +
24392 +RET_ENDP
24393 +BEGIN(sub_unchecked)
24394 + subl %eax, (v)
24395 + sbbl %edx, 4(v)
24396 RET_ENDP
24397 #undef v
24398
24399 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24400 sbbl $0, %edx
24401 addl (v), %eax
24402 adcl 4(v), %edx
24403 +
24404 +#ifdef CONFIG_PAX_REFCOUNT
24405 + into
24406 +1234:
24407 + _ASM_EXTABLE(1234b, 2f)
24408 +#endif
24409 +
24410 + movl %eax, (v)
24411 + movl %edx, 4(v)
24412 +
24413 +#ifdef CONFIG_PAX_REFCOUNT
24414 +2:
24415 +#endif
24416 +
24417 +RET_ENDP
24418 +BEGIN(sub_return_unchecked)
24419 + negl %edx
24420 + negl %eax
24421 + sbbl $0, %edx
24422 + addl (v), %eax
24423 + adcl 4(v), %edx
24424 movl %eax, (v)
24425 movl %edx, 4(v)
24426 RET_ENDP
24427 @@ -105,6 +180,20 @@ RET_ENDP
24428 BEGIN(inc)
24429 addl $1, (v)
24430 adcl $0, 4(v)
24431 +
24432 +#ifdef CONFIG_PAX_REFCOUNT
24433 + jno 0f
24434 + subl $1, (v)
24435 + sbbl $0, 4(v)
24436 + int $4
24437 +0:
24438 + _ASM_EXTABLE(0b, 0b)
24439 +#endif
24440 +
24441 +RET_ENDP
24442 +BEGIN(inc_unchecked)
24443 + addl $1, (v)
24444 + adcl $0, 4(v)
24445 RET_ENDP
24446 #undef v
24447
24448 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24449 movl 4(v), %edx
24450 addl $1, %eax
24451 adcl $0, %edx
24452 +
24453 +#ifdef CONFIG_PAX_REFCOUNT
24454 + into
24455 +1234:
24456 + _ASM_EXTABLE(1234b, 2f)
24457 +#endif
24458 +
24459 + movl %eax, (v)
24460 + movl %edx, 4(v)
24461 +
24462 +#ifdef CONFIG_PAX_REFCOUNT
24463 +2:
24464 +#endif
24465 +
24466 +RET_ENDP
24467 +BEGIN(inc_return_unchecked)
24468 + movl (v), %eax
24469 + movl 4(v), %edx
24470 + addl $1, %eax
24471 + adcl $0, %edx
24472 movl %eax, (v)
24473 movl %edx, 4(v)
24474 RET_ENDP
24475 @@ -123,6 +232,20 @@ RET_ENDP
24476 BEGIN(dec)
24477 subl $1, (v)
24478 sbbl $0, 4(v)
24479 +
24480 +#ifdef CONFIG_PAX_REFCOUNT
24481 + jno 0f
24482 + addl $1, (v)
24483 + adcl $0, 4(v)
24484 + int $4
24485 +0:
24486 + _ASM_EXTABLE(0b, 0b)
24487 +#endif
24488 +
24489 +RET_ENDP
24490 +BEGIN(dec_unchecked)
24491 + subl $1, (v)
24492 + sbbl $0, 4(v)
24493 RET_ENDP
24494 #undef v
24495
24496 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24497 movl 4(v), %edx
24498 subl $1, %eax
24499 sbbl $0, %edx
24500 +
24501 +#ifdef CONFIG_PAX_REFCOUNT
24502 + into
24503 +1234:
24504 + _ASM_EXTABLE(1234b, 2f)
24505 +#endif
24506 +
24507 + movl %eax, (v)
24508 + movl %edx, 4(v)
24509 +
24510 +#ifdef CONFIG_PAX_REFCOUNT
24511 +2:
24512 +#endif
24513 +
24514 +RET_ENDP
24515 +BEGIN(dec_return_unchecked)
24516 + movl (v), %eax
24517 + movl 4(v), %edx
24518 + subl $1, %eax
24519 + sbbl $0, %edx
24520 movl %eax, (v)
24521 movl %edx, 4(v)
24522 RET_ENDP
24523 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24524 adcl %edx, %edi
24525 addl (v), %eax
24526 adcl 4(v), %edx
24527 +
24528 +#ifdef CONFIG_PAX_REFCOUNT
24529 + into
24530 +1234:
24531 + _ASM_EXTABLE(1234b, 2f)
24532 +#endif
24533 +
24534 cmpl %eax, %ecx
24535 je 3f
24536 1:
24537 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24538 1:
24539 addl $1, %eax
24540 adcl $0, %edx
24541 +
24542 +#ifdef CONFIG_PAX_REFCOUNT
24543 + into
24544 +1234:
24545 + _ASM_EXTABLE(1234b, 2f)
24546 +#endif
24547 +
24548 movl %eax, (v)
24549 movl %edx, 4(v)
24550 movl $1, %eax
24551 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24552 movl 4(v), %edx
24553 subl $1, %eax
24554 sbbl $0, %edx
24555 +
24556 +#ifdef CONFIG_PAX_REFCOUNT
24557 + into
24558 +1234:
24559 + _ASM_EXTABLE(1234b, 1f)
24560 +#endif
24561 +
24562 js 1f
24563 movl %eax, (v)
24564 movl %edx, 4(v)
24565 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24566 index f5cc9eb..51fa319 100644
24567 --- a/arch/x86/lib/atomic64_cx8_32.S
24568 +++ b/arch/x86/lib/atomic64_cx8_32.S
24569 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24570 CFI_STARTPROC
24571
24572 read64 %ecx
24573 + pax_force_retaddr
24574 ret
24575 CFI_ENDPROC
24576 ENDPROC(atomic64_read_cx8)
24577
24578 +ENTRY(atomic64_read_unchecked_cx8)
24579 + CFI_STARTPROC
24580 +
24581 + read64 %ecx
24582 + pax_force_retaddr
24583 + ret
24584 + CFI_ENDPROC
24585 +ENDPROC(atomic64_read_unchecked_cx8)
24586 +
24587 ENTRY(atomic64_set_cx8)
24588 CFI_STARTPROC
24589
24590 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24591 cmpxchg8b (%esi)
24592 jne 1b
24593
24594 + pax_force_retaddr
24595 ret
24596 CFI_ENDPROC
24597 ENDPROC(atomic64_set_cx8)
24598
24599 +ENTRY(atomic64_set_unchecked_cx8)
24600 + CFI_STARTPROC
24601 +
24602 +1:
24603 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24604 + * are atomic on 586 and newer */
24605 + cmpxchg8b (%esi)
24606 + jne 1b
24607 +
24608 + pax_force_retaddr
24609 + ret
24610 + CFI_ENDPROC
24611 +ENDPROC(atomic64_set_unchecked_cx8)
24612 +
24613 ENTRY(atomic64_xchg_cx8)
24614 CFI_STARTPROC
24615
24616 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24617 cmpxchg8b (%esi)
24618 jne 1b
24619
24620 + pax_force_retaddr
24621 ret
24622 CFI_ENDPROC
24623 ENDPROC(atomic64_xchg_cx8)
24624
24625 -.macro addsub_return func ins insc
24626 -ENTRY(atomic64_\func\()_return_cx8)
24627 +.macro addsub_return func ins insc unchecked=""
24628 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24629 CFI_STARTPROC
24630 SAVE ebp
24631 SAVE ebx
24632 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24633 movl %edx, %ecx
24634 \ins\()l %esi, %ebx
24635 \insc\()l %edi, %ecx
24636 +
24637 +.ifb \unchecked
24638 +#ifdef CONFIG_PAX_REFCOUNT
24639 + into
24640 +2:
24641 + _ASM_EXTABLE(2b, 3f)
24642 +#endif
24643 +.endif
24644 +
24645 LOCK_PREFIX
24646 cmpxchg8b (%ebp)
24647 jne 1b
24648 -
24649 -10:
24650 movl %ebx, %eax
24651 movl %ecx, %edx
24652 +
24653 +.ifb \unchecked
24654 +#ifdef CONFIG_PAX_REFCOUNT
24655 +3:
24656 +#endif
24657 +.endif
24658 +
24659 RESTORE edi
24660 RESTORE esi
24661 RESTORE ebx
24662 RESTORE ebp
24663 + pax_force_retaddr
24664 ret
24665 CFI_ENDPROC
24666 -ENDPROC(atomic64_\func\()_return_cx8)
24667 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24668 .endm
24669
24670 addsub_return add add adc
24671 addsub_return sub sub sbb
24672 +addsub_return add add adc _unchecked
24673 +addsub_return sub sub sbb _unchecked
24674
24675 -.macro incdec_return func ins insc
24676 -ENTRY(atomic64_\func\()_return_cx8)
24677 +.macro incdec_return func ins insc unchecked=""
24678 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24679 CFI_STARTPROC
24680 SAVE ebx
24681
24682 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24683 movl %edx, %ecx
24684 \ins\()l $1, %ebx
24685 \insc\()l $0, %ecx
24686 +
24687 +.ifb \unchecked
24688 +#ifdef CONFIG_PAX_REFCOUNT
24689 + into
24690 +2:
24691 + _ASM_EXTABLE(2b, 3f)
24692 +#endif
24693 +.endif
24694 +
24695 LOCK_PREFIX
24696 cmpxchg8b (%esi)
24697 jne 1b
24698
24699 -10:
24700 movl %ebx, %eax
24701 movl %ecx, %edx
24702 +
24703 +.ifb \unchecked
24704 +#ifdef CONFIG_PAX_REFCOUNT
24705 +3:
24706 +#endif
24707 +.endif
24708 +
24709 RESTORE ebx
24710 + pax_force_retaddr
24711 ret
24712 CFI_ENDPROC
24713 -ENDPROC(atomic64_\func\()_return_cx8)
24714 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24715 .endm
24716
24717 incdec_return inc add adc
24718 incdec_return dec sub sbb
24719 +incdec_return inc add adc _unchecked
24720 +incdec_return dec sub sbb _unchecked
24721
24722 ENTRY(atomic64_dec_if_positive_cx8)
24723 CFI_STARTPROC
24724 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24725 movl %edx, %ecx
24726 subl $1, %ebx
24727 sbb $0, %ecx
24728 +
24729 +#ifdef CONFIG_PAX_REFCOUNT
24730 + into
24731 +1234:
24732 + _ASM_EXTABLE(1234b, 2f)
24733 +#endif
24734 +
24735 js 2f
24736 LOCK_PREFIX
24737 cmpxchg8b (%esi)
24738 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24739 movl %ebx, %eax
24740 movl %ecx, %edx
24741 RESTORE ebx
24742 + pax_force_retaddr
24743 ret
24744 CFI_ENDPROC
24745 ENDPROC(atomic64_dec_if_positive_cx8)
24746 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24747 movl %edx, %ecx
24748 addl %ebp, %ebx
24749 adcl %edi, %ecx
24750 +
24751 +#ifdef CONFIG_PAX_REFCOUNT
24752 + into
24753 +1234:
24754 + _ASM_EXTABLE(1234b, 3f)
24755 +#endif
24756 +
24757 LOCK_PREFIX
24758 cmpxchg8b (%esi)
24759 jne 1b
24760 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24761 CFI_ADJUST_CFA_OFFSET -8
24762 RESTORE ebx
24763 RESTORE ebp
24764 + pax_force_retaddr
24765 ret
24766 4:
24767 cmpl %edx, 4(%esp)
24768 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24769 xorl %ecx, %ecx
24770 addl $1, %ebx
24771 adcl %edx, %ecx
24772 +
24773 +#ifdef CONFIG_PAX_REFCOUNT
24774 + into
24775 +1234:
24776 + _ASM_EXTABLE(1234b, 3f)
24777 +#endif
24778 +
24779 LOCK_PREFIX
24780 cmpxchg8b (%esi)
24781 jne 1b
24782 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24783 movl $1, %eax
24784 3:
24785 RESTORE ebx
24786 + pax_force_retaddr
24787 ret
24788 CFI_ENDPROC
24789 ENDPROC(atomic64_inc_not_zero_cx8)
24790 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24791 index e78b8ee..7e173a8 100644
24792 --- a/arch/x86/lib/checksum_32.S
24793 +++ b/arch/x86/lib/checksum_32.S
24794 @@ -29,7 +29,8 @@
24795 #include <asm/dwarf2.h>
24796 #include <asm/errno.h>
24797 #include <asm/asm.h>
24798 -
24799 +#include <asm/segment.h>
24800 +
24801 /*
24802 * computes a partial checksum, e.g. for TCP/UDP fragments
24803 */
24804 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24805
24806 #define ARGBASE 16
24807 #define FP 12
24808 -
24809 -ENTRY(csum_partial_copy_generic)
24810 +
24811 +ENTRY(csum_partial_copy_generic_to_user)
24812 CFI_STARTPROC
24813 +
24814 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24815 + pushl_cfi %gs
24816 + popl_cfi %es
24817 + jmp csum_partial_copy_generic
24818 +#endif
24819 +
24820 +ENTRY(csum_partial_copy_generic_from_user)
24821 +
24822 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24823 + pushl_cfi %gs
24824 + popl_cfi %ds
24825 +#endif
24826 +
24827 +ENTRY(csum_partial_copy_generic)
24828 subl $4,%esp
24829 CFI_ADJUST_CFA_OFFSET 4
24830 pushl_cfi %edi
24831 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24832 jmp 4f
24833 SRC(1: movw (%esi), %bx )
24834 addl $2, %esi
24835 -DST( movw %bx, (%edi) )
24836 +DST( movw %bx, %es:(%edi) )
24837 addl $2, %edi
24838 addw %bx, %ax
24839 adcl $0, %eax
24840 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24841 SRC(1: movl (%esi), %ebx )
24842 SRC( movl 4(%esi), %edx )
24843 adcl %ebx, %eax
24844 -DST( movl %ebx, (%edi) )
24845 +DST( movl %ebx, %es:(%edi) )
24846 adcl %edx, %eax
24847 -DST( movl %edx, 4(%edi) )
24848 +DST( movl %edx, %es:4(%edi) )
24849
24850 SRC( movl 8(%esi), %ebx )
24851 SRC( movl 12(%esi), %edx )
24852 adcl %ebx, %eax
24853 -DST( movl %ebx, 8(%edi) )
24854 +DST( movl %ebx, %es:8(%edi) )
24855 adcl %edx, %eax
24856 -DST( movl %edx, 12(%edi) )
24857 +DST( movl %edx, %es:12(%edi) )
24858
24859 SRC( movl 16(%esi), %ebx )
24860 SRC( movl 20(%esi), %edx )
24861 adcl %ebx, %eax
24862 -DST( movl %ebx, 16(%edi) )
24863 +DST( movl %ebx, %es:16(%edi) )
24864 adcl %edx, %eax
24865 -DST( movl %edx, 20(%edi) )
24866 +DST( movl %edx, %es:20(%edi) )
24867
24868 SRC( movl 24(%esi), %ebx )
24869 SRC( movl 28(%esi), %edx )
24870 adcl %ebx, %eax
24871 -DST( movl %ebx, 24(%edi) )
24872 +DST( movl %ebx, %es:24(%edi) )
24873 adcl %edx, %eax
24874 -DST( movl %edx, 28(%edi) )
24875 +DST( movl %edx, %es:28(%edi) )
24876
24877 lea 32(%esi), %esi
24878 lea 32(%edi), %edi
24879 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24880 shrl $2, %edx # This clears CF
24881 SRC(3: movl (%esi), %ebx )
24882 adcl %ebx, %eax
24883 -DST( movl %ebx, (%edi) )
24884 +DST( movl %ebx, %es:(%edi) )
24885 lea 4(%esi), %esi
24886 lea 4(%edi), %edi
24887 dec %edx
24888 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24889 jb 5f
24890 SRC( movw (%esi), %cx )
24891 leal 2(%esi), %esi
24892 -DST( movw %cx, (%edi) )
24893 +DST( movw %cx, %es:(%edi) )
24894 leal 2(%edi), %edi
24895 je 6f
24896 shll $16,%ecx
24897 SRC(5: movb (%esi), %cl )
24898 -DST( movb %cl, (%edi) )
24899 +DST( movb %cl, %es:(%edi) )
24900 6: addl %ecx, %eax
24901 adcl $0, %eax
24902 7:
24903 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24904
24905 6001:
24906 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24907 - movl $-EFAULT, (%ebx)
24908 + movl $-EFAULT, %ss:(%ebx)
24909
24910 # zero the complete destination - computing the rest
24911 # is too much work
24912 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24913
24914 6002:
24915 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24916 - movl $-EFAULT,(%ebx)
24917 + movl $-EFAULT,%ss:(%ebx)
24918 jmp 5000b
24919
24920 .previous
24921
24922 + pushl_cfi %ss
24923 + popl_cfi %ds
24924 + pushl_cfi %ss
24925 + popl_cfi %es
24926 popl_cfi %ebx
24927 CFI_RESTORE ebx
24928 popl_cfi %esi
24929 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24930 popl_cfi %ecx # equivalent to addl $4,%esp
24931 ret
24932 CFI_ENDPROC
24933 -ENDPROC(csum_partial_copy_generic)
24934 +ENDPROC(csum_partial_copy_generic_to_user)
24935
24936 #else
24937
24938 /* Version for PentiumII/PPro */
24939
24940 #define ROUND1(x) \
24941 + nop; nop; nop; \
24942 SRC(movl x(%esi), %ebx ) ; \
24943 addl %ebx, %eax ; \
24944 - DST(movl %ebx, x(%edi) ) ;
24945 + DST(movl %ebx, %es:x(%edi)) ;
24946
24947 #define ROUND(x) \
24948 + nop; nop; nop; \
24949 SRC(movl x(%esi), %ebx ) ; \
24950 adcl %ebx, %eax ; \
24951 - DST(movl %ebx, x(%edi) ) ;
24952 + DST(movl %ebx, %es:x(%edi)) ;
24953
24954 #define ARGBASE 12
24955 -
24956 -ENTRY(csum_partial_copy_generic)
24957 +
24958 +ENTRY(csum_partial_copy_generic_to_user)
24959 CFI_STARTPROC
24960 +
24961 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24962 + pushl_cfi %gs
24963 + popl_cfi %es
24964 + jmp csum_partial_copy_generic
24965 +#endif
24966 +
24967 +ENTRY(csum_partial_copy_generic_from_user)
24968 +
24969 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24970 + pushl_cfi %gs
24971 + popl_cfi %ds
24972 +#endif
24973 +
24974 +ENTRY(csum_partial_copy_generic)
24975 pushl_cfi %ebx
24976 CFI_REL_OFFSET ebx, 0
24977 pushl_cfi %edi
24978 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24979 subl %ebx, %edi
24980 lea -1(%esi),%edx
24981 andl $-32,%edx
24982 - lea 3f(%ebx,%ebx), %ebx
24983 + lea 3f(%ebx,%ebx,2), %ebx
24984 testl %esi, %esi
24985 jmp *%ebx
24986 1: addl $64,%esi
24987 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24988 jb 5f
24989 SRC( movw (%esi), %dx )
24990 leal 2(%esi), %esi
24991 -DST( movw %dx, (%edi) )
24992 +DST( movw %dx, %es:(%edi) )
24993 leal 2(%edi), %edi
24994 je 6f
24995 shll $16,%edx
24996 5:
24997 SRC( movb (%esi), %dl )
24998 -DST( movb %dl, (%edi) )
24999 +DST( movb %dl, %es:(%edi) )
25000 6: addl %edx, %eax
25001 adcl $0, %eax
25002 7:
25003 .section .fixup, "ax"
25004 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25005 - movl $-EFAULT, (%ebx)
25006 + movl $-EFAULT, %ss:(%ebx)
25007 # zero the complete destination (computing the rest is too much work)
25008 movl ARGBASE+8(%esp),%edi # dst
25009 movl ARGBASE+12(%esp),%ecx # len
25010 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25011 rep; stosb
25012 jmp 7b
25013 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25014 - movl $-EFAULT, (%ebx)
25015 + movl $-EFAULT, %ss:(%ebx)
25016 jmp 7b
25017 .previous
25018
25019 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25020 + pushl_cfi %ss
25021 + popl_cfi %ds
25022 + pushl_cfi %ss
25023 + popl_cfi %es
25024 +#endif
25025 +
25026 popl_cfi %esi
25027 CFI_RESTORE esi
25028 popl_cfi %edi
25029 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25030 CFI_RESTORE ebx
25031 ret
25032 CFI_ENDPROC
25033 -ENDPROC(csum_partial_copy_generic)
25034 +ENDPROC(csum_partial_copy_generic_to_user)
25035
25036 #undef ROUND
25037 #undef ROUND1
25038 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25039 index f2145cf..cea889d 100644
25040 --- a/arch/x86/lib/clear_page_64.S
25041 +++ b/arch/x86/lib/clear_page_64.S
25042 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25043 movl $4096/8,%ecx
25044 xorl %eax,%eax
25045 rep stosq
25046 + pax_force_retaddr
25047 ret
25048 CFI_ENDPROC
25049 ENDPROC(clear_page_c)
25050 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25051 movl $4096,%ecx
25052 xorl %eax,%eax
25053 rep stosb
25054 + pax_force_retaddr
25055 ret
25056 CFI_ENDPROC
25057 ENDPROC(clear_page_c_e)
25058 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25059 leaq 64(%rdi),%rdi
25060 jnz .Lloop
25061 nop
25062 + pax_force_retaddr
25063 ret
25064 CFI_ENDPROC
25065 .Lclear_page_end:
25066 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25067
25068 #include <asm/cpufeature.h>
25069
25070 - .section .altinstr_replacement,"ax"
25071 + .section .altinstr_replacement,"a"
25072 1: .byte 0xeb /* jmp <disp8> */
25073 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25074 2: .byte 0xeb /* jmp <disp8> */
25075 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25076 index 1e572c5..2a162cd 100644
25077 --- a/arch/x86/lib/cmpxchg16b_emu.S
25078 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25079 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25080
25081 popf
25082 mov $1, %al
25083 + pax_force_retaddr
25084 ret
25085
25086 not_same:
25087 popf
25088 xor %al,%al
25089 + pax_force_retaddr
25090 ret
25091
25092 CFI_ENDPROC
25093 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25094 index 176cca6..1166c50 100644
25095 --- a/arch/x86/lib/copy_page_64.S
25096 +++ b/arch/x86/lib/copy_page_64.S
25097 @@ -9,6 +9,7 @@ copy_page_rep:
25098 CFI_STARTPROC
25099 movl $4096/8, %ecx
25100 rep movsq
25101 + pax_force_retaddr
25102 ret
25103 CFI_ENDPROC
25104 ENDPROC(copy_page_rep)
25105 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25106
25107 ENTRY(copy_page)
25108 CFI_STARTPROC
25109 - subq $2*8, %rsp
25110 - CFI_ADJUST_CFA_OFFSET 2*8
25111 + subq $3*8, %rsp
25112 + CFI_ADJUST_CFA_OFFSET 3*8
25113 movq %rbx, (%rsp)
25114 CFI_REL_OFFSET rbx, 0
25115 movq %r12, 1*8(%rsp)
25116 CFI_REL_OFFSET r12, 1*8
25117 + movq %r13, 2*8(%rsp)
25118 + CFI_REL_OFFSET r13, 2*8
25119
25120 movl $(4096/64)-5, %ecx
25121 .p2align 4
25122 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25123 movq 0x8*2(%rsi), %rdx
25124 movq 0x8*3(%rsi), %r8
25125 movq 0x8*4(%rsi), %r9
25126 - movq 0x8*5(%rsi), %r10
25127 + movq 0x8*5(%rsi), %r13
25128 movq 0x8*6(%rsi), %r11
25129 movq 0x8*7(%rsi), %r12
25130
25131 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25132 movq %rdx, 0x8*2(%rdi)
25133 movq %r8, 0x8*3(%rdi)
25134 movq %r9, 0x8*4(%rdi)
25135 - movq %r10, 0x8*5(%rdi)
25136 + movq %r13, 0x8*5(%rdi)
25137 movq %r11, 0x8*6(%rdi)
25138 movq %r12, 0x8*7(%rdi)
25139
25140 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25141 movq 0x8*2(%rsi), %rdx
25142 movq 0x8*3(%rsi), %r8
25143 movq 0x8*4(%rsi), %r9
25144 - movq 0x8*5(%rsi), %r10
25145 + movq 0x8*5(%rsi), %r13
25146 movq 0x8*6(%rsi), %r11
25147 movq 0x8*7(%rsi), %r12
25148
25149 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25150 movq %rdx, 0x8*2(%rdi)
25151 movq %r8, 0x8*3(%rdi)
25152 movq %r9, 0x8*4(%rdi)
25153 - movq %r10, 0x8*5(%rdi)
25154 + movq %r13, 0x8*5(%rdi)
25155 movq %r11, 0x8*6(%rdi)
25156 movq %r12, 0x8*7(%rdi)
25157
25158 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25159 CFI_RESTORE rbx
25160 movq 1*8(%rsp), %r12
25161 CFI_RESTORE r12
25162 - addq $2*8, %rsp
25163 - CFI_ADJUST_CFA_OFFSET -2*8
25164 + movq 2*8(%rsp), %r13
25165 + CFI_RESTORE r13
25166 + addq $3*8, %rsp
25167 + CFI_ADJUST_CFA_OFFSET -3*8
25168 + pax_force_retaddr
25169 ret
25170 .Lcopy_page_end:
25171 CFI_ENDPROC
25172 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25173
25174 #include <asm/cpufeature.h>
25175
25176 - .section .altinstr_replacement,"ax"
25177 + .section .altinstr_replacement,"a"
25178 1: .byte 0xeb /* jmp <disp8> */
25179 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25180 2:
25181 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25182 index a30ca15..d25fab6 100644
25183 --- a/arch/x86/lib/copy_user_64.S
25184 +++ b/arch/x86/lib/copy_user_64.S
25185 @@ -18,6 +18,7 @@
25186 #include <asm/alternative-asm.h>
25187 #include <asm/asm.h>
25188 #include <asm/smap.h>
25189 +#include <asm/pgtable.h>
25190
25191 /*
25192 * By placing feature2 after feature1 in altinstructions section, we logically
25193 @@ -31,7 +32,7 @@
25194 .byte 0xe9 /* 32bit jump */
25195 .long \orig-1f /* by default jump to orig */
25196 1:
25197 - .section .altinstr_replacement,"ax"
25198 + .section .altinstr_replacement,"a"
25199 2: .byte 0xe9 /* near jump with 32bit immediate */
25200 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25201 3: .byte 0xe9 /* near jump with 32bit immediate */
25202 @@ -70,47 +71,20 @@
25203 #endif
25204 .endm
25205
25206 -/* Standard copy_to_user with segment limit checking */
25207 -ENTRY(_copy_to_user)
25208 - CFI_STARTPROC
25209 - GET_THREAD_INFO(%rax)
25210 - movq %rdi,%rcx
25211 - addq %rdx,%rcx
25212 - jc bad_to_user
25213 - cmpq TI_addr_limit(%rax),%rcx
25214 - ja bad_to_user
25215 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25216 - copy_user_generic_unrolled,copy_user_generic_string, \
25217 - copy_user_enhanced_fast_string
25218 - CFI_ENDPROC
25219 -ENDPROC(_copy_to_user)
25220 -
25221 -/* Standard copy_from_user with segment limit checking */
25222 -ENTRY(_copy_from_user)
25223 - CFI_STARTPROC
25224 - GET_THREAD_INFO(%rax)
25225 - movq %rsi,%rcx
25226 - addq %rdx,%rcx
25227 - jc bad_from_user
25228 - cmpq TI_addr_limit(%rax),%rcx
25229 - ja bad_from_user
25230 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25231 - copy_user_generic_unrolled,copy_user_generic_string, \
25232 - copy_user_enhanced_fast_string
25233 - CFI_ENDPROC
25234 -ENDPROC(_copy_from_user)
25235 -
25236 .section .fixup,"ax"
25237 /* must zero dest */
25238 ENTRY(bad_from_user)
25239 bad_from_user:
25240 CFI_STARTPROC
25241 + testl %edx,%edx
25242 + js bad_to_user
25243 movl %edx,%ecx
25244 xorl %eax,%eax
25245 rep
25246 stosb
25247 bad_to_user:
25248 movl %edx,%eax
25249 + pax_force_retaddr
25250 ret
25251 CFI_ENDPROC
25252 ENDPROC(bad_from_user)
25253 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25254 jz 17f
25255 1: movq (%rsi),%r8
25256 2: movq 1*8(%rsi),%r9
25257 -3: movq 2*8(%rsi),%r10
25258 +3: movq 2*8(%rsi),%rax
25259 4: movq 3*8(%rsi),%r11
25260 5: movq %r8,(%rdi)
25261 6: movq %r9,1*8(%rdi)
25262 -7: movq %r10,2*8(%rdi)
25263 +7: movq %rax,2*8(%rdi)
25264 8: movq %r11,3*8(%rdi)
25265 9: movq 4*8(%rsi),%r8
25266 10: movq 5*8(%rsi),%r9
25267 -11: movq 6*8(%rsi),%r10
25268 +11: movq 6*8(%rsi),%rax
25269 12: movq 7*8(%rsi),%r11
25270 13: movq %r8,4*8(%rdi)
25271 14: movq %r9,5*8(%rdi)
25272 -15: movq %r10,6*8(%rdi)
25273 +15: movq %rax,6*8(%rdi)
25274 16: movq %r11,7*8(%rdi)
25275 leaq 64(%rsi),%rsi
25276 leaq 64(%rdi),%rdi
25277 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25278 jnz 21b
25279 23: xor %eax,%eax
25280 ASM_CLAC
25281 + pax_force_retaddr
25282 ret
25283
25284 .section .fixup,"ax"
25285 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25286 movsb
25287 4: xorl %eax,%eax
25288 ASM_CLAC
25289 + pax_force_retaddr
25290 ret
25291
25292 .section .fixup,"ax"
25293 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25294 movsb
25295 2: xorl %eax,%eax
25296 ASM_CLAC
25297 + pax_force_retaddr
25298 ret
25299
25300 .section .fixup,"ax"
25301 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25302 index 6a4f43c..f08b4a2 100644
25303 --- a/arch/x86/lib/copy_user_nocache_64.S
25304 +++ b/arch/x86/lib/copy_user_nocache_64.S
25305 @@ -8,6 +8,7 @@
25306
25307 #include <linux/linkage.h>
25308 #include <asm/dwarf2.h>
25309 +#include <asm/alternative-asm.h>
25310
25311 #define FIX_ALIGNMENT 1
25312
25313 @@ -16,6 +17,7 @@
25314 #include <asm/thread_info.h>
25315 #include <asm/asm.h>
25316 #include <asm/smap.h>
25317 +#include <asm/pgtable.h>
25318
25319 .macro ALIGN_DESTINATION
25320 #ifdef FIX_ALIGNMENT
25321 @@ -49,6 +51,15 @@
25322 */
25323 ENTRY(__copy_user_nocache)
25324 CFI_STARTPROC
25325 +
25326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25327 + mov pax_user_shadow_base,%rcx
25328 + cmp %rcx,%rsi
25329 + jae 1f
25330 + add %rcx,%rsi
25331 +1:
25332 +#endif
25333 +
25334 ASM_STAC
25335 cmpl $8,%edx
25336 jb 20f /* less then 8 bytes, go to byte copy loop */
25337 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25338 jz 17f
25339 1: movq (%rsi),%r8
25340 2: movq 1*8(%rsi),%r9
25341 -3: movq 2*8(%rsi),%r10
25342 +3: movq 2*8(%rsi),%rax
25343 4: movq 3*8(%rsi),%r11
25344 5: movnti %r8,(%rdi)
25345 6: movnti %r9,1*8(%rdi)
25346 -7: movnti %r10,2*8(%rdi)
25347 +7: movnti %rax,2*8(%rdi)
25348 8: movnti %r11,3*8(%rdi)
25349 9: movq 4*8(%rsi),%r8
25350 10: movq 5*8(%rsi),%r9
25351 -11: movq 6*8(%rsi),%r10
25352 +11: movq 6*8(%rsi),%rax
25353 12: movq 7*8(%rsi),%r11
25354 13: movnti %r8,4*8(%rdi)
25355 14: movnti %r9,5*8(%rdi)
25356 -15: movnti %r10,6*8(%rdi)
25357 +15: movnti %rax,6*8(%rdi)
25358 16: movnti %r11,7*8(%rdi)
25359 leaq 64(%rsi),%rsi
25360 leaq 64(%rdi),%rdi
25361 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25362 23: xorl %eax,%eax
25363 ASM_CLAC
25364 sfence
25365 + pax_force_retaddr
25366 ret
25367
25368 .section .fixup,"ax"
25369 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25370 index 2419d5f..953ee51 100644
25371 --- a/arch/x86/lib/csum-copy_64.S
25372 +++ b/arch/x86/lib/csum-copy_64.S
25373 @@ -9,6 +9,7 @@
25374 #include <asm/dwarf2.h>
25375 #include <asm/errno.h>
25376 #include <asm/asm.h>
25377 +#include <asm/alternative-asm.h>
25378
25379 /*
25380 * Checksum copy with exception handling.
25381 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25382 CFI_RESTORE rbp
25383 addq $7*8, %rsp
25384 CFI_ADJUST_CFA_OFFSET -7*8
25385 + pax_force_retaddr 0, 1
25386 ret
25387 CFI_RESTORE_STATE
25388
25389 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25390 index 25b7ae8..169fafc 100644
25391 --- a/arch/x86/lib/csum-wrappers_64.c
25392 +++ b/arch/x86/lib/csum-wrappers_64.c
25393 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25394 len -= 2;
25395 }
25396 }
25397 - isum = csum_partial_copy_generic((__force const void *)src,
25398 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25399 dst, len, isum, errp, NULL);
25400 if (unlikely(*errp))
25401 goto out_err;
25402 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25403 }
25404
25405 *errp = 0;
25406 - return csum_partial_copy_generic(src, (void __force *)dst,
25407 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25408 len, isum, NULL, errp);
25409 }
25410 EXPORT_SYMBOL(csum_partial_copy_to_user);
25411 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25412 index a451235..79fb5cf 100644
25413 --- a/arch/x86/lib/getuser.S
25414 +++ b/arch/x86/lib/getuser.S
25415 @@ -33,17 +33,40 @@
25416 #include <asm/thread_info.h>
25417 #include <asm/asm.h>
25418 #include <asm/smap.h>
25419 +#include <asm/segment.h>
25420 +#include <asm/pgtable.h>
25421 +#include <asm/alternative-asm.h>
25422 +
25423 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25424 +#define __copyuser_seg gs;
25425 +#else
25426 +#define __copyuser_seg
25427 +#endif
25428
25429 .text
25430 ENTRY(__get_user_1)
25431 CFI_STARTPROC
25432 +
25433 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25434 GET_THREAD_INFO(%_ASM_DX)
25435 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25436 jae bad_get_user
25437 ASM_STAC
25438 -1: movzbl (%_ASM_AX),%edx
25439 +
25440 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25441 + mov pax_user_shadow_base,%_ASM_DX
25442 + cmp %_ASM_DX,%_ASM_AX
25443 + jae 1234f
25444 + add %_ASM_DX,%_ASM_AX
25445 +1234:
25446 +#endif
25447 +
25448 +#endif
25449 +
25450 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25451 xor %eax,%eax
25452 ASM_CLAC
25453 + pax_force_retaddr
25454 ret
25455 CFI_ENDPROC
25456 ENDPROC(__get_user_1)
25457 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25458 ENTRY(__get_user_2)
25459 CFI_STARTPROC
25460 add $1,%_ASM_AX
25461 +
25462 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25463 jc bad_get_user
25464 GET_THREAD_INFO(%_ASM_DX)
25465 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25466 jae bad_get_user
25467 ASM_STAC
25468 -2: movzwl -1(%_ASM_AX),%edx
25469 +
25470 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25471 + mov pax_user_shadow_base,%_ASM_DX
25472 + cmp %_ASM_DX,%_ASM_AX
25473 + jae 1234f
25474 + add %_ASM_DX,%_ASM_AX
25475 +1234:
25476 +#endif
25477 +
25478 +#endif
25479 +
25480 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25481 xor %eax,%eax
25482 ASM_CLAC
25483 + pax_force_retaddr
25484 ret
25485 CFI_ENDPROC
25486 ENDPROC(__get_user_2)
25487 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25488 ENTRY(__get_user_4)
25489 CFI_STARTPROC
25490 add $3,%_ASM_AX
25491 +
25492 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25493 jc bad_get_user
25494 GET_THREAD_INFO(%_ASM_DX)
25495 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25496 jae bad_get_user
25497 ASM_STAC
25498 -3: movl -3(%_ASM_AX),%edx
25499 +
25500 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25501 + mov pax_user_shadow_base,%_ASM_DX
25502 + cmp %_ASM_DX,%_ASM_AX
25503 + jae 1234f
25504 + add %_ASM_DX,%_ASM_AX
25505 +1234:
25506 +#endif
25507 +
25508 +#endif
25509 +
25510 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25511 xor %eax,%eax
25512 ASM_CLAC
25513 + pax_force_retaddr
25514 ret
25515 CFI_ENDPROC
25516 ENDPROC(__get_user_4)
25517 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25518 GET_THREAD_INFO(%_ASM_DX)
25519 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25520 jae bad_get_user
25521 +
25522 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25523 + mov pax_user_shadow_base,%_ASM_DX
25524 + cmp %_ASM_DX,%_ASM_AX
25525 + jae 1234f
25526 + add %_ASM_DX,%_ASM_AX
25527 +1234:
25528 +#endif
25529 +
25530 ASM_STAC
25531 4: movq -7(%_ASM_AX),%rdx
25532 xor %eax,%eax
25533 ASM_CLAC
25534 + pax_force_retaddr
25535 ret
25536 #else
25537 add $7,%_ASM_AX
25538 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25539 5: movl -3(%_ASM_AX),%ecx
25540 xor %eax,%eax
25541 ASM_CLAC
25542 + pax_force_retaddr
25543 ret
25544 #endif
25545 CFI_ENDPROC
25546 @@ -113,6 +175,7 @@ bad_get_user:
25547 xor %edx,%edx
25548 mov $(-EFAULT),%_ASM_AX
25549 ASM_CLAC
25550 + pax_force_retaddr
25551 ret
25552 CFI_ENDPROC
25553 END(bad_get_user)
25554 @@ -124,6 +187,7 @@ bad_get_user_8:
25555 xor %ecx,%ecx
25556 mov $(-EFAULT),%_ASM_AX
25557 ASM_CLAC
25558 + pax_force_retaddr
25559 ret
25560 CFI_ENDPROC
25561 END(bad_get_user_8)
25562 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25563 index 54fcffe..7be149e 100644
25564 --- a/arch/x86/lib/insn.c
25565 +++ b/arch/x86/lib/insn.c
25566 @@ -20,8 +20,10 @@
25567
25568 #ifdef __KERNEL__
25569 #include <linux/string.h>
25570 +#include <asm/pgtable_types.h>
25571 #else
25572 #include <string.h>
25573 +#define ktla_ktva(addr) addr
25574 #endif
25575 #include <asm/inat.h>
25576 #include <asm/insn.h>
25577 @@ -53,8 +55,8 @@
25578 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25579 {
25580 memset(insn, 0, sizeof(*insn));
25581 - insn->kaddr = kaddr;
25582 - insn->next_byte = kaddr;
25583 + insn->kaddr = ktla_ktva(kaddr);
25584 + insn->next_byte = ktla_ktva(kaddr);
25585 insn->x86_64 = x86_64 ? 1 : 0;
25586 insn->opnd_bytes = 4;
25587 if (x86_64)
25588 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25589 index 05a95e7..326f2fa 100644
25590 --- a/arch/x86/lib/iomap_copy_64.S
25591 +++ b/arch/x86/lib/iomap_copy_64.S
25592 @@ -17,6 +17,7 @@
25593
25594 #include <linux/linkage.h>
25595 #include <asm/dwarf2.h>
25596 +#include <asm/alternative-asm.h>
25597
25598 /*
25599 * override generic version in lib/iomap_copy.c
25600 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25601 CFI_STARTPROC
25602 movl %edx,%ecx
25603 rep movsd
25604 + pax_force_retaddr
25605 ret
25606 CFI_ENDPROC
25607 ENDPROC(__iowrite32_copy)
25608 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25609 index 56313a3..aa84a79 100644
25610 --- a/arch/x86/lib/memcpy_64.S
25611 +++ b/arch/x86/lib/memcpy_64.S
25612 @@ -33,6 +33,7 @@
25613 rep movsq
25614 movl %edx, %ecx
25615 rep movsb
25616 + pax_force_retaddr
25617 ret
25618 .Lmemcpy_e:
25619 .previous
25620 @@ -49,6 +50,7 @@
25621 movq %rdi, %rax
25622 movq %rdx, %rcx
25623 rep movsb
25624 + pax_force_retaddr
25625 ret
25626 .Lmemcpy_e_e:
25627 .previous
25628 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25629 */
25630 movq 0*8(%rsi), %r8
25631 movq 1*8(%rsi), %r9
25632 - movq 2*8(%rsi), %r10
25633 + movq 2*8(%rsi), %rcx
25634 movq 3*8(%rsi), %r11
25635 leaq 4*8(%rsi), %rsi
25636
25637 movq %r8, 0*8(%rdi)
25638 movq %r9, 1*8(%rdi)
25639 - movq %r10, 2*8(%rdi)
25640 + movq %rcx, 2*8(%rdi)
25641 movq %r11, 3*8(%rdi)
25642 leaq 4*8(%rdi), %rdi
25643 jae .Lcopy_forward_loop
25644 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25645 subq $0x20, %rdx
25646 movq -1*8(%rsi), %r8
25647 movq -2*8(%rsi), %r9
25648 - movq -3*8(%rsi), %r10
25649 + movq -3*8(%rsi), %rcx
25650 movq -4*8(%rsi), %r11
25651 leaq -4*8(%rsi), %rsi
25652 movq %r8, -1*8(%rdi)
25653 movq %r9, -2*8(%rdi)
25654 - movq %r10, -3*8(%rdi)
25655 + movq %rcx, -3*8(%rdi)
25656 movq %r11, -4*8(%rdi)
25657 leaq -4*8(%rdi), %rdi
25658 jae .Lcopy_backward_loop
25659 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25660 */
25661 movq 0*8(%rsi), %r8
25662 movq 1*8(%rsi), %r9
25663 - movq -2*8(%rsi, %rdx), %r10
25664 + movq -2*8(%rsi, %rdx), %rcx
25665 movq -1*8(%rsi, %rdx), %r11
25666 movq %r8, 0*8(%rdi)
25667 movq %r9, 1*8(%rdi)
25668 - movq %r10, -2*8(%rdi, %rdx)
25669 + movq %rcx, -2*8(%rdi, %rdx)
25670 movq %r11, -1*8(%rdi, %rdx)
25671 + pax_force_retaddr
25672 retq
25673 .p2align 4
25674 .Lless_16bytes:
25675 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25676 movq -1*8(%rsi, %rdx), %r9
25677 movq %r8, 0*8(%rdi)
25678 movq %r9, -1*8(%rdi, %rdx)
25679 + pax_force_retaddr
25680 retq
25681 .p2align 4
25682 .Lless_8bytes:
25683 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25684 movl -4(%rsi, %rdx), %r8d
25685 movl %ecx, (%rdi)
25686 movl %r8d, -4(%rdi, %rdx)
25687 + pax_force_retaddr
25688 retq
25689 .p2align 4
25690 .Lless_3bytes:
25691 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25692 movb %cl, (%rdi)
25693
25694 .Lend:
25695 + pax_force_retaddr
25696 retq
25697 CFI_ENDPROC
25698 ENDPROC(memcpy)
25699 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25700 index 65268a6..c9518d1 100644
25701 --- a/arch/x86/lib/memmove_64.S
25702 +++ b/arch/x86/lib/memmove_64.S
25703 @@ -61,13 +61,13 @@ ENTRY(memmove)
25704 5:
25705 sub $0x20, %rdx
25706 movq 0*8(%rsi), %r11
25707 - movq 1*8(%rsi), %r10
25708 + movq 1*8(%rsi), %rcx
25709 movq 2*8(%rsi), %r9
25710 movq 3*8(%rsi), %r8
25711 leaq 4*8(%rsi), %rsi
25712
25713 movq %r11, 0*8(%rdi)
25714 - movq %r10, 1*8(%rdi)
25715 + movq %rcx, 1*8(%rdi)
25716 movq %r9, 2*8(%rdi)
25717 movq %r8, 3*8(%rdi)
25718 leaq 4*8(%rdi), %rdi
25719 @@ -81,10 +81,10 @@ ENTRY(memmove)
25720 4:
25721 movq %rdx, %rcx
25722 movq -8(%rsi, %rdx), %r11
25723 - lea -8(%rdi, %rdx), %r10
25724 + lea -8(%rdi, %rdx), %r9
25725 shrq $3, %rcx
25726 rep movsq
25727 - movq %r11, (%r10)
25728 + movq %r11, (%r9)
25729 jmp 13f
25730 .Lmemmove_end_forward:
25731
25732 @@ -95,14 +95,14 @@ ENTRY(memmove)
25733 7:
25734 movq %rdx, %rcx
25735 movq (%rsi), %r11
25736 - movq %rdi, %r10
25737 + movq %rdi, %r9
25738 leaq -8(%rsi, %rdx), %rsi
25739 leaq -8(%rdi, %rdx), %rdi
25740 shrq $3, %rcx
25741 std
25742 rep movsq
25743 cld
25744 - movq %r11, (%r10)
25745 + movq %r11, (%r9)
25746 jmp 13f
25747
25748 /*
25749 @@ -127,13 +127,13 @@ ENTRY(memmove)
25750 8:
25751 subq $0x20, %rdx
25752 movq -1*8(%rsi), %r11
25753 - movq -2*8(%rsi), %r10
25754 + movq -2*8(%rsi), %rcx
25755 movq -3*8(%rsi), %r9
25756 movq -4*8(%rsi), %r8
25757 leaq -4*8(%rsi), %rsi
25758
25759 movq %r11, -1*8(%rdi)
25760 - movq %r10, -2*8(%rdi)
25761 + movq %rcx, -2*8(%rdi)
25762 movq %r9, -3*8(%rdi)
25763 movq %r8, -4*8(%rdi)
25764 leaq -4*8(%rdi), %rdi
25765 @@ -151,11 +151,11 @@ ENTRY(memmove)
25766 * Move data from 16 bytes to 31 bytes.
25767 */
25768 movq 0*8(%rsi), %r11
25769 - movq 1*8(%rsi), %r10
25770 + movq 1*8(%rsi), %rcx
25771 movq -2*8(%rsi, %rdx), %r9
25772 movq -1*8(%rsi, %rdx), %r8
25773 movq %r11, 0*8(%rdi)
25774 - movq %r10, 1*8(%rdi)
25775 + movq %rcx, 1*8(%rdi)
25776 movq %r9, -2*8(%rdi, %rdx)
25777 movq %r8, -1*8(%rdi, %rdx)
25778 jmp 13f
25779 @@ -167,9 +167,9 @@ ENTRY(memmove)
25780 * Move data from 8 bytes to 15 bytes.
25781 */
25782 movq 0*8(%rsi), %r11
25783 - movq -1*8(%rsi, %rdx), %r10
25784 + movq -1*8(%rsi, %rdx), %r9
25785 movq %r11, 0*8(%rdi)
25786 - movq %r10, -1*8(%rdi, %rdx)
25787 + movq %r9, -1*8(%rdi, %rdx)
25788 jmp 13f
25789 10:
25790 cmpq $4, %rdx
25791 @@ -178,9 +178,9 @@ ENTRY(memmove)
25792 * Move data from 4 bytes to 7 bytes.
25793 */
25794 movl (%rsi), %r11d
25795 - movl -4(%rsi, %rdx), %r10d
25796 + movl -4(%rsi, %rdx), %r9d
25797 movl %r11d, (%rdi)
25798 - movl %r10d, -4(%rdi, %rdx)
25799 + movl %r9d, -4(%rdi, %rdx)
25800 jmp 13f
25801 11:
25802 cmp $2, %rdx
25803 @@ -189,9 +189,9 @@ ENTRY(memmove)
25804 * Move data from 2 bytes to 3 bytes.
25805 */
25806 movw (%rsi), %r11w
25807 - movw -2(%rsi, %rdx), %r10w
25808 + movw -2(%rsi, %rdx), %r9w
25809 movw %r11w, (%rdi)
25810 - movw %r10w, -2(%rdi, %rdx)
25811 + movw %r9w, -2(%rdi, %rdx)
25812 jmp 13f
25813 12:
25814 cmp $1, %rdx
25815 @@ -202,6 +202,7 @@ ENTRY(memmove)
25816 movb (%rsi), %r11b
25817 movb %r11b, (%rdi)
25818 13:
25819 + pax_force_retaddr
25820 retq
25821 CFI_ENDPROC
25822
25823 @@ -210,6 +211,7 @@ ENTRY(memmove)
25824 /* Forward moving data. */
25825 movq %rdx, %rcx
25826 rep movsb
25827 + pax_force_retaddr
25828 retq
25829 .Lmemmove_end_forward_efs:
25830 .previous
25831 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25832 index 2dcb380..963660a 100644
25833 --- a/arch/x86/lib/memset_64.S
25834 +++ b/arch/x86/lib/memset_64.S
25835 @@ -30,6 +30,7 @@
25836 movl %edx,%ecx
25837 rep stosb
25838 movq %r9,%rax
25839 + pax_force_retaddr
25840 ret
25841 .Lmemset_e:
25842 .previous
25843 @@ -52,6 +53,7 @@
25844 movq %rdx,%rcx
25845 rep stosb
25846 movq %r9,%rax
25847 + pax_force_retaddr
25848 ret
25849 .Lmemset_e_e:
25850 .previous
25851 @@ -59,7 +61,7 @@
25852 ENTRY(memset)
25853 ENTRY(__memset)
25854 CFI_STARTPROC
25855 - movq %rdi,%r10
25856 + movq %rdi,%r11
25857
25858 /* expand byte value */
25859 movzbl %sil,%ecx
25860 @@ -117,7 +119,8 @@ ENTRY(__memset)
25861 jnz .Lloop_1
25862
25863 .Lende:
25864 - movq %r10,%rax
25865 + movq %r11,%rax
25866 + pax_force_retaddr
25867 ret
25868
25869 CFI_RESTORE_STATE
25870 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25871 index c9f2d9b..e7fd2c0 100644
25872 --- a/arch/x86/lib/mmx_32.c
25873 +++ b/arch/x86/lib/mmx_32.c
25874 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25875 {
25876 void *p;
25877 int i;
25878 + unsigned long cr0;
25879
25880 if (unlikely(in_interrupt()))
25881 return __memcpy(to, from, len);
25882 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25883 kernel_fpu_begin();
25884
25885 __asm__ __volatile__ (
25886 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25887 - " prefetch 64(%0)\n"
25888 - " prefetch 128(%0)\n"
25889 - " prefetch 192(%0)\n"
25890 - " prefetch 256(%0)\n"
25891 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25892 + " prefetch 64(%1)\n"
25893 + " prefetch 128(%1)\n"
25894 + " prefetch 192(%1)\n"
25895 + " prefetch 256(%1)\n"
25896 "2: \n"
25897 ".section .fixup, \"ax\"\n"
25898 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25899 + "3: \n"
25900 +
25901 +#ifdef CONFIG_PAX_KERNEXEC
25902 + " movl %%cr0, %0\n"
25903 + " movl %0, %%eax\n"
25904 + " andl $0xFFFEFFFF, %%eax\n"
25905 + " movl %%eax, %%cr0\n"
25906 +#endif
25907 +
25908 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25909 +
25910 +#ifdef CONFIG_PAX_KERNEXEC
25911 + " movl %0, %%cr0\n"
25912 +#endif
25913 +
25914 " jmp 2b\n"
25915 ".previous\n"
25916 _ASM_EXTABLE(1b, 3b)
25917 - : : "r" (from));
25918 + : "=&r" (cr0) : "r" (from) : "ax");
25919
25920 for ( ; i > 5; i--) {
25921 __asm__ __volatile__ (
25922 - "1: prefetch 320(%0)\n"
25923 - "2: movq (%0), %%mm0\n"
25924 - " movq 8(%0), %%mm1\n"
25925 - " movq 16(%0), %%mm2\n"
25926 - " movq 24(%0), %%mm3\n"
25927 - " movq %%mm0, (%1)\n"
25928 - " movq %%mm1, 8(%1)\n"
25929 - " movq %%mm2, 16(%1)\n"
25930 - " movq %%mm3, 24(%1)\n"
25931 - " movq 32(%0), %%mm0\n"
25932 - " movq 40(%0), %%mm1\n"
25933 - " movq 48(%0), %%mm2\n"
25934 - " movq 56(%0), %%mm3\n"
25935 - " movq %%mm0, 32(%1)\n"
25936 - " movq %%mm1, 40(%1)\n"
25937 - " movq %%mm2, 48(%1)\n"
25938 - " movq %%mm3, 56(%1)\n"
25939 + "1: prefetch 320(%1)\n"
25940 + "2: movq (%1), %%mm0\n"
25941 + " movq 8(%1), %%mm1\n"
25942 + " movq 16(%1), %%mm2\n"
25943 + " movq 24(%1), %%mm3\n"
25944 + " movq %%mm0, (%2)\n"
25945 + " movq %%mm1, 8(%2)\n"
25946 + " movq %%mm2, 16(%2)\n"
25947 + " movq %%mm3, 24(%2)\n"
25948 + " movq 32(%1), %%mm0\n"
25949 + " movq 40(%1), %%mm1\n"
25950 + " movq 48(%1), %%mm2\n"
25951 + " movq 56(%1), %%mm3\n"
25952 + " movq %%mm0, 32(%2)\n"
25953 + " movq %%mm1, 40(%2)\n"
25954 + " movq %%mm2, 48(%2)\n"
25955 + " movq %%mm3, 56(%2)\n"
25956 ".section .fixup, \"ax\"\n"
25957 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25958 + "3:\n"
25959 +
25960 +#ifdef CONFIG_PAX_KERNEXEC
25961 + " movl %%cr0, %0\n"
25962 + " movl %0, %%eax\n"
25963 + " andl $0xFFFEFFFF, %%eax\n"
25964 + " movl %%eax, %%cr0\n"
25965 +#endif
25966 +
25967 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25968 +
25969 +#ifdef CONFIG_PAX_KERNEXEC
25970 + " movl %0, %%cr0\n"
25971 +#endif
25972 +
25973 " jmp 2b\n"
25974 ".previous\n"
25975 _ASM_EXTABLE(1b, 3b)
25976 - : : "r" (from), "r" (to) : "memory");
25977 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25978
25979 from += 64;
25980 to += 64;
25981 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25982 static void fast_copy_page(void *to, void *from)
25983 {
25984 int i;
25985 + unsigned long cr0;
25986
25987 kernel_fpu_begin();
25988
25989 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25990 * but that is for later. -AV
25991 */
25992 __asm__ __volatile__(
25993 - "1: prefetch (%0)\n"
25994 - " prefetch 64(%0)\n"
25995 - " prefetch 128(%0)\n"
25996 - " prefetch 192(%0)\n"
25997 - " prefetch 256(%0)\n"
25998 + "1: prefetch (%1)\n"
25999 + " prefetch 64(%1)\n"
26000 + " prefetch 128(%1)\n"
26001 + " prefetch 192(%1)\n"
26002 + " prefetch 256(%1)\n"
26003 "2: \n"
26004 ".section .fixup, \"ax\"\n"
26005 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26006 + "3: \n"
26007 +
26008 +#ifdef CONFIG_PAX_KERNEXEC
26009 + " movl %%cr0, %0\n"
26010 + " movl %0, %%eax\n"
26011 + " andl $0xFFFEFFFF, %%eax\n"
26012 + " movl %%eax, %%cr0\n"
26013 +#endif
26014 +
26015 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26016 +
26017 +#ifdef CONFIG_PAX_KERNEXEC
26018 + " movl %0, %%cr0\n"
26019 +#endif
26020 +
26021 " jmp 2b\n"
26022 ".previous\n"
26023 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26024 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26025
26026 for (i = 0; i < (4096-320)/64; i++) {
26027 __asm__ __volatile__ (
26028 - "1: prefetch 320(%0)\n"
26029 - "2: movq (%0), %%mm0\n"
26030 - " movntq %%mm0, (%1)\n"
26031 - " movq 8(%0), %%mm1\n"
26032 - " movntq %%mm1, 8(%1)\n"
26033 - " movq 16(%0), %%mm2\n"
26034 - " movntq %%mm2, 16(%1)\n"
26035 - " movq 24(%0), %%mm3\n"
26036 - " movntq %%mm3, 24(%1)\n"
26037 - " movq 32(%0), %%mm4\n"
26038 - " movntq %%mm4, 32(%1)\n"
26039 - " movq 40(%0), %%mm5\n"
26040 - " movntq %%mm5, 40(%1)\n"
26041 - " movq 48(%0), %%mm6\n"
26042 - " movntq %%mm6, 48(%1)\n"
26043 - " movq 56(%0), %%mm7\n"
26044 - " movntq %%mm7, 56(%1)\n"
26045 + "1: prefetch 320(%1)\n"
26046 + "2: movq (%1), %%mm0\n"
26047 + " movntq %%mm0, (%2)\n"
26048 + " movq 8(%1), %%mm1\n"
26049 + " movntq %%mm1, 8(%2)\n"
26050 + " movq 16(%1), %%mm2\n"
26051 + " movntq %%mm2, 16(%2)\n"
26052 + " movq 24(%1), %%mm3\n"
26053 + " movntq %%mm3, 24(%2)\n"
26054 + " movq 32(%1), %%mm4\n"
26055 + " movntq %%mm4, 32(%2)\n"
26056 + " movq 40(%1), %%mm5\n"
26057 + " movntq %%mm5, 40(%2)\n"
26058 + " movq 48(%1), %%mm6\n"
26059 + " movntq %%mm6, 48(%2)\n"
26060 + " movq 56(%1), %%mm7\n"
26061 + " movntq %%mm7, 56(%2)\n"
26062 ".section .fixup, \"ax\"\n"
26063 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26064 + "3:\n"
26065 +
26066 +#ifdef CONFIG_PAX_KERNEXEC
26067 + " movl %%cr0, %0\n"
26068 + " movl %0, %%eax\n"
26069 + " andl $0xFFFEFFFF, %%eax\n"
26070 + " movl %%eax, %%cr0\n"
26071 +#endif
26072 +
26073 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26074 +
26075 +#ifdef CONFIG_PAX_KERNEXEC
26076 + " movl %0, %%cr0\n"
26077 +#endif
26078 +
26079 " jmp 2b\n"
26080 ".previous\n"
26081 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26082 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26083
26084 from += 64;
26085 to += 64;
26086 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26087 static void fast_copy_page(void *to, void *from)
26088 {
26089 int i;
26090 + unsigned long cr0;
26091
26092 kernel_fpu_begin();
26093
26094 __asm__ __volatile__ (
26095 - "1: prefetch (%0)\n"
26096 - " prefetch 64(%0)\n"
26097 - " prefetch 128(%0)\n"
26098 - " prefetch 192(%0)\n"
26099 - " prefetch 256(%0)\n"
26100 + "1: prefetch (%1)\n"
26101 + " prefetch 64(%1)\n"
26102 + " prefetch 128(%1)\n"
26103 + " prefetch 192(%1)\n"
26104 + " prefetch 256(%1)\n"
26105 "2: \n"
26106 ".section .fixup, \"ax\"\n"
26107 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26108 + "3: \n"
26109 +
26110 +#ifdef CONFIG_PAX_KERNEXEC
26111 + " movl %%cr0, %0\n"
26112 + " movl %0, %%eax\n"
26113 + " andl $0xFFFEFFFF, %%eax\n"
26114 + " movl %%eax, %%cr0\n"
26115 +#endif
26116 +
26117 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26118 +
26119 +#ifdef CONFIG_PAX_KERNEXEC
26120 + " movl %0, %%cr0\n"
26121 +#endif
26122 +
26123 " jmp 2b\n"
26124 ".previous\n"
26125 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26126 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26127
26128 for (i = 0; i < 4096/64; i++) {
26129 __asm__ __volatile__ (
26130 - "1: prefetch 320(%0)\n"
26131 - "2: movq (%0), %%mm0\n"
26132 - " movq 8(%0), %%mm1\n"
26133 - " movq 16(%0), %%mm2\n"
26134 - " movq 24(%0), %%mm3\n"
26135 - " movq %%mm0, (%1)\n"
26136 - " movq %%mm1, 8(%1)\n"
26137 - " movq %%mm2, 16(%1)\n"
26138 - " movq %%mm3, 24(%1)\n"
26139 - " movq 32(%0), %%mm0\n"
26140 - " movq 40(%0), %%mm1\n"
26141 - " movq 48(%0), %%mm2\n"
26142 - " movq 56(%0), %%mm3\n"
26143 - " movq %%mm0, 32(%1)\n"
26144 - " movq %%mm1, 40(%1)\n"
26145 - " movq %%mm2, 48(%1)\n"
26146 - " movq %%mm3, 56(%1)\n"
26147 + "1: prefetch 320(%1)\n"
26148 + "2: movq (%1), %%mm0\n"
26149 + " movq 8(%1), %%mm1\n"
26150 + " movq 16(%1), %%mm2\n"
26151 + " movq 24(%1), %%mm3\n"
26152 + " movq %%mm0, (%2)\n"
26153 + " movq %%mm1, 8(%2)\n"
26154 + " movq %%mm2, 16(%2)\n"
26155 + " movq %%mm3, 24(%2)\n"
26156 + " movq 32(%1), %%mm0\n"
26157 + " movq 40(%1), %%mm1\n"
26158 + " movq 48(%1), %%mm2\n"
26159 + " movq 56(%1), %%mm3\n"
26160 + " movq %%mm0, 32(%2)\n"
26161 + " movq %%mm1, 40(%2)\n"
26162 + " movq %%mm2, 48(%2)\n"
26163 + " movq %%mm3, 56(%2)\n"
26164 ".section .fixup, \"ax\"\n"
26165 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26166 + "3:\n"
26167 +
26168 +#ifdef CONFIG_PAX_KERNEXEC
26169 + " movl %%cr0, %0\n"
26170 + " movl %0, %%eax\n"
26171 + " andl $0xFFFEFFFF, %%eax\n"
26172 + " movl %%eax, %%cr0\n"
26173 +#endif
26174 +
26175 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26176 +
26177 +#ifdef CONFIG_PAX_KERNEXEC
26178 + " movl %0, %%cr0\n"
26179 +#endif
26180 +
26181 " jmp 2b\n"
26182 ".previous\n"
26183 _ASM_EXTABLE(1b, 3b)
26184 - : : "r" (from), "r" (to) : "memory");
26185 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26186
26187 from += 64;
26188 to += 64;
26189 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26190 index f6d13ee..aca5f0b 100644
26191 --- a/arch/x86/lib/msr-reg.S
26192 +++ b/arch/x86/lib/msr-reg.S
26193 @@ -3,6 +3,7 @@
26194 #include <asm/dwarf2.h>
26195 #include <asm/asm.h>
26196 #include <asm/msr.h>
26197 +#include <asm/alternative-asm.h>
26198
26199 #ifdef CONFIG_X86_64
26200 /*
26201 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26202 CFI_STARTPROC
26203 pushq_cfi %rbx
26204 pushq_cfi %rbp
26205 - movq %rdi, %r10 /* Save pointer */
26206 + movq %rdi, %r9 /* Save pointer */
26207 xorl %r11d, %r11d /* Return value */
26208 movl (%rdi), %eax
26209 movl 4(%rdi), %ecx
26210 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26211 movl 28(%rdi), %edi
26212 CFI_REMEMBER_STATE
26213 1: \op
26214 -2: movl %eax, (%r10)
26215 +2: movl %eax, (%r9)
26216 movl %r11d, %eax /* Return value */
26217 - movl %ecx, 4(%r10)
26218 - movl %edx, 8(%r10)
26219 - movl %ebx, 12(%r10)
26220 - movl %ebp, 20(%r10)
26221 - movl %esi, 24(%r10)
26222 - movl %edi, 28(%r10)
26223 + movl %ecx, 4(%r9)
26224 + movl %edx, 8(%r9)
26225 + movl %ebx, 12(%r9)
26226 + movl %ebp, 20(%r9)
26227 + movl %esi, 24(%r9)
26228 + movl %edi, 28(%r9)
26229 popq_cfi %rbp
26230 popq_cfi %rbx
26231 + pax_force_retaddr
26232 ret
26233 3:
26234 CFI_RESTORE_STATE
26235 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26236 index fc6ba17..d4d989d 100644
26237 --- a/arch/x86/lib/putuser.S
26238 +++ b/arch/x86/lib/putuser.S
26239 @@ -16,7 +16,9 @@
26240 #include <asm/errno.h>
26241 #include <asm/asm.h>
26242 #include <asm/smap.h>
26243 -
26244 +#include <asm/segment.h>
26245 +#include <asm/pgtable.h>
26246 +#include <asm/alternative-asm.h>
26247
26248 /*
26249 * __put_user_X
26250 @@ -30,57 +32,125 @@
26251 * as they get called from within inline assembly.
26252 */
26253
26254 -#define ENTER CFI_STARTPROC ; \
26255 - GET_THREAD_INFO(%_ASM_BX)
26256 -#define EXIT ASM_CLAC ; \
26257 - ret ; \
26258 +#define ENTER CFI_STARTPROC
26259 +#define EXIT ASM_CLAC ; \
26260 + pax_force_retaddr ; \
26261 + ret ; \
26262 CFI_ENDPROC
26263
26264 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26265 +#define _DEST %_ASM_CX,%_ASM_BX
26266 +#else
26267 +#define _DEST %_ASM_CX
26268 +#endif
26269 +
26270 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26271 +#define __copyuser_seg gs;
26272 +#else
26273 +#define __copyuser_seg
26274 +#endif
26275 +
26276 .text
26277 ENTRY(__put_user_1)
26278 ENTER
26279 +
26280 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26281 + GET_THREAD_INFO(%_ASM_BX)
26282 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26283 jae bad_put_user
26284 ASM_STAC
26285 -1: movb %al,(%_ASM_CX)
26286 +
26287 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26288 + mov pax_user_shadow_base,%_ASM_BX
26289 + cmp %_ASM_BX,%_ASM_CX
26290 + jb 1234f
26291 + xor %ebx,%ebx
26292 +1234:
26293 +#endif
26294 +
26295 +#endif
26296 +
26297 +1: __copyuser_seg movb %al,(_DEST)
26298 xor %eax,%eax
26299 EXIT
26300 ENDPROC(__put_user_1)
26301
26302 ENTRY(__put_user_2)
26303 ENTER
26304 +
26305 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26306 + GET_THREAD_INFO(%_ASM_BX)
26307 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26308 sub $1,%_ASM_BX
26309 cmp %_ASM_BX,%_ASM_CX
26310 jae bad_put_user
26311 ASM_STAC
26312 -2: movw %ax,(%_ASM_CX)
26313 +
26314 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26315 + mov pax_user_shadow_base,%_ASM_BX
26316 + cmp %_ASM_BX,%_ASM_CX
26317 + jb 1234f
26318 + xor %ebx,%ebx
26319 +1234:
26320 +#endif
26321 +
26322 +#endif
26323 +
26324 +2: __copyuser_seg movw %ax,(_DEST)
26325 xor %eax,%eax
26326 EXIT
26327 ENDPROC(__put_user_2)
26328
26329 ENTRY(__put_user_4)
26330 ENTER
26331 +
26332 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26333 + GET_THREAD_INFO(%_ASM_BX)
26334 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26335 sub $3,%_ASM_BX
26336 cmp %_ASM_BX,%_ASM_CX
26337 jae bad_put_user
26338 ASM_STAC
26339 -3: movl %eax,(%_ASM_CX)
26340 +
26341 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26342 + mov pax_user_shadow_base,%_ASM_BX
26343 + cmp %_ASM_BX,%_ASM_CX
26344 + jb 1234f
26345 + xor %ebx,%ebx
26346 +1234:
26347 +#endif
26348 +
26349 +#endif
26350 +
26351 +3: __copyuser_seg movl %eax,(_DEST)
26352 xor %eax,%eax
26353 EXIT
26354 ENDPROC(__put_user_4)
26355
26356 ENTRY(__put_user_8)
26357 ENTER
26358 +
26359 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26360 + GET_THREAD_INFO(%_ASM_BX)
26361 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26362 sub $7,%_ASM_BX
26363 cmp %_ASM_BX,%_ASM_CX
26364 jae bad_put_user
26365 ASM_STAC
26366 -4: mov %_ASM_AX,(%_ASM_CX)
26367 +
26368 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26369 + mov pax_user_shadow_base,%_ASM_BX
26370 + cmp %_ASM_BX,%_ASM_CX
26371 + jb 1234f
26372 + xor %ebx,%ebx
26373 +1234:
26374 +#endif
26375 +
26376 +#endif
26377 +
26378 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26379 #ifdef CONFIG_X86_32
26380 -5: movl %edx,4(%_ASM_CX)
26381 +5: __copyuser_seg movl %edx,4(_DEST)
26382 #endif
26383 xor %eax,%eax
26384 EXIT
26385 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26386 index 1cad221..de671ee 100644
26387 --- a/arch/x86/lib/rwlock.S
26388 +++ b/arch/x86/lib/rwlock.S
26389 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26390 FRAME
26391 0: LOCK_PREFIX
26392 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26393 +
26394 +#ifdef CONFIG_PAX_REFCOUNT
26395 + jno 1234f
26396 + LOCK_PREFIX
26397 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26398 + int $4
26399 +1234:
26400 + _ASM_EXTABLE(1234b, 1234b)
26401 +#endif
26402 +
26403 1: rep; nop
26404 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26405 jne 1b
26406 LOCK_PREFIX
26407 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26408 +
26409 +#ifdef CONFIG_PAX_REFCOUNT
26410 + jno 1234f
26411 + LOCK_PREFIX
26412 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26413 + int $4
26414 +1234:
26415 + _ASM_EXTABLE(1234b, 1234b)
26416 +#endif
26417 +
26418 jnz 0b
26419 ENDFRAME
26420 + pax_force_retaddr
26421 ret
26422 CFI_ENDPROC
26423 END(__write_lock_failed)
26424 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26425 FRAME
26426 0: LOCK_PREFIX
26427 READ_LOCK_SIZE(inc) (%__lock_ptr)
26428 +
26429 +#ifdef CONFIG_PAX_REFCOUNT
26430 + jno 1234f
26431 + LOCK_PREFIX
26432 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26433 + int $4
26434 +1234:
26435 + _ASM_EXTABLE(1234b, 1234b)
26436 +#endif
26437 +
26438 1: rep; nop
26439 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26440 js 1b
26441 LOCK_PREFIX
26442 READ_LOCK_SIZE(dec) (%__lock_ptr)
26443 +
26444 +#ifdef CONFIG_PAX_REFCOUNT
26445 + jno 1234f
26446 + LOCK_PREFIX
26447 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26448 + int $4
26449 +1234:
26450 + _ASM_EXTABLE(1234b, 1234b)
26451 +#endif
26452 +
26453 js 0b
26454 ENDFRAME
26455 + pax_force_retaddr
26456 ret
26457 CFI_ENDPROC
26458 END(__read_lock_failed)
26459 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26460 index 5dff5f0..cadebf4 100644
26461 --- a/arch/x86/lib/rwsem.S
26462 +++ b/arch/x86/lib/rwsem.S
26463 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26464 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26465 CFI_RESTORE __ASM_REG(dx)
26466 restore_common_regs
26467 + pax_force_retaddr
26468 ret
26469 CFI_ENDPROC
26470 ENDPROC(call_rwsem_down_read_failed)
26471 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26472 movq %rax,%rdi
26473 call rwsem_down_write_failed
26474 restore_common_regs
26475 + pax_force_retaddr
26476 ret
26477 CFI_ENDPROC
26478 ENDPROC(call_rwsem_down_write_failed)
26479 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26480 movq %rax,%rdi
26481 call rwsem_wake
26482 restore_common_regs
26483 -1: ret
26484 +1: pax_force_retaddr
26485 + ret
26486 CFI_ENDPROC
26487 ENDPROC(call_rwsem_wake)
26488
26489 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26490 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26491 CFI_RESTORE __ASM_REG(dx)
26492 restore_common_regs
26493 + pax_force_retaddr
26494 ret
26495 CFI_ENDPROC
26496 ENDPROC(call_rwsem_downgrade_wake)
26497 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26498 index a63efd6..ccecad8 100644
26499 --- a/arch/x86/lib/thunk_64.S
26500 +++ b/arch/x86/lib/thunk_64.S
26501 @@ -8,6 +8,7 @@
26502 #include <linux/linkage.h>
26503 #include <asm/dwarf2.h>
26504 #include <asm/calling.h>
26505 +#include <asm/alternative-asm.h>
26506
26507 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26508 .macro THUNK name, func, put_ret_addr_in_rdi=0
26509 @@ -41,5 +42,6 @@
26510 SAVE_ARGS
26511 restore:
26512 RESTORE_ARGS
26513 + pax_force_retaddr
26514 ret
26515 CFI_ENDPROC
26516 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26517 index 3eb18ac..6890bc3 100644
26518 --- a/arch/x86/lib/usercopy_32.c
26519 +++ b/arch/x86/lib/usercopy_32.c
26520 @@ -42,11 +42,13 @@ do { \
26521 int __d0; \
26522 might_fault(); \
26523 __asm__ __volatile__( \
26524 + __COPYUSER_SET_ES \
26525 ASM_STAC "\n" \
26526 "0: rep; stosl\n" \
26527 " movl %2,%0\n" \
26528 "1: rep; stosb\n" \
26529 "2: " ASM_CLAC "\n" \
26530 + __COPYUSER_RESTORE_ES \
26531 ".section .fixup,\"ax\"\n" \
26532 "3: lea 0(%2,%0,4),%0\n" \
26533 " jmp 2b\n" \
26534 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26535
26536 #ifdef CONFIG_X86_INTEL_USERCOPY
26537 static unsigned long
26538 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26539 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26540 {
26541 int d0, d1;
26542 __asm__ __volatile__(
26543 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26544 " .align 2,0x90\n"
26545 "3: movl 0(%4), %%eax\n"
26546 "4: movl 4(%4), %%edx\n"
26547 - "5: movl %%eax, 0(%3)\n"
26548 - "6: movl %%edx, 4(%3)\n"
26549 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26550 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26551 "7: movl 8(%4), %%eax\n"
26552 "8: movl 12(%4),%%edx\n"
26553 - "9: movl %%eax, 8(%3)\n"
26554 - "10: movl %%edx, 12(%3)\n"
26555 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26556 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26557 "11: movl 16(%4), %%eax\n"
26558 "12: movl 20(%4), %%edx\n"
26559 - "13: movl %%eax, 16(%3)\n"
26560 - "14: movl %%edx, 20(%3)\n"
26561 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26562 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26563 "15: movl 24(%4), %%eax\n"
26564 "16: movl 28(%4), %%edx\n"
26565 - "17: movl %%eax, 24(%3)\n"
26566 - "18: movl %%edx, 28(%3)\n"
26567 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26568 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26569 "19: movl 32(%4), %%eax\n"
26570 "20: movl 36(%4), %%edx\n"
26571 - "21: movl %%eax, 32(%3)\n"
26572 - "22: movl %%edx, 36(%3)\n"
26573 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26574 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26575 "23: movl 40(%4), %%eax\n"
26576 "24: movl 44(%4), %%edx\n"
26577 - "25: movl %%eax, 40(%3)\n"
26578 - "26: movl %%edx, 44(%3)\n"
26579 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26580 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26581 "27: movl 48(%4), %%eax\n"
26582 "28: movl 52(%4), %%edx\n"
26583 - "29: movl %%eax, 48(%3)\n"
26584 - "30: movl %%edx, 52(%3)\n"
26585 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26586 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26587 "31: movl 56(%4), %%eax\n"
26588 "32: movl 60(%4), %%edx\n"
26589 - "33: movl %%eax, 56(%3)\n"
26590 - "34: movl %%edx, 60(%3)\n"
26591 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26592 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26593 " addl $-64, %0\n"
26594 " addl $64, %4\n"
26595 " addl $64, %3\n"
26596 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26597 " shrl $2, %0\n"
26598 " andl $3, %%eax\n"
26599 " cld\n"
26600 + __COPYUSER_SET_ES
26601 "99: rep; movsl\n"
26602 "36: movl %%eax, %0\n"
26603 "37: rep; movsb\n"
26604 "100:\n"
26605 + __COPYUSER_RESTORE_ES
26606 ".section .fixup,\"ax\"\n"
26607 "101: lea 0(%%eax,%0,4),%0\n"
26608 " jmp 100b\n"
26609 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26610 }
26611
26612 static unsigned long
26613 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26614 +{
26615 + int d0, d1;
26616 + __asm__ __volatile__(
26617 + " .align 2,0x90\n"
26618 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26619 + " cmpl $67, %0\n"
26620 + " jbe 3f\n"
26621 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26622 + " .align 2,0x90\n"
26623 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26624 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26625 + "5: movl %%eax, 0(%3)\n"
26626 + "6: movl %%edx, 4(%3)\n"
26627 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26628 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26629 + "9: movl %%eax, 8(%3)\n"
26630 + "10: movl %%edx, 12(%3)\n"
26631 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26632 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26633 + "13: movl %%eax, 16(%3)\n"
26634 + "14: movl %%edx, 20(%3)\n"
26635 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26636 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26637 + "17: movl %%eax, 24(%3)\n"
26638 + "18: movl %%edx, 28(%3)\n"
26639 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26640 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26641 + "21: movl %%eax, 32(%3)\n"
26642 + "22: movl %%edx, 36(%3)\n"
26643 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26644 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26645 + "25: movl %%eax, 40(%3)\n"
26646 + "26: movl %%edx, 44(%3)\n"
26647 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26648 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26649 + "29: movl %%eax, 48(%3)\n"
26650 + "30: movl %%edx, 52(%3)\n"
26651 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26652 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26653 + "33: movl %%eax, 56(%3)\n"
26654 + "34: movl %%edx, 60(%3)\n"
26655 + " addl $-64, %0\n"
26656 + " addl $64, %4\n"
26657 + " addl $64, %3\n"
26658 + " cmpl $63, %0\n"
26659 + " ja 1b\n"
26660 + "35: movl %0, %%eax\n"
26661 + " shrl $2, %0\n"
26662 + " andl $3, %%eax\n"
26663 + " cld\n"
26664 + "99: rep; "__copyuser_seg" movsl\n"
26665 + "36: movl %%eax, %0\n"
26666 + "37: rep; "__copyuser_seg" movsb\n"
26667 + "100:\n"
26668 + ".section .fixup,\"ax\"\n"
26669 + "101: lea 0(%%eax,%0,4),%0\n"
26670 + " jmp 100b\n"
26671 + ".previous\n"
26672 + _ASM_EXTABLE(1b,100b)
26673 + _ASM_EXTABLE(2b,100b)
26674 + _ASM_EXTABLE(3b,100b)
26675 + _ASM_EXTABLE(4b,100b)
26676 + _ASM_EXTABLE(5b,100b)
26677 + _ASM_EXTABLE(6b,100b)
26678 + _ASM_EXTABLE(7b,100b)
26679 + _ASM_EXTABLE(8b,100b)
26680 + _ASM_EXTABLE(9b,100b)
26681 + _ASM_EXTABLE(10b,100b)
26682 + _ASM_EXTABLE(11b,100b)
26683 + _ASM_EXTABLE(12b,100b)
26684 + _ASM_EXTABLE(13b,100b)
26685 + _ASM_EXTABLE(14b,100b)
26686 + _ASM_EXTABLE(15b,100b)
26687 + _ASM_EXTABLE(16b,100b)
26688 + _ASM_EXTABLE(17b,100b)
26689 + _ASM_EXTABLE(18b,100b)
26690 + _ASM_EXTABLE(19b,100b)
26691 + _ASM_EXTABLE(20b,100b)
26692 + _ASM_EXTABLE(21b,100b)
26693 + _ASM_EXTABLE(22b,100b)
26694 + _ASM_EXTABLE(23b,100b)
26695 + _ASM_EXTABLE(24b,100b)
26696 + _ASM_EXTABLE(25b,100b)
26697 + _ASM_EXTABLE(26b,100b)
26698 + _ASM_EXTABLE(27b,100b)
26699 + _ASM_EXTABLE(28b,100b)
26700 + _ASM_EXTABLE(29b,100b)
26701 + _ASM_EXTABLE(30b,100b)
26702 + _ASM_EXTABLE(31b,100b)
26703 + _ASM_EXTABLE(32b,100b)
26704 + _ASM_EXTABLE(33b,100b)
26705 + _ASM_EXTABLE(34b,100b)
26706 + _ASM_EXTABLE(35b,100b)
26707 + _ASM_EXTABLE(36b,100b)
26708 + _ASM_EXTABLE(37b,100b)
26709 + _ASM_EXTABLE(99b,101b)
26710 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26711 + : "1"(to), "2"(from), "0"(size)
26712 + : "eax", "edx", "memory");
26713 + return size;
26714 +}
26715 +
26716 +static unsigned long __size_overflow(3)
26717 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26718 {
26719 int d0, d1;
26720 __asm__ __volatile__(
26721 " .align 2,0x90\n"
26722 - "0: movl 32(%4), %%eax\n"
26723 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26724 " cmpl $67, %0\n"
26725 " jbe 2f\n"
26726 - "1: movl 64(%4), %%eax\n"
26727 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26728 " .align 2,0x90\n"
26729 - "2: movl 0(%4), %%eax\n"
26730 - "21: movl 4(%4), %%edx\n"
26731 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26732 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26733 " movl %%eax, 0(%3)\n"
26734 " movl %%edx, 4(%3)\n"
26735 - "3: movl 8(%4), %%eax\n"
26736 - "31: movl 12(%4),%%edx\n"
26737 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26738 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26739 " movl %%eax, 8(%3)\n"
26740 " movl %%edx, 12(%3)\n"
26741 - "4: movl 16(%4), %%eax\n"
26742 - "41: movl 20(%4), %%edx\n"
26743 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26744 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26745 " movl %%eax, 16(%3)\n"
26746 " movl %%edx, 20(%3)\n"
26747 - "10: movl 24(%4), %%eax\n"
26748 - "51: movl 28(%4), %%edx\n"
26749 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26750 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26751 " movl %%eax, 24(%3)\n"
26752 " movl %%edx, 28(%3)\n"
26753 - "11: movl 32(%4), %%eax\n"
26754 - "61: movl 36(%4), %%edx\n"
26755 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26756 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26757 " movl %%eax, 32(%3)\n"
26758 " movl %%edx, 36(%3)\n"
26759 - "12: movl 40(%4), %%eax\n"
26760 - "71: movl 44(%4), %%edx\n"
26761 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26762 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26763 " movl %%eax, 40(%3)\n"
26764 " movl %%edx, 44(%3)\n"
26765 - "13: movl 48(%4), %%eax\n"
26766 - "81: movl 52(%4), %%edx\n"
26767 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26768 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26769 " movl %%eax, 48(%3)\n"
26770 " movl %%edx, 52(%3)\n"
26771 - "14: movl 56(%4), %%eax\n"
26772 - "91: movl 60(%4), %%edx\n"
26773 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26774 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26775 " movl %%eax, 56(%3)\n"
26776 " movl %%edx, 60(%3)\n"
26777 " addl $-64, %0\n"
26778 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26779 " shrl $2, %0\n"
26780 " andl $3, %%eax\n"
26781 " cld\n"
26782 - "6: rep; movsl\n"
26783 + "6: rep; "__copyuser_seg" movsl\n"
26784 " movl %%eax,%0\n"
26785 - "7: rep; movsb\n"
26786 + "7: rep; "__copyuser_seg" movsb\n"
26787 "8:\n"
26788 ".section .fixup,\"ax\"\n"
26789 "9: lea 0(%%eax,%0,4),%0\n"
26790 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26791 * hyoshiok@miraclelinux.com
26792 */
26793
26794 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26795 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26796 const void __user *from, unsigned long size)
26797 {
26798 int d0, d1;
26799
26800 __asm__ __volatile__(
26801 " .align 2,0x90\n"
26802 - "0: movl 32(%4), %%eax\n"
26803 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26804 " cmpl $67, %0\n"
26805 " jbe 2f\n"
26806 - "1: movl 64(%4), %%eax\n"
26807 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26808 " .align 2,0x90\n"
26809 - "2: movl 0(%4), %%eax\n"
26810 - "21: movl 4(%4), %%edx\n"
26811 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26812 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26813 " movnti %%eax, 0(%3)\n"
26814 " movnti %%edx, 4(%3)\n"
26815 - "3: movl 8(%4), %%eax\n"
26816 - "31: movl 12(%4),%%edx\n"
26817 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26818 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26819 " movnti %%eax, 8(%3)\n"
26820 " movnti %%edx, 12(%3)\n"
26821 - "4: movl 16(%4), %%eax\n"
26822 - "41: movl 20(%4), %%edx\n"
26823 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26824 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26825 " movnti %%eax, 16(%3)\n"
26826 " movnti %%edx, 20(%3)\n"
26827 - "10: movl 24(%4), %%eax\n"
26828 - "51: movl 28(%4), %%edx\n"
26829 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26830 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26831 " movnti %%eax, 24(%3)\n"
26832 " movnti %%edx, 28(%3)\n"
26833 - "11: movl 32(%4), %%eax\n"
26834 - "61: movl 36(%4), %%edx\n"
26835 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26836 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26837 " movnti %%eax, 32(%3)\n"
26838 " movnti %%edx, 36(%3)\n"
26839 - "12: movl 40(%4), %%eax\n"
26840 - "71: movl 44(%4), %%edx\n"
26841 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26842 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26843 " movnti %%eax, 40(%3)\n"
26844 " movnti %%edx, 44(%3)\n"
26845 - "13: movl 48(%4), %%eax\n"
26846 - "81: movl 52(%4), %%edx\n"
26847 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26848 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26849 " movnti %%eax, 48(%3)\n"
26850 " movnti %%edx, 52(%3)\n"
26851 - "14: movl 56(%4), %%eax\n"
26852 - "91: movl 60(%4), %%edx\n"
26853 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26854 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26855 " movnti %%eax, 56(%3)\n"
26856 " movnti %%edx, 60(%3)\n"
26857 " addl $-64, %0\n"
26858 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26859 " shrl $2, %0\n"
26860 " andl $3, %%eax\n"
26861 " cld\n"
26862 - "6: rep; movsl\n"
26863 + "6: rep; "__copyuser_seg" movsl\n"
26864 " movl %%eax,%0\n"
26865 - "7: rep; movsb\n"
26866 + "7: rep; "__copyuser_seg" movsb\n"
26867 "8:\n"
26868 ".section .fixup,\"ax\"\n"
26869 "9: lea 0(%%eax,%0,4),%0\n"
26870 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26871 return size;
26872 }
26873
26874 -static unsigned long __copy_user_intel_nocache(void *to,
26875 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26876 const void __user *from, unsigned long size)
26877 {
26878 int d0, d1;
26879
26880 __asm__ __volatile__(
26881 " .align 2,0x90\n"
26882 - "0: movl 32(%4), %%eax\n"
26883 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26884 " cmpl $67, %0\n"
26885 " jbe 2f\n"
26886 - "1: movl 64(%4), %%eax\n"
26887 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26888 " .align 2,0x90\n"
26889 - "2: movl 0(%4), %%eax\n"
26890 - "21: movl 4(%4), %%edx\n"
26891 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26892 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26893 " movnti %%eax, 0(%3)\n"
26894 " movnti %%edx, 4(%3)\n"
26895 - "3: movl 8(%4), %%eax\n"
26896 - "31: movl 12(%4),%%edx\n"
26897 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26898 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26899 " movnti %%eax, 8(%3)\n"
26900 " movnti %%edx, 12(%3)\n"
26901 - "4: movl 16(%4), %%eax\n"
26902 - "41: movl 20(%4), %%edx\n"
26903 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26904 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26905 " movnti %%eax, 16(%3)\n"
26906 " movnti %%edx, 20(%3)\n"
26907 - "10: movl 24(%4), %%eax\n"
26908 - "51: movl 28(%4), %%edx\n"
26909 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26910 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26911 " movnti %%eax, 24(%3)\n"
26912 " movnti %%edx, 28(%3)\n"
26913 - "11: movl 32(%4), %%eax\n"
26914 - "61: movl 36(%4), %%edx\n"
26915 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26916 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26917 " movnti %%eax, 32(%3)\n"
26918 " movnti %%edx, 36(%3)\n"
26919 - "12: movl 40(%4), %%eax\n"
26920 - "71: movl 44(%4), %%edx\n"
26921 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26922 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26923 " movnti %%eax, 40(%3)\n"
26924 " movnti %%edx, 44(%3)\n"
26925 - "13: movl 48(%4), %%eax\n"
26926 - "81: movl 52(%4), %%edx\n"
26927 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26928 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26929 " movnti %%eax, 48(%3)\n"
26930 " movnti %%edx, 52(%3)\n"
26931 - "14: movl 56(%4), %%eax\n"
26932 - "91: movl 60(%4), %%edx\n"
26933 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26934 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26935 " movnti %%eax, 56(%3)\n"
26936 " movnti %%edx, 60(%3)\n"
26937 " addl $-64, %0\n"
26938 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26939 " shrl $2, %0\n"
26940 " andl $3, %%eax\n"
26941 " cld\n"
26942 - "6: rep; movsl\n"
26943 + "6: rep; "__copyuser_seg" movsl\n"
26944 " movl %%eax,%0\n"
26945 - "7: rep; movsb\n"
26946 + "7: rep; "__copyuser_seg" movsb\n"
26947 "8:\n"
26948 ".section .fixup,\"ax\"\n"
26949 "9: lea 0(%%eax,%0,4),%0\n"
26950 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26951 */
26952 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26953 unsigned long size);
26954 -unsigned long __copy_user_intel(void __user *to, const void *from,
26955 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26956 + unsigned long size);
26957 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26958 unsigned long size);
26959 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26960 const void __user *from, unsigned long size);
26961 #endif /* CONFIG_X86_INTEL_USERCOPY */
26962
26963 /* Generic arbitrary sized copy. */
26964 -#define __copy_user(to, from, size) \
26965 +#define __copy_user(to, from, size, prefix, set, restore) \
26966 do { \
26967 int __d0, __d1, __d2; \
26968 __asm__ __volatile__( \
26969 + set \
26970 " cmp $7,%0\n" \
26971 " jbe 1f\n" \
26972 " movl %1,%0\n" \
26973 " negl %0\n" \
26974 " andl $7,%0\n" \
26975 " subl %0,%3\n" \
26976 - "4: rep; movsb\n" \
26977 + "4: rep; "prefix"movsb\n" \
26978 " movl %3,%0\n" \
26979 " shrl $2,%0\n" \
26980 " andl $3,%3\n" \
26981 " .align 2,0x90\n" \
26982 - "0: rep; movsl\n" \
26983 + "0: rep; "prefix"movsl\n" \
26984 " movl %3,%0\n" \
26985 - "1: rep; movsb\n" \
26986 + "1: rep; "prefix"movsb\n" \
26987 "2:\n" \
26988 + restore \
26989 ".section .fixup,\"ax\"\n" \
26990 "5: addl %3,%0\n" \
26991 " jmp 2b\n" \
26992 @@ -538,14 +650,14 @@ do { \
26993 " negl %0\n" \
26994 " andl $7,%0\n" \
26995 " subl %0,%3\n" \
26996 - "4: rep; movsb\n" \
26997 + "4: rep; "__copyuser_seg"movsb\n" \
26998 " movl %3,%0\n" \
26999 " shrl $2,%0\n" \
27000 " andl $3,%3\n" \
27001 " .align 2,0x90\n" \
27002 - "0: rep; movsl\n" \
27003 + "0: rep; "__copyuser_seg"movsl\n" \
27004 " movl %3,%0\n" \
27005 - "1: rep; movsb\n" \
27006 + "1: rep; "__copyuser_seg"movsb\n" \
27007 "2:\n" \
27008 ".section .fixup,\"ax\"\n" \
27009 "5: addl %3,%0\n" \
27010 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27011 {
27012 stac();
27013 if (movsl_is_ok(to, from, n))
27014 - __copy_user(to, from, n);
27015 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27016 else
27017 - n = __copy_user_intel(to, from, n);
27018 + n = __generic_copy_to_user_intel(to, from, n);
27019 clac();
27020 return n;
27021 }
27022 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27023 {
27024 stac();
27025 if (movsl_is_ok(to, from, n))
27026 - __copy_user(to, from, n);
27027 + __copy_user(to, from, n, __copyuser_seg, "", "");
27028 else
27029 - n = __copy_user_intel((void __user *)to,
27030 - (const void *)from, n);
27031 + n = __generic_copy_from_user_intel(to, from, n);
27032 clac();
27033 return n;
27034 }
27035 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27036 if (n > 64 && cpu_has_xmm2)
27037 n = __copy_user_intel_nocache(to, from, n);
27038 else
27039 - __copy_user(to, from, n);
27040 + __copy_user(to, from, n, __copyuser_seg, "", "");
27041 #else
27042 - __copy_user(to, from, n);
27043 + __copy_user(to, from, n, __copyuser_seg, "", "");
27044 #endif
27045 clac();
27046 return n;
27047 }
27048 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27049
27050 -/**
27051 - * copy_to_user: - Copy a block of data into user space.
27052 - * @to: Destination address, in user space.
27053 - * @from: Source address, in kernel space.
27054 - * @n: Number of bytes to copy.
27055 - *
27056 - * Context: User context only. This function may sleep.
27057 - *
27058 - * Copy data from kernel space to user space.
27059 - *
27060 - * Returns number of bytes that could not be copied.
27061 - * On success, this will be zero.
27062 - */
27063 -unsigned long
27064 -copy_to_user(void __user *to, const void *from, unsigned long n)
27065 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27066 +void __set_fs(mm_segment_t x)
27067 {
27068 - if (access_ok(VERIFY_WRITE, to, n))
27069 - n = __copy_to_user(to, from, n);
27070 - return n;
27071 + switch (x.seg) {
27072 + case 0:
27073 + loadsegment(gs, 0);
27074 + break;
27075 + case TASK_SIZE_MAX:
27076 + loadsegment(gs, __USER_DS);
27077 + break;
27078 + case -1UL:
27079 + loadsegment(gs, __KERNEL_DS);
27080 + break;
27081 + default:
27082 + BUG();
27083 + }
27084 }
27085 -EXPORT_SYMBOL(copy_to_user);
27086 +EXPORT_SYMBOL(__set_fs);
27087
27088 -/**
27089 - * copy_from_user: - Copy a block of data from user space.
27090 - * @to: Destination address, in kernel space.
27091 - * @from: Source address, in user space.
27092 - * @n: Number of bytes to copy.
27093 - *
27094 - * Context: User context only. This function may sleep.
27095 - *
27096 - * Copy data from user space to kernel space.
27097 - *
27098 - * Returns number of bytes that could not be copied.
27099 - * On success, this will be zero.
27100 - *
27101 - * If some data could not be copied, this function will pad the copied
27102 - * data to the requested size using zero bytes.
27103 - */
27104 -unsigned long
27105 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27106 +void set_fs(mm_segment_t x)
27107 {
27108 - if (access_ok(VERIFY_READ, from, n))
27109 - n = __copy_from_user(to, from, n);
27110 - else
27111 - memset(to, 0, n);
27112 - return n;
27113 + current_thread_info()->addr_limit = x;
27114 + __set_fs(x);
27115 }
27116 -EXPORT_SYMBOL(_copy_from_user);
27117 +EXPORT_SYMBOL(set_fs);
27118 +#endif
27119 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27120 index 906fea3..5646695 100644
27121 --- a/arch/x86/lib/usercopy_64.c
27122 +++ b/arch/x86/lib/usercopy_64.c
27123 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27124 _ASM_EXTABLE(0b,3b)
27125 _ASM_EXTABLE(1b,2b)
27126 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27127 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27128 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27129 [zero] "r" (0UL), [eight] "r" (8UL));
27130 clac();
27131 return size;
27132 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27133 }
27134 EXPORT_SYMBOL(clear_user);
27135
27136 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27137 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27138 {
27139 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27140 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27141 - }
27142 - return len;
27143 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27144 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27145 + return len;
27146 }
27147 EXPORT_SYMBOL(copy_in_user);
27148
27149 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27150 * it is not necessary to optimize tail handling.
27151 */
27152 unsigned long
27153 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27154 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27155 {
27156 char c;
27157 unsigned zero_len;
27158 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27159 index 903ec1e..c4166b2 100644
27160 --- a/arch/x86/mm/extable.c
27161 +++ b/arch/x86/mm/extable.c
27162 @@ -6,12 +6,24 @@
27163 static inline unsigned long
27164 ex_insn_addr(const struct exception_table_entry *x)
27165 {
27166 - return (unsigned long)&x->insn + x->insn;
27167 + unsigned long reloc = 0;
27168 +
27169 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27170 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27171 +#endif
27172 +
27173 + return (unsigned long)&x->insn + x->insn + reloc;
27174 }
27175 static inline unsigned long
27176 ex_fixup_addr(const struct exception_table_entry *x)
27177 {
27178 - return (unsigned long)&x->fixup + x->fixup;
27179 + unsigned long reloc = 0;
27180 +
27181 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27182 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27183 +#endif
27184 +
27185 + return (unsigned long)&x->fixup + x->fixup + reloc;
27186 }
27187
27188 int fixup_exception(struct pt_regs *regs)
27189 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27190 unsigned long new_ip;
27191
27192 #ifdef CONFIG_PNPBIOS
27193 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27194 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27195 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27196 extern u32 pnp_bios_is_utter_crap;
27197 pnp_bios_is_utter_crap = 1;
27198 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27199 i += 4;
27200 p->fixup -= i;
27201 i += 4;
27202 +
27203 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27204 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27205 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27206 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27207 +#endif
27208 +
27209 }
27210 }
27211
27212 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27213 index 654be4a..d36985f 100644
27214 --- a/arch/x86/mm/fault.c
27215 +++ b/arch/x86/mm/fault.c
27216 @@ -14,11 +14,18 @@
27217 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27218 #include <linux/prefetch.h> /* prefetchw */
27219 #include <linux/context_tracking.h> /* exception_enter(), ... */
27220 +#include <linux/unistd.h>
27221 +#include <linux/compiler.h>
27222
27223 #include <asm/traps.h> /* dotraplinkage, ... */
27224 #include <asm/pgalloc.h> /* pgd_*(), ... */
27225 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27226 #include <asm/fixmap.h> /* VSYSCALL_START */
27227 +#include <asm/tlbflush.h>
27228 +
27229 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27230 +#include <asm/stacktrace.h>
27231 +#endif
27232
27233 /*
27234 * Page fault error code bits:
27235 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27236 int ret = 0;
27237
27238 /* kprobe_running() needs smp_processor_id() */
27239 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27240 + if (kprobes_built_in() && !user_mode(regs)) {
27241 preempt_disable();
27242 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27243 ret = 1;
27244 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27245 return !instr_lo || (instr_lo>>1) == 1;
27246 case 0x00:
27247 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27248 - if (probe_kernel_address(instr, opcode))
27249 + if (user_mode(regs)) {
27250 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27251 + return 0;
27252 + } else if (probe_kernel_address(instr, opcode))
27253 return 0;
27254
27255 *prefetch = (instr_lo == 0xF) &&
27256 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27257 while (instr < max_instr) {
27258 unsigned char opcode;
27259
27260 - if (probe_kernel_address(instr, opcode))
27261 + if (user_mode(regs)) {
27262 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27263 + break;
27264 + } else if (probe_kernel_address(instr, opcode))
27265 break;
27266
27267 instr++;
27268 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27269 force_sig_info(si_signo, &info, tsk);
27270 }
27271
27272 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27273 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27274 +#endif
27275 +
27276 +#ifdef CONFIG_PAX_EMUTRAMP
27277 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27278 +#endif
27279 +
27280 +#ifdef CONFIG_PAX_PAGEEXEC
27281 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27282 +{
27283 + pgd_t *pgd;
27284 + pud_t *pud;
27285 + pmd_t *pmd;
27286 +
27287 + pgd = pgd_offset(mm, address);
27288 + if (!pgd_present(*pgd))
27289 + return NULL;
27290 + pud = pud_offset(pgd, address);
27291 + if (!pud_present(*pud))
27292 + return NULL;
27293 + pmd = pmd_offset(pud, address);
27294 + if (!pmd_present(*pmd))
27295 + return NULL;
27296 + return pmd;
27297 +}
27298 +#endif
27299 +
27300 DEFINE_SPINLOCK(pgd_lock);
27301 LIST_HEAD(pgd_list);
27302
27303 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27304 for (address = VMALLOC_START & PMD_MASK;
27305 address >= TASK_SIZE && address < FIXADDR_TOP;
27306 address += PMD_SIZE) {
27307 +
27308 +#ifdef CONFIG_PAX_PER_CPU_PGD
27309 + unsigned long cpu;
27310 +#else
27311 struct page *page;
27312 +#endif
27313
27314 spin_lock(&pgd_lock);
27315 +
27316 +#ifdef CONFIG_PAX_PER_CPU_PGD
27317 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27318 + pgd_t *pgd = get_cpu_pgd(cpu);
27319 + pmd_t *ret;
27320 +#else
27321 list_for_each_entry(page, &pgd_list, lru) {
27322 + pgd_t *pgd;
27323 spinlock_t *pgt_lock;
27324 pmd_t *ret;
27325
27326 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27327 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27328
27329 spin_lock(pgt_lock);
27330 - ret = vmalloc_sync_one(page_address(page), address);
27331 + pgd = page_address(page);
27332 +#endif
27333 +
27334 + ret = vmalloc_sync_one(pgd, address);
27335 +
27336 +#ifndef CONFIG_PAX_PER_CPU_PGD
27337 spin_unlock(pgt_lock);
27338 +#endif
27339
27340 if (!ret)
27341 break;
27342 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27343 * an interrupt in the middle of a task switch..
27344 */
27345 pgd_paddr = read_cr3();
27346 +
27347 +#ifdef CONFIG_PAX_PER_CPU_PGD
27348 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27349 +#endif
27350 +
27351 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27352 if (!pmd_k)
27353 return -1;
27354 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27355 * happen within a race in page table update. In the later
27356 * case just flush:
27357 */
27358 +
27359 +#ifdef CONFIG_PAX_PER_CPU_PGD
27360 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27361 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27362 +#else
27363 pgd = pgd_offset(current->active_mm, address);
27364 +#endif
27365 +
27366 pgd_ref = pgd_offset_k(address);
27367 if (pgd_none(*pgd_ref))
27368 return -1;
27369 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27370 static int is_errata100(struct pt_regs *regs, unsigned long address)
27371 {
27372 #ifdef CONFIG_X86_64
27373 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27374 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27375 return 1;
27376 #endif
27377 return 0;
27378 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27379 }
27380
27381 static const char nx_warning[] = KERN_CRIT
27382 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27383 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27384
27385 static void
27386 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27387 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27388 if (!oops_may_print())
27389 return;
27390
27391 - if (error_code & PF_INSTR) {
27392 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27393 unsigned int level;
27394
27395 pte_t *pte = lookup_address(address, &level);
27396
27397 if (pte && pte_present(*pte) && !pte_exec(*pte))
27398 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27399 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27400 }
27401
27402 +#ifdef CONFIG_PAX_KERNEXEC
27403 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27404 + if (current->signal->curr_ip)
27405 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27406 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27407 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27408 + else
27409 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27410 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27411 + }
27412 +#endif
27413 +
27414 printk(KERN_ALERT "BUG: unable to handle kernel ");
27415 if (address < PAGE_SIZE)
27416 printk(KERN_CONT "NULL pointer dereference");
27417 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27418 return;
27419 }
27420 #endif
27421 +
27422 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27423 + if (pax_is_fetch_fault(regs, error_code, address)) {
27424 +
27425 +#ifdef CONFIG_PAX_EMUTRAMP
27426 + switch (pax_handle_fetch_fault(regs)) {
27427 + case 2:
27428 + return;
27429 + }
27430 +#endif
27431 +
27432 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27433 + do_group_exit(SIGKILL);
27434 + }
27435 +#endif
27436 +
27437 /* Kernel addresses are always protection faults: */
27438 if (address >= TASK_SIZE)
27439 error_code |= PF_PROT;
27440 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27441 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27442 printk(KERN_ERR
27443 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27444 - tsk->comm, tsk->pid, address);
27445 + tsk->comm, task_pid_nr(tsk), address);
27446 code = BUS_MCEERR_AR;
27447 }
27448 #endif
27449 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27450 return 1;
27451 }
27452
27453 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27454 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27455 +{
27456 + pte_t *pte;
27457 + pmd_t *pmd;
27458 + spinlock_t *ptl;
27459 + unsigned char pte_mask;
27460 +
27461 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27462 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27463 + return 0;
27464 +
27465 + /* PaX: it's our fault, let's handle it if we can */
27466 +
27467 + /* PaX: take a look at read faults before acquiring any locks */
27468 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27469 + /* instruction fetch attempt from a protected page in user mode */
27470 + up_read(&mm->mmap_sem);
27471 +
27472 +#ifdef CONFIG_PAX_EMUTRAMP
27473 + switch (pax_handle_fetch_fault(regs)) {
27474 + case 2:
27475 + return 1;
27476 + }
27477 +#endif
27478 +
27479 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27480 + do_group_exit(SIGKILL);
27481 + }
27482 +
27483 + pmd = pax_get_pmd(mm, address);
27484 + if (unlikely(!pmd))
27485 + return 0;
27486 +
27487 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27488 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27489 + pte_unmap_unlock(pte, ptl);
27490 + return 0;
27491 + }
27492 +
27493 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27494 + /* write attempt to a protected page in user mode */
27495 + pte_unmap_unlock(pte, ptl);
27496 + return 0;
27497 + }
27498 +
27499 +#ifdef CONFIG_SMP
27500 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27501 +#else
27502 + if (likely(address > get_limit(regs->cs)))
27503 +#endif
27504 + {
27505 + set_pte(pte, pte_mkread(*pte));
27506 + __flush_tlb_one(address);
27507 + pte_unmap_unlock(pte, ptl);
27508 + up_read(&mm->mmap_sem);
27509 + return 1;
27510 + }
27511 +
27512 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27513 +
27514 + /*
27515 + * PaX: fill DTLB with user rights and retry
27516 + */
27517 + __asm__ __volatile__ (
27518 + "orb %2,(%1)\n"
27519 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27520 +/*
27521 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27522 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27523 + * page fault when examined during a TLB load attempt. this is true not only
27524 + * for PTEs holding a non-present entry but also present entries that will
27525 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27526 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27527 + * for our target pages since their PTEs are simply not in the TLBs at all.
27528 +
27529 + * the best thing in omitting it is that we gain around 15-20% speed in the
27530 + * fast path of the page fault handler and can get rid of tracing since we
27531 + * can no longer flush unintended entries.
27532 + */
27533 + "invlpg (%0)\n"
27534 +#endif
27535 + __copyuser_seg"testb $0,(%0)\n"
27536 + "xorb %3,(%1)\n"
27537 + :
27538 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27539 + : "memory", "cc");
27540 + pte_unmap_unlock(pte, ptl);
27541 + up_read(&mm->mmap_sem);
27542 + return 1;
27543 +}
27544 +#endif
27545 +
27546 /*
27547 * Handle a spurious fault caused by a stale TLB entry.
27548 *
27549 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27550 static inline int
27551 access_error(unsigned long error_code, struct vm_area_struct *vma)
27552 {
27553 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27554 + return 1;
27555 +
27556 if (error_code & PF_WRITE) {
27557 /* write, present and write, not present: */
27558 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27559 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27560 if (error_code & PF_USER)
27561 return false;
27562
27563 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27564 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27565 return false;
27566
27567 return true;
27568 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27569 {
27570 struct vm_area_struct *vma;
27571 struct task_struct *tsk;
27572 - unsigned long address;
27573 struct mm_struct *mm;
27574 int fault;
27575 int write = error_code & PF_WRITE;
27576 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27577 (write ? FAULT_FLAG_WRITE : 0);
27578
27579 - tsk = current;
27580 - mm = tsk->mm;
27581 -
27582 /* Get the faulting address: */
27583 - address = read_cr2();
27584 + unsigned long address = read_cr2();
27585 +
27586 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27587 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27588 + if (!search_exception_tables(regs->ip)) {
27589 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27590 + bad_area_nosemaphore(regs, error_code, address);
27591 + return;
27592 + }
27593 + if (address < pax_user_shadow_base) {
27594 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27595 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27596 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27597 + } else
27598 + address -= pax_user_shadow_base;
27599 + }
27600 +#endif
27601 +
27602 + tsk = current;
27603 + mm = tsk->mm;
27604
27605 /*
27606 * Detect and handle instructions that would cause a page fault for
27607 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27608 * User-mode registers count as a user access even for any
27609 * potential system fault or CPU buglet:
27610 */
27611 - if (user_mode_vm(regs)) {
27612 + if (user_mode(regs)) {
27613 local_irq_enable();
27614 error_code |= PF_USER;
27615 } else {
27616 @@ -1142,6 +1352,11 @@ retry:
27617 might_sleep();
27618 }
27619
27620 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27621 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27622 + return;
27623 +#endif
27624 +
27625 vma = find_vma(mm, address);
27626 if (unlikely(!vma)) {
27627 bad_area(regs, error_code, address);
27628 @@ -1153,18 +1368,24 @@ retry:
27629 bad_area(regs, error_code, address);
27630 return;
27631 }
27632 - if (error_code & PF_USER) {
27633 - /*
27634 - * Accessing the stack below %sp is always a bug.
27635 - * The large cushion allows instructions like enter
27636 - * and pusha to work. ("enter $65535, $31" pushes
27637 - * 32 pointers and then decrements %sp by 65535.)
27638 - */
27639 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27640 - bad_area(regs, error_code, address);
27641 - return;
27642 - }
27643 + /*
27644 + * Accessing the stack below %sp is always a bug.
27645 + * The large cushion allows instructions like enter
27646 + * and pusha to work. ("enter $65535, $31" pushes
27647 + * 32 pointers and then decrements %sp by 65535.)
27648 + */
27649 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27650 + bad_area(regs, error_code, address);
27651 + return;
27652 }
27653 +
27654 +#ifdef CONFIG_PAX_SEGMEXEC
27655 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27656 + bad_area(regs, error_code, address);
27657 + return;
27658 + }
27659 +#endif
27660 +
27661 if (unlikely(expand_stack(vma, address))) {
27662 bad_area(regs, error_code, address);
27663 return;
27664 @@ -1230,3 +1451,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27665 __do_page_fault(regs, error_code);
27666 exception_exit(prev_state);
27667 }
27668 +
27669 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27670 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27671 +{
27672 + struct mm_struct *mm = current->mm;
27673 + unsigned long ip = regs->ip;
27674 +
27675 + if (v8086_mode(regs))
27676 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27677 +
27678 +#ifdef CONFIG_PAX_PAGEEXEC
27679 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27680 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27681 + return true;
27682 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27683 + return true;
27684 + return false;
27685 + }
27686 +#endif
27687 +
27688 +#ifdef CONFIG_PAX_SEGMEXEC
27689 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27690 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27691 + return true;
27692 + return false;
27693 + }
27694 +#endif
27695 +
27696 + return false;
27697 +}
27698 +#endif
27699 +
27700 +#ifdef CONFIG_PAX_EMUTRAMP
27701 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27702 +{
27703 + int err;
27704 +
27705 + do { /* PaX: libffi trampoline emulation */
27706 + unsigned char mov, jmp;
27707 + unsigned int addr1, addr2;
27708 +
27709 +#ifdef CONFIG_X86_64
27710 + if ((regs->ip + 9) >> 32)
27711 + break;
27712 +#endif
27713 +
27714 + err = get_user(mov, (unsigned char __user *)regs->ip);
27715 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27716 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27717 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27718 +
27719 + if (err)
27720 + break;
27721 +
27722 + if (mov == 0xB8 && jmp == 0xE9) {
27723 + regs->ax = addr1;
27724 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27725 + return 2;
27726 + }
27727 + } while (0);
27728 +
27729 + do { /* PaX: gcc trampoline emulation #1 */
27730 + unsigned char mov1, mov2;
27731 + unsigned short jmp;
27732 + unsigned int addr1, addr2;
27733 +
27734 +#ifdef CONFIG_X86_64
27735 + if ((regs->ip + 11) >> 32)
27736 + break;
27737 +#endif
27738 +
27739 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27740 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27741 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27742 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27743 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27744 +
27745 + if (err)
27746 + break;
27747 +
27748 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27749 + regs->cx = addr1;
27750 + regs->ax = addr2;
27751 + regs->ip = addr2;
27752 + return 2;
27753 + }
27754 + } while (0);
27755 +
27756 + do { /* PaX: gcc trampoline emulation #2 */
27757 + unsigned char mov, jmp;
27758 + unsigned int addr1, addr2;
27759 +
27760 +#ifdef CONFIG_X86_64
27761 + if ((regs->ip + 9) >> 32)
27762 + break;
27763 +#endif
27764 +
27765 + err = get_user(mov, (unsigned char __user *)regs->ip);
27766 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27767 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27768 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27769 +
27770 + if (err)
27771 + break;
27772 +
27773 + if (mov == 0xB9 && jmp == 0xE9) {
27774 + regs->cx = addr1;
27775 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27776 + return 2;
27777 + }
27778 + } while (0);
27779 +
27780 + return 1; /* PaX in action */
27781 +}
27782 +
27783 +#ifdef CONFIG_X86_64
27784 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27785 +{
27786 + int err;
27787 +
27788 + do { /* PaX: libffi trampoline emulation */
27789 + unsigned short mov1, mov2, jmp1;
27790 + unsigned char stcclc, jmp2;
27791 + unsigned long addr1, addr2;
27792 +
27793 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27794 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27795 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27796 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27797 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27798 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27799 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27800 +
27801 + if (err)
27802 + break;
27803 +
27804 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27805 + regs->r11 = addr1;
27806 + regs->r10 = addr2;
27807 + if (stcclc == 0xF8)
27808 + regs->flags &= ~X86_EFLAGS_CF;
27809 + else
27810 + regs->flags |= X86_EFLAGS_CF;
27811 + regs->ip = addr1;
27812 + return 2;
27813 + }
27814 + } while (0);
27815 +
27816 + do { /* PaX: gcc trampoline emulation #1 */
27817 + unsigned short mov1, mov2, jmp1;
27818 + unsigned char jmp2;
27819 + unsigned int addr1;
27820 + unsigned long addr2;
27821 +
27822 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27823 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27824 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27825 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27826 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27827 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27828 +
27829 + if (err)
27830 + break;
27831 +
27832 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27833 + regs->r11 = addr1;
27834 + regs->r10 = addr2;
27835 + regs->ip = addr1;
27836 + return 2;
27837 + }
27838 + } while (0);
27839 +
27840 + do { /* PaX: gcc trampoline emulation #2 */
27841 + unsigned short mov1, mov2, jmp1;
27842 + unsigned char jmp2;
27843 + unsigned long addr1, addr2;
27844 +
27845 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27846 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27847 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27848 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27849 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27850 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27851 +
27852 + if (err)
27853 + break;
27854 +
27855 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27856 + regs->r11 = addr1;
27857 + regs->r10 = addr2;
27858 + regs->ip = addr1;
27859 + return 2;
27860 + }
27861 + } while (0);
27862 +
27863 + return 1; /* PaX in action */
27864 +}
27865 +#endif
27866 +
27867 +/*
27868 + * PaX: decide what to do with offenders (regs->ip = fault address)
27869 + *
27870 + * returns 1 when task should be killed
27871 + * 2 when gcc trampoline was detected
27872 + */
27873 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27874 +{
27875 + if (v8086_mode(regs))
27876 + return 1;
27877 +
27878 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27879 + return 1;
27880 +
27881 +#ifdef CONFIG_X86_32
27882 + return pax_handle_fetch_fault_32(regs);
27883 +#else
27884 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27885 + return pax_handle_fetch_fault_32(regs);
27886 + else
27887 + return pax_handle_fetch_fault_64(regs);
27888 +#endif
27889 +}
27890 +#endif
27891 +
27892 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27893 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27894 +{
27895 + long i;
27896 +
27897 + printk(KERN_ERR "PAX: bytes at PC: ");
27898 + for (i = 0; i < 20; i++) {
27899 + unsigned char c;
27900 + if (get_user(c, (unsigned char __force_user *)pc+i))
27901 + printk(KERN_CONT "?? ");
27902 + else
27903 + printk(KERN_CONT "%02x ", c);
27904 + }
27905 + printk("\n");
27906 +
27907 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27908 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27909 + unsigned long c;
27910 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27911 +#ifdef CONFIG_X86_32
27912 + printk(KERN_CONT "???????? ");
27913 +#else
27914 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27915 + printk(KERN_CONT "???????? ???????? ");
27916 + else
27917 + printk(KERN_CONT "???????????????? ");
27918 +#endif
27919 + } else {
27920 +#ifdef CONFIG_X86_64
27921 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27922 + printk(KERN_CONT "%08x ", (unsigned int)c);
27923 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27924 + } else
27925 +#endif
27926 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27927 + }
27928 + }
27929 + printk("\n");
27930 +}
27931 +#endif
27932 +
27933 +/**
27934 + * probe_kernel_write(): safely attempt to write to a location
27935 + * @dst: address to write to
27936 + * @src: pointer to the data that shall be written
27937 + * @size: size of the data chunk
27938 + *
27939 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27940 + * happens, handle that and return -EFAULT.
27941 + */
27942 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27943 +{
27944 + long ret;
27945 + mm_segment_t old_fs = get_fs();
27946 +
27947 + set_fs(KERNEL_DS);
27948 + pagefault_disable();
27949 + pax_open_kernel();
27950 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27951 + pax_close_kernel();
27952 + pagefault_enable();
27953 + set_fs(old_fs);
27954 +
27955 + return ret ? -EFAULT : 0;
27956 +}
27957 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27958 index dd74e46..7d26398 100644
27959 --- a/arch/x86/mm/gup.c
27960 +++ b/arch/x86/mm/gup.c
27961 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27962 addr = start;
27963 len = (unsigned long) nr_pages << PAGE_SHIFT;
27964 end = start + len;
27965 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27966 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27967 (void __user *)start, len)))
27968 return 0;
27969
27970 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27971 index 252b8f5..4dcfdc1 100644
27972 --- a/arch/x86/mm/highmem_32.c
27973 +++ b/arch/x86/mm/highmem_32.c
27974 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27975 idx = type + KM_TYPE_NR*smp_processor_id();
27976 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27977 BUG_ON(!pte_none(*(kmap_pte-idx)));
27978 +
27979 + pax_open_kernel();
27980 set_pte(kmap_pte-idx, mk_pte(page, prot));
27981 + pax_close_kernel();
27982 +
27983 arch_flush_lazy_mmu_mode();
27984
27985 return (void *)vaddr;
27986 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27987 index ae1aa71..d9bea75 100644
27988 --- a/arch/x86/mm/hugetlbpage.c
27989 +++ b/arch/x86/mm/hugetlbpage.c
27990 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27991 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27992 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27993 unsigned long addr, unsigned long len,
27994 - unsigned long pgoff, unsigned long flags)
27995 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27996 {
27997 struct hstate *h = hstate_file(file);
27998 struct vm_unmapped_area_info info;
27999 -
28000 +
28001 info.flags = 0;
28002 info.length = len;
28003 info.low_limit = TASK_UNMAPPED_BASE;
28004 +
28005 +#ifdef CONFIG_PAX_RANDMMAP
28006 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28007 + info.low_limit += current->mm->delta_mmap;
28008 +#endif
28009 +
28010 info.high_limit = TASK_SIZE;
28011 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28012 info.align_offset = 0;
28013 + info.threadstack_offset = offset;
28014 return vm_unmapped_area(&info);
28015 }
28016
28017 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28018 unsigned long addr0, unsigned long len,
28019 - unsigned long pgoff, unsigned long flags)
28020 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28021 {
28022 struct hstate *h = hstate_file(file);
28023 struct vm_unmapped_area_info info;
28024 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28025 info.high_limit = current->mm->mmap_base;
28026 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28027 info.align_offset = 0;
28028 + info.threadstack_offset = offset;
28029 addr = vm_unmapped_area(&info);
28030
28031 /*
28032 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28033 VM_BUG_ON(addr != -ENOMEM);
28034 info.flags = 0;
28035 info.low_limit = TASK_UNMAPPED_BASE;
28036 +
28037 +#ifdef CONFIG_PAX_RANDMMAP
28038 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28039 + info.low_limit += current->mm->delta_mmap;
28040 +#endif
28041 +
28042 info.high_limit = TASK_SIZE;
28043 addr = vm_unmapped_area(&info);
28044 }
28045 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28046 struct hstate *h = hstate_file(file);
28047 struct mm_struct *mm = current->mm;
28048 struct vm_area_struct *vma;
28049 + unsigned long pax_task_size = TASK_SIZE;
28050 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28051
28052 if (len & ~huge_page_mask(h))
28053 return -EINVAL;
28054 - if (len > TASK_SIZE)
28055 +
28056 +#ifdef CONFIG_PAX_SEGMEXEC
28057 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28058 + pax_task_size = SEGMEXEC_TASK_SIZE;
28059 +#endif
28060 +
28061 + pax_task_size -= PAGE_SIZE;
28062 +
28063 + if (len > pax_task_size)
28064 return -ENOMEM;
28065
28066 if (flags & MAP_FIXED) {
28067 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28068 return addr;
28069 }
28070
28071 +#ifdef CONFIG_PAX_RANDMMAP
28072 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28073 +#endif
28074 +
28075 if (addr) {
28076 addr = ALIGN(addr, huge_page_size(h));
28077 vma = find_vma(mm, addr);
28078 - if (TASK_SIZE - len >= addr &&
28079 - (!vma || addr + len <= vma->vm_start))
28080 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28081 return addr;
28082 }
28083 if (mm->get_unmapped_area == arch_get_unmapped_area)
28084 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28085 - pgoff, flags);
28086 + pgoff, flags, offset);
28087 else
28088 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28089 - pgoff, flags);
28090 + pgoff, flags, offset);
28091 }
28092
28093 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28094 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28095 index 1f34e92..d252637 100644
28096 --- a/arch/x86/mm/init.c
28097 +++ b/arch/x86/mm/init.c
28098 @@ -4,6 +4,7 @@
28099 #include <linux/swap.h>
28100 #include <linux/memblock.h>
28101 #include <linux/bootmem.h> /* for max_low_pfn */
28102 +#include <linux/tboot.h>
28103
28104 #include <asm/cacheflush.h>
28105 #include <asm/e820.h>
28106 @@ -17,6 +18,8 @@
28107 #include <asm/proto.h>
28108 #include <asm/dma.h> /* for MAX_DMA_PFN */
28109 #include <asm/microcode.h>
28110 +#include <asm/desc.h>
28111 +#include <asm/bios_ebda.h>
28112
28113 #include "mm_internal.h"
28114
28115 @@ -465,7 +468,15 @@ void __init init_mem_mapping(void)
28116 early_ioremap_page_table_range_init();
28117 #endif
28118
28119 +#ifdef CONFIG_PAX_PER_CPU_PGD
28120 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28121 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28122 + KERNEL_PGD_PTRS);
28123 + load_cr3(get_cpu_pgd(0));
28124 +#else
28125 load_cr3(swapper_pg_dir);
28126 +#endif
28127 +
28128 __flush_tlb_all();
28129
28130 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
28131 @@ -481,10 +492,40 @@ void __init init_mem_mapping(void)
28132 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28133 * mmio resources as well as potential bios/acpi data regions.
28134 */
28135 +
28136 +#ifdef CONFIG_GRKERNSEC_KMEM
28137 +static unsigned int ebda_start __read_only;
28138 +static unsigned int ebda_end __read_only;
28139 +#endif
28140 +
28141 int devmem_is_allowed(unsigned long pagenr)
28142 {
28143 - if (pagenr < 256)
28144 +#ifdef CONFIG_GRKERNSEC_KMEM
28145 + /* allow BDA */
28146 + if (!pagenr)
28147 return 1;
28148 + /* allow EBDA */
28149 + if (pagenr >= ebda_start && pagenr < ebda_end)
28150 + return 1;
28151 + /* if tboot is in use, allow access to its hardcoded serial log range */
28152 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28153 + return 1;
28154 +#else
28155 + if (!pagenr)
28156 + return 1;
28157 +#ifdef CONFIG_VM86
28158 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28159 + return 1;
28160 +#endif
28161 +#endif
28162 +
28163 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28164 + return 1;
28165 +#ifdef CONFIG_GRKERNSEC_KMEM
28166 + /* throw out everything else below 1MB */
28167 + if (pagenr <= 256)
28168 + return 0;
28169 +#endif
28170 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28171 return 0;
28172 if (!page_is_ram(pagenr))
28173 @@ -538,8 +579,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28174 #endif
28175 }
28176
28177 +#ifdef CONFIG_GRKERNSEC_KMEM
28178 +static inline void gr_init_ebda(void)
28179 +{
28180 + unsigned int ebda_addr;
28181 + unsigned int ebda_size = 0;
28182 +
28183 + ebda_addr = get_bios_ebda();
28184 + if (ebda_addr) {
28185 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28186 + ebda_size <<= 10;
28187 + }
28188 + if (ebda_addr && ebda_size) {
28189 + ebda_start = ebda_addr >> PAGE_SHIFT;
28190 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28191 + } else {
28192 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28193 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28194 + }
28195 +}
28196 +#else
28197 +static inline void gr_init_ebda(void) { }
28198 +#endif
28199 +
28200 void free_initmem(void)
28201 {
28202 +#ifdef CONFIG_PAX_KERNEXEC
28203 +#ifdef CONFIG_X86_32
28204 + /* PaX: limit KERNEL_CS to actual size */
28205 + unsigned long addr, limit;
28206 + struct desc_struct d;
28207 + int cpu;
28208 +#else
28209 + pgd_t *pgd;
28210 + pud_t *pud;
28211 + pmd_t *pmd;
28212 + unsigned long addr, end;
28213 +#endif
28214 +#endif
28215 +
28216 + gr_init_ebda();
28217 +
28218 +#ifdef CONFIG_PAX_KERNEXEC
28219 +#ifdef CONFIG_X86_32
28220 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28221 + limit = (limit - 1UL) >> PAGE_SHIFT;
28222 +
28223 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28224 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28225 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28226 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28227 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28228 + }
28229 +
28230 + /* PaX: make KERNEL_CS read-only */
28231 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28232 + if (!paravirt_enabled())
28233 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28234 +/*
28235 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28236 + pgd = pgd_offset_k(addr);
28237 + pud = pud_offset(pgd, addr);
28238 + pmd = pmd_offset(pud, addr);
28239 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28240 + }
28241 +*/
28242 +#ifdef CONFIG_X86_PAE
28243 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28244 +/*
28245 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28246 + pgd = pgd_offset_k(addr);
28247 + pud = pud_offset(pgd, addr);
28248 + pmd = pmd_offset(pud, addr);
28249 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28250 + }
28251 +*/
28252 +#endif
28253 +
28254 +#ifdef CONFIG_MODULES
28255 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28256 +#endif
28257 +
28258 +#else
28259 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28260 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28261 + pgd = pgd_offset_k(addr);
28262 + pud = pud_offset(pgd, addr);
28263 + pmd = pmd_offset(pud, addr);
28264 + if (!pmd_present(*pmd))
28265 + continue;
28266 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28267 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28268 + else
28269 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28270 + }
28271 +
28272 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28273 + end = addr + KERNEL_IMAGE_SIZE;
28274 + for (; addr < end; addr += PMD_SIZE) {
28275 + pgd = pgd_offset_k(addr);
28276 + pud = pud_offset(pgd, addr);
28277 + pmd = pmd_offset(pud, addr);
28278 + if (!pmd_present(*pmd))
28279 + continue;
28280 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28281 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28282 + }
28283 +#endif
28284 +
28285 + flush_tlb_all();
28286 +#endif
28287 +
28288 free_init_pages("unused kernel memory",
28289 (unsigned long)(&__init_begin),
28290 (unsigned long)(&__init_end));
28291 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28292 index 3ac7e31..89611b7 100644
28293 --- a/arch/x86/mm/init_32.c
28294 +++ b/arch/x86/mm/init_32.c
28295 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28296 bool __read_mostly __vmalloc_start_set = false;
28297
28298 /*
28299 - * Creates a middle page table and puts a pointer to it in the
28300 - * given global directory entry. This only returns the gd entry
28301 - * in non-PAE compilation mode, since the middle layer is folded.
28302 - */
28303 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28304 -{
28305 - pud_t *pud;
28306 - pmd_t *pmd_table;
28307 -
28308 -#ifdef CONFIG_X86_PAE
28309 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28310 - pmd_table = (pmd_t *)alloc_low_page();
28311 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28312 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28313 - pud = pud_offset(pgd, 0);
28314 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28315 -
28316 - return pmd_table;
28317 - }
28318 -#endif
28319 - pud = pud_offset(pgd, 0);
28320 - pmd_table = pmd_offset(pud, 0);
28321 -
28322 - return pmd_table;
28323 -}
28324 -
28325 -/*
28326 * Create a page table and place a pointer to it in a middle page
28327 * directory entry:
28328 */
28329 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28330 pte_t *page_table = (pte_t *)alloc_low_page();
28331
28332 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28333 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28334 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28335 +#else
28336 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28337 +#endif
28338 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28339 }
28340
28341 return pte_offset_kernel(pmd, 0);
28342 }
28343
28344 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28345 +{
28346 + pud_t *pud;
28347 + pmd_t *pmd_table;
28348 +
28349 + pud = pud_offset(pgd, 0);
28350 + pmd_table = pmd_offset(pud, 0);
28351 +
28352 + return pmd_table;
28353 +}
28354 +
28355 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28356 {
28357 int pgd_idx = pgd_index(vaddr);
28358 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28359 int pgd_idx, pmd_idx;
28360 unsigned long vaddr;
28361 pgd_t *pgd;
28362 + pud_t *pud;
28363 pmd_t *pmd;
28364 pte_t *pte = NULL;
28365 unsigned long count = page_table_range_init_count(start, end);
28366 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28367 pgd = pgd_base + pgd_idx;
28368
28369 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28370 - pmd = one_md_table_init(pgd);
28371 - pmd = pmd + pmd_index(vaddr);
28372 + pud = pud_offset(pgd, vaddr);
28373 + pmd = pmd_offset(pud, vaddr);
28374 +
28375 +#ifdef CONFIG_X86_PAE
28376 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28377 +#endif
28378 +
28379 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28380 pmd++, pmd_idx++) {
28381 pte = page_table_kmap_check(one_page_table_init(pmd),
28382 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28383 }
28384 }
28385
28386 -static inline int is_kernel_text(unsigned long addr)
28387 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28388 {
28389 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28390 - return 1;
28391 - return 0;
28392 + if ((start > ktla_ktva((unsigned long)_etext) ||
28393 + end <= ktla_ktva((unsigned long)_stext)) &&
28394 + (start > ktla_ktva((unsigned long)_einittext) ||
28395 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28396 +
28397 +#ifdef CONFIG_ACPI_SLEEP
28398 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28399 +#endif
28400 +
28401 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28402 + return 0;
28403 + return 1;
28404 }
28405
28406 /*
28407 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28408 unsigned long last_map_addr = end;
28409 unsigned long start_pfn, end_pfn;
28410 pgd_t *pgd_base = swapper_pg_dir;
28411 - int pgd_idx, pmd_idx, pte_ofs;
28412 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28413 unsigned long pfn;
28414 pgd_t *pgd;
28415 + pud_t *pud;
28416 pmd_t *pmd;
28417 pte_t *pte;
28418 unsigned pages_2m, pages_4k;
28419 @@ -291,8 +295,13 @@ repeat:
28420 pfn = start_pfn;
28421 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28422 pgd = pgd_base + pgd_idx;
28423 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28424 - pmd = one_md_table_init(pgd);
28425 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28426 + pud = pud_offset(pgd, 0);
28427 + pmd = pmd_offset(pud, 0);
28428 +
28429 +#ifdef CONFIG_X86_PAE
28430 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28431 +#endif
28432
28433 if (pfn >= end_pfn)
28434 continue;
28435 @@ -304,14 +313,13 @@ repeat:
28436 #endif
28437 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28438 pmd++, pmd_idx++) {
28439 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28440 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28441
28442 /*
28443 * Map with big pages if possible, otherwise
28444 * create normal page tables:
28445 */
28446 if (use_pse) {
28447 - unsigned int addr2;
28448 pgprot_t prot = PAGE_KERNEL_LARGE;
28449 /*
28450 * first pass will use the same initial
28451 @@ -322,11 +330,7 @@ repeat:
28452 _PAGE_PSE);
28453
28454 pfn &= PMD_MASK >> PAGE_SHIFT;
28455 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28456 - PAGE_OFFSET + PAGE_SIZE-1;
28457 -
28458 - if (is_kernel_text(addr) ||
28459 - is_kernel_text(addr2))
28460 + if (is_kernel_text(address, address + PMD_SIZE))
28461 prot = PAGE_KERNEL_LARGE_EXEC;
28462
28463 pages_2m++;
28464 @@ -343,7 +347,7 @@ repeat:
28465 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28466 pte += pte_ofs;
28467 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28468 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28469 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28470 pgprot_t prot = PAGE_KERNEL;
28471 /*
28472 * first pass will use the same initial
28473 @@ -351,7 +355,7 @@ repeat:
28474 */
28475 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28476
28477 - if (is_kernel_text(addr))
28478 + if (is_kernel_text(address, address + PAGE_SIZE))
28479 prot = PAGE_KERNEL_EXEC;
28480
28481 pages_4k++;
28482 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
28483
28484 pud = pud_offset(pgd, va);
28485 pmd = pmd_offset(pud, va);
28486 - if (!pmd_present(*pmd))
28487 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28488 break;
28489
28490 /* should not be large page here */
28491 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
28492
28493 static void __init pagetable_init(void)
28494 {
28495 - pgd_t *pgd_base = swapper_pg_dir;
28496 -
28497 - permanent_kmaps_init(pgd_base);
28498 + permanent_kmaps_init(swapper_pg_dir);
28499 }
28500
28501 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28502 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28503 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28504
28505 /* user-defined highmem size */
28506 @@ -772,7 +774,7 @@ void __init mem_init(void)
28507 after_bootmem = 1;
28508
28509 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28510 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28511 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28512 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28513
28514 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28515 @@ -813,10 +815,10 @@ void __init mem_init(void)
28516 ((unsigned long)&__init_end -
28517 (unsigned long)&__init_begin) >> 10,
28518
28519 - (unsigned long)&_etext, (unsigned long)&_edata,
28520 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28521 + (unsigned long)&_sdata, (unsigned long)&_edata,
28522 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28523
28524 - (unsigned long)&_text, (unsigned long)&_etext,
28525 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28526 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28527
28528 /*
28529 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
28530 if (!kernel_set_to_readonly)
28531 return;
28532
28533 + start = ktla_ktva(start);
28534 pr_debug("Set kernel text: %lx - %lx for read write\n",
28535 start, start+size);
28536
28537 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
28538 if (!kernel_set_to_readonly)
28539 return;
28540
28541 + start = ktla_ktva(start);
28542 pr_debug("Set kernel text: %lx - %lx for read only\n",
28543 start, start+size);
28544
28545 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
28546 unsigned long start = PFN_ALIGN(_text);
28547 unsigned long size = PFN_ALIGN(_etext) - start;
28548
28549 + start = ktla_ktva(start);
28550 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28551 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28552 size >> 10);
28553 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28554 index bb00c46..f31d2f0 100644
28555 --- a/arch/x86/mm/init_64.c
28556 +++ b/arch/x86/mm/init_64.c
28557 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28558 * around without checking the pgd every time.
28559 */
28560
28561 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28562 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28563 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28564
28565 int force_personality32;
28566 @@ -184,12 +184,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28567
28568 for (address = start; address <= end; address += PGDIR_SIZE) {
28569 const pgd_t *pgd_ref = pgd_offset_k(address);
28570 +
28571 +#ifdef CONFIG_PAX_PER_CPU_PGD
28572 + unsigned long cpu;
28573 +#else
28574 struct page *page;
28575 +#endif
28576
28577 if (pgd_none(*pgd_ref))
28578 continue;
28579
28580 spin_lock(&pgd_lock);
28581 +
28582 +#ifdef CONFIG_PAX_PER_CPU_PGD
28583 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28584 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28585 +#else
28586 list_for_each_entry(page, &pgd_list, lru) {
28587 pgd_t *pgd;
28588 spinlock_t *pgt_lock;
28589 @@ -198,6 +208,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28590 /* the pgt_lock only for Xen */
28591 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28592 spin_lock(pgt_lock);
28593 +#endif
28594
28595 if (pgd_none(*pgd))
28596 set_pgd(pgd, *pgd_ref);
28597 @@ -205,7 +216,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28598 BUG_ON(pgd_page_vaddr(*pgd)
28599 != pgd_page_vaddr(*pgd_ref));
28600
28601 +#ifndef CONFIG_PAX_PER_CPU_PGD
28602 spin_unlock(pgt_lock);
28603 +#endif
28604 +
28605 }
28606 spin_unlock(&pgd_lock);
28607 }
28608 @@ -238,7 +252,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28609 {
28610 if (pgd_none(*pgd)) {
28611 pud_t *pud = (pud_t *)spp_getpage();
28612 - pgd_populate(&init_mm, pgd, pud);
28613 + pgd_populate_kernel(&init_mm, pgd, pud);
28614 if (pud != pud_offset(pgd, 0))
28615 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28616 pud, pud_offset(pgd, 0));
28617 @@ -250,7 +264,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28618 {
28619 if (pud_none(*pud)) {
28620 pmd_t *pmd = (pmd_t *) spp_getpage();
28621 - pud_populate(&init_mm, pud, pmd);
28622 + pud_populate_kernel(&init_mm, pud, pmd);
28623 if (pmd != pmd_offset(pud, 0))
28624 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28625 pmd, pmd_offset(pud, 0));
28626 @@ -279,7 +293,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28627 pmd = fill_pmd(pud, vaddr);
28628 pte = fill_pte(pmd, vaddr);
28629
28630 + pax_open_kernel();
28631 set_pte(pte, new_pte);
28632 + pax_close_kernel();
28633
28634 /*
28635 * It's enough to flush this one mapping.
28636 @@ -338,14 +354,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28637 pgd = pgd_offset_k((unsigned long)__va(phys));
28638 if (pgd_none(*pgd)) {
28639 pud = (pud_t *) spp_getpage();
28640 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28641 - _PAGE_USER));
28642 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28643 }
28644 pud = pud_offset(pgd, (unsigned long)__va(phys));
28645 if (pud_none(*pud)) {
28646 pmd = (pmd_t *) spp_getpage();
28647 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28648 - _PAGE_USER));
28649 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28650 }
28651 pmd = pmd_offset(pud, phys);
28652 BUG_ON(!pmd_none(*pmd));
28653 @@ -586,7 +600,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28654 prot);
28655
28656 spin_lock(&init_mm.page_table_lock);
28657 - pud_populate(&init_mm, pud, pmd);
28658 + pud_populate_kernel(&init_mm, pud, pmd);
28659 spin_unlock(&init_mm.page_table_lock);
28660 }
28661 __flush_tlb_all();
28662 @@ -627,7 +641,7 @@ kernel_physical_mapping_init(unsigned long start,
28663 page_size_mask);
28664
28665 spin_lock(&init_mm.page_table_lock);
28666 - pgd_populate(&init_mm, pgd, pud);
28667 + pgd_populate_kernel(&init_mm, pgd, pud);
28668 spin_unlock(&init_mm.page_table_lock);
28669 pgd_changed = true;
28670 }
28671 @@ -1221,8 +1235,8 @@ int kern_addr_valid(unsigned long addr)
28672 static struct vm_area_struct gate_vma = {
28673 .vm_start = VSYSCALL_START,
28674 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28675 - .vm_page_prot = PAGE_READONLY_EXEC,
28676 - .vm_flags = VM_READ | VM_EXEC
28677 + .vm_page_prot = PAGE_READONLY,
28678 + .vm_flags = VM_READ
28679 };
28680
28681 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28682 @@ -1256,7 +1270,7 @@ int in_gate_area_no_mm(unsigned long addr)
28683
28684 const char *arch_vma_name(struct vm_area_struct *vma)
28685 {
28686 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28687 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28688 return "[vdso]";
28689 if (vma == &gate_vma)
28690 return "[vsyscall]";
28691 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28692 index 7b179b4..6bd17777 100644
28693 --- a/arch/x86/mm/iomap_32.c
28694 +++ b/arch/x86/mm/iomap_32.c
28695 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28696 type = kmap_atomic_idx_push();
28697 idx = type + KM_TYPE_NR * smp_processor_id();
28698 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28699 +
28700 + pax_open_kernel();
28701 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28702 + pax_close_kernel();
28703 +
28704 arch_flush_lazy_mmu_mode();
28705
28706 return (void *)vaddr;
28707 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28708 index 9a1e658..da003f3 100644
28709 --- a/arch/x86/mm/ioremap.c
28710 +++ b/arch/x86/mm/ioremap.c
28711 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28712 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28713 int is_ram = page_is_ram(pfn);
28714
28715 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28716 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28717 return NULL;
28718 WARN_ON_ONCE(is_ram);
28719 }
28720 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28721 *
28722 * Caller must ensure there is only one unmapping for the same pointer.
28723 */
28724 -void iounmap(volatile void __iomem *addr)
28725 +void iounmap(const volatile void __iomem *addr)
28726 {
28727 struct vm_struct *p, *o;
28728
28729 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28730
28731 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28732 if (page_is_ram(start >> PAGE_SHIFT))
28733 +#ifdef CONFIG_HIGHMEM
28734 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28735 +#endif
28736 return __va(phys);
28737
28738 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28739 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28740 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28741 {
28742 if (page_is_ram(phys >> PAGE_SHIFT))
28743 +#ifdef CONFIG_HIGHMEM
28744 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28745 +#endif
28746 return;
28747
28748 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28749 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
28750 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28751
28752 static __initdata int after_paging_init;
28753 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28754 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28755
28756 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28757 {
28758 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
28759 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28760
28761 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28762 - memset(bm_pte, 0, sizeof(bm_pte));
28763 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28764 + pmd_populate_user(&init_mm, pmd, bm_pte);
28765
28766 /*
28767 * The boot-ioremap range spans multiple pmds, for which
28768 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28769 index d87dd6d..bf3fa66 100644
28770 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28771 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28772 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28773 * memory (e.g. tracked pages)? For now, we need this to avoid
28774 * invoking kmemcheck for PnP BIOS calls.
28775 */
28776 - if (regs->flags & X86_VM_MASK)
28777 + if (v8086_mode(regs))
28778 return false;
28779 - if (regs->cs != __KERNEL_CS)
28780 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28781 return false;
28782
28783 pte = kmemcheck_pte_lookup(address);
28784 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28785 index 845df68..1d8d29f 100644
28786 --- a/arch/x86/mm/mmap.c
28787 +++ b/arch/x86/mm/mmap.c
28788 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28789 * Leave an at least ~128 MB hole with possible stack randomization.
28790 */
28791 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28792 -#define MAX_GAP (TASK_SIZE/6*5)
28793 +#define MAX_GAP (pax_task_size/6*5)
28794
28795 static int mmap_is_legacy(void)
28796 {
28797 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28798 return rnd << PAGE_SHIFT;
28799 }
28800
28801 -static unsigned long mmap_base(void)
28802 +static unsigned long mmap_base(struct mm_struct *mm)
28803 {
28804 unsigned long gap = rlimit(RLIMIT_STACK);
28805 + unsigned long pax_task_size = TASK_SIZE;
28806 +
28807 +#ifdef CONFIG_PAX_SEGMEXEC
28808 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28809 + pax_task_size = SEGMEXEC_TASK_SIZE;
28810 +#endif
28811
28812 if (gap < MIN_GAP)
28813 gap = MIN_GAP;
28814 else if (gap > MAX_GAP)
28815 gap = MAX_GAP;
28816
28817 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28818 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28819 }
28820
28821 /*
28822 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28823 * does, but not when emulating X86_32
28824 */
28825 -static unsigned long mmap_legacy_base(void)
28826 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28827 {
28828 - if (mmap_is_ia32())
28829 + if (mmap_is_ia32()) {
28830 +
28831 +#ifdef CONFIG_PAX_SEGMEXEC
28832 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28833 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28834 + else
28835 +#endif
28836 +
28837 return TASK_UNMAPPED_BASE;
28838 - else
28839 + } else
28840 return TASK_UNMAPPED_BASE + mmap_rnd();
28841 }
28842
28843 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28844 void arch_pick_mmap_layout(struct mm_struct *mm)
28845 {
28846 if (mmap_is_legacy()) {
28847 - mm->mmap_base = mmap_legacy_base();
28848 + mm->mmap_base = mmap_legacy_base(mm);
28849 +
28850 +#ifdef CONFIG_PAX_RANDMMAP
28851 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28852 + mm->mmap_base += mm->delta_mmap;
28853 +#endif
28854 +
28855 mm->get_unmapped_area = arch_get_unmapped_area;
28856 mm->unmap_area = arch_unmap_area;
28857 } else {
28858 - mm->mmap_base = mmap_base();
28859 + mm->mmap_base = mmap_base(mm);
28860 +
28861 +#ifdef CONFIG_PAX_RANDMMAP
28862 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28863 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28864 +#endif
28865 +
28866 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28867 mm->unmap_area = arch_unmap_area_topdown;
28868 }
28869 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28870 index dc0b727..f612039 100644
28871 --- a/arch/x86/mm/mmio-mod.c
28872 +++ b/arch/x86/mm/mmio-mod.c
28873 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28874 break;
28875 default:
28876 {
28877 - unsigned char *ip = (unsigned char *)instptr;
28878 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28879 my_trace->opcode = MMIO_UNKNOWN_OP;
28880 my_trace->width = 0;
28881 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28882 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28883 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28884 void __iomem *addr)
28885 {
28886 - static atomic_t next_id;
28887 + static atomic_unchecked_t next_id;
28888 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28889 /* These are page-unaligned. */
28890 struct mmiotrace_map map = {
28891 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28892 .private = trace
28893 },
28894 .phys = offset,
28895 - .id = atomic_inc_return(&next_id)
28896 + .id = atomic_inc_return_unchecked(&next_id)
28897 };
28898 map.map_id = trace->id;
28899
28900 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28901 ioremap_trace_core(offset, size, addr);
28902 }
28903
28904 -static void iounmap_trace_core(volatile void __iomem *addr)
28905 +static void iounmap_trace_core(const volatile void __iomem *addr)
28906 {
28907 struct mmiotrace_map map = {
28908 .phys = 0,
28909 @@ -328,7 +328,7 @@ not_enabled:
28910 }
28911 }
28912
28913 -void mmiotrace_iounmap(volatile void __iomem *addr)
28914 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28915 {
28916 might_sleep();
28917 if (is_enabled()) /* recheck and proper locking in *_core() */
28918 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28919 index a71c4e2..301ae44 100644
28920 --- a/arch/x86/mm/numa.c
28921 +++ b/arch/x86/mm/numa.c
28922 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28923 return true;
28924 }
28925
28926 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28927 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28928 {
28929 unsigned long uninitialized_var(pfn_align);
28930 int i, nid;
28931 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28932 index d0b1773..4c3327c 100644
28933 --- a/arch/x86/mm/pageattr-test.c
28934 +++ b/arch/x86/mm/pageattr-test.c
28935 @@ -36,7 +36,7 @@ enum {
28936
28937 static int pte_testbit(pte_t pte)
28938 {
28939 - return pte_flags(pte) & _PAGE_UNUSED1;
28940 + return pte_flags(pte) & _PAGE_CPA_TEST;
28941 }
28942
28943 struct split_state {
28944 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28945 index bb32480..aef8278 100644
28946 --- a/arch/x86/mm/pageattr.c
28947 +++ b/arch/x86/mm/pageattr.c
28948 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28949 */
28950 #ifdef CONFIG_PCI_BIOS
28951 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28952 - pgprot_val(forbidden) |= _PAGE_NX;
28953 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28954 #endif
28955
28956 /*
28957 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28958 * Does not cover __inittext since that is gone later on. On
28959 * 64bit we do not enforce !NX on the low mapping
28960 */
28961 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28962 - pgprot_val(forbidden) |= _PAGE_NX;
28963 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28964 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28965
28966 +#ifdef CONFIG_DEBUG_RODATA
28967 /*
28968 * The .rodata section needs to be read-only. Using the pfn
28969 * catches all aliases.
28970 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28971 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28972 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28973 pgprot_val(forbidden) |= _PAGE_RW;
28974 +#endif
28975
28976 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28977 /*
28978 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28979 }
28980 #endif
28981
28982 +#ifdef CONFIG_PAX_KERNEXEC
28983 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28984 + pgprot_val(forbidden) |= _PAGE_RW;
28985 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28986 + }
28987 +#endif
28988 +
28989 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28990
28991 return prot;
28992 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28993 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28994 {
28995 /* change init_mm */
28996 + pax_open_kernel();
28997 set_pte_atomic(kpte, pte);
28998 +
28999 #ifdef CONFIG_X86_32
29000 if (!SHARED_KERNEL_PMD) {
29001 +
29002 +#ifdef CONFIG_PAX_PER_CPU_PGD
29003 + unsigned long cpu;
29004 +#else
29005 struct page *page;
29006 +#endif
29007
29008 +#ifdef CONFIG_PAX_PER_CPU_PGD
29009 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29010 + pgd_t *pgd = get_cpu_pgd(cpu);
29011 +#else
29012 list_for_each_entry(page, &pgd_list, lru) {
29013 - pgd_t *pgd;
29014 + pgd_t *pgd = (pgd_t *)page_address(page);
29015 +#endif
29016 +
29017 pud_t *pud;
29018 pmd_t *pmd;
29019
29020 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29021 + pgd += pgd_index(address);
29022 pud = pud_offset(pgd, address);
29023 pmd = pmd_offset(pud, address);
29024 set_pte_atomic((pte_t *)pmd, pte);
29025 }
29026 }
29027 #endif
29028 + pax_close_kernel();
29029 }
29030
29031 static int
29032 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29033 index 6574388..87e9bef 100644
29034 --- a/arch/x86/mm/pat.c
29035 +++ b/arch/x86/mm/pat.c
29036 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29037
29038 if (!entry) {
29039 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29040 - current->comm, current->pid, start, end - 1);
29041 + current->comm, task_pid_nr(current), start, end - 1);
29042 return -EINVAL;
29043 }
29044
29045 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29046
29047 while (cursor < to) {
29048 if (!devmem_is_allowed(pfn)) {
29049 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29050 - current->comm, from, to - 1);
29051 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29052 + current->comm, from, to - 1, cursor);
29053 return 0;
29054 }
29055 cursor += PAGE_SIZE;
29056 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29057 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29058 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29059 "for [mem %#010Lx-%#010Lx]\n",
29060 - current->comm, current->pid,
29061 + current->comm, task_pid_nr(current),
29062 cattr_name(flags),
29063 base, (unsigned long long)(base + size-1));
29064 return -EINVAL;
29065 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29066 flags = lookup_memtype(paddr);
29067 if (want_flags != flags) {
29068 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29069 - current->comm, current->pid,
29070 + current->comm, task_pid_nr(current),
29071 cattr_name(want_flags),
29072 (unsigned long long)paddr,
29073 (unsigned long long)(paddr + size - 1),
29074 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29075 free_memtype(paddr, paddr + size);
29076 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29077 " for [mem %#010Lx-%#010Lx], got %s\n",
29078 - current->comm, current->pid,
29079 + current->comm, task_pid_nr(current),
29080 cattr_name(want_flags),
29081 (unsigned long long)paddr,
29082 (unsigned long long)(paddr + size - 1),
29083 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
29084 index 415f6c4..d319983 100644
29085 --- a/arch/x86/mm/pat_rbtree.c
29086 +++ b/arch/x86/mm/pat_rbtree.c
29087 @@ -160,7 +160,7 @@ success:
29088
29089 failure:
29090 printk(KERN_INFO "%s:%d conflicting memory types "
29091 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
29092 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
29093 end, cattr_name(found_type), cattr_name(match->type));
29094 return -EBUSY;
29095 }
29096 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29097 index 9f0614d..92ae64a 100644
29098 --- a/arch/x86/mm/pf_in.c
29099 +++ b/arch/x86/mm/pf_in.c
29100 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29101 int i;
29102 enum reason_type rv = OTHERS;
29103
29104 - p = (unsigned char *)ins_addr;
29105 + p = (unsigned char *)ktla_ktva(ins_addr);
29106 p += skip_prefix(p, &prf);
29107 p += get_opcode(p, &opcode);
29108
29109 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29110 struct prefix_bits prf;
29111 int i;
29112
29113 - p = (unsigned char *)ins_addr;
29114 + p = (unsigned char *)ktla_ktva(ins_addr);
29115 p += skip_prefix(p, &prf);
29116 p += get_opcode(p, &opcode);
29117
29118 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29119 struct prefix_bits prf;
29120 int i;
29121
29122 - p = (unsigned char *)ins_addr;
29123 + p = (unsigned char *)ktla_ktva(ins_addr);
29124 p += skip_prefix(p, &prf);
29125 p += get_opcode(p, &opcode);
29126
29127 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29128 struct prefix_bits prf;
29129 int i;
29130
29131 - p = (unsigned char *)ins_addr;
29132 + p = (unsigned char *)ktla_ktva(ins_addr);
29133 p += skip_prefix(p, &prf);
29134 p += get_opcode(p, &opcode);
29135 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29136 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29137 struct prefix_bits prf;
29138 int i;
29139
29140 - p = (unsigned char *)ins_addr;
29141 + p = (unsigned char *)ktla_ktva(ins_addr);
29142 p += skip_prefix(p, &prf);
29143 p += get_opcode(p, &opcode);
29144 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29145 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29146 index 17fda6a..489c74a 100644
29147 --- a/arch/x86/mm/pgtable.c
29148 +++ b/arch/x86/mm/pgtable.c
29149 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29150 list_del(&page->lru);
29151 }
29152
29153 -#define UNSHARED_PTRS_PER_PGD \
29154 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29155 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29156 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29157
29158 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29159 +{
29160 + unsigned int count = USER_PGD_PTRS;
29161
29162 + while (count--)
29163 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29164 +}
29165 +#endif
29166 +
29167 +#ifdef CONFIG_PAX_PER_CPU_PGD
29168 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29169 +{
29170 + unsigned int count = USER_PGD_PTRS;
29171 +
29172 + while (count--) {
29173 + pgd_t pgd;
29174 +
29175 +#ifdef CONFIG_X86_64
29176 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29177 +#else
29178 + pgd = *src++;
29179 +#endif
29180 +
29181 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29182 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29183 +#endif
29184 +
29185 + *dst++ = pgd;
29186 + }
29187 +
29188 +}
29189 +#endif
29190 +
29191 +#ifdef CONFIG_X86_64
29192 +#define pxd_t pud_t
29193 +#define pyd_t pgd_t
29194 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29195 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29196 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29197 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29198 +#define PYD_SIZE PGDIR_SIZE
29199 +#else
29200 +#define pxd_t pmd_t
29201 +#define pyd_t pud_t
29202 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29203 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29204 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29205 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29206 +#define PYD_SIZE PUD_SIZE
29207 +#endif
29208 +
29209 +#ifdef CONFIG_PAX_PER_CPU_PGD
29210 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29211 +static inline void pgd_dtor(pgd_t *pgd) {}
29212 +#else
29213 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29214 {
29215 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29216 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29217 pgd_list_del(pgd);
29218 spin_unlock(&pgd_lock);
29219 }
29220 +#endif
29221
29222 /*
29223 * List of all pgd's needed for non-PAE so it can invalidate entries
29224 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29225 * -- nyc
29226 */
29227
29228 -#ifdef CONFIG_X86_PAE
29229 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29230 /*
29231 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29232 * updating the top-level pagetable entries to guarantee the
29233 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29234 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29235 * and initialize the kernel pmds here.
29236 */
29237 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29238 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29239
29240 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29241 {
29242 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29243 */
29244 flush_tlb_mm(mm);
29245 }
29246 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29247 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29248 #else /* !CONFIG_X86_PAE */
29249
29250 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29251 -#define PREALLOCATED_PMDS 0
29252 +#define PREALLOCATED_PXDS 0
29253
29254 #endif /* CONFIG_X86_PAE */
29255
29256 -static void free_pmds(pmd_t *pmds[])
29257 +static void free_pxds(pxd_t *pxds[])
29258 {
29259 int i;
29260
29261 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29262 - if (pmds[i])
29263 - free_page((unsigned long)pmds[i]);
29264 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29265 + if (pxds[i])
29266 + free_page((unsigned long)pxds[i]);
29267 }
29268
29269 -static int preallocate_pmds(pmd_t *pmds[])
29270 +static int preallocate_pxds(pxd_t *pxds[])
29271 {
29272 int i;
29273 bool failed = false;
29274
29275 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29276 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29277 - if (pmd == NULL)
29278 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29279 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29280 + if (pxd == NULL)
29281 failed = true;
29282 - pmds[i] = pmd;
29283 + pxds[i] = pxd;
29284 }
29285
29286 if (failed) {
29287 - free_pmds(pmds);
29288 + free_pxds(pxds);
29289 return -ENOMEM;
29290 }
29291
29292 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29293 * preallocate which never got a corresponding vma will need to be
29294 * freed manually.
29295 */
29296 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29297 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29298 {
29299 int i;
29300
29301 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29302 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29303 pgd_t pgd = pgdp[i];
29304
29305 if (pgd_val(pgd) != 0) {
29306 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29307 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29308
29309 - pgdp[i] = native_make_pgd(0);
29310 + set_pgd(pgdp + i, native_make_pgd(0));
29311
29312 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29313 - pmd_free(mm, pmd);
29314 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29315 + pxd_free(mm, pxd);
29316 }
29317 }
29318 }
29319
29320 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29321 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29322 {
29323 - pud_t *pud;
29324 + pyd_t *pyd;
29325 unsigned long addr;
29326 int i;
29327
29328 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29329 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29330 return;
29331
29332 - pud = pud_offset(pgd, 0);
29333 +#ifdef CONFIG_X86_64
29334 + pyd = pyd_offset(mm, 0L);
29335 +#else
29336 + pyd = pyd_offset(pgd, 0L);
29337 +#endif
29338
29339 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29340 - i++, pud++, addr += PUD_SIZE) {
29341 - pmd_t *pmd = pmds[i];
29342 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29343 + i++, pyd++, addr += PYD_SIZE) {
29344 + pxd_t *pxd = pxds[i];
29345
29346 if (i >= KERNEL_PGD_BOUNDARY)
29347 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29348 - sizeof(pmd_t) * PTRS_PER_PMD);
29349 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29350 + sizeof(pxd_t) * PTRS_PER_PMD);
29351
29352 - pud_populate(mm, pud, pmd);
29353 + pyd_populate(mm, pyd, pxd);
29354 }
29355 }
29356
29357 pgd_t *pgd_alloc(struct mm_struct *mm)
29358 {
29359 pgd_t *pgd;
29360 - pmd_t *pmds[PREALLOCATED_PMDS];
29361 + pxd_t *pxds[PREALLOCATED_PXDS];
29362
29363 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29364
29365 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29366
29367 mm->pgd = pgd;
29368
29369 - if (preallocate_pmds(pmds) != 0)
29370 + if (preallocate_pxds(pxds) != 0)
29371 goto out_free_pgd;
29372
29373 if (paravirt_pgd_alloc(mm) != 0)
29374 - goto out_free_pmds;
29375 + goto out_free_pxds;
29376
29377 /*
29378 * Make sure that pre-populating the pmds is atomic with
29379 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29380 spin_lock(&pgd_lock);
29381
29382 pgd_ctor(mm, pgd);
29383 - pgd_prepopulate_pmd(mm, pgd, pmds);
29384 + pgd_prepopulate_pxd(mm, pgd, pxds);
29385
29386 spin_unlock(&pgd_lock);
29387
29388 return pgd;
29389
29390 -out_free_pmds:
29391 - free_pmds(pmds);
29392 +out_free_pxds:
29393 + free_pxds(pxds);
29394 out_free_pgd:
29395 free_page((unsigned long)pgd);
29396 out:
29397 @@ -302,7 +363,7 @@ out:
29398
29399 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29400 {
29401 - pgd_mop_up_pmds(mm, pgd);
29402 + pgd_mop_up_pxds(mm, pgd);
29403 pgd_dtor(pgd);
29404 paravirt_pgd_free(mm, pgd);
29405 free_page((unsigned long)pgd);
29406 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29407 index a69bcb8..19068ab 100644
29408 --- a/arch/x86/mm/pgtable_32.c
29409 +++ b/arch/x86/mm/pgtable_32.c
29410 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29411 return;
29412 }
29413 pte = pte_offset_kernel(pmd, vaddr);
29414 +
29415 + pax_open_kernel();
29416 if (pte_val(pteval))
29417 set_pte_at(&init_mm, vaddr, pte, pteval);
29418 else
29419 pte_clear(&init_mm, vaddr, pte);
29420 + pax_close_kernel();
29421
29422 /*
29423 * It's enough to flush this one mapping.
29424 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29425 index e666cbb..61788c45 100644
29426 --- a/arch/x86/mm/physaddr.c
29427 +++ b/arch/x86/mm/physaddr.c
29428 @@ -10,7 +10,7 @@
29429 #ifdef CONFIG_X86_64
29430
29431 #ifdef CONFIG_DEBUG_VIRTUAL
29432 -unsigned long __phys_addr(unsigned long x)
29433 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29434 {
29435 unsigned long y = x - __START_KERNEL_map;
29436
29437 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29438 #else
29439
29440 #ifdef CONFIG_DEBUG_VIRTUAL
29441 -unsigned long __phys_addr(unsigned long x)
29442 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29443 {
29444 unsigned long phys_addr = x - PAGE_OFFSET;
29445 /* VMALLOC_* aren't constants */
29446 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29447 index 410531d..0f16030 100644
29448 --- a/arch/x86/mm/setup_nx.c
29449 +++ b/arch/x86/mm/setup_nx.c
29450 @@ -5,8 +5,10 @@
29451 #include <asm/pgtable.h>
29452 #include <asm/proto.h>
29453
29454 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29455 static int disable_nx __cpuinitdata;
29456
29457 +#ifndef CONFIG_PAX_PAGEEXEC
29458 /*
29459 * noexec = on|off
29460 *
29461 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29462 return 0;
29463 }
29464 early_param("noexec", noexec_setup);
29465 +#endif
29466 +
29467 +#endif
29468
29469 void __cpuinit x86_configure_nx(void)
29470 {
29471 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29472 if (cpu_has_nx && !disable_nx)
29473 __supported_pte_mask |= _PAGE_NX;
29474 else
29475 +#endif
29476 __supported_pte_mask &= ~_PAGE_NX;
29477 }
29478
29479 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29480 index 282375f..e03a98f 100644
29481 --- a/arch/x86/mm/tlb.c
29482 +++ b/arch/x86/mm/tlb.c
29483 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29484 BUG();
29485 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29486 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29487 +
29488 +#ifndef CONFIG_PAX_PER_CPU_PGD
29489 load_cr3(swapper_pg_dir);
29490 +#endif
29491 +
29492 }
29493 }
29494 EXPORT_SYMBOL_GPL(leave_mm);
29495 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29496 index 877b9a1..a8ecf42 100644
29497 --- a/arch/x86/net/bpf_jit.S
29498 +++ b/arch/x86/net/bpf_jit.S
29499 @@ -9,6 +9,7 @@
29500 */
29501 #include <linux/linkage.h>
29502 #include <asm/dwarf2.h>
29503 +#include <asm/alternative-asm.h>
29504
29505 /*
29506 * Calling convention :
29507 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29508 jle bpf_slow_path_word
29509 mov (SKBDATA,%rsi),%eax
29510 bswap %eax /* ntohl() */
29511 + pax_force_retaddr
29512 ret
29513
29514 sk_load_half:
29515 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29516 jle bpf_slow_path_half
29517 movzwl (SKBDATA,%rsi),%eax
29518 rol $8,%ax # ntohs()
29519 + pax_force_retaddr
29520 ret
29521
29522 sk_load_byte:
29523 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29524 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29525 jle bpf_slow_path_byte
29526 movzbl (SKBDATA,%rsi),%eax
29527 + pax_force_retaddr
29528 ret
29529
29530 /**
29531 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29532 movzbl (SKBDATA,%rsi),%ebx
29533 and $15,%bl
29534 shl $2,%bl
29535 + pax_force_retaddr
29536 ret
29537
29538 /* rsi contains offset and can be scratched */
29539 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29540 js bpf_error
29541 mov -12(%rbp),%eax
29542 bswap %eax
29543 + pax_force_retaddr
29544 ret
29545
29546 bpf_slow_path_half:
29547 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29548 mov -12(%rbp),%ax
29549 rol $8,%ax
29550 movzwl %ax,%eax
29551 + pax_force_retaddr
29552 ret
29553
29554 bpf_slow_path_byte:
29555 bpf_slow_path_common(1)
29556 js bpf_error
29557 movzbl -12(%rbp),%eax
29558 + pax_force_retaddr
29559 ret
29560
29561 bpf_slow_path_byte_msh:
29562 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29563 and $15,%al
29564 shl $2,%al
29565 xchg %eax,%ebx
29566 + pax_force_retaddr
29567 ret
29568
29569 #define sk_negative_common(SIZE) \
29570 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29571 sk_negative_common(4)
29572 mov (%rax), %eax
29573 bswap %eax
29574 + pax_force_retaddr
29575 ret
29576
29577 bpf_slow_path_half_neg:
29578 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29579 mov (%rax),%ax
29580 rol $8,%ax
29581 movzwl %ax,%eax
29582 + pax_force_retaddr
29583 ret
29584
29585 bpf_slow_path_byte_neg:
29586 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29587 .globl sk_load_byte_negative_offset
29588 sk_negative_common(1)
29589 movzbl (%rax), %eax
29590 + pax_force_retaddr
29591 ret
29592
29593 bpf_slow_path_byte_msh_neg:
29594 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29595 and $15,%al
29596 shl $2,%al
29597 xchg %eax,%ebx
29598 + pax_force_retaddr
29599 ret
29600
29601 bpf_error:
29602 @@ -197,4 +210,5 @@ bpf_error:
29603 xor %eax,%eax
29604 mov -8(%rbp),%rbx
29605 leaveq
29606 + pax_force_retaddr
29607 ret
29608 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29609 index f66b540..3e88dfb 100644
29610 --- a/arch/x86/net/bpf_jit_comp.c
29611 +++ b/arch/x86/net/bpf_jit_comp.c
29612 @@ -12,6 +12,7 @@
29613 #include <linux/netdevice.h>
29614 #include <linux/filter.h>
29615 #include <linux/if_vlan.h>
29616 +#include <linux/random.h>
29617
29618 /*
29619 * Conventions :
29620 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29621 return ptr + len;
29622 }
29623
29624 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29625 +#define MAX_INSTR_CODE_SIZE 96
29626 +#else
29627 +#define MAX_INSTR_CODE_SIZE 64
29628 +#endif
29629 +
29630 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29631
29632 #define EMIT1(b1) EMIT(b1, 1)
29633 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29634 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29635 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29636 +
29637 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29638 +/* original constant will appear in ecx */
29639 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29640 +do { \
29641 + /* mov ecx, randkey */ \
29642 + EMIT1(0xb9); \
29643 + EMIT(_key, 4); \
29644 + /* xor ecx, randkey ^ off */ \
29645 + EMIT2(0x81, 0xf1); \
29646 + EMIT((_key) ^ (_off), 4); \
29647 +} while (0)
29648 +
29649 +#define EMIT1_off32(b1, _off) \
29650 +do { \
29651 + switch (b1) { \
29652 + case 0x05: /* add eax, imm32 */ \
29653 + case 0x2d: /* sub eax, imm32 */ \
29654 + case 0x25: /* and eax, imm32 */ \
29655 + case 0x0d: /* or eax, imm32 */ \
29656 + case 0xb8: /* mov eax, imm32 */ \
29657 + case 0x35: /* xor eax, imm32 */ \
29658 + case 0x3d: /* cmp eax, imm32 */ \
29659 + case 0xa9: /* test eax, imm32 */ \
29660 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29661 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29662 + break; \
29663 + case 0xbb: /* mov ebx, imm32 */ \
29664 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29665 + /* mov ebx, ecx */ \
29666 + EMIT2(0x89, 0xcb); \
29667 + break; \
29668 + case 0xbe: /* mov esi, imm32 */ \
29669 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29670 + /* mov esi, ecx */ \
29671 + EMIT2(0x89, 0xce); \
29672 + break; \
29673 + case 0xe8: /* call rel imm32, always to known funcs */ \
29674 + EMIT1(b1); \
29675 + EMIT(_off, 4); \
29676 + break; \
29677 + case 0xe9: /* jmp rel imm32 */ \
29678 + EMIT1(b1); \
29679 + EMIT(_off, 4); \
29680 + /* prevent fall-through, we're not called if off = 0 */ \
29681 + EMIT(0xcccccccc, 4); \
29682 + EMIT(0xcccccccc, 4); \
29683 + break; \
29684 + default: \
29685 + BUILD_BUG(); \
29686 + } \
29687 +} while (0)
29688 +
29689 +#define EMIT2_off32(b1, b2, _off) \
29690 +do { \
29691 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29692 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29693 + EMIT(randkey, 4); \
29694 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29695 + EMIT((_off) - randkey, 4); \
29696 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29697 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29698 + /* imul eax, ecx */ \
29699 + EMIT3(0x0f, 0xaf, 0xc1); \
29700 + } else { \
29701 + BUILD_BUG(); \
29702 + } \
29703 +} while (0)
29704 +#else
29705 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29706 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29707 +#endif
29708
29709 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29710 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29711 @@ -90,6 +168,24 @@ do { \
29712 #define X86_JBE 0x76
29713 #define X86_JA 0x77
29714
29715 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29716 +#define APPEND_FLOW_VERIFY() \
29717 +do { \
29718 + /* mov ecx, randkey */ \
29719 + EMIT1(0xb9); \
29720 + EMIT(randkey, 4); \
29721 + /* cmp ecx, randkey */ \
29722 + EMIT2(0x81, 0xf9); \
29723 + EMIT(randkey, 4); \
29724 + /* jz after 8 int 3s */ \
29725 + EMIT2(0x74, 0x08); \
29726 + EMIT(0xcccccccc, 4); \
29727 + EMIT(0xcccccccc, 4); \
29728 +} while (0)
29729 +#else
29730 +#define APPEND_FLOW_VERIFY() do { } while (0)
29731 +#endif
29732 +
29733 #define EMIT_COND_JMP(op, offset) \
29734 do { \
29735 if (is_near(offset)) \
29736 @@ -97,6 +193,7 @@ do { \
29737 else { \
29738 EMIT2(0x0f, op + 0x10); \
29739 EMIT(offset, 4); /* jxx .+off32 */ \
29740 + APPEND_FLOW_VERIFY(); \
29741 } \
29742 } while (0)
29743
29744 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29745 set_fs(old_fs);
29746 }
29747
29748 +struct bpf_jit_work {
29749 + struct work_struct work;
29750 + void *image;
29751 +};
29752 +
29753 #define CHOOSE_LOAD_FUNC(K, func) \
29754 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29755
29756 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29757
29758 void bpf_jit_compile(struct sk_filter *fp)
29759 {
29760 - u8 temp[64];
29761 + u8 temp[MAX_INSTR_CODE_SIZE];
29762 u8 *prog;
29763 unsigned int proglen, oldproglen = 0;
29764 int ilen, i;
29765 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29766 unsigned int *addrs;
29767 const struct sock_filter *filter = fp->insns;
29768 int flen = fp->len;
29769 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29770 + unsigned int randkey;
29771 +#endif
29772
29773 if (!bpf_jit_enable)
29774 return;
29775 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29776 if (addrs == NULL)
29777 return;
29778
29779 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29780 + if (!fp->work)
29781 + goto out;
29782 +
29783 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29784 + randkey = get_random_int();
29785 +#endif
29786 +
29787 /* Before first pass, make a rough estimation of addrs[]
29788 - * each bpf instruction is translated to less than 64 bytes
29789 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29790 */
29791 for (proglen = 0, i = 0; i < flen; i++) {
29792 - proglen += 64;
29793 + proglen += MAX_INSTR_CODE_SIZE;
29794 addrs[i] = proglen;
29795 }
29796 cleanup_addr = proglen; /* epilogue address */
29797 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29798 case BPF_S_ALU_MUL_K: /* A *= K */
29799 if (is_imm8(K))
29800 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29801 - else {
29802 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29803 - EMIT(K, 4);
29804 - }
29805 + else
29806 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29807 break;
29808 case BPF_S_ALU_DIV_X: /* A /= X; */
29809 seen |= SEEN_XREG;
29810 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29811 break;
29812 case BPF_S_ALU_MOD_K: /* A %= K; */
29813 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29814 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29815 + DILUTE_CONST_SEQUENCE(K, randkey);
29816 +#else
29817 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29818 +#endif
29819 EMIT2(0xf7, 0xf1); /* div %ecx */
29820 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29821 break;
29822 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29823 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29824 + DILUTE_CONST_SEQUENCE(K, randkey);
29825 + // imul rax, rcx
29826 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29827 +#else
29828 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29829 EMIT(K, 4);
29830 +#endif
29831 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29832 break;
29833 case BPF_S_ALU_AND_X:
29834 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29835 if (is_imm8(K)) {
29836 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29837 } else {
29838 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29839 - EMIT(K, 4);
29840 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29841 }
29842 } else {
29843 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29844 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29845 break;
29846 default:
29847 /* hmm, too complex filter, give up with jit compiler */
29848 - goto out;
29849 + goto error;
29850 }
29851 ilen = prog - temp;
29852 if (image) {
29853 if (unlikely(proglen + ilen > oldproglen)) {
29854 pr_err("bpb_jit_compile fatal error\n");
29855 - kfree(addrs);
29856 - module_free(NULL, image);
29857 - return;
29858 + module_free_exec(NULL, image);
29859 + goto error;
29860 }
29861 + pax_open_kernel();
29862 memcpy(image + proglen, temp, ilen);
29863 + pax_close_kernel();
29864 }
29865 proglen += ilen;
29866 addrs[i] = proglen;
29867 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29868 break;
29869 }
29870 if (proglen == oldproglen) {
29871 - image = module_alloc(max_t(unsigned int,
29872 - proglen,
29873 - sizeof(struct work_struct)));
29874 + image = module_alloc_exec(proglen);
29875 if (!image)
29876 - goto out;
29877 + goto error;
29878 }
29879 oldproglen = proglen;
29880 }
29881 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29882 if (image) {
29883 bpf_flush_icache(image, image + proglen);
29884 fp->bpf_func = (void *)image;
29885 - }
29886 + } else
29887 +error:
29888 + kfree(fp->work);
29889 +
29890 out:
29891 kfree(addrs);
29892 return;
29893 @@ -740,18 +862,20 @@ out:
29894
29895 static void jit_free_defer(struct work_struct *arg)
29896 {
29897 - module_free(NULL, arg);
29898 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29899 + kfree(arg);
29900 }
29901
29902 /* run from softirq, we must use a work_struct to call
29903 - * module_free() from process context
29904 + * module_free_exec() from process context
29905 */
29906 void bpf_jit_free(struct sk_filter *fp)
29907 {
29908 if (fp->bpf_func != sk_run_filter) {
29909 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29910 + struct work_struct *work = &fp->work->work;
29911
29912 INIT_WORK(work, jit_free_defer);
29913 + fp->work->image = fp->bpf_func;
29914 schedule_work(work);
29915 }
29916 }
29917 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29918 index d6aa6e8..266395a 100644
29919 --- a/arch/x86/oprofile/backtrace.c
29920 +++ b/arch/x86/oprofile/backtrace.c
29921 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29922 struct stack_frame_ia32 *fp;
29923 unsigned long bytes;
29924
29925 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29926 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29927 if (bytes != sizeof(bufhead))
29928 return NULL;
29929
29930 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29931 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29932
29933 oprofile_add_trace(bufhead[0].return_address);
29934
29935 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29936 struct stack_frame bufhead[2];
29937 unsigned long bytes;
29938
29939 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29940 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29941 if (bytes != sizeof(bufhead))
29942 return NULL;
29943
29944 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29945 {
29946 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29947
29948 - if (!user_mode_vm(regs)) {
29949 + if (!user_mode(regs)) {
29950 unsigned long stack = kernel_stack_pointer(regs);
29951 if (depth)
29952 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29953 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29954 index 48768df..ba9143c 100644
29955 --- a/arch/x86/oprofile/nmi_int.c
29956 +++ b/arch/x86/oprofile/nmi_int.c
29957 @@ -23,6 +23,7 @@
29958 #include <asm/nmi.h>
29959 #include <asm/msr.h>
29960 #include <asm/apic.h>
29961 +#include <asm/pgtable.h>
29962
29963 #include "op_counter.h"
29964 #include "op_x86_model.h"
29965 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29966 if (ret)
29967 return ret;
29968
29969 - if (!model->num_virt_counters)
29970 - model->num_virt_counters = model->num_counters;
29971 + if (!model->num_virt_counters) {
29972 + pax_open_kernel();
29973 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29974 + pax_close_kernel();
29975 + }
29976
29977 mux_init(ops);
29978
29979 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29980 index b2b9443..be58856 100644
29981 --- a/arch/x86/oprofile/op_model_amd.c
29982 +++ b/arch/x86/oprofile/op_model_amd.c
29983 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29984 num_counters = AMD64_NUM_COUNTERS;
29985 }
29986
29987 - op_amd_spec.num_counters = num_counters;
29988 - op_amd_spec.num_controls = num_counters;
29989 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29990 + pax_open_kernel();
29991 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29992 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29993 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29994 + pax_close_kernel();
29995
29996 return 0;
29997 }
29998 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29999 index d90528e..0127e2b 100644
30000 --- a/arch/x86/oprofile/op_model_ppro.c
30001 +++ b/arch/x86/oprofile/op_model_ppro.c
30002 @@ -19,6 +19,7 @@
30003 #include <asm/msr.h>
30004 #include <asm/apic.h>
30005 #include <asm/nmi.h>
30006 +#include <asm/pgtable.h>
30007
30008 #include "op_x86_model.h"
30009 #include "op_counter.h"
30010 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30011
30012 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30013
30014 - op_arch_perfmon_spec.num_counters = num_counters;
30015 - op_arch_perfmon_spec.num_controls = num_counters;
30016 + pax_open_kernel();
30017 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30018 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30019 + pax_close_kernel();
30020 }
30021
30022 static int arch_perfmon_init(struct oprofile_operations *ignore)
30023 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30024 index 71e8a67..6a313bb 100644
30025 --- a/arch/x86/oprofile/op_x86_model.h
30026 +++ b/arch/x86/oprofile/op_x86_model.h
30027 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30028 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30029 struct op_msrs const * const msrs);
30030 #endif
30031 -};
30032 +} __do_const;
30033
30034 struct op_counter_config;
30035
30036 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30037 index e9e6ed5..e47ae67 100644
30038 --- a/arch/x86/pci/amd_bus.c
30039 +++ b/arch/x86/pci/amd_bus.c
30040 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30041 return NOTIFY_OK;
30042 }
30043
30044 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30045 +static struct notifier_block amd_cpu_notifier = {
30046 .notifier_call = amd_cpu_notify,
30047 };
30048
30049 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30050 index 372e9b8..e775a6c 100644
30051 --- a/arch/x86/pci/irq.c
30052 +++ b/arch/x86/pci/irq.c
30053 @@ -50,7 +50,7 @@ struct irq_router {
30054 struct irq_router_handler {
30055 u16 vendor;
30056 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30057 -};
30058 +} __do_const;
30059
30060 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30061 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30062 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30063 return 0;
30064 }
30065
30066 -static __initdata struct irq_router_handler pirq_routers[] = {
30067 +static __initconst const struct irq_router_handler pirq_routers[] = {
30068 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30069 { PCI_VENDOR_ID_AL, ali_router_probe },
30070 { PCI_VENDOR_ID_ITE, ite_router_probe },
30071 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30072 static void __init pirq_find_router(struct irq_router *r)
30073 {
30074 struct irq_routing_table *rt = pirq_table;
30075 - struct irq_router_handler *h;
30076 + const struct irq_router_handler *h;
30077
30078 #ifdef CONFIG_PCI_BIOS
30079 if (!rt->signature) {
30080 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30081 return 0;
30082 }
30083
30084 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30085 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30086 {
30087 .callback = fix_broken_hp_bios_irq9,
30088 .ident = "HP Pavilion N5400 Series Laptop",
30089 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30090 index 6eb18c4..20d83de 100644
30091 --- a/arch/x86/pci/mrst.c
30092 +++ b/arch/x86/pci/mrst.c
30093 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30094 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30095 pci_mmcfg_late_init();
30096 pcibios_enable_irq = mrst_pci_irq_enable;
30097 - pci_root_ops = pci_mrst_ops;
30098 + pax_open_kernel();
30099 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30100 + pax_close_kernel();
30101 pci_soc_mode = 1;
30102 /* Continue with standard init */
30103 return 1;
30104 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30105 index c77b24a..c979855 100644
30106 --- a/arch/x86/pci/pcbios.c
30107 +++ b/arch/x86/pci/pcbios.c
30108 @@ -79,7 +79,7 @@ union bios32 {
30109 static struct {
30110 unsigned long address;
30111 unsigned short segment;
30112 -} bios32_indirect = { 0, __KERNEL_CS };
30113 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30114
30115 /*
30116 * Returns the entry point for the given service, NULL on error
30117 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30118 unsigned long length; /* %ecx */
30119 unsigned long entry; /* %edx */
30120 unsigned long flags;
30121 + struct desc_struct d, *gdt;
30122
30123 local_irq_save(flags);
30124 - __asm__("lcall *(%%edi); cld"
30125 +
30126 + gdt = get_cpu_gdt_table(smp_processor_id());
30127 +
30128 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30129 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30130 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30131 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30132 +
30133 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30134 : "=a" (return_code),
30135 "=b" (address),
30136 "=c" (length),
30137 "=d" (entry)
30138 : "0" (service),
30139 "1" (0),
30140 - "D" (&bios32_indirect));
30141 + "D" (&bios32_indirect),
30142 + "r"(__PCIBIOS_DS)
30143 + : "memory");
30144 +
30145 + pax_open_kernel();
30146 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30147 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30148 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30149 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30150 + pax_close_kernel();
30151 +
30152 local_irq_restore(flags);
30153
30154 switch (return_code) {
30155 - case 0:
30156 - return address + entry;
30157 - case 0x80: /* Not present */
30158 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30159 - return 0;
30160 - default: /* Shouldn't happen */
30161 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30162 - service, return_code);
30163 + case 0: {
30164 + int cpu;
30165 + unsigned char flags;
30166 +
30167 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30168 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30169 + printk(KERN_WARNING "bios32_service: not valid\n");
30170 return 0;
30171 + }
30172 + address = address + PAGE_OFFSET;
30173 + length += 16UL; /* some BIOSs underreport this... */
30174 + flags = 4;
30175 + if (length >= 64*1024*1024) {
30176 + length >>= PAGE_SHIFT;
30177 + flags |= 8;
30178 + }
30179 +
30180 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30181 + gdt = get_cpu_gdt_table(cpu);
30182 + pack_descriptor(&d, address, length, 0x9b, flags);
30183 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30184 + pack_descriptor(&d, address, length, 0x93, flags);
30185 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30186 + }
30187 + return entry;
30188 + }
30189 + case 0x80: /* Not present */
30190 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30191 + return 0;
30192 + default: /* Shouldn't happen */
30193 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30194 + service, return_code);
30195 + return 0;
30196 }
30197 }
30198
30199 static struct {
30200 unsigned long address;
30201 unsigned short segment;
30202 -} pci_indirect = { 0, __KERNEL_CS };
30203 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30204
30205 -static int pci_bios_present;
30206 +static int pci_bios_present __read_only;
30207
30208 static int check_pcibios(void)
30209 {
30210 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30211 unsigned long flags, pcibios_entry;
30212
30213 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30214 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30215 + pci_indirect.address = pcibios_entry;
30216
30217 local_irq_save(flags);
30218 - __asm__(
30219 - "lcall *(%%edi); cld\n\t"
30220 + __asm__("movw %w6, %%ds\n\t"
30221 + "lcall *%%ss:(%%edi); cld\n\t"
30222 + "push %%ss\n\t"
30223 + "pop %%ds\n\t"
30224 "jc 1f\n\t"
30225 "xor %%ah, %%ah\n"
30226 "1:"
30227 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30228 "=b" (ebx),
30229 "=c" (ecx)
30230 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30231 - "D" (&pci_indirect)
30232 + "D" (&pci_indirect),
30233 + "r" (__PCIBIOS_DS)
30234 : "memory");
30235 local_irq_restore(flags);
30236
30237 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30238
30239 switch (len) {
30240 case 1:
30241 - __asm__("lcall *(%%esi); cld\n\t"
30242 + __asm__("movw %w6, %%ds\n\t"
30243 + "lcall *%%ss:(%%esi); cld\n\t"
30244 + "push %%ss\n\t"
30245 + "pop %%ds\n\t"
30246 "jc 1f\n\t"
30247 "xor %%ah, %%ah\n"
30248 "1:"
30249 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30250 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30251 "b" (bx),
30252 "D" ((long)reg),
30253 - "S" (&pci_indirect));
30254 + "S" (&pci_indirect),
30255 + "r" (__PCIBIOS_DS));
30256 /*
30257 * Zero-extend the result beyond 8 bits, do not trust the
30258 * BIOS having done it:
30259 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30260 *value &= 0xff;
30261 break;
30262 case 2:
30263 - __asm__("lcall *(%%esi); cld\n\t"
30264 + __asm__("movw %w6, %%ds\n\t"
30265 + "lcall *%%ss:(%%esi); cld\n\t"
30266 + "push %%ss\n\t"
30267 + "pop %%ds\n\t"
30268 "jc 1f\n\t"
30269 "xor %%ah, %%ah\n"
30270 "1:"
30271 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30272 : "1" (PCIBIOS_READ_CONFIG_WORD),
30273 "b" (bx),
30274 "D" ((long)reg),
30275 - "S" (&pci_indirect));
30276 + "S" (&pci_indirect),
30277 + "r" (__PCIBIOS_DS));
30278 /*
30279 * Zero-extend the result beyond 16 bits, do not trust the
30280 * BIOS having done it:
30281 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30282 *value &= 0xffff;
30283 break;
30284 case 4:
30285 - __asm__("lcall *(%%esi); cld\n\t"
30286 + __asm__("movw %w6, %%ds\n\t"
30287 + "lcall *%%ss:(%%esi); cld\n\t"
30288 + "push %%ss\n\t"
30289 + "pop %%ds\n\t"
30290 "jc 1f\n\t"
30291 "xor %%ah, %%ah\n"
30292 "1:"
30293 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30294 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30295 "b" (bx),
30296 "D" ((long)reg),
30297 - "S" (&pci_indirect));
30298 + "S" (&pci_indirect),
30299 + "r" (__PCIBIOS_DS));
30300 break;
30301 }
30302
30303 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30304
30305 switch (len) {
30306 case 1:
30307 - __asm__("lcall *(%%esi); cld\n\t"
30308 + __asm__("movw %w6, %%ds\n\t"
30309 + "lcall *%%ss:(%%esi); cld\n\t"
30310 + "push %%ss\n\t"
30311 + "pop %%ds\n\t"
30312 "jc 1f\n\t"
30313 "xor %%ah, %%ah\n"
30314 "1:"
30315 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30316 "c" (value),
30317 "b" (bx),
30318 "D" ((long)reg),
30319 - "S" (&pci_indirect));
30320 + "S" (&pci_indirect),
30321 + "r" (__PCIBIOS_DS));
30322 break;
30323 case 2:
30324 - __asm__("lcall *(%%esi); cld\n\t"
30325 + __asm__("movw %w6, %%ds\n\t"
30326 + "lcall *%%ss:(%%esi); cld\n\t"
30327 + "push %%ss\n\t"
30328 + "pop %%ds\n\t"
30329 "jc 1f\n\t"
30330 "xor %%ah, %%ah\n"
30331 "1:"
30332 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30333 "c" (value),
30334 "b" (bx),
30335 "D" ((long)reg),
30336 - "S" (&pci_indirect));
30337 + "S" (&pci_indirect),
30338 + "r" (__PCIBIOS_DS));
30339 break;
30340 case 4:
30341 - __asm__("lcall *(%%esi); cld\n\t"
30342 + __asm__("movw %w6, %%ds\n\t"
30343 + "lcall *%%ss:(%%esi); cld\n\t"
30344 + "push %%ss\n\t"
30345 + "pop %%ds\n\t"
30346 "jc 1f\n\t"
30347 "xor %%ah, %%ah\n"
30348 "1:"
30349 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30350 "c" (value),
30351 "b" (bx),
30352 "D" ((long)reg),
30353 - "S" (&pci_indirect));
30354 + "S" (&pci_indirect),
30355 + "r" (__PCIBIOS_DS));
30356 break;
30357 }
30358
30359 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30360
30361 DBG("PCI: Fetching IRQ routing table... ");
30362 __asm__("push %%es\n\t"
30363 + "movw %w8, %%ds\n\t"
30364 "push %%ds\n\t"
30365 "pop %%es\n\t"
30366 - "lcall *(%%esi); cld\n\t"
30367 + "lcall *%%ss:(%%esi); cld\n\t"
30368 "pop %%es\n\t"
30369 + "push %%ss\n\t"
30370 + "pop %%ds\n"
30371 "jc 1f\n\t"
30372 "xor %%ah, %%ah\n"
30373 "1:"
30374 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30375 "1" (0),
30376 "D" ((long) &opt),
30377 "S" (&pci_indirect),
30378 - "m" (opt)
30379 + "m" (opt),
30380 + "r" (__PCIBIOS_DS)
30381 : "memory");
30382 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30383 if (ret & 0xff00)
30384 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30385 {
30386 int ret;
30387
30388 - __asm__("lcall *(%%esi); cld\n\t"
30389 + __asm__("movw %w5, %%ds\n\t"
30390 + "lcall *%%ss:(%%esi); cld\n\t"
30391 + "push %%ss\n\t"
30392 + "pop %%ds\n"
30393 "jc 1f\n\t"
30394 "xor %%ah, %%ah\n"
30395 "1:"
30396 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30397 : "0" (PCIBIOS_SET_PCI_HW_INT),
30398 "b" ((dev->bus->number << 8) | dev->devfn),
30399 "c" ((irq << 8) | (pin + 10)),
30400 - "S" (&pci_indirect));
30401 + "S" (&pci_indirect),
30402 + "r" (__PCIBIOS_DS));
30403 return !(ret & 0xff00);
30404 }
30405 EXPORT_SYMBOL(pcibios_set_irq_routing);
30406 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30407 index 40e4469..0592924 100644
30408 --- a/arch/x86/platform/efi/efi_32.c
30409 +++ b/arch/x86/platform/efi/efi_32.c
30410 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30411 {
30412 struct desc_ptr gdt_descr;
30413
30414 +#ifdef CONFIG_PAX_KERNEXEC
30415 + struct desc_struct d;
30416 +#endif
30417 +
30418 local_irq_save(efi_rt_eflags);
30419
30420 load_cr3(initial_page_table);
30421 __flush_tlb_all();
30422
30423 +#ifdef CONFIG_PAX_KERNEXEC
30424 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30425 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30426 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30427 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30428 +#endif
30429 +
30430 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30431 gdt_descr.size = GDT_SIZE - 1;
30432 load_gdt(&gdt_descr);
30433 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
30434 {
30435 struct desc_ptr gdt_descr;
30436
30437 +#ifdef CONFIG_PAX_KERNEXEC
30438 + struct desc_struct d;
30439 +
30440 + memset(&d, 0, sizeof d);
30441 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30442 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30443 +#endif
30444 +
30445 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30446 gdt_descr.size = GDT_SIZE - 1;
30447 load_gdt(&gdt_descr);
30448
30449 +#ifdef CONFIG_PAX_PER_CPU_PGD
30450 + load_cr3(get_cpu_pgd(smp_processor_id()));
30451 +#else
30452 load_cr3(swapper_pg_dir);
30453 +#endif
30454 +
30455 __flush_tlb_all();
30456
30457 local_irq_restore(efi_rt_eflags);
30458 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
30459 index 39a0e7f1..ecc2f1e 100644
30460 --- a/arch/x86/platform/efi/efi_64.c
30461 +++ b/arch/x86/platform/efi/efi_64.c
30462 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
30463 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
30464 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
30465 }
30466 +
30467 +#ifdef CONFIG_PAX_PER_CPU_PGD
30468 + load_cr3(swapper_pg_dir);
30469 +#endif
30470 +
30471 __flush_tlb_all();
30472 }
30473
30474 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
30475 for (pgd = 0; pgd < n_pgds; pgd++)
30476 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
30477 kfree(save_pgd);
30478 +
30479 +#ifdef CONFIG_PAX_PER_CPU_PGD
30480 + load_cr3(get_cpu_pgd(smp_processor_id()));
30481 +#endif
30482 +
30483 __flush_tlb_all();
30484 local_irq_restore(efi_flags);
30485 early_code_mapping_set_exec(0);
30486 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30487 index fbe66e6..eae5e38 100644
30488 --- a/arch/x86/platform/efi/efi_stub_32.S
30489 +++ b/arch/x86/platform/efi/efi_stub_32.S
30490 @@ -6,7 +6,9 @@
30491 */
30492
30493 #include <linux/linkage.h>
30494 +#include <linux/init.h>
30495 #include <asm/page_types.h>
30496 +#include <asm/segment.h>
30497
30498 /*
30499 * efi_call_phys(void *, ...) is a function with variable parameters.
30500 @@ -20,7 +22,7 @@
30501 * service functions will comply with gcc calling convention, too.
30502 */
30503
30504 -.text
30505 +__INIT
30506 ENTRY(efi_call_phys)
30507 /*
30508 * 0. The function can only be called in Linux kernel. So CS has been
30509 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30510 * The mapping of lower virtual memory has been created in prelog and
30511 * epilog.
30512 */
30513 - movl $1f, %edx
30514 - subl $__PAGE_OFFSET, %edx
30515 - jmp *%edx
30516 +#ifdef CONFIG_PAX_KERNEXEC
30517 + movl $(__KERNEXEC_EFI_DS), %edx
30518 + mov %edx, %ds
30519 + mov %edx, %es
30520 + mov %edx, %ss
30521 + addl $2f,(1f)
30522 + ljmp *(1f)
30523 +
30524 +__INITDATA
30525 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30526 +.previous
30527 +
30528 +2:
30529 + subl $2b,(1b)
30530 +#else
30531 + jmp 1f-__PAGE_OFFSET
30532 1:
30533 +#endif
30534
30535 /*
30536 * 2. Now on the top of stack is the return
30537 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30538 * parameter 2, ..., param n. To make things easy, we save the return
30539 * address of efi_call_phys in a global variable.
30540 */
30541 - popl %edx
30542 - movl %edx, saved_return_addr
30543 - /* get the function pointer into ECX*/
30544 - popl %ecx
30545 - movl %ecx, efi_rt_function_ptr
30546 - movl $2f, %edx
30547 - subl $__PAGE_OFFSET, %edx
30548 - pushl %edx
30549 + popl (saved_return_addr)
30550 + popl (efi_rt_function_ptr)
30551
30552 /*
30553 * 3. Clear PG bit in %CR0.
30554 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30555 /*
30556 * 5. Call the physical function.
30557 */
30558 - jmp *%ecx
30559 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30560
30561 -2:
30562 /*
30563 * 6. After EFI runtime service returns, control will return to
30564 * following instruction. We'd better readjust stack pointer first.
30565 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30566 movl %cr0, %edx
30567 orl $0x80000000, %edx
30568 movl %edx, %cr0
30569 - jmp 1f
30570 -1:
30571 +
30572 /*
30573 * 8. Now restore the virtual mode from flat mode by
30574 * adding EIP with PAGE_OFFSET.
30575 */
30576 - movl $1f, %edx
30577 - jmp *%edx
30578 +#ifdef CONFIG_PAX_KERNEXEC
30579 + movl $(__KERNEL_DS), %edx
30580 + mov %edx, %ds
30581 + mov %edx, %es
30582 + mov %edx, %ss
30583 + ljmp $(__KERNEL_CS),$1f
30584 +#else
30585 + jmp 1f+__PAGE_OFFSET
30586 +#endif
30587 1:
30588
30589 /*
30590 * 9. Balance the stack. And because EAX contain the return value,
30591 * we'd better not clobber it.
30592 */
30593 - leal efi_rt_function_ptr, %edx
30594 - movl (%edx), %ecx
30595 - pushl %ecx
30596 + pushl (efi_rt_function_ptr)
30597
30598 /*
30599 - * 10. Push the saved return address onto the stack and return.
30600 + * 10. Return to the saved return address.
30601 */
30602 - leal saved_return_addr, %edx
30603 - movl (%edx), %ecx
30604 - pushl %ecx
30605 - ret
30606 + jmpl *(saved_return_addr)
30607 ENDPROC(efi_call_phys)
30608 .previous
30609
30610 -.data
30611 +__INITDATA
30612 saved_return_addr:
30613 .long 0
30614 efi_rt_function_ptr:
30615 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30616 index 4c07cca..2c8427d 100644
30617 --- a/arch/x86/platform/efi/efi_stub_64.S
30618 +++ b/arch/x86/platform/efi/efi_stub_64.S
30619 @@ -7,6 +7,7 @@
30620 */
30621
30622 #include <linux/linkage.h>
30623 +#include <asm/alternative-asm.h>
30624
30625 #define SAVE_XMM \
30626 mov %rsp, %rax; \
30627 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30628 call *%rdi
30629 addq $32, %rsp
30630 RESTORE_XMM
30631 + pax_force_retaddr 0, 1
30632 ret
30633 ENDPROC(efi_call0)
30634
30635 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30636 call *%rdi
30637 addq $32, %rsp
30638 RESTORE_XMM
30639 + pax_force_retaddr 0, 1
30640 ret
30641 ENDPROC(efi_call1)
30642
30643 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30644 call *%rdi
30645 addq $32, %rsp
30646 RESTORE_XMM
30647 + pax_force_retaddr 0, 1
30648 ret
30649 ENDPROC(efi_call2)
30650
30651 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30652 call *%rdi
30653 addq $32, %rsp
30654 RESTORE_XMM
30655 + pax_force_retaddr 0, 1
30656 ret
30657 ENDPROC(efi_call3)
30658
30659 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30660 call *%rdi
30661 addq $32, %rsp
30662 RESTORE_XMM
30663 + pax_force_retaddr 0, 1
30664 ret
30665 ENDPROC(efi_call4)
30666
30667 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30668 call *%rdi
30669 addq $48, %rsp
30670 RESTORE_XMM
30671 + pax_force_retaddr 0, 1
30672 ret
30673 ENDPROC(efi_call5)
30674
30675 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30676 call *%rdi
30677 addq $48, %rsp
30678 RESTORE_XMM
30679 + pax_force_retaddr 0, 1
30680 ret
30681 ENDPROC(efi_call6)
30682 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30683 index a0a0a43..a48e233 100644
30684 --- a/arch/x86/platform/mrst/mrst.c
30685 +++ b/arch/x86/platform/mrst/mrst.c
30686 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30687 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30688 int sfi_mrtc_num;
30689
30690 -static void mrst_power_off(void)
30691 +static __noreturn void mrst_power_off(void)
30692 {
30693 + BUG();
30694 }
30695
30696 -static void mrst_reboot(void)
30697 +static __noreturn void mrst_reboot(void)
30698 {
30699 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30700 + BUG();
30701 }
30702
30703 /* parse all the mtimer info to a static mtimer array */
30704 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30705 index d6ee929..3637cb5 100644
30706 --- a/arch/x86/platform/olpc/olpc_dt.c
30707 +++ b/arch/x86/platform/olpc/olpc_dt.c
30708 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30709 return res;
30710 }
30711
30712 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30713 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30714 .nextprop = olpc_dt_nextprop,
30715 .getproplen = olpc_dt_getproplen,
30716 .getproperty = olpc_dt_getproperty,
30717 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30718 index 1cf5b30..fd45732 100644
30719 --- a/arch/x86/power/cpu.c
30720 +++ b/arch/x86/power/cpu.c
30721 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
30722 static void fix_processor_context(void)
30723 {
30724 int cpu = smp_processor_id();
30725 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30726 -#ifdef CONFIG_X86_64
30727 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
30728 - tss_desc tss;
30729 -#endif
30730 + struct tss_struct *t = init_tss + cpu;
30731 +
30732 set_tss_desc(cpu, t); /*
30733 * This just modifies memory; should not be
30734 * necessary. But... This is necessary, because
30735 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
30736 */
30737
30738 #ifdef CONFIG_X86_64
30739 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
30740 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
30741 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
30742 -
30743 syscall_init(); /* This sets MSR_*STAR and related */
30744 #endif
30745 load_TR_desc(); /* This does ltr */
30746 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30747 index a44f457..9140171 100644
30748 --- a/arch/x86/realmode/init.c
30749 +++ b/arch/x86/realmode/init.c
30750 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30751 __va(real_mode_header->trampoline_header);
30752
30753 #ifdef CONFIG_X86_32
30754 - trampoline_header->start = __pa_symbol(startup_32_smp);
30755 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30756 +
30757 +#ifdef CONFIG_PAX_KERNEXEC
30758 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30759 +#endif
30760 +
30761 + trampoline_header->boot_cs = __BOOT_CS;
30762 trampoline_header->gdt_limit = __BOOT_DS + 7;
30763 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30764 #else
30765 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30766 *trampoline_cr4_features = read_cr4();
30767
30768 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30769 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30770 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30771 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30772 #endif
30773 }
30774 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30775 index 8869287..d577672 100644
30776 --- a/arch/x86/realmode/rm/Makefile
30777 +++ b/arch/x86/realmode/rm/Makefile
30778 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30779 $(call cc-option, -fno-unit-at-a-time)) \
30780 $(call cc-option, -fno-stack-protector) \
30781 $(call cc-option, -mpreferred-stack-boundary=2)
30782 +ifdef CONSTIFY_PLUGIN
30783 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30784 +endif
30785 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30786 GCOV_PROFILE := n
30787 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30788 index a28221d..93c40f1 100644
30789 --- a/arch/x86/realmode/rm/header.S
30790 +++ b/arch/x86/realmode/rm/header.S
30791 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30792 #endif
30793 /* APM/BIOS reboot */
30794 .long pa_machine_real_restart_asm
30795 -#ifdef CONFIG_X86_64
30796 +#ifdef CONFIG_X86_32
30797 + .long __KERNEL_CS
30798 +#else
30799 .long __KERNEL32_CS
30800 #endif
30801 END(real_mode_header)
30802 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30803 index c1b2791..f9e31c7 100644
30804 --- a/arch/x86/realmode/rm/trampoline_32.S
30805 +++ b/arch/x86/realmode/rm/trampoline_32.S
30806 @@ -25,6 +25,12 @@
30807 #include <asm/page_types.h>
30808 #include "realmode.h"
30809
30810 +#ifdef CONFIG_PAX_KERNEXEC
30811 +#define ta(X) (X)
30812 +#else
30813 +#define ta(X) (pa_ ## X)
30814 +#endif
30815 +
30816 .text
30817 .code16
30818
30819 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30820
30821 cli # We should be safe anyway
30822
30823 - movl tr_start, %eax # where we need to go
30824 -
30825 movl $0xA5A5A5A5, trampoline_status
30826 # write marker for master knows we're running
30827
30828 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30829 movw $1, %dx # protected mode (PE) bit
30830 lmsw %dx # into protected mode
30831
30832 - ljmpl $__BOOT_CS, $pa_startup_32
30833 + ljmpl *(trampoline_header)
30834
30835 .section ".text32","ax"
30836 .code32
30837 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30838 .balign 8
30839 GLOBAL(trampoline_header)
30840 tr_start: .space 4
30841 - tr_gdt_pad: .space 2
30842 + tr_boot_cs: .space 2
30843 tr_gdt: .space 6
30844 END(trampoline_header)
30845
30846 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30847 index bb360dc..3e5945f 100644
30848 --- a/arch/x86/realmode/rm/trampoline_64.S
30849 +++ b/arch/x86/realmode/rm/trampoline_64.S
30850 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30851 wrmsr
30852
30853 # Enable paging and in turn activate Long Mode
30854 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30855 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30856 movl %eax, %cr0
30857
30858 /*
30859 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
30860 index e812034..c747134 100644
30861 --- a/arch/x86/tools/Makefile
30862 +++ b/arch/x86/tools/Makefile
30863 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
30864
30865 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
30866
30867 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
30868 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
30869 hostprogs-y += relocs
30870 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
30871 relocs: $(obj)/relocs
30872 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30873 index f7bab68..b6d9886 100644
30874 --- a/arch/x86/tools/relocs.c
30875 +++ b/arch/x86/tools/relocs.c
30876 @@ -1,5 +1,7 @@
30877 /* This is included from relocs_32/64.c */
30878
30879 +#include "../../../include/generated/autoconf.h"
30880 +
30881 #define ElfW(type) _ElfW(ELF_BITS, type)
30882 #define _ElfW(bits, type) __ElfW(bits, type)
30883 #define __ElfW(bits, type) Elf##bits##_##type
30884 @@ -11,6 +13,7 @@
30885 #define Elf_Sym ElfW(Sym)
30886
30887 static Elf_Ehdr ehdr;
30888 +static Elf_Phdr *phdr;
30889
30890 struct relocs {
30891 uint32_t *offset;
30892 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
30893 }
30894 }
30895
30896 +static void read_phdrs(FILE *fp)
30897 +{
30898 + unsigned int i;
30899 +
30900 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
30901 + if (!phdr) {
30902 + die("Unable to allocate %d program headers\n",
30903 + ehdr.e_phnum);
30904 + }
30905 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30906 + die("Seek to %d failed: %s\n",
30907 + ehdr.e_phoff, strerror(errno));
30908 + }
30909 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30910 + die("Cannot read ELF program headers: %s\n",
30911 + strerror(errno));
30912 + }
30913 + for(i = 0; i < ehdr.e_phnum; i++) {
30914 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
30915 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
30916 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
30917 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
30918 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
30919 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
30920 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
30921 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
30922 + }
30923 +
30924 +}
30925 +
30926 static void read_shdrs(FILE *fp)
30927 {
30928 - int i;
30929 + unsigned int i;
30930 Elf_Shdr shdr;
30931
30932 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30933 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
30934
30935 static void read_strtabs(FILE *fp)
30936 {
30937 - int i;
30938 + unsigned int i;
30939 for (i = 0; i < ehdr.e_shnum; i++) {
30940 struct section *sec = &secs[i];
30941 if (sec->shdr.sh_type != SHT_STRTAB) {
30942 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
30943
30944 static void read_symtabs(FILE *fp)
30945 {
30946 - int i,j;
30947 + unsigned int i,j;
30948 for (i = 0; i < ehdr.e_shnum; i++) {
30949 struct section *sec = &secs[i];
30950 if (sec->shdr.sh_type != SHT_SYMTAB) {
30951 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
30952 }
30953
30954
30955 -static void read_relocs(FILE *fp)
30956 +static void read_relocs(FILE *fp, int use_real_mode)
30957 {
30958 - int i,j;
30959 + unsigned int i,j;
30960 + uint32_t base;
30961 +
30962 for (i = 0; i < ehdr.e_shnum; i++) {
30963 struct section *sec = &secs[i];
30964 if (sec->shdr.sh_type != SHT_REL_TYPE) {
30965 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
30966 die("Cannot read symbol table: %s\n",
30967 strerror(errno));
30968 }
30969 + base = 0;
30970 +
30971 +#ifdef CONFIG_X86_32
30972 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30973 + if (phdr[j].p_type != PT_LOAD )
30974 + continue;
30975 + 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)
30976 + continue;
30977 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30978 + break;
30979 + }
30980 +#endif
30981 +
30982 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
30983 Elf_Rel *rel = &sec->reltab[j];
30984 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
30985 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
30986 rel->r_info = elf_xword_to_cpu(rel->r_info);
30987 #if (SHT_REL_TYPE == SHT_RELA)
30988 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
30989 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
30990
30991 static void print_absolute_symbols(void)
30992 {
30993 - int i;
30994 + unsigned int i;
30995 const char *format;
30996
30997 if (ELF_BITS == 64)
30998 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
30999 for (i = 0; i < ehdr.e_shnum; i++) {
31000 struct section *sec = &secs[i];
31001 char *sym_strtab;
31002 - int j;
31003 + unsigned int j;
31004
31005 if (sec->shdr.sh_type != SHT_SYMTAB) {
31006 continue;
31007 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
31008
31009 static void print_absolute_relocs(void)
31010 {
31011 - int i, printed = 0;
31012 + unsigned int i, printed = 0;
31013 const char *format;
31014
31015 if (ELF_BITS == 64)
31016 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
31017 struct section *sec_applies, *sec_symtab;
31018 char *sym_strtab;
31019 Elf_Sym *sh_symtab;
31020 - int j;
31021 + unsigned int j;
31022 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31023 continue;
31024 }
31025 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
31026 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
31027 Elf_Sym *sym, const char *symname))
31028 {
31029 - int i;
31030 + unsigned int i;
31031 /* Walk through the relocations */
31032 for (i = 0; i < ehdr.e_shnum; i++) {
31033 char *sym_strtab;
31034 Elf_Sym *sh_symtab;
31035 struct section *sec_applies, *sec_symtab;
31036 - int j;
31037 + unsigned int j;
31038 struct section *sec = &secs[i];
31039
31040 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31041 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31042 {
31043 unsigned r_type = ELF32_R_TYPE(rel->r_info);
31044 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
31045 + char *sym_strtab = sec->link->link->strtab;
31046 +
31047 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31048 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31049 + return 0;
31050 +
31051 +#ifdef CONFIG_PAX_KERNEXEC
31052 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31053 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31054 + return 0;
31055 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31056 + return 0;
31057 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31058 + return 0;
31059 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31060 + return 0;
31061 +#endif
31062
31063 switch (r_type) {
31064 case R_386_NONE:
31065 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
31066
31067 static void emit_relocs(int as_text, int use_real_mode)
31068 {
31069 - int i;
31070 + unsigned int i;
31071 int (*write_reloc)(uint32_t, FILE *) = write32;
31072 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31073 const char *symname);
31074 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
31075 {
31076 regex_init(use_real_mode);
31077 read_ehdr(fp);
31078 + read_phdrs(fp);
31079 read_shdrs(fp);
31080 read_strtabs(fp);
31081 read_symtabs(fp);
31082 - read_relocs(fp);
31083 + read_relocs(fp, use_real_mode);
31084 if (ELF_BITS == 64)
31085 percpu_init();
31086 if (show_absolute_syms) {
31087 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
31088 index 80ffa5b..a33bd15 100644
31089 --- a/arch/x86/um/tls_32.c
31090 +++ b/arch/x86/um/tls_32.c
31091 @@ -260,7 +260,7 @@ out:
31092 if (unlikely(task == current &&
31093 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
31094 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
31095 - "without flushed TLS.", current->pid);
31096 + "without flushed TLS.", task_pid_nr(current));
31097 }
31098
31099 return 0;
31100 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31101 index fd14be1..e3c79c0 100644
31102 --- a/arch/x86/vdso/Makefile
31103 +++ b/arch/x86/vdso/Makefile
31104 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31105 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31106 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31107
31108 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31109 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31110 GCOV_PROFILE := n
31111
31112 #
31113 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31114 index 0faad64..39ef157 100644
31115 --- a/arch/x86/vdso/vdso32-setup.c
31116 +++ b/arch/x86/vdso/vdso32-setup.c
31117 @@ -25,6 +25,7 @@
31118 #include <asm/tlbflush.h>
31119 #include <asm/vdso.h>
31120 #include <asm/proto.h>
31121 +#include <asm/mman.h>
31122
31123 enum {
31124 VDSO_DISABLED = 0,
31125 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31126 void enable_sep_cpu(void)
31127 {
31128 int cpu = get_cpu();
31129 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31130 + struct tss_struct *tss = init_tss + cpu;
31131
31132 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31133 put_cpu();
31134 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31135 gate_vma.vm_start = FIXADDR_USER_START;
31136 gate_vma.vm_end = FIXADDR_USER_END;
31137 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31138 - gate_vma.vm_page_prot = __P101;
31139 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31140
31141 return 0;
31142 }
31143 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31144 if (compat)
31145 addr = VDSO_HIGH_BASE;
31146 else {
31147 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31148 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31149 if (IS_ERR_VALUE(addr)) {
31150 ret = addr;
31151 goto up_fail;
31152 }
31153 }
31154
31155 - current->mm->context.vdso = (void *)addr;
31156 + current->mm->context.vdso = addr;
31157
31158 if (compat_uses_vma || !compat) {
31159 /*
31160 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31161 }
31162
31163 current_thread_info()->sysenter_return =
31164 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31165 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31166
31167 up_fail:
31168 if (ret)
31169 - current->mm->context.vdso = NULL;
31170 + current->mm->context.vdso = 0;
31171
31172 up_write(&mm->mmap_sem);
31173
31174 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31175
31176 const char *arch_vma_name(struct vm_area_struct *vma)
31177 {
31178 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31179 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31180 return "[vdso]";
31181 +
31182 +#ifdef CONFIG_PAX_SEGMEXEC
31183 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31184 + return "[vdso]";
31185 +#endif
31186 +
31187 return NULL;
31188 }
31189
31190 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31191 * Check to see if the corresponding task was created in compat vdso
31192 * mode.
31193 */
31194 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31195 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31196 return &gate_vma;
31197 return NULL;
31198 }
31199 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31200 index 431e875..cbb23f3 100644
31201 --- a/arch/x86/vdso/vma.c
31202 +++ b/arch/x86/vdso/vma.c
31203 @@ -16,8 +16,6 @@
31204 #include <asm/vdso.h>
31205 #include <asm/page.h>
31206
31207 -unsigned int __read_mostly vdso_enabled = 1;
31208 -
31209 extern char vdso_start[], vdso_end[];
31210 extern unsigned short vdso_sync_cpuid;
31211
31212 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31213 * unaligned here as a result of stack start randomization.
31214 */
31215 addr = PAGE_ALIGN(addr);
31216 - addr = align_vdso_addr(addr);
31217
31218 return addr;
31219 }
31220 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31221 unsigned size)
31222 {
31223 struct mm_struct *mm = current->mm;
31224 - unsigned long addr;
31225 + unsigned long addr = 0;
31226 int ret;
31227
31228 - if (!vdso_enabled)
31229 - return 0;
31230 -
31231 down_write(&mm->mmap_sem);
31232 +
31233 +#ifdef CONFIG_PAX_RANDMMAP
31234 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31235 +#endif
31236 +
31237 addr = vdso_addr(mm->start_stack, size);
31238 + addr = align_vdso_addr(addr);
31239 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31240 if (IS_ERR_VALUE(addr)) {
31241 ret = addr;
31242 goto up_fail;
31243 }
31244
31245 - current->mm->context.vdso = (void *)addr;
31246 + mm->context.vdso = addr;
31247
31248 ret = install_special_mapping(mm, addr, size,
31249 VM_READ|VM_EXEC|
31250 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31251 pages);
31252 - if (ret) {
31253 - current->mm->context.vdso = NULL;
31254 - goto up_fail;
31255 - }
31256 + if (ret)
31257 + mm->context.vdso = 0;
31258
31259 up_fail:
31260 up_write(&mm->mmap_sem);
31261 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31262 vdsox32_size);
31263 }
31264 #endif
31265 -
31266 -static __init int vdso_setup(char *s)
31267 -{
31268 - vdso_enabled = simple_strtoul(s, NULL, 0);
31269 - return 0;
31270 -}
31271 -__setup("vdso=", vdso_setup);
31272 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31273 index a492be2..08678da 100644
31274 --- a/arch/x86/xen/enlighten.c
31275 +++ b/arch/x86/xen/enlighten.c
31276 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31277
31278 struct shared_info xen_dummy_shared_info;
31279
31280 -void *xen_initial_gdt;
31281 -
31282 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31283 __read_mostly int xen_have_vector_callback;
31284 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31285 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31286 {
31287 unsigned long va = dtr->address;
31288 unsigned int size = dtr->size + 1;
31289 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31290 - unsigned long frames[pages];
31291 + unsigned long frames[65536 / PAGE_SIZE];
31292 int f;
31293
31294 /*
31295 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31296 {
31297 unsigned long va = dtr->address;
31298 unsigned int size = dtr->size + 1;
31299 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31300 - unsigned long frames[pages];
31301 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31302 int f;
31303
31304 /*
31305 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31306 * 8-byte entries, or 16 4k pages..
31307 */
31308
31309 - BUG_ON(size > 65536);
31310 + BUG_ON(size > GDT_SIZE);
31311 BUG_ON(va & ~PAGE_MASK);
31312
31313 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31314 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31315 return 0;
31316 }
31317
31318 -static void set_xen_basic_apic_ops(void)
31319 +static void __init set_xen_basic_apic_ops(void)
31320 {
31321 apic->read = xen_apic_read;
31322 apic->write = xen_apic_write;
31323 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31324 #endif
31325 };
31326
31327 -static void xen_reboot(int reason)
31328 +static __noreturn void xen_reboot(int reason)
31329 {
31330 struct sched_shutdown r = { .reason = reason };
31331
31332 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31333 - BUG();
31334 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31335 + BUG();
31336 }
31337
31338 -static void xen_restart(char *msg)
31339 +static __noreturn void xen_restart(char *msg)
31340 {
31341 xen_reboot(SHUTDOWN_reboot);
31342 }
31343
31344 -static void xen_emergency_restart(void)
31345 +static __noreturn void xen_emergency_restart(void)
31346 {
31347 xen_reboot(SHUTDOWN_reboot);
31348 }
31349
31350 -static void xen_machine_halt(void)
31351 +static __noreturn void xen_machine_halt(void)
31352 {
31353 xen_reboot(SHUTDOWN_poweroff);
31354 }
31355
31356 -static void xen_machine_power_off(void)
31357 +static __noreturn void xen_machine_power_off(void)
31358 {
31359 if (pm_power_off)
31360 pm_power_off();
31361 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
31362 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31363
31364 /* Work out if we support NX */
31365 - x86_configure_nx();
31366 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31367 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31368 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31369 + unsigned l, h;
31370 +
31371 + __supported_pte_mask |= _PAGE_NX;
31372 + rdmsr(MSR_EFER, l, h);
31373 + l |= EFER_NX;
31374 + wrmsr(MSR_EFER, l, h);
31375 + }
31376 +#endif
31377
31378 xen_setup_features();
31379
31380 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
31381
31382 machine_ops = xen_machine_ops;
31383
31384 - /*
31385 - * The only reliable way to retain the initial address of the
31386 - * percpu gdt_page is to remember it here, so we can go and
31387 - * mark it RW later, when the initial percpu area is freed.
31388 - */
31389 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31390 -
31391 xen_smp_init();
31392
31393 #ifdef CONFIG_ACPI_NUMA
31394 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31395 return NOTIFY_OK;
31396 }
31397
31398 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31399 +static struct notifier_block xen_hvm_cpu_notifier = {
31400 .notifier_call = xen_hvm_cpu_notify,
31401 };
31402
31403 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31404 index fdc3ba2..3daee39 100644
31405 --- a/arch/x86/xen/mmu.c
31406 +++ b/arch/x86/xen/mmu.c
31407 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31408 /* L3_k[510] -> level2_kernel_pgt
31409 * L3_i[511] -> level2_fixmap_pgt */
31410 convert_pfn_mfn(level3_kernel_pgt);
31411 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31412 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31413 + convert_pfn_mfn(level3_vmemmap_pgt);
31414
31415 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31416 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31417 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31418 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31419 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31420 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31421 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31422 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31423 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31424 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31425 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31426 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31427 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31428 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31429
31430 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
31431 pv_mmu_ops.set_pud = xen_set_pud;
31432 #if PAGETABLE_LEVELS == 4
31433 pv_mmu_ops.set_pgd = xen_set_pgd;
31434 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31435 #endif
31436
31437 /* This will work as long as patching hasn't happened yet
31438 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31439 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31440 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31441 .set_pgd = xen_set_pgd_hyper,
31442 + .set_pgd_batched = xen_set_pgd_hyper,
31443
31444 .alloc_pud = xen_alloc_pmd_init,
31445 .release_pud = xen_release_pmd_init,
31446 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31447 index d99cae8..18401e1 100644
31448 --- a/arch/x86/xen/smp.c
31449 +++ b/arch/x86/xen/smp.c
31450 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31451 {
31452 BUG_ON(smp_processor_id() != 0);
31453 native_smp_prepare_boot_cpu();
31454 -
31455 - /* We've switched to the "real" per-cpu gdt, so make sure the
31456 - old memory can be recycled */
31457 - make_lowmem_page_readwrite(xen_initial_gdt);
31458 -
31459 xen_filter_cpu_maps();
31460 xen_setup_vcpu_info_placement();
31461 }
31462 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31463 ctxt->user_regs.ss = __KERNEL_DS;
31464 #ifdef CONFIG_X86_32
31465 ctxt->user_regs.fs = __KERNEL_PERCPU;
31466 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31467 + savesegment(gs, ctxt->user_regs.gs);
31468 #else
31469 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31470 #endif
31471 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31472
31473 {
31474 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31475 - ctxt->user_regs.ds = __USER_DS;
31476 - ctxt->user_regs.es = __USER_DS;
31477 + ctxt->user_regs.ds = __KERNEL_DS;
31478 + ctxt->user_regs.es = __KERNEL_DS;
31479
31480 xen_copy_trap_info(ctxt->trap_ctxt);
31481
31482 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31483 int rc;
31484
31485 per_cpu(current_task, cpu) = idle;
31486 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31487 #ifdef CONFIG_X86_32
31488 irq_ctx_init(cpu);
31489 #else
31490 clear_tsk_thread_flag(idle, TIF_FORK);
31491 - per_cpu(kernel_stack, cpu) =
31492 - (unsigned long)task_stack_page(idle) -
31493 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31494 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31495 #endif
31496 xen_setup_runstate_info(cpu);
31497 xen_setup_timer(cpu);
31498 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31499
31500 void __init xen_smp_init(void)
31501 {
31502 - smp_ops = xen_smp_ops;
31503 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31504 xen_fill_possible_map();
31505 xen_init_spinlocks();
31506 }
31507 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31508 index 33ca6e4..0ded929 100644
31509 --- a/arch/x86/xen/xen-asm_32.S
31510 +++ b/arch/x86/xen/xen-asm_32.S
31511 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31512 ESP_OFFSET=4 # bytes pushed onto stack
31513
31514 /*
31515 - * Store vcpu_info pointer for easy access. Do it this way to
31516 - * avoid having to reload %fs
31517 + * Store vcpu_info pointer for easy access.
31518 */
31519 #ifdef CONFIG_SMP
31520 - GET_THREAD_INFO(%eax)
31521 - movl %ss:TI_cpu(%eax), %eax
31522 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31523 - mov %ss:xen_vcpu(%eax), %eax
31524 + push %fs
31525 + mov $(__KERNEL_PERCPU), %eax
31526 + mov %eax, %fs
31527 + mov PER_CPU_VAR(xen_vcpu), %eax
31528 + pop %fs
31529 #else
31530 movl %ss:xen_vcpu, %eax
31531 #endif
31532 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31533 index 7faed58..ba4427c 100644
31534 --- a/arch/x86/xen/xen-head.S
31535 +++ b/arch/x86/xen/xen-head.S
31536 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31537 #ifdef CONFIG_X86_32
31538 mov %esi,xen_start_info
31539 mov $init_thread_union+THREAD_SIZE,%esp
31540 +#ifdef CONFIG_SMP
31541 + movl $cpu_gdt_table,%edi
31542 + movl $__per_cpu_load,%eax
31543 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31544 + rorl $16,%eax
31545 + movb %al,__KERNEL_PERCPU + 4(%edi)
31546 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31547 + movl $__per_cpu_end - 1,%eax
31548 + subl $__per_cpu_start,%eax
31549 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31550 +#endif
31551 #else
31552 mov %rsi,xen_start_info
31553 mov $init_thread_union+THREAD_SIZE,%rsp
31554 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31555 index a95b417..b6dbd0b 100644
31556 --- a/arch/x86/xen/xen-ops.h
31557 +++ b/arch/x86/xen/xen-ops.h
31558 @@ -10,8 +10,6 @@
31559 extern const char xen_hypervisor_callback[];
31560 extern const char xen_failsafe_callback[];
31561
31562 -extern void *xen_initial_gdt;
31563 -
31564 struct trap_info;
31565 void xen_copy_trap_info(struct trap_info *traps);
31566
31567 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31568 index 525bd3d..ef888b1 100644
31569 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31570 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31571 @@ -119,9 +119,9 @@
31572 ----------------------------------------------------------------------*/
31573
31574 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31575 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31576 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31577 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31578 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31579
31580 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31581 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31582 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31583 index 2f33760..835e50a 100644
31584 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31585 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31586 @@ -11,6 +11,7 @@
31587 #ifndef _XTENSA_CORE_H
31588 #define _XTENSA_CORE_H
31589
31590 +#include <linux/const.h>
31591
31592 /****************************************************************************
31593 Parameters Useful for Any Code, USER or PRIVILEGED
31594 @@ -112,9 +113,9 @@
31595 ----------------------------------------------------------------------*/
31596
31597 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31598 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31599 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31600 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31601 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31602
31603 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31604 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31605 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31606 index af00795..2bb8105 100644
31607 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31608 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31609 @@ -11,6 +11,7 @@
31610 #ifndef _XTENSA_CORE_CONFIGURATION_H
31611 #define _XTENSA_CORE_CONFIGURATION_H
31612
31613 +#include <linux/const.h>
31614
31615 /****************************************************************************
31616 Parameters Useful for Any Code, USER or PRIVILEGED
31617 @@ -118,9 +119,9 @@
31618 ----------------------------------------------------------------------*/
31619
31620 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31621 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31622 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31623 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31624 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31625
31626 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31627 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31628 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31629 index 58916af..eb9dbcf6 100644
31630 --- a/block/blk-iopoll.c
31631 +++ b/block/blk-iopoll.c
31632 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31633 }
31634 EXPORT_SYMBOL(blk_iopoll_complete);
31635
31636 -static void blk_iopoll_softirq(struct softirq_action *h)
31637 +static void blk_iopoll_softirq(void)
31638 {
31639 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31640 int rearm = 0, budget = blk_iopoll_budget;
31641 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31642 return NOTIFY_OK;
31643 }
31644
31645 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31646 +static struct notifier_block blk_iopoll_cpu_notifier = {
31647 .notifier_call = blk_iopoll_cpu_notify,
31648 };
31649
31650 diff --git a/block/blk-map.c b/block/blk-map.c
31651 index 623e1cd..ca1e109 100644
31652 --- a/block/blk-map.c
31653 +++ b/block/blk-map.c
31654 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31655 if (!len || !kbuf)
31656 return -EINVAL;
31657
31658 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31659 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31660 if (do_copy)
31661 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31662 else
31663 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31664 index 467c8de..f3628c5 100644
31665 --- a/block/blk-softirq.c
31666 +++ b/block/blk-softirq.c
31667 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31668 * Softirq action handler - move entries to local list and loop over them
31669 * while passing them to the queue registered handler.
31670 */
31671 -static void blk_done_softirq(struct softirq_action *h)
31672 +static void blk_done_softirq(void)
31673 {
31674 struct list_head *cpu_list, local_list;
31675
31676 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31677 return NOTIFY_OK;
31678 }
31679
31680 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31681 +static struct notifier_block blk_cpu_notifier = {
31682 .notifier_call = blk_cpu_notify,
31683 };
31684
31685 diff --git a/block/bsg.c b/block/bsg.c
31686 index 420a5a9..23834aa 100644
31687 --- a/block/bsg.c
31688 +++ b/block/bsg.c
31689 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31690 struct sg_io_v4 *hdr, struct bsg_device *bd,
31691 fmode_t has_write_perm)
31692 {
31693 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31694 + unsigned char *cmdptr;
31695 +
31696 if (hdr->request_len > BLK_MAX_CDB) {
31697 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31698 if (!rq->cmd)
31699 return -ENOMEM;
31700 - }
31701 + cmdptr = rq->cmd;
31702 + } else
31703 + cmdptr = tmpcmd;
31704
31705 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31706 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31707 hdr->request_len))
31708 return -EFAULT;
31709
31710 + if (cmdptr != rq->cmd)
31711 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31712 +
31713 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31714 if (blk_verify_command(rq->cmd, has_write_perm))
31715 return -EPERM;
31716 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31717 index 7c668c8..db3521c 100644
31718 --- a/block/compat_ioctl.c
31719 +++ b/block/compat_ioctl.c
31720 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31721 err |= __get_user(f->spec1, &uf->spec1);
31722 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31723 err |= __get_user(name, &uf->name);
31724 - f->name = compat_ptr(name);
31725 + f->name = (void __force_kernel *)compat_ptr(name);
31726 if (err) {
31727 err = -EFAULT;
31728 goto out;
31729 diff --git a/block/genhd.c b/block/genhd.c
31730 index cdeb527..10aa34d 100644
31731 --- a/block/genhd.c
31732 +++ b/block/genhd.c
31733 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31734
31735 /*
31736 * Register device numbers dev..(dev+range-1)
31737 - * range must be nonzero
31738 + * Noop if @range is zero.
31739 * The hash chain is sorted on range, so that subranges can override.
31740 */
31741 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31742 struct kobject *(*probe)(dev_t, int *, void *),
31743 int (*lock)(dev_t, void *), void *data)
31744 {
31745 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31746 + if (range)
31747 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31748 }
31749
31750 EXPORT_SYMBOL(blk_register_region);
31751
31752 +/* undo blk_register_region(), noop if @range is zero */
31753 void blk_unregister_region(dev_t devt, unsigned long range)
31754 {
31755 - kobj_unmap(bdev_map, devt, range);
31756 + if (range)
31757 + kobj_unmap(bdev_map, devt, range);
31758 }
31759
31760 EXPORT_SYMBOL(blk_unregister_region);
31761 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31762 index c85fc89..51e690b 100644
31763 --- a/block/partitions/efi.c
31764 +++ b/block/partitions/efi.c
31765 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31766 if (!gpt)
31767 return NULL;
31768
31769 + if (!le32_to_cpu(gpt->num_partition_entries))
31770 + return NULL;
31771 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31772 + if (!pte)
31773 + return NULL;
31774 +
31775 count = le32_to_cpu(gpt->num_partition_entries) *
31776 le32_to_cpu(gpt->sizeof_partition_entry);
31777 - if (!count)
31778 - return NULL;
31779 - pte = kmalloc(count, GFP_KERNEL);
31780 - if (!pte)
31781 - return NULL;
31782 -
31783 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31784 (u8 *) pte,
31785 count) < count) {
31786 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31787 index a5ffcc9..3cedc9c 100644
31788 --- a/block/scsi_ioctl.c
31789 +++ b/block/scsi_ioctl.c
31790 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
31791 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31792 struct sg_io_hdr *hdr, fmode_t mode)
31793 {
31794 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31795 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31796 + unsigned char *cmdptr;
31797 +
31798 + if (rq->cmd != rq->__cmd)
31799 + cmdptr = rq->cmd;
31800 + else
31801 + cmdptr = tmpcmd;
31802 +
31803 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31804 return -EFAULT;
31805 +
31806 + if (cmdptr != rq->cmd)
31807 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31808 +
31809 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31810 return -EPERM;
31811
31812 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31813 int err;
31814 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31815 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31816 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31817 + unsigned char *cmdptr;
31818
31819 if (!sic)
31820 return -EINVAL;
31821 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31822 */
31823 err = -EFAULT;
31824 rq->cmd_len = cmdlen;
31825 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31826 +
31827 + if (rq->cmd != rq->__cmd)
31828 + cmdptr = rq->cmd;
31829 + else
31830 + cmdptr = tmpcmd;
31831 +
31832 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31833 goto error;
31834
31835 + if (rq->cmd != cmdptr)
31836 + memcpy(rq->cmd, cmdptr, cmdlen);
31837 +
31838 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31839 goto error;
31840
31841 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31842 index 7bdd61b..afec999 100644
31843 --- a/crypto/cryptd.c
31844 +++ b/crypto/cryptd.c
31845 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31846
31847 struct cryptd_blkcipher_request_ctx {
31848 crypto_completion_t complete;
31849 -};
31850 +} __no_const;
31851
31852 struct cryptd_hash_ctx {
31853 struct crypto_shash *child;
31854 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31855
31856 struct cryptd_aead_request_ctx {
31857 crypto_completion_t complete;
31858 -};
31859 +} __no_const;
31860
31861 static void cryptd_queue_worker(struct work_struct *work);
31862
31863 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31864 index b2c99dc..476c9fb 100644
31865 --- a/crypto/pcrypt.c
31866 +++ b/crypto/pcrypt.c
31867 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31868 int ret;
31869
31870 pinst->kobj.kset = pcrypt_kset;
31871 - ret = kobject_add(&pinst->kobj, NULL, name);
31872 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31873 if (!ret)
31874 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31875
31876 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31877
31878 get_online_cpus();
31879
31880 - pcrypt->wq = alloc_workqueue(name,
31881 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31882 + pcrypt->wq = alloc_workqueue("%s",
31883 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31884 if (!pcrypt->wq)
31885 goto err;
31886
31887 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31888 index f220d64..d359ad6 100644
31889 --- a/drivers/acpi/apei/apei-internal.h
31890 +++ b/drivers/acpi/apei/apei-internal.h
31891 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31892 struct apei_exec_ins_type {
31893 u32 flags;
31894 apei_exec_ins_func_t run;
31895 -};
31896 +} __do_const;
31897
31898 struct apei_exec_context {
31899 u32 ip;
31900 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31901 index 33dc6a0..4b24b47 100644
31902 --- a/drivers/acpi/apei/cper.c
31903 +++ b/drivers/acpi/apei/cper.c
31904 @@ -39,12 +39,12 @@
31905 */
31906 u64 cper_next_record_id(void)
31907 {
31908 - static atomic64_t seq;
31909 + static atomic64_unchecked_t seq;
31910
31911 - if (!atomic64_read(&seq))
31912 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31913 + if (!atomic64_read_unchecked(&seq))
31914 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31915
31916 - return atomic64_inc_return(&seq);
31917 + return atomic64_inc_return_unchecked(&seq);
31918 }
31919 EXPORT_SYMBOL_GPL(cper_next_record_id);
31920
31921 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31922 index be60399..778b33e8 100644
31923 --- a/drivers/acpi/bgrt.c
31924 +++ b/drivers/acpi/bgrt.c
31925 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31926 return -ENODEV;
31927
31928 sysfs_bin_attr_init(&image_attr);
31929 - image_attr.private = bgrt_image;
31930 - image_attr.size = bgrt_image_size;
31931 + pax_open_kernel();
31932 + *(void **)&image_attr.private = bgrt_image;
31933 + *(size_t *)&image_attr.size = bgrt_image_size;
31934 + pax_close_kernel();
31935
31936 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31937 if (!bgrt_kobj)
31938 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31939 index cb96296..b81293b 100644
31940 --- a/drivers/acpi/blacklist.c
31941 +++ b/drivers/acpi/blacklist.c
31942 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31943 u32 is_critical_error;
31944 };
31945
31946 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31947 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31948
31949 /*
31950 * POLICY: If *anything* doesn't work, put it on the blacklist.
31951 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31952 return 0;
31953 }
31954
31955 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31956 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31957 {
31958 .callback = dmi_disable_osi_vista,
31959 .ident = "Fujitsu Siemens",
31960 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31961 index 7586544..636a2f0 100644
31962 --- a/drivers/acpi/ec_sys.c
31963 +++ b/drivers/acpi/ec_sys.c
31964 @@ -12,6 +12,7 @@
31965 #include <linux/acpi.h>
31966 #include <linux/debugfs.h>
31967 #include <linux/module.h>
31968 +#include <linux/uaccess.h>
31969 #include "internal.h"
31970
31971 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31972 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31973 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31974 */
31975 unsigned int size = EC_SPACE_SIZE;
31976 - u8 *data = (u8 *) buf;
31977 + u8 data;
31978 loff_t init_off = *off;
31979 int err = 0;
31980
31981 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31982 size = count;
31983
31984 while (size) {
31985 - err = ec_read(*off, &data[*off - init_off]);
31986 + err = ec_read(*off, &data);
31987 if (err)
31988 return err;
31989 + if (put_user(data, &buf[*off - init_off]))
31990 + return -EFAULT;
31991 *off += 1;
31992 size--;
31993 }
31994 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31995
31996 unsigned int size = count;
31997 loff_t init_off = *off;
31998 - u8 *data = (u8 *) buf;
31999 int err = 0;
32000
32001 if (*off >= EC_SPACE_SIZE)
32002 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32003 }
32004
32005 while (size) {
32006 - u8 byte_write = data[*off - init_off];
32007 + u8 byte_write;
32008 + if (get_user(byte_write, &buf[*off - init_off]))
32009 + return -EFAULT;
32010 err = ec_write(*off, byte_write);
32011 if (err)
32012 return err;
32013 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32014 index eb133c7..f571552 100644
32015 --- a/drivers/acpi/processor_idle.c
32016 +++ b/drivers/acpi/processor_idle.c
32017 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32018 {
32019 int i, count = CPUIDLE_DRIVER_STATE_START;
32020 struct acpi_processor_cx *cx;
32021 - struct cpuidle_state *state;
32022 + cpuidle_state_no_const *state;
32023 struct cpuidle_driver *drv = &acpi_idle_driver;
32024
32025 if (!pr->flags.power_setup_done)
32026 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32027 index fcae5fa..e9f71ea 100644
32028 --- a/drivers/acpi/sysfs.c
32029 +++ b/drivers/acpi/sysfs.c
32030 @@ -423,11 +423,11 @@ static u32 num_counters;
32031 static struct attribute **all_attrs;
32032 static u32 acpi_gpe_count;
32033
32034 -static struct attribute_group interrupt_stats_attr_group = {
32035 +static attribute_group_no_const interrupt_stats_attr_group = {
32036 .name = "interrupts",
32037 };
32038
32039 -static struct kobj_attribute *counter_attrs;
32040 +static kobj_attribute_no_const *counter_attrs;
32041
32042 static void delete_gpe_attr_array(void)
32043 {
32044 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32045 index a70ff15..f1ff44e 100644
32046 --- a/drivers/ata/libahci.c
32047 +++ b/drivers/ata/libahci.c
32048 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32049 }
32050 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32051
32052 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32053 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32054 struct ata_taskfile *tf, int is_cmd, u16 flags,
32055 unsigned long timeout_msec)
32056 {
32057 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32058 index adf002a..39bb8f9 100644
32059 --- a/drivers/ata/libata-core.c
32060 +++ b/drivers/ata/libata-core.c
32061 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32062 struct ata_port *ap;
32063 unsigned int tag;
32064
32065 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32066 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32067 ap = qc->ap;
32068
32069 qc->flags = 0;
32070 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32071 struct ata_port *ap;
32072 struct ata_link *link;
32073
32074 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32075 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32076 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32077 ap = qc->ap;
32078 link = qc->dev->link;
32079 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32080 return;
32081
32082 spin_lock(&lock);
32083 + pax_open_kernel();
32084
32085 for (cur = ops->inherits; cur; cur = cur->inherits) {
32086 void **inherit = (void **)cur;
32087 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32088 if (IS_ERR(*pp))
32089 *pp = NULL;
32090
32091 - ops->inherits = NULL;
32092 + *(struct ata_port_operations **)&ops->inherits = NULL;
32093
32094 + pax_close_kernel();
32095 spin_unlock(&lock);
32096 }
32097
32098 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32099 index 7638121..357a965 100644
32100 --- a/drivers/ata/pata_arasan_cf.c
32101 +++ b/drivers/ata/pata_arasan_cf.c
32102 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32103 /* Handle platform specific quirks */
32104 if (quirk) {
32105 if (quirk & CF_BROKEN_PIO) {
32106 - ap->ops->set_piomode = NULL;
32107 + pax_open_kernel();
32108 + *(void **)&ap->ops->set_piomode = NULL;
32109 + pax_close_kernel();
32110 ap->pio_mask = 0;
32111 }
32112 if (quirk & CF_BROKEN_MWDMA)
32113 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32114 index f9b983a..887b9d8 100644
32115 --- a/drivers/atm/adummy.c
32116 +++ b/drivers/atm/adummy.c
32117 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32118 vcc->pop(vcc, skb);
32119 else
32120 dev_kfree_skb_any(skb);
32121 - atomic_inc(&vcc->stats->tx);
32122 + atomic_inc_unchecked(&vcc->stats->tx);
32123
32124 return 0;
32125 }
32126 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32127 index 77a7480d..05cde58 100644
32128 --- a/drivers/atm/ambassador.c
32129 +++ b/drivers/atm/ambassador.c
32130 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32131 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32132
32133 // VC layer stats
32134 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32135 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32136
32137 // free the descriptor
32138 kfree (tx_descr);
32139 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32140 dump_skb ("<<<", vc, skb);
32141
32142 // VC layer stats
32143 - atomic_inc(&atm_vcc->stats->rx);
32144 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32145 __net_timestamp(skb);
32146 // end of our responsibility
32147 atm_vcc->push (atm_vcc, skb);
32148 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32149 } else {
32150 PRINTK (KERN_INFO, "dropped over-size frame");
32151 // should we count this?
32152 - atomic_inc(&atm_vcc->stats->rx_drop);
32153 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32154 }
32155
32156 } else {
32157 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32158 }
32159
32160 if (check_area (skb->data, skb->len)) {
32161 - atomic_inc(&atm_vcc->stats->tx_err);
32162 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32163 return -ENOMEM; // ?
32164 }
32165
32166 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32167 index 0e3f8f9..765a7a5 100644
32168 --- a/drivers/atm/atmtcp.c
32169 +++ b/drivers/atm/atmtcp.c
32170 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32171 if (vcc->pop) vcc->pop(vcc,skb);
32172 else dev_kfree_skb(skb);
32173 if (dev_data) return 0;
32174 - atomic_inc(&vcc->stats->tx_err);
32175 + atomic_inc_unchecked(&vcc->stats->tx_err);
32176 return -ENOLINK;
32177 }
32178 size = skb->len+sizeof(struct atmtcp_hdr);
32179 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32180 if (!new_skb) {
32181 if (vcc->pop) vcc->pop(vcc,skb);
32182 else dev_kfree_skb(skb);
32183 - atomic_inc(&vcc->stats->tx_err);
32184 + atomic_inc_unchecked(&vcc->stats->tx_err);
32185 return -ENOBUFS;
32186 }
32187 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32188 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32189 if (vcc->pop) vcc->pop(vcc,skb);
32190 else dev_kfree_skb(skb);
32191 out_vcc->push(out_vcc,new_skb);
32192 - atomic_inc(&vcc->stats->tx);
32193 - atomic_inc(&out_vcc->stats->rx);
32194 + atomic_inc_unchecked(&vcc->stats->tx);
32195 + atomic_inc_unchecked(&out_vcc->stats->rx);
32196 return 0;
32197 }
32198
32199 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32200 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32201 read_unlock(&vcc_sklist_lock);
32202 if (!out_vcc) {
32203 - atomic_inc(&vcc->stats->tx_err);
32204 + atomic_inc_unchecked(&vcc->stats->tx_err);
32205 goto done;
32206 }
32207 skb_pull(skb,sizeof(struct atmtcp_hdr));
32208 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32209 __net_timestamp(new_skb);
32210 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32211 out_vcc->push(out_vcc,new_skb);
32212 - atomic_inc(&vcc->stats->tx);
32213 - atomic_inc(&out_vcc->stats->rx);
32214 + atomic_inc_unchecked(&vcc->stats->tx);
32215 + atomic_inc_unchecked(&out_vcc->stats->rx);
32216 done:
32217 if (vcc->pop) vcc->pop(vcc,skb);
32218 else dev_kfree_skb(skb);
32219 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32220 index b1955ba..b179940 100644
32221 --- a/drivers/atm/eni.c
32222 +++ b/drivers/atm/eni.c
32223 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32224 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32225 vcc->dev->number);
32226 length = 0;
32227 - atomic_inc(&vcc->stats->rx_err);
32228 + atomic_inc_unchecked(&vcc->stats->rx_err);
32229 }
32230 else {
32231 length = ATM_CELL_SIZE-1; /* no HEC */
32232 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32233 size);
32234 }
32235 eff = length = 0;
32236 - atomic_inc(&vcc->stats->rx_err);
32237 + atomic_inc_unchecked(&vcc->stats->rx_err);
32238 }
32239 else {
32240 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32241 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32242 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32243 vcc->dev->number,vcc->vci,length,size << 2,descr);
32244 length = eff = 0;
32245 - atomic_inc(&vcc->stats->rx_err);
32246 + atomic_inc_unchecked(&vcc->stats->rx_err);
32247 }
32248 }
32249 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32250 @@ -767,7 +767,7 @@ rx_dequeued++;
32251 vcc->push(vcc,skb);
32252 pushed++;
32253 }
32254 - atomic_inc(&vcc->stats->rx);
32255 + atomic_inc_unchecked(&vcc->stats->rx);
32256 }
32257 wake_up(&eni_dev->rx_wait);
32258 }
32259 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32260 PCI_DMA_TODEVICE);
32261 if (vcc->pop) vcc->pop(vcc,skb);
32262 else dev_kfree_skb_irq(skb);
32263 - atomic_inc(&vcc->stats->tx);
32264 + atomic_inc_unchecked(&vcc->stats->tx);
32265 wake_up(&eni_dev->tx_wait);
32266 dma_complete++;
32267 }
32268 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32269 index b41c948..a002b17 100644
32270 --- a/drivers/atm/firestream.c
32271 +++ b/drivers/atm/firestream.c
32272 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32273 }
32274 }
32275
32276 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32277 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32278
32279 fs_dprintk (FS_DEBUG_TXMEM, "i");
32280 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32281 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32282 #endif
32283 skb_put (skb, qe->p1 & 0xffff);
32284 ATM_SKB(skb)->vcc = atm_vcc;
32285 - atomic_inc(&atm_vcc->stats->rx);
32286 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32287 __net_timestamp(skb);
32288 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32289 atm_vcc->push (atm_vcc, skb);
32290 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32291 kfree (pe);
32292 }
32293 if (atm_vcc)
32294 - atomic_inc(&atm_vcc->stats->rx_drop);
32295 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32296 break;
32297 case 0x1f: /* Reassembly abort: no buffers. */
32298 /* Silently increment error counter. */
32299 if (atm_vcc)
32300 - atomic_inc(&atm_vcc->stats->rx_drop);
32301 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32302 break;
32303 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32304 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32305 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32306 index 204814e..cede831 100644
32307 --- a/drivers/atm/fore200e.c
32308 +++ b/drivers/atm/fore200e.c
32309 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32310 #endif
32311 /* check error condition */
32312 if (*entry->status & STATUS_ERROR)
32313 - atomic_inc(&vcc->stats->tx_err);
32314 + atomic_inc_unchecked(&vcc->stats->tx_err);
32315 else
32316 - atomic_inc(&vcc->stats->tx);
32317 + atomic_inc_unchecked(&vcc->stats->tx);
32318 }
32319 }
32320
32321 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32322 if (skb == NULL) {
32323 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32324
32325 - atomic_inc(&vcc->stats->rx_drop);
32326 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32327 return -ENOMEM;
32328 }
32329
32330 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32331
32332 dev_kfree_skb_any(skb);
32333
32334 - atomic_inc(&vcc->stats->rx_drop);
32335 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32336 return -ENOMEM;
32337 }
32338
32339 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32340
32341 vcc->push(vcc, skb);
32342 - atomic_inc(&vcc->stats->rx);
32343 + atomic_inc_unchecked(&vcc->stats->rx);
32344
32345 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32346
32347 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32348 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32349 fore200e->atm_dev->number,
32350 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32351 - atomic_inc(&vcc->stats->rx_err);
32352 + atomic_inc_unchecked(&vcc->stats->rx_err);
32353 }
32354 }
32355
32356 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32357 goto retry_here;
32358 }
32359
32360 - atomic_inc(&vcc->stats->tx_err);
32361 + atomic_inc_unchecked(&vcc->stats->tx_err);
32362
32363 fore200e->tx_sat++;
32364 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32365 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32366 index 507362a..a845e57 100644
32367 --- a/drivers/atm/he.c
32368 +++ b/drivers/atm/he.c
32369 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32370
32371 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32372 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32373 - atomic_inc(&vcc->stats->rx_drop);
32374 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32375 goto return_host_buffers;
32376 }
32377
32378 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32379 RBRQ_LEN_ERR(he_dev->rbrq_head)
32380 ? "LEN_ERR" : "",
32381 vcc->vpi, vcc->vci);
32382 - atomic_inc(&vcc->stats->rx_err);
32383 + atomic_inc_unchecked(&vcc->stats->rx_err);
32384 goto return_host_buffers;
32385 }
32386
32387 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32388 vcc->push(vcc, skb);
32389 spin_lock(&he_dev->global_lock);
32390
32391 - atomic_inc(&vcc->stats->rx);
32392 + atomic_inc_unchecked(&vcc->stats->rx);
32393
32394 return_host_buffers:
32395 ++pdus_assembled;
32396 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32397 tpd->vcc->pop(tpd->vcc, tpd->skb);
32398 else
32399 dev_kfree_skb_any(tpd->skb);
32400 - atomic_inc(&tpd->vcc->stats->tx_err);
32401 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32402 }
32403 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32404 return;
32405 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32406 vcc->pop(vcc, skb);
32407 else
32408 dev_kfree_skb_any(skb);
32409 - atomic_inc(&vcc->stats->tx_err);
32410 + atomic_inc_unchecked(&vcc->stats->tx_err);
32411 return -EINVAL;
32412 }
32413
32414 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32415 vcc->pop(vcc, skb);
32416 else
32417 dev_kfree_skb_any(skb);
32418 - atomic_inc(&vcc->stats->tx_err);
32419 + atomic_inc_unchecked(&vcc->stats->tx_err);
32420 return -EINVAL;
32421 }
32422 #endif
32423 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32424 vcc->pop(vcc, skb);
32425 else
32426 dev_kfree_skb_any(skb);
32427 - atomic_inc(&vcc->stats->tx_err);
32428 + atomic_inc_unchecked(&vcc->stats->tx_err);
32429 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32430 return -ENOMEM;
32431 }
32432 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32433 vcc->pop(vcc, skb);
32434 else
32435 dev_kfree_skb_any(skb);
32436 - atomic_inc(&vcc->stats->tx_err);
32437 + atomic_inc_unchecked(&vcc->stats->tx_err);
32438 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32439 return -ENOMEM;
32440 }
32441 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32442 __enqueue_tpd(he_dev, tpd, cid);
32443 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32444
32445 - atomic_inc(&vcc->stats->tx);
32446 + atomic_inc_unchecked(&vcc->stats->tx);
32447
32448 return 0;
32449 }
32450 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32451 index 1dc0519..1aadaf7 100644
32452 --- a/drivers/atm/horizon.c
32453 +++ b/drivers/atm/horizon.c
32454 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32455 {
32456 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32457 // VC layer stats
32458 - atomic_inc(&vcc->stats->rx);
32459 + atomic_inc_unchecked(&vcc->stats->rx);
32460 __net_timestamp(skb);
32461 // end of our responsibility
32462 vcc->push (vcc, skb);
32463 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32464 dev->tx_iovec = NULL;
32465
32466 // VC layer stats
32467 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32468 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32469
32470 // free the skb
32471 hrz_kfree_skb (skb);
32472 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32473 index 272f009..a18ba55 100644
32474 --- a/drivers/atm/idt77252.c
32475 +++ b/drivers/atm/idt77252.c
32476 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32477 else
32478 dev_kfree_skb(skb);
32479
32480 - atomic_inc(&vcc->stats->tx);
32481 + atomic_inc_unchecked(&vcc->stats->tx);
32482 }
32483
32484 atomic_dec(&scq->used);
32485 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32486 if ((sb = dev_alloc_skb(64)) == NULL) {
32487 printk("%s: Can't allocate buffers for aal0.\n",
32488 card->name);
32489 - atomic_add(i, &vcc->stats->rx_drop);
32490 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32491 break;
32492 }
32493 if (!atm_charge(vcc, sb->truesize)) {
32494 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32495 card->name);
32496 - atomic_add(i - 1, &vcc->stats->rx_drop);
32497 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32498 dev_kfree_skb(sb);
32499 break;
32500 }
32501 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32502 ATM_SKB(sb)->vcc = vcc;
32503 __net_timestamp(sb);
32504 vcc->push(vcc, sb);
32505 - atomic_inc(&vcc->stats->rx);
32506 + atomic_inc_unchecked(&vcc->stats->rx);
32507
32508 cell += ATM_CELL_PAYLOAD;
32509 }
32510 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32511 "(CDC: %08x)\n",
32512 card->name, len, rpp->len, readl(SAR_REG_CDC));
32513 recycle_rx_pool_skb(card, rpp);
32514 - atomic_inc(&vcc->stats->rx_err);
32515 + atomic_inc_unchecked(&vcc->stats->rx_err);
32516 return;
32517 }
32518 if (stat & SAR_RSQE_CRC) {
32519 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32520 recycle_rx_pool_skb(card, rpp);
32521 - atomic_inc(&vcc->stats->rx_err);
32522 + atomic_inc_unchecked(&vcc->stats->rx_err);
32523 return;
32524 }
32525 if (skb_queue_len(&rpp->queue) > 1) {
32526 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32527 RXPRINTK("%s: Can't alloc RX skb.\n",
32528 card->name);
32529 recycle_rx_pool_skb(card, rpp);
32530 - atomic_inc(&vcc->stats->rx_err);
32531 + atomic_inc_unchecked(&vcc->stats->rx_err);
32532 return;
32533 }
32534 if (!atm_charge(vcc, skb->truesize)) {
32535 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32536 __net_timestamp(skb);
32537
32538 vcc->push(vcc, skb);
32539 - atomic_inc(&vcc->stats->rx);
32540 + atomic_inc_unchecked(&vcc->stats->rx);
32541
32542 return;
32543 }
32544 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32545 __net_timestamp(skb);
32546
32547 vcc->push(vcc, skb);
32548 - atomic_inc(&vcc->stats->rx);
32549 + atomic_inc_unchecked(&vcc->stats->rx);
32550
32551 if (skb->truesize > SAR_FB_SIZE_3)
32552 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32553 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32554 if (vcc->qos.aal != ATM_AAL0) {
32555 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32556 card->name, vpi, vci);
32557 - atomic_inc(&vcc->stats->rx_drop);
32558 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32559 goto drop;
32560 }
32561
32562 if ((sb = dev_alloc_skb(64)) == NULL) {
32563 printk("%s: Can't allocate buffers for AAL0.\n",
32564 card->name);
32565 - atomic_inc(&vcc->stats->rx_err);
32566 + atomic_inc_unchecked(&vcc->stats->rx_err);
32567 goto drop;
32568 }
32569
32570 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32571 ATM_SKB(sb)->vcc = vcc;
32572 __net_timestamp(sb);
32573 vcc->push(vcc, sb);
32574 - atomic_inc(&vcc->stats->rx);
32575 + atomic_inc_unchecked(&vcc->stats->rx);
32576
32577 drop:
32578 skb_pull(queue, 64);
32579 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32580
32581 if (vc == NULL) {
32582 printk("%s: NULL connection in send().\n", card->name);
32583 - atomic_inc(&vcc->stats->tx_err);
32584 + atomic_inc_unchecked(&vcc->stats->tx_err);
32585 dev_kfree_skb(skb);
32586 return -EINVAL;
32587 }
32588 if (!test_bit(VCF_TX, &vc->flags)) {
32589 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32590 - atomic_inc(&vcc->stats->tx_err);
32591 + atomic_inc_unchecked(&vcc->stats->tx_err);
32592 dev_kfree_skb(skb);
32593 return -EINVAL;
32594 }
32595 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32596 break;
32597 default:
32598 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32599 - atomic_inc(&vcc->stats->tx_err);
32600 + atomic_inc_unchecked(&vcc->stats->tx_err);
32601 dev_kfree_skb(skb);
32602 return -EINVAL;
32603 }
32604
32605 if (skb_shinfo(skb)->nr_frags != 0) {
32606 printk("%s: No scatter-gather yet.\n", card->name);
32607 - atomic_inc(&vcc->stats->tx_err);
32608 + atomic_inc_unchecked(&vcc->stats->tx_err);
32609 dev_kfree_skb(skb);
32610 return -EINVAL;
32611 }
32612 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32613
32614 err = queue_skb(card, vc, skb, oam);
32615 if (err) {
32616 - atomic_inc(&vcc->stats->tx_err);
32617 + atomic_inc_unchecked(&vcc->stats->tx_err);
32618 dev_kfree_skb(skb);
32619 return err;
32620 }
32621 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32622 skb = dev_alloc_skb(64);
32623 if (!skb) {
32624 printk("%s: Out of memory in send_oam().\n", card->name);
32625 - atomic_inc(&vcc->stats->tx_err);
32626 + atomic_inc_unchecked(&vcc->stats->tx_err);
32627 return -ENOMEM;
32628 }
32629 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32630 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32631 index 4217f29..88f547a 100644
32632 --- a/drivers/atm/iphase.c
32633 +++ b/drivers/atm/iphase.c
32634 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32635 status = (u_short) (buf_desc_ptr->desc_mode);
32636 if (status & (RX_CER | RX_PTE | RX_OFL))
32637 {
32638 - atomic_inc(&vcc->stats->rx_err);
32639 + atomic_inc_unchecked(&vcc->stats->rx_err);
32640 IF_ERR(printk("IA: bad packet, dropping it");)
32641 if (status & RX_CER) {
32642 IF_ERR(printk(" cause: packet CRC error\n");)
32643 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32644 len = dma_addr - buf_addr;
32645 if (len > iadev->rx_buf_sz) {
32646 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32647 - atomic_inc(&vcc->stats->rx_err);
32648 + atomic_inc_unchecked(&vcc->stats->rx_err);
32649 goto out_free_desc;
32650 }
32651
32652 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32653 ia_vcc = INPH_IA_VCC(vcc);
32654 if (ia_vcc == NULL)
32655 {
32656 - atomic_inc(&vcc->stats->rx_err);
32657 + atomic_inc_unchecked(&vcc->stats->rx_err);
32658 atm_return(vcc, skb->truesize);
32659 dev_kfree_skb_any(skb);
32660 goto INCR_DLE;
32661 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32662 if ((length > iadev->rx_buf_sz) || (length >
32663 (skb->len - sizeof(struct cpcs_trailer))))
32664 {
32665 - atomic_inc(&vcc->stats->rx_err);
32666 + atomic_inc_unchecked(&vcc->stats->rx_err);
32667 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32668 length, skb->len);)
32669 atm_return(vcc, skb->truesize);
32670 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32671
32672 IF_RX(printk("rx_dle_intr: skb push");)
32673 vcc->push(vcc,skb);
32674 - atomic_inc(&vcc->stats->rx);
32675 + atomic_inc_unchecked(&vcc->stats->rx);
32676 iadev->rx_pkt_cnt++;
32677 }
32678 INCR_DLE:
32679 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32680 {
32681 struct k_sonet_stats *stats;
32682 stats = &PRIV(_ia_dev[board])->sonet_stats;
32683 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32684 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32685 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32686 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32687 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32688 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32689 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32690 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32691 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32692 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32693 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32694 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32695 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32696 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32697 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32698 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32699 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32700 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32701 }
32702 ia_cmds.status = 0;
32703 break;
32704 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32705 if ((desc == 0) || (desc > iadev->num_tx_desc))
32706 {
32707 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32708 - atomic_inc(&vcc->stats->tx);
32709 + atomic_inc_unchecked(&vcc->stats->tx);
32710 if (vcc->pop)
32711 vcc->pop(vcc, skb);
32712 else
32713 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32714 ATM_DESC(skb) = vcc->vci;
32715 skb_queue_tail(&iadev->tx_dma_q, skb);
32716
32717 - atomic_inc(&vcc->stats->tx);
32718 + atomic_inc_unchecked(&vcc->stats->tx);
32719 iadev->tx_pkt_cnt++;
32720 /* Increment transaction counter */
32721 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32722
32723 #if 0
32724 /* add flow control logic */
32725 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32726 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32727 if (iavcc->vc_desc_cnt > 10) {
32728 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32729 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32730 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32731 index fa7d701..1e404c7 100644
32732 --- a/drivers/atm/lanai.c
32733 +++ b/drivers/atm/lanai.c
32734 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32735 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32736 lanai_endtx(lanai, lvcc);
32737 lanai_free_skb(lvcc->tx.atmvcc, skb);
32738 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32739 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32740 }
32741
32742 /* Try to fill the buffer - don't call unless there is backlog */
32743 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32744 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32745 __net_timestamp(skb);
32746 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32747 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32748 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32749 out:
32750 lvcc->rx.buf.ptr = end;
32751 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32752 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32753 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32754 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32755 lanai->stats.service_rxnotaal5++;
32756 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32757 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32758 return 0;
32759 }
32760 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32761 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32762 int bytes;
32763 read_unlock(&vcc_sklist_lock);
32764 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32765 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32766 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32767 lvcc->stats.x.aal5.service_trash++;
32768 bytes = (SERVICE_GET_END(s) * 16) -
32769 (((unsigned long) lvcc->rx.buf.ptr) -
32770 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32771 }
32772 if (s & SERVICE_STREAM) {
32773 read_unlock(&vcc_sklist_lock);
32774 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32775 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32776 lvcc->stats.x.aal5.service_stream++;
32777 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32778 "PDU on VCI %d!\n", lanai->number, vci);
32779 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32780 return 0;
32781 }
32782 DPRINTK("got rx crc error on vci %d\n", vci);
32783 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32784 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32785 lvcc->stats.x.aal5.service_rxcrc++;
32786 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32787 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32788 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32789 index 6587dc2..149833d 100644
32790 --- a/drivers/atm/nicstar.c
32791 +++ b/drivers/atm/nicstar.c
32792 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32793 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32794 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32795 card->index);
32796 - atomic_inc(&vcc->stats->tx_err);
32797 + atomic_inc_unchecked(&vcc->stats->tx_err);
32798 dev_kfree_skb_any(skb);
32799 return -EINVAL;
32800 }
32801 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32802 if (!vc->tx) {
32803 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32804 card->index);
32805 - atomic_inc(&vcc->stats->tx_err);
32806 + atomic_inc_unchecked(&vcc->stats->tx_err);
32807 dev_kfree_skb_any(skb);
32808 return -EINVAL;
32809 }
32810 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32811 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32812 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32813 card->index);
32814 - atomic_inc(&vcc->stats->tx_err);
32815 + atomic_inc_unchecked(&vcc->stats->tx_err);
32816 dev_kfree_skb_any(skb);
32817 return -EINVAL;
32818 }
32819
32820 if (skb_shinfo(skb)->nr_frags != 0) {
32821 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32822 - atomic_inc(&vcc->stats->tx_err);
32823 + atomic_inc_unchecked(&vcc->stats->tx_err);
32824 dev_kfree_skb_any(skb);
32825 return -EINVAL;
32826 }
32827 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32828 }
32829
32830 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32831 - atomic_inc(&vcc->stats->tx_err);
32832 + atomic_inc_unchecked(&vcc->stats->tx_err);
32833 dev_kfree_skb_any(skb);
32834 return -EIO;
32835 }
32836 - atomic_inc(&vcc->stats->tx);
32837 + atomic_inc_unchecked(&vcc->stats->tx);
32838
32839 return 0;
32840 }
32841 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32842 printk
32843 ("nicstar%d: Can't allocate buffers for aal0.\n",
32844 card->index);
32845 - atomic_add(i, &vcc->stats->rx_drop);
32846 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32847 break;
32848 }
32849 if (!atm_charge(vcc, sb->truesize)) {
32850 RXPRINTK
32851 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32852 card->index);
32853 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32854 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32855 dev_kfree_skb_any(sb);
32856 break;
32857 }
32858 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32859 ATM_SKB(sb)->vcc = vcc;
32860 __net_timestamp(sb);
32861 vcc->push(vcc, sb);
32862 - atomic_inc(&vcc->stats->rx);
32863 + atomic_inc_unchecked(&vcc->stats->rx);
32864 cell += ATM_CELL_PAYLOAD;
32865 }
32866
32867 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32868 if (iovb == NULL) {
32869 printk("nicstar%d: Out of iovec buffers.\n",
32870 card->index);
32871 - atomic_inc(&vcc->stats->rx_drop);
32872 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32873 recycle_rx_buf(card, skb);
32874 return;
32875 }
32876 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32877 small or large buffer itself. */
32878 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32879 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32880 - atomic_inc(&vcc->stats->rx_err);
32881 + atomic_inc_unchecked(&vcc->stats->rx_err);
32882 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32883 NS_MAX_IOVECS);
32884 NS_PRV_IOVCNT(iovb) = 0;
32885 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32886 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32887 card->index);
32888 which_list(card, skb);
32889 - atomic_inc(&vcc->stats->rx_err);
32890 + atomic_inc_unchecked(&vcc->stats->rx_err);
32891 recycle_rx_buf(card, skb);
32892 vc->rx_iov = NULL;
32893 recycle_iov_buf(card, iovb);
32894 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32895 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32896 card->index);
32897 which_list(card, skb);
32898 - atomic_inc(&vcc->stats->rx_err);
32899 + atomic_inc_unchecked(&vcc->stats->rx_err);
32900 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32901 NS_PRV_IOVCNT(iovb));
32902 vc->rx_iov = NULL;
32903 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32904 printk(" - PDU size mismatch.\n");
32905 else
32906 printk(".\n");
32907 - atomic_inc(&vcc->stats->rx_err);
32908 + atomic_inc_unchecked(&vcc->stats->rx_err);
32909 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32910 NS_PRV_IOVCNT(iovb));
32911 vc->rx_iov = NULL;
32912 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32913 /* skb points to a small buffer */
32914 if (!atm_charge(vcc, skb->truesize)) {
32915 push_rxbufs(card, skb);
32916 - atomic_inc(&vcc->stats->rx_drop);
32917 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32918 } else {
32919 skb_put(skb, len);
32920 dequeue_sm_buf(card, skb);
32921 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32922 ATM_SKB(skb)->vcc = vcc;
32923 __net_timestamp(skb);
32924 vcc->push(vcc, skb);
32925 - atomic_inc(&vcc->stats->rx);
32926 + atomic_inc_unchecked(&vcc->stats->rx);
32927 }
32928 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32929 struct sk_buff *sb;
32930 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32931 if (len <= NS_SMBUFSIZE) {
32932 if (!atm_charge(vcc, sb->truesize)) {
32933 push_rxbufs(card, sb);
32934 - atomic_inc(&vcc->stats->rx_drop);
32935 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32936 } else {
32937 skb_put(sb, len);
32938 dequeue_sm_buf(card, sb);
32939 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32940 ATM_SKB(sb)->vcc = vcc;
32941 __net_timestamp(sb);
32942 vcc->push(vcc, sb);
32943 - atomic_inc(&vcc->stats->rx);
32944 + atomic_inc_unchecked(&vcc->stats->rx);
32945 }
32946
32947 push_rxbufs(card, skb);
32948 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32949
32950 if (!atm_charge(vcc, skb->truesize)) {
32951 push_rxbufs(card, skb);
32952 - atomic_inc(&vcc->stats->rx_drop);
32953 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32954 } else {
32955 dequeue_lg_buf(card, skb);
32956 #ifdef NS_USE_DESTRUCTORS
32957 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32958 ATM_SKB(skb)->vcc = vcc;
32959 __net_timestamp(skb);
32960 vcc->push(vcc, skb);
32961 - atomic_inc(&vcc->stats->rx);
32962 + atomic_inc_unchecked(&vcc->stats->rx);
32963 }
32964
32965 push_rxbufs(card, sb);
32966 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32967 printk
32968 ("nicstar%d: Out of huge buffers.\n",
32969 card->index);
32970 - atomic_inc(&vcc->stats->rx_drop);
32971 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32972 recycle_iovec_rx_bufs(card,
32973 (struct iovec *)
32974 iovb->data,
32975 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32976 card->hbpool.count++;
32977 } else
32978 dev_kfree_skb_any(hb);
32979 - atomic_inc(&vcc->stats->rx_drop);
32980 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32981 } else {
32982 /* Copy the small buffer to the huge buffer */
32983 sb = (struct sk_buff *)iov->iov_base;
32984 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32985 #endif /* NS_USE_DESTRUCTORS */
32986 __net_timestamp(hb);
32987 vcc->push(vcc, hb);
32988 - atomic_inc(&vcc->stats->rx);
32989 + atomic_inc_unchecked(&vcc->stats->rx);
32990 }
32991 }
32992
32993 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32994 index 32784d1..4a8434a 100644
32995 --- a/drivers/atm/solos-pci.c
32996 +++ b/drivers/atm/solos-pci.c
32997 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32998 }
32999 atm_charge(vcc, skb->truesize);
33000 vcc->push(vcc, skb);
33001 - atomic_inc(&vcc->stats->rx);
33002 + atomic_inc_unchecked(&vcc->stats->rx);
33003 break;
33004
33005 case PKT_STATUS:
33006 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33007 vcc = SKB_CB(oldskb)->vcc;
33008
33009 if (vcc) {
33010 - atomic_inc(&vcc->stats->tx);
33011 + atomic_inc_unchecked(&vcc->stats->tx);
33012 solos_pop(vcc, oldskb);
33013 } else {
33014 dev_kfree_skb_irq(oldskb);
33015 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33016 index 0215934..ce9f5b1 100644
33017 --- a/drivers/atm/suni.c
33018 +++ b/drivers/atm/suni.c
33019 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33020
33021
33022 #define ADD_LIMITED(s,v) \
33023 - atomic_add((v),&stats->s); \
33024 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33025 + atomic_add_unchecked((v),&stats->s); \
33026 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33027
33028
33029 static void suni_hz(unsigned long from_timer)
33030 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33031 index 5120a96..e2572bd 100644
33032 --- a/drivers/atm/uPD98402.c
33033 +++ b/drivers/atm/uPD98402.c
33034 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33035 struct sonet_stats tmp;
33036 int error = 0;
33037
33038 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33039 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33040 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33041 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33042 if (zero && !error) {
33043 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33044
33045
33046 #define ADD_LIMITED(s,v) \
33047 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33048 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33049 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33050 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33051 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33052 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33053
33054
33055 static void stat_event(struct atm_dev *dev)
33056 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33057 if (reason & uPD98402_INT_PFM) stat_event(dev);
33058 if (reason & uPD98402_INT_PCO) {
33059 (void) GET(PCOCR); /* clear interrupt cause */
33060 - atomic_add(GET(HECCT),
33061 + atomic_add_unchecked(GET(HECCT),
33062 &PRIV(dev)->sonet_stats.uncorr_hcs);
33063 }
33064 if ((reason & uPD98402_INT_RFO) &&
33065 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33066 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33067 uPD98402_INT_LOS),PIMR); /* enable them */
33068 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33069 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33070 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33071 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33072 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33073 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33074 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33075 return 0;
33076 }
33077
33078 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33079 index 969c3c2..9b72956 100644
33080 --- a/drivers/atm/zatm.c
33081 +++ b/drivers/atm/zatm.c
33082 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33083 }
33084 if (!size) {
33085 dev_kfree_skb_irq(skb);
33086 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33087 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33088 continue;
33089 }
33090 if (!atm_charge(vcc,skb->truesize)) {
33091 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33092 skb->len = size;
33093 ATM_SKB(skb)->vcc = vcc;
33094 vcc->push(vcc,skb);
33095 - atomic_inc(&vcc->stats->rx);
33096 + atomic_inc_unchecked(&vcc->stats->rx);
33097 }
33098 zout(pos & 0xffff,MTA(mbx));
33099 #if 0 /* probably a stupid idea */
33100 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33101 skb_queue_head(&zatm_vcc->backlog,skb);
33102 break;
33103 }
33104 - atomic_inc(&vcc->stats->tx);
33105 + atomic_inc_unchecked(&vcc->stats->tx);
33106 wake_up(&zatm_vcc->tx_wait);
33107 }
33108
33109 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33110 index d78b204..ecc1929 100644
33111 --- a/drivers/base/attribute_container.c
33112 +++ b/drivers/base/attribute_container.c
33113 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33114 ic->classdev.parent = get_device(dev);
33115 ic->classdev.class = cont->class;
33116 cont->class->dev_release = attribute_container_release;
33117 - dev_set_name(&ic->classdev, dev_name(dev));
33118 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33119 if (fn)
33120 fn(cont, dev, &ic->classdev);
33121 else
33122 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33123 index d414331..b4dd4ba 100644
33124 --- a/drivers/base/bus.c
33125 +++ b/drivers/base/bus.c
33126 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33127 return -EINVAL;
33128
33129 mutex_lock(&subsys->p->mutex);
33130 - list_add_tail(&sif->node, &subsys->p->interfaces);
33131 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33132 if (sif->add_dev) {
33133 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33134 while ((dev = subsys_dev_iter_next(&iter)))
33135 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33136 subsys = sif->subsys;
33137
33138 mutex_lock(&subsys->p->mutex);
33139 - list_del_init(&sif->node);
33140 + pax_list_del_init((struct list_head *)&sif->node);
33141 if (sif->remove_dev) {
33142 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33143 while ((dev = subsys_dev_iter_next(&iter)))
33144 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33145 index 7413d06..79155fa 100644
33146 --- a/drivers/base/devtmpfs.c
33147 +++ b/drivers/base/devtmpfs.c
33148 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
33149 if (!thread)
33150 return 0;
33151
33152 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33153 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33154 if (err)
33155 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33156 else
33157 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
33158 *err = sys_unshare(CLONE_NEWNS);
33159 if (*err)
33160 goto out;
33161 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33162 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33163 if (*err)
33164 goto out;
33165 - sys_chdir("/.."); /* will traverse into overmounted root */
33166 - sys_chroot(".");
33167 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33168 + sys_chroot((char __force_user *)".");
33169 complete(&setup_done);
33170 while (1) {
33171 spin_lock(&req_lock);
33172 diff --git a/drivers/base/node.c b/drivers/base/node.c
33173 index 7616a77c..8f57f51 100644
33174 --- a/drivers/base/node.c
33175 +++ b/drivers/base/node.c
33176 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33177 struct node_attr {
33178 struct device_attribute attr;
33179 enum node_states state;
33180 -};
33181 +} __do_const;
33182
33183 static ssize_t show_node_state(struct device *dev,
33184 struct device_attribute *attr, char *buf)
33185 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33186 index 7072404..76dcebd 100644
33187 --- a/drivers/base/power/domain.c
33188 +++ b/drivers/base/power/domain.c
33189 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33190 {
33191 struct cpuidle_driver *cpuidle_drv;
33192 struct gpd_cpu_data *cpu_data;
33193 - struct cpuidle_state *idle_state;
33194 + cpuidle_state_no_const *idle_state;
33195 int ret = 0;
33196
33197 if (IS_ERR_OR_NULL(genpd) || state < 0)
33198 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33199 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33200 {
33201 struct gpd_cpu_data *cpu_data;
33202 - struct cpuidle_state *idle_state;
33203 + cpuidle_state_no_const *idle_state;
33204 int ret = 0;
33205
33206 if (IS_ERR_OR_NULL(genpd))
33207 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33208 index a53ebd2..8f73eeb 100644
33209 --- a/drivers/base/power/sysfs.c
33210 +++ b/drivers/base/power/sysfs.c
33211 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33212 return -EIO;
33213 }
33214 }
33215 - return sprintf(buf, p);
33216 + return sprintf(buf, "%s", p);
33217 }
33218
33219 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33220 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33221 index 79715e7..df06b3b 100644
33222 --- a/drivers/base/power/wakeup.c
33223 +++ b/drivers/base/power/wakeup.c
33224 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33225 * They need to be modified together atomically, so it's better to use one
33226 * atomic variable to hold them both.
33227 */
33228 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33229 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33230
33231 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33232 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33233
33234 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33235 {
33236 - unsigned int comb = atomic_read(&combined_event_count);
33237 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33238
33239 *cnt = (comb >> IN_PROGRESS_BITS);
33240 *inpr = comb & MAX_IN_PROGRESS;
33241 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33242 ws->start_prevent_time = ws->last_time;
33243
33244 /* Increment the counter of events in progress. */
33245 - cec = atomic_inc_return(&combined_event_count);
33246 + cec = atomic_inc_return_unchecked(&combined_event_count);
33247
33248 trace_wakeup_source_activate(ws->name, cec);
33249 }
33250 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33251 * Increment the counter of registered wakeup events and decrement the
33252 * couter of wakeup events in progress simultaneously.
33253 */
33254 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33255 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33256 trace_wakeup_source_deactivate(ws->name, cec);
33257
33258 split_counters(&cnt, &inpr);
33259 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33260 index e8d11b6..7b1b36f 100644
33261 --- a/drivers/base/syscore.c
33262 +++ b/drivers/base/syscore.c
33263 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33264 void register_syscore_ops(struct syscore_ops *ops)
33265 {
33266 mutex_lock(&syscore_ops_lock);
33267 - list_add_tail(&ops->node, &syscore_ops_list);
33268 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33269 mutex_unlock(&syscore_ops_lock);
33270 }
33271 EXPORT_SYMBOL_GPL(register_syscore_ops);
33272 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33273 void unregister_syscore_ops(struct syscore_ops *ops)
33274 {
33275 mutex_lock(&syscore_ops_lock);
33276 - list_del(&ops->node);
33277 + pax_list_del((struct list_head *)&ops->node);
33278 mutex_unlock(&syscore_ops_lock);
33279 }
33280 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33281 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33282 index 62b6c2c..4a11354 100644
33283 --- a/drivers/block/cciss.c
33284 +++ b/drivers/block/cciss.c
33285 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33286 int err;
33287 u32 cp;
33288
33289 + memset(&arg64, 0, sizeof(arg64));
33290 +
33291 err = 0;
33292 err |=
33293 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33294 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
33295 while (!list_empty(&h->reqQ)) {
33296 c = list_entry(h->reqQ.next, CommandList_struct, list);
33297 /* can't do anything if fifo is full */
33298 - if ((h->access.fifo_full(h))) {
33299 + if ((h->access->fifo_full(h))) {
33300 dev_warn(&h->pdev->dev, "fifo full\n");
33301 break;
33302 }
33303 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
33304 h->Qdepth--;
33305
33306 /* Tell the controller execute command */
33307 - h->access.submit_command(h, c);
33308 + h->access->submit_command(h, c);
33309
33310 /* Put job onto the completed Q */
33311 addQ(&h->cmpQ, c);
33312 @@ -3446,17 +3448,17 @@ startio:
33313
33314 static inline unsigned long get_next_completion(ctlr_info_t *h)
33315 {
33316 - return h->access.command_completed(h);
33317 + return h->access->command_completed(h);
33318 }
33319
33320 static inline int interrupt_pending(ctlr_info_t *h)
33321 {
33322 - return h->access.intr_pending(h);
33323 + return h->access->intr_pending(h);
33324 }
33325
33326 static inline long interrupt_not_for_us(ctlr_info_t *h)
33327 {
33328 - return ((h->access.intr_pending(h) == 0) ||
33329 + return ((h->access->intr_pending(h) == 0) ||
33330 (h->interrupts_enabled == 0));
33331 }
33332
33333 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
33334 u32 a;
33335
33336 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33337 - return h->access.command_completed(h);
33338 + return h->access->command_completed(h);
33339
33340 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33341 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33342 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33343 trans_support & CFGTBL_Trans_use_short_tags);
33344
33345 /* Change the access methods to the performant access methods */
33346 - h->access = SA5_performant_access;
33347 + h->access = &SA5_performant_access;
33348 h->transMethod = CFGTBL_Trans_Performant;
33349
33350 return;
33351 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33352 if (prod_index < 0)
33353 return -ENODEV;
33354 h->product_name = products[prod_index].product_name;
33355 - h->access = *(products[prod_index].access);
33356 + h->access = products[prod_index].access;
33357
33358 if (cciss_board_disabled(h)) {
33359 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33360 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
33361 }
33362
33363 /* make sure the board interrupts are off */
33364 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33365 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33366 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33367 if (rc)
33368 goto clean2;
33369 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
33370 * fake ones to scoop up any residual completions.
33371 */
33372 spin_lock_irqsave(&h->lock, flags);
33373 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33374 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33375 spin_unlock_irqrestore(&h->lock, flags);
33376 free_irq(h->intr[h->intr_mode], h);
33377 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33378 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
33379 dev_info(&h->pdev->dev, "Board READY.\n");
33380 dev_info(&h->pdev->dev,
33381 "Waiting for stale completions to drain.\n");
33382 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33383 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33384 msleep(10000);
33385 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33386 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33387
33388 rc = controller_reset_failed(h->cfgtable);
33389 if (rc)
33390 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
33391 cciss_scsi_setup(h);
33392
33393 /* Turn the interrupts on so we can service requests */
33394 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33395 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33396
33397 /* Get the firmware version */
33398 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33399 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33400 kfree(flush_buf);
33401 if (return_code != IO_OK)
33402 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33403 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33404 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33405 free_irq(h->intr[h->intr_mode], h);
33406 }
33407
33408 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33409 index 7fda30e..eb5dfe0 100644
33410 --- a/drivers/block/cciss.h
33411 +++ b/drivers/block/cciss.h
33412 @@ -101,7 +101,7 @@ struct ctlr_info
33413 /* information about each logical volume */
33414 drive_info_struct *drv[CISS_MAX_LUN];
33415
33416 - struct access_method access;
33417 + struct access_method *access;
33418
33419 /* queue and queue Info */
33420 struct list_head reqQ;
33421 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33422 index 639d26b..fd6ad1f 100644
33423 --- a/drivers/block/cpqarray.c
33424 +++ b/drivers/block/cpqarray.c
33425 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33426 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33427 goto Enomem4;
33428 }
33429 - hba[i]->access.set_intr_mask(hba[i], 0);
33430 + hba[i]->access->set_intr_mask(hba[i], 0);
33431 if (request_irq(hba[i]->intr, do_ida_intr,
33432 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33433 {
33434 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33435 add_timer(&hba[i]->timer);
33436
33437 /* Enable IRQ now that spinlock and rate limit timer are set up */
33438 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33439 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33440
33441 for(j=0; j<NWD; j++) {
33442 struct gendisk *disk = ida_gendisk[i][j];
33443 @@ -694,7 +694,7 @@ DBGINFO(
33444 for(i=0; i<NR_PRODUCTS; i++) {
33445 if (board_id == products[i].board_id) {
33446 c->product_name = products[i].product_name;
33447 - c->access = *(products[i].access);
33448 + c->access = products[i].access;
33449 break;
33450 }
33451 }
33452 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33453 hba[ctlr]->intr = intr;
33454 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33455 hba[ctlr]->product_name = products[j].product_name;
33456 - hba[ctlr]->access = *(products[j].access);
33457 + hba[ctlr]->access = products[j].access;
33458 hba[ctlr]->ctlr = ctlr;
33459 hba[ctlr]->board_id = board_id;
33460 hba[ctlr]->pci_dev = NULL; /* not PCI */
33461 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
33462
33463 while((c = h->reqQ) != NULL) {
33464 /* Can't do anything if we're busy */
33465 - if (h->access.fifo_full(h) == 0)
33466 + if (h->access->fifo_full(h) == 0)
33467 return;
33468
33469 /* Get the first entry from the request Q */
33470 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
33471 h->Qdepth--;
33472
33473 /* Tell the controller to do our bidding */
33474 - h->access.submit_command(h, c);
33475 + h->access->submit_command(h, c);
33476
33477 /* Get onto the completion Q */
33478 addQ(&h->cmpQ, c);
33479 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33480 unsigned long flags;
33481 __u32 a,a1;
33482
33483 - istat = h->access.intr_pending(h);
33484 + istat = h->access->intr_pending(h);
33485 /* Is this interrupt for us? */
33486 if (istat == 0)
33487 return IRQ_NONE;
33488 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33489 */
33490 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33491 if (istat & FIFO_NOT_EMPTY) {
33492 - while((a = h->access.command_completed(h))) {
33493 + while((a = h->access->command_completed(h))) {
33494 a1 = a; a &= ~3;
33495 if ((c = h->cmpQ) == NULL)
33496 {
33497 @@ -1193,6 +1193,7 @@ out_passthru:
33498 ida_pci_info_struct pciinfo;
33499
33500 if (!arg) return -EINVAL;
33501 + memset(&pciinfo, 0, sizeof(pciinfo));
33502 pciinfo.bus = host->pci_dev->bus->number;
33503 pciinfo.dev_fn = host->pci_dev->devfn;
33504 pciinfo.board_id = host->board_id;
33505 @@ -1447,11 +1448,11 @@ static int sendcmd(
33506 /*
33507 * Disable interrupt
33508 */
33509 - info_p->access.set_intr_mask(info_p, 0);
33510 + info_p->access->set_intr_mask(info_p, 0);
33511 /* Make sure there is room in the command FIFO */
33512 /* Actually it should be completely empty at this time. */
33513 for (i = 200000; i > 0; i--) {
33514 - temp = info_p->access.fifo_full(info_p);
33515 + temp = info_p->access->fifo_full(info_p);
33516 if (temp != 0) {
33517 break;
33518 }
33519 @@ -1464,7 +1465,7 @@ DBG(
33520 /*
33521 * Send the cmd
33522 */
33523 - info_p->access.submit_command(info_p, c);
33524 + info_p->access->submit_command(info_p, c);
33525 complete = pollcomplete(ctlr);
33526
33527 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33528 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33529 * we check the new geometry. Then turn interrupts back on when
33530 * we're done.
33531 */
33532 - host->access.set_intr_mask(host, 0);
33533 + host->access->set_intr_mask(host, 0);
33534 getgeometry(ctlr);
33535 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33536 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33537
33538 for(i=0; i<NWD; i++) {
33539 struct gendisk *disk = ida_gendisk[ctlr][i];
33540 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
33541 /* Wait (up to 2 seconds) for a command to complete */
33542
33543 for (i = 200000; i > 0; i--) {
33544 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33545 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33546 if (done == 0) {
33547 udelay(10); /* a short fixed delay */
33548 } else
33549 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33550 index be73e9d..7fbf140 100644
33551 --- a/drivers/block/cpqarray.h
33552 +++ b/drivers/block/cpqarray.h
33553 @@ -99,7 +99,7 @@ struct ctlr_info {
33554 drv_info_t drv[NWD];
33555 struct proc_dir_entry *proc;
33556
33557 - struct access_method access;
33558 + struct access_method *access;
33559
33560 cmdlist_t *reqQ;
33561 cmdlist_t *cmpQ;
33562 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33563 index f943aac..99bfd19 100644
33564 --- a/drivers/block/drbd/drbd_int.h
33565 +++ b/drivers/block/drbd/drbd_int.h
33566 @@ -582,7 +582,7 @@ struct drbd_epoch {
33567 struct drbd_tconn *tconn;
33568 struct list_head list;
33569 unsigned int barrier_nr;
33570 - atomic_t epoch_size; /* increased on every request added. */
33571 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33572 atomic_t active; /* increased on every req. added, and dec on every finished. */
33573 unsigned long flags;
33574 };
33575 @@ -1021,7 +1021,7 @@ struct drbd_conf {
33576 unsigned int al_tr_number;
33577 int al_tr_cycle;
33578 wait_queue_head_t seq_wait;
33579 - atomic_t packet_seq;
33580 + atomic_unchecked_t packet_seq;
33581 unsigned int peer_seq;
33582 spinlock_t peer_seq_lock;
33583 unsigned int minor;
33584 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33585 char __user *uoptval;
33586 int err;
33587
33588 - uoptval = (char __user __force *)optval;
33589 + uoptval = (char __force_user *)optval;
33590
33591 set_fs(KERNEL_DS);
33592 if (level == SOL_SOCKET)
33593 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33594 index a5dca6a..bb27967 100644
33595 --- a/drivers/block/drbd/drbd_main.c
33596 +++ b/drivers/block/drbd/drbd_main.c
33597 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33598 p->sector = sector;
33599 p->block_id = block_id;
33600 p->blksize = blksize;
33601 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33602 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33603 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33604 }
33605
33606 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33607 return -EIO;
33608 p->sector = cpu_to_be64(req->i.sector);
33609 p->block_id = (unsigned long)req;
33610 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33611 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33612 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33613 if (mdev->state.conn >= C_SYNC_SOURCE &&
33614 mdev->state.conn <= C_PAUSED_SYNC_T)
33615 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33616 {
33617 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33618
33619 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33620 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33621 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33622 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33623 kfree(tconn->current_epoch);
33624
33625 idr_destroy(&tconn->volumes);
33626 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33627 index 4222aff..1f79506 100644
33628 --- a/drivers/block/drbd/drbd_receiver.c
33629 +++ b/drivers/block/drbd/drbd_receiver.c
33630 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
33631 {
33632 int err;
33633
33634 - atomic_set(&mdev->packet_seq, 0);
33635 + atomic_set_unchecked(&mdev->packet_seq, 0);
33636 mdev->peer_seq = 0;
33637
33638 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33639 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33640 do {
33641 next_epoch = NULL;
33642
33643 - epoch_size = atomic_read(&epoch->epoch_size);
33644 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33645
33646 switch (ev & ~EV_CLEANUP) {
33647 case EV_PUT:
33648 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33649 rv = FE_DESTROYED;
33650 } else {
33651 epoch->flags = 0;
33652 - atomic_set(&epoch->epoch_size, 0);
33653 + atomic_set_unchecked(&epoch->epoch_size, 0);
33654 /* atomic_set(&epoch->active, 0); is already zero */
33655 if (rv == FE_STILL_LIVE)
33656 rv = FE_RECYCLED;
33657 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33658 conn_wait_active_ee_empty(tconn);
33659 drbd_flush(tconn);
33660
33661 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33662 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33663 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33664 if (epoch)
33665 break;
33666 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33667 }
33668
33669 epoch->flags = 0;
33670 - atomic_set(&epoch->epoch_size, 0);
33671 + atomic_set_unchecked(&epoch->epoch_size, 0);
33672 atomic_set(&epoch->active, 0);
33673
33674 spin_lock(&tconn->epoch_lock);
33675 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33676 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33677 list_add(&epoch->list, &tconn->current_epoch->list);
33678 tconn->current_epoch = epoch;
33679 tconn->epochs++;
33680 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33681
33682 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33683 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33684 - atomic_inc(&tconn->current_epoch->epoch_size);
33685 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33686 err2 = drbd_drain_block(mdev, pi->size);
33687 if (!err)
33688 err = err2;
33689 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33690
33691 spin_lock(&tconn->epoch_lock);
33692 peer_req->epoch = tconn->current_epoch;
33693 - atomic_inc(&peer_req->epoch->epoch_size);
33694 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33695 atomic_inc(&peer_req->epoch->active);
33696 spin_unlock(&tconn->epoch_lock);
33697
33698 @@ -4347,7 +4347,7 @@ struct data_cmd {
33699 int expect_payload;
33700 size_t pkt_size;
33701 int (*fn)(struct drbd_tconn *, struct packet_info *);
33702 -};
33703 +} __do_const;
33704
33705 static struct data_cmd drbd_cmd_handler[] = {
33706 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33707 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33708 if (!list_empty(&tconn->current_epoch->list))
33709 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33710 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33711 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33712 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33713 tconn->send.seen_any_write_yet = false;
33714
33715 conn_info(tconn, "Connection closed\n");
33716 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33717 struct asender_cmd {
33718 size_t pkt_size;
33719 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33720 -};
33721 +} __do_const;
33722
33723 static struct asender_cmd asender_tbl[] = {
33724 [P_PING] = { 0, got_Ping },
33725 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33726 index d92d50f..a7e9d97 100644
33727 --- a/drivers/block/loop.c
33728 +++ b/drivers/block/loop.c
33729 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
33730
33731 file_start_write(file);
33732 set_fs(get_ds());
33733 - bw = file->f_op->write(file, buf, len, &pos);
33734 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33735 set_fs(old_fs);
33736 file_end_write(file);
33737 if (likely(bw == len))
33738 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33739 index f5d0ea1..c62380a 100644
33740 --- a/drivers/block/pktcdvd.c
33741 +++ b/drivers/block/pktcdvd.c
33742 @@ -84,7 +84,7 @@
33743 #define MAX_SPEED 0xffff
33744
33745 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
33746 - ~(sector_t)((pd)->settings.size - 1))
33747 + ~(sector_t)((pd)->settings.size - 1UL))
33748
33749 static DEFINE_MUTEX(pktcdvd_mutex);
33750 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33751 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33752 index 8a3aff7..d7538c2 100644
33753 --- a/drivers/cdrom/cdrom.c
33754 +++ b/drivers/cdrom/cdrom.c
33755 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33756 ENSURE(reset, CDC_RESET);
33757 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33758 cdi->mc_flags = 0;
33759 - cdo->n_minors = 0;
33760 cdi->options = CDO_USE_FFLAGS;
33761
33762 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33763 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33764 else
33765 cdi->cdda_method = CDDA_OLD;
33766
33767 - if (!cdo->generic_packet)
33768 - cdo->generic_packet = cdrom_dummy_generic_packet;
33769 + if (!cdo->generic_packet) {
33770 + pax_open_kernel();
33771 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33772 + pax_close_kernel();
33773 + }
33774
33775 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33776 mutex_lock(&cdrom_mutex);
33777 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33778 if (cdi->exit)
33779 cdi->exit(cdi);
33780
33781 - cdi->ops->n_minors--;
33782 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33783 }
33784
33785 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33786 */
33787 nr = nframes;
33788 do {
33789 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33790 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33791 if (cgc.buffer)
33792 break;
33793
33794 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33795 struct cdrom_device_info *cdi;
33796 int ret;
33797
33798 - ret = scnprintf(info + *pos, max_size - *pos, header);
33799 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33800 if (!ret)
33801 return 1;
33802
33803 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33804 index 4afcb65..a68a32d 100644
33805 --- a/drivers/cdrom/gdrom.c
33806 +++ b/drivers/cdrom/gdrom.c
33807 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33808 .audio_ioctl = gdrom_audio_ioctl,
33809 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33810 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33811 - .n_minors = 1,
33812 };
33813
33814 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33815 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33816 index 3bb6fa3..34013fb 100644
33817 --- a/drivers/char/Kconfig
33818 +++ b/drivers/char/Kconfig
33819 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33820
33821 config DEVKMEM
33822 bool "/dev/kmem virtual device support"
33823 - default y
33824 + default n
33825 + depends on !GRKERNSEC_KMEM
33826 help
33827 Say Y here if you want to support the /dev/kmem device. The
33828 /dev/kmem device is rarely used, but can be used for certain
33829 @@ -582,6 +583,7 @@ config DEVPORT
33830 bool
33831 depends on !M68K
33832 depends on ISA || PCI
33833 + depends on !GRKERNSEC_KMEM
33834 default y
33835
33836 source "drivers/s390/char/Kconfig"
33837 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33838 index a48e05b..6bac831 100644
33839 --- a/drivers/char/agp/compat_ioctl.c
33840 +++ b/drivers/char/agp/compat_ioctl.c
33841 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33842 return -ENOMEM;
33843 }
33844
33845 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33846 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33847 sizeof(*usegment) * ureserve.seg_count)) {
33848 kfree(usegment);
33849 kfree(ksegment);
33850 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33851 index 2e04433..771f2cc 100644
33852 --- a/drivers/char/agp/frontend.c
33853 +++ b/drivers/char/agp/frontend.c
33854 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33855 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33856 return -EFAULT;
33857
33858 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33859 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33860 return -EFAULT;
33861
33862 client = agp_find_client_by_pid(reserve.pid);
33863 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33864 if (segment == NULL)
33865 return -ENOMEM;
33866
33867 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33868 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33869 sizeof(struct agp_segment) * reserve.seg_count)) {
33870 kfree(segment);
33871 return -EFAULT;
33872 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33873 index 4f94375..413694e 100644
33874 --- a/drivers/char/genrtc.c
33875 +++ b/drivers/char/genrtc.c
33876 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
33877 switch (cmd) {
33878
33879 case RTC_PLL_GET:
33880 + memset(&pll, 0, sizeof(pll));
33881 if (get_rtc_pll(&pll))
33882 return -EINVAL;
33883 else
33884 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33885 index d784650..e8bfd69 100644
33886 --- a/drivers/char/hpet.c
33887 +++ b/drivers/char/hpet.c
33888 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33889 }
33890
33891 static int
33892 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33893 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33894 struct hpet_info *info)
33895 {
33896 struct hpet_timer __iomem *timer;
33897 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33898 index 86fe45c..c0ea948 100644
33899 --- a/drivers/char/hw_random/intel-rng.c
33900 +++ b/drivers/char/hw_random/intel-rng.c
33901 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33902
33903 if (no_fwh_detect)
33904 return -ENODEV;
33905 - printk(warning);
33906 + printk("%s", warning);
33907 return -EBUSY;
33908 }
33909
33910 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33911 index 4445fa1..7c6de37 100644
33912 --- a/drivers/char/ipmi/ipmi_msghandler.c
33913 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33914 @@ -420,7 +420,7 @@ struct ipmi_smi {
33915 struct proc_dir_entry *proc_dir;
33916 char proc_dir_name[10];
33917
33918 - atomic_t stats[IPMI_NUM_STATS];
33919 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33920
33921 /*
33922 * run_to_completion duplicate of smb_info, smi_info
33923 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33924
33925
33926 #define ipmi_inc_stat(intf, stat) \
33927 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33928 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33929 #define ipmi_get_stat(intf, stat) \
33930 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33931 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33932
33933 static int is_lan_addr(struct ipmi_addr *addr)
33934 {
33935 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33936 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33937 init_waitqueue_head(&intf->waitq);
33938 for (i = 0; i < IPMI_NUM_STATS; i++)
33939 - atomic_set(&intf->stats[i], 0);
33940 + atomic_set_unchecked(&intf->stats[i], 0);
33941
33942 intf->proc_dir = NULL;
33943
33944 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33945 index af4b23f..79806fc 100644
33946 --- a/drivers/char/ipmi/ipmi_si_intf.c
33947 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33948 @@ -275,7 +275,7 @@ struct smi_info {
33949 unsigned char slave_addr;
33950
33951 /* Counters and things for the proc filesystem. */
33952 - atomic_t stats[SI_NUM_STATS];
33953 + atomic_unchecked_t stats[SI_NUM_STATS];
33954
33955 struct task_struct *thread;
33956
33957 @@ -284,9 +284,9 @@ struct smi_info {
33958 };
33959
33960 #define smi_inc_stat(smi, stat) \
33961 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33962 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33963 #define smi_get_stat(smi, stat) \
33964 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33965 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33966
33967 #define SI_MAX_PARMS 4
33968
33969 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
33970 atomic_set(&new_smi->req_events, 0);
33971 new_smi->run_to_completion = 0;
33972 for (i = 0; i < SI_NUM_STATS; i++)
33973 - atomic_set(&new_smi->stats[i], 0);
33974 + atomic_set_unchecked(&new_smi->stats[i], 0);
33975
33976 new_smi->interrupt_disabled = 1;
33977 atomic_set(&new_smi->stop_operation, 0);
33978 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33979 index 1ccbe94..6ad651a 100644
33980 --- a/drivers/char/mem.c
33981 +++ b/drivers/char/mem.c
33982 @@ -18,6 +18,7 @@
33983 #include <linux/raw.h>
33984 #include <linux/tty.h>
33985 #include <linux/capability.h>
33986 +#include <linux/security.h>
33987 #include <linux/ptrace.h>
33988 #include <linux/device.h>
33989 #include <linux/highmem.h>
33990 @@ -38,6 +39,10 @@
33991
33992 #define DEVPORT_MINOR 4
33993
33994 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33995 +extern const struct file_operations grsec_fops;
33996 +#endif
33997 +
33998 static inline unsigned long size_inside_page(unsigned long start,
33999 unsigned long size)
34000 {
34001 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34002
34003 while (cursor < to) {
34004 if (!devmem_is_allowed(pfn)) {
34005 +#ifdef CONFIG_GRKERNSEC_KMEM
34006 + gr_handle_mem_readwrite(from, to);
34007 +#else
34008 printk(KERN_INFO
34009 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34010 current->comm, from, to);
34011 +#endif
34012 return 0;
34013 }
34014 cursor += PAGE_SIZE;
34015 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34016 }
34017 return 1;
34018 }
34019 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34020 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34021 +{
34022 + return 0;
34023 +}
34024 #else
34025 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34026 {
34027 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34028
34029 while (count > 0) {
34030 unsigned long remaining;
34031 + char *temp;
34032
34033 sz = size_inside_page(p, count);
34034
34035 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34036 if (!ptr)
34037 return -EFAULT;
34038
34039 - remaining = copy_to_user(buf, ptr, sz);
34040 +#ifdef CONFIG_PAX_USERCOPY
34041 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34042 + if (!temp) {
34043 + unxlate_dev_mem_ptr(p, ptr);
34044 + return -ENOMEM;
34045 + }
34046 + memcpy(temp, ptr, sz);
34047 +#else
34048 + temp = ptr;
34049 +#endif
34050 +
34051 + remaining = copy_to_user(buf, temp, sz);
34052 +
34053 +#ifdef CONFIG_PAX_USERCOPY
34054 + kfree(temp);
34055 +#endif
34056 +
34057 unxlate_dev_mem_ptr(p, ptr);
34058 if (remaining)
34059 return -EFAULT;
34060 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34061 else
34062 csize = count;
34063
34064 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34065 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34066 if (rc < 0)
34067 return rc;
34068 buf += csize;
34069 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34070 size_t count, loff_t *ppos)
34071 {
34072 unsigned long p = *ppos;
34073 - ssize_t low_count, read, sz;
34074 + ssize_t low_count, read, sz, err = 0;
34075 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34076 - int err = 0;
34077
34078 read = 0;
34079 if (p < (unsigned long) high_memory) {
34080 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34081 }
34082 #endif
34083 while (low_count > 0) {
34084 + char *temp;
34085 +
34086 sz = size_inside_page(p, low_count);
34087
34088 /*
34089 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34090 */
34091 kbuf = xlate_dev_kmem_ptr((char *)p);
34092
34093 - if (copy_to_user(buf, kbuf, sz))
34094 +#ifdef CONFIG_PAX_USERCOPY
34095 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34096 + if (!temp)
34097 + return -ENOMEM;
34098 + memcpy(temp, kbuf, sz);
34099 +#else
34100 + temp = kbuf;
34101 +#endif
34102 +
34103 + err = copy_to_user(buf, temp, sz);
34104 +
34105 +#ifdef CONFIG_PAX_USERCOPY
34106 + kfree(temp);
34107 +#endif
34108 +
34109 + if (err)
34110 return -EFAULT;
34111 buf += sz;
34112 p += sz;
34113 @@ -869,6 +916,9 @@ static const struct memdev {
34114 #ifdef CONFIG_CRASH_DUMP
34115 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34116 #endif
34117 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34118 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34119 +#endif
34120 };
34121
34122 static int memory_open(struct inode *inode, struct file *filp)
34123 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
34124 continue;
34125
34126 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34127 - NULL, devlist[minor].name);
34128 + NULL, "%s", devlist[minor].name);
34129 }
34130
34131 return tty_init();
34132 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34133 index c689697..04e6d6a2 100644
34134 --- a/drivers/char/mwave/tp3780i.c
34135 +++ b/drivers/char/mwave/tp3780i.c
34136 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34137 PRINTK_2(TRACE_TP3780I,
34138 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34139
34140 + memset(pAbilities, 0, sizeof(*pAbilities));
34141 /* fill out standard constant fields */
34142 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34143 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34144 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34145 index 9df78e2..01ba9ae 100644
34146 --- a/drivers/char/nvram.c
34147 +++ b/drivers/char/nvram.c
34148 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34149
34150 spin_unlock_irq(&rtc_lock);
34151
34152 - if (copy_to_user(buf, contents, tmp - contents))
34153 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34154 return -EFAULT;
34155
34156 *ppos = i;
34157 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34158 index 5c5cc00..ac9edb7 100644
34159 --- a/drivers/char/pcmcia/synclink_cs.c
34160 +++ b/drivers/char/pcmcia/synclink_cs.c
34161 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34162
34163 if (debug_level >= DEBUG_LEVEL_INFO)
34164 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34165 - __FILE__, __LINE__, info->device_name, port->count);
34166 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34167
34168 - WARN_ON(!port->count);
34169 + WARN_ON(!atomic_read(&port->count));
34170
34171 if (tty_port_close_start(port, tty, filp) == 0)
34172 goto cleanup;
34173 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34174 cleanup:
34175 if (debug_level >= DEBUG_LEVEL_INFO)
34176 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34177 - tty->driver->name, port->count);
34178 + tty->driver->name, atomic_read(&port->count));
34179 }
34180
34181 /* Wait until the transmitter is empty.
34182 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34183
34184 if (debug_level >= DEBUG_LEVEL_INFO)
34185 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34186 - __FILE__, __LINE__, tty->driver->name, port->count);
34187 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34188
34189 /* If port is closing, signal caller to try again */
34190 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34191 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34192 goto cleanup;
34193 }
34194 spin_lock(&port->lock);
34195 - port->count++;
34196 + atomic_inc(&port->count);
34197 spin_unlock(&port->lock);
34198 spin_unlock_irqrestore(&info->netlock, flags);
34199
34200 - if (port->count == 1) {
34201 + if (atomic_read(&port->count) == 1) {
34202 /* 1st open on this device, init hardware */
34203 retval = startup(info, tty);
34204 if (retval < 0)
34205 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34206 unsigned short new_crctype;
34207
34208 /* return error if TTY interface open */
34209 - if (info->port.count)
34210 + if (atomic_read(&info->port.count))
34211 return -EBUSY;
34212
34213 switch (encoding)
34214 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34215
34216 /* arbitrate between network and tty opens */
34217 spin_lock_irqsave(&info->netlock, flags);
34218 - if (info->port.count != 0 || info->netcount != 0) {
34219 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34220 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34221 spin_unlock_irqrestore(&info->netlock, flags);
34222 return -EBUSY;
34223 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34224 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34225
34226 /* return error if TTY interface open */
34227 - if (info->port.count)
34228 + if (atomic_read(&info->port.count))
34229 return -EBUSY;
34230
34231 if (cmd != SIOCWANDEV)
34232 diff --git a/drivers/char/random.c b/drivers/char/random.c
34233 index 35487e8..dac8bd1 100644
34234 --- a/drivers/char/random.c
34235 +++ b/drivers/char/random.c
34236 @@ -272,8 +272,13 @@
34237 /*
34238 * Configuration information
34239 */
34240 +#ifdef CONFIG_GRKERNSEC_RANDNET
34241 +#define INPUT_POOL_WORDS 512
34242 +#define OUTPUT_POOL_WORDS 128
34243 +#else
34244 #define INPUT_POOL_WORDS 128
34245 #define OUTPUT_POOL_WORDS 32
34246 +#endif
34247 #define SEC_XFER_SIZE 512
34248 #define EXTRACT_SIZE 10
34249
34250 @@ -313,10 +318,17 @@ static struct poolinfo {
34251 int poolwords;
34252 int tap1, tap2, tap3, tap4, tap5;
34253 } poolinfo_table[] = {
34254 +#ifdef CONFIG_GRKERNSEC_RANDNET
34255 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34256 + { 512, 411, 308, 208, 104, 1 },
34257 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34258 + { 128, 103, 76, 51, 25, 1 },
34259 +#else
34260 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34261 { 128, 103, 76, 51, 25, 1 },
34262 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34263 { 32, 26, 20, 14, 7, 1 },
34264 +#endif
34265 #if 0
34266 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34267 { 2048, 1638, 1231, 819, 411, 1 },
34268 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34269 input_rotate += i ? 7 : 14;
34270 }
34271
34272 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34273 - ACCESS_ONCE(r->add_ptr) = i;
34274 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34275 + ACCESS_ONCE_RW(r->add_ptr) = i;
34276 smp_wmb();
34277
34278 if (out)
34279 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34280
34281 extract_buf(r, tmp);
34282 i = min_t(int, nbytes, EXTRACT_SIZE);
34283 - if (copy_to_user(buf, tmp, i)) {
34284 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34285 ret = -EFAULT;
34286 break;
34287 }
34288 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34289 #include <linux/sysctl.h>
34290
34291 static int min_read_thresh = 8, min_write_thresh;
34292 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34293 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34294 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34295 static char sysctl_bootid[16];
34296
34297 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34298 static int proc_do_uuid(ctl_table *table, int write,
34299 void __user *buffer, size_t *lenp, loff_t *ppos)
34300 {
34301 - ctl_table fake_table;
34302 + ctl_table_no_const fake_table;
34303 unsigned char buf[64], tmp_uuid[16], *uuid;
34304
34305 uuid = table->data;
34306 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34307 index bf2349db..5456d53 100644
34308 --- a/drivers/char/sonypi.c
34309 +++ b/drivers/char/sonypi.c
34310 @@ -54,6 +54,7 @@
34311
34312 #include <asm/uaccess.h>
34313 #include <asm/io.h>
34314 +#include <asm/local.h>
34315
34316 #include <linux/sonypi.h>
34317
34318 @@ -490,7 +491,7 @@ static struct sonypi_device {
34319 spinlock_t fifo_lock;
34320 wait_queue_head_t fifo_proc_list;
34321 struct fasync_struct *fifo_async;
34322 - int open_count;
34323 + local_t open_count;
34324 int model;
34325 struct input_dev *input_jog_dev;
34326 struct input_dev *input_key_dev;
34327 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34328 static int sonypi_misc_release(struct inode *inode, struct file *file)
34329 {
34330 mutex_lock(&sonypi_device.lock);
34331 - sonypi_device.open_count--;
34332 + local_dec(&sonypi_device.open_count);
34333 mutex_unlock(&sonypi_device.lock);
34334 return 0;
34335 }
34336 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34337 {
34338 mutex_lock(&sonypi_device.lock);
34339 /* Flush input queue on first open */
34340 - if (!sonypi_device.open_count)
34341 + if (!local_read(&sonypi_device.open_count))
34342 kfifo_reset(&sonypi_device.fifo);
34343 - sonypi_device.open_count++;
34344 + local_inc(&sonypi_device.open_count);
34345 mutex_unlock(&sonypi_device.lock);
34346
34347 return 0;
34348 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34349 index 64420b3..5c40b56 100644
34350 --- a/drivers/char/tpm/tpm_acpi.c
34351 +++ b/drivers/char/tpm/tpm_acpi.c
34352 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34353 virt = acpi_os_map_memory(start, len);
34354 if (!virt) {
34355 kfree(log->bios_event_log);
34356 + log->bios_event_log = NULL;
34357 printk("%s: ERROR - Unable to map memory\n", __func__);
34358 return -EIO;
34359 }
34360
34361 - memcpy_fromio(log->bios_event_log, virt, len);
34362 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34363
34364 acpi_os_unmap_memory(virt, len);
34365 return 0;
34366 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34367 index 84ddc55..1d32f1e 100644
34368 --- a/drivers/char/tpm/tpm_eventlog.c
34369 +++ b/drivers/char/tpm/tpm_eventlog.c
34370 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34371 event = addr;
34372
34373 if ((event->event_type == 0 && event->event_size == 0) ||
34374 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34375 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34376 return NULL;
34377
34378 return addr;
34379 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34380 return NULL;
34381
34382 if ((event->event_type == 0 && event->event_size == 0) ||
34383 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34384 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34385 return NULL;
34386
34387 (*pos)++;
34388 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34389 int i;
34390
34391 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34392 - seq_putc(m, data[i]);
34393 + if (!seq_putc(m, data[i]))
34394 + return -EFAULT;
34395
34396 return 0;
34397 }
34398 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34399 index 1b456fe..2510242 100644
34400 --- a/drivers/char/virtio_console.c
34401 +++ b/drivers/char/virtio_console.c
34402 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34403 if (to_user) {
34404 ssize_t ret;
34405
34406 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34407 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34408 if (ret)
34409 return -EFAULT;
34410 } else {
34411 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34412 if (!port_has_data(port) && !port->host_connected)
34413 return 0;
34414
34415 - return fill_readbuf(port, ubuf, count, true);
34416 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34417 }
34418
34419 static int wait_port_writable(struct port *port, bool nonblock)
34420 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
34421 index a33f46f..a720eed 100644
34422 --- a/drivers/clk/clk-composite.c
34423 +++ b/drivers/clk/clk-composite.c
34424 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
34425 struct clk *clk;
34426 struct clk_init_data init;
34427 struct clk_composite *composite;
34428 - struct clk_ops *clk_composite_ops;
34429 + clk_ops_no_const *clk_composite_ops;
34430
34431 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
34432 if (!composite) {
34433 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
34434 index bd11315..7f87098 100644
34435 --- a/drivers/clk/socfpga/clk.c
34436 +++ b/drivers/clk/socfpga/clk.c
34437 @@ -22,6 +22,7 @@
34438 #include <linux/clk-provider.h>
34439 #include <linux/io.h>
34440 #include <linux/of.h>
34441 +#include <asm/pgtable.h>
34442
34443 /* Clock Manager offsets */
34444 #define CLKMGR_CTRL 0x0
34445 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
34446 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
34447 strcmp(clk_name, "sdram_pll")) {
34448 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
34449 - clk_pll_ops.enable = clk_gate_ops.enable;
34450 - clk_pll_ops.disable = clk_gate_ops.disable;
34451 + pax_open_kernel();
34452 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
34453 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
34454 + pax_close_kernel();
34455 }
34456
34457 clk = clk_register(NULL, &socfpga_clk->hw.hw);
34458 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34459 index a2b2541..bc1e7ff 100644
34460 --- a/drivers/clocksource/arm_arch_timer.c
34461 +++ b/drivers/clocksource/arm_arch_timer.c
34462 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34463 return NOTIFY_OK;
34464 }
34465
34466 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34467 +static struct notifier_block arch_timer_cpu_nb = {
34468 .notifier_call = arch_timer_cpu_notify,
34469 };
34470
34471 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34472 index ade7513..069445f 100644
34473 --- a/drivers/clocksource/metag_generic.c
34474 +++ b/drivers/clocksource/metag_generic.c
34475 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34476 return NOTIFY_OK;
34477 }
34478
34479 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34480 +static struct notifier_block arch_timer_cpu_nb = {
34481 .notifier_call = arch_timer_cpu_notify,
34482 };
34483
34484 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34485 index edc089e..bc7c0bc 100644
34486 --- a/drivers/cpufreq/acpi-cpufreq.c
34487 +++ b/drivers/cpufreq/acpi-cpufreq.c
34488 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34489 return sprintf(buf, "%u\n", boost_enabled);
34490 }
34491
34492 -static struct global_attr global_boost = __ATTR(boost, 0644,
34493 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34494 show_global_boost,
34495 store_global_boost);
34496
34497 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34498 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34499 per_cpu(acfreq_data, cpu) = data;
34500
34501 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34502 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34503 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34504 + pax_open_kernel();
34505 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34506 + pax_close_kernel();
34507 + }
34508
34509 result = acpi_processor_register_performance(data->acpi_data, cpu);
34510 if (result)
34511 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34512 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34513 break;
34514 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34515 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34516 + pax_open_kernel();
34517 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34518 + pax_close_kernel();
34519 policy->cur = get_cur_freq_on_cpu(cpu);
34520 break;
34521 default:
34522 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34523 acpi_processor_notify_smm(THIS_MODULE);
34524
34525 /* Check for APERF/MPERF support in hardware */
34526 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34527 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34528 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34529 + pax_open_kernel();
34530 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34531 + pax_close_kernel();
34532 + }
34533
34534 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34535 for (i = 0; i < perf->state_count; i++)
34536 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34537 index 2d53f47..eb3803e 100644
34538 --- a/drivers/cpufreq/cpufreq.c
34539 +++ b/drivers/cpufreq/cpufreq.c
34540 @@ -1851,7 +1851,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34541 return NOTIFY_OK;
34542 }
34543
34544 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34545 +static struct notifier_block cpufreq_cpu_notifier = {
34546 .notifier_call = cpufreq_cpu_callback,
34547 };
34548
34549 @@ -1883,8 +1883,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34550
34551 pr_debug("trying to register driver %s\n", driver_data->name);
34552
34553 - if (driver_data->setpolicy)
34554 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34555 + if (driver_data->setpolicy) {
34556 + pax_open_kernel();
34557 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34558 + pax_close_kernel();
34559 + }
34560
34561 write_lock_irqsave(&cpufreq_driver_lock, flags);
34562 if (cpufreq_driver) {
34563 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34564 index dc9b72e..11c0302 100644
34565 --- a/drivers/cpufreq/cpufreq_governor.c
34566 +++ b/drivers/cpufreq/cpufreq_governor.c
34567 @@ -238,7 +238,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34568 struct dbs_data *dbs_data;
34569 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34570 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34571 - struct od_ops *od_ops = NULL;
34572 + const struct od_ops *od_ops = NULL;
34573 struct od_dbs_tuners *od_tuners = NULL;
34574 struct cs_dbs_tuners *cs_tuners = NULL;
34575 struct cpu_dbs_common_info *cpu_cdbs;
34576 @@ -301,7 +301,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34577
34578 if ((cdata->governor == GOV_CONSERVATIVE) &&
34579 (!policy->governor->initialized)) {
34580 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34581 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34582
34583 cpufreq_register_notifier(cs_ops->notifier_block,
34584 CPUFREQ_TRANSITION_NOTIFIER);
34585 @@ -318,7 +318,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34586
34587 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
34588 (policy->governor->initialized == 1)) {
34589 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34590 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34591
34592 cpufreq_unregister_notifier(cs_ops->notifier_block,
34593 CPUFREQ_TRANSITION_NOTIFIER);
34594 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34595 index e16a961..0e68927 100644
34596 --- a/drivers/cpufreq/cpufreq_governor.h
34597 +++ b/drivers/cpufreq/cpufreq_governor.h
34598 @@ -204,7 +204,7 @@ struct common_dbs_data {
34599 void (*exit)(struct dbs_data *dbs_data);
34600
34601 /* Governor specific ops, see below */
34602 - void *gov_ops;
34603 + const void *gov_ops;
34604 };
34605
34606 /* Governer Per policy data */
34607 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
34608 index 93eb5cb..f8ab572 100644
34609 --- a/drivers/cpufreq/cpufreq_ondemand.c
34610 +++ b/drivers/cpufreq/cpufreq_ondemand.c
34611 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
34612 (struct cpufreq_policy *, unsigned int, unsigned int),
34613 unsigned int powersave_bias)
34614 {
34615 - od_ops.powersave_bias_target = f;
34616 + pax_open_kernel();
34617 + *(void **)&od_ops.powersave_bias_target = f;
34618 + pax_close_kernel();
34619 od_set_powersave_bias(powersave_bias);
34620 }
34621 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
34622
34623 void od_unregister_powersave_bias_handler(void)
34624 {
34625 - od_ops.powersave_bias_target = generic_powersave_bias_target;
34626 + pax_open_kernel();
34627 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
34628 + pax_close_kernel();
34629 od_set_powersave_bias(0);
34630 }
34631 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
34632 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34633 index 591b6fb..2a01183 100644
34634 --- a/drivers/cpufreq/cpufreq_stats.c
34635 +++ b/drivers/cpufreq/cpufreq_stats.c
34636 @@ -367,7 +367,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34637 }
34638
34639 /* priority=1 so this will get called before cpufreq_remove_dev */
34640 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34641 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34642 .notifier_call = cpufreq_stat_cpu_callback,
34643 .priority = 1,
34644 };
34645 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34646 index 421ef37..e708530c 100644
34647 --- a/drivers/cpufreq/p4-clockmod.c
34648 +++ b/drivers/cpufreq/p4-clockmod.c
34649 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34650 case 0x0F: /* Core Duo */
34651 case 0x16: /* Celeron Core */
34652 case 0x1C: /* Atom */
34653 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34654 + pax_open_kernel();
34655 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34656 + pax_close_kernel();
34657 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34658 case 0x0D: /* Pentium M (Dothan) */
34659 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34660 + pax_open_kernel();
34661 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34662 + pax_close_kernel();
34663 /* fall through */
34664 case 0x09: /* Pentium M (Banias) */
34665 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34666 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34667
34668 /* on P-4s, the TSC runs with constant frequency independent whether
34669 * throttling is active or not. */
34670 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34671 + pax_open_kernel();
34672 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34673 + pax_close_kernel();
34674
34675 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34676 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34677 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
34678 index c71ee14..7c2e183 100644
34679 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
34680 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
34681 @@ -18,14 +18,12 @@
34682 #include <asm/head.h>
34683 #include <asm/timer.h>
34684
34685 -static struct cpufreq_driver *cpufreq_us3_driver;
34686 -
34687 struct us3_freq_percpu_info {
34688 struct cpufreq_frequency_table table[4];
34689 };
34690
34691 /* Indexed by cpu number. */
34692 -static struct us3_freq_percpu_info *us3_freq_table;
34693 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
34694
34695 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
34696 * in the Safari config register.
34697 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
34698
34699 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
34700 {
34701 - if (cpufreq_us3_driver)
34702 - us3_set_cpu_divider_index(policy, 0);
34703 + us3_set_cpu_divider_index(policy->cpu, 0);
34704
34705 return 0;
34706 }
34707
34708 +static int __init us3_freq_init(void);
34709 +static void __exit us3_freq_exit(void);
34710 +
34711 +static struct cpufreq_driver cpufreq_us3_driver = {
34712 + .init = us3_freq_cpu_init,
34713 + .verify = us3_freq_verify,
34714 + .target = us3_freq_target,
34715 + .get = us3_freq_get,
34716 + .exit = us3_freq_cpu_exit,
34717 + .owner = THIS_MODULE,
34718 + .name = "UltraSPARC-III",
34719 +
34720 +};
34721 +
34722 static int __init us3_freq_init(void)
34723 {
34724 unsigned long manuf, impl, ver;
34725 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
34726 (impl == CHEETAH_IMPL ||
34727 impl == CHEETAH_PLUS_IMPL ||
34728 impl == JAGUAR_IMPL ||
34729 - impl == PANTHER_IMPL)) {
34730 - struct cpufreq_driver *driver;
34731 -
34732 - ret = -ENOMEM;
34733 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
34734 - if (!driver)
34735 - goto err_out;
34736 -
34737 - us3_freq_table = kzalloc(
34738 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
34739 - GFP_KERNEL);
34740 - if (!us3_freq_table)
34741 - goto err_out;
34742 -
34743 - driver->init = us3_freq_cpu_init;
34744 - driver->verify = us3_freq_verify;
34745 - driver->target = us3_freq_target;
34746 - driver->get = us3_freq_get;
34747 - driver->exit = us3_freq_cpu_exit;
34748 - driver->owner = THIS_MODULE,
34749 - strcpy(driver->name, "UltraSPARC-III");
34750 -
34751 - cpufreq_us3_driver = driver;
34752 - ret = cpufreq_register_driver(driver);
34753 - if (ret)
34754 - goto err_out;
34755 -
34756 - return 0;
34757 -
34758 -err_out:
34759 - if (driver) {
34760 - kfree(driver);
34761 - cpufreq_us3_driver = NULL;
34762 - }
34763 - kfree(us3_freq_table);
34764 - us3_freq_table = NULL;
34765 - return ret;
34766 - }
34767 + impl == PANTHER_IMPL))
34768 + return cpufreq_register_driver(&cpufreq_us3_driver);
34769
34770 return -ENODEV;
34771 }
34772
34773 static void __exit us3_freq_exit(void)
34774 {
34775 - if (cpufreq_us3_driver) {
34776 - cpufreq_unregister_driver(cpufreq_us3_driver);
34777 - kfree(cpufreq_us3_driver);
34778 - cpufreq_us3_driver = NULL;
34779 - kfree(us3_freq_table);
34780 - us3_freq_table = NULL;
34781 - }
34782 + cpufreq_unregister_driver(&cpufreq_us3_driver);
34783 }
34784
34785 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
34786 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34787 index 618e6f4..e89d915 100644
34788 --- a/drivers/cpufreq/speedstep-centrino.c
34789 +++ b/drivers/cpufreq/speedstep-centrino.c
34790 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34791 !cpu_has(cpu, X86_FEATURE_EST))
34792 return -ENODEV;
34793
34794 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34795 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34796 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34797 + pax_open_kernel();
34798 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34799 + pax_close_kernel();
34800 + }
34801
34802 if (policy->cpu != 0)
34803 return -ENODEV;
34804 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34805 index c3a93fe..e808f24 100644
34806 --- a/drivers/cpuidle/cpuidle.c
34807 +++ b/drivers/cpuidle/cpuidle.c
34808 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
34809
34810 static void poll_idle_init(struct cpuidle_driver *drv)
34811 {
34812 - struct cpuidle_state *state = &drv->states[0];
34813 + cpuidle_state_no_const *state = &drv->states[0];
34814
34815 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34816 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34817 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34818 index ea2f8e7..70ac501 100644
34819 --- a/drivers/cpuidle/governor.c
34820 +++ b/drivers/cpuidle/governor.c
34821 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34822 mutex_lock(&cpuidle_lock);
34823 if (__cpuidle_find_governor(gov->name) == NULL) {
34824 ret = 0;
34825 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34826 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34827 if (!cpuidle_curr_governor ||
34828 cpuidle_curr_governor->rating < gov->rating)
34829 cpuidle_switch_governor(gov);
34830 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34831 new_gov = cpuidle_replace_governor(gov->rating);
34832 cpuidle_switch_governor(new_gov);
34833 }
34834 - list_del(&gov->governor_list);
34835 + pax_list_del((struct list_head *)&gov->governor_list);
34836 mutex_unlock(&cpuidle_lock);
34837 }
34838
34839 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34840 index 428754a..8bdf9cc 100644
34841 --- a/drivers/cpuidle/sysfs.c
34842 +++ b/drivers/cpuidle/sysfs.c
34843 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34844 NULL
34845 };
34846
34847 -static struct attribute_group cpuidle_attr_group = {
34848 +static attribute_group_no_const cpuidle_attr_group = {
34849 .attrs = cpuidle_default_attrs,
34850 .name = "cpuidle",
34851 };
34852 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34853 index 3b36797..db0b0c0 100644
34854 --- a/drivers/devfreq/devfreq.c
34855 +++ b/drivers/devfreq/devfreq.c
34856 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34857 GFP_KERNEL);
34858 devfreq->last_stat_updated = jiffies;
34859
34860 - dev_set_name(&devfreq->dev, dev_name(dev));
34861 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34862 err = device_register(&devfreq->dev);
34863 if (err) {
34864 put_device(&devfreq->dev);
34865 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34866 goto err_out;
34867 }
34868
34869 - list_add(&governor->node, &devfreq_governor_list);
34870 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34871
34872 list_for_each_entry(devfreq, &devfreq_list, node) {
34873 int ret = 0;
34874 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34875 }
34876 }
34877
34878 - list_del(&governor->node);
34879 + pax_list_del((struct list_head *)&governor->node);
34880 err_out:
34881 mutex_unlock(&devfreq_list_lock);
34882
34883 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34884 index b70709b..1d8d02a 100644
34885 --- a/drivers/dma/sh/shdma.c
34886 +++ b/drivers/dma/sh/shdma.c
34887 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34888 return ret;
34889 }
34890
34891 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34892 +static struct notifier_block sh_dmae_nmi_notifier = {
34893 .notifier_call = sh_dmae_nmi_handler,
34894
34895 /* Run before NMI debug handler and KGDB */
34896 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34897 index 67610a6..30f8a11 100644
34898 --- a/drivers/edac/edac_mc_sysfs.c
34899 +++ b/drivers/edac/edac_mc_sysfs.c
34900 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
34901 struct dev_ch_attribute {
34902 struct device_attribute attr;
34903 int channel;
34904 -};
34905 +} __do_const;
34906
34907 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34908 struct dev_ch_attribute dev_attr_legacy_##_name = \
34909 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34910 }
34911
34912 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34913 + pax_open_kernel();
34914 if (mci->get_sdram_scrub_rate) {
34915 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34916 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34917 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34918 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34919 }
34920 if (mci->set_sdram_scrub_rate) {
34921 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34922 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34923 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34924 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34925 }
34926 + pax_close_kernel();
34927 err = device_create_file(&mci->dev,
34928 &dev_attr_sdram_scrub_rate);
34929 if (err) {
34930 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34931 index e8658e4..22746d6 100644
34932 --- a/drivers/edac/edac_pci_sysfs.c
34933 +++ b/drivers/edac/edac_pci_sysfs.c
34934 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34935 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34936 static int edac_pci_poll_msec = 1000; /* one second workq period */
34937
34938 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34939 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34940 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34941 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34942
34943 static struct kobject *edac_pci_top_main_kobj;
34944 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34945 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34946 void *value;
34947 ssize_t(*show) (void *, char *);
34948 ssize_t(*store) (void *, const char *, size_t);
34949 -};
34950 +} __do_const;
34951
34952 /* Set of show/store abstract level functions for PCI Parity object */
34953 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34954 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34955 edac_printk(KERN_CRIT, EDAC_PCI,
34956 "Signaled System Error on %s\n",
34957 pci_name(dev));
34958 - atomic_inc(&pci_nonparity_count);
34959 + atomic_inc_unchecked(&pci_nonparity_count);
34960 }
34961
34962 if (status & (PCI_STATUS_PARITY)) {
34963 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34964 "Master Data Parity Error on %s\n",
34965 pci_name(dev));
34966
34967 - atomic_inc(&pci_parity_count);
34968 + atomic_inc_unchecked(&pci_parity_count);
34969 }
34970
34971 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34972 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34973 "Detected Parity Error on %s\n",
34974 pci_name(dev));
34975
34976 - atomic_inc(&pci_parity_count);
34977 + atomic_inc_unchecked(&pci_parity_count);
34978 }
34979 }
34980
34981 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34982 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34983 "Signaled System Error on %s\n",
34984 pci_name(dev));
34985 - atomic_inc(&pci_nonparity_count);
34986 + atomic_inc_unchecked(&pci_nonparity_count);
34987 }
34988
34989 if (status & (PCI_STATUS_PARITY)) {
34990 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34991 "Master Data Parity Error on "
34992 "%s\n", pci_name(dev));
34993
34994 - atomic_inc(&pci_parity_count);
34995 + atomic_inc_unchecked(&pci_parity_count);
34996 }
34997
34998 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34999 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35000 "Detected Parity Error on %s\n",
35001 pci_name(dev));
35002
35003 - atomic_inc(&pci_parity_count);
35004 + atomic_inc_unchecked(&pci_parity_count);
35005 }
35006 }
35007 }
35008 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
35009 if (!check_pci_errors)
35010 return;
35011
35012 - before_count = atomic_read(&pci_parity_count);
35013 + before_count = atomic_read_unchecked(&pci_parity_count);
35014
35015 /* scan all PCI devices looking for a Parity Error on devices and
35016 * bridges.
35017 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
35018 /* Only if operator has selected panic on PCI Error */
35019 if (edac_pci_get_panic_on_pe()) {
35020 /* If the count is different 'after' from 'before' */
35021 - if (before_count != atomic_read(&pci_parity_count))
35022 + if (before_count != atomic_read_unchecked(&pci_parity_count))
35023 panic("EDAC: PCI Parity Error");
35024 }
35025 }
35026 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
35027 index 51b7e3a..aa8a3e8 100644
35028 --- a/drivers/edac/mce_amd.h
35029 +++ b/drivers/edac/mce_amd.h
35030 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
35031 bool (*mc0_mce)(u16, u8);
35032 bool (*mc1_mce)(u16, u8);
35033 bool (*mc2_mce)(u16, u8);
35034 -};
35035 +} __no_const;
35036
35037 void amd_report_gart_errors(bool);
35038 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35039 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35040 index 57ea7f4..789e3c3 100644
35041 --- a/drivers/firewire/core-card.c
35042 +++ b/drivers/firewire/core-card.c
35043 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35044
35045 void fw_core_remove_card(struct fw_card *card)
35046 {
35047 - struct fw_card_driver dummy_driver = dummy_driver_template;
35048 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35049
35050 card->driver->update_phy_reg(card, 4,
35051 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35052 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35053 index 664a6ff..af13580 100644
35054 --- a/drivers/firewire/core-device.c
35055 +++ b/drivers/firewire/core-device.c
35056 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35057 struct config_rom_attribute {
35058 struct device_attribute attr;
35059 u32 key;
35060 -};
35061 +} __do_const;
35062
35063 static ssize_t show_immediate(struct device *dev,
35064 struct device_attribute *dattr, char *buf)
35065 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35066 index 28a94c7..58da63a 100644
35067 --- a/drivers/firewire/core-transaction.c
35068 +++ b/drivers/firewire/core-transaction.c
35069 @@ -38,6 +38,7 @@
35070 #include <linux/timer.h>
35071 #include <linux/types.h>
35072 #include <linux/workqueue.h>
35073 +#include <linux/sched.h>
35074
35075 #include <asm/byteorder.h>
35076
35077 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35078 index 515a42c..5ecf3ba 100644
35079 --- a/drivers/firewire/core.h
35080 +++ b/drivers/firewire/core.h
35081 @@ -111,6 +111,7 @@ struct fw_card_driver {
35082
35083 int (*stop_iso)(struct fw_iso_context *ctx);
35084 };
35085 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35086
35087 void fw_card_initialize(struct fw_card *card,
35088 const struct fw_card_driver *driver, struct device *device);
35089 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35090 index 94a58a0..f5eba42 100644
35091 --- a/drivers/firmware/dmi-id.c
35092 +++ b/drivers/firmware/dmi-id.c
35093 @@ -16,7 +16,7 @@
35094 struct dmi_device_attribute{
35095 struct device_attribute dev_attr;
35096 int field;
35097 -};
35098 +} __do_const;
35099 #define to_dmi_dev_attr(_dev_attr) \
35100 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35101
35102 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35103 index b95159b..841ae55 100644
35104 --- a/drivers/firmware/dmi_scan.c
35105 +++ b/drivers/firmware/dmi_scan.c
35106 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
35107 }
35108 }
35109 else {
35110 - /*
35111 - * no iounmap() for that ioremap(); it would be a no-op, but
35112 - * it's so early in setup that sucker gets confused into doing
35113 - * what it shouldn't if we actually call it.
35114 - */
35115 p = dmi_ioremap(0xF0000, 0x10000);
35116 if (p == NULL)
35117 goto error;
35118 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35119 if (buf == NULL)
35120 return -1;
35121
35122 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35123 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35124
35125 iounmap(buf);
35126 return 0;
35127 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
35128 index 5145fa3..0d3babd 100644
35129 --- a/drivers/firmware/efi/efi.c
35130 +++ b/drivers/firmware/efi/efi.c
35131 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
35132 };
35133
35134 static struct efivars generic_efivars;
35135 -static struct efivar_operations generic_ops;
35136 +static efivar_operations_no_const generic_ops __read_only;
35137
35138 static int generic_ops_register(void)
35139 {
35140 - generic_ops.get_variable = efi.get_variable;
35141 - generic_ops.set_variable = efi.set_variable;
35142 - generic_ops.get_next_variable = efi.get_next_variable;
35143 - generic_ops.query_variable_store = efi_query_variable_store;
35144 + pax_open_kernel();
35145 + *(void **)&generic_ops.get_variable = efi.get_variable;
35146 + *(void **)&generic_ops.set_variable = efi.set_variable;
35147 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
35148 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
35149 + pax_close_kernel();
35150
35151 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
35152 }
35153 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
35154 index 8bd1bb6..c48b0c6 100644
35155 --- a/drivers/firmware/efi/efivars.c
35156 +++ b/drivers/firmware/efi/efivars.c
35157 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
35158 static int
35159 create_efivars_bin_attributes(void)
35160 {
35161 - struct bin_attribute *attr;
35162 + bin_attribute_no_const *attr;
35163 int error;
35164
35165 /* new_var */
35166 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35167 index 2a90ba6..07f3733 100644
35168 --- a/drivers/firmware/google/memconsole.c
35169 +++ b/drivers/firmware/google/memconsole.c
35170 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35171 if (!found_memconsole())
35172 return -ENODEV;
35173
35174 - memconsole_bin_attr.size = memconsole_length;
35175 + pax_open_kernel();
35176 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35177 + pax_close_kernel();
35178
35179 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35180
35181 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35182 index e16d932..f0206ef 100644
35183 --- a/drivers/gpio/gpio-ich.c
35184 +++ b/drivers/gpio/gpio-ich.c
35185 @@ -69,7 +69,7 @@ struct ichx_desc {
35186 /* Some chipsets have quirks, let these use their own request/get */
35187 int (*request)(struct gpio_chip *chip, unsigned offset);
35188 int (*get)(struct gpio_chip *chip, unsigned offset);
35189 -};
35190 +} __do_const;
35191
35192 static struct {
35193 spinlock_t lock;
35194 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35195 index 9902732..64b62dd 100644
35196 --- a/drivers/gpio/gpio-vr41xx.c
35197 +++ b/drivers/gpio/gpio-vr41xx.c
35198 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35199 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35200 maskl, pendl, maskh, pendh);
35201
35202 - atomic_inc(&irq_err_count);
35203 + atomic_inc_unchecked(&irq_err_count);
35204
35205 return -EINVAL;
35206 }
35207 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35208 index ed1334e..ee0dd42 100644
35209 --- a/drivers/gpu/drm/drm_crtc_helper.c
35210 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35211 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35212 struct drm_crtc *tmp;
35213 int crtc_mask = 1;
35214
35215 - WARN(!crtc, "checking null crtc?\n");
35216 + BUG_ON(!crtc);
35217
35218 dev = crtc->dev;
35219
35220 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35221 index 9cc247f..36aa285 100644
35222 --- a/drivers/gpu/drm/drm_drv.c
35223 +++ b/drivers/gpu/drm/drm_drv.c
35224 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35225 /**
35226 * Copy and IOCTL return string to user space
35227 */
35228 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35229 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35230 {
35231 int len;
35232
35233 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35234 struct drm_file *file_priv = filp->private_data;
35235 struct drm_device *dev;
35236 const struct drm_ioctl_desc *ioctl = NULL;
35237 - drm_ioctl_t *func;
35238 + drm_ioctl_no_const_t func;
35239 unsigned int nr = DRM_IOCTL_NR(cmd);
35240 int retcode = -EINVAL;
35241 char stack_kdata[128];
35242 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35243 return -ENODEV;
35244
35245 atomic_inc(&dev->ioctl_count);
35246 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35247 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35248 ++file_priv->ioctl_count;
35249
35250 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
35251 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35252 index 429e07d..e681a2c 100644
35253 --- a/drivers/gpu/drm/drm_fops.c
35254 +++ b/drivers/gpu/drm/drm_fops.c
35255 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35256 }
35257
35258 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35259 - atomic_set(&dev->counts[i], 0);
35260 + atomic_set_unchecked(&dev->counts[i], 0);
35261
35262 dev->sigdata.lock = NULL;
35263
35264 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35265 if (drm_device_is_unplugged(dev))
35266 return -ENODEV;
35267
35268 - if (!dev->open_count++)
35269 + if (local_inc_return(&dev->open_count) == 1)
35270 need_setup = 1;
35271 mutex_lock(&dev->struct_mutex);
35272 old_imapping = inode->i_mapping;
35273 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35274 retcode = drm_open_helper(inode, filp, dev);
35275 if (retcode)
35276 goto err_undo;
35277 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35278 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35279 if (need_setup) {
35280 retcode = drm_setup(dev);
35281 if (retcode)
35282 @@ -166,7 +166,7 @@ err_undo:
35283 iput(container_of(dev->dev_mapping, struct inode, i_data));
35284 dev->dev_mapping = old_mapping;
35285 mutex_unlock(&dev->struct_mutex);
35286 - dev->open_count--;
35287 + local_dec(&dev->open_count);
35288 return retcode;
35289 }
35290 EXPORT_SYMBOL(drm_open);
35291 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35292
35293 mutex_lock(&drm_global_mutex);
35294
35295 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35296 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35297
35298 if (dev->driver->preclose)
35299 dev->driver->preclose(dev, file_priv);
35300 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35301 * Begin inline drm_release
35302 */
35303
35304 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35305 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35306 task_pid_nr(current),
35307 (long)old_encode_dev(file_priv->minor->device),
35308 - dev->open_count);
35309 + local_read(&dev->open_count));
35310
35311 /* Release any auth tokens that might point to this file_priv,
35312 (do that under the drm_global_mutex) */
35313 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35314 * End inline drm_release
35315 */
35316
35317 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35318 - if (!--dev->open_count) {
35319 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35320 + if (local_dec_and_test(&dev->open_count)) {
35321 if (atomic_read(&dev->ioctl_count)) {
35322 DRM_ERROR("Device busy: %d\n",
35323 atomic_read(&dev->ioctl_count));
35324 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35325 index f731116..629842c 100644
35326 --- a/drivers/gpu/drm/drm_global.c
35327 +++ b/drivers/gpu/drm/drm_global.c
35328 @@ -36,7 +36,7 @@
35329 struct drm_global_item {
35330 struct mutex mutex;
35331 void *object;
35332 - int refcount;
35333 + atomic_t refcount;
35334 };
35335
35336 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35337 @@ -49,7 +49,7 @@ void drm_global_init(void)
35338 struct drm_global_item *item = &glob[i];
35339 mutex_init(&item->mutex);
35340 item->object = NULL;
35341 - item->refcount = 0;
35342 + atomic_set(&item->refcount, 0);
35343 }
35344 }
35345
35346 @@ -59,7 +59,7 @@ void drm_global_release(void)
35347 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35348 struct drm_global_item *item = &glob[i];
35349 BUG_ON(item->object != NULL);
35350 - BUG_ON(item->refcount != 0);
35351 + BUG_ON(atomic_read(&item->refcount) != 0);
35352 }
35353 }
35354
35355 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35356 void *object;
35357
35358 mutex_lock(&item->mutex);
35359 - if (item->refcount == 0) {
35360 + if (atomic_read(&item->refcount) == 0) {
35361 item->object = kzalloc(ref->size, GFP_KERNEL);
35362 if (unlikely(item->object == NULL)) {
35363 ret = -ENOMEM;
35364 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35365 goto out_err;
35366
35367 }
35368 - ++item->refcount;
35369 + atomic_inc(&item->refcount);
35370 ref->object = item->object;
35371 object = item->object;
35372 mutex_unlock(&item->mutex);
35373 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35374 struct drm_global_item *item = &glob[ref->global_type];
35375
35376 mutex_lock(&item->mutex);
35377 - BUG_ON(item->refcount == 0);
35378 + BUG_ON(atomic_read(&item->refcount) == 0);
35379 BUG_ON(ref->object != item->object);
35380 - if (--item->refcount == 0) {
35381 + if (atomic_dec_and_test(&item->refcount)) {
35382 ref->release(ref);
35383 item->object = NULL;
35384 }
35385 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35386 index d4b20ce..77a8d41 100644
35387 --- a/drivers/gpu/drm/drm_info.c
35388 +++ b/drivers/gpu/drm/drm_info.c
35389 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35390 struct drm_local_map *map;
35391 struct drm_map_list *r_list;
35392
35393 - /* Hardcoded from _DRM_FRAME_BUFFER,
35394 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35395 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35396 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35397 + static const char * const types[] = {
35398 + [_DRM_FRAME_BUFFER] = "FB",
35399 + [_DRM_REGISTERS] = "REG",
35400 + [_DRM_SHM] = "SHM",
35401 + [_DRM_AGP] = "AGP",
35402 + [_DRM_SCATTER_GATHER] = "SG",
35403 + [_DRM_CONSISTENT] = "PCI",
35404 + [_DRM_GEM] = "GEM" };
35405 const char *type;
35406 int i;
35407
35408 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35409 map = r_list->map;
35410 if (!map)
35411 continue;
35412 - if (map->type < 0 || map->type > 5)
35413 + if (map->type >= ARRAY_SIZE(types))
35414 type = "??";
35415 else
35416 type = types[map->type];
35417 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35418 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35419 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35420 vma->vm_flags & VM_IO ? 'i' : '-',
35421 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35422 + 0);
35423 +#else
35424 vma->vm_pgoff);
35425 +#endif
35426
35427 #if defined(__i386__)
35428 pgprot = pgprot_val(vma->vm_page_prot);
35429 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35430 index 2f4c434..dd12cd2 100644
35431 --- a/drivers/gpu/drm/drm_ioc32.c
35432 +++ b/drivers/gpu/drm/drm_ioc32.c
35433 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35434 request = compat_alloc_user_space(nbytes);
35435 if (!access_ok(VERIFY_WRITE, request, nbytes))
35436 return -EFAULT;
35437 - list = (struct drm_buf_desc *) (request + 1);
35438 + list = (struct drm_buf_desc __user *) (request + 1);
35439
35440 if (__put_user(count, &request->count)
35441 || __put_user(list, &request->list))
35442 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35443 request = compat_alloc_user_space(nbytes);
35444 if (!access_ok(VERIFY_WRITE, request, nbytes))
35445 return -EFAULT;
35446 - list = (struct drm_buf_pub *) (request + 1);
35447 + list = (struct drm_buf_pub __user *) (request + 1);
35448
35449 if (__put_user(count, &request->count)
35450 || __put_user(list, &request->list))
35451 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35452 return 0;
35453 }
35454
35455 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35456 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35457 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35458 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35459 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35460 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35461 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35462 {
35463 unsigned int nr = DRM_IOCTL_NR(cmd);
35464 - drm_ioctl_compat_t *fn;
35465 int ret;
35466
35467 /* Assume that ioctls without an explicit compat routine will just
35468 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35469 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35470 return drm_ioctl(filp, cmd, arg);
35471
35472 - fn = drm_compat_ioctls[nr];
35473 -
35474 - if (fn != NULL)
35475 - ret = (*fn) (filp, cmd, arg);
35476 + if (drm_compat_ioctls[nr] != NULL)
35477 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35478 else
35479 ret = drm_ioctl(filp, cmd, arg);
35480
35481 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35482 index e77bd8b..1571b85 100644
35483 --- a/drivers/gpu/drm/drm_ioctl.c
35484 +++ b/drivers/gpu/drm/drm_ioctl.c
35485 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35486 stats->data[i].value =
35487 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35488 else
35489 - stats->data[i].value = atomic_read(&dev->counts[i]);
35490 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35491 stats->data[i].type = dev->types[i];
35492 }
35493
35494 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35495 index d752c96..fe08455 100644
35496 --- a/drivers/gpu/drm/drm_lock.c
35497 +++ b/drivers/gpu/drm/drm_lock.c
35498 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35499 if (drm_lock_take(&master->lock, lock->context)) {
35500 master->lock.file_priv = file_priv;
35501 master->lock.lock_time = jiffies;
35502 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35503 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35504 break; /* Got lock */
35505 }
35506
35507 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35508 return -EINVAL;
35509 }
35510
35511 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35512 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35513
35514 if (drm_lock_free(&master->lock, lock->context)) {
35515 /* FIXME: Should really bail out here. */
35516 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35517 index 16f3ec5..b28f9ca 100644
35518 --- a/drivers/gpu/drm/drm_stub.c
35519 +++ b/drivers/gpu/drm/drm_stub.c
35520 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35521
35522 drm_device_set_unplugged(dev);
35523
35524 - if (dev->open_count == 0) {
35525 + if (local_read(&dev->open_count) == 0) {
35526 drm_put_dev(dev);
35527 }
35528 mutex_unlock(&drm_global_mutex);
35529 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35530 index 0229665..f61329c 100644
35531 --- a/drivers/gpu/drm/drm_sysfs.c
35532 +++ b/drivers/gpu/drm/drm_sysfs.c
35533 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35534 int drm_sysfs_device_add(struct drm_minor *minor)
35535 {
35536 int err;
35537 - char *minor_str;
35538 + const char *minor_str;
35539
35540 minor->kdev.parent = minor->dev->dev;
35541
35542 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35543 index 004ecdf..db1f6e0 100644
35544 --- a/drivers/gpu/drm/i810/i810_dma.c
35545 +++ b/drivers/gpu/drm/i810/i810_dma.c
35546 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35547 dma->buflist[vertex->idx],
35548 vertex->discard, vertex->used);
35549
35550 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35551 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35552 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35553 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35554 sarea_priv->last_enqueue = dev_priv->counter - 1;
35555 sarea_priv->last_dispatch = (int)hw_status[5];
35556
35557 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35558 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35559 mc->last_render);
35560
35561 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35562 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35563 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35564 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35565 sarea_priv->last_enqueue = dev_priv->counter - 1;
35566 sarea_priv->last_dispatch = (int)hw_status[5];
35567
35568 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35569 index 6e0acad..93c8289 100644
35570 --- a/drivers/gpu/drm/i810/i810_drv.h
35571 +++ b/drivers/gpu/drm/i810/i810_drv.h
35572 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35573 int page_flipping;
35574
35575 wait_queue_head_t irq_queue;
35576 - atomic_t irq_received;
35577 - atomic_t irq_emitted;
35578 + atomic_unchecked_t irq_received;
35579 + atomic_unchecked_t irq_emitted;
35580
35581 int front_offset;
35582 } drm_i810_private_t;
35583 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35584 index e913d32..4d9b351 100644
35585 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35586 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35587 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35588 I915_READ(GTIMR));
35589 }
35590 seq_printf(m, "Interrupts received: %d\n",
35591 - atomic_read(&dev_priv->irq_received));
35592 + atomic_read_unchecked(&dev_priv->irq_received));
35593 for_each_ring(ring, dev_priv, i) {
35594 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35595 seq_printf(m,
35596 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35597 index 3b315ba..aac280f 100644
35598 --- a/drivers/gpu/drm/i915/i915_dma.c
35599 +++ b/drivers/gpu/drm/i915/i915_dma.c
35600 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35601 bool can_switch;
35602
35603 spin_lock(&dev->count_lock);
35604 - can_switch = (dev->open_count == 0);
35605 + can_switch = (local_read(&dev->open_count) == 0);
35606 spin_unlock(&dev->count_lock);
35607 return can_switch;
35608 }
35609 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35610 index 9669a0b..bb65176 100644
35611 --- a/drivers/gpu/drm/i915/i915_drv.h
35612 +++ b/drivers/gpu/drm/i915/i915_drv.h
35613 @@ -915,7 +915,7 @@ typedef struct drm_i915_private {
35614 drm_dma_handle_t *status_page_dmah;
35615 struct resource mch_res;
35616
35617 - atomic_t irq_received;
35618 + atomic_unchecked_t irq_received;
35619
35620 /* protects the irq masks */
35621 spinlock_t irq_lock;
35622 @@ -1811,7 +1811,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35623 struct drm_i915_private *dev_priv, unsigned port);
35624 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35625 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35626 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35627 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35628 {
35629 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35630 }
35631 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35632 index 117ce38..eefd237 100644
35633 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35634 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35635 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35636
35637 static int
35638 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35639 - int count)
35640 + unsigned int count)
35641 {
35642 - int i;
35643 + unsigned int i;
35644 int relocs_total = 0;
35645 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35646
35647 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35648 index 3c59584..500f2e9 100644
35649 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35650 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35651 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35652 (unsigned long)request);
35653 }
35654
35655 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35656 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35657 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35658 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35659 [DRM_I915_GETPARAM] = compat_i915_getparam,
35660 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35661 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35662 {
35663 unsigned int nr = DRM_IOCTL_NR(cmd);
35664 - drm_ioctl_compat_t *fn = NULL;
35665 int ret;
35666
35667 if (nr < DRM_COMMAND_BASE)
35668 return drm_compat_ioctl(filp, cmd, arg);
35669
35670 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35671 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35672 -
35673 - if (fn != NULL)
35674 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35675 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35676 ret = (*fn) (filp, cmd, arg);
35677 - else
35678 + } else
35679 ret = drm_ioctl(filp, cmd, arg);
35680
35681 return ret;
35682 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35683 index 0aa2ef0..77c03d0 100644
35684 --- a/drivers/gpu/drm/i915/i915_irq.c
35685 +++ b/drivers/gpu/drm/i915/i915_irq.c
35686 @@ -679,7 +679,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35687 int pipe;
35688 u32 pipe_stats[I915_MAX_PIPES];
35689
35690 - atomic_inc(&dev_priv->irq_received);
35691 + atomic_inc_unchecked(&dev_priv->irq_received);
35692
35693 while (true) {
35694 iir = I915_READ(VLV_IIR);
35695 @@ -844,7 +844,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35696 irqreturn_t ret = IRQ_NONE;
35697 int i;
35698
35699 - atomic_inc(&dev_priv->irq_received);
35700 + atomic_inc_unchecked(&dev_priv->irq_received);
35701
35702 /* disable master interrupt before clearing iir */
35703 de_ier = I915_READ(DEIER);
35704 @@ -934,7 +934,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35705 int ret = IRQ_NONE;
35706 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35707
35708 - atomic_inc(&dev_priv->irq_received);
35709 + atomic_inc_unchecked(&dev_priv->irq_received);
35710
35711 /* disable master interrupt before clearing iir */
35712 de_ier = I915_READ(DEIER);
35713 @@ -2098,7 +2098,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35714 {
35715 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35716
35717 - atomic_set(&dev_priv->irq_received, 0);
35718 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35719
35720 I915_WRITE(HWSTAM, 0xeffe);
35721
35722 @@ -2133,7 +2133,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35723 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35724 int pipe;
35725
35726 - atomic_set(&dev_priv->irq_received, 0);
35727 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35728
35729 /* VLV magic */
35730 I915_WRITE(VLV_IMR, 0);
35731 @@ -2420,7 +2420,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35732 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35733 int pipe;
35734
35735 - atomic_set(&dev_priv->irq_received, 0);
35736 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35737
35738 for_each_pipe(pipe)
35739 I915_WRITE(PIPESTAT(pipe), 0);
35740 @@ -2499,7 +2499,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35741 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35742 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35743
35744 - atomic_inc(&dev_priv->irq_received);
35745 + atomic_inc_unchecked(&dev_priv->irq_received);
35746
35747 iir = I915_READ16(IIR);
35748 if (iir == 0)
35749 @@ -2574,7 +2574,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35750 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35751 int pipe;
35752
35753 - atomic_set(&dev_priv->irq_received, 0);
35754 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35755
35756 if (I915_HAS_HOTPLUG(dev)) {
35757 I915_WRITE(PORT_HOTPLUG_EN, 0);
35758 @@ -2673,7 +2673,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35759 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35760 int pipe, ret = IRQ_NONE;
35761
35762 - atomic_inc(&dev_priv->irq_received);
35763 + atomic_inc_unchecked(&dev_priv->irq_received);
35764
35765 iir = I915_READ(IIR);
35766 do {
35767 @@ -2800,7 +2800,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35768 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35769 int pipe;
35770
35771 - atomic_set(&dev_priv->irq_received, 0);
35772 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35773
35774 I915_WRITE(PORT_HOTPLUG_EN, 0);
35775 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35776 @@ -2907,7 +2907,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35777 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35778 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35779
35780 - atomic_inc(&dev_priv->irq_received);
35781 + atomic_inc_unchecked(&dev_priv->irq_received);
35782
35783 iir = I915_READ(IIR);
35784
35785 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35786 index 56746dc..b5a214f 100644
35787 --- a/drivers/gpu/drm/i915/intel_display.c
35788 +++ b/drivers/gpu/drm/i915/intel_display.c
35789 @@ -8919,13 +8919,13 @@ struct intel_quirk {
35790 int subsystem_vendor;
35791 int subsystem_device;
35792 void (*hook)(struct drm_device *dev);
35793 -};
35794 +} __do_const;
35795
35796 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35797 struct intel_dmi_quirk {
35798 void (*hook)(struct drm_device *dev);
35799 const struct dmi_system_id (*dmi_id_list)[];
35800 -};
35801 +} __do_const;
35802
35803 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35804 {
35805 @@ -8933,18 +8933,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35806 return 1;
35807 }
35808
35809 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35810 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35811 {
35812 - .dmi_id_list = &(const struct dmi_system_id[]) {
35813 - {
35814 - .callback = intel_dmi_reverse_brightness,
35815 - .ident = "NCR Corporation",
35816 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35817 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35818 - },
35819 - },
35820 - { } /* terminating entry */
35821 + .callback = intel_dmi_reverse_brightness,
35822 + .ident = "NCR Corporation",
35823 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35824 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35825 },
35826 + },
35827 + { } /* terminating entry */
35828 +};
35829 +
35830 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35831 + {
35832 + .dmi_id_list = &intel_dmi_quirks_table,
35833 .hook = quirk_invert_brightness,
35834 },
35835 };
35836 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35837 index 54558a0..2d97005 100644
35838 --- a/drivers/gpu/drm/mga/mga_drv.h
35839 +++ b/drivers/gpu/drm/mga/mga_drv.h
35840 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35841 u32 clear_cmd;
35842 u32 maccess;
35843
35844 - atomic_t vbl_received; /**< Number of vblanks received. */
35845 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35846 wait_queue_head_t fence_queue;
35847 - atomic_t last_fence_retired;
35848 + atomic_unchecked_t last_fence_retired;
35849 u32 next_fence_to_post;
35850
35851 unsigned int fb_cpp;
35852 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35853 index 709e90d..89a1c0d 100644
35854 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35855 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35856 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35857 return 0;
35858 }
35859
35860 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35861 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35862 [DRM_MGA_INIT] = compat_mga_init,
35863 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35864 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35865 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35866 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35867 {
35868 unsigned int nr = DRM_IOCTL_NR(cmd);
35869 - drm_ioctl_compat_t *fn = NULL;
35870 int ret;
35871
35872 if (nr < DRM_COMMAND_BASE)
35873 return drm_compat_ioctl(filp, cmd, arg);
35874
35875 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35876 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35877 -
35878 - if (fn != NULL)
35879 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35880 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35881 ret = (*fn) (filp, cmd, arg);
35882 - else
35883 + } else
35884 ret = drm_ioctl(filp, cmd, arg);
35885
35886 return ret;
35887 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35888 index 598c281..60d590e 100644
35889 --- a/drivers/gpu/drm/mga/mga_irq.c
35890 +++ b/drivers/gpu/drm/mga/mga_irq.c
35891 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35892 if (crtc != 0)
35893 return 0;
35894
35895 - return atomic_read(&dev_priv->vbl_received);
35896 + return atomic_read_unchecked(&dev_priv->vbl_received);
35897 }
35898
35899
35900 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35901 /* VBLANK interrupt */
35902 if (status & MGA_VLINEPEN) {
35903 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35904 - atomic_inc(&dev_priv->vbl_received);
35905 + atomic_inc_unchecked(&dev_priv->vbl_received);
35906 drm_handle_vblank(dev, 0);
35907 handled = 1;
35908 }
35909 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35910 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35911 MGA_WRITE(MGA_PRIMEND, prim_end);
35912
35913 - atomic_inc(&dev_priv->last_fence_retired);
35914 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35915 DRM_WAKEUP(&dev_priv->fence_queue);
35916 handled = 1;
35917 }
35918 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35919 * using fences.
35920 */
35921 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35922 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35923 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35924 - *sequence) <= (1 << 23)));
35925
35926 *sequence = cur_fence;
35927 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35928 index 6aa2137..fe8dc55 100644
35929 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35930 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35931 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35932 struct bit_table {
35933 const char id;
35934 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35935 -};
35936 +} __no_const;
35937
35938 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35939
35940 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35941 index f2b30f8..d0f9a95 100644
35942 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35943 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35944 @@ -92,7 +92,7 @@ struct nouveau_drm {
35945 struct drm_global_reference mem_global_ref;
35946 struct ttm_bo_global_ref bo_global_ref;
35947 struct ttm_bo_device bdev;
35948 - atomic_t validate_sequence;
35949 + atomic_unchecked_t validate_sequence;
35950 int (*move)(struct nouveau_channel *,
35951 struct ttm_buffer_object *,
35952 struct ttm_mem_reg *, struct ttm_mem_reg *);
35953 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35954 index b4b4d0c..b7edc15 100644
35955 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35956 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35957 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35958 int ret, i;
35959 struct nouveau_bo *res_bo = NULL;
35960
35961 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35962 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35963 retry:
35964 if (++trycnt > 100000) {
35965 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35966 @@ -359,7 +359,7 @@ retry:
35967 if (ret) {
35968 validate_fini(op, NULL);
35969 if (unlikely(ret == -EAGAIN)) {
35970 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35971 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35972 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35973 sequence);
35974 if (!ret)
35975 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35976 index 08214bc..9208577 100644
35977 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35978 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35979 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35980 unsigned long arg)
35981 {
35982 unsigned int nr = DRM_IOCTL_NR(cmd);
35983 - drm_ioctl_compat_t *fn = NULL;
35984 + drm_ioctl_compat_t fn = NULL;
35985 int ret;
35986
35987 if (nr < DRM_COMMAND_BASE)
35988 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35989 index 25d3495..d81aaf6 100644
35990 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35991 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35992 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35993 bool can_switch;
35994
35995 spin_lock(&dev->count_lock);
35996 - can_switch = (dev->open_count == 0);
35997 + can_switch = (local_read(&dev->open_count) == 0);
35998 spin_unlock(&dev->count_lock);
35999 return can_switch;
36000 }
36001 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
36002 index 489cb8c..0b8d0d3 100644
36003 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
36004 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
36005 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
36006 }
36007 }
36008
36009 -static struct vm_operations_struct qxl_ttm_vm_ops;
36010 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
36011 static const struct vm_operations_struct *ttm_vm_ops;
36012
36013 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36014 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
36015 return r;
36016 if (unlikely(ttm_vm_ops == NULL)) {
36017 ttm_vm_ops = vma->vm_ops;
36018 + pax_open_kernel();
36019 qxl_ttm_vm_ops = *ttm_vm_ops;
36020 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
36021 + pax_close_kernel();
36022 }
36023 vma->vm_ops = &qxl_ttm_vm_ops;
36024 return 0;
36025 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
36026 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
36027 {
36028 #if defined(CONFIG_DEBUG_FS)
36029 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
36030 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
36031 - unsigned i;
36032 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
36033 + {
36034 + .name = "qxl_mem_mm",
36035 + .show = &qxl_mm_dump_table,
36036 + },
36037 + {
36038 + .name = "qxl_surf_mm",
36039 + .show = &qxl_mm_dump_table,
36040 + }
36041 + };
36042
36043 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
36044 - if (i == 0)
36045 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
36046 - else
36047 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
36048 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
36049 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
36050 - qxl_mem_types_list[i].driver_features = 0;
36051 - if (i == 0)
36052 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36053 - else
36054 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36055 + pax_open_kernel();
36056 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36057 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36058 + pax_close_kernel();
36059
36060 - }
36061 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
36062 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
36063 #else
36064 return 0;
36065 #endif
36066 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36067 index d4660cf..70dbe65 100644
36068 --- a/drivers/gpu/drm/r128/r128_cce.c
36069 +++ b/drivers/gpu/drm/r128/r128_cce.c
36070 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36071
36072 /* GH: Simple idle check.
36073 */
36074 - atomic_set(&dev_priv->idle_count, 0);
36075 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36076
36077 /* We don't support anything other than bus-mastering ring mode,
36078 * but the ring can be in either AGP or PCI space for the ring
36079 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36080 index 930c71b..499aded 100644
36081 --- a/drivers/gpu/drm/r128/r128_drv.h
36082 +++ b/drivers/gpu/drm/r128/r128_drv.h
36083 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36084 int is_pci;
36085 unsigned long cce_buffers_offset;
36086
36087 - atomic_t idle_count;
36088 + atomic_unchecked_t idle_count;
36089
36090 int page_flipping;
36091 int current_page;
36092 u32 crtc_offset;
36093 u32 crtc_offset_cntl;
36094
36095 - atomic_t vbl_received;
36096 + atomic_unchecked_t vbl_received;
36097
36098 u32 color_fmt;
36099 unsigned int front_offset;
36100 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36101 index a954c54..9cc595c 100644
36102 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36103 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36104 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36105 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36106 }
36107
36108 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36109 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36110 [DRM_R128_INIT] = compat_r128_init,
36111 [DRM_R128_DEPTH] = compat_r128_depth,
36112 [DRM_R128_STIPPLE] = compat_r128_stipple,
36113 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36114 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36115 {
36116 unsigned int nr = DRM_IOCTL_NR(cmd);
36117 - drm_ioctl_compat_t *fn = NULL;
36118 int ret;
36119
36120 if (nr < DRM_COMMAND_BASE)
36121 return drm_compat_ioctl(filp, cmd, arg);
36122
36123 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36124 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36125 -
36126 - if (fn != NULL)
36127 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36128 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36129 ret = (*fn) (filp, cmd, arg);
36130 - else
36131 + } else
36132 ret = drm_ioctl(filp, cmd, arg);
36133
36134 return ret;
36135 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36136 index 2ea4f09..d391371 100644
36137 --- a/drivers/gpu/drm/r128/r128_irq.c
36138 +++ b/drivers/gpu/drm/r128/r128_irq.c
36139 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36140 if (crtc != 0)
36141 return 0;
36142
36143 - return atomic_read(&dev_priv->vbl_received);
36144 + return atomic_read_unchecked(&dev_priv->vbl_received);
36145 }
36146
36147 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36148 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36149 /* VBLANK interrupt */
36150 if (status & R128_CRTC_VBLANK_INT) {
36151 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36152 - atomic_inc(&dev_priv->vbl_received);
36153 + atomic_inc_unchecked(&dev_priv->vbl_received);
36154 drm_handle_vblank(dev, 0);
36155 return IRQ_HANDLED;
36156 }
36157 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36158 index 19bb7e6..de7e2a2 100644
36159 --- a/drivers/gpu/drm/r128/r128_state.c
36160 +++ b/drivers/gpu/drm/r128/r128_state.c
36161 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36162
36163 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36164 {
36165 - if (atomic_read(&dev_priv->idle_count) == 0)
36166 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36167 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36168 else
36169 - atomic_set(&dev_priv->idle_count, 0);
36170 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36171 }
36172
36173 #endif
36174 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36175 index 5a82b6b..9e69c73 100644
36176 --- a/drivers/gpu/drm/radeon/mkregtable.c
36177 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36178 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36179 regex_t mask_rex;
36180 regmatch_t match[4];
36181 char buf[1024];
36182 - size_t end;
36183 + long end;
36184 int len;
36185 int done = 0;
36186 int r;
36187 unsigned o;
36188 struct offset *offset;
36189 char last_reg_s[10];
36190 - int last_reg;
36191 + unsigned long last_reg;
36192
36193 if (regcomp
36194 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36195 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36196 index b0dc0b6..a9bfe9c 100644
36197 --- a/drivers/gpu/drm/radeon/radeon_device.c
36198 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36199 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36200 bool can_switch;
36201
36202 spin_lock(&dev->count_lock);
36203 - can_switch = (dev->open_count == 0);
36204 + can_switch = (local_read(&dev->open_count) == 0);
36205 spin_unlock(&dev->count_lock);
36206 return can_switch;
36207 }
36208 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36209 index b369d42..8dd04eb 100644
36210 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36211 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36212 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
36213
36214 /* SW interrupt */
36215 wait_queue_head_t swi_queue;
36216 - atomic_t swi_emitted;
36217 + atomic_unchecked_t swi_emitted;
36218 int vblank_crtc;
36219 uint32_t irq_enable_reg;
36220 uint32_t r500_disp_irq_reg;
36221 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36222 index c180df8..5fd8186 100644
36223 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36224 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36225 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36226 request = compat_alloc_user_space(sizeof(*request));
36227 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36228 || __put_user(req32.param, &request->param)
36229 - || __put_user((void __user *)(unsigned long)req32.value,
36230 + || __put_user((unsigned long)req32.value,
36231 &request->value))
36232 return -EFAULT;
36233
36234 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36235 #define compat_radeon_cp_setparam NULL
36236 #endif /* X86_64 || IA64 */
36237
36238 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36239 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36240 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36241 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36242 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36243 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36244 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36245 {
36246 unsigned int nr = DRM_IOCTL_NR(cmd);
36247 - drm_ioctl_compat_t *fn = NULL;
36248 int ret;
36249
36250 if (nr < DRM_COMMAND_BASE)
36251 return drm_compat_ioctl(filp, cmd, arg);
36252
36253 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36254 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36255 -
36256 - if (fn != NULL)
36257 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36258 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36259 ret = (*fn) (filp, cmd, arg);
36260 - else
36261 + } else
36262 ret = drm_ioctl(filp, cmd, arg);
36263
36264 return ret;
36265 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36266 index 8d68e97..9dcfed8 100644
36267 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36268 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36269 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36270 unsigned int ret;
36271 RING_LOCALS;
36272
36273 - atomic_inc(&dev_priv->swi_emitted);
36274 - ret = atomic_read(&dev_priv->swi_emitted);
36275 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36276 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36277
36278 BEGIN_RING(4);
36279 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36280 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36281 drm_radeon_private_t *dev_priv =
36282 (drm_radeon_private_t *) dev->dev_private;
36283
36284 - atomic_set(&dev_priv->swi_emitted, 0);
36285 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36286 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36287
36288 dev->max_vblank_count = 0x001fffff;
36289 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36290 index 4d20910..6726b6d 100644
36291 --- a/drivers/gpu/drm/radeon/radeon_state.c
36292 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36293 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36294 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36295 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36296
36297 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36298 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36299 sarea_priv->nbox * sizeof(depth_boxes[0])))
36300 return -EFAULT;
36301
36302 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36303 {
36304 drm_radeon_private_t *dev_priv = dev->dev_private;
36305 drm_radeon_getparam_t *param = data;
36306 - int value;
36307 + int value = 0;
36308
36309 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36310
36311 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36312 index 6c0ce89..57a2529 100644
36313 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36314 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36315 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36316 man->size = size >> PAGE_SHIFT;
36317 }
36318
36319 -static struct vm_operations_struct radeon_ttm_vm_ops;
36320 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36321 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36322
36323 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36324 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36325 }
36326 if (unlikely(ttm_vm_ops == NULL)) {
36327 ttm_vm_ops = vma->vm_ops;
36328 + pax_open_kernel();
36329 radeon_ttm_vm_ops = *ttm_vm_ops;
36330 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36331 + pax_close_kernel();
36332 }
36333 vma->vm_ops = &radeon_ttm_vm_ops;
36334 return 0;
36335 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
36336 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36337 {
36338 #if defined(CONFIG_DEBUG_FS)
36339 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
36340 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
36341 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
36342 + {
36343 + .name = "radeon_vram_mm",
36344 + .show = &radeon_mm_dump_table,
36345 + },
36346 + {
36347 + .name = "radeon_gtt_mm",
36348 + .show = &radeon_mm_dump_table,
36349 + },
36350 + {
36351 + .name = "ttm_page_pool",
36352 + .show = &ttm_page_alloc_debugfs,
36353 + },
36354 + {
36355 + .name = "ttm_dma_page_pool",
36356 + .show = &ttm_dma_page_alloc_debugfs,
36357 + },
36358 + };
36359 unsigned i;
36360
36361 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
36362 - if (i == 0)
36363 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36364 - else
36365 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36366 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36367 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36368 - radeon_mem_types_list[i].driver_features = 0;
36369 - if (i == 0)
36370 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36371 - else
36372 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36373 -
36374 - }
36375 - /* Add ttm page pool to debugfs */
36376 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36377 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36378 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36379 - radeon_mem_types_list[i].driver_features = 0;
36380 - radeon_mem_types_list[i++].data = NULL;
36381 + pax_open_kernel();
36382 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36383 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36384 + pax_close_kernel();
36385 #ifdef CONFIG_SWIOTLB
36386 - if (swiotlb_nr_tbl()) {
36387 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36388 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36389 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36390 - radeon_mem_types_list[i].driver_features = 0;
36391 - radeon_mem_types_list[i++].data = NULL;
36392 - }
36393 + if (swiotlb_nr_tbl())
36394 + i++;
36395 #endif
36396 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36397
36398 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36399 index 55880d5..9e95342 100644
36400 --- a/drivers/gpu/drm/radeon/rs690.c
36401 +++ b/drivers/gpu/drm/radeon/rs690.c
36402 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36403 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36404 rdev->pm.sideport_bandwidth.full)
36405 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36406 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36407 + read_delay_latency.full = dfixed_const(800 * 1000);
36408 read_delay_latency.full = dfixed_div(read_delay_latency,
36409 rdev->pm.igp_sideport_mclk);
36410 + a.full = dfixed_const(370);
36411 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36412 } else {
36413 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36414 rdev->pm.k8_bandwidth.full)
36415 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36416 index dbc2def..0a9f710 100644
36417 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36418 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36419 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36420 zone->glob = glob;
36421 glob->zone_kernel = zone;
36422 ret = kobject_init_and_add(
36423 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36424 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36425 if (unlikely(ret != 0)) {
36426 kobject_put(&zone->kobj);
36427 return ret;
36428 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36429 zone->glob = glob;
36430 glob->zone_dma32 = zone;
36431 ret = kobject_init_and_add(
36432 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36433 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36434 if (unlikely(ret != 0)) {
36435 kobject_put(&zone->kobj);
36436 return ret;
36437 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36438 index bd2a3b4..122d9ad 100644
36439 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36440 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36441 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36442 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36443 struct shrink_control *sc)
36444 {
36445 - static atomic_t start_pool = ATOMIC_INIT(0);
36446 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36447 unsigned i;
36448 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36449 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36450 struct ttm_page_pool *pool;
36451 int shrink_pages = sc->nr_to_scan;
36452
36453 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36454 index dc0c065..58a0782 100644
36455 --- a/drivers/gpu/drm/udl/udl_fb.c
36456 +++ b/drivers/gpu/drm/udl/udl_fb.c
36457 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36458 fb_deferred_io_cleanup(info);
36459 kfree(info->fbdefio);
36460 info->fbdefio = NULL;
36461 - info->fbops->fb_mmap = udl_fb_mmap;
36462 }
36463
36464 pr_warn("released /dev/fb%d user=%d count=%d\n",
36465 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36466 index 893a650..6190d3b 100644
36467 --- a/drivers/gpu/drm/via/via_drv.h
36468 +++ b/drivers/gpu/drm/via/via_drv.h
36469 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36470 typedef uint32_t maskarray_t[5];
36471
36472 typedef struct drm_via_irq {
36473 - atomic_t irq_received;
36474 + atomic_unchecked_t irq_received;
36475 uint32_t pending_mask;
36476 uint32_t enable_mask;
36477 wait_queue_head_t irq_queue;
36478 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36479 struct timeval last_vblank;
36480 int last_vblank_valid;
36481 unsigned usec_per_vblank;
36482 - atomic_t vbl_received;
36483 + atomic_unchecked_t vbl_received;
36484 drm_via_state_t hc_state;
36485 char pci_buf[VIA_PCI_BUF_SIZE];
36486 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36487 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36488 index ac98964..5dbf512 100644
36489 --- a/drivers/gpu/drm/via/via_irq.c
36490 +++ b/drivers/gpu/drm/via/via_irq.c
36491 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36492 if (crtc != 0)
36493 return 0;
36494
36495 - return atomic_read(&dev_priv->vbl_received);
36496 + return atomic_read_unchecked(&dev_priv->vbl_received);
36497 }
36498
36499 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36500 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36501
36502 status = VIA_READ(VIA_REG_INTERRUPT);
36503 if (status & VIA_IRQ_VBLANK_PENDING) {
36504 - atomic_inc(&dev_priv->vbl_received);
36505 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36506 + atomic_inc_unchecked(&dev_priv->vbl_received);
36507 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36508 do_gettimeofday(&cur_vblank);
36509 if (dev_priv->last_vblank_valid) {
36510 dev_priv->usec_per_vblank =
36511 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36512 dev_priv->last_vblank = cur_vblank;
36513 dev_priv->last_vblank_valid = 1;
36514 }
36515 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36516 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36517 DRM_DEBUG("US per vblank is: %u\n",
36518 dev_priv->usec_per_vblank);
36519 }
36520 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36521
36522 for (i = 0; i < dev_priv->num_irqs; ++i) {
36523 if (status & cur_irq->pending_mask) {
36524 - atomic_inc(&cur_irq->irq_received);
36525 + atomic_inc_unchecked(&cur_irq->irq_received);
36526 DRM_WAKEUP(&cur_irq->irq_queue);
36527 handled = 1;
36528 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36529 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36530 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36531 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36532 masks[irq][4]));
36533 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36534 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36535 } else {
36536 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36537 (((cur_irq_sequence =
36538 - atomic_read(&cur_irq->irq_received)) -
36539 + atomic_read_unchecked(&cur_irq->irq_received)) -
36540 *sequence) <= (1 << 23)));
36541 }
36542 *sequence = cur_irq_sequence;
36543 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36544 }
36545
36546 for (i = 0; i < dev_priv->num_irqs; ++i) {
36547 - atomic_set(&cur_irq->irq_received, 0);
36548 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36549 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36550 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36551 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36552 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36553 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36554 case VIA_IRQ_RELATIVE:
36555 irqwait->request.sequence +=
36556 - atomic_read(&cur_irq->irq_received);
36557 + atomic_read_unchecked(&cur_irq->irq_received);
36558 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36559 case VIA_IRQ_ABSOLUTE:
36560 break;
36561 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36562 index 13aeda7..4a952d1 100644
36563 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36564 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36565 @@ -290,7 +290,7 @@ struct vmw_private {
36566 * Fencing and IRQs.
36567 */
36568
36569 - atomic_t marker_seq;
36570 + atomic_unchecked_t marker_seq;
36571 wait_queue_head_t fence_queue;
36572 wait_queue_head_t fifo_queue;
36573 int fence_queue_waiters; /* Protected by hw_mutex */
36574 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36575 index 3eb1486..0a47ee9 100644
36576 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36577 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36578 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36579 (unsigned int) min,
36580 (unsigned int) fifo->capabilities);
36581
36582 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36583 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36584 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36585 vmw_marker_queue_init(&fifo->marker_queue);
36586 return vmw_fifo_send_fence(dev_priv, &dummy);
36587 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36588 if (reserveable)
36589 iowrite32(bytes, fifo_mem +
36590 SVGA_FIFO_RESERVED);
36591 - return fifo_mem + (next_cmd >> 2);
36592 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36593 } else {
36594 need_bounce = true;
36595 }
36596 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36597
36598 fm = vmw_fifo_reserve(dev_priv, bytes);
36599 if (unlikely(fm == NULL)) {
36600 - *seqno = atomic_read(&dev_priv->marker_seq);
36601 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36602 ret = -ENOMEM;
36603 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36604 false, 3*HZ);
36605 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36606 }
36607
36608 do {
36609 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36610 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36611 } while (*seqno == 0);
36612
36613 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36614 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36615 index c509d40..3b640c3 100644
36616 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36617 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36618 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36619 int ret;
36620
36621 num_clips = arg->num_clips;
36622 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36623 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36624
36625 if (unlikely(num_clips == 0))
36626 return 0;
36627 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36628 int ret;
36629
36630 num_clips = arg->num_clips;
36631 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36632 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36633
36634 if (unlikely(num_clips == 0))
36635 return 0;
36636 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36637 index 4640adb..e1384ed 100644
36638 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36639 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36640 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36641 * emitted. Then the fence is stale and signaled.
36642 */
36643
36644 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36645 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36646 > VMW_FENCE_WRAP);
36647
36648 return ret;
36649 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36650
36651 if (fifo_idle)
36652 down_read(&fifo_state->rwsem);
36653 - signal_seq = atomic_read(&dev_priv->marker_seq);
36654 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36655 ret = 0;
36656
36657 for (;;) {
36658 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36659 index 8a8725c2..afed796 100644
36660 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36661 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36662 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36663 while (!vmw_lag_lt(queue, us)) {
36664 spin_lock(&queue->lock);
36665 if (list_empty(&queue->head))
36666 - seqno = atomic_read(&dev_priv->marker_seq);
36667 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36668 else {
36669 marker = list_first_entry(&queue->head,
36670 struct vmw_marker, head);
36671 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36672 index 264f550..f92dd8c 100644
36673 --- a/drivers/hid/hid-core.c
36674 +++ b/drivers/hid/hid-core.c
36675 @@ -2269,7 +2269,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36676
36677 int hid_add_device(struct hid_device *hdev)
36678 {
36679 - static atomic_t id = ATOMIC_INIT(0);
36680 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36681 int ret;
36682
36683 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36684 @@ -2303,7 +2303,7 @@ int hid_add_device(struct hid_device *hdev)
36685 /* XXX hack, any other cleaner solution after the driver core
36686 * is converted to allow more than 20 bytes as the device name? */
36687 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36688 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36689 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36690
36691 hid_debug_register(hdev, dev_name(&hdev->dev));
36692 ret = device_add(&hdev->dev);
36693 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36694 index 90124ff..3761764 100644
36695 --- a/drivers/hid/hid-wiimote-debug.c
36696 +++ b/drivers/hid/hid-wiimote-debug.c
36697 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36698 else if (size == 0)
36699 return -EIO;
36700
36701 - if (copy_to_user(u, buf, size))
36702 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36703 return -EFAULT;
36704
36705 *off += size;
36706 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36707 index 0b122f8..b1d8160 100644
36708 --- a/drivers/hv/channel.c
36709 +++ b/drivers/hv/channel.c
36710 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36711 int ret = 0;
36712 int t;
36713
36714 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36715 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36716 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36717 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36718
36719 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36720 if (ret)
36721 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36722 index ae49237..380d4c9 100644
36723 --- a/drivers/hv/hv.c
36724 +++ b/drivers/hv/hv.c
36725 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36726 u64 output_address = (output) ? virt_to_phys(output) : 0;
36727 u32 output_address_hi = output_address >> 32;
36728 u32 output_address_lo = output_address & 0xFFFFFFFF;
36729 - void *hypercall_page = hv_context.hypercall_page;
36730 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36731
36732 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36733 "=a"(hv_status_lo) : "d" (control_hi),
36734 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36735 index 12f2f9e..679603c 100644
36736 --- a/drivers/hv/hyperv_vmbus.h
36737 +++ b/drivers/hv/hyperv_vmbus.h
36738 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36739 struct vmbus_connection {
36740 enum vmbus_connect_state conn_state;
36741
36742 - atomic_t next_gpadl_handle;
36743 + atomic_unchecked_t next_gpadl_handle;
36744
36745 /*
36746 * Represents channel interrupts. Each bit position represents a
36747 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36748 index bf421e0..ce2c897 100644
36749 --- a/drivers/hv/vmbus_drv.c
36750 +++ b/drivers/hv/vmbus_drv.c
36751 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36752 {
36753 int ret = 0;
36754
36755 - static atomic_t device_num = ATOMIC_INIT(0);
36756 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36757
36758 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36759 - atomic_inc_return(&device_num));
36760 + atomic_inc_return_unchecked(&device_num));
36761
36762 child_device_obj->device.bus = &hv_bus;
36763 child_device_obj->device.parent = &hv_acpi_dev->dev;
36764 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36765 index 6351aba..dc4aaf4 100644
36766 --- a/drivers/hwmon/acpi_power_meter.c
36767 +++ b/drivers/hwmon/acpi_power_meter.c
36768 @@ -117,7 +117,7 @@ struct sensor_template {
36769 struct device_attribute *devattr,
36770 const char *buf, size_t count);
36771 int index;
36772 -};
36773 +} __do_const;
36774
36775 /* Averaging interval */
36776 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36777 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36778 struct sensor_template *attrs)
36779 {
36780 struct device *dev = &resource->acpi_dev->dev;
36781 - struct sensor_device_attribute *sensors =
36782 + sensor_device_attribute_no_const *sensors =
36783 &resource->sensors[resource->num_sensors];
36784 int res = 0;
36785
36786 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36787 index 62c2e32..8f2859a 100644
36788 --- a/drivers/hwmon/applesmc.c
36789 +++ b/drivers/hwmon/applesmc.c
36790 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36791 {
36792 struct applesmc_node_group *grp;
36793 struct applesmc_dev_attr *node;
36794 - struct attribute *attr;
36795 + attribute_no_const *attr;
36796 int ret, i;
36797
36798 for (grp = groups; grp->format; grp++) {
36799 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36800 index b25c643..a13460d 100644
36801 --- a/drivers/hwmon/asus_atk0110.c
36802 +++ b/drivers/hwmon/asus_atk0110.c
36803 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36804 struct atk_sensor_data {
36805 struct list_head list;
36806 struct atk_data *data;
36807 - struct device_attribute label_attr;
36808 - struct device_attribute input_attr;
36809 - struct device_attribute limit1_attr;
36810 - struct device_attribute limit2_attr;
36811 + device_attribute_no_const label_attr;
36812 + device_attribute_no_const input_attr;
36813 + device_attribute_no_const limit1_attr;
36814 + device_attribute_no_const limit2_attr;
36815 char label_attr_name[ATTR_NAME_SIZE];
36816 char input_attr_name[ATTR_NAME_SIZE];
36817 char limit1_attr_name[ATTR_NAME_SIZE];
36818 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36819 static struct device_attribute atk_name_attr =
36820 __ATTR(name, 0444, atk_name_show, NULL);
36821
36822 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36823 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36824 sysfs_show_func show)
36825 {
36826 sysfs_attr_init(&attr->attr);
36827 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36828 index 658ce3a..0d0c2f3 100644
36829 --- a/drivers/hwmon/coretemp.c
36830 +++ b/drivers/hwmon/coretemp.c
36831 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36832 return NOTIFY_OK;
36833 }
36834
36835 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36836 +static struct notifier_block coretemp_cpu_notifier = {
36837 .notifier_call = coretemp_cpu_callback,
36838 };
36839
36840 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36841 index 1429f6e..ee03d59 100644
36842 --- a/drivers/hwmon/ibmaem.c
36843 +++ b/drivers/hwmon/ibmaem.c
36844 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
36845 struct aem_rw_sensor_template *rw)
36846 {
36847 struct device *dev = &data->pdev->dev;
36848 - struct sensor_device_attribute *sensors = data->sensors;
36849 + sensor_device_attribute_no_const *sensors = data->sensors;
36850 int err;
36851
36852 /* Set up read-only sensors */
36853 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
36854 index 52b77af..aed1ddf 100644
36855 --- a/drivers/hwmon/iio_hwmon.c
36856 +++ b/drivers/hwmon/iio_hwmon.c
36857 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
36858 {
36859 struct device *dev = &pdev->dev;
36860 struct iio_hwmon_state *st;
36861 - struct sensor_device_attribute *a;
36862 + sensor_device_attribute_no_const *a;
36863 int ret, i;
36864 int in_i = 1, temp_i = 1, curr_i = 1;
36865 enum iio_chan_type type;
36866 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36867 index 9add6092..ee7ba3f 100644
36868 --- a/drivers/hwmon/pmbus/pmbus_core.c
36869 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36870 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36871 return 0;
36872 }
36873
36874 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36875 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36876 const char *name,
36877 umode_t mode,
36878 ssize_t (*show)(struct device *dev,
36879 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36880 dev_attr->store = store;
36881 }
36882
36883 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36884 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36885 const char *name,
36886 umode_t mode,
36887 ssize_t (*show)(struct device *dev,
36888 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36889 u16 reg, u8 mask)
36890 {
36891 struct pmbus_boolean *boolean;
36892 - struct sensor_device_attribute *a;
36893 + sensor_device_attribute_no_const *a;
36894
36895 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36896 if (!boolean)
36897 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36898 bool update, bool readonly)
36899 {
36900 struct pmbus_sensor *sensor;
36901 - struct device_attribute *a;
36902 + device_attribute_no_const *a;
36903
36904 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36905 if (!sensor)
36906 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36907 const char *lstring, int index)
36908 {
36909 struct pmbus_label *label;
36910 - struct device_attribute *a;
36911 + device_attribute_no_const *a;
36912
36913 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36914 if (!label)
36915 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36916 index 2507f90..1645765 100644
36917 --- a/drivers/hwmon/sht15.c
36918 +++ b/drivers/hwmon/sht15.c
36919 @@ -169,7 +169,7 @@ struct sht15_data {
36920 int supply_uv;
36921 bool supply_uv_valid;
36922 struct work_struct update_supply_work;
36923 - atomic_t interrupt_handled;
36924 + atomic_unchecked_t interrupt_handled;
36925 };
36926
36927 /**
36928 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36929 ret = gpio_direction_input(data->pdata->gpio_data);
36930 if (ret)
36931 return ret;
36932 - atomic_set(&data->interrupt_handled, 0);
36933 + atomic_set_unchecked(&data->interrupt_handled, 0);
36934
36935 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36936 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36937 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36938 /* Only relevant if the interrupt hasn't occurred. */
36939 - if (!atomic_read(&data->interrupt_handled))
36940 + if (!atomic_read_unchecked(&data->interrupt_handled))
36941 schedule_work(&data->read_work);
36942 }
36943 ret = wait_event_timeout(data->wait_queue,
36944 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36945
36946 /* First disable the interrupt */
36947 disable_irq_nosync(irq);
36948 - atomic_inc(&data->interrupt_handled);
36949 + atomic_inc_unchecked(&data->interrupt_handled);
36950 /* Then schedule a reading work struct */
36951 if (data->state != SHT15_READING_NOTHING)
36952 schedule_work(&data->read_work);
36953 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36954 * If not, then start the interrupt again - care here as could
36955 * have gone low in meantime so verify it hasn't!
36956 */
36957 - atomic_set(&data->interrupt_handled, 0);
36958 + atomic_set_unchecked(&data->interrupt_handled, 0);
36959 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36960 /* If still not occurred or another handler was scheduled */
36961 if (gpio_get_value(data->pdata->gpio_data)
36962 - || atomic_read(&data->interrupt_handled))
36963 + || atomic_read_unchecked(&data->interrupt_handled))
36964 return;
36965 }
36966
36967 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36968 index 76f157b..9c0db1b 100644
36969 --- a/drivers/hwmon/via-cputemp.c
36970 +++ b/drivers/hwmon/via-cputemp.c
36971 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36972 return NOTIFY_OK;
36973 }
36974
36975 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36976 +static struct notifier_block via_cputemp_cpu_notifier = {
36977 .notifier_call = via_cputemp_cpu_callback,
36978 };
36979
36980 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36981 index 07f01ac..d79ad3d 100644
36982 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36983 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36984 @@ -43,7 +43,7 @@
36985 extern struct i2c_adapter amd756_smbus;
36986
36987 static struct i2c_adapter *s4882_adapter;
36988 -static struct i2c_algorithm *s4882_algo;
36989 +static i2c_algorithm_no_const *s4882_algo;
36990
36991 /* Wrapper access functions for multiplexed SMBus */
36992 static DEFINE_MUTEX(amd756_lock);
36993 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36994 index 2ca268d..c6acbdf 100644
36995 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36996 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36997 @@ -41,7 +41,7 @@
36998 extern struct i2c_adapter *nforce2_smbus;
36999
37000 static struct i2c_adapter *s4985_adapter;
37001 -static struct i2c_algorithm *s4985_algo;
37002 +static i2c_algorithm_no_const *s4985_algo;
37003
37004 /* Wrapper access functions for multiplexed SMBus */
37005 static DEFINE_MUTEX(nforce2_lock);
37006 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
37007 index c3ccdea..5b3dc1a 100644
37008 --- a/drivers/i2c/i2c-dev.c
37009 +++ b/drivers/i2c/i2c-dev.c
37010 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
37011 break;
37012 }
37013
37014 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
37015 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
37016 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
37017 if (IS_ERR(rdwr_pa[i].buf)) {
37018 res = PTR_ERR(rdwr_pa[i].buf);
37019 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
37020 index 2ff6204..218c16e 100644
37021 --- a/drivers/ide/ide-cd.c
37022 +++ b/drivers/ide/ide-cd.c
37023 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
37024 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
37025 if ((unsigned long)buf & alignment
37026 || blk_rq_bytes(rq) & q->dma_pad_mask
37027 - || object_is_on_stack(buf))
37028 + || object_starts_on_stack(buf))
37029 drive->dma = 0;
37030 }
37031 }
37032 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37033 index e145931..08bfc59 100644
37034 --- a/drivers/iio/industrialio-core.c
37035 +++ b/drivers/iio/industrialio-core.c
37036 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37037 }
37038
37039 static
37040 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37041 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37042 const char *postfix,
37043 struct iio_chan_spec const *chan,
37044 ssize_t (*readfunc)(struct device *dev,
37045 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37046 index 784b97c..c9ceadf 100644
37047 --- a/drivers/infiniband/core/cm.c
37048 +++ b/drivers/infiniband/core/cm.c
37049 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37050
37051 struct cm_counter_group {
37052 struct kobject obj;
37053 - atomic_long_t counter[CM_ATTR_COUNT];
37054 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37055 };
37056
37057 struct cm_counter_attribute {
37058 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37059 struct ib_mad_send_buf *msg = NULL;
37060 int ret;
37061
37062 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37063 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37064 counter[CM_REQ_COUNTER]);
37065
37066 /* Quick state check to discard duplicate REQs. */
37067 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37068 if (!cm_id_priv)
37069 return;
37070
37071 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37072 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37073 counter[CM_REP_COUNTER]);
37074 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37075 if (ret)
37076 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
37077 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37078 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37079 spin_unlock_irq(&cm_id_priv->lock);
37080 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37081 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37082 counter[CM_RTU_COUNTER]);
37083 goto out;
37084 }
37085 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
37086 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37087 dreq_msg->local_comm_id);
37088 if (!cm_id_priv) {
37089 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37090 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37091 counter[CM_DREQ_COUNTER]);
37092 cm_issue_drep(work->port, work->mad_recv_wc);
37093 return -EINVAL;
37094 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
37095 case IB_CM_MRA_REP_RCVD:
37096 break;
37097 case IB_CM_TIMEWAIT:
37098 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37099 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37100 counter[CM_DREQ_COUNTER]);
37101 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37102 goto unlock;
37103 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
37104 cm_free_msg(msg);
37105 goto deref;
37106 case IB_CM_DREQ_RCVD:
37107 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37108 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37109 counter[CM_DREQ_COUNTER]);
37110 goto unlock;
37111 default:
37112 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
37113 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37114 cm_id_priv->msg, timeout)) {
37115 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37116 - atomic_long_inc(&work->port->
37117 + atomic_long_inc_unchecked(&work->port->
37118 counter_group[CM_RECV_DUPLICATES].
37119 counter[CM_MRA_COUNTER]);
37120 goto out;
37121 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
37122 break;
37123 case IB_CM_MRA_REQ_RCVD:
37124 case IB_CM_MRA_REP_RCVD:
37125 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37126 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37127 counter[CM_MRA_COUNTER]);
37128 /* fall through */
37129 default:
37130 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
37131 case IB_CM_LAP_IDLE:
37132 break;
37133 case IB_CM_MRA_LAP_SENT:
37134 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37135 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37136 counter[CM_LAP_COUNTER]);
37137 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37138 goto unlock;
37139 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
37140 cm_free_msg(msg);
37141 goto deref;
37142 case IB_CM_LAP_RCVD:
37143 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37144 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37145 counter[CM_LAP_COUNTER]);
37146 goto unlock;
37147 default:
37148 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37149 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37150 if (cur_cm_id_priv) {
37151 spin_unlock_irq(&cm.lock);
37152 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37153 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37154 counter[CM_SIDR_REQ_COUNTER]);
37155 goto out; /* Duplicate message. */
37156 }
37157 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37158 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37159 msg->retries = 1;
37160
37161 - atomic_long_add(1 + msg->retries,
37162 + atomic_long_add_unchecked(1 + msg->retries,
37163 &port->counter_group[CM_XMIT].counter[attr_index]);
37164 if (msg->retries)
37165 - atomic_long_add(msg->retries,
37166 + atomic_long_add_unchecked(msg->retries,
37167 &port->counter_group[CM_XMIT_RETRIES].
37168 counter[attr_index]);
37169
37170 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37171 }
37172
37173 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37174 - atomic_long_inc(&port->counter_group[CM_RECV].
37175 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37176 counter[attr_id - CM_ATTR_ID_OFFSET]);
37177
37178 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37179 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37180 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37181
37182 return sprintf(buf, "%ld\n",
37183 - atomic_long_read(&group->counter[cm_attr->index]));
37184 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37185 }
37186
37187 static const struct sysfs_ops cm_counter_ops = {
37188 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37189 index 9f5ad7c..588cd84 100644
37190 --- a/drivers/infiniband/core/fmr_pool.c
37191 +++ b/drivers/infiniband/core/fmr_pool.c
37192 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37193
37194 struct task_struct *thread;
37195
37196 - atomic_t req_ser;
37197 - atomic_t flush_ser;
37198 + atomic_unchecked_t req_ser;
37199 + atomic_unchecked_t flush_ser;
37200
37201 wait_queue_head_t force_wait;
37202 };
37203 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37204 struct ib_fmr_pool *pool = pool_ptr;
37205
37206 do {
37207 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37208 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37209 ib_fmr_batch_release(pool);
37210
37211 - atomic_inc(&pool->flush_ser);
37212 + atomic_inc_unchecked(&pool->flush_ser);
37213 wake_up_interruptible(&pool->force_wait);
37214
37215 if (pool->flush_function)
37216 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37217 }
37218
37219 set_current_state(TASK_INTERRUPTIBLE);
37220 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37221 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37222 !kthread_should_stop())
37223 schedule();
37224 __set_current_state(TASK_RUNNING);
37225 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37226 pool->dirty_watermark = params->dirty_watermark;
37227 pool->dirty_len = 0;
37228 spin_lock_init(&pool->pool_lock);
37229 - atomic_set(&pool->req_ser, 0);
37230 - atomic_set(&pool->flush_ser, 0);
37231 + atomic_set_unchecked(&pool->req_ser, 0);
37232 + atomic_set_unchecked(&pool->flush_ser, 0);
37233 init_waitqueue_head(&pool->force_wait);
37234
37235 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37236 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37237 }
37238 spin_unlock_irq(&pool->pool_lock);
37239
37240 - serial = atomic_inc_return(&pool->req_ser);
37241 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37242 wake_up_process(pool->thread);
37243
37244 if (wait_event_interruptible(pool->force_wait,
37245 - atomic_read(&pool->flush_ser) - serial >= 0))
37246 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37247 return -EINTR;
37248
37249 return 0;
37250 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37251 } else {
37252 list_add_tail(&fmr->list, &pool->dirty_list);
37253 if (++pool->dirty_len >= pool->dirty_watermark) {
37254 - atomic_inc(&pool->req_ser);
37255 + atomic_inc_unchecked(&pool->req_ser);
37256 wake_up_process(pool->thread);
37257 }
37258 }
37259 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37260 index 4cb8eb2..146bf60 100644
37261 --- a/drivers/infiniband/hw/cxgb4/mem.c
37262 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37263 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37264 int err;
37265 struct fw_ri_tpte tpt;
37266 u32 stag_idx;
37267 - static atomic_t key;
37268 + static atomic_unchecked_t key;
37269
37270 if (c4iw_fatal_error(rdev))
37271 return -EIO;
37272 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37273 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37274 rdev->stats.stag.max = rdev->stats.stag.cur;
37275 mutex_unlock(&rdev->stats.lock);
37276 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37277 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37278 }
37279 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37280 __func__, stag_state, type, pdid, stag_idx);
37281 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37282 index 79b3dbc..96e5fcc 100644
37283 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37284 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37285 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37286 struct ib_atomic_eth *ateth;
37287 struct ipath_ack_entry *e;
37288 u64 vaddr;
37289 - atomic64_t *maddr;
37290 + atomic64_unchecked_t *maddr;
37291 u64 sdata;
37292 u32 rkey;
37293 u8 next;
37294 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37295 IB_ACCESS_REMOTE_ATOMIC)))
37296 goto nack_acc_unlck;
37297 /* Perform atomic OP and save result. */
37298 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37299 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37300 sdata = be64_to_cpu(ateth->swap_data);
37301 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37302 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37303 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37304 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37305 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37306 be64_to_cpu(ateth->compare_data),
37307 sdata);
37308 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37309 index 1f95bba..9530f87 100644
37310 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37311 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37312 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37313 unsigned long flags;
37314 struct ib_wc wc;
37315 u64 sdata;
37316 - atomic64_t *maddr;
37317 + atomic64_unchecked_t *maddr;
37318 enum ib_wc_status send_status;
37319
37320 /*
37321 @@ -382,11 +382,11 @@ again:
37322 IB_ACCESS_REMOTE_ATOMIC)))
37323 goto acc_err;
37324 /* Perform atomic OP and save result. */
37325 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37326 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37327 sdata = wqe->wr.wr.atomic.compare_add;
37328 *(u64 *) sqp->s_sge.sge.vaddr =
37329 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37330 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37331 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37332 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37333 sdata, wqe->wr.wr.atomic.swap);
37334 goto send_comp;
37335 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37336 index 9d3e5c1..d9afe4a 100644
37337 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37338 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37339 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37340 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37341 }
37342
37343 -int mthca_QUERY_FW(struct mthca_dev *dev)
37344 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37345 {
37346 struct mthca_mailbox *mailbox;
37347 u32 *outbox;
37348 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37349 index ed9a989..e0c5871 100644
37350 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37351 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37352 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37353 return key;
37354 }
37355
37356 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37357 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37358 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37359 {
37360 struct mthca_mailbox *mailbox;
37361 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37362 index 4291410..d2ab1fb 100644
37363 --- a/drivers/infiniband/hw/nes/nes.c
37364 +++ b/drivers/infiniband/hw/nes/nes.c
37365 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37366 LIST_HEAD(nes_adapter_list);
37367 static LIST_HEAD(nes_dev_list);
37368
37369 -atomic_t qps_destroyed;
37370 +atomic_unchecked_t qps_destroyed;
37371
37372 static unsigned int ee_flsh_adapter;
37373 static unsigned int sysfs_nonidx_addr;
37374 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37375 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37376 struct nes_adapter *nesadapter = nesdev->nesadapter;
37377
37378 - atomic_inc(&qps_destroyed);
37379 + atomic_inc_unchecked(&qps_destroyed);
37380
37381 /* Free the control structures */
37382
37383 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37384 index 33cc589..3bd6538 100644
37385 --- a/drivers/infiniband/hw/nes/nes.h
37386 +++ b/drivers/infiniband/hw/nes/nes.h
37387 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37388 extern unsigned int wqm_quanta;
37389 extern struct list_head nes_adapter_list;
37390
37391 -extern atomic_t cm_connects;
37392 -extern atomic_t cm_accepts;
37393 -extern atomic_t cm_disconnects;
37394 -extern atomic_t cm_closes;
37395 -extern atomic_t cm_connecteds;
37396 -extern atomic_t cm_connect_reqs;
37397 -extern atomic_t cm_rejects;
37398 -extern atomic_t mod_qp_timouts;
37399 -extern atomic_t qps_created;
37400 -extern atomic_t qps_destroyed;
37401 -extern atomic_t sw_qps_destroyed;
37402 +extern atomic_unchecked_t cm_connects;
37403 +extern atomic_unchecked_t cm_accepts;
37404 +extern atomic_unchecked_t cm_disconnects;
37405 +extern atomic_unchecked_t cm_closes;
37406 +extern atomic_unchecked_t cm_connecteds;
37407 +extern atomic_unchecked_t cm_connect_reqs;
37408 +extern atomic_unchecked_t cm_rejects;
37409 +extern atomic_unchecked_t mod_qp_timouts;
37410 +extern atomic_unchecked_t qps_created;
37411 +extern atomic_unchecked_t qps_destroyed;
37412 +extern atomic_unchecked_t sw_qps_destroyed;
37413 extern u32 mh_detected;
37414 extern u32 mh_pauses_sent;
37415 extern u32 cm_packets_sent;
37416 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37417 extern u32 cm_packets_received;
37418 extern u32 cm_packets_dropped;
37419 extern u32 cm_packets_retrans;
37420 -extern atomic_t cm_listens_created;
37421 -extern atomic_t cm_listens_destroyed;
37422 +extern atomic_unchecked_t cm_listens_created;
37423 +extern atomic_unchecked_t cm_listens_destroyed;
37424 extern u32 cm_backlog_drops;
37425 -extern atomic_t cm_loopbacks;
37426 -extern atomic_t cm_nodes_created;
37427 -extern atomic_t cm_nodes_destroyed;
37428 -extern atomic_t cm_accel_dropped_pkts;
37429 -extern atomic_t cm_resets_recvd;
37430 -extern atomic_t pau_qps_created;
37431 -extern atomic_t pau_qps_destroyed;
37432 +extern atomic_unchecked_t cm_loopbacks;
37433 +extern atomic_unchecked_t cm_nodes_created;
37434 +extern atomic_unchecked_t cm_nodes_destroyed;
37435 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37436 +extern atomic_unchecked_t cm_resets_recvd;
37437 +extern atomic_unchecked_t pau_qps_created;
37438 +extern atomic_unchecked_t pau_qps_destroyed;
37439
37440 extern u32 int_mod_timer_init;
37441 extern u32 int_mod_cq_depth_256;
37442 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37443 index 24b9f1a..00fd004 100644
37444 --- a/drivers/infiniband/hw/nes/nes_cm.c
37445 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37446 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37447 u32 cm_packets_retrans;
37448 u32 cm_packets_created;
37449 u32 cm_packets_received;
37450 -atomic_t cm_listens_created;
37451 -atomic_t cm_listens_destroyed;
37452 +atomic_unchecked_t cm_listens_created;
37453 +atomic_unchecked_t cm_listens_destroyed;
37454 u32 cm_backlog_drops;
37455 -atomic_t cm_loopbacks;
37456 -atomic_t cm_nodes_created;
37457 -atomic_t cm_nodes_destroyed;
37458 -atomic_t cm_accel_dropped_pkts;
37459 -atomic_t cm_resets_recvd;
37460 +atomic_unchecked_t cm_loopbacks;
37461 +atomic_unchecked_t cm_nodes_created;
37462 +atomic_unchecked_t cm_nodes_destroyed;
37463 +atomic_unchecked_t cm_accel_dropped_pkts;
37464 +atomic_unchecked_t cm_resets_recvd;
37465
37466 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37467 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37468 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37469
37470 static struct nes_cm_core *g_cm_core;
37471
37472 -atomic_t cm_connects;
37473 -atomic_t cm_accepts;
37474 -atomic_t cm_disconnects;
37475 -atomic_t cm_closes;
37476 -atomic_t cm_connecteds;
37477 -atomic_t cm_connect_reqs;
37478 -atomic_t cm_rejects;
37479 +atomic_unchecked_t cm_connects;
37480 +atomic_unchecked_t cm_accepts;
37481 +atomic_unchecked_t cm_disconnects;
37482 +atomic_unchecked_t cm_closes;
37483 +atomic_unchecked_t cm_connecteds;
37484 +atomic_unchecked_t cm_connect_reqs;
37485 +atomic_unchecked_t cm_rejects;
37486
37487 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37488 {
37489 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37490 kfree(listener);
37491 listener = NULL;
37492 ret = 0;
37493 - atomic_inc(&cm_listens_destroyed);
37494 + atomic_inc_unchecked(&cm_listens_destroyed);
37495 } else {
37496 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37497 }
37498 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37499 cm_node->rem_mac);
37500
37501 add_hte_node(cm_core, cm_node);
37502 - atomic_inc(&cm_nodes_created);
37503 + atomic_inc_unchecked(&cm_nodes_created);
37504
37505 return cm_node;
37506 }
37507 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37508 }
37509
37510 atomic_dec(&cm_core->node_cnt);
37511 - atomic_inc(&cm_nodes_destroyed);
37512 + atomic_inc_unchecked(&cm_nodes_destroyed);
37513 nesqp = cm_node->nesqp;
37514 if (nesqp) {
37515 nesqp->cm_node = NULL;
37516 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37517
37518 static void drop_packet(struct sk_buff *skb)
37519 {
37520 - atomic_inc(&cm_accel_dropped_pkts);
37521 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37522 dev_kfree_skb_any(skb);
37523 }
37524
37525 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37526 {
37527
37528 int reset = 0; /* whether to send reset in case of err.. */
37529 - atomic_inc(&cm_resets_recvd);
37530 + atomic_inc_unchecked(&cm_resets_recvd);
37531 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37532 " refcnt=%d\n", cm_node, cm_node->state,
37533 atomic_read(&cm_node->ref_count));
37534 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37535 rem_ref_cm_node(cm_node->cm_core, cm_node);
37536 return NULL;
37537 }
37538 - atomic_inc(&cm_loopbacks);
37539 + atomic_inc_unchecked(&cm_loopbacks);
37540 loopbackremotenode->loopbackpartner = cm_node;
37541 loopbackremotenode->tcp_cntxt.rcv_wscale =
37542 NES_CM_DEFAULT_RCV_WND_SCALE;
37543 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37544 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37545 else {
37546 rem_ref_cm_node(cm_core, cm_node);
37547 - atomic_inc(&cm_accel_dropped_pkts);
37548 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37549 dev_kfree_skb_any(skb);
37550 }
37551 break;
37552 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37553
37554 if ((cm_id) && (cm_id->event_handler)) {
37555 if (issue_disconn) {
37556 - atomic_inc(&cm_disconnects);
37557 + atomic_inc_unchecked(&cm_disconnects);
37558 cm_event.event = IW_CM_EVENT_DISCONNECT;
37559 cm_event.status = disconn_status;
37560 cm_event.local_addr = cm_id->local_addr;
37561 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37562 }
37563
37564 if (issue_close) {
37565 - atomic_inc(&cm_closes);
37566 + atomic_inc_unchecked(&cm_closes);
37567 nes_disconnect(nesqp, 1);
37568
37569 cm_id->provider_data = nesqp;
37570 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37571
37572 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37573 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37574 - atomic_inc(&cm_accepts);
37575 + atomic_inc_unchecked(&cm_accepts);
37576
37577 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37578 netdev_refcnt_read(nesvnic->netdev));
37579 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37580 struct nes_cm_core *cm_core;
37581 u8 *start_buff;
37582
37583 - atomic_inc(&cm_rejects);
37584 + atomic_inc_unchecked(&cm_rejects);
37585 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37586 loopback = cm_node->loopbackpartner;
37587 cm_core = cm_node->cm_core;
37588 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37589 ntohl(cm_id->local_addr.sin_addr.s_addr),
37590 ntohs(cm_id->local_addr.sin_port));
37591
37592 - atomic_inc(&cm_connects);
37593 + atomic_inc_unchecked(&cm_connects);
37594 nesqp->active_conn = 1;
37595
37596 /* cache the cm_id in the qp */
37597 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37598 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37599 return err;
37600 }
37601 - atomic_inc(&cm_listens_created);
37602 + atomic_inc_unchecked(&cm_listens_created);
37603 }
37604
37605 cm_id->add_ref(cm_id);
37606 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37607
37608 if (nesqp->destroyed)
37609 return;
37610 - atomic_inc(&cm_connecteds);
37611 + atomic_inc_unchecked(&cm_connecteds);
37612 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37613 " local port 0x%04X. jiffies = %lu.\n",
37614 nesqp->hwqp.qp_id,
37615 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37616
37617 cm_id->add_ref(cm_id);
37618 ret = cm_id->event_handler(cm_id, &cm_event);
37619 - atomic_inc(&cm_closes);
37620 + atomic_inc_unchecked(&cm_closes);
37621 cm_event.event = IW_CM_EVENT_CLOSE;
37622 cm_event.status = 0;
37623 cm_event.provider_data = cm_id->provider_data;
37624 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37625 return;
37626 cm_id = cm_node->cm_id;
37627
37628 - atomic_inc(&cm_connect_reqs);
37629 + atomic_inc_unchecked(&cm_connect_reqs);
37630 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37631 cm_node, cm_id, jiffies);
37632
37633 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37634 return;
37635 cm_id = cm_node->cm_id;
37636
37637 - atomic_inc(&cm_connect_reqs);
37638 + atomic_inc_unchecked(&cm_connect_reqs);
37639 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37640 cm_node, cm_id, jiffies);
37641
37642 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37643 index 4166452..fc952c3 100644
37644 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37645 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37646 @@ -40,8 +40,8 @@
37647 #include "nes.h"
37648 #include "nes_mgt.h"
37649
37650 -atomic_t pau_qps_created;
37651 -atomic_t pau_qps_destroyed;
37652 +atomic_unchecked_t pau_qps_created;
37653 +atomic_unchecked_t pau_qps_destroyed;
37654
37655 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37656 {
37657 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37658 {
37659 struct sk_buff *skb;
37660 unsigned long flags;
37661 - atomic_inc(&pau_qps_destroyed);
37662 + atomic_inc_unchecked(&pau_qps_destroyed);
37663
37664 /* Free packets that have not yet been forwarded */
37665 /* Lock is acquired by skb_dequeue when removing the skb */
37666 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37667 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37668 skb_queue_head_init(&nesqp->pau_list);
37669 spin_lock_init(&nesqp->pau_lock);
37670 - atomic_inc(&pau_qps_created);
37671 + atomic_inc_unchecked(&pau_qps_created);
37672 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37673 }
37674
37675 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37676 index 49eb511..a774366 100644
37677 --- a/drivers/infiniband/hw/nes/nes_nic.c
37678 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37679 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37680 target_stat_values[++index] = mh_detected;
37681 target_stat_values[++index] = mh_pauses_sent;
37682 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37683 - target_stat_values[++index] = atomic_read(&cm_connects);
37684 - target_stat_values[++index] = atomic_read(&cm_accepts);
37685 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37686 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37687 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37688 - target_stat_values[++index] = atomic_read(&cm_rejects);
37689 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37690 - target_stat_values[++index] = atomic_read(&qps_created);
37691 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37692 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37693 - target_stat_values[++index] = atomic_read(&cm_closes);
37694 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37695 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37696 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37697 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37698 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37699 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37700 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37701 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37702 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37703 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37704 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37705 target_stat_values[++index] = cm_packets_sent;
37706 target_stat_values[++index] = cm_packets_bounced;
37707 target_stat_values[++index] = cm_packets_created;
37708 target_stat_values[++index] = cm_packets_received;
37709 target_stat_values[++index] = cm_packets_dropped;
37710 target_stat_values[++index] = cm_packets_retrans;
37711 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37712 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37713 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37714 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37715 target_stat_values[++index] = cm_backlog_drops;
37716 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37717 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37718 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37719 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37720 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37721 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37722 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37723 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37724 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37725 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37726 target_stat_values[++index] = nesadapter->free_4kpbl;
37727 target_stat_values[++index] = nesadapter->free_256pbl;
37728 target_stat_values[++index] = int_mod_timer_init;
37729 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37730 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37731 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37732 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37733 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37734 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37735 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37736 }
37737
37738 /**
37739 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37740 index 8f67fe2..8960859 100644
37741 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37742 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37743 @@ -46,9 +46,9 @@
37744
37745 #include <rdma/ib_umem.h>
37746
37747 -atomic_t mod_qp_timouts;
37748 -atomic_t qps_created;
37749 -atomic_t sw_qps_destroyed;
37750 +atomic_unchecked_t mod_qp_timouts;
37751 +atomic_unchecked_t qps_created;
37752 +atomic_unchecked_t sw_qps_destroyed;
37753
37754 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37755
37756 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37757 if (init_attr->create_flags)
37758 return ERR_PTR(-EINVAL);
37759
37760 - atomic_inc(&qps_created);
37761 + atomic_inc_unchecked(&qps_created);
37762 switch (init_attr->qp_type) {
37763 case IB_QPT_RC:
37764 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37765 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37766 struct iw_cm_event cm_event;
37767 int ret = 0;
37768
37769 - atomic_inc(&sw_qps_destroyed);
37770 + atomic_inc_unchecked(&sw_qps_destroyed);
37771 nesqp->destroyed = 1;
37772
37773 /* Blow away the connection if it exists. */
37774 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37775 index 4d11575..3e890e5 100644
37776 --- a/drivers/infiniband/hw/qib/qib.h
37777 +++ b/drivers/infiniband/hw/qib/qib.h
37778 @@ -51,6 +51,7 @@
37779 #include <linux/completion.h>
37780 #include <linux/kref.h>
37781 #include <linux/sched.h>
37782 +#include <linux/slab.h>
37783
37784 #include "qib_common.h"
37785 #include "qib_verbs.h"
37786 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37787 index da739d9..da1c7f4 100644
37788 --- a/drivers/input/gameport/gameport.c
37789 +++ b/drivers/input/gameport/gameport.c
37790 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37791 */
37792 static void gameport_init_port(struct gameport *gameport)
37793 {
37794 - static atomic_t gameport_no = ATOMIC_INIT(0);
37795 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37796
37797 __module_get(THIS_MODULE);
37798
37799 mutex_init(&gameport->drv_mutex);
37800 device_initialize(&gameport->dev);
37801 dev_set_name(&gameport->dev, "gameport%lu",
37802 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37803 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37804 gameport->dev.bus = &gameport_bus;
37805 gameport->dev.release = gameport_release_port;
37806 if (gameport->parent)
37807 diff --git a/drivers/input/input.c b/drivers/input/input.c
37808 index c044699..174d71a 100644
37809 --- a/drivers/input/input.c
37810 +++ b/drivers/input/input.c
37811 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37812 */
37813 int input_register_device(struct input_dev *dev)
37814 {
37815 - static atomic_t input_no = ATOMIC_INIT(0);
37816 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37817 struct input_devres *devres = NULL;
37818 struct input_handler *handler;
37819 unsigned int packet_size;
37820 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37821 dev->setkeycode = input_default_setkeycode;
37822
37823 dev_set_name(&dev->dev, "input%ld",
37824 - (unsigned long) atomic_inc_return(&input_no) - 1);
37825 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37826
37827 error = device_add(&dev->dev);
37828 if (error)
37829 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37830 index 04c69af..5f92d00 100644
37831 --- a/drivers/input/joystick/sidewinder.c
37832 +++ b/drivers/input/joystick/sidewinder.c
37833 @@ -30,6 +30,7 @@
37834 #include <linux/kernel.h>
37835 #include <linux/module.h>
37836 #include <linux/slab.h>
37837 +#include <linux/sched.h>
37838 #include <linux/init.h>
37839 #include <linux/input.h>
37840 #include <linux/gameport.h>
37841 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37842 index fa061d4..4a6957c 100644
37843 --- a/drivers/input/joystick/xpad.c
37844 +++ b/drivers/input/joystick/xpad.c
37845 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37846
37847 static int xpad_led_probe(struct usb_xpad *xpad)
37848 {
37849 - static atomic_t led_seq = ATOMIC_INIT(0);
37850 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37851 long led_no;
37852 struct xpad_led *led;
37853 struct led_classdev *led_cdev;
37854 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37855 if (!led)
37856 return -ENOMEM;
37857
37858 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37859 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37860
37861 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37862 led->xpad = xpad;
37863 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37864 index 2f0b39d..7370f13 100644
37865 --- a/drivers/input/mouse/psmouse.h
37866 +++ b/drivers/input/mouse/psmouse.h
37867 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37868 ssize_t (*set)(struct psmouse *psmouse, void *data,
37869 const char *buf, size_t count);
37870 bool protect;
37871 -};
37872 +} __do_const;
37873 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37874
37875 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37876 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37877 index 4c842c3..590b0bf 100644
37878 --- a/drivers/input/mousedev.c
37879 +++ b/drivers/input/mousedev.c
37880 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37881
37882 spin_unlock_irq(&client->packet_lock);
37883
37884 - if (copy_to_user(buffer, data, count))
37885 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37886 return -EFAULT;
37887
37888 return count;
37889 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37890 index 25fc597..558bf3b3 100644
37891 --- a/drivers/input/serio/serio.c
37892 +++ b/drivers/input/serio/serio.c
37893 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37894 */
37895 static void serio_init_port(struct serio *serio)
37896 {
37897 - static atomic_t serio_no = ATOMIC_INIT(0);
37898 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37899
37900 __module_get(THIS_MODULE);
37901
37902 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37903 mutex_init(&serio->drv_mutex);
37904 device_initialize(&serio->dev);
37905 dev_set_name(&serio->dev, "serio%ld",
37906 - (long)atomic_inc_return(&serio_no) - 1);
37907 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37908 serio->dev.bus = &serio_bus;
37909 serio->dev.release = serio_release_port;
37910 serio->dev.groups = serio_device_attr_groups;
37911 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37912 index d8f98b1..f62a640 100644
37913 --- a/drivers/iommu/iommu.c
37914 +++ b/drivers/iommu/iommu.c
37915 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
37916 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37917 {
37918 bus_register_notifier(bus, &iommu_bus_nb);
37919 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37920 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37921 }
37922
37923 /**
37924 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37925 index dcfea4e..f4226b2 100644
37926 --- a/drivers/iommu/irq_remapping.c
37927 +++ b/drivers/iommu/irq_remapping.c
37928 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37929 void panic_if_irq_remap(const char *msg)
37930 {
37931 if (irq_remapping_enabled)
37932 - panic(msg);
37933 + panic("%s", msg);
37934 }
37935
37936 static void ir_ack_apic_edge(struct irq_data *data)
37937 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37938
37939 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37940 {
37941 - chip->irq_print_chip = ir_print_prefix;
37942 - chip->irq_ack = ir_ack_apic_edge;
37943 - chip->irq_eoi = ir_ack_apic_level;
37944 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37945 + pax_open_kernel();
37946 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37947 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37948 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37949 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37950 + pax_close_kernel();
37951 }
37952
37953 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37954 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37955 index 19ceaa6..3625818 100644
37956 --- a/drivers/irqchip/irq-gic.c
37957 +++ b/drivers/irqchip/irq-gic.c
37958 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37959 * Supported arch specific GIC irq extension.
37960 * Default make them NULL.
37961 */
37962 -struct irq_chip gic_arch_extn = {
37963 +irq_chip_no_const gic_arch_extn = {
37964 .irq_eoi = NULL,
37965 .irq_mask = NULL,
37966 .irq_unmask = NULL,
37967 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37968 chained_irq_exit(chip, desc);
37969 }
37970
37971 -static struct irq_chip gic_chip = {
37972 +static irq_chip_no_const gic_chip __read_only = {
37973 .name = "GIC",
37974 .irq_mask = gic_mask_irq,
37975 .irq_unmask = gic_unmask_irq,
37976 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37977 index ac6f72b..81150f2 100644
37978 --- a/drivers/isdn/capi/capi.c
37979 +++ b/drivers/isdn/capi/capi.c
37980 @@ -81,8 +81,8 @@ struct capiminor {
37981
37982 struct capi20_appl *ap;
37983 u32 ncci;
37984 - atomic_t datahandle;
37985 - atomic_t msgid;
37986 + atomic_unchecked_t datahandle;
37987 + atomic_unchecked_t msgid;
37988
37989 struct tty_port port;
37990 int ttyinstop;
37991 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37992 capimsg_setu16(s, 2, mp->ap->applid);
37993 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37994 capimsg_setu8 (s, 5, CAPI_RESP);
37995 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37996 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37997 capimsg_setu32(s, 8, mp->ncci);
37998 capimsg_setu16(s, 12, datahandle);
37999 }
38000 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
38001 mp->outbytes -= len;
38002 spin_unlock_bh(&mp->outlock);
38003
38004 - datahandle = atomic_inc_return(&mp->datahandle);
38005 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
38006 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
38007 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38008 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38009 capimsg_setu16(skb->data, 2, mp->ap->applid);
38010 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
38011 capimsg_setu8 (skb->data, 5, CAPI_REQ);
38012 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
38013 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
38014 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
38015 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
38016 capimsg_setu16(skb->data, 16, len); /* Data length */
38017 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
38018 index 600c79b..3752bab 100644
38019 --- a/drivers/isdn/gigaset/interface.c
38020 +++ b/drivers/isdn/gigaset/interface.c
38021 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
38022 }
38023 tty->driver_data = cs;
38024
38025 - ++cs->port.count;
38026 + atomic_inc(&cs->port.count);
38027
38028 - if (cs->port.count == 1) {
38029 + if (atomic_read(&cs->port.count) == 1) {
38030 tty_port_tty_set(&cs->port, tty);
38031 cs->port.low_latency = 1;
38032 }
38033 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38034
38035 if (!cs->connected)
38036 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38037 - else if (!cs->port.count)
38038 + else if (!atomic_read(&cs->port.count))
38039 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38040 - else if (!--cs->port.count)
38041 + else if (!atomic_dec_return(&cs->port.count))
38042 tty_port_tty_set(&cs->port, NULL);
38043
38044 mutex_unlock(&cs->mutex);
38045 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38046 index 4d9b195..455075c 100644
38047 --- a/drivers/isdn/hardware/avm/b1.c
38048 +++ b/drivers/isdn/hardware/avm/b1.c
38049 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38050 }
38051 if (left) {
38052 if (t4file->user) {
38053 - if (copy_from_user(buf, dp, left))
38054 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38055 return -EFAULT;
38056 } else {
38057 memcpy(buf, dp, left);
38058 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38059 }
38060 if (left) {
38061 if (config->user) {
38062 - if (copy_from_user(buf, dp, left))
38063 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38064 return -EFAULT;
38065 } else {
38066 memcpy(buf, dp, left);
38067 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38068 index 3c5f249..5fac4d0 100644
38069 --- a/drivers/isdn/i4l/isdn_tty.c
38070 +++ b/drivers/isdn/i4l/isdn_tty.c
38071 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38072
38073 #ifdef ISDN_DEBUG_MODEM_OPEN
38074 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38075 - port->count);
38076 + atomic_read(&port->count));
38077 #endif
38078 - port->count++;
38079 + atomic_inc(&port->count);
38080 port->tty = tty;
38081 /*
38082 * Start up serial port
38083 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38084 #endif
38085 return;
38086 }
38087 - if ((tty->count == 1) && (port->count != 1)) {
38088 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38089 /*
38090 * Uh, oh. tty->count is 1, which means that the tty
38091 * structure will be freed. Info->count should always
38092 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38093 * serial port won't be shutdown.
38094 */
38095 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38096 - "info->count is %d\n", port->count);
38097 - port->count = 1;
38098 + "info->count is %d\n", atomic_read(&port->count));
38099 + atomic_set(&port->count, 1);
38100 }
38101 - if (--port->count < 0) {
38102 + if (atomic_dec_return(&port->count) < 0) {
38103 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38104 - info->line, port->count);
38105 - port->count = 0;
38106 + info->line, atomic_read(&port->count));
38107 + atomic_set(&port->count, 0);
38108 }
38109 - if (port->count) {
38110 + if (atomic_read(&port->count)) {
38111 #ifdef ISDN_DEBUG_MODEM_OPEN
38112 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38113 #endif
38114 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38115 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38116 return;
38117 isdn_tty_shutdown(info);
38118 - port->count = 0;
38119 + atomic_set(&port->count, 0);
38120 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38121 port->tty = NULL;
38122 wake_up_interruptible(&port->open_wait);
38123 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38124 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38125 modem_info *info = &dev->mdm.info[i];
38126
38127 - if (info->port.count == 0)
38128 + if (atomic_read(&info->port.count) == 0)
38129 continue;
38130 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38131 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38132 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38133 index e74df7c..03a03ba 100644
38134 --- a/drivers/isdn/icn/icn.c
38135 +++ b/drivers/isdn/icn/icn.c
38136 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38137 if (count > len)
38138 count = len;
38139 if (user) {
38140 - if (copy_from_user(msg, buf, count))
38141 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38142 return -EFAULT;
38143 } else
38144 memcpy(msg, buf, count);
38145 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38146 index 6a8405d..0bd1c7e 100644
38147 --- a/drivers/leds/leds-clevo-mail.c
38148 +++ b/drivers/leds/leds-clevo-mail.c
38149 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38150 * detected as working, but in reality it is not) as low as
38151 * possible.
38152 */
38153 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38154 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38155 {
38156 .callback = clevo_mail_led_dmi_callback,
38157 .ident = "Clevo D410J",
38158 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38159 index 64e204e..c6bf189 100644
38160 --- a/drivers/leds/leds-ss4200.c
38161 +++ b/drivers/leds/leds-ss4200.c
38162 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38163 * detected as working, but in reality it is not) as low as
38164 * possible.
38165 */
38166 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38167 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38168 {
38169 .callback = ss4200_led_dmi_callback,
38170 .ident = "Intel SS4200-E",
38171 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38172 index 0bf1e4e..b4bf44e 100644
38173 --- a/drivers/lguest/core.c
38174 +++ b/drivers/lguest/core.c
38175 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
38176 * The end address needs +1 because __get_vm_area allocates an
38177 * extra guard page, so we need space for that.
38178 */
38179 +
38180 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38181 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38182 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
38183 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38184 +#else
38185 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38186 VM_ALLOC, switcher_addr, switcher_addr
38187 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38188 +#endif
38189 +
38190 if (!switcher_vma) {
38191 err = -ENOMEM;
38192 printk("lguest: could not map switcher pages high\n");
38193 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
38194 * Now the Switcher is mapped at the right address, we can't fail!
38195 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38196 */
38197 - memcpy(switcher_vma->addr, start_switcher_text,
38198 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38199 end_switcher_text - start_switcher_text);
38200
38201 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38202 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38203 index 5b9ac32..2ef4f26 100644
38204 --- a/drivers/lguest/page_tables.c
38205 +++ b/drivers/lguest/page_tables.c
38206 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38207 /*:*/
38208
38209 #ifdef CONFIG_X86_PAE
38210 -static void release_pmd(pmd_t *spmd)
38211 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38212 {
38213 /* If the entry's not present, there's nothing to release. */
38214 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38215 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38216 index f0a3347..f6608b2 100644
38217 --- a/drivers/lguest/x86/core.c
38218 +++ b/drivers/lguest/x86/core.c
38219 @@ -59,7 +59,7 @@ static struct {
38220 /* Offset from where switcher.S was compiled to where we've copied it */
38221 static unsigned long switcher_offset(void)
38222 {
38223 - return switcher_addr - (unsigned long)start_switcher_text;
38224 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
38225 }
38226
38227 /* This cpu's struct lguest_pages (after the Switcher text page) */
38228 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38229 * These copies are pretty cheap, so we do them unconditionally: */
38230 /* Save the current Host top-level page directory.
38231 */
38232 +
38233 +#ifdef CONFIG_PAX_PER_CPU_PGD
38234 + pages->state.host_cr3 = read_cr3();
38235 +#else
38236 pages->state.host_cr3 = __pa(current->mm->pgd);
38237 +#endif
38238 +
38239 /*
38240 * Set up the Guest's page tables to see this CPU's pages (and no
38241 * other CPU's pages).
38242 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
38243 * compiled-in switcher code and the high-mapped copy we just made.
38244 */
38245 for (i = 0; i < IDT_ENTRIES; i++)
38246 - default_idt_entries[i] += switcher_offset();
38247 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38248
38249 /*
38250 * Set up the Switcher's per-cpu areas.
38251 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
38252 * it will be undisturbed when we switch. To change %cs and jump we
38253 * need this structure to feed to Intel's "lcall" instruction.
38254 */
38255 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38256 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38257 lguest_entry.segment = LGUEST_CS;
38258
38259 /*
38260 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38261 index 40634b0..4f5855e 100644
38262 --- a/drivers/lguest/x86/switcher_32.S
38263 +++ b/drivers/lguest/x86/switcher_32.S
38264 @@ -87,6 +87,7 @@
38265 #include <asm/page.h>
38266 #include <asm/segment.h>
38267 #include <asm/lguest.h>
38268 +#include <asm/processor-flags.h>
38269
38270 // We mark the start of the code to copy
38271 // It's placed in .text tho it's never run here
38272 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38273 // Changes type when we load it: damn Intel!
38274 // For after we switch over our page tables
38275 // That entry will be read-only: we'd crash.
38276 +
38277 +#ifdef CONFIG_PAX_KERNEXEC
38278 + mov %cr0, %edx
38279 + xor $X86_CR0_WP, %edx
38280 + mov %edx, %cr0
38281 +#endif
38282 +
38283 movl $(GDT_ENTRY_TSS*8), %edx
38284 ltr %dx
38285
38286 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38287 // Let's clear it again for our return.
38288 // The GDT descriptor of the Host
38289 // Points to the table after two "size" bytes
38290 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38291 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38292 // Clear "used" from type field (byte 5, bit 2)
38293 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38294 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38295 +
38296 +#ifdef CONFIG_PAX_KERNEXEC
38297 + mov %cr0, %eax
38298 + xor $X86_CR0_WP, %eax
38299 + mov %eax, %cr0
38300 +#endif
38301
38302 // Once our page table's switched, the Guest is live!
38303 // The Host fades as we run this final step.
38304 @@ -295,13 +309,12 @@ deliver_to_host:
38305 // I consulted gcc, and it gave
38306 // These instructions, which I gladly credit:
38307 leal (%edx,%ebx,8), %eax
38308 - movzwl (%eax),%edx
38309 - movl 4(%eax), %eax
38310 - xorw %ax, %ax
38311 - orl %eax, %edx
38312 + movl 4(%eax), %edx
38313 + movw (%eax), %dx
38314 // Now the address of the handler's in %edx
38315 // We call it now: its "iret" drops us home.
38316 - jmp *%edx
38317 + ljmp $__KERNEL_CS, $1f
38318 +1: jmp *%edx
38319
38320 // Every interrupt can come to us here
38321 // But we must truly tell each apart.
38322 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
38323 index 0003992..854bbce 100644
38324 --- a/drivers/md/bcache/closure.h
38325 +++ b/drivers/md/bcache/closure.h
38326 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
38327 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
38328 struct workqueue_struct *wq)
38329 {
38330 - BUG_ON(object_is_on_stack(cl));
38331 + BUG_ON(object_starts_on_stack(cl));
38332 closure_set_ip(cl);
38333 cl->fn = fn;
38334 cl->wq = wq;
38335 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38336 index 5a2c754..0fa55db 100644
38337 --- a/drivers/md/bitmap.c
38338 +++ b/drivers/md/bitmap.c
38339 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38340 chunk_kb ? "KB" : "B");
38341 if (bitmap->storage.file) {
38342 seq_printf(seq, ", file: ");
38343 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38344 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38345 }
38346
38347 seq_printf(seq, "\n");
38348 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38349 index aa04f02..2a1309e 100644
38350 --- a/drivers/md/dm-ioctl.c
38351 +++ b/drivers/md/dm-ioctl.c
38352 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38353 cmd == DM_LIST_VERSIONS_CMD)
38354 return 0;
38355
38356 - if ((cmd == DM_DEV_CREATE_CMD)) {
38357 + if (cmd == DM_DEV_CREATE_CMD) {
38358 if (!*param->name) {
38359 DMWARN("name not supplied when creating device");
38360 return -EINVAL;
38361 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38362 index 699b5be..eac0a15 100644
38363 --- a/drivers/md/dm-raid1.c
38364 +++ b/drivers/md/dm-raid1.c
38365 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38366
38367 struct mirror {
38368 struct mirror_set *ms;
38369 - atomic_t error_count;
38370 + atomic_unchecked_t error_count;
38371 unsigned long error_type;
38372 struct dm_dev *dev;
38373 sector_t offset;
38374 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38375 struct mirror *m;
38376
38377 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38378 - if (!atomic_read(&m->error_count))
38379 + if (!atomic_read_unchecked(&m->error_count))
38380 return m;
38381
38382 return NULL;
38383 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38384 * simple way to tell if a device has encountered
38385 * errors.
38386 */
38387 - atomic_inc(&m->error_count);
38388 + atomic_inc_unchecked(&m->error_count);
38389
38390 if (test_and_set_bit(error_type, &m->error_type))
38391 return;
38392 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38393 struct mirror *m = get_default_mirror(ms);
38394
38395 do {
38396 - if (likely(!atomic_read(&m->error_count)))
38397 + if (likely(!atomic_read_unchecked(&m->error_count)))
38398 return m;
38399
38400 if (m-- == ms->mirror)
38401 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38402 {
38403 struct mirror *default_mirror = get_default_mirror(m->ms);
38404
38405 - return !atomic_read(&default_mirror->error_count);
38406 + return !atomic_read_unchecked(&default_mirror->error_count);
38407 }
38408
38409 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38410 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38411 */
38412 if (likely(region_in_sync(ms, region, 1)))
38413 m = choose_mirror(ms, bio->bi_sector);
38414 - else if (m && atomic_read(&m->error_count))
38415 + else if (m && atomic_read_unchecked(&m->error_count))
38416 m = NULL;
38417
38418 if (likely(m))
38419 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38420 }
38421
38422 ms->mirror[mirror].ms = ms;
38423 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38424 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38425 ms->mirror[mirror].error_type = 0;
38426 ms->mirror[mirror].offset = offset;
38427
38428 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38429 */
38430 static char device_status_char(struct mirror *m)
38431 {
38432 - if (!atomic_read(&(m->error_count)))
38433 + if (!atomic_read_unchecked(&(m->error_count)))
38434 return 'A';
38435
38436 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38437 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38438 index d907ca6..cfb8384 100644
38439 --- a/drivers/md/dm-stripe.c
38440 +++ b/drivers/md/dm-stripe.c
38441 @@ -20,7 +20,7 @@ struct stripe {
38442 struct dm_dev *dev;
38443 sector_t physical_start;
38444
38445 - atomic_t error_count;
38446 + atomic_unchecked_t error_count;
38447 };
38448
38449 struct stripe_c {
38450 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38451 kfree(sc);
38452 return r;
38453 }
38454 - atomic_set(&(sc->stripe[i].error_count), 0);
38455 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38456 }
38457
38458 ti->private = sc;
38459 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38460 DMEMIT("%d ", sc->stripes);
38461 for (i = 0; i < sc->stripes; i++) {
38462 DMEMIT("%s ", sc->stripe[i].dev->name);
38463 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38464 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38465 'D' : 'A';
38466 }
38467 buffer[i] = '\0';
38468 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38469 */
38470 for (i = 0; i < sc->stripes; i++)
38471 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38472 - atomic_inc(&(sc->stripe[i].error_count));
38473 - if (atomic_read(&(sc->stripe[i].error_count)) <
38474 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38475 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38476 DM_IO_ERROR_THRESHOLD)
38477 schedule_work(&sc->trigger_event);
38478 }
38479 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38480 index 1ff252a..ee384c1 100644
38481 --- a/drivers/md/dm-table.c
38482 +++ b/drivers/md/dm-table.c
38483 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38484 if (!dev_size)
38485 return 0;
38486
38487 - if ((start >= dev_size) || (start + len > dev_size)) {
38488 + if ((start >= dev_size) || (len > dev_size - start)) {
38489 DMWARN("%s: %s too small for target: "
38490 "start=%llu, len=%llu, dev_size=%llu",
38491 dm_device_name(ti->table->md), bdevname(bdev, b),
38492 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38493 index 60bce43..9b997d0 100644
38494 --- a/drivers/md/dm-thin-metadata.c
38495 +++ b/drivers/md/dm-thin-metadata.c
38496 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38497 {
38498 pmd->info.tm = pmd->tm;
38499 pmd->info.levels = 2;
38500 - pmd->info.value_type.context = pmd->data_sm;
38501 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38502 pmd->info.value_type.size = sizeof(__le64);
38503 pmd->info.value_type.inc = data_block_inc;
38504 pmd->info.value_type.dec = data_block_dec;
38505 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38506
38507 pmd->bl_info.tm = pmd->tm;
38508 pmd->bl_info.levels = 1;
38509 - pmd->bl_info.value_type.context = pmd->data_sm;
38510 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38511 pmd->bl_info.value_type.size = sizeof(__le64);
38512 pmd->bl_info.value_type.inc = data_block_inc;
38513 pmd->bl_info.value_type.dec = data_block_dec;
38514 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38515 index d5370a9..8761bbc 100644
38516 --- a/drivers/md/dm.c
38517 +++ b/drivers/md/dm.c
38518 @@ -169,9 +169,9 @@ struct mapped_device {
38519 /*
38520 * Event handling.
38521 */
38522 - atomic_t event_nr;
38523 + atomic_unchecked_t event_nr;
38524 wait_queue_head_t eventq;
38525 - atomic_t uevent_seq;
38526 + atomic_unchecked_t uevent_seq;
38527 struct list_head uevent_list;
38528 spinlock_t uevent_lock; /* Protect access to uevent_list */
38529
38530 @@ -1877,8 +1877,8 @@ static struct mapped_device *alloc_dev(int minor)
38531 rwlock_init(&md->map_lock);
38532 atomic_set(&md->holders, 1);
38533 atomic_set(&md->open_count, 0);
38534 - atomic_set(&md->event_nr, 0);
38535 - atomic_set(&md->uevent_seq, 0);
38536 + atomic_set_unchecked(&md->event_nr, 0);
38537 + atomic_set_unchecked(&md->uevent_seq, 0);
38538 INIT_LIST_HEAD(&md->uevent_list);
38539 spin_lock_init(&md->uevent_lock);
38540
38541 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38542
38543 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38544
38545 - atomic_inc(&md->event_nr);
38546 + atomic_inc_unchecked(&md->event_nr);
38547 wake_up(&md->eventq);
38548 }
38549
38550 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38551
38552 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38553 {
38554 - return atomic_add_return(1, &md->uevent_seq);
38555 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38556 }
38557
38558 uint32_t dm_get_event_nr(struct mapped_device *md)
38559 {
38560 - return atomic_read(&md->event_nr);
38561 + return atomic_read_unchecked(&md->event_nr);
38562 }
38563
38564 int dm_wait_event(struct mapped_device *md, int event_nr)
38565 {
38566 return wait_event_interruptible(md->eventq,
38567 - (event_nr != atomic_read(&md->event_nr)));
38568 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38569 }
38570
38571 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38572 diff --git a/drivers/md/md.c b/drivers/md/md.c
38573 index 9b82377..6b6922d 100644
38574 --- a/drivers/md/md.c
38575 +++ b/drivers/md/md.c
38576 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38577 * start build, activate spare
38578 */
38579 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38580 -static atomic_t md_event_count;
38581 +static atomic_unchecked_t md_event_count;
38582 void md_new_event(struct mddev *mddev)
38583 {
38584 - atomic_inc(&md_event_count);
38585 + atomic_inc_unchecked(&md_event_count);
38586 wake_up(&md_event_waiters);
38587 }
38588 EXPORT_SYMBOL_GPL(md_new_event);
38589 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38590 */
38591 static void md_new_event_inintr(struct mddev *mddev)
38592 {
38593 - atomic_inc(&md_event_count);
38594 + atomic_inc_unchecked(&md_event_count);
38595 wake_up(&md_event_waiters);
38596 }
38597
38598 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38599 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38600 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38601 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38602 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38603 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38604
38605 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38606 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38607 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38608 else
38609 sb->resync_offset = cpu_to_le64(0);
38610
38611 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38612 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38613
38614 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38615 sb->size = cpu_to_le64(mddev->dev_sectors);
38616 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38617 static ssize_t
38618 errors_show(struct md_rdev *rdev, char *page)
38619 {
38620 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38621 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38622 }
38623
38624 static ssize_t
38625 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38626 char *e;
38627 unsigned long n = simple_strtoul(buf, &e, 10);
38628 if (*buf && (*e == 0 || *e == '\n')) {
38629 - atomic_set(&rdev->corrected_errors, n);
38630 + atomic_set_unchecked(&rdev->corrected_errors, n);
38631 return len;
38632 }
38633 return -EINVAL;
38634 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
38635 rdev->sb_loaded = 0;
38636 rdev->bb_page = NULL;
38637 atomic_set(&rdev->nr_pending, 0);
38638 - atomic_set(&rdev->read_errors, 0);
38639 - atomic_set(&rdev->corrected_errors, 0);
38640 + atomic_set_unchecked(&rdev->read_errors, 0);
38641 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38642
38643 INIT_LIST_HEAD(&rdev->same_set);
38644 init_waitqueue_head(&rdev->blocked_wait);
38645 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38646
38647 spin_unlock(&pers_lock);
38648 seq_printf(seq, "\n");
38649 - seq->poll_event = atomic_read(&md_event_count);
38650 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38651 return 0;
38652 }
38653 if (v == (void*)2) {
38654 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38655 return error;
38656
38657 seq = file->private_data;
38658 - seq->poll_event = atomic_read(&md_event_count);
38659 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38660 return error;
38661 }
38662
38663 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38664 /* always allow read */
38665 mask = POLLIN | POLLRDNORM;
38666
38667 - if (seq->poll_event != atomic_read(&md_event_count))
38668 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38669 mask |= POLLERR | POLLPRI;
38670 return mask;
38671 }
38672 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38673 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38674 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38675 (int)part_stat_read(&disk->part0, sectors[1]) -
38676 - atomic_read(&disk->sync_io);
38677 + atomic_read_unchecked(&disk->sync_io);
38678 /* sync IO will cause sync_io to increase before the disk_stats
38679 * as sync_io is counted when a request starts, and
38680 * disk_stats is counted when it completes.
38681 diff --git a/drivers/md/md.h b/drivers/md/md.h
38682 index 653f992b6..6af6c40 100644
38683 --- a/drivers/md/md.h
38684 +++ b/drivers/md/md.h
38685 @@ -94,13 +94,13 @@ struct md_rdev {
38686 * only maintained for arrays that
38687 * support hot removal
38688 */
38689 - atomic_t read_errors; /* number of consecutive read errors that
38690 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38691 * we have tried to ignore.
38692 */
38693 struct timespec last_read_error; /* monotonic time since our
38694 * last read error
38695 */
38696 - atomic_t corrected_errors; /* number of corrected read errors,
38697 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38698 * for reporting to userspace and storing
38699 * in superblock.
38700 */
38701 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38702
38703 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38704 {
38705 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38706 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38707 }
38708
38709 struct md_personality
38710 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38711 index 3e6d115..ffecdeb 100644
38712 --- a/drivers/md/persistent-data/dm-space-map.h
38713 +++ b/drivers/md/persistent-data/dm-space-map.h
38714 @@ -71,6 +71,7 @@ struct dm_space_map {
38715 dm_sm_threshold_fn fn,
38716 void *context);
38717 };
38718 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38719
38720 /*----------------------------------------------------------------*/
38721
38722 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38723 index 6e17f81..140f717 100644
38724 --- a/drivers/md/raid1.c
38725 +++ b/drivers/md/raid1.c
38726 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38727 if (r1_sync_page_io(rdev, sect, s,
38728 bio->bi_io_vec[idx].bv_page,
38729 READ) != 0)
38730 - atomic_add(s, &rdev->corrected_errors);
38731 + atomic_add_unchecked(s, &rdev->corrected_errors);
38732 }
38733 sectors -= s;
38734 sect += s;
38735 @@ -2042,7 +2042,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38736 test_bit(In_sync, &rdev->flags)) {
38737 if (r1_sync_page_io(rdev, sect, s,
38738 conf->tmppage, READ)) {
38739 - atomic_add(s, &rdev->corrected_errors);
38740 + atomic_add_unchecked(s, &rdev->corrected_errors);
38741 printk(KERN_INFO
38742 "md/raid1:%s: read error corrected "
38743 "(%d sectors at %llu on %s)\n",
38744 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38745 index 6ddae25..514caa9 100644
38746 --- a/drivers/md/raid10.c
38747 +++ b/drivers/md/raid10.c
38748 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
38749 /* The write handler will notice the lack of
38750 * R10BIO_Uptodate and record any errors etc
38751 */
38752 - atomic_add(r10_bio->sectors,
38753 + atomic_add_unchecked(r10_bio->sectors,
38754 &conf->mirrors[d].rdev->corrected_errors);
38755
38756 /* for reconstruct, we always reschedule after a read.
38757 @@ -2286,7 +2286,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38758 {
38759 struct timespec cur_time_mon;
38760 unsigned long hours_since_last;
38761 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38762 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38763
38764 ktime_get_ts(&cur_time_mon);
38765
38766 @@ -2308,9 +2308,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38767 * overflowing the shift of read_errors by hours_since_last.
38768 */
38769 if (hours_since_last >= 8 * sizeof(read_errors))
38770 - atomic_set(&rdev->read_errors, 0);
38771 + atomic_set_unchecked(&rdev->read_errors, 0);
38772 else
38773 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38774 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38775 }
38776
38777 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38778 @@ -2364,8 +2364,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38779 return;
38780
38781 check_decay_read_errors(mddev, rdev);
38782 - atomic_inc(&rdev->read_errors);
38783 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38784 + atomic_inc_unchecked(&rdev->read_errors);
38785 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38786 char b[BDEVNAME_SIZE];
38787 bdevname(rdev->bdev, b);
38788
38789 @@ -2373,7 +2373,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38790 "md/raid10:%s: %s: Raid device exceeded "
38791 "read_error threshold [cur %d:max %d]\n",
38792 mdname(mddev), b,
38793 - atomic_read(&rdev->read_errors), max_read_errors);
38794 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38795 printk(KERN_NOTICE
38796 "md/raid10:%s: %s: Failing raid device\n",
38797 mdname(mddev), b);
38798 @@ -2528,7 +2528,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38799 sect +
38800 choose_data_offset(r10_bio, rdev)),
38801 bdevname(rdev->bdev, b));
38802 - atomic_add(s, &rdev->corrected_errors);
38803 + atomic_add_unchecked(s, &rdev->corrected_errors);
38804 }
38805
38806 rdev_dec_pending(rdev, mddev);
38807 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38808 index 05e4a10..48fbe37 100644
38809 --- a/drivers/md/raid5.c
38810 +++ b/drivers/md/raid5.c
38811 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38812 mdname(conf->mddev), STRIPE_SECTORS,
38813 (unsigned long long)s,
38814 bdevname(rdev->bdev, b));
38815 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38816 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38817 clear_bit(R5_ReadError, &sh->dev[i].flags);
38818 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38819 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38820 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38821
38822 - if (atomic_read(&rdev->read_errors))
38823 - atomic_set(&rdev->read_errors, 0);
38824 + if (atomic_read_unchecked(&rdev->read_errors))
38825 + atomic_set_unchecked(&rdev->read_errors, 0);
38826 } else {
38827 const char *bdn = bdevname(rdev->bdev, b);
38828 int retry = 0;
38829 int set_bad = 0;
38830
38831 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38832 - atomic_inc(&rdev->read_errors);
38833 + atomic_inc_unchecked(&rdev->read_errors);
38834 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38835 printk_ratelimited(
38836 KERN_WARNING
38837 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38838 mdname(conf->mddev),
38839 (unsigned long long)s,
38840 bdn);
38841 - } else if (atomic_read(&rdev->read_errors)
38842 + } else if (atomic_read_unchecked(&rdev->read_errors)
38843 > conf->max_nr_stripes)
38844 printk(KERN_WARNING
38845 "md/raid:%s: Too many read errors, failing device %s.\n",
38846 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38847 index 401ef64..836e563 100644
38848 --- a/drivers/media/dvb-core/dvbdev.c
38849 +++ b/drivers/media/dvb-core/dvbdev.c
38850 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38851 const struct dvb_device *template, void *priv, int type)
38852 {
38853 struct dvb_device *dvbdev;
38854 - struct file_operations *dvbdevfops;
38855 + file_operations_no_const *dvbdevfops;
38856 struct device *clsdev;
38857 int minor;
38858 int id;
38859 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38860 index 9b6c3bb..baeb5c7 100644
38861 --- a/drivers/media/dvb-frontends/dib3000.h
38862 +++ b/drivers/media/dvb-frontends/dib3000.h
38863 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38864 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38865 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38866 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38867 -};
38868 +} __no_const;
38869
38870 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38871 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38872 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38873 index c7a9be1..683f6f8 100644
38874 --- a/drivers/media/pci/cx88/cx88-video.c
38875 +++ b/drivers/media/pci/cx88/cx88-video.c
38876 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38877
38878 /* ------------------------------------------------------------------ */
38879
38880 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38881 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38882 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38883 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38884 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38885 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38886
38887 module_param_array(video_nr, int, NULL, 0444);
38888 module_param_array(vbi_nr, int, NULL, 0444);
38889 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38890 index d338b19..aae4f9e 100644
38891 --- a/drivers/media/platform/omap/omap_vout.c
38892 +++ b/drivers/media/platform/omap/omap_vout.c
38893 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38894 OMAP_VIDEO2,
38895 };
38896
38897 -static struct videobuf_queue_ops video_vbq_ops;
38898 /* Variables configurable through module params*/
38899 static u32 video1_numbuffers = 3;
38900 static u32 video2_numbuffers = 3;
38901 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
38902 {
38903 struct videobuf_queue *q;
38904 struct omap_vout_device *vout = NULL;
38905 + static struct videobuf_queue_ops video_vbq_ops = {
38906 + .buf_setup = omap_vout_buffer_setup,
38907 + .buf_prepare = omap_vout_buffer_prepare,
38908 + .buf_release = omap_vout_buffer_release,
38909 + .buf_queue = omap_vout_buffer_queue,
38910 + };
38911
38912 vout = video_drvdata(file);
38913 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38914 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
38915 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38916
38917 q = &vout->vbq;
38918 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38919 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38920 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38921 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38922 spin_lock_init(&vout->vbq_lock);
38923
38924 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38925 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38926 index 04e6490..2df65bf 100644
38927 --- a/drivers/media/platform/s5p-tv/mixer.h
38928 +++ b/drivers/media/platform/s5p-tv/mixer.h
38929 @@ -156,7 +156,7 @@ struct mxr_layer {
38930 /** layer index (unique identifier) */
38931 int idx;
38932 /** callbacks for layer methods */
38933 - struct mxr_layer_ops ops;
38934 + struct mxr_layer_ops *ops;
38935 /** format array */
38936 const struct mxr_format **fmt_array;
38937 /** size of format array */
38938 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38939 index b93a21f..2535195 100644
38940 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38941 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38942 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38943 {
38944 struct mxr_layer *layer;
38945 int ret;
38946 - struct mxr_layer_ops ops = {
38947 + static struct mxr_layer_ops ops = {
38948 .release = mxr_graph_layer_release,
38949 .buffer_set = mxr_graph_buffer_set,
38950 .stream_set = mxr_graph_stream_set,
38951 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38952 index b713403..53cb5ad 100644
38953 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38954 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38955 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38956 layer->update_buf = next;
38957 }
38958
38959 - layer->ops.buffer_set(layer, layer->update_buf);
38960 + layer->ops->buffer_set(layer, layer->update_buf);
38961
38962 if (done && done != layer->shadow_buf)
38963 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38964 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38965 index ef0efdf..8c78eb6 100644
38966 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38967 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38968 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38969 layer->geo.src.height = layer->geo.src.full_height;
38970
38971 mxr_geometry_dump(mdev, &layer->geo);
38972 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38973 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38974 mxr_geometry_dump(mdev, &layer->geo);
38975 }
38976
38977 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38978 layer->geo.dst.full_width = mbus_fmt.width;
38979 layer->geo.dst.full_height = mbus_fmt.height;
38980 layer->geo.dst.field = mbus_fmt.field;
38981 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38982 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38983
38984 mxr_geometry_dump(mdev, &layer->geo);
38985 }
38986 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38987 /* set source size to highest accepted value */
38988 geo->src.full_width = max(geo->dst.full_width, pix->width);
38989 geo->src.full_height = max(geo->dst.full_height, pix->height);
38990 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38991 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38992 mxr_geometry_dump(mdev, &layer->geo);
38993 /* set cropping to total visible screen */
38994 geo->src.width = pix->width;
38995 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38996 geo->src.x_offset = 0;
38997 geo->src.y_offset = 0;
38998 /* assure consistency of geometry */
38999 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39000 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39001 mxr_geometry_dump(mdev, &layer->geo);
39002 /* set full size to lowest possible value */
39003 geo->src.full_width = 0;
39004 geo->src.full_height = 0;
39005 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39006 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39007 mxr_geometry_dump(mdev, &layer->geo);
39008
39009 /* returning results */
39010 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
39011 target->width = s->r.width;
39012 target->height = s->r.height;
39013
39014 - layer->ops.fix_geometry(layer, stage, s->flags);
39015 + layer->ops->fix_geometry(layer, stage, s->flags);
39016
39017 /* retrieve update selection rectangle */
39018 res.left = target->x_offset;
39019 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
39020 mxr_output_get(mdev);
39021
39022 mxr_layer_update_output(layer);
39023 - layer->ops.format_set(layer);
39024 + layer->ops->format_set(layer);
39025 /* enabling layer in hardware */
39026 spin_lock_irqsave(&layer->enq_slock, flags);
39027 layer->state = MXR_LAYER_STREAMING;
39028 spin_unlock_irqrestore(&layer->enq_slock, flags);
39029
39030 - layer->ops.stream_set(layer, MXR_ENABLE);
39031 + layer->ops->stream_set(layer, MXR_ENABLE);
39032 mxr_streamer_get(mdev);
39033
39034 return 0;
39035 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
39036 spin_unlock_irqrestore(&layer->enq_slock, flags);
39037
39038 /* disabling layer in hardware */
39039 - layer->ops.stream_set(layer, MXR_DISABLE);
39040 + layer->ops->stream_set(layer, MXR_DISABLE);
39041 /* remove one streamer */
39042 mxr_streamer_put(mdev);
39043 /* allow changes in output configuration */
39044 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39045
39046 void mxr_layer_release(struct mxr_layer *layer)
39047 {
39048 - if (layer->ops.release)
39049 - layer->ops.release(layer);
39050 + if (layer->ops->release)
39051 + layer->ops->release(layer);
39052 }
39053
39054 void mxr_base_layer_release(struct mxr_layer *layer)
39055 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39056
39057 layer->mdev = mdev;
39058 layer->idx = idx;
39059 - layer->ops = *ops;
39060 + layer->ops = ops;
39061
39062 spin_lock_init(&layer->enq_slock);
39063 INIT_LIST_HEAD(&layer->enq_list);
39064 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39065 index 3d13a63..da31bf1 100644
39066 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39067 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39068 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39069 {
39070 struct mxr_layer *layer;
39071 int ret;
39072 - struct mxr_layer_ops ops = {
39073 + static struct mxr_layer_ops ops = {
39074 .release = mxr_vp_layer_release,
39075 .buffer_set = mxr_vp_buffer_set,
39076 .stream_set = mxr_vp_stream_set,
39077 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39078 index 545c04c..a14bded 100644
39079 --- a/drivers/media/radio/radio-cadet.c
39080 +++ b/drivers/media/radio/radio-cadet.c
39081 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39082 unsigned char readbuf[RDS_BUFFER];
39083 int i = 0;
39084
39085 + if (count > RDS_BUFFER)
39086 + return -EFAULT;
39087 mutex_lock(&dev->lock);
39088 if (dev->rdsstat == 0)
39089 cadet_start_rds(dev);
39090 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39091 while (i < count && dev->rdsin != dev->rdsout)
39092 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39093
39094 - if (i && copy_to_user(data, readbuf, i))
39095 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39096 i = -EFAULT;
39097 unlock:
39098 mutex_unlock(&dev->lock);
39099 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39100 index 3940bb0..fb3952a 100644
39101 --- a/drivers/media/usb/dvb-usb/cxusb.c
39102 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39103 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39104
39105 struct dib0700_adapter_state {
39106 int (*set_param_save) (struct dvb_frontend *);
39107 -};
39108 +} __no_const;
39109
39110 static int dib7070_set_param_override(struct dvb_frontend *fe)
39111 {
39112 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39113 index 6e237b6..dc25556 100644
39114 --- a/drivers/media/usb/dvb-usb/dw2102.c
39115 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39116 @@ -118,7 +118,7 @@ struct su3000_state {
39117
39118 struct s6x0_state {
39119 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39120 -};
39121 +} __no_const;
39122
39123 /* debug */
39124 static int dvb_usb_dw2102_debug;
39125 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39126 index f129551..ecf6514 100644
39127 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39128 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39129 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
39130 __u32 reserved;
39131 };
39132
39133 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39134 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39135 enum v4l2_memory memory)
39136 {
39137 void __user *up_pln;
39138 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39139 return 0;
39140 }
39141
39142 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39143 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39144 enum v4l2_memory memory)
39145 {
39146 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
39147 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
39148 put_user(kp->start_block, &up->start_block) ||
39149 put_user(kp->blocks, &up->blocks) ||
39150 put_user(tmp, &up->edid) ||
39151 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
39152 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
39153 return -EFAULT;
39154 return 0;
39155 }
39156 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39157 index 7658586..1079260 100644
39158 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39159 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39160 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
39161 struct file *file, void *fh, void *p);
39162 } u;
39163 void (*debug)(const void *arg, bool write_only);
39164 -};
39165 +} __do_const;
39166 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39167
39168 /* This control needs a priority check */
39169 #define INFO_FL_PRIO (1 << 0)
39170 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
39171 struct video_device *vfd = video_devdata(file);
39172 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39173 bool write_only = false;
39174 - struct v4l2_ioctl_info default_info;
39175 + v4l2_ioctl_info_no_const default_info;
39176 const struct v4l2_ioctl_info *info;
39177 void *fh = file->private_data;
39178 struct v4l2_fh *vfh = NULL;
39179 @@ -2251,7 +2252,7 @@ done:
39180 }
39181
39182 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39183 - void * __user *user_ptr, void ***kernel_ptr)
39184 + void __user **user_ptr, void ***kernel_ptr)
39185 {
39186 int ret = 0;
39187
39188 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39189 ret = -EINVAL;
39190 break;
39191 }
39192 - *user_ptr = (void __user *)buf->m.planes;
39193 + *user_ptr = (void __force_user *)buf->m.planes;
39194 *kernel_ptr = (void *)&buf->m.planes;
39195 *array_size = sizeof(struct v4l2_plane) * buf->length;
39196 ret = 1;
39197 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39198 ret = -EINVAL;
39199 break;
39200 }
39201 - *user_ptr = (void __user *)ctrls->controls;
39202 + *user_ptr = (void __force_user *)ctrls->controls;
39203 *kernel_ptr = (void *)&ctrls->controls;
39204 *array_size = sizeof(struct v4l2_ext_control)
39205 * ctrls->count;
39206 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39207 index 767ff4d..c69d259 100644
39208 --- a/drivers/message/fusion/mptbase.c
39209 +++ b/drivers/message/fusion/mptbase.c
39210 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39211 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39212 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39213
39214 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39215 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39216 +#else
39217 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39218 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39219 +#endif
39220 +
39221 /*
39222 * Rounding UP to nearest 4-kB boundary here...
39223 */
39224 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39225 ioc->facts.GlobalCredits);
39226
39227 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39228 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39229 + NULL, NULL);
39230 +#else
39231 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39232 +#endif
39233 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39234 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39235 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39236 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39237 index dd239bd..689c4f7 100644
39238 --- a/drivers/message/fusion/mptsas.c
39239 +++ b/drivers/message/fusion/mptsas.c
39240 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39241 return 0;
39242 }
39243
39244 +static inline void
39245 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39246 +{
39247 + if (phy_info->port_details) {
39248 + phy_info->port_details->rphy = rphy;
39249 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39250 + ioc->name, rphy));
39251 + }
39252 +
39253 + if (rphy) {
39254 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39255 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39256 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39257 + ioc->name, rphy, rphy->dev.release));
39258 + }
39259 +}
39260 +
39261 /* no mutex */
39262 static void
39263 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39264 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39265 return NULL;
39266 }
39267
39268 -static inline void
39269 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39270 -{
39271 - if (phy_info->port_details) {
39272 - phy_info->port_details->rphy = rphy;
39273 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39274 - ioc->name, rphy));
39275 - }
39276 -
39277 - if (rphy) {
39278 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39279 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39280 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39281 - ioc->name, rphy, rphy->dev.release));
39282 - }
39283 -}
39284 -
39285 static inline struct sas_port *
39286 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39287 {
39288 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39289 index 727819c..ad74694 100644
39290 --- a/drivers/message/fusion/mptscsih.c
39291 +++ b/drivers/message/fusion/mptscsih.c
39292 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39293
39294 h = shost_priv(SChost);
39295
39296 - if (h) {
39297 - if (h->info_kbuf == NULL)
39298 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39299 - return h->info_kbuf;
39300 - h->info_kbuf[0] = '\0';
39301 + if (!h)
39302 + return NULL;
39303
39304 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39305 - h->info_kbuf[size-1] = '\0';
39306 - }
39307 + if (h->info_kbuf == NULL)
39308 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39309 + return h->info_kbuf;
39310 + h->info_kbuf[0] = '\0';
39311 +
39312 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39313 + h->info_kbuf[size-1] = '\0';
39314
39315 return h->info_kbuf;
39316 }
39317 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39318 index b7d87cd..9890039 100644
39319 --- a/drivers/message/i2o/i2o_proc.c
39320 +++ b/drivers/message/i2o/i2o_proc.c
39321 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39322 "Array Controller Device"
39323 };
39324
39325 -static char *chtostr(char *tmp, u8 *chars, int n)
39326 -{
39327 - tmp[0] = 0;
39328 - return strncat(tmp, (char *)chars, n);
39329 -}
39330 -
39331 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39332 char *group)
39333 {
39334 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39335 } *result;
39336
39337 i2o_exec_execute_ddm_table ddm_table;
39338 - char tmp[28 + 1];
39339
39340 result = kmalloc(sizeof(*result), GFP_KERNEL);
39341 if (!result)
39342 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39343
39344 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39345 seq_printf(seq, "%-#8x", ddm_table.module_id);
39346 - seq_printf(seq, "%-29s",
39347 - chtostr(tmp, ddm_table.module_name_version, 28));
39348 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39349 seq_printf(seq, "%9d ", ddm_table.data_size);
39350 seq_printf(seq, "%8d", ddm_table.code_size);
39351
39352 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39353
39354 i2o_driver_result_table *result;
39355 i2o_driver_store_table *dst;
39356 - char tmp[28 + 1];
39357
39358 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39359 if (result == NULL)
39360 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39361
39362 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39363 seq_printf(seq, "%-#8x", dst->module_id);
39364 - seq_printf(seq, "%-29s",
39365 - chtostr(tmp, dst->module_name_version, 28));
39366 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39367 + seq_printf(seq, "%-.28s", dst->module_name_version);
39368 + seq_printf(seq, "%-.8s", dst->date);
39369 seq_printf(seq, "%8d ", dst->module_size);
39370 seq_printf(seq, "%8d ", dst->mpb_size);
39371 seq_printf(seq, "0x%04x", dst->module_flags);
39372 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39373 // == (allow) 512d bytes (max)
39374 static u16 *work16 = (u16 *) work32;
39375 int token;
39376 - char tmp[16 + 1];
39377
39378 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39379
39380 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39381 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39382 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39383 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39384 - seq_printf(seq, "Vendor info : %s\n",
39385 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39386 - seq_printf(seq, "Product info : %s\n",
39387 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39388 - seq_printf(seq, "Description : %s\n",
39389 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39390 - seq_printf(seq, "Product rev. : %s\n",
39391 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39392 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39393 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39394 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39395 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39396
39397 seq_printf(seq, "Serial number : ");
39398 print_serial_number(seq, (u8 *) (work32 + 16),
39399 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39400 u8 pad[256]; // allow up to 256 byte (max) serial number
39401 } result;
39402
39403 - char tmp[24 + 1];
39404 -
39405 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39406
39407 if (token < 0) {
39408 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39409 }
39410
39411 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39412 - seq_printf(seq, "Module name : %s\n",
39413 - chtostr(tmp, result.module_name, 24));
39414 - seq_printf(seq, "Module revision : %s\n",
39415 - chtostr(tmp, result.module_rev, 8));
39416 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39417 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39418
39419 seq_printf(seq, "Serial number : ");
39420 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39421 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39422 u8 instance_number[4];
39423 } result;
39424
39425 - char tmp[64 + 1];
39426 -
39427 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39428
39429 if (token < 0) {
39430 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39431 return 0;
39432 }
39433
39434 - seq_printf(seq, "Device name : %s\n",
39435 - chtostr(tmp, result.device_name, 64));
39436 - seq_printf(seq, "Service name : %s\n",
39437 - chtostr(tmp, result.service_name, 64));
39438 - seq_printf(seq, "Physical name : %s\n",
39439 - chtostr(tmp, result.physical_location, 64));
39440 - seq_printf(seq, "Instance number : %s\n",
39441 - chtostr(tmp, result.instance_number, 4));
39442 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39443 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39444 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39445 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39446
39447 return 0;
39448 }
39449 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39450 index a8c08f3..155fe3d 100644
39451 --- a/drivers/message/i2o/iop.c
39452 +++ b/drivers/message/i2o/iop.c
39453 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39454
39455 spin_lock_irqsave(&c->context_list_lock, flags);
39456
39457 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39458 - atomic_inc(&c->context_list_counter);
39459 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39460 + atomic_inc_unchecked(&c->context_list_counter);
39461
39462 - entry->context = atomic_read(&c->context_list_counter);
39463 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39464
39465 list_add(&entry->list, &c->context_list);
39466
39467 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39468
39469 #if BITS_PER_LONG == 64
39470 spin_lock_init(&c->context_list_lock);
39471 - atomic_set(&c->context_list_counter, 0);
39472 + atomic_set_unchecked(&c->context_list_counter, 0);
39473 INIT_LIST_HEAD(&c->context_list);
39474 #endif
39475
39476 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39477 index 45ece11..8efa218 100644
39478 --- a/drivers/mfd/janz-cmodio.c
39479 +++ b/drivers/mfd/janz-cmodio.c
39480 @@ -13,6 +13,7 @@
39481
39482 #include <linux/kernel.h>
39483 #include <linux/module.h>
39484 +#include <linux/slab.h>
39485 #include <linux/init.h>
39486 #include <linux/pci.h>
39487 #include <linux/interrupt.h>
39488 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39489 index a5f9888..1c0ed56 100644
39490 --- a/drivers/mfd/twl4030-irq.c
39491 +++ b/drivers/mfd/twl4030-irq.c
39492 @@ -35,6 +35,7 @@
39493 #include <linux/of.h>
39494 #include <linux/irqdomain.h>
39495 #include <linux/i2c/twl.h>
39496 +#include <asm/pgtable.h>
39497
39498 #include "twl-core.h"
39499
39500 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39501 * Install an irq handler for each of the SIH modules;
39502 * clone dummy irq_chip since PIH can't *do* anything
39503 */
39504 - twl4030_irq_chip = dummy_irq_chip;
39505 - twl4030_irq_chip.name = "twl4030";
39506 + pax_open_kernel();
39507 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39508 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39509
39510 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39511 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39512 + pax_close_kernel();
39513
39514 for (i = irq_base; i < irq_end; i++) {
39515 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39516 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39517 index 277a8db..0e0b754 100644
39518 --- a/drivers/mfd/twl6030-irq.c
39519 +++ b/drivers/mfd/twl6030-irq.c
39520 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39521 * install an irq handler for each of the modules;
39522 * clone dummy irq_chip since PIH can't *do* anything
39523 */
39524 - twl6030_irq_chip = dummy_irq_chip;
39525 - twl6030_irq_chip.name = "twl6030";
39526 - twl6030_irq_chip.irq_set_type = NULL;
39527 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39528 + pax_open_kernel();
39529 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39530 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39531 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39532 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39533 + pax_close_kernel();
39534
39535 for (i = irq_base; i < irq_end; i++) {
39536 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39537 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39538 index f32550a..e3e52a2 100644
39539 --- a/drivers/misc/c2port/core.c
39540 +++ b/drivers/misc/c2port/core.c
39541 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39542 mutex_init(&c2dev->mutex);
39543
39544 /* Create binary file */
39545 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39546 + pax_open_kernel();
39547 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39548 + pax_close_kernel();
39549 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39550 if (unlikely(ret))
39551 goto error_device_create_bin_file;
39552 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39553 index 36f5d52..32311c3 100644
39554 --- a/drivers/misc/kgdbts.c
39555 +++ b/drivers/misc/kgdbts.c
39556 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39557 char before[BREAK_INSTR_SIZE];
39558 char after[BREAK_INSTR_SIZE];
39559
39560 - probe_kernel_read(before, (char *)kgdbts_break_test,
39561 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39562 BREAK_INSTR_SIZE);
39563 init_simple_test();
39564 ts.tst = plant_and_detach_test;
39565 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39566 /* Activate test with initial breakpoint */
39567 if (!is_early)
39568 kgdb_breakpoint();
39569 - probe_kernel_read(after, (char *)kgdbts_break_test,
39570 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39571 BREAK_INSTR_SIZE);
39572 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39573 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39574 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39575 index 4cd4a3d..b48cbc7 100644
39576 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39577 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39578 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39579 * the lid is closed. This leads to interrupts as soon as a little move
39580 * is done.
39581 */
39582 - atomic_inc(&lis3->count);
39583 + atomic_inc_unchecked(&lis3->count);
39584
39585 wake_up_interruptible(&lis3->misc_wait);
39586 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39587 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39588 if (lis3->pm_dev)
39589 pm_runtime_get_sync(lis3->pm_dev);
39590
39591 - atomic_set(&lis3->count, 0);
39592 + atomic_set_unchecked(&lis3->count, 0);
39593 return 0;
39594 }
39595
39596 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39597 add_wait_queue(&lis3->misc_wait, &wait);
39598 while (true) {
39599 set_current_state(TASK_INTERRUPTIBLE);
39600 - data = atomic_xchg(&lis3->count, 0);
39601 + data = atomic_xchg_unchecked(&lis3->count, 0);
39602 if (data)
39603 break;
39604
39605 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39606 struct lis3lv02d, miscdev);
39607
39608 poll_wait(file, &lis3->misc_wait, wait);
39609 - if (atomic_read(&lis3->count))
39610 + if (atomic_read_unchecked(&lis3->count))
39611 return POLLIN | POLLRDNORM;
39612 return 0;
39613 }
39614 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39615 index c439c82..1f20f57 100644
39616 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39617 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39618 @@ -297,7 +297,7 @@ struct lis3lv02d {
39619 struct input_polled_dev *idev; /* input device */
39620 struct platform_device *pdev; /* platform device */
39621 struct regulator_bulk_data regulators[2];
39622 - atomic_t count; /* interrupt count after last read */
39623 + atomic_unchecked_t count; /* interrupt count after last read */
39624 union axis_conversion ac; /* hw -> logical axis */
39625 int mapped_btns[3];
39626
39627 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39628 index 2f30bad..c4c13d0 100644
39629 --- a/drivers/misc/sgi-gru/gruhandles.c
39630 +++ b/drivers/misc/sgi-gru/gruhandles.c
39631 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39632 unsigned long nsec;
39633
39634 nsec = CLKS2NSEC(clks);
39635 - atomic_long_inc(&mcs_op_statistics[op].count);
39636 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39637 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39638 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39639 if (mcs_op_statistics[op].max < nsec)
39640 mcs_op_statistics[op].max = nsec;
39641 }
39642 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39643 index 797d796..ae8f01e 100644
39644 --- a/drivers/misc/sgi-gru/gruprocfs.c
39645 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39646 @@ -32,9 +32,9 @@
39647
39648 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39649
39650 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39651 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39652 {
39653 - unsigned long val = atomic_long_read(v);
39654 + unsigned long val = atomic_long_read_unchecked(v);
39655
39656 seq_printf(s, "%16lu %s\n", val, id);
39657 }
39658 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39659
39660 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39661 for (op = 0; op < mcsop_last; op++) {
39662 - count = atomic_long_read(&mcs_op_statistics[op].count);
39663 - total = atomic_long_read(&mcs_op_statistics[op].total);
39664 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39665 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39666 max = mcs_op_statistics[op].max;
39667 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39668 count ? total / count : 0, max);
39669 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39670 index 5c3ce24..4915ccb 100644
39671 --- a/drivers/misc/sgi-gru/grutables.h
39672 +++ b/drivers/misc/sgi-gru/grutables.h
39673 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39674 * GRU statistics.
39675 */
39676 struct gru_stats_s {
39677 - atomic_long_t vdata_alloc;
39678 - atomic_long_t vdata_free;
39679 - atomic_long_t gts_alloc;
39680 - atomic_long_t gts_free;
39681 - atomic_long_t gms_alloc;
39682 - atomic_long_t gms_free;
39683 - atomic_long_t gts_double_allocate;
39684 - atomic_long_t assign_context;
39685 - atomic_long_t assign_context_failed;
39686 - atomic_long_t free_context;
39687 - atomic_long_t load_user_context;
39688 - atomic_long_t load_kernel_context;
39689 - atomic_long_t lock_kernel_context;
39690 - atomic_long_t unlock_kernel_context;
39691 - atomic_long_t steal_user_context;
39692 - atomic_long_t steal_kernel_context;
39693 - atomic_long_t steal_context_failed;
39694 - atomic_long_t nopfn;
39695 - atomic_long_t asid_new;
39696 - atomic_long_t asid_next;
39697 - atomic_long_t asid_wrap;
39698 - atomic_long_t asid_reuse;
39699 - atomic_long_t intr;
39700 - atomic_long_t intr_cbr;
39701 - atomic_long_t intr_tfh;
39702 - atomic_long_t intr_spurious;
39703 - atomic_long_t intr_mm_lock_failed;
39704 - atomic_long_t call_os;
39705 - atomic_long_t call_os_wait_queue;
39706 - atomic_long_t user_flush_tlb;
39707 - atomic_long_t user_unload_context;
39708 - atomic_long_t user_exception;
39709 - atomic_long_t set_context_option;
39710 - atomic_long_t check_context_retarget_intr;
39711 - atomic_long_t check_context_unload;
39712 - atomic_long_t tlb_dropin;
39713 - atomic_long_t tlb_preload_page;
39714 - atomic_long_t tlb_dropin_fail_no_asid;
39715 - atomic_long_t tlb_dropin_fail_upm;
39716 - atomic_long_t tlb_dropin_fail_invalid;
39717 - atomic_long_t tlb_dropin_fail_range_active;
39718 - atomic_long_t tlb_dropin_fail_idle;
39719 - atomic_long_t tlb_dropin_fail_fmm;
39720 - atomic_long_t tlb_dropin_fail_no_exception;
39721 - atomic_long_t tfh_stale_on_fault;
39722 - atomic_long_t mmu_invalidate_range;
39723 - atomic_long_t mmu_invalidate_page;
39724 - atomic_long_t flush_tlb;
39725 - atomic_long_t flush_tlb_gru;
39726 - atomic_long_t flush_tlb_gru_tgh;
39727 - atomic_long_t flush_tlb_gru_zero_asid;
39728 + atomic_long_unchecked_t vdata_alloc;
39729 + atomic_long_unchecked_t vdata_free;
39730 + atomic_long_unchecked_t gts_alloc;
39731 + atomic_long_unchecked_t gts_free;
39732 + atomic_long_unchecked_t gms_alloc;
39733 + atomic_long_unchecked_t gms_free;
39734 + atomic_long_unchecked_t gts_double_allocate;
39735 + atomic_long_unchecked_t assign_context;
39736 + atomic_long_unchecked_t assign_context_failed;
39737 + atomic_long_unchecked_t free_context;
39738 + atomic_long_unchecked_t load_user_context;
39739 + atomic_long_unchecked_t load_kernel_context;
39740 + atomic_long_unchecked_t lock_kernel_context;
39741 + atomic_long_unchecked_t unlock_kernel_context;
39742 + atomic_long_unchecked_t steal_user_context;
39743 + atomic_long_unchecked_t steal_kernel_context;
39744 + atomic_long_unchecked_t steal_context_failed;
39745 + atomic_long_unchecked_t nopfn;
39746 + atomic_long_unchecked_t asid_new;
39747 + atomic_long_unchecked_t asid_next;
39748 + atomic_long_unchecked_t asid_wrap;
39749 + atomic_long_unchecked_t asid_reuse;
39750 + atomic_long_unchecked_t intr;
39751 + atomic_long_unchecked_t intr_cbr;
39752 + atomic_long_unchecked_t intr_tfh;
39753 + atomic_long_unchecked_t intr_spurious;
39754 + atomic_long_unchecked_t intr_mm_lock_failed;
39755 + atomic_long_unchecked_t call_os;
39756 + atomic_long_unchecked_t call_os_wait_queue;
39757 + atomic_long_unchecked_t user_flush_tlb;
39758 + atomic_long_unchecked_t user_unload_context;
39759 + atomic_long_unchecked_t user_exception;
39760 + atomic_long_unchecked_t set_context_option;
39761 + atomic_long_unchecked_t check_context_retarget_intr;
39762 + atomic_long_unchecked_t check_context_unload;
39763 + atomic_long_unchecked_t tlb_dropin;
39764 + atomic_long_unchecked_t tlb_preload_page;
39765 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39766 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39767 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39768 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39769 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39770 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39771 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39772 + atomic_long_unchecked_t tfh_stale_on_fault;
39773 + atomic_long_unchecked_t mmu_invalidate_range;
39774 + atomic_long_unchecked_t mmu_invalidate_page;
39775 + atomic_long_unchecked_t flush_tlb;
39776 + atomic_long_unchecked_t flush_tlb_gru;
39777 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39778 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39779
39780 - atomic_long_t copy_gpa;
39781 - atomic_long_t read_gpa;
39782 + atomic_long_unchecked_t copy_gpa;
39783 + atomic_long_unchecked_t read_gpa;
39784
39785 - atomic_long_t mesq_receive;
39786 - atomic_long_t mesq_receive_none;
39787 - atomic_long_t mesq_send;
39788 - atomic_long_t mesq_send_failed;
39789 - atomic_long_t mesq_noop;
39790 - atomic_long_t mesq_send_unexpected_error;
39791 - atomic_long_t mesq_send_lb_overflow;
39792 - atomic_long_t mesq_send_qlimit_reached;
39793 - atomic_long_t mesq_send_amo_nacked;
39794 - atomic_long_t mesq_send_put_nacked;
39795 - atomic_long_t mesq_page_overflow;
39796 - atomic_long_t mesq_qf_locked;
39797 - atomic_long_t mesq_qf_noop_not_full;
39798 - atomic_long_t mesq_qf_switch_head_failed;
39799 - atomic_long_t mesq_qf_unexpected_error;
39800 - atomic_long_t mesq_noop_unexpected_error;
39801 - atomic_long_t mesq_noop_lb_overflow;
39802 - atomic_long_t mesq_noop_qlimit_reached;
39803 - atomic_long_t mesq_noop_amo_nacked;
39804 - atomic_long_t mesq_noop_put_nacked;
39805 - atomic_long_t mesq_noop_page_overflow;
39806 + atomic_long_unchecked_t mesq_receive;
39807 + atomic_long_unchecked_t mesq_receive_none;
39808 + atomic_long_unchecked_t mesq_send;
39809 + atomic_long_unchecked_t mesq_send_failed;
39810 + atomic_long_unchecked_t mesq_noop;
39811 + atomic_long_unchecked_t mesq_send_unexpected_error;
39812 + atomic_long_unchecked_t mesq_send_lb_overflow;
39813 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39814 + atomic_long_unchecked_t mesq_send_amo_nacked;
39815 + atomic_long_unchecked_t mesq_send_put_nacked;
39816 + atomic_long_unchecked_t mesq_page_overflow;
39817 + atomic_long_unchecked_t mesq_qf_locked;
39818 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39819 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39820 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39821 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39822 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39823 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39824 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39825 + atomic_long_unchecked_t mesq_noop_put_nacked;
39826 + atomic_long_unchecked_t mesq_noop_page_overflow;
39827
39828 };
39829
39830 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39831 tghop_invalidate, mcsop_last};
39832
39833 struct mcs_op_statistic {
39834 - atomic_long_t count;
39835 - atomic_long_t total;
39836 + atomic_long_unchecked_t count;
39837 + atomic_long_unchecked_t total;
39838 unsigned long max;
39839 };
39840
39841 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39842
39843 #define STAT(id) do { \
39844 if (gru_options & OPT_STATS) \
39845 - atomic_long_inc(&gru_stats.id); \
39846 + atomic_long_inc_unchecked(&gru_stats.id); \
39847 } while (0)
39848
39849 #ifdef CONFIG_SGI_GRU_DEBUG
39850 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39851 index c862cd4..0d176fe 100644
39852 --- a/drivers/misc/sgi-xp/xp.h
39853 +++ b/drivers/misc/sgi-xp/xp.h
39854 @@ -288,7 +288,7 @@ struct xpc_interface {
39855 xpc_notify_func, void *);
39856 void (*received) (short, int, void *);
39857 enum xp_retval (*partid_to_nasids) (short, void *);
39858 -};
39859 +} __no_const;
39860
39861 extern struct xpc_interface xpc_interface;
39862
39863 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39864 index b94d5f7..7f494c5 100644
39865 --- a/drivers/misc/sgi-xp/xpc.h
39866 +++ b/drivers/misc/sgi-xp/xpc.h
39867 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39868 void (*received_payload) (struct xpc_channel *, void *);
39869 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39870 };
39871 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39872
39873 /* struct xpc_partition act_state values (for XPC HB) */
39874
39875 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39876 /* found in xpc_main.c */
39877 extern struct device *xpc_part;
39878 extern struct device *xpc_chan;
39879 -extern struct xpc_arch_operations xpc_arch_ops;
39880 +extern xpc_arch_operations_no_const xpc_arch_ops;
39881 extern int xpc_disengage_timelimit;
39882 extern int xpc_disengage_timedout;
39883 extern int xpc_activate_IRQ_rcvd;
39884 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39885 index d971817..33bdca5 100644
39886 --- a/drivers/misc/sgi-xp/xpc_main.c
39887 +++ b/drivers/misc/sgi-xp/xpc_main.c
39888 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39889 .notifier_call = xpc_system_die,
39890 };
39891
39892 -struct xpc_arch_operations xpc_arch_ops;
39893 +xpc_arch_operations_no_const xpc_arch_ops;
39894
39895 /*
39896 * Timer function to enforce the timelimit on the partition disengage.
39897 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39898
39899 if (((die_args->trapnr == X86_TRAP_MF) ||
39900 (die_args->trapnr == X86_TRAP_XF)) &&
39901 - !user_mode_vm(die_args->regs))
39902 + !user_mode(die_args->regs))
39903 xpc_die_deactivate();
39904
39905 break;
39906 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39907 index 49f04bc..65660c2 100644
39908 --- a/drivers/mmc/core/mmc_ops.c
39909 +++ b/drivers/mmc/core/mmc_ops.c
39910 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39911 void *data_buf;
39912 int is_on_stack;
39913
39914 - is_on_stack = object_is_on_stack(buf);
39915 + is_on_stack = object_starts_on_stack(buf);
39916 if (is_on_stack) {
39917 /*
39918 * dma onto stack is unsafe/nonportable, but callers to this
39919 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39920 index 0b74189..818358f 100644
39921 --- a/drivers/mmc/host/dw_mmc.h
39922 +++ b/drivers/mmc/host/dw_mmc.h
39923 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
39924 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
39925 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
39926 int (*parse_dt)(struct dw_mci *host);
39927 -};
39928 +} __do_const;
39929 #endif /* _DW_MMC_H_ */
39930 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39931 index c6f6246..60760a8 100644
39932 --- a/drivers/mmc/host/sdhci-s3c.c
39933 +++ b/drivers/mmc/host/sdhci-s3c.c
39934 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39935 * we can use overriding functions instead of default.
39936 */
39937 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39938 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39939 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39940 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39941 + pax_open_kernel();
39942 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39943 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39944 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39945 + pax_close_kernel();
39946 }
39947
39948 /* It supports additional host capabilities if needed */
39949 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39950 index 0c8bb6b..6f35deb 100644
39951 --- a/drivers/mtd/nand/denali.c
39952 +++ b/drivers/mtd/nand/denali.c
39953 @@ -24,6 +24,7 @@
39954 #include <linux/slab.h>
39955 #include <linux/mtd/mtd.h>
39956 #include <linux/module.h>
39957 +#include <linux/slab.h>
39958
39959 #include "denali.h"
39960
39961 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39962 index 51b9d6a..52af9a7 100644
39963 --- a/drivers/mtd/nftlmount.c
39964 +++ b/drivers/mtd/nftlmount.c
39965 @@ -24,6 +24,7 @@
39966 #include <asm/errno.h>
39967 #include <linux/delay.h>
39968 #include <linux/slab.h>
39969 +#include <linux/sched.h>
39970 #include <linux/mtd/mtd.h>
39971 #include <linux/mtd/nand.h>
39972 #include <linux/mtd/nftl.h>
39973 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39974 index f9d5615..99dd95f 100644
39975 --- a/drivers/mtd/sm_ftl.c
39976 +++ b/drivers/mtd/sm_ftl.c
39977 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39978 #define SM_CIS_VENDOR_OFFSET 0x59
39979 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39980 {
39981 - struct attribute_group *attr_group;
39982 + attribute_group_no_const *attr_group;
39983 struct attribute **attributes;
39984 struct sm_sysfs_attribute *vendor_attribute;
39985
39986 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39987 index f975696..4597e21 100644
39988 --- a/drivers/net/bonding/bond_main.c
39989 +++ b/drivers/net/bonding/bond_main.c
39990 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
39991 return tx_queues;
39992 }
39993
39994 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39995 +static struct rtnl_link_ops bond_link_ops = {
39996 .kind = "bond",
39997 .priv_size = sizeof(struct bonding),
39998 .setup = bond_setup,
39999 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
40000
40001 bond_destroy_debugfs();
40002
40003 - rtnl_link_unregister(&bond_link_ops);
40004 unregister_pernet_subsys(&bond_net_ops);
40005 + rtnl_link_unregister(&bond_link_ops);
40006
40007 #ifdef CONFIG_NET_POLL_CONTROLLER
40008 /*
40009 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
40010 index e1d2643..7f4133b 100644
40011 --- a/drivers/net/ethernet/8390/ax88796.c
40012 +++ b/drivers/net/ethernet/8390/ax88796.c
40013 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
40014 if (ax->plat->reg_offsets)
40015 ei_local->reg_offset = ax->plat->reg_offsets;
40016 else {
40017 + resource_size_t _mem_size = mem_size;
40018 + do_div(_mem_size, 0x18);
40019 ei_local->reg_offset = ax->reg_offsets;
40020 for (ret = 0; ret < 0x18; ret++)
40021 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
40022 + ax->reg_offsets[ret] = _mem_size * ret;
40023 }
40024
40025 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
40026 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40027 index 151675d..0139a9d 100644
40028 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40029 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40030 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40031 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40032 {
40033 /* RX_MODE controlling object */
40034 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40035 + bnx2x_init_rx_mode_obj(bp);
40036
40037 /* multicast configuration controlling object */
40038 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40039 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40040 index ce1a916..10b52b0 100644
40041 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40042 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40043 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
40044 struct bnx2x *bp = netdev_priv(dev);
40045
40046 /* Use the ethtool_dump "flag" field as the dump preset index */
40047 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
40048 + return -EINVAL;
40049 +
40050 bp->dump_preset_idx = val->flag;
40051 return 0;
40052 }
40053 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
40054 struct bnx2x *bp = netdev_priv(dev);
40055 struct dump_header dump_hdr = {0};
40056
40057 - memset(p, 0, dump->len);
40058 -
40059 /* Disable parity attentions as long as following dump may
40060 * cause false alarms by reading never written registers. We
40061 * will re-enable parity attentions right after the dump.
40062 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40063 index b4c9dea..2a9927f 100644
40064 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40065 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40066 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
40067 bp->min_msix_vec_cnt = 2;
40068 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
40069
40070 + bp->dump_preset_idx = 1;
40071 +
40072 return rc;
40073 }
40074
40075 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40076 index 32a9609..0b1c53a 100644
40077 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40078 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40079 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40080 return rc;
40081 }
40082
40083 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40084 - struct bnx2x_rx_mode_obj *o)
40085 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40086 {
40087 if (CHIP_IS_E1x(bp)) {
40088 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40089 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40090 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40091 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40092 } else {
40093 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40094 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40095 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40096 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40097 }
40098 }
40099
40100 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40101 index 43c00bc..dd1d03d 100644
40102 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40103 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40104 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40105
40106 /********************* RX MODE ****************/
40107
40108 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40109 - struct bnx2x_rx_mode_obj *o);
40110 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40111
40112 /**
40113 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40114 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40115 index ff6e30e..87e8452 100644
40116 --- a/drivers/net/ethernet/broadcom/tg3.h
40117 +++ b/drivers/net/ethernet/broadcom/tg3.h
40118 @@ -147,6 +147,7 @@
40119 #define CHIPREV_ID_5750_A0 0x4000
40120 #define CHIPREV_ID_5750_A1 0x4001
40121 #define CHIPREV_ID_5750_A3 0x4003
40122 +#define CHIPREV_ID_5750_C1 0x4201
40123 #define CHIPREV_ID_5750_C2 0x4202
40124 #define CHIPREV_ID_5752_A0_HW 0x5000
40125 #define CHIPREV_ID_5752_A0 0x6000
40126 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40127 index 71497e8..b650951 100644
40128 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40129 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40130 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
40131 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
40132 t3_read_reg(adapter, A_PCIE_PEX_ERR));
40133
40134 + rtnl_lock();
40135 t3_resume_ports(adapter);
40136 + rtnl_unlock();
40137 }
40138
40139 static const struct pci_error_handlers t3_err_handler = {
40140 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40141 index 8cffcdf..aadf043 100644
40142 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40143 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40144 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40145 */
40146 struct l2t_skb_cb {
40147 arp_failure_handler_func arp_failure_handler;
40148 -};
40149 +} __no_const;
40150
40151 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40152
40153 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40154 index 4c83003..2a2a5b9 100644
40155 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40156 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40157 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40158 for (i=0; i<ETH_ALEN; i++) {
40159 tmp.addr[i] = dev->dev_addr[i];
40160 }
40161 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40162 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40163 break;
40164
40165 case DE4X5_SET_HWADDR: /* Set the hardware address */
40166 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40167 spin_lock_irqsave(&lp->lock, flags);
40168 memcpy(&statbuf, &lp->pktStats, ioc->len);
40169 spin_unlock_irqrestore(&lp->lock, flags);
40170 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40171 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40172 return -EFAULT;
40173 break;
40174 }
40175 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40176 index a0b4be5..d8cb082 100644
40177 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40178 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40179 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40180
40181 if (wrapped)
40182 newacc += 65536;
40183 - ACCESS_ONCE(*acc) = newacc;
40184 + ACCESS_ONCE_RW(*acc) = newacc;
40185 }
40186
40187 void populate_erx_stats(struct be_adapter *adapter,
40188 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40189 index 21b85fb..b49e5fc 100644
40190 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40191 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40192 @@ -31,6 +31,8 @@
40193 #include <linux/netdevice.h>
40194 #include <linux/phy.h>
40195 #include <linux/platform_device.h>
40196 +#include <linux/interrupt.h>
40197 +#include <linux/irqreturn.h>
40198 #include <net/ip.h>
40199
40200 #include "ftgmac100.h"
40201 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40202 index a6eda8d..935d273 100644
40203 --- a/drivers/net/ethernet/faraday/ftmac100.c
40204 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40205 @@ -31,6 +31,8 @@
40206 #include <linux/module.h>
40207 #include <linux/netdevice.h>
40208 #include <linux/platform_device.h>
40209 +#include <linux/interrupt.h>
40210 +#include <linux/irqreturn.h>
40211
40212 #include "ftmac100.h"
40213
40214 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40215 index 331987d..3be1135 100644
40216 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40217 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40218 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40219 }
40220
40221 /* update the base incval used to calculate frequency adjustment */
40222 - ACCESS_ONCE(adapter->base_incval) = incval;
40223 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40224 smp_mb();
40225
40226 /* need lock to prevent incorrect read while modifying cyclecounter */
40227 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40228 index fbe5363..266b4e3 100644
40229 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40230 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40231 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40232 struct __vxge_hw_fifo *fifo;
40233 struct vxge_hw_fifo_config *config;
40234 u32 txdl_size, txdl_per_memblock;
40235 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40236 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40237 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40238 + };
40239 +
40240 struct __vxge_hw_virtualpath *vpath;
40241
40242 if ((vp == NULL) || (attr == NULL)) {
40243 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40244 goto exit;
40245 }
40246
40247 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40248 -
40249 fifo->mempool =
40250 __vxge_hw_mempool_create(vpath->hldev,
40251 fifo->config->memblock_size,
40252 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40253 index 5e7fb1d..f8d1810 100644
40254 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40255 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40256 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40257 op_mode = QLC_83XX_DEFAULT_OPMODE;
40258
40259 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40260 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40261 + pax_open_kernel();
40262 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40263 + pax_close_kernel();
40264 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40265 } else {
40266 return -EIO;
40267 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40268 index b0c3de9..fc5857e 100644
40269 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40270 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40271 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40272 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40273 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40274 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40275 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40276 + pax_open_kernel();
40277 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40278 + pax_close_kernel();
40279 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40280 ahw->op_mode = QLCNIC_PRIV_FUNC;
40281 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40282 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40283 + pax_open_kernel();
40284 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40285 + pax_close_kernel();
40286 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40287 ahw->op_mode = QLCNIC_MGMT_FUNC;
40288 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40289 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40290 + pax_open_kernel();
40291 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40292 + pax_close_kernel();
40293 } else {
40294 return -EIO;
40295 }
40296 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40297 index 393f961..d343034 100644
40298 --- a/drivers/net/ethernet/realtek/r8169.c
40299 +++ b/drivers/net/ethernet/realtek/r8169.c
40300 @@ -753,22 +753,22 @@ struct rtl8169_private {
40301 struct mdio_ops {
40302 void (*write)(struct rtl8169_private *, int, int);
40303 int (*read)(struct rtl8169_private *, int);
40304 - } mdio_ops;
40305 + } __no_const mdio_ops;
40306
40307 struct pll_power_ops {
40308 void (*down)(struct rtl8169_private *);
40309 void (*up)(struct rtl8169_private *);
40310 - } pll_power_ops;
40311 + } __no_const pll_power_ops;
40312
40313 struct jumbo_ops {
40314 void (*enable)(struct rtl8169_private *);
40315 void (*disable)(struct rtl8169_private *);
40316 - } jumbo_ops;
40317 + } __no_const jumbo_ops;
40318
40319 struct csi_ops {
40320 void (*write)(struct rtl8169_private *, int, int);
40321 u32 (*read)(struct rtl8169_private *, int);
40322 - } csi_ops;
40323 + } __no_const csi_ops;
40324
40325 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40326 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40327 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40328 index 9a95abf..36df7f9 100644
40329 --- a/drivers/net/ethernet/sfc/ptp.c
40330 +++ b/drivers/net/ethernet/sfc/ptp.c
40331 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40332 (u32)((u64)ptp->start.dma_addr >> 32));
40333
40334 /* Clear flag that signals MC ready */
40335 - ACCESS_ONCE(*start) = 0;
40336 + ACCESS_ONCE_RW(*start) = 0;
40337 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40338 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40339
40340 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40341 index 50617c5..b13724c 100644
40342 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40343 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40344 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40345
40346 writel(value, ioaddr + MMC_CNTRL);
40347
40348 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40349 - MMC_CNTRL, value);
40350 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40351 +// MMC_CNTRL, value);
40352 }
40353
40354 /* To mask all all interrupts.*/
40355 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40356 index e6fe0d8..2b7d752 100644
40357 --- a/drivers/net/hyperv/hyperv_net.h
40358 +++ b/drivers/net/hyperv/hyperv_net.h
40359 @@ -101,7 +101,7 @@ struct rndis_device {
40360
40361 enum rndis_device_state state;
40362 bool link_state;
40363 - atomic_t new_req_id;
40364 + atomic_unchecked_t new_req_id;
40365
40366 spinlock_t request_lock;
40367 struct list_head req_list;
40368 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40369 index 0775f0a..d4fb316 100644
40370 --- a/drivers/net/hyperv/rndis_filter.c
40371 +++ b/drivers/net/hyperv/rndis_filter.c
40372 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40373 * template
40374 */
40375 set = &rndis_msg->msg.set_req;
40376 - set->req_id = atomic_inc_return(&dev->new_req_id);
40377 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40378
40379 /* Add to the request list */
40380 spin_lock_irqsave(&dev->request_lock, flags);
40381 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40382
40383 /* Setup the rndis set */
40384 halt = &request->request_msg.msg.halt_req;
40385 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40386 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40387
40388 /* Ignore return since this msg is optional. */
40389 rndis_filter_send_request(dev, request);
40390 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40391 index bf0d55e..82bcfbd1 100644
40392 --- a/drivers/net/ieee802154/fakehard.c
40393 +++ b/drivers/net/ieee802154/fakehard.c
40394 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40395 phy->transmit_power = 0xbf;
40396
40397 dev->netdev_ops = &fake_ops;
40398 - dev->ml_priv = &fake_mlme;
40399 + dev->ml_priv = (void *)&fake_mlme;
40400
40401 priv = netdev_priv(dev);
40402 priv->phy = phy;
40403 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40404 index 6e91931..2b0ebe7 100644
40405 --- a/drivers/net/macvlan.c
40406 +++ b/drivers/net/macvlan.c
40407 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40408 int macvlan_link_register(struct rtnl_link_ops *ops)
40409 {
40410 /* common fields */
40411 - ops->priv_size = sizeof(struct macvlan_dev);
40412 - ops->validate = macvlan_validate;
40413 - ops->maxtype = IFLA_MACVLAN_MAX;
40414 - ops->policy = macvlan_policy;
40415 - ops->changelink = macvlan_changelink;
40416 - ops->get_size = macvlan_get_size;
40417 - ops->fill_info = macvlan_fill_info;
40418 + pax_open_kernel();
40419 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40420 + *(void **)&ops->validate = macvlan_validate;
40421 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40422 + *(const void **)&ops->policy = macvlan_policy;
40423 + *(void **)&ops->changelink = macvlan_changelink;
40424 + *(void **)&ops->get_size = macvlan_get_size;
40425 + *(void **)&ops->fill_info = macvlan_fill_info;
40426 + pax_close_kernel();
40427
40428 return rtnl_link_register(ops);
40429 };
40430 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40431 return NOTIFY_DONE;
40432 }
40433
40434 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40435 +static struct notifier_block macvlan_notifier_block = {
40436 .notifier_call = macvlan_device_event,
40437 };
40438
40439 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40440 index b6dd6a7..5c38a02 100644
40441 --- a/drivers/net/macvtap.c
40442 +++ b/drivers/net/macvtap.c
40443 @@ -1094,7 +1094,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40444 return NOTIFY_DONE;
40445 }
40446
40447 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40448 +static struct notifier_block macvtap_notifier_block = {
40449 .notifier_call = macvtap_device_event,
40450 };
40451
40452 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40453 index daec9b0..6428fcb 100644
40454 --- a/drivers/net/phy/mdio-bitbang.c
40455 +++ b/drivers/net/phy/mdio-bitbang.c
40456 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40457 struct mdiobb_ctrl *ctrl = bus->priv;
40458
40459 module_put(ctrl->ops->owner);
40460 + mdiobus_unregister(bus);
40461 mdiobus_free(bus);
40462 }
40463 EXPORT_SYMBOL(free_mdio_bitbang);
40464 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40465 index 72ff14b..11d442d 100644
40466 --- a/drivers/net/ppp/ppp_generic.c
40467 +++ b/drivers/net/ppp/ppp_generic.c
40468 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40469 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40470 struct ppp_stats stats;
40471 struct ppp_comp_stats cstats;
40472 - char *vers;
40473
40474 switch (cmd) {
40475 case SIOCGPPPSTATS:
40476 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40477 break;
40478
40479 case SIOCGPPPVER:
40480 - vers = PPP_VERSION;
40481 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40482 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40483 break;
40484 err = 0;
40485 break;
40486 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40487 index 1252d9c..80e660b 100644
40488 --- a/drivers/net/slip/slhc.c
40489 +++ b/drivers/net/slip/slhc.c
40490 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40491 register struct tcphdr *thp;
40492 register struct iphdr *ip;
40493 register struct cstate *cs;
40494 - int len, hdrlen;
40495 + long len, hdrlen;
40496 unsigned char *cp = icp;
40497
40498 /* We've got a compressed packet; read the change byte */
40499 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40500 index b305105..8ead6df 100644
40501 --- a/drivers/net/team/team.c
40502 +++ b/drivers/net/team/team.c
40503 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
40504 return NOTIFY_DONE;
40505 }
40506
40507 -static struct notifier_block team_notifier_block __read_mostly = {
40508 +static struct notifier_block team_notifier_block = {
40509 .notifier_call = team_device_event,
40510 };
40511
40512 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40513 index 9c61f87..213609e 100644
40514 --- a/drivers/net/tun.c
40515 +++ b/drivers/net/tun.c
40516 @@ -1852,7 +1852,7 @@ unlock:
40517 }
40518
40519 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40520 - unsigned long arg, int ifreq_len)
40521 + unsigned long arg, size_t ifreq_len)
40522 {
40523 struct tun_file *tfile = file->private_data;
40524 struct tun_struct *tun;
40525 @@ -1864,6 +1864,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40526 int vnet_hdr_sz;
40527 int ret;
40528
40529 + if (ifreq_len > sizeof ifr)
40530 + return -EFAULT;
40531 +
40532 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40533 if (copy_from_user(&ifr, argp, ifreq_len))
40534 return -EFAULT;
40535 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40536 index cba1d46..f703766 100644
40537 --- a/drivers/net/usb/hso.c
40538 +++ b/drivers/net/usb/hso.c
40539 @@ -71,7 +71,7 @@
40540 #include <asm/byteorder.h>
40541 #include <linux/serial_core.h>
40542 #include <linux/serial.h>
40543 -
40544 +#include <asm/local.h>
40545
40546 #define MOD_AUTHOR "Option Wireless"
40547 #define MOD_DESCRIPTION "USB High Speed Option driver"
40548 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40549 struct urb *urb;
40550
40551 urb = serial->rx_urb[0];
40552 - if (serial->port.count > 0) {
40553 + if (atomic_read(&serial->port.count) > 0) {
40554 count = put_rxbuf_data(urb, serial);
40555 if (count == -1)
40556 return;
40557 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40558 DUMP1(urb->transfer_buffer, urb->actual_length);
40559
40560 /* Anyone listening? */
40561 - if (serial->port.count == 0)
40562 + if (atomic_read(&serial->port.count) == 0)
40563 return;
40564
40565 if (status == 0) {
40566 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40567 tty_port_tty_set(&serial->port, tty);
40568
40569 /* check for port already opened, if not set the termios */
40570 - serial->port.count++;
40571 - if (serial->port.count == 1) {
40572 + if (atomic_inc_return(&serial->port.count) == 1) {
40573 serial->rx_state = RX_IDLE;
40574 /* Force default termio settings */
40575 _hso_serial_set_termios(tty, NULL);
40576 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40577 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40578 if (result) {
40579 hso_stop_serial_device(serial->parent);
40580 - serial->port.count--;
40581 + atomic_dec(&serial->port.count);
40582 kref_put(&serial->parent->ref, hso_serial_ref_free);
40583 }
40584 } else {
40585 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40586
40587 /* reset the rts and dtr */
40588 /* do the actual close */
40589 - serial->port.count--;
40590 + atomic_dec(&serial->port.count);
40591
40592 - if (serial->port.count <= 0) {
40593 - serial->port.count = 0;
40594 + if (atomic_read(&serial->port.count) <= 0) {
40595 + atomic_set(&serial->port.count, 0);
40596 tty_port_tty_set(&serial->port, NULL);
40597 if (!usb_gone)
40598 hso_stop_serial_device(serial->parent);
40599 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40600
40601 /* the actual setup */
40602 spin_lock_irqsave(&serial->serial_lock, flags);
40603 - if (serial->port.count)
40604 + if (atomic_read(&serial->port.count))
40605 _hso_serial_set_termios(tty, old);
40606 else
40607 tty->termios = *old;
40608 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40609 D1("Pending read interrupt on port %d\n", i);
40610 spin_lock(&serial->serial_lock);
40611 if (serial->rx_state == RX_IDLE &&
40612 - serial->port.count > 0) {
40613 + atomic_read(&serial->port.count) > 0) {
40614 /* Setup and send a ctrl req read on
40615 * port i */
40616 if (!serial->rx_urb_filled[0]) {
40617 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
40618 /* Start all serial ports */
40619 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40620 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40621 - if (dev2ser(serial_table[i])->port.count) {
40622 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40623 result =
40624 hso_start_serial_device(serial_table[i], GFP_NOIO);
40625 hso_kick_transmit(dev2ser(serial_table[i]));
40626 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40627 index 57325f3..36b181f 100644
40628 --- a/drivers/net/vxlan.c
40629 +++ b/drivers/net/vxlan.c
40630 @@ -1579,7 +1579,7 @@ nla_put_failure:
40631 return -EMSGSIZE;
40632 }
40633
40634 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40635 +static struct rtnl_link_ops vxlan_link_ops = {
40636 .kind = "vxlan",
40637 .maxtype = IFLA_VXLAN_MAX,
40638 .policy = vxlan_policy,
40639 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40640 index 34c8a33..3261fdc 100644
40641 --- a/drivers/net/wireless/at76c50x-usb.c
40642 +++ b/drivers/net/wireless/at76c50x-usb.c
40643 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40644 }
40645
40646 /* Convert timeout from the DFU status to jiffies */
40647 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40648 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40649 {
40650 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40651 | (s->poll_timeout[1] << 8)
40652 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40653 index 8d78253..bebbb68 100644
40654 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40655 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40656 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40657 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40658 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40659
40660 - ACCESS_ONCE(ads->ds_link) = i->link;
40661 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40662 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40663 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40664
40665 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40666 ctl6 = SM(i->keytype, AR_EncrType);
40667 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40668
40669 if ((i->is_first || i->is_last) &&
40670 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40671 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40672 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40673 | set11nTries(i->rates, 1)
40674 | set11nTries(i->rates, 2)
40675 | set11nTries(i->rates, 3)
40676 | (i->dur_update ? AR_DurUpdateEna : 0)
40677 | SM(0, AR_BurstDur);
40678
40679 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40680 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40681 | set11nRate(i->rates, 1)
40682 | set11nRate(i->rates, 2)
40683 | set11nRate(i->rates, 3);
40684 } else {
40685 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40686 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40687 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40688 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40689 }
40690
40691 if (!i->is_first) {
40692 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40693 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40694 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40695 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40696 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40697 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40698 return;
40699 }
40700
40701 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40702 break;
40703 }
40704
40705 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40706 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40707 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40708 | SM(i->txpower, AR_XmitPower)
40709 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40710 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40711 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40712 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40713
40714 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40715 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40716 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40717 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40718
40719 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40720 return;
40721
40722 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40723 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40724 | set11nPktDurRTSCTS(i->rates, 1);
40725
40726 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40727 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40728 | set11nPktDurRTSCTS(i->rates, 3);
40729
40730 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40731 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40732 | set11nRateFlags(i->rates, 1)
40733 | set11nRateFlags(i->rates, 2)
40734 | set11nRateFlags(i->rates, 3)
40735 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40736 index 301bf72..3f5654f 100644
40737 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40738 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40739 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40740 (i->qcu << AR_TxQcuNum_S) | desc_len;
40741
40742 checksum += val;
40743 - ACCESS_ONCE(ads->info) = val;
40744 + ACCESS_ONCE_RW(ads->info) = val;
40745
40746 checksum += i->link;
40747 - ACCESS_ONCE(ads->link) = i->link;
40748 + ACCESS_ONCE_RW(ads->link) = i->link;
40749
40750 checksum += i->buf_addr[0];
40751 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40752 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40753 checksum += i->buf_addr[1];
40754 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40755 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40756 checksum += i->buf_addr[2];
40757 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40758 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40759 checksum += i->buf_addr[3];
40760 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40761 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40762
40763 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40764 - ACCESS_ONCE(ads->ctl3) = val;
40765 + ACCESS_ONCE_RW(ads->ctl3) = val;
40766 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40767 - ACCESS_ONCE(ads->ctl5) = val;
40768 + ACCESS_ONCE_RW(ads->ctl5) = val;
40769 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40770 - ACCESS_ONCE(ads->ctl7) = val;
40771 + ACCESS_ONCE_RW(ads->ctl7) = val;
40772 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40773 - ACCESS_ONCE(ads->ctl9) = val;
40774 + ACCESS_ONCE_RW(ads->ctl9) = val;
40775
40776 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40777 - ACCESS_ONCE(ads->ctl10) = checksum;
40778 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40779
40780 if (i->is_first || i->is_last) {
40781 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40782 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40783 | set11nTries(i->rates, 1)
40784 | set11nTries(i->rates, 2)
40785 | set11nTries(i->rates, 3)
40786 | (i->dur_update ? AR_DurUpdateEna : 0)
40787 | SM(0, AR_BurstDur);
40788
40789 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40790 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40791 | set11nRate(i->rates, 1)
40792 | set11nRate(i->rates, 2)
40793 | set11nRate(i->rates, 3);
40794 } else {
40795 - ACCESS_ONCE(ads->ctl13) = 0;
40796 - ACCESS_ONCE(ads->ctl14) = 0;
40797 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40798 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40799 }
40800
40801 ads->ctl20 = 0;
40802 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40803
40804 ctl17 = SM(i->keytype, AR_EncrType);
40805 if (!i->is_first) {
40806 - ACCESS_ONCE(ads->ctl11) = 0;
40807 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40808 - ACCESS_ONCE(ads->ctl15) = 0;
40809 - ACCESS_ONCE(ads->ctl16) = 0;
40810 - ACCESS_ONCE(ads->ctl17) = ctl17;
40811 - ACCESS_ONCE(ads->ctl18) = 0;
40812 - ACCESS_ONCE(ads->ctl19) = 0;
40813 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40814 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40815 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40816 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40817 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40818 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40819 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40820 return;
40821 }
40822
40823 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40824 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40825 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40826 | SM(i->txpower, AR_XmitPower)
40827 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40828 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40829 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40830 ctl12 |= SM(val, AR_PAPRDChainMask);
40831
40832 - ACCESS_ONCE(ads->ctl12) = ctl12;
40833 - ACCESS_ONCE(ads->ctl17) = ctl17;
40834 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40835 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40836
40837 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40838 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40839 | set11nPktDurRTSCTS(i->rates, 1);
40840
40841 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40842 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40843 | set11nPktDurRTSCTS(i->rates, 3);
40844
40845 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40846 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40847 | set11nRateFlags(i->rates, 1)
40848 | set11nRateFlags(i->rates, 2)
40849 | set11nRateFlags(i->rates, 3)
40850 | SM(i->rtscts_rate, AR_RTSCTSRate);
40851
40852 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40853 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40854 }
40855
40856 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40857 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40858 index ae30343..a117806 100644
40859 --- a/drivers/net/wireless/ath/ath9k/hw.h
40860 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40861 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
40862
40863 /* ANI */
40864 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40865 -};
40866 +} __no_const;
40867
40868 /**
40869 * struct ath_spec_scan - parameters for Atheros spectral scan
40870 @@ -721,7 +721,7 @@ struct ath_hw_ops {
40871 struct ath_spec_scan *param);
40872 void (*spectral_scan_trigger)(struct ath_hw *ah);
40873 void (*spectral_scan_wait)(struct ath_hw *ah);
40874 -};
40875 +} __no_const;
40876
40877 struct ath_nf_limits {
40878 s16 max;
40879 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40880 index b37a582..680835d 100644
40881 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40882 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40883 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40884 */
40885 if (il3945_mod_params.disable_hw_scan) {
40886 D_INFO("Disabling hw_scan\n");
40887 - il3945_mac_ops.hw_scan = NULL;
40888 + pax_open_kernel();
40889 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40890 + pax_close_kernel();
40891 }
40892
40893 D_INFO("*** LOAD DRIVER ***\n");
40894 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40895 index d532948..a1cb592 100644
40896 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40897 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40898 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40899 {
40900 struct iwl_priv *priv = file->private_data;
40901 char buf[64];
40902 - int buf_size;
40903 + size_t buf_size;
40904 u32 offset, len;
40905
40906 memset(buf, 0, sizeof(buf));
40907 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40908 struct iwl_priv *priv = file->private_data;
40909
40910 char buf[8];
40911 - int buf_size;
40912 + size_t buf_size;
40913 u32 reset_flag;
40914
40915 memset(buf, 0, sizeof(buf));
40916 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40917 {
40918 struct iwl_priv *priv = file->private_data;
40919 char buf[8];
40920 - int buf_size;
40921 + size_t buf_size;
40922 int ht40;
40923
40924 memset(buf, 0, sizeof(buf));
40925 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40926 {
40927 struct iwl_priv *priv = file->private_data;
40928 char buf[8];
40929 - int buf_size;
40930 + size_t buf_size;
40931 int value;
40932
40933 memset(buf, 0, sizeof(buf));
40934 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40935 {
40936 struct iwl_priv *priv = file->private_data;
40937 char buf[8];
40938 - int buf_size;
40939 + size_t buf_size;
40940 int clear;
40941
40942 memset(buf, 0, sizeof(buf));
40943 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40944 {
40945 struct iwl_priv *priv = file->private_data;
40946 char buf[8];
40947 - int buf_size;
40948 + size_t buf_size;
40949 int trace;
40950
40951 memset(buf, 0, sizeof(buf));
40952 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40953 {
40954 struct iwl_priv *priv = file->private_data;
40955 char buf[8];
40956 - int buf_size;
40957 + size_t buf_size;
40958 int missed;
40959
40960 memset(buf, 0, sizeof(buf));
40961 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40962
40963 struct iwl_priv *priv = file->private_data;
40964 char buf[8];
40965 - int buf_size;
40966 + size_t buf_size;
40967 int plcp;
40968
40969 memset(buf, 0, sizeof(buf));
40970 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40971
40972 struct iwl_priv *priv = file->private_data;
40973 char buf[8];
40974 - int buf_size;
40975 + size_t buf_size;
40976 int flush;
40977
40978 memset(buf, 0, sizeof(buf));
40979 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40980
40981 struct iwl_priv *priv = file->private_data;
40982 char buf[8];
40983 - int buf_size;
40984 + size_t buf_size;
40985 int rts;
40986
40987 if (!priv->cfg->ht_params)
40988 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40989 {
40990 struct iwl_priv *priv = file->private_data;
40991 char buf[8];
40992 - int buf_size;
40993 + size_t buf_size;
40994
40995 memset(buf, 0, sizeof(buf));
40996 buf_size = min(count, sizeof(buf) - 1);
40997 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40998 struct iwl_priv *priv = file->private_data;
40999 u32 event_log_flag;
41000 char buf[8];
41001 - int buf_size;
41002 + size_t buf_size;
41003
41004 /* check that the interface is up */
41005 if (!iwl_is_ready(priv))
41006 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
41007 struct iwl_priv *priv = file->private_data;
41008 char buf[8];
41009 u32 calib_disabled;
41010 - int buf_size;
41011 + size_t buf_size;
41012
41013 memset(buf, 0, sizeof(buf));
41014 buf_size = min(count, sizeof(buf) - 1);
41015 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
41016 index 50ba0a4..29424e7 100644
41017 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
41018 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
41019 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
41020 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
41021
41022 char buf[8];
41023 - int buf_size;
41024 + size_t buf_size;
41025 u32 reset_flag;
41026
41027 memset(buf, 0, sizeof(buf));
41028 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
41029 {
41030 struct iwl_trans *trans = file->private_data;
41031 char buf[8];
41032 - int buf_size;
41033 + size_t buf_size;
41034 int csr;
41035
41036 memset(buf, 0, sizeof(buf));
41037 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
41038 index cb34c78..9fec0dc 100644
41039 --- a/drivers/net/wireless/mac80211_hwsim.c
41040 +++ b/drivers/net/wireless/mac80211_hwsim.c
41041 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
41042
41043 if (channels > 1) {
41044 hwsim_if_comb.num_different_channels = channels;
41045 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41046 - mac80211_hwsim_ops.cancel_hw_scan =
41047 - mac80211_hwsim_cancel_hw_scan;
41048 - mac80211_hwsim_ops.sw_scan_start = NULL;
41049 - mac80211_hwsim_ops.sw_scan_complete = NULL;
41050 - mac80211_hwsim_ops.remain_on_channel =
41051 - mac80211_hwsim_roc;
41052 - mac80211_hwsim_ops.cancel_remain_on_channel =
41053 - mac80211_hwsim_croc;
41054 - mac80211_hwsim_ops.add_chanctx =
41055 - mac80211_hwsim_add_chanctx;
41056 - mac80211_hwsim_ops.remove_chanctx =
41057 - mac80211_hwsim_remove_chanctx;
41058 - mac80211_hwsim_ops.change_chanctx =
41059 - mac80211_hwsim_change_chanctx;
41060 - mac80211_hwsim_ops.assign_vif_chanctx =
41061 - mac80211_hwsim_assign_vif_chanctx;
41062 - mac80211_hwsim_ops.unassign_vif_chanctx =
41063 - mac80211_hwsim_unassign_vif_chanctx;
41064 + pax_open_kernel();
41065 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41066 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
41067 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
41068 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
41069 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
41070 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
41071 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
41072 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
41073 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
41074 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
41075 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
41076 + pax_close_kernel();
41077 }
41078
41079 spin_lock_init(&hwsim_radio_lock);
41080 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41081 index 8169a85..7fa3b47 100644
41082 --- a/drivers/net/wireless/rndis_wlan.c
41083 +++ b/drivers/net/wireless/rndis_wlan.c
41084 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41085
41086 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41087
41088 - if (rts_threshold < 0 || rts_threshold > 2347)
41089 + if (rts_threshold > 2347)
41090 rts_threshold = 2347;
41091
41092 tmp = cpu_to_le32(rts_threshold);
41093 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41094 index 7510723..5ba37f5 100644
41095 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41096 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41097 @@ -386,7 +386,7 @@ struct rt2x00_intf {
41098 * for hardware which doesn't support hardware
41099 * sequence counting.
41100 */
41101 - atomic_t seqno;
41102 + atomic_unchecked_t seqno;
41103 };
41104
41105 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41106 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41107 index 2c12311..7b77f24 100644
41108 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41109 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41110 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41111 * sequence counter given by mac80211.
41112 */
41113 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41114 - seqno = atomic_add_return(0x10, &intf->seqno);
41115 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41116 else
41117 - seqno = atomic_read(&intf->seqno);
41118 + seqno = atomic_read_unchecked(&intf->seqno);
41119
41120 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41121 hdr->seq_ctrl |= cpu_to_le16(seqno);
41122 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41123 index e2b3d9c..67a5184 100644
41124 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41125 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41126 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41127
41128 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41129
41130 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41131 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41132 + pax_open_kernel();
41133 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41134 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41135 + pax_close_kernel();
41136
41137 wl1251_info("using dedicated interrupt line");
41138 } else {
41139 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41140 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41141 + pax_open_kernel();
41142 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41143 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41144 + pax_close_kernel();
41145
41146 wl1251_info("using SDIO interrupt");
41147 }
41148 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41149 index 1c627da..69f7d17 100644
41150 --- a/drivers/net/wireless/ti/wl12xx/main.c
41151 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41152 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41153 sizeof(wl->conf.mem));
41154
41155 /* read data preparation is only needed by wl127x */
41156 - wl->ops->prepare_read = wl127x_prepare_read;
41157 + pax_open_kernel();
41158 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41159 + pax_close_kernel();
41160
41161 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41162 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41163 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41164 sizeof(wl->conf.mem));
41165
41166 /* read data preparation is only needed by wl127x */
41167 - wl->ops->prepare_read = wl127x_prepare_read;
41168 + pax_open_kernel();
41169 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41170 + pax_close_kernel();
41171
41172 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41173 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41174 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41175 index 9fa692d..b31fee0 100644
41176 --- a/drivers/net/wireless/ti/wl18xx/main.c
41177 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41178 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41179 }
41180
41181 if (!checksum_param) {
41182 - wl18xx_ops.set_rx_csum = NULL;
41183 - wl18xx_ops.init_vif = NULL;
41184 + pax_open_kernel();
41185 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41186 + *(void **)&wl18xx_ops.init_vif = NULL;
41187 + pax_close_kernel();
41188 }
41189
41190 /* Enable 11a Band only if we have 5G antennas */
41191 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41192 index 7ef0b4a..ff65c28 100644
41193 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41194 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41195 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41196 {
41197 struct zd_usb *usb = urb->context;
41198 struct zd_usb_interrupt *intr = &usb->intr;
41199 - int len;
41200 + unsigned int len;
41201 u16 int_num;
41202
41203 ZD_ASSERT(in_interrupt());
41204 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41205 index d93b2b6..ae50401 100644
41206 --- a/drivers/oprofile/buffer_sync.c
41207 +++ b/drivers/oprofile/buffer_sync.c
41208 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41209 if (cookie == NO_COOKIE)
41210 offset = pc;
41211 if (cookie == INVALID_COOKIE) {
41212 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41213 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41214 offset = pc;
41215 }
41216 if (cookie != last_cookie) {
41217 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41218 /* add userspace sample */
41219
41220 if (!mm) {
41221 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41222 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41223 return 0;
41224 }
41225
41226 cookie = lookup_dcookie(mm, s->eip, &offset);
41227
41228 if (cookie == INVALID_COOKIE) {
41229 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41230 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41231 return 0;
41232 }
41233
41234 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41235 /* ignore backtraces if failed to add a sample */
41236 if (state == sb_bt_start) {
41237 state = sb_bt_ignore;
41238 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41239 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41240 }
41241 }
41242 release_mm(mm);
41243 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41244 index c0cc4e7..44d4e54 100644
41245 --- a/drivers/oprofile/event_buffer.c
41246 +++ b/drivers/oprofile/event_buffer.c
41247 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41248 }
41249
41250 if (buffer_pos == buffer_size) {
41251 - atomic_inc(&oprofile_stats.event_lost_overflow);
41252 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41253 return;
41254 }
41255
41256 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41257 index ed2c3ec..deda85a 100644
41258 --- a/drivers/oprofile/oprof.c
41259 +++ b/drivers/oprofile/oprof.c
41260 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41261 if (oprofile_ops.switch_events())
41262 return;
41263
41264 - atomic_inc(&oprofile_stats.multiplex_counter);
41265 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41266 start_switch_worker();
41267 }
41268
41269 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41270 index 84a208d..d61b0a1 100644
41271 --- a/drivers/oprofile/oprofile_files.c
41272 +++ b/drivers/oprofile/oprofile_files.c
41273 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41274
41275 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41276
41277 -static ssize_t timeout_read(struct file *file, char __user *buf,
41278 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41279 size_t count, loff_t *offset)
41280 {
41281 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41282 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41283 index 917d28e..d62d981 100644
41284 --- a/drivers/oprofile/oprofile_stats.c
41285 +++ b/drivers/oprofile/oprofile_stats.c
41286 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41287 cpu_buf->sample_invalid_eip = 0;
41288 }
41289
41290 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41291 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41292 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41293 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41294 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41295 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41296 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41297 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41298 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41299 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41300 }
41301
41302
41303 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41304 index 38b6fc0..b5cbfce 100644
41305 --- a/drivers/oprofile/oprofile_stats.h
41306 +++ b/drivers/oprofile/oprofile_stats.h
41307 @@ -13,11 +13,11 @@
41308 #include <linux/atomic.h>
41309
41310 struct oprofile_stat_struct {
41311 - atomic_t sample_lost_no_mm;
41312 - atomic_t sample_lost_no_mapping;
41313 - atomic_t bt_lost_no_mapping;
41314 - atomic_t event_lost_overflow;
41315 - atomic_t multiplex_counter;
41316 + atomic_unchecked_t sample_lost_no_mm;
41317 + atomic_unchecked_t sample_lost_no_mapping;
41318 + atomic_unchecked_t bt_lost_no_mapping;
41319 + atomic_unchecked_t event_lost_overflow;
41320 + atomic_unchecked_t multiplex_counter;
41321 };
41322
41323 extern struct oprofile_stat_struct oprofile_stats;
41324 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41325 index 7c12d9c..558bf3bb 100644
41326 --- a/drivers/oprofile/oprofilefs.c
41327 +++ b/drivers/oprofile/oprofilefs.c
41328 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41329
41330
41331 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41332 - char const *name, atomic_t *val)
41333 + char const *name, atomic_unchecked_t *val)
41334 {
41335 return __oprofilefs_create_file(sb, root, name,
41336 &atomic_ro_fops, 0444, val);
41337 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41338 index 93404f7..4a313d8 100644
41339 --- a/drivers/oprofile/timer_int.c
41340 +++ b/drivers/oprofile/timer_int.c
41341 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41342 return NOTIFY_OK;
41343 }
41344
41345 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41346 +static struct notifier_block oprofile_cpu_notifier = {
41347 .notifier_call = oprofile_cpu_notify,
41348 };
41349
41350 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41351 index 92ed045..62d39bd7 100644
41352 --- a/drivers/parport/procfs.c
41353 +++ b/drivers/parport/procfs.c
41354 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41355
41356 *ppos += len;
41357
41358 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41359 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41360 }
41361
41362 #ifdef CONFIG_PARPORT_1284
41363 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41364
41365 *ppos += len;
41366
41367 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41368 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41369 }
41370 #endif /* IEEE1284.3 support. */
41371
41372 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41373 index c35e8ad..fc33beb 100644
41374 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41375 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41376 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41377 goto init_cleanup;
41378 }
41379
41380 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41381 + pax_open_kernel();
41382 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41383 + pax_close_kernel();
41384 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41385
41386 return retval;
41387 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41388 index a6a71c4..c91097b 100644
41389 --- a/drivers/pci/hotplug/cpcihp_generic.c
41390 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41391 @@ -73,7 +73,6 @@ static u16 port;
41392 static unsigned int enum_bit;
41393 static u8 enum_mask;
41394
41395 -static struct cpci_hp_controller_ops generic_hpc_ops;
41396 static struct cpci_hp_controller generic_hpc;
41397
41398 static int __init validate_parameters(void)
41399 @@ -139,6 +138,10 @@ static int query_enum(void)
41400 return ((value & enum_mask) == enum_mask);
41401 }
41402
41403 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41404 + .query_enum = query_enum,
41405 +};
41406 +
41407 static int __init cpcihp_generic_init(void)
41408 {
41409 int status;
41410 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41411 pci_dev_put(dev);
41412
41413 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41414 - generic_hpc_ops.query_enum = query_enum;
41415 generic_hpc.ops = &generic_hpc_ops;
41416
41417 status = cpci_hp_register_controller(&generic_hpc);
41418 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41419 index 449b4bb..257e2e8 100644
41420 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41421 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41422 @@ -59,7 +59,6 @@
41423 /* local variables */
41424 static bool debug;
41425 static bool poll;
41426 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41427 static struct cpci_hp_controller zt5550_hpc;
41428
41429 /* Primary cPCI bus bridge device */
41430 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41431 return 0;
41432 }
41433
41434 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41435 + .query_enum = zt5550_hc_query_enum,
41436 +};
41437 +
41438 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41439 {
41440 int status;
41441 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41442 dbg("returned from zt5550_hc_config");
41443
41444 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41445 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41446 zt5550_hpc.ops = &zt5550_hpc_ops;
41447 if(!poll) {
41448 zt5550_hpc.irq = hc_dev->irq;
41449 zt5550_hpc.irq_flags = IRQF_SHARED;
41450 zt5550_hpc.dev_id = hc_dev;
41451
41452 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41453 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41454 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41455 + pax_open_kernel();
41456 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41457 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41458 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41459 + pax_open_kernel();
41460 } else {
41461 info("using ENUM# polling mode");
41462 }
41463 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41464 index 76ba8a1..20ca857 100644
41465 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41466 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41467 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41468
41469 void compaq_nvram_init (void __iomem *rom_start)
41470 {
41471 +
41472 +#ifndef CONFIG_PAX_KERNEXEC
41473 if (rom_start) {
41474 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41475 }
41476 +#endif
41477 +
41478 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41479
41480 /* initialize our int15 lock */
41481 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41482 index ec20f74..c1d961e 100644
41483 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41484 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41485 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41486 return -EINVAL;
41487 }
41488
41489 - slot->ops->owner = owner;
41490 - slot->ops->mod_name = mod_name;
41491 + pax_open_kernel();
41492 + *(struct module **)&slot->ops->owner = owner;
41493 + *(const char **)&slot->ops->mod_name = mod_name;
41494 + pax_close_kernel();
41495
41496 mutex_lock(&pci_hp_mutex);
41497 /*
41498 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41499 index 7d72c5e..edce02c 100644
41500 --- a/drivers/pci/hotplug/pciehp_core.c
41501 +++ b/drivers/pci/hotplug/pciehp_core.c
41502 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41503 struct slot *slot = ctrl->slot;
41504 struct hotplug_slot *hotplug = NULL;
41505 struct hotplug_slot_info *info = NULL;
41506 - struct hotplug_slot_ops *ops = NULL;
41507 + hotplug_slot_ops_no_const *ops = NULL;
41508 char name[SLOT_NAME_SIZE];
41509 int retval = -ENOMEM;
41510
41511 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41512 index 5b4a9d9..cd5ac1f 100644
41513 --- a/drivers/pci/pci-sysfs.c
41514 +++ b/drivers/pci/pci-sysfs.c
41515 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41516 {
41517 /* allocate attribute structure, piggyback attribute name */
41518 int name_len = write_combine ? 13 : 10;
41519 - struct bin_attribute *res_attr;
41520 + bin_attribute_no_const *res_attr;
41521 int retval;
41522
41523 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41524 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41525 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41526 {
41527 int retval;
41528 - struct bin_attribute *attr;
41529 + bin_attribute_no_const *attr;
41530
41531 /* If the device has VPD, try to expose it in sysfs. */
41532 if (dev->vpd) {
41533 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41534 {
41535 int retval;
41536 int rom_size = 0;
41537 - struct bin_attribute *attr;
41538 + bin_attribute_no_const *attr;
41539
41540 if (!sysfs_initialized)
41541 return -EACCES;
41542 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41543 index d1182c4..2a138ec 100644
41544 --- a/drivers/pci/pci.h
41545 +++ b/drivers/pci/pci.h
41546 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
41547 struct pci_vpd {
41548 unsigned int len;
41549 const struct pci_vpd_ops *ops;
41550 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41551 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41552 };
41553
41554 int pci_vpd_pci22_init(struct pci_dev *dev);
41555 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41556 index d320df6..ca9a8f6 100644
41557 --- a/drivers/pci/pcie/aspm.c
41558 +++ b/drivers/pci/pcie/aspm.c
41559 @@ -27,9 +27,9 @@
41560 #define MODULE_PARAM_PREFIX "pcie_aspm."
41561
41562 /* Note: those are not register definitions */
41563 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41564 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41565 -#define ASPM_STATE_L1 (4) /* L1 state */
41566 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41567 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41568 +#define ASPM_STATE_L1 (4U) /* L1 state */
41569 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41570 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41571
41572 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41573 index 70f10fa..cb5e917 100644
41574 --- a/drivers/pci/probe.c
41575 +++ b/drivers/pci/probe.c
41576 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41577 struct pci_bus_region region;
41578 bool bar_too_big = false, bar_disabled = false;
41579
41580 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41581 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41582
41583 /* No printks while decoding is disabled! */
41584 if (!dev->mmio_always_on) {
41585 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41586 index 0812608..b04018c4 100644
41587 --- a/drivers/pci/proc.c
41588 +++ b/drivers/pci/proc.c
41589 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41590 static int __init pci_proc_init(void)
41591 {
41592 struct pci_dev *dev = NULL;
41593 +
41594 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41595 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41596 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41597 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41598 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41599 +#endif
41600 +#else
41601 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41602 +#endif
41603 proc_create("devices", 0, proc_bus_pci_dir,
41604 &proc_bus_pci_dev_operations);
41605 proc_initialized = 1;
41606 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41607 index 3e5b4497..dcdfb70 100644
41608 --- a/drivers/platform/x86/chromeos_laptop.c
41609 +++ b/drivers/platform/x86/chromeos_laptop.c
41610 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41611 return 0;
41612 }
41613
41614 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41615 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41616 {
41617 .ident = "Samsung Series 5 550 - Touchpad",
41618 .matches = {
41619 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41620 index 6b22938..bc9700e 100644
41621 --- a/drivers/platform/x86/msi-laptop.c
41622 +++ b/drivers/platform/x86/msi-laptop.c
41623 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41624
41625 if (!quirks->ec_read_only) {
41626 /* allow userland write sysfs file */
41627 - dev_attr_bluetooth.store = store_bluetooth;
41628 - dev_attr_wlan.store = store_wlan;
41629 - dev_attr_threeg.store = store_threeg;
41630 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41631 - dev_attr_wlan.attr.mode |= S_IWUSR;
41632 - dev_attr_threeg.attr.mode |= S_IWUSR;
41633 + pax_open_kernel();
41634 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41635 + *(void **)&dev_attr_wlan.store = store_wlan;
41636 + *(void **)&dev_attr_threeg.store = store_threeg;
41637 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41638 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41639 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41640 + pax_close_kernel();
41641 }
41642
41643 /* disable hardware control by fn key */
41644 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41645 index 2ac045f..39c443d 100644
41646 --- a/drivers/platform/x86/sony-laptop.c
41647 +++ b/drivers/platform/x86/sony-laptop.c
41648 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41649 }
41650
41651 /* High speed charging function */
41652 -static struct device_attribute *hsc_handle;
41653 +static device_attribute_no_const *hsc_handle;
41654
41655 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41656 struct device_attribute *attr,
41657 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41658 index 54d31c0..3f896d3 100644
41659 --- a/drivers/platform/x86/thinkpad_acpi.c
41660 +++ b/drivers/platform/x86/thinkpad_acpi.c
41661 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41662 return 0;
41663 }
41664
41665 -void static hotkey_mask_warn_incomplete_mask(void)
41666 +static void hotkey_mask_warn_incomplete_mask(void)
41667 {
41668 /* log only what the user can fix... */
41669 const u32 wantedmask = hotkey_driver_mask &
41670 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41671 }
41672 }
41673
41674 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41675 - struct tp_nvram_state *newn,
41676 - const u32 event_mask)
41677 -{
41678 -
41679 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41680 do { \
41681 if ((event_mask & (1 << __scancode)) && \
41682 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41683 tpacpi_hotkey_send_key(__scancode); \
41684 } while (0)
41685
41686 - void issue_volchange(const unsigned int oldvol,
41687 - const unsigned int newvol)
41688 - {
41689 - unsigned int i = oldvol;
41690 +static void issue_volchange(const unsigned int oldvol,
41691 + const unsigned int newvol,
41692 + const u32 event_mask)
41693 +{
41694 + unsigned int i = oldvol;
41695
41696 - while (i > newvol) {
41697 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41698 - i--;
41699 - }
41700 - while (i < newvol) {
41701 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41702 - i++;
41703 - }
41704 + while (i > newvol) {
41705 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41706 + i--;
41707 }
41708 + while (i < newvol) {
41709 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41710 + i++;
41711 + }
41712 +}
41713
41714 - void issue_brightnesschange(const unsigned int oldbrt,
41715 - const unsigned int newbrt)
41716 - {
41717 - unsigned int i = oldbrt;
41718 +static void issue_brightnesschange(const unsigned int oldbrt,
41719 + const unsigned int newbrt,
41720 + const u32 event_mask)
41721 +{
41722 + unsigned int i = oldbrt;
41723
41724 - while (i > newbrt) {
41725 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41726 - i--;
41727 - }
41728 - while (i < newbrt) {
41729 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41730 - i++;
41731 - }
41732 + while (i > newbrt) {
41733 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41734 + i--;
41735 + }
41736 + while (i < newbrt) {
41737 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41738 + i++;
41739 }
41740 +}
41741
41742 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41743 + struct tp_nvram_state *newn,
41744 + const u32 event_mask)
41745 +{
41746 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41747 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41748 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41749 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41750 oldn->volume_level != newn->volume_level) {
41751 /* recently muted, or repeated mute keypress, or
41752 * multiple presses ending in mute */
41753 - issue_volchange(oldn->volume_level, newn->volume_level);
41754 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41755 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41756 }
41757 } else {
41758 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41759 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41760 }
41761 if (oldn->volume_level != newn->volume_level) {
41762 - issue_volchange(oldn->volume_level, newn->volume_level);
41763 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41764 } else if (oldn->volume_toggle != newn->volume_toggle) {
41765 /* repeated vol up/down keypress at end of scale ? */
41766 if (newn->volume_level == 0)
41767 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41768 /* handle brightness */
41769 if (oldn->brightness_level != newn->brightness_level) {
41770 issue_brightnesschange(oldn->brightness_level,
41771 - newn->brightness_level);
41772 + newn->brightness_level,
41773 + event_mask);
41774 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41775 /* repeated key presses that didn't change state */
41776 if (newn->brightness_level == 0)
41777 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41778 && !tp_features.bright_unkfw)
41779 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41780 }
41781 +}
41782
41783 #undef TPACPI_COMPARE_KEY
41784 #undef TPACPI_MAY_SEND_KEY
41785 -}
41786
41787 /*
41788 * Polling driver
41789 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41790 index 769d265..a3a05ca 100644
41791 --- a/drivers/pnp/pnpbios/bioscalls.c
41792 +++ b/drivers/pnp/pnpbios/bioscalls.c
41793 @@ -58,7 +58,7 @@ do { \
41794 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41795 } while(0)
41796
41797 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41798 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41799 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41800
41801 /*
41802 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41803
41804 cpu = get_cpu();
41805 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41806 +
41807 + pax_open_kernel();
41808 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41809 + pax_close_kernel();
41810
41811 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41812 spin_lock_irqsave(&pnp_bios_lock, flags);
41813 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41814 :"memory");
41815 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41816
41817 + pax_open_kernel();
41818 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41819 + pax_close_kernel();
41820 +
41821 put_cpu();
41822
41823 /* If we get here and this is set then the PnP BIOS faulted on us. */
41824 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41825 return status;
41826 }
41827
41828 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41829 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41830 {
41831 int i;
41832
41833 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41834 pnp_bios_callpoint.offset = header->fields.pm16offset;
41835 pnp_bios_callpoint.segment = PNP_CS16;
41836
41837 + pax_open_kernel();
41838 +
41839 for_each_possible_cpu(i) {
41840 struct desc_struct *gdt = get_cpu_gdt_table(i);
41841 if (!gdt)
41842 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41843 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41844 (unsigned long)__va(header->fields.pm16dseg));
41845 }
41846 +
41847 + pax_close_kernel();
41848 }
41849 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41850 index 3e6db1c..1fbbdae 100644
41851 --- a/drivers/pnp/resource.c
41852 +++ b/drivers/pnp/resource.c
41853 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41854 return 1;
41855
41856 /* check if the resource is valid */
41857 - if (*irq < 0 || *irq > 15)
41858 + if (*irq > 15)
41859 return 0;
41860
41861 /* check if the resource is reserved */
41862 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41863 return 1;
41864
41865 /* check if the resource is valid */
41866 - if (*dma < 0 || *dma == 4 || *dma > 7)
41867 + if (*dma == 4 || *dma > 7)
41868 return 0;
41869
41870 /* check if the resource is reserved */
41871 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41872 index 0c52e2a..3421ab7 100644
41873 --- a/drivers/power/pda_power.c
41874 +++ b/drivers/power/pda_power.c
41875 @@ -37,7 +37,11 @@ static int polling;
41876
41877 #if IS_ENABLED(CONFIG_USB_PHY)
41878 static struct usb_phy *transceiver;
41879 -static struct notifier_block otg_nb;
41880 +static int otg_handle_notification(struct notifier_block *nb,
41881 + unsigned long event, void *unused);
41882 +static struct notifier_block otg_nb = {
41883 + .notifier_call = otg_handle_notification
41884 +};
41885 #endif
41886
41887 static struct regulator *ac_draw;
41888 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41889
41890 #if IS_ENABLED(CONFIG_USB_PHY)
41891 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41892 - otg_nb.notifier_call = otg_handle_notification;
41893 ret = usb_register_notifier(transceiver, &otg_nb);
41894 if (ret) {
41895 dev_err(dev, "failure to register otg notifier\n");
41896 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41897 index cc439fd..8fa30df 100644
41898 --- a/drivers/power/power_supply.h
41899 +++ b/drivers/power/power_supply.h
41900 @@ -16,12 +16,12 @@ struct power_supply;
41901
41902 #ifdef CONFIG_SYSFS
41903
41904 -extern void power_supply_init_attrs(struct device_type *dev_type);
41905 +extern void power_supply_init_attrs(void);
41906 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41907
41908 #else
41909
41910 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41911 +static inline void power_supply_init_attrs(void) {}
41912 #define power_supply_uevent NULL
41913
41914 #endif /* CONFIG_SYSFS */
41915 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41916 index 1c517c3..ffa2f17 100644
41917 --- a/drivers/power/power_supply_core.c
41918 +++ b/drivers/power/power_supply_core.c
41919 @@ -24,7 +24,10 @@
41920 struct class *power_supply_class;
41921 EXPORT_SYMBOL_GPL(power_supply_class);
41922
41923 -static struct device_type power_supply_dev_type;
41924 +extern const struct attribute_group *power_supply_attr_groups[];
41925 +static struct device_type power_supply_dev_type = {
41926 + .groups = power_supply_attr_groups,
41927 +};
41928
41929 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
41930 struct power_supply *supply)
41931 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
41932 return PTR_ERR(power_supply_class);
41933
41934 power_supply_class->dev_uevent = power_supply_uevent;
41935 - power_supply_init_attrs(&power_supply_dev_type);
41936 + power_supply_init_attrs();
41937
41938 return 0;
41939 }
41940 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41941 index 29178f7..c65f324 100644
41942 --- a/drivers/power/power_supply_sysfs.c
41943 +++ b/drivers/power/power_supply_sysfs.c
41944 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41945 .is_visible = power_supply_attr_is_visible,
41946 };
41947
41948 -static const struct attribute_group *power_supply_attr_groups[] = {
41949 +const struct attribute_group *power_supply_attr_groups[] = {
41950 &power_supply_attr_group,
41951 NULL,
41952 };
41953
41954 -void power_supply_init_attrs(struct device_type *dev_type)
41955 +void power_supply_init_attrs(void)
41956 {
41957 int i;
41958
41959 - dev_type->groups = power_supply_attr_groups;
41960 -
41961 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41962 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41963 }
41964 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41965 index d428ef9..fdc0357 100644
41966 --- a/drivers/regulator/max8660.c
41967 +++ b/drivers/regulator/max8660.c
41968 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41969 max8660->shadow_regs[MAX8660_OVER1] = 5;
41970 } else {
41971 /* Otherwise devices can be toggled via software */
41972 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41973 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41974 + pax_open_kernel();
41975 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41976 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41977 + pax_close_kernel();
41978 }
41979
41980 /*
41981 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41982 index adb1414..c13e0ce 100644
41983 --- a/drivers/regulator/max8973-regulator.c
41984 +++ b/drivers/regulator/max8973-regulator.c
41985 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41986 if (!pdata->enable_ext_control) {
41987 max->desc.enable_reg = MAX8973_VOUT;
41988 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41989 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41990 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41991 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41992 + pax_open_kernel();
41993 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41994 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41995 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41996 + pax_close_kernel();
41997 }
41998
41999 max->enable_external_control = pdata->enable_ext_control;
42000 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
42001 index b716283..3cc4349 100644
42002 --- a/drivers/regulator/mc13892-regulator.c
42003 +++ b/drivers/regulator/mc13892-regulator.c
42004 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
42005 }
42006 mc13xxx_unlock(mc13892);
42007
42008 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42009 + pax_open_kernel();
42010 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42011 = mc13892_vcam_set_mode;
42012 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42013 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42014 = mc13892_vcam_get_mode;
42015 + pax_close_kernel();
42016
42017 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
42018 ARRAY_SIZE(mc13892_regulators));
42019 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
42020 index f1cb706..4c7832a 100644
42021 --- a/drivers/rtc/rtc-cmos.c
42022 +++ b/drivers/rtc/rtc-cmos.c
42023 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
42024 hpet_rtc_timer_init();
42025
42026 /* export at least the first block of NVRAM */
42027 - nvram.size = address_space - NVRAM_OFFSET;
42028 + pax_open_kernel();
42029 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
42030 + pax_close_kernel();
42031 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
42032 if (retval < 0) {
42033 dev_dbg(dev, "can't create nvram file? %d\n", retval);
42034 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
42035 index d049393..bb20be0 100644
42036 --- a/drivers/rtc/rtc-dev.c
42037 +++ b/drivers/rtc/rtc-dev.c
42038 @@ -16,6 +16,7 @@
42039 #include <linux/module.h>
42040 #include <linux/rtc.h>
42041 #include <linux/sched.h>
42042 +#include <linux/grsecurity.h>
42043 #include "rtc-core.h"
42044
42045 static dev_t rtc_devt;
42046 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
42047 if (copy_from_user(&tm, uarg, sizeof(tm)))
42048 return -EFAULT;
42049
42050 + gr_log_timechange();
42051 +
42052 return rtc_set_time(rtc, &tm);
42053
42054 case RTC_PIE_ON:
42055 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
42056 index b53992a..776df84 100644
42057 --- a/drivers/rtc/rtc-ds1307.c
42058 +++ b/drivers/rtc/rtc-ds1307.c
42059 @@ -107,7 +107,7 @@ struct ds1307 {
42060 u8 offset; /* register's offset */
42061 u8 regs[11];
42062 u16 nvram_offset;
42063 - struct bin_attribute *nvram;
42064 + bin_attribute_no_const *nvram;
42065 enum ds_type type;
42066 unsigned long flags;
42067 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
42068 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
42069 index 130f29a..6179d03 100644
42070 --- a/drivers/rtc/rtc-m48t59.c
42071 +++ b/drivers/rtc/rtc-m48t59.c
42072 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
42073 goto out;
42074 }
42075
42076 - m48t59_nvram_attr.size = pdata->offset;
42077 + pax_open_kernel();
42078 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42079 + pax_close_kernel();
42080
42081 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42082 if (ret) {
42083 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42084 index e693af6..2e525b6 100644
42085 --- a/drivers/scsi/bfa/bfa_fcpim.h
42086 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42087 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42088
42089 struct bfa_itn_s {
42090 bfa_isr_func_t isr;
42091 -};
42092 +} __no_const;
42093
42094 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42095 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42096 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42097 index 23a90e7..9cf04ee 100644
42098 --- a/drivers/scsi/bfa/bfa_ioc.h
42099 +++ b/drivers/scsi/bfa/bfa_ioc.h
42100 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42101 bfa_ioc_disable_cbfn_t disable_cbfn;
42102 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42103 bfa_ioc_reset_cbfn_t reset_cbfn;
42104 -};
42105 +} __no_const;
42106
42107 /*
42108 * IOC event notification mechanism.
42109 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42110 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42111 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42112 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42113 -};
42114 +} __no_const;
42115
42116 /*
42117 * Queue element to wait for room in request queue. FIFO order is
42118 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42119 index df0c3c7..b00e1d0 100644
42120 --- a/drivers/scsi/hosts.c
42121 +++ b/drivers/scsi/hosts.c
42122 @@ -42,7 +42,7 @@
42123 #include "scsi_logging.h"
42124
42125
42126 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42127 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42128
42129
42130 static void scsi_host_cls_release(struct device *dev)
42131 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42132 * subtract one because we increment first then return, but we need to
42133 * know what the next host number was before increment
42134 */
42135 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42136 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42137 shost->dma_channel = 0xff;
42138
42139 /* These three are default values which can be overridden */
42140 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42141 index 7f4f790..b75b92a 100644
42142 --- a/drivers/scsi/hpsa.c
42143 +++ b/drivers/scsi/hpsa.c
42144 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42145 unsigned long flags;
42146
42147 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42148 - return h->access.command_completed(h, q);
42149 + return h->access->command_completed(h, q);
42150
42151 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42152 a = rq->head[rq->current_entry];
42153 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42154 while (!list_empty(&h->reqQ)) {
42155 c = list_entry(h->reqQ.next, struct CommandList, list);
42156 /* can't do anything if fifo is full */
42157 - if ((h->access.fifo_full(h))) {
42158 + if ((h->access->fifo_full(h))) {
42159 dev_warn(&h->pdev->dev, "fifo full\n");
42160 break;
42161 }
42162 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42163
42164 /* Tell the controller execute command */
42165 spin_unlock_irqrestore(&h->lock, flags);
42166 - h->access.submit_command(h, c);
42167 + h->access->submit_command(h, c);
42168 spin_lock_irqsave(&h->lock, flags);
42169 }
42170 spin_unlock_irqrestore(&h->lock, flags);
42171 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42172
42173 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42174 {
42175 - return h->access.command_completed(h, q);
42176 + return h->access->command_completed(h, q);
42177 }
42178
42179 static inline bool interrupt_pending(struct ctlr_info *h)
42180 {
42181 - return h->access.intr_pending(h);
42182 + return h->access->intr_pending(h);
42183 }
42184
42185 static inline long interrupt_not_for_us(struct ctlr_info *h)
42186 {
42187 - return (h->access.intr_pending(h) == 0) ||
42188 + return (h->access->intr_pending(h) == 0) ||
42189 (h->interrupts_enabled == 0);
42190 }
42191
42192 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42193 if (prod_index < 0)
42194 return -ENODEV;
42195 h->product_name = products[prod_index].product_name;
42196 - h->access = *(products[prod_index].access);
42197 + h->access = products[prod_index].access;
42198
42199 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42200 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42201 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42202
42203 assert_spin_locked(&lockup_detector_lock);
42204 remove_ctlr_from_lockup_detector_list(h);
42205 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42206 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42207 spin_lock_irqsave(&h->lock, flags);
42208 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42209 spin_unlock_irqrestore(&h->lock, flags);
42210 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42211 }
42212
42213 /* make sure the board interrupts are off */
42214 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42215 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42216
42217 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42218 goto clean2;
42219 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42220 * fake ones to scoop up any residual completions.
42221 */
42222 spin_lock_irqsave(&h->lock, flags);
42223 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42224 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42225 spin_unlock_irqrestore(&h->lock, flags);
42226 free_irqs(h);
42227 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42228 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42229 dev_info(&h->pdev->dev, "Board READY.\n");
42230 dev_info(&h->pdev->dev,
42231 "Waiting for stale completions to drain.\n");
42232 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42233 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42234 msleep(10000);
42235 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42236 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42237
42238 rc = controller_reset_failed(h->cfgtable);
42239 if (rc)
42240 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42241 }
42242
42243 /* Turn the interrupts on so we can service requests */
42244 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42245 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42246
42247 hpsa_hba_inquiry(h);
42248 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42249 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42250 * To write all data in the battery backed cache to disks
42251 */
42252 hpsa_flush_cache(h);
42253 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42254 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42255 hpsa_free_irqs_and_disable_msix(h);
42256 }
42257
42258 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42259 return;
42260 }
42261 /* Change the access methods to the performant access methods */
42262 - h->access = SA5_performant_access;
42263 + h->access = &SA5_performant_access;
42264 h->transMethod = CFGTBL_Trans_Performant;
42265 }
42266
42267 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42268 index 9816479..c5d4e97 100644
42269 --- a/drivers/scsi/hpsa.h
42270 +++ b/drivers/scsi/hpsa.h
42271 @@ -79,7 +79,7 @@ struct ctlr_info {
42272 unsigned int msix_vector;
42273 unsigned int msi_vector;
42274 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42275 - struct access_method access;
42276 + struct access_method *access;
42277
42278 /* queue and queue Info */
42279 struct list_head reqQ;
42280 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42281 index 8b928c6..9c76300 100644
42282 --- a/drivers/scsi/libfc/fc_exch.c
42283 +++ b/drivers/scsi/libfc/fc_exch.c
42284 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42285 u16 pool_max_index;
42286
42287 struct {
42288 - atomic_t no_free_exch;
42289 - atomic_t no_free_exch_xid;
42290 - atomic_t xid_not_found;
42291 - atomic_t xid_busy;
42292 - atomic_t seq_not_found;
42293 - atomic_t non_bls_resp;
42294 + atomic_unchecked_t no_free_exch;
42295 + atomic_unchecked_t no_free_exch_xid;
42296 + atomic_unchecked_t xid_not_found;
42297 + atomic_unchecked_t xid_busy;
42298 + atomic_unchecked_t seq_not_found;
42299 + atomic_unchecked_t non_bls_resp;
42300 } stats;
42301 };
42302
42303 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42304 /* allocate memory for exchange */
42305 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42306 if (!ep) {
42307 - atomic_inc(&mp->stats.no_free_exch);
42308 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42309 goto out;
42310 }
42311 memset(ep, 0, sizeof(*ep));
42312 @@ -797,7 +797,7 @@ out:
42313 return ep;
42314 err:
42315 spin_unlock_bh(&pool->lock);
42316 - atomic_inc(&mp->stats.no_free_exch_xid);
42317 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42318 mempool_free(ep, mp->ep_pool);
42319 return NULL;
42320 }
42321 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42322 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42323 ep = fc_exch_find(mp, xid);
42324 if (!ep) {
42325 - atomic_inc(&mp->stats.xid_not_found);
42326 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42327 reject = FC_RJT_OX_ID;
42328 goto out;
42329 }
42330 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42331 ep = fc_exch_find(mp, xid);
42332 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42333 if (ep) {
42334 - atomic_inc(&mp->stats.xid_busy);
42335 + atomic_inc_unchecked(&mp->stats.xid_busy);
42336 reject = FC_RJT_RX_ID;
42337 goto rel;
42338 }
42339 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42340 }
42341 xid = ep->xid; /* get our XID */
42342 } else if (!ep) {
42343 - atomic_inc(&mp->stats.xid_not_found);
42344 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42345 reject = FC_RJT_RX_ID; /* XID not found */
42346 goto out;
42347 }
42348 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42349 } else {
42350 sp = &ep->seq;
42351 if (sp->id != fh->fh_seq_id) {
42352 - atomic_inc(&mp->stats.seq_not_found);
42353 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42354 if (f_ctl & FC_FC_END_SEQ) {
42355 /*
42356 * Update sequence_id based on incoming last
42357 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42358
42359 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42360 if (!ep) {
42361 - atomic_inc(&mp->stats.xid_not_found);
42362 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42363 goto out;
42364 }
42365 if (ep->esb_stat & ESB_ST_COMPLETE) {
42366 - atomic_inc(&mp->stats.xid_not_found);
42367 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42368 goto rel;
42369 }
42370 if (ep->rxid == FC_XID_UNKNOWN)
42371 ep->rxid = ntohs(fh->fh_rx_id);
42372 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42373 - atomic_inc(&mp->stats.xid_not_found);
42374 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42375 goto rel;
42376 }
42377 if (ep->did != ntoh24(fh->fh_s_id) &&
42378 ep->did != FC_FID_FLOGI) {
42379 - atomic_inc(&mp->stats.xid_not_found);
42380 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42381 goto rel;
42382 }
42383 sof = fr_sof(fp);
42384 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42385 sp->ssb_stat |= SSB_ST_RESP;
42386 sp->id = fh->fh_seq_id;
42387 } else if (sp->id != fh->fh_seq_id) {
42388 - atomic_inc(&mp->stats.seq_not_found);
42389 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42390 goto rel;
42391 }
42392
42393 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42394 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42395
42396 if (!sp)
42397 - atomic_inc(&mp->stats.xid_not_found);
42398 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42399 else
42400 - atomic_inc(&mp->stats.non_bls_resp);
42401 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42402
42403 fc_frame_free(fp);
42404 }
42405 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42406
42407 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42408 mp = ema->mp;
42409 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42410 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42411 st->fc_no_free_exch_xid +=
42412 - atomic_read(&mp->stats.no_free_exch_xid);
42413 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42414 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42415 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42416 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42417 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42418 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42419 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42420 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42421 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42422 }
42423 }
42424 EXPORT_SYMBOL(fc_exch_update_stats);
42425 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42426 index 161c98e..6d563b3 100644
42427 --- a/drivers/scsi/libsas/sas_ata.c
42428 +++ b/drivers/scsi/libsas/sas_ata.c
42429 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42430 .postreset = ata_std_postreset,
42431 .error_handler = ata_std_error_handler,
42432 .post_internal_cmd = sas_ata_post_internal,
42433 - .qc_defer = ata_std_qc_defer,
42434 + .qc_defer = ata_std_qc_defer,
42435 .qc_prep = ata_noop_qc_prep,
42436 .qc_issue = sas_ata_qc_issue,
42437 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42438 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42439 index bcc56ca..6f4174a 100644
42440 --- a/drivers/scsi/lpfc/lpfc.h
42441 +++ b/drivers/scsi/lpfc/lpfc.h
42442 @@ -431,7 +431,7 @@ struct lpfc_vport {
42443 struct dentry *debug_nodelist;
42444 struct dentry *vport_debugfs_root;
42445 struct lpfc_debugfs_trc *disc_trc;
42446 - atomic_t disc_trc_cnt;
42447 + atomic_unchecked_t disc_trc_cnt;
42448 #endif
42449 uint8_t stat_data_enabled;
42450 uint8_t stat_data_blocked;
42451 @@ -865,8 +865,8 @@ struct lpfc_hba {
42452 struct timer_list fabric_block_timer;
42453 unsigned long bit_flags;
42454 #define FABRIC_COMANDS_BLOCKED 0
42455 - atomic_t num_rsrc_err;
42456 - atomic_t num_cmd_success;
42457 + atomic_unchecked_t num_rsrc_err;
42458 + atomic_unchecked_t num_cmd_success;
42459 unsigned long last_rsrc_error_time;
42460 unsigned long last_ramp_down_time;
42461 unsigned long last_ramp_up_time;
42462 @@ -902,7 +902,7 @@ struct lpfc_hba {
42463
42464 struct dentry *debug_slow_ring_trc;
42465 struct lpfc_debugfs_trc *slow_ring_trc;
42466 - atomic_t slow_ring_trc_cnt;
42467 + atomic_unchecked_t slow_ring_trc_cnt;
42468 /* iDiag debugfs sub-directory */
42469 struct dentry *idiag_root;
42470 struct dentry *idiag_pci_cfg;
42471 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42472 index f525ecb..32549a4 100644
42473 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42474 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42475 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42476
42477 #include <linux/debugfs.h>
42478
42479 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42480 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42481 static unsigned long lpfc_debugfs_start_time = 0L;
42482
42483 /* iDiag */
42484 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42485 lpfc_debugfs_enable = 0;
42486
42487 len = 0;
42488 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42489 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42490 (lpfc_debugfs_max_disc_trc - 1);
42491 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42492 dtp = vport->disc_trc + i;
42493 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42494 lpfc_debugfs_enable = 0;
42495
42496 len = 0;
42497 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42498 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42499 (lpfc_debugfs_max_slow_ring_trc - 1);
42500 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42501 dtp = phba->slow_ring_trc + i;
42502 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42503 !vport || !vport->disc_trc)
42504 return;
42505
42506 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42507 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42508 (lpfc_debugfs_max_disc_trc - 1);
42509 dtp = vport->disc_trc + index;
42510 dtp->fmt = fmt;
42511 dtp->data1 = data1;
42512 dtp->data2 = data2;
42513 dtp->data3 = data3;
42514 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42515 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42516 dtp->jif = jiffies;
42517 #endif
42518 return;
42519 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42520 !phba || !phba->slow_ring_trc)
42521 return;
42522
42523 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42524 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42525 (lpfc_debugfs_max_slow_ring_trc - 1);
42526 dtp = phba->slow_ring_trc + index;
42527 dtp->fmt = fmt;
42528 dtp->data1 = data1;
42529 dtp->data2 = data2;
42530 dtp->data3 = data3;
42531 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42532 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42533 dtp->jif = jiffies;
42534 #endif
42535 return;
42536 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42537 "slow_ring buffer\n");
42538 goto debug_failed;
42539 }
42540 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42541 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42542 memset(phba->slow_ring_trc, 0,
42543 (sizeof(struct lpfc_debugfs_trc) *
42544 lpfc_debugfs_max_slow_ring_trc));
42545 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42546 "buffer\n");
42547 goto debug_failed;
42548 }
42549 - atomic_set(&vport->disc_trc_cnt, 0);
42550 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42551
42552 snprintf(name, sizeof(name), "discovery_trace");
42553 vport->debug_disc_trc =
42554 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42555 index cb465b2..2e7b25f 100644
42556 --- a/drivers/scsi/lpfc/lpfc_init.c
42557 +++ b/drivers/scsi/lpfc/lpfc_init.c
42558 @@ -10950,8 +10950,10 @@ lpfc_init(void)
42559 "misc_register returned with status %d", error);
42560
42561 if (lpfc_enable_npiv) {
42562 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42563 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42564 + pax_open_kernel();
42565 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42566 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42567 + pax_close_kernel();
42568 }
42569 lpfc_transport_template =
42570 fc_attach_transport(&lpfc_transport_functions);
42571 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42572 index 8523b278e..ce1d812 100644
42573 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42574 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42575 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42576 uint32_t evt_posted;
42577
42578 spin_lock_irqsave(&phba->hbalock, flags);
42579 - atomic_inc(&phba->num_rsrc_err);
42580 + atomic_inc_unchecked(&phba->num_rsrc_err);
42581 phba->last_rsrc_error_time = jiffies;
42582
42583 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42584 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42585 unsigned long flags;
42586 struct lpfc_hba *phba = vport->phba;
42587 uint32_t evt_posted;
42588 - atomic_inc(&phba->num_cmd_success);
42589 + atomic_inc_unchecked(&phba->num_cmd_success);
42590
42591 if (vport->cfg_lun_queue_depth <= queue_depth)
42592 return;
42593 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42594 unsigned long num_rsrc_err, num_cmd_success;
42595 int i;
42596
42597 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42598 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42599 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42600 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42601
42602 /*
42603 * The error and success command counters are global per
42604 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42605 }
42606 }
42607 lpfc_destroy_vport_work_array(phba, vports);
42608 - atomic_set(&phba->num_rsrc_err, 0);
42609 - atomic_set(&phba->num_cmd_success, 0);
42610 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42611 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42612 }
42613
42614 /**
42615 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42616 }
42617 }
42618 lpfc_destroy_vport_work_array(phba, vports);
42619 - atomic_set(&phba->num_rsrc_err, 0);
42620 - atomic_set(&phba->num_cmd_success, 0);
42621 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42622 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42623 }
42624
42625 /**
42626 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42627 index 8e1b737..50ff510 100644
42628 --- a/drivers/scsi/pmcraid.c
42629 +++ b/drivers/scsi/pmcraid.c
42630 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42631 res->scsi_dev = scsi_dev;
42632 scsi_dev->hostdata = res;
42633 res->change_detected = 0;
42634 - atomic_set(&res->read_failures, 0);
42635 - atomic_set(&res->write_failures, 0);
42636 + atomic_set_unchecked(&res->read_failures, 0);
42637 + atomic_set_unchecked(&res->write_failures, 0);
42638 rc = 0;
42639 }
42640 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42641 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42642
42643 /* If this was a SCSI read/write command keep count of errors */
42644 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42645 - atomic_inc(&res->read_failures);
42646 + atomic_inc_unchecked(&res->read_failures);
42647 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42648 - atomic_inc(&res->write_failures);
42649 + atomic_inc_unchecked(&res->write_failures);
42650
42651 if (!RES_IS_GSCSI(res->cfg_entry) &&
42652 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42653 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42654 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42655 * hrrq_id assigned here in queuecommand
42656 */
42657 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42658 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42659 pinstance->num_hrrq;
42660 cmd->cmd_done = pmcraid_io_done;
42661
42662 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
42663 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42664 * hrrq_id assigned here in queuecommand
42665 */
42666 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42667 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42668 pinstance->num_hrrq;
42669
42670 if (request_size) {
42671 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42672
42673 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42674 /* add resources only after host is added into system */
42675 - if (!atomic_read(&pinstance->expose_resources))
42676 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42677 return;
42678
42679 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42680 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42681 init_waitqueue_head(&pinstance->reset_wait_q);
42682
42683 atomic_set(&pinstance->outstanding_cmds, 0);
42684 - atomic_set(&pinstance->last_message_id, 0);
42685 - atomic_set(&pinstance->expose_resources, 0);
42686 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42687 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42688
42689 INIT_LIST_HEAD(&pinstance->free_res_q);
42690 INIT_LIST_HEAD(&pinstance->used_res_q);
42691 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42692 /* Schedule worker thread to handle CCN and take care of adding and
42693 * removing devices to OS
42694 */
42695 - atomic_set(&pinstance->expose_resources, 1);
42696 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42697 schedule_work(&pinstance->worker_q);
42698 return rc;
42699
42700 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42701 index e1d150f..6c6df44 100644
42702 --- a/drivers/scsi/pmcraid.h
42703 +++ b/drivers/scsi/pmcraid.h
42704 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42705 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42706
42707 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42708 - atomic_t last_message_id;
42709 + atomic_unchecked_t last_message_id;
42710
42711 /* configuration table */
42712 struct pmcraid_config_table *cfg_table;
42713 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42714 atomic_t outstanding_cmds;
42715
42716 /* should add/delete resources to mid-layer now ?*/
42717 - atomic_t expose_resources;
42718 + atomic_unchecked_t expose_resources;
42719
42720
42721
42722 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42723 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42724 };
42725 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42726 - atomic_t read_failures; /* count of failed READ commands */
42727 - atomic_t write_failures; /* count of failed WRITE commands */
42728 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42729 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42730
42731 /* To indicate add/delete/modify during CCN */
42732 u8 change_detected;
42733 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42734 index bf60c63..74d4dce 100644
42735 --- a/drivers/scsi/qla2xxx/qla_attr.c
42736 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42737 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42738 return 0;
42739 }
42740
42741 -struct fc_function_template qla2xxx_transport_functions = {
42742 +fc_function_template_no_const qla2xxx_transport_functions = {
42743
42744 .show_host_node_name = 1,
42745 .show_host_port_name = 1,
42746 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42747 .bsg_timeout = qla24xx_bsg_timeout,
42748 };
42749
42750 -struct fc_function_template qla2xxx_transport_vport_functions = {
42751 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42752
42753 .show_host_node_name = 1,
42754 .show_host_port_name = 1,
42755 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42756 index 026bfde..90c4018 100644
42757 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42758 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42759 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42760 struct device_attribute;
42761 extern struct device_attribute *qla2x00_host_attrs[];
42762 struct fc_function_template;
42763 -extern struct fc_function_template qla2xxx_transport_functions;
42764 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42765 +extern fc_function_template_no_const qla2xxx_transport_functions;
42766 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42767 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42768 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42769 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42770 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42771 index ad72c1d..afc9a98 100644
42772 --- a/drivers/scsi/qla2xxx/qla_os.c
42773 +++ b/drivers/scsi/qla2xxx/qla_os.c
42774 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42775 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42776 /* Ok, a 64bit DMA mask is applicable. */
42777 ha->flags.enable_64bit_addressing = 1;
42778 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42779 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42780 + pax_open_kernel();
42781 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42782 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42783 + pax_close_kernel();
42784 return;
42785 }
42786 }
42787 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42788 index ddf16a8..80f4dd0 100644
42789 --- a/drivers/scsi/qla4xxx/ql4_def.h
42790 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42791 @@ -291,7 +291,7 @@ struct ddb_entry {
42792 * (4000 only) */
42793 atomic_t relogin_timer; /* Max Time to wait for
42794 * relogin to complete */
42795 - atomic_t relogin_retry_count; /* Num of times relogin has been
42796 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42797 * retried */
42798 uint32_t default_time2wait; /* Default Min time between
42799 * relogins (+aens) */
42800 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42801 index 4d231c1..2892c37 100644
42802 --- a/drivers/scsi/qla4xxx/ql4_os.c
42803 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42804 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42805 */
42806 if (!iscsi_is_session_online(cls_sess)) {
42807 /* Reset retry relogin timer */
42808 - atomic_inc(&ddb_entry->relogin_retry_count);
42809 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42810 DEBUG2(ql4_printk(KERN_INFO, ha,
42811 "%s: index[%d] relogin timed out-retrying"
42812 " relogin (%d), retry (%d)\n", __func__,
42813 ddb_entry->fw_ddb_index,
42814 - atomic_read(&ddb_entry->relogin_retry_count),
42815 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42816 ddb_entry->default_time2wait + 4));
42817 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42818 atomic_set(&ddb_entry->retry_relogin_timer,
42819 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42820
42821 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42822 atomic_set(&ddb_entry->relogin_timer, 0);
42823 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42824 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42825 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42826 ddb_entry->default_relogin_timeout =
42827 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42828 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42829 index 2c0d0ec..4e8681a 100644
42830 --- a/drivers/scsi/scsi.c
42831 +++ b/drivers/scsi/scsi.c
42832 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42833 unsigned long timeout;
42834 int rtn = 0;
42835
42836 - atomic_inc(&cmd->device->iorequest_cnt);
42837 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42838
42839 /* check if the device is still usable */
42840 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42841 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42842 index 86d5220..f22c51a 100644
42843 --- a/drivers/scsi/scsi_lib.c
42844 +++ b/drivers/scsi/scsi_lib.c
42845 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42846 shost = sdev->host;
42847 scsi_init_cmd_errh(cmd);
42848 cmd->result = DID_NO_CONNECT << 16;
42849 - atomic_inc(&cmd->device->iorequest_cnt);
42850 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42851
42852 /*
42853 * SCSI request completion path will do scsi_device_unbusy(),
42854 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
42855
42856 INIT_LIST_HEAD(&cmd->eh_entry);
42857
42858 - atomic_inc(&cmd->device->iodone_cnt);
42859 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42860 if (cmd->result)
42861 - atomic_inc(&cmd->device->ioerr_cnt);
42862 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42863
42864 disposition = scsi_decide_disposition(cmd);
42865 if (disposition != SUCCESS &&
42866 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42867 index 931a7d9..0c2a754 100644
42868 --- a/drivers/scsi/scsi_sysfs.c
42869 +++ b/drivers/scsi/scsi_sysfs.c
42870 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42871 char *buf) \
42872 { \
42873 struct scsi_device *sdev = to_scsi_device(dev); \
42874 - unsigned long long count = atomic_read(&sdev->field); \
42875 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42876 return snprintf(buf, 20, "0x%llx\n", count); \
42877 } \
42878 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42879 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42880 index 84a1fdf..693b0d6 100644
42881 --- a/drivers/scsi/scsi_tgt_lib.c
42882 +++ b/drivers/scsi/scsi_tgt_lib.c
42883 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42884 int err;
42885
42886 dprintk("%lx %u\n", uaddr, len);
42887 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42888 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42889 if (err) {
42890 /*
42891 * TODO: need to fixup sg_tablesize, max_segment_size,
42892 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42893 index e106c27..11a380e 100644
42894 --- a/drivers/scsi/scsi_transport_fc.c
42895 +++ b/drivers/scsi/scsi_transport_fc.c
42896 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42897 * Netlink Infrastructure
42898 */
42899
42900 -static atomic_t fc_event_seq;
42901 +static atomic_unchecked_t fc_event_seq;
42902
42903 /**
42904 * fc_get_event_number - Obtain the next sequential FC event number
42905 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
42906 u32
42907 fc_get_event_number(void)
42908 {
42909 - return atomic_add_return(1, &fc_event_seq);
42910 + return atomic_add_return_unchecked(1, &fc_event_seq);
42911 }
42912 EXPORT_SYMBOL(fc_get_event_number);
42913
42914 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
42915 {
42916 int error;
42917
42918 - atomic_set(&fc_event_seq, 0);
42919 + atomic_set_unchecked(&fc_event_seq, 0);
42920
42921 error = transport_class_register(&fc_host_class);
42922 if (error)
42923 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42924 char *cp;
42925
42926 *val = simple_strtoul(buf, &cp, 0);
42927 - if ((*cp && (*cp != '\n')) || (*val < 0))
42928 + if (*cp && (*cp != '\n'))
42929 return -EINVAL;
42930 /*
42931 * Check for overflow; dev_loss_tmo is u32
42932 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42933 index 133926b..903000d 100644
42934 --- a/drivers/scsi/scsi_transport_iscsi.c
42935 +++ b/drivers/scsi/scsi_transport_iscsi.c
42936 @@ -80,7 +80,7 @@ struct iscsi_internal {
42937 struct transport_container session_cont;
42938 };
42939
42940 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42941 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42942 static struct workqueue_struct *iscsi_eh_timer_workq;
42943
42944 static DEFINE_IDA(iscsi_sess_ida);
42945 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42946 int err;
42947
42948 ihost = shost->shost_data;
42949 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42950 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42951
42952 if (target_id == ISCSI_MAX_TARGET) {
42953 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42954 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
42955 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42956 ISCSI_TRANSPORT_VERSION);
42957
42958 - atomic_set(&iscsi_session_nr, 0);
42959 + atomic_set_unchecked(&iscsi_session_nr, 0);
42960
42961 err = class_register(&iscsi_transport_class);
42962 if (err)
42963 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42964 index f379c7f..e8fc69c 100644
42965 --- a/drivers/scsi/scsi_transport_srp.c
42966 +++ b/drivers/scsi/scsi_transport_srp.c
42967 @@ -33,7 +33,7 @@
42968 #include "scsi_transport_srp_internal.h"
42969
42970 struct srp_host_attrs {
42971 - atomic_t next_port_id;
42972 + atomic_unchecked_t next_port_id;
42973 };
42974 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42975
42976 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42977 struct Scsi_Host *shost = dev_to_shost(dev);
42978 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42979
42980 - atomic_set(&srp_host->next_port_id, 0);
42981 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42982 return 0;
42983 }
42984
42985 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42986 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42987 rport->roles = ids->roles;
42988
42989 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42990 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42991 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42992
42993 transport_setup_device(&rport->dev);
42994 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42995 index 6f6a1b4..80704a9 100644
42996 --- a/drivers/scsi/sd.c
42997 +++ b/drivers/scsi/sd.c
42998 @@ -2918,7 +2918,7 @@ static int sd_probe(struct device *dev)
42999 sdkp->disk = gd;
43000 sdkp->index = index;
43001 atomic_set(&sdkp->openers, 0);
43002 - atomic_set(&sdkp->device->ioerr_cnt, 0);
43003 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
43004
43005 if (!sdp->request_queue->rq_timeout) {
43006 if (sdp->type != TYPE_MOD)
43007 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
43008 index df5e961..df6b97f 100644
43009 --- a/drivers/scsi/sg.c
43010 +++ b/drivers/scsi/sg.c
43011 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
43012 sdp->disk->disk_name,
43013 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
43014 NULL,
43015 - (char *)arg);
43016 + (char __user *)arg);
43017 case BLKTRACESTART:
43018 return blk_trace_startstop(sdp->device->request_queue, 1);
43019 case BLKTRACESTOP:
43020 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
43021 index 32b7bb1..2f1c4bd 100644
43022 --- a/drivers/spi/spi.c
43023 +++ b/drivers/spi/spi.c
43024 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
43025 EXPORT_SYMBOL_GPL(spi_bus_unlock);
43026
43027 /* portable code must never pass more than 32 bytes */
43028 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
43029 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
43030
43031 static u8 *buf;
43032
43033 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
43034 index 3675020..e80d92c 100644
43035 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
43036 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
43037 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
43038
43039 static int solo_sysfs_init(struct solo_dev *solo_dev)
43040 {
43041 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
43042 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
43043 struct device *dev = &solo_dev->dev;
43044 const char *driver;
43045 int i;
43046 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
43047 index 34afc16..ffe44dd 100644
43048 --- a/drivers/staging/octeon/ethernet-rx.c
43049 +++ b/drivers/staging/octeon/ethernet-rx.c
43050 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43051 /* Increment RX stats for virtual ports */
43052 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
43053 #ifdef CONFIG_64BIT
43054 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
43055 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
43056 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
43057 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
43058 #else
43059 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
43060 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
43061 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
43062 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
43063 #endif
43064 }
43065 netif_receive_skb(skb);
43066 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43067 dev->name);
43068 */
43069 #ifdef CONFIG_64BIT
43070 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
43071 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43072 #else
43073 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
43074 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
43075 #endif
43076 dev_kfree_skb_irq(skb);
43077 }
43078 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43079 index c3a90e7..023619a 100644
43080 --- a/drivers/staging/octeon/ethernet.c
43081 +++ b/drivers/staging/octeon/ethernet.c
43082 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43083 * since the RX tasklet also increments it.
43084 */
43085 #ifdef CONFIG_64BIT
43086 - atomic64_add(rx_status.dropped_packets,
43087 - (atomic64_t *)&priv->stats.rx_dropped);
43088 + atomic64_add_unchecked(rx_status.dropped_packets,
43089 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43090 #else
43091 - atomic_add(rx_status.dropped_packets,
43092 - (atomic_t *)&priv->stats.rx_dropped);
43093 + atomic_add_unchecked(rx_status.dropped_packets,
43094 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43095 #endif
43096 }
43097
43098 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43099 index dc23395..cf7e9b1 100644
43100 --- a/drivers/staging/rtl8712/rtl871x_io.h
43101 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43102 @@ -108,7 +108,7 @@ struct _io_ops {
43103 u8 *pmem);
43104 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43105 u8 *pmem);
43106 -};
43107 +} __no_const;
43108
43109 struct io_req {
43110 struct list_head list;
43111 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43112 index 1f5088b..0e59820 100644
43113 --- a/drivers/staging/sbe-2t3e3/netdev.c
43114 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43115 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43116 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43117
43118 if (rlen)
43119 - if (copy_to_user(data, &resp, rlen))
43120 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43121 return -EFAULT;
43122
43123 return 0;
43124 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43125 index a863a98..d272795 100644
43126 --- a/drivers/staging/usbip/vhci.h
43127 +++ b/drivers/staging/usbip/vhci.h
43128 @@ -83,7 +83,7 @@ struct vhci_hcd {
43129 unsigned resuming:1;
43130 unsigned long re_timeout;
43131
43132 - atomic_t seqnum;
43133 + atomic_unchecked_t seqnum;
43134
43135 /*
43136 * NOTE:
43137 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43138 index d7974cb..d78076b 100644
43139 --- a/drivers/staging/usbip/vhci_hcd.c
43140 +++ b/drivers/staging/usbip/vhci_hcd.c
43141 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43142
43143 spin_lock(&vdev->priv_lock);
43144
43145 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43146 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43147 if (priv->seqnum == 0xffff)
43148 dev_info(&urb->dev->dev, "seqnum max\n");
43149
43150 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43151 return -ENOMEM;
43152 }
43153
43154 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43155 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43156 if (unlink->seqnum == 0xffff)
43157 pr_info("seqnum max\n");
43158
43159 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43160 vdev->rhport = rhport;
43161 }
43162
43163 - atomic_set(&vhci->seqnum, 0);
43164 + atomic_set_unchecked(&vhci->seqnum, 0);
43165 spin_lock_init(&vhci->lock);
43166
43167 hcd->power_budget = 0; /* no limit */
43168 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43169 index d07fcb5..358e1e1 100644
43170 --- a/drivers/staging/usbip/vhci_rx.c
43171 +++ b/drivers/staging/usbip/vhci_rx.c
43172 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43173 if (!urb) {
43174 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43175 pr_info("max seqnum %d\n",
43176 - atomic_read(&the_controller->seqnum));
43177 + atomic_read_unchecked(&the_controller->seqnum));
43178 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43179 return;
43180 }
43181 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43182 index 8417c2f..ef5ebd6 100644
43183 --- a/drivers/staging/vt6655/hostap.c
43184 +++ b/drivers/staging/vt6655/hostap.c
43185 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
43186 *
43187 */
43188
43189 +static net_device_ops_no_const apdev_netdev_ops;
43190 +
43191 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43192 {
43193 PSDevice apdev_priv;
43194 struct net_device *dev = pDevice->dev;
43195 int ret;
43196 - const struct net_device_ops apdev_netdev_ops = {
43197 - .ndo_start_xmit = pDevice->tx_80211,
43198 - };
43199
43200 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43201
43202 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43203 *apdev_priv = *pDevice;
43204 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43205
43206 + /* only half broken now */
43207 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43208 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43209
43210 pDevice->apdev->type = ARPHRD_IEEE80211;
43211 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43212 index c699a30..b90a5fd 100644
43213 --- a/drivers/staging/vt6656/hostap.c
43214 +++ b/drivers/staging/vt6656/hostap.c
43215 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43216 *
43217 */
43218
43219 +static net_device_ops_no_const apdev_netdev_ops;
43220 +
43221 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43222 {
43223 struct vnt_private *apdev_priv;
43224 struct net_device *dev = pDevice->dev;
43225 int ret;
43226 - const struct net_device_ops apdev_netdev_ops = {
43227 - .ndo_start_xmit = pDevice->tx_80211,
43228 - };
43229
43230 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43231
43232 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43233 *apdev_priv = *pDevice;
43234 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43235
43236 + /* only half broken now */
43237 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43238 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43239
43240 pDevice->apdev->type = ARPHRD_IEEE80211;
43241 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43242 index d7e51e4..d07eaab 100644
43243 --- a/drivers/staging/zcache/tmem.c
43244 +++ b/drivers/staging/zcache/tmem.c
43245 @@ -51,7 +51,7 @@
43246 * A tmem host implementation must use this function to register callbacks
43247 * for memory allocation.
43248 */
43249 -static struct tmem_hostops tmem_hostops;
43250 +static tmem_hostops_no_const tmem_hostops;
43251
43252 static void tmem_objnode_tree_init(void);
43253
43254 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43255 * A tmem host implementation must use this function to register
43256 * callbacks for a page-accessible memory (PAM) implementation.
43257 */
43258 -static struct tmem_pamops tmem_pamops;
43259 +static tmem_pamops_no_const tmem_pamops;
43260
43261 void tmem_register_pamops(struct tmem_pamops *m)
43262 {
43263 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43264 index d128ce2..a43980c 100644
43265 --- a/drivers/staging/zcache/tmem.h
43266 +++ b/drivers/staging/zcache/tmem.h
43267 @@ -226,6 +226,7 @@ struct tmem_pamops {
43268 int (*replace_in_obj)(void *, struct tmem_obj *);
43269 #endif
43270 };
43271 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43272 extern void tmem_register_pamops(struct tmem_pamops *m);
43273
43274 /* memory allocation methods provided by the host implementation */
43275 @@ -235,6 +236,7 @@ struct tmem_hostops {
43276 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43277 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43278 };
43279 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43280 extern void tmem_register_hostops(struct tmem_hostops *m);
43281
43282 /* core tmem accessor functions */
43283 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43284 index 4630481..c26782a 100644
43285 --- a/drivers/target/target_core_device.c
43286 +++ b/drivers/target/target_core_device.c
43287 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43288 spin_lock_init(&dev->se_port_lock);
43289 spin_lock_init(&dev->se_tmr_lock);
43290 spin_lock_init(&dev->qf_cmd_lock);
43291 - atomic_set(&dev->dev_ordered_id, 0);
43292 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43293 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43294 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43295 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43296 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43297 index 21e3158..43c6004 100644
43298 --- a/drivers/target/target_core_transport.c
43299 +++ b/drivers/target/target_core_transport.c
43300 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43301 * Used to determine when ORDERED commands should go from
43302 * Dormant to Active status.
43303 */
43304 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43305 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43306 smp_mb__after_atomic_inc();
43307 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43308 cmd->se_ordered_id, cmd->sam_task_attr,
43309 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43310 index 33f83fe..d80f8e1 100644
43311 --- a/drivers/tty/cyclades.c
43312 +++ b/drivers/tty/cyclades.c
43313 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43314 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43315 info->port.count);
43316 #endif
43317 - info->port.count++;
43318 + atomic_inc(&info->port.count);
43319 #ifdef CY_DEBUG_COUNT
43320 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43321 - current->pid, info->port.count);
43322 + current->pid, atomic_read(&info->port.count));
43323 #endif
43324
43325 /*
43326 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43327 for (j = 0; j < cy_card[i].nports; j++) {
43328 info = &cy_card[i].ports[j];
43329
43330 - if (info->port.count) {
43331 + if (atomic_read(&info->port.count)) {
43332 /* XXX is the ldisc num worth this? */
43333 struct tty_struct *tty;
43334 struct tty_ldisc *ld;
43335 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43336 index eb255e8..f637a57 100644
43337 --- a/drivers/tty/hvc/hvc_console.c
43338 +++ b/drivers/tty/hvc/hvc_console.c
43339 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43340
43341 spin_lock_irqsave(&hp->port.lock, flags);
43342 /* Check and then increment for fast path open. */
43343 - if (hp->port.count++ > 0) {
43344 + if (atomic_inc_return(&hp->port.count) > 1) {
43345 spin_unlock_irqrestore(&hp->port.lock, flags);
43346 hvc_kick();
43347 return 0;
43348 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43349
43350 spin_lock_irqsave(&hp->port.lock, flags);
43351
43352 - if (--hp->port.count == 0) {
43353 + if (atomic_dec_return(&hp->port.count) == 0) {
43354 spin_unlock_irqrestore(&hp->port.lock, flags);
43355 /* We are done with the tty pointer now. */
43356 tty_port_tty_set(&hp->port, NULL);
43357 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43358 */
43359 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43360 } else {
43361 - if (hp->port.count < 0)
43362 + if (atomic_read(&hp->port.count) < 0)
43363 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43364 - hp->vtermno, hp->port.count);
43365 + hp->vtermno, atomic_read(&hp->port.count));
43366 spin_unlock_irqrestore(&hp->port.lock, flags);
43367 }
43368 }
43369 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43370 * open->hangup case this can be called after the final close so prevent
43371 * that from happening for now.
43372 */
43373 - if (hp->port.count <= 0) {
43374 + if (atomic_read(&hp->port.count) <= 0) {
43375 spin_unlock_irqrestore(&hp->port.lock, flags);
43376 return;
43377 }
43378
43379 - hp->port.count = 0;
43380 + atomic_set(&hp->port.count, 0);
43381 spin_unlock_irqrestore(&hp->port.lock, flags);
43382 tty_port_tty_set(&hp->port, NULL);
43383
43384 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43385 return -EPIPE;
43386
43387 /* FIXME what's this (unprotected) check for? */
43388 - if (hp->port.count <= 0)
43389 + if (atomic_read(&hp->port.count) <= 0)
43390 return -EIO;
43391
43392 spin_lock_irqsave(&hp->lock, flags);
43393 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43394 index 81e939e..95ead10 100644
43395 --- a/drivers/tty/hvc/hvcs.c
43396 +++ b/drivers/tty/hvc/hvcs.c
43397 @@ -83,6 +83,7 @@
43398 #include <asm/hvcserver.h>
43399 #include <asm/uaccess.h>
43400 #include <asm/vio.h>
43401 +#include <asm/local.h>
43402
43403 /*
43404 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43405 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43406
43407 spin_lock_irqsave(&hvcsd->lock, flags);
43408
43409 - if (hvcsd->port.count > 0) {
43410 + if (atomic_read(&hvcsd->port.count) > 0) {
43411 spin_unlock_irqrestore(&hvcsd->lock, flags);
43412 printk(KERN_INFO "HVCS: vterm state unchanged. "
43413 "The hvcs device node is still in use.\n");
43414 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43415 }
43416 }
43417
43418 - hvcsd->port.count = 0;
43419 + atomic_set(&hvcsd->port.count, 0);
43420 hvcsd->port.tty = tty;
43421 tty->driver_data = hvcsd;
43422
43423 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43424 unsigned long flags;
43425
43426 spin_lock_irqsave(&hvcsd->lock, flags);
43427 - hvcsd->port.count++;
43428 + atomic_inc(&hvcsd->port.count);
43429 hvcsd->todo_mask |= HVCS_SCHED_READ;
43430 spin_unlock_irqrestore(&hvcsd->lock, flags);
43431
43432 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43433 hvcsd = tty->driver_data;
43434
43435 spin_lock_irqsave(&hvcsd->lock, flags);
43436 - if (--hvcsd->port.count == 0) {
43437 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43438
43439 vio_disable_interrupts(hvcsd->vdev);
43440
43441 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43442
43443 free_irq(irq, hvcsd);
43444 return;
43445 - } else if (hvcsd->port.count < 0) {
43446 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43447 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43448 " is missmanaged.\n",
43449 - hvcsd->vdev->unit_address, hvcsd->port.count);
43450 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43451 }
43452
43453 spin_unlock_irqrestore(&hvcsd->lock, flags);
43454 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43455
43456 spin_lock_irqsave(&hvcsd->lock, flags);
43457 /* Preserve this so that we know how many kref refs to put */
43458 - temp_open_count = hvcsd->port.count;
43459 + temp_open_count = atomic_read(&hvcsd->port.count);
43460
43461 /*
43462 * Don't kref put inside the spinlock because the destruction
43463 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43464 tty->driver_data = NULL;
43465 hvcsd->port.tty = NULL;
43466
43467 - hvcsd->port.count = 0;
43468 + atomic_set(&hvcsd->port.count, 0);
43469
43470 /* This will drop any buffered data on the floor which is OK in a hangup
43471 * scenario. */
43472 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43473 * the middle of a write operation? This is a crummy place to do this
43474 * but we want to keep it all in the spinlock.
43475 */
43476 - if (hvcsd->port.count <= 0) {
43477 + if (atomic_read(&hvcsd->port.count) <= 0) {
43478 spin_unlock_irqrestore(&hvcsd->lock, flags);
43479 return -ENODEV;
43480 }
43481 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43482 {
43483 struct hvcs_struct *hvcsd = tty->driver_data;
43484
43485 - if (!hvcsd || hvcsd->port.count <= 0)
43486 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43487 return 0;
43488
43489 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43490 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43491 index 8fd72ff..34a0bed 100644
43492 --- a/drivers/tty/ipwireless/tty.c
43493 +++ b/drivers/tty/ipwireless/tty.c
43494 @@ -29,6 +29,7 @@
43495 #include <linux/tty_driver.h>
43496 #include <linux/tty_flip.h>
43497 #include <linux/uaccess.h>
43498 +#include <asm/local.h>
43499
43500 #include "tty.h"
43501 #include "network.h"
43502 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43503 mutex_unlock(&tty->ipw_tty_mutex);
43504 return -ENODEV;
43505 }
43506 - if (tty->port.count == 0)
43507 + if (atomic_read(&tty->port.count) == 0)
43508 tty->tx_bytes_queued = 0;
43509
43510 - tty->port.count++;
43511 + atomic_inc(&tty->port.count);
43512
43513 tty->port.tty = linux_tty;
43514 linux_tty->driver_data = tty;
43515 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43516
43517 static void do_ipw_close(struct ipw_tty *tty)
43518 {
43519 - tty->port.count--;
43520 -
43521 - if (tty->port.count == 0) {
43522 + if (atomic_dec_return(&tty->port.count) == 0) {
43523 struct tty_struct *linux_tty = tty->port.tty;
43524
43525 if (linux_tty != NULL) {
43526 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43527 return;
43528
43529 mutex_lock(&tty->ipw_tty_mutex);
43530 - if (tty->port.count == 0) {
43531 + if (atomic_read(&tty->port.count) == 0) {
43532 mutex_unlock(&tty->ipw_tty_mutex);
43533 return;
43534 }
43535 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43536
43537 mutex_lock(&tty->ipw_tty_mutex);
43538
43539 - if (!tty->port.count) {
43540 + if (!atomic_read(&tty->port.count)) {
43541 mutex_unlock(&tty->ipw_tty_mutex);
43542 return;
43543 }
43544 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43545 return -ENODEV;
43546
43547 mutex_lock(&tty->ipw_tty_mutex);
43548 - if (!tty->port.count) {
43549 + if (!atomic_read(&tty->port.count)) {
43550 mutex_unlock(&tty->ipw_tty_mutex);
43551 return -EINVAL;
43552 }
43553 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43554 if (!tty)
43555 return -ENODEV;
43556
43557 - if (!tty->port.count)
43558 + if (!atomic_read(&tty->port.count))
43559 return -EINVAL;
43560
43561 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43562 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43563 if (!tty)
43564 return 0;
43565
43566 - if (!tty->port.count)
43567 + if (!atomic_read(&tty->port.count))
43568 return 0;
43569
43570 return tty->tx_bytes_queued;
43571 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43572 if (!tty)
43573 return -ENODEV;
43574
43575 - if (!tty->port.count)
43576 + if (!atomic_read(&tty->port.count))
43577 return -EINVAL;
43578
43579 return get_control_lines(tty);
43580 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43581 if (!tty)
43582 return -ENODEV;
43583
43584 - if (!tty->port.count)
43585 + if (!atomic_read(&tty->port.count))
43586 return -EINVAL;
43587
43588 return set_control_lines(tty, set, clear);
43589 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43590 if (!tty)
43591 return -ENODEV;
43592
43593 - if (!tty->port.count)
43594 + if (!atomic_read(&tty->port.count))
43595 return -EINVAL;
43596
43597 /* FIXME: Exactly how is the tty object locked here .. */
43598 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43599 * are gone */
43600 mutex_lock(&ttyj->ipw_tty_mutex);
43601 }
43602 - while (ttyj->port.count)
43603 + while (atomic_read(&ttyj->port.count))
43604 do_ipw_close(ttyj);
43605 ipwireless_disassociate_network_ttys(network,
43606 ttyj->channel_idx);
43607 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43608 index 1deaca4..c8582d4 100644
43609 --- a/drivers/tty/moxa.c
43610 +++ b/drivers/tty/moxa.c
43611 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43612 }
43613
43614 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43615 - ch->port.count++;
43616 + atomic_inc(&ch->port.count);
43617 tty->driver_data = ch;
43618 tty_port_tty_set(&ch->port, tty);
43619 mutex_lock(&ch->port.mutex);
43620 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43621 index 6422390..49003ac8 100644
43622 --- a/drivers/tty/n_gsm.c
43623 +++ b/drivers/tty/n_gsm.c
43624 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43625 spin_lock_init(&dlci->lock);
43626 mutex_init(&dlci->mutex);
43627 dlci->fifo = &dlci->_fifo;
43628 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43629 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43630 kfree(dlci);
43631 return NULL;
43632 }
43633 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43634 struct gsm_dlci *dlci = tty->driver_data;
43635 struct tty_port *port = &dlci->port;
43636
43637 - port->count++;
43638 + atomic_inc(&port->count);
43639 dlci_get(dlci);
43640 dlci_get(dlci->gsm->dlci[0]);
43641 mux_get(dlci->gsm);
43642 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43643 index 6c7fe90..9241dab 100644
43644 --- a/drivers/tty/n_tty.c
43645 +++ b/drivers/tty/n_tty.c
43646 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43647 {
43648 *ops = tty_ldisc_N_TTY;
43649 ops->owner = NULL;
43650 - ops->refcount = ops->flags = 0;
43651 + atomic_set(&ops->refcount, 0);
43652 + ops->flags = 0;
43653 }
43654 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43655 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43656 index abfd990..5ab5da9 100644
43657 --- a/drivers/tty/pty.c
43658 +++ b/drivers/tty/pty.c
43659 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
43660 panic("Couldn't register Unix98 pts driver");
43661
43662 /* Now create the /dev/ptmx special device */
43663 + pax_open_kernel();
43664 tty_default_fops(&ptmx_fops);
43665 - ptmx_fops.open = ptmx_open;
43666 + *(void **)&ptmx_fops.open = ptmx_open;
43667 + pax_close_kernel();
43668
43669 cdev_init(&ptmx_cdev, &ptmx_fops);
43670 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43671 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43672 index 354564e..fe50d9a 100644
43673 --- a/drivers/tty/rocket.c
43674 +++ b/drivers/tty/rocket.c
43675 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43676 tty->driver_data = info;
43677 tty_port_tty_set(port, tty);
43678
43679 - if (port->count++ == 0) {
43680 + if (atomic_inc_return(&port->count) == 1) {
43681 atomic_inc(&rp_num_ports_open);
43682
43683 #ifdef ROCKET_DEBUG_OPEN
43684 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43685 #endif
43686 }
43687 #ifdef ROCKET_DEBUG_OPEN
43688 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43689 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43690 #endif
43691
43692 /*
43693 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
43694 spin_unlock_irqrestore(&info->port.lock, flags);
43695 return;
43696 }
43697 - if (info->port.count)
43698 + if (atomic_read(&info->port.count))
43699 atomic_dec(&rp_num_ports_open);
43700 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43701 spin_unlock_irqrestore(&info->port.lock, flags);
43702 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43703 index 1002054..dd644a8 100644
43704 --- a/drivers/tty/serial/kgdboc.c
43705 +++ b/drivers/tty/serial/kgdboc.c
43706 @@ -24,8 +24,9 @@
43707 #define MAX_CONFIG_LEN 40
43708
43709 static struct kgdb_io kgdboc_io_ops;
43710 +static struct kgdb_io kgdboc_io_ops_console;
43711
43712 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43713 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43714 static int configured = -1;
43715
43716 static char config[MAX_CONFIG_LEN];
43717 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43718 kgdboc_unregister_kbd();
43719 if (configured == 1)
43720 kgdb_unregister_io_module(&kgdboc_io_ops);
43721 + else if (configured == 2)
43722 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43723 }
43724
43725 static int configure_kgdboc(void)
43726 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43727 int err;
43728 char *cptr = config;
43729 struct console *cons;
43730 + int is_console = 0;
43731
43732 err = kgdboc_option_setup(config);
43733 if (err || !strlen(config) || isspace(config[0]))
43734 goto noconfig;
43735
43736 err = -ENODEV;
43737 - kgdboc_io_ops.is_console = 0;
43738 kgdb_tty_driver = NULL;
43739
43740 kgdboc_use_kms = 0;
43741 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43742 int idx;
43743 if (cons->device && cons->device(cons, &idx) == p &&
43744 idx == tty_line) {
43745 - kgdboc_io_ops.is_console = 1;
43746 + is_console = 1;
43747 break;
43748 }
43749 cons = cons->next;
43750 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43751 kgdb_tty_line = tty_line;
43752
43753 do_register:
43754 - err = kgdb_register_io_module(&kgdboc_io_ops);
43755 + if (is_console) {
43756 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43757 + configured = 2;
43758 + } else {
43759 + err = kgdb_register_io_module(&kgdboc_io_ops);
43760 + configured = 1;
43761 + }
43762 if (err)
43763 goto noconfig;
43764
43765 @@ -205,8 +214,6 @@ do_register:
43766 if (err)
43767 goto nmi_con_failed;
43768
43769 - configured = 1;
43770 -
43771 return 0;
43772
43773 nmi_con_failed:
43774 @@ -223,7 +230,7 @@ noconfig:
43775 static int __init init_kgdboc(void)
43776 {
43777 /* Already configured? */
43778 - if (configured == 1)
43779 + if (configured >= 1)
43780 return 0;
43781
43782 return configure_kgdboc();
43783 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43784 if (config[len - 1] == '\n')
43785 config[len - 1] = '\0';
43786
43787 - if (configured == 1)
43788 + if (configured >= 1)
43789 cleanup_kgdboc();
43790
43791 /* Go and configure with the new params. */
43792 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43793 .post_exception = kgdboc_post_exp_handler,
43794 };
43795
43796 +static struct kgdb_io kgdboc_io_ops_console = {
43797 + .name = "kgdboc",
43798 + .read_char = kgdboc_get_char,
43799 + .write_char = kgdboc_put_char,
43800 + .pre_exception = kgdboc_pre_exp_handler,
43801 + .post_exception = kgdboc_post_exp_handler,
43802 + .is_console = 1
43803 +};
43804 +
43805 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43806 /* This is only available if kgdboc is a built in for early debugging */
43807 static int __init kgdboc_early_init(char *opt)
43808 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43809 index 0c8a9fa..234a95f 100644
43810 --- a/drivers/tty/serial/samsung.c
43811 +++ b/drivers/tty/serial/samsung.c
43812 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43813 }
43814 }
43815
43816 +static int s3c64xx_serial_startup(struct uart_port *port);
43817 static int s3c24xx_serial_startup(struct uart_port *port)
43818 {
43819 struct s3c24xx_uart_port *ourport = to_ourport(port);
43820 int ret;
43821
43822 + /* Startup sequence is different for s3c64xx and higher SoC's */
43823 + if (s3c24xx_serial_has_interrupt_mask(port))
43824 + return s3c64xx_serial_startup(port);
43825 +
43826 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43827 port->mapbase, port->membase);
43828
43829 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43830 /* setup info for port */
43831 port->dev = &platdev->dev;
43832
43833 - /* Startup sequence is different for s3c64xx and higher SoC's */
43834 - if (s3c24xx_serial_has_interrupt_mask(port))
43835 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43836 -
43837 port->uartclk = 1;
43838
43839 if (cfg->uart_flags & UPF_CONS_FLOW) {
43840 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43841 index f87dbfd..42ad4b1 100644
43842 --- a/drivers/tty/serial/serial_core.c
43843 +++ b/drivers/tty/serial/serial_core.c
43844 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43845 uart_flush_buffer(tty);
43846 uart_shutdown(tty, state);
43847 spin_lock_irqsave(&port->lock, flags);
43848 - port->count = 0;
43849 + atomic_set(&port->count, 0);
43850 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43851 spin_unlock_irqrestore(&port->lock, flags);
43852 tty_port_tty_set(port, NULL);
43853 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43854 goto end;
43855 }
43856
43857 - port->count++;
43858 + atomic_inc(&port->count);
43859 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43860 retval = -ENXIO;
43861 goto err_dec_count;
43862 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43863 /*
43864 * Make sure the device is in D0 state.
43865 */
43866 - if (port->count == 1)
43867 + if (atomic_read(&port->count) == 1)
43868 uart_change_pm(state, UART_PM_STATE_ON);
43869
43870 /*
43871 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43872 end:
43873 return retval;
43874 err_dec_count:
43875 - port->count--;
43876 + atomic_inc(&port->count);
43877 mutex_unlock(&port->mutex);
43878 goto end;
43879 }
43880 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43881 index 8eaf1ab..85c030d 100644
43882 --- a/drivers/tty/synclink.c
43883 +++ b/drivers/tty/synclink.c
43884 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43885
43886 if (debug_level >= DEBUG_LEVEL_INFO)
43887 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43888 - __FILE__,__LINE__, info->device_name, info->port.count);
43889 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43890
43891 if (tty_port_close_start(&info->port, tty, filp) == 0)
43892 goto cleanup;
43893 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43894 cleanup:
43895 if (debug_level >= DEBUG_LEVEL_INFO)
43896 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43897 - tty->driver->name, info->port.count);
43898 + tty->driver->name, atomic_read(&info->port.count));
43899
43900 } /* end of mgsl_close() */
43901
43902 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43903
43904 mgsl_flush_buffer(tty);
43905 shutdown(info);
43906 -
43907 - info->port.count = 0;
43908 +
43909 + atomic_set(&info->port.count, 0);
43910 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43911 info->port.tty = NULL;
43912
43913 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43914
43915 if (debug_level >= DEBUG_LEVEL_INFO)
43916 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43917 - __FILE__,__LINE__, tty->driver->name, port->count );
43918 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43919
43920 spin_lock_irqsave(&info->irq_spinlock, flags);
43921 if (!tty_hung_up_p(filp)) {
43922 extra_count = true;
43923 - port->count--;
43924 + atomic_dec(&port->count);
43925 }
43926 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43927 port->blocked_open++;
43928 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43929
43930 if (debug_level >= DEBUG_LEVEL_INFO)
43931 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43932 - __FILE__,__LINE__, tty->driver->name, port->count );
43933 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43934
43935 tty_unlock(tty);
43936 schedule();
43937 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43938
43939 /* FIXME: Racy on hangup during close wait */
43940 if (extra_count)
43941 - port->count++;
43942 + atomic_inc(&port->count);
43943 port->blocked_open--;
43944
43945 if (debug_level >= DEBUG_LEVEL_INFO)
43946 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43947 - __FILE__,__LINE__, tty->driver->name, port->count );
43948 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43949
43950 if (!retval)
43951 port->flags |= ASYNC_NORMAL_ACTIVE;
43952 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43953
43954 if (debug_level >= DEBUG_LEVEL_INFO)
43955 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43956 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43957 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43958
43959 /* If port is closing, signal caller to try again */
43960 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43961 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43962 spin_unlock_irqrestore(&info->netlock, flags);
43963 goto cleanup;
43964 }
43965 - info->port.count++;
43966 + atomic_inc(&info->port.count);
43967 spin_unlock_irqrestore(&info->netlock, flags);
43968
43969 - if (info->port.count == 1) {
43970 + if (atomic_read(&info->port.count) == 1) {
43971 /* 1st open on this device, init hardware */
43972 retval = startup(info);
43973 if (retval < 0)
43974 @@ -3446,8 +3446,8 @@ cleanup:
43975 if (retval) {
43976 if (tty->count == 1)
43977 info->port.tty = NULL; /* tty layer will release tty struct */
43978 - if(info->port.count)
43979 - info->port.count--;
43980 + if (atomic_read(&info->port.count))
43981 + atomic_dec(&info->port.count);
43982 }
43983
43984 return retval;
43985 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43986 unsigned short new_crctype;
43987
43988 /* return error if TTY interface open */
43989 - if (info->port.count)
43990 + if (atomic_read(&info->port.count))
43991 return -EBUSY;
43992
43993 switch (encoding)
43994 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
43995
43996 /* arbitrate between network and tty opens */
43997 spin_lock_irqsave(&info->netlock, flags);
43998 - if (info->port.count != 0 || info->netcount != 0) {
43999 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44000 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44001 spin_unlock_irqrestore(&info->netlock, flags);
44002 return -EBUSY;
44003 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44004 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44005
44006 /* return error if TTY interface open */
44007 - if (info->port.count)
44008 + if (atomic_read(&info->port.count))
44009 return -EBUSY;
44010
44011 if (cmd != SIOCWANDEV)
44012 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44013 index 1abf946..1ee34fc 100644
44014 --- a/drivers/tty/synclink_gt.c
44015 +++ b/drivers/tty/synclink_gt.c
44016 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44017 tty->driver_data = info;
44018 info->port.tty = tty;
44019
44020 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44021 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44022
44023 /* If port is closing, signal caller to try again */
44024 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44025 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44026 mutex_unlock(&info->port.mutex);
44027 goto cleanup;
44028 }
44029 - info->port.count++;
44030 + atomic_inc(&info->port.count);
44031 spin_unlock_irqrestore(&info->netlock, flags);
44032
44033 - if (info->port.count == 1) {
44034 + if (atomic_read(&info->port.count) == 1) {
44035 /* 1st open on this device, init hardware */
44036 retval = startup(info);
44037 if (retval < 0) {
44038 @@ -715,8 +715,8 @@ cleanup:
44039 if (retval) {
44040 if (tty->count == 1)
44041 info->port.tty = NULL; /* tty layer will release tty struct */
44042 - if(info->port.count)
44043 - info->port.count--;
44044 + if(atomic_read(&info->port.count))
44045 + atomic_dec(&info->port.count);
44046 }
44047
44048 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44049 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44050
44051 if (sanity_check(info, tty->name, "close"))
44052 return;
44053 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44054 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44055
44056 if (tty_port_close_start(&info->port, tty, filp) == 0)
44057 goto cleanup;
44058 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44059 tty_port_close_end(&info->port, tty);
44060 info->port.tty = NULL;
44061 cleanup:
44062 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44063 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44064 }
44065
44066 static void hangup(struct tty_struct *tty)
44067 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
44068 shutdown(info);
44069
44070 spin_lock_irqsave(&info->port.lock, flags);
44071 - info->port.count = 0;
44072 + atomic_set(&info->port.count, 0);
44073 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44074 info->port.tty = NULL;
44075 spin_unlock_irqrestore(&info->port.lock, flags);
44076 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44077 unsigned short new_crctype;
44078
44079 /* return error if TTY interface open */
44080 - if (info->port.count)
44081 + if (atomic_read(&info->port.count))
44082 return -EBUSY;
44083
44084 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44085 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
44086
44087 /* arbitrate between network and tty opens */
44088 spin_lock_irqsave(&info->netlock, flags);
44089 - if (info->port.count != 0 || info->netcount != 0) {
44090 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44091 DBGINFO(("%s hdlc_open busy\n", dev->name));
44092 spin_unlock_irqrestore(&info->netlock, flags);
44093 return -EBUSY;
44094 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44095 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44096
44097 /* return error if TTY interface open */
44098 - if (info->port.count)
44099 + if (atomic_read(&info->port.count))
44100 return -EBUSY;
44101
44102 if (cmd != SIOCWANDEV)
44103 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44104 if (port == NULL)
44105 continue;
44106 spin_lock(&port->lock);
44107 - if ((port->port.count || port->netcount) &&
44108 + if ((atomic_read(&port->port.count) || port->netcount) &&
44109 port->pending_bh && !port->bh_running &&
44110 !port->bh_requested) {
44111 DBGISR(("%s bh queued\n", port->device_name));
44112 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44113 spin_lock_irqsave(&info->lock, flags);
44114 if (!tty_hung_up_p(filp)) {
44115 extra_count = true;
44116 - port->count--;
44117 + atomic_dec(&port->count);
44118 }
44119 spin_unlock_irqrestore(&info->lock, flags);
44120 port->blocked_open++;
44121 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44122 remove_wait_queue(&port->open_wait, &wait);
44123
44124 if (extra_count)
44125 - port->count++;
44126 + atomic_inc(&port->count);
44127 port->blocked_open--;
44128
44129 if (!retval)
44130 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44131 index ff17138..e38b41e 100644
44132 --- a/drivers/tty/synclinkmp.c
44133 +++ b/drivers/tty/synclinkmp.c
44134 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44135
44136 if (debug_level >= DEBUG_LEVEL_INFO)
44137 printk("%s(%d):%s open(), old ref count = %d\n",
44138 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44139 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44140
44141 /* If port is closing, signal caller to try again */
44142 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44143 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44144 spin_unlock_irqrestore(&info->netlock, flags);
44145 goto cleanup;
44146 }
44147 - info->port.count++;
44148 + atomic_inc(&info->port.count);
44149 spin_unlock_irqrestore(&info->netlock, flags);
44150
44151 - if (info->port.count == 1) {
44152 + if (atomic_read(&info->port.count) == 1) {
44153 /* 1st open on this device, init hardware */
44154 retval = startup(info);
44155 if (retval < 0)
44156 @@ -796,8 +796,8 @@ cleanup:
44157 if (retval) {
44158 if (tty->count == 1)
44159 info->port.tty = NULL; /* tty layer will release tty struct */
44160 - if(info->port.count)
44161 - info->port.count--;
44162 + if(atomic_read(&info->port.count))
44163 + atomic_dec(&info->port.count);
44164 }
44165
44166 return retval;
44167 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44168
44169 if (debug_level >= DEBUG_LEVEL_INFO)
44170 printk("%s(%d):%s close() entry, count=%d\n",
44171 - __FILE__,__LINE__, info->device_name, info->port.count);
44172 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44173
44174 if (tty_port_close_start(&info->port, tty, filp) == 0)
44175 goto cleanup;
44176 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44177 cleanup:
44178 if (debug_level >= DEBUG_LEVEL_INFO)
44179 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44180 - tty->driver->name, info->port.count);
44181 + tty->driver->name, atomic_read(&info->port.count));
44182 }
44183
44184 /* Called by tty_hangup() when a hangup is signaled.
44185 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44186 shutdown(info);
44187
44188 spin_lock_irqsave(&info->port.lock, flags);
44189 - info->port.count = 0;
44190 + atomic_set(&info->port.count, 0);
44191 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44192 info->port.tty = NULL;
44193 spin_unlock_irqrestore(&info->port.lock, flags);
44194 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44195 unsigned short new_crctype;
44196
44197 /* return error if TTY interface open */
44198 - if (info->port.count)
44199 + if (atomic_read(&info->port.count))
44200 return -EBUSY;
44201
44202 switch (encoding)
44203 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44204
44205 /* arbitrate between network and tty opens */
44206 spin_lock_irqsave(&info->netlock, flags);
44207 - if (info->port.count != 0 || info->netcount != 0) {
44208 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44209 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44210 spin_unlock_irqrestore(&info->netlock, flags);
44211 return -EBUSY;
44212 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44213 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44214
44215 /* return error if TTY interface open */
44216 - if (info->port.count)
44217 + if (atomic_read(&info->port.count))
44218 return -EBUSY;
44219
44220 if (cmd != SIOCWANDEV)
44221 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44222 * do not request bottom half processing if the
44223 * device is not open in a normal mode.
44224 */
44225 - if ( port && (port->port.count || port->netcount) &&
44226 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44227 port->pending_bh && !port->bh_running &&
44228 !port->bh_requested ) {
44229 if ( debug_level >= DEBUG_LEVEL_ISR )
44230 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44231
44232 if (debug_level >= DEBUG_LEVEL_INFO)
44233 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44234 - __FILE__,__LINE__, tty->driver->name, port->count );
44235 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44236
44237 spin_lock_irqsave(&info->lock, flags);
44238 if (!tty_hung_up_p(filp)) {
44239 extra_count = true;
44240 - port->count--;
44241 + atomic_dec(&port->count);
44242 }
44243 spin_unlock_irqrestore(&info->lock, flags);
44244 port->blocked_open++;
44245 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44246
44247 if (debug_level >= DEBUG_LEVEL_INFO)
44248 printk("%s(%d):%s block_til_ready() count=%d\n",
44249 - __FILE__,__LINE__, tty->driver->name, port->count );
44250 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44251
44252 tty_unlock(tty);
44253 schedule();
44254 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44255 remove_wait_queue(&port->open_wait, &wait);
44256
44257 if (extra_count)
44258 - port->count++;
44259 + atomic_inc(&port->count);
44260 port->blocked_open--;
44261
44262 if (debug_level >= DEBUG_LEVEL_INFO)
44263 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44264 - __FILE__,__LINE__, tty->driver->name, port->count );
44265 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44266
44267 if (!retval)
44268 port->flags |= ASYNC_NORMAL_ACTIVE;
44269 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44270 index b51c154..17d55d1 100644
44271 --- a/drivers/tty/sysrq.c
44272 +++ b/drivers/tty/sysrq.c
44273 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44274 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44275 size_t count, loff_t *ppos)
44276 {
44277 - if (count) {
44278 + if (count && capable(CAP_SYS_ADMIN)) {
44279 char c;
44280
44281 if (get_user(c, buf))
44282 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44283 index 4476682..d77e748 100644
44284 --- a/drivers/tty/tty_io.c
44285 +++ b/drivers/tty/tty_io.c
44286 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44287
44288 void tty_default_fops(struct file_operations *fops)
44289 {
44290 - *fops = tty_fops;
44291 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44292 }
44293
44294 /*
44295 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44296 index 1afe192..73d2c20 100644
44297 --- a/drivers/tty/tty_ldisc.c
44298 +++ b/drivers/tty/tty_ldisc.c
44299 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44300 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44301 tty_ldiscs[disc] = new_ldisc;
44302 new_ldisc->num = disc;
44303 - new_ldisc->refcount = 0;
44304 + atomic_set(&new_ldisc->refcount, 0);
44305 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44306
44307 return ret;
44308 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
44309 return -EINVAL;
44310
44311 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44312 - if (tty_ldiscs[disc]->refcount)
44313 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44314 ret = -EBUSY;
44315 else
44316 tty_ldiscs[disc] = NULL;
44317 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44318 if (ldops) {
44319 ret = ERR_PTR(-EAGAIN);
44320 if (try_module_get(ldops->owner)) {
44321 - ldops->refcount++;
44322 + atomic_inc(&ldops->refcount);
44323 ret = ldops;
44324 }
44325 }
44326 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44327 unsigned long flags;
44328
44329 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44330 - ldops->refcount--;
44331 + atomic_dec(&ldops->refcount);
44332 module_put(ldops->owner);
44333 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44334 }
44335 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
44336 /* unreleased reader reference(s) will cause this WARN */
44337 WARN_ON(!atomic_dec_and_test(&ld->users));
44338
44339 - ld->ops->refcount--;
44340 + atomic_dec(&ld->ops->refcount);
44341 module_put(ld->ops->owner);
44342 kfree(ld);
44343 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44344 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44345 index 121aeb9..0d2c4b9 100644
44346 --- a/drivers/tty/tty_port.c
44347 +++ b/drivers/tty/tty_port.c
44348 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
44349 unsigned long flags;
44350
44351 spin_lock_irqsave(&port->lock, flags);
44352 - port->count = 0;
44353 + atomic_set(&port->count, 0);
44354 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44355 tty = port->tty;
44356 if (tty)
44357 @@ -391,7 +391,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44358 /* The port lock protects the port counts */
44359 spin_lock_irqsave(&port->lock, flags);
44360 if (!tty_hung_up_p(filp))
44361 - port->count--;
44362 + atomic_dec(&port->count);
44363 port->blocked_open++;
44364 spin_unlock_irqrestore(&port->lock, flags);
44365
44366 @@ -433,7 +433,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44367 we must not mess that up further */
44368 spin_lock_irqsave(&port->lock, flags);
44369 if (!tty_hung_up_p(filp))
44370 - port->count++;
44371 + atomic_inc(&port->count);
44372 port->blocked_open--;
44373 if (retval == 0)
44374 port->flags |= ASYNC_NORMAL_ACTIVE;
44375 @@ -467,19 +467,19 @@ int tty_port_close_start(struct tty_port *port,
44376 return 0;
44377 }
44378
44379 - if (tty->count == 1 && port->count != 1) {
44380 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44381 printk(KERN_WARNING
44382 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44383 - port->count);
44384 - port->count = 1;
44385 + atomic_read(&port->count));
44386 + atomic_set(&port->count, 1);
44387 }
44388 - if (--port->count < 0) {
44389 + if (atomic_dec_return(&port->count) < 0) {
44390 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44391 - port->count);
44392 - port->count = 0;
44393 + atomic_read(&port->count));
44394 + atomic_set(&port->count, 0);
44395 }
44396
44397 - if (port->count) {
44398 + if (atomic_read(&port->count)) {
44399 spin_unlock_irqrestore(&port->lock, flags);
44400 if (port->ops->drop)
44401 port->ops->drop(port);
44402 @@ -565,7 +565,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44403 {
44404 spin_lock_irq(&port->lock);
44405 if (!tty_hung_up_p(filp))
44406 - ++port->count;
44407 + atomic_inc(&port->count);
44408 spin_unlock_irq(&port->lock);
44409 tty_port_tty_set(port, tty);
44410
44411 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44412 index a9af1b9a..1e08e7f 100644
44413 --- a/drivers/tty/vt/keyboard.c
44414 +++ b/drivers/tty/vt/keyboard.c
44415 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44416 kbd->kbdmode == VC_OFF) &&
44417 value != KVAL(K_SAK))
44418 return; /* SAK is allowed even in raw mode */
44419 +
44420 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44421 + {
44422 + void *func = fn_handler[value];
44423 + if (func == fn_show_state || func == fn_show_ptregs ||
44424 + func == fn_show_mem)
44425 + return;
44426 + }
44427 +#endif
44428 +
44429 fn_handler[value](vc);
44430 }
44431
44432 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44433 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44434 return -EFAULT;
44435
44436 - if (!capable(CAP_SYS_TTY_CONFIG))
44437 - perm = 0;
44438 -
44439 switch (cmd) {
44440 case KDGKBENT:
44441 /* Ensure another thread doesn't free it under us */
44442 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44443 spin_unlock_irqrestore(&kbd_event_lock, flags);
44444 return put_user(val, &user_kbe->kb_value);
44445 case KDSKBENT:
44446 + if (!capable(CAP_SYS_TTY_CONFIG))
44447 + perm = 0;
44448 +
44449 if (!perm)
44450 return -EPERM;
44451 if (!i && v == K_NOSUCHMAP) {
44452 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44453 int i, j, k;
44454 int ret;
44455
44456 - if (!capable(CAP_SYS_TTY_CONFIG))
44457 - perm = 0;
44458 -
44459 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44460 if (!kbs) {
44461 ret = -ENOMEM;
44462 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44463 kfree(kbs);
44464 return ((p && *p) ? -EOVERFLOW : 0);
44465 case KDSKBSENT:
44466 + if (!capable(CAP_SYS_TTY_CONFIG))
44467 + perm = 0;
44468 +
44469 if (!perm) {
44470 ret = -EPERM;
44471 goto reterr;
44472 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44473 index b645c47..a55c182 100644
44474 --- a/drivers/uio/uio.c
44475 +++ b/drivers/uio/uio.c
44476 @@ -25,6 +25,7 @@
44477 #include <linux/kobject.h>
44478 #include <linux/cdev.h>
44479 #include <linux/uio_driver.h>
44480 +#include <asm/local.h>
44481
44482 #define UIO_MAX_DEVICES (1U << MINORBITS)
44483
44484 @@ -32,10 +33,10 @@ struct uio_device {
44485 struct module *owner;
44486 struct device *dev;
44487 int minor;
44488 - atomic_t event;
44489 + atomic_unchecked_t event;
44490 struct fasync_struct *async_queue;
44491 wait_queue_head_t wait;
44492 - int vma_count;
44493 + local_t vma_count;
44494 struct uio_info *info;
44495 struct kobject *map_dir;
44496 struct kobject *portio_dir;
44497 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44498 struct device_attribute *attr, char *buf)
44499 {
44500 struct uio_device *idev = dev_get_drvdata(dev);
44501 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44502 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44503 }
44504
44505 static struct device_attribute uio_class_attributes[] = {
44506 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44507 {
44508 struct uio_device *idev = info->uio_dev;
44509
44510 - atomic_inc(&idev->event);
44511 + atomic_inc_unchecked(&idev->event);
44512 wake_up_interruptible(&idev->wait);
44513 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44514 }
44515 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44516 }
44517
44518 listener->dev = idev;
44519 - listener->event_count = atomic_read(&idev->event);
44520 + listener->event_count = atomic_read_unchecked(&idev->event);
44521 filep->private_data = listener;
44522
44523 if (idev->info->open) {
44524 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44525 return -EIO;
44526
44527 poll_wait(filep, &idev->wait, wait);
44528 - if (listener->event_count != atomic_read(&idev->event))
44529 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44530 return POLLIN | POLLRDNORM;
44531 return 0;
44532 }
44533 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44534 do {
44535 set_current_state(TASK_INTERRUPTIBLE);
44536
44537 - event_count = atomic_read(&idev->event);
44538 + event_count = atomic_read_unchecked(&idev->event);
44539 if (event_count != listener->event_count) {
44540 if (copy_to_user(buf, &event_count, count))
44541 retval = -EFAULT;
44542 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44543 static void uio_vma_open(struct vm_area_struct *vma)
44544 {
44545 struct uio_device *idev = vma->vm_private_data;
44546 - idev->vma_count++;
44547 + local_inc(&idev->vma_count);
44548 }
44549
44550 static void uio_vma_close(struct vm_area_struct *vma)
44551 {
44552 struct uio_device *idev = vma->vm_private_data;
44553 - idev->vma_count--;
44554 + local_dec(&idev->vma_count);
44555 }
44556
44557 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44558 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44559 idev->owner = owner;
44560 idev->info = info;
44561 init_waitqueue_head(&idev->wait);
44562 - atomic_set(&idev->event, 0);
44563 + atomic_set_unchecked(&idev->event, 0);
44564
44565 ret = uio_get_minor(idev);
44566 if (ret)
44567 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44568 index 8a7eb77..c00402f 100644
44569 --- a/drivers/usb/atm/cxacru.c
44570 +++ b/drivers/usb/atm/cxacru.c
44571 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44572 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44573 if (ret < 2)
44574 return -EINVAL;
44575 - if (index < 0 || index > 0x7f)
44576 + if (index > 0x7f)
44577 return -EINVAL;
44578 pos += tmp;
44579
44580 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44581 index d3527dd..26effa2 100644
44582 --- a/drivers/usb/atm/usbatm.c
44583 +++ b/drivers/usb/atm/usbatm.c
44584 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44585 if (printk_ratelimit())
44586 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44587 __func__, vpi, vci);
44588 - atomic_inc(&vcc->stats->rx_err);
44589 + atomic_inc_unchecked(&vcc->stats->rx_err);
44590 return;
44591 }
44592
44593 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44594 if (length > ATM_MAX_AAL5_PDU) {
44595 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44596 __func__, length, vcc);
44597 - atomic_inc(&vcc->stats->rx_err);
44598 + atomic_inc_unchecked(&vcc->stats->rx_err);
44599 goto out;
44600 }
44601
44602 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44603 if (sarb->len < pdu_length) {
44604 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44605 __func__, pdu_length, sarb->len, vcc);
44606 - atomic_inc(&vcc->stats->rx_err);
44607 + atomic_inc_unchecked(&vcc->stats->rx_err);
44608 goto out;
44609 }
44610
44611 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44612 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44613 __func__, vcc);
44614 - atomic_inc(&vcc->stats->rx_err);
44615 + atomic_inc_unchecked(&vcc->stats->rx_err);
44616 goto out;
44617 }
44618
44619 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44620 if (printk_ratelimit())
44621 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44622 __func__, length);
44623 - atomic_inc(&vcc->stats->rx_drop);
44624 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44625 goto out;
44626 }
44627
44628 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44629
44630 vcc->push(vcc, skb);
44631
44632 - atomic_inc(&vcc->stats->rx);
44633 + atomic_inc_unchecked(&vcc->stats->rx);
44634 out:
44635 skb_trim(sarb, 0);
44636 }
44637 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44638 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44639
44640 usbatm_pop(vcc, skb);
44641 - atomic_inc(&vcc->stats->tx);
44642 + atomic_inc_unchecked(&vcc->stats->tx);
44643
44644 skb = skb_dequeue(&instance->sndqueue);
44645 }
44646 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44647 if (!left--)
44648 return sprintf(page,
44649 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44650 - atomic_read(&atm_dev->stats.aal5.tx),
44651 - atomic_read(&atm_dev->stats.aal5.tx_err),
44652 - atomic_read(&atm_dev->stats.aal5.rx),
44653 - atomic_read(&atm_dev->stats.aal5.rx_err),
44654 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44655 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44656 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44657 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44658 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44659 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44660
44661 if (!left--) {
44662 if (instance->disconnected)
44663 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44664 index 2a3bbdf..91d72cf 100644
44665 --- a/drivers/usb/core/devices.c
44666 +++ b/drivers/usb/core/devices.c
44667 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44668 * time it gets called.
44669 */
44670 static struct device_connect_event {
44671 - atomic_t count;
44672 + atomic_unchecked_t count;
44673 wait_queue_head_t wait;
44674 } device_event = {
44675 .count = ATOMIC_INIT(1),
44676 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44677
44678 void usbfs_conn_disc_event(void)
44679 {
44680 - atomic_add(2, &device_event.count);
44681 + atomic_add_unchecked(2, &device_event.count);
44682 wake_up(&device_event.wait);
44683 }
44684
44685 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44686
44687 poll_wait(file, &device_event.wait, wait);
44688
44689 - event_count = atomic_read(&device_event.count);
44690 + event_count = atomic_read_unchecked(&device_event.count);
44691 if (file->f_version != event_count) {
44692 file->f_version = event_count;
44693 return POLLIN | POLLRDNORM;
44694 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44695 index d53547d..6a22d02 100644
44696 --- a/drivers/usb/core/hcd.c
44697 +++ b/drivers/usb/core/hcd.c
44698 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44699 */
44700 usb_get_urb(urb);
44701 atomic_inc(&urb->use_count);
44702 - atomic_inc(&urb->dev->urbnum);
44703 + atomic_inc_unchecked(&urb->dev->urbnum);
44704 usbmon_urb_submit(&hcd->self, urb);
44705
44706 /* NOTE requirements on root-hub callers (usbfs and the hub
44707 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44708 urb->hcpriv = NULL;
44709 INIT_LIST_HEAD(&urb->urb_list);
44710 atomic_dec(&urb->use_count);
44711 - atomic_dec(&urb->dev->urbnum);
44712 + atomic_dec_unchecked(&urb->dev->urbnum);
44713 if (atomic_read(&urb->reject))
44714 wake_up(&usb_kill_urb_queue);
44715 usb_put_urb(urb);
44716 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44717 index 444d30e..f15c850 100644
44718 --- a/drivers/usb/core/message.c
44719 +++ b/drivers/usb/core/message.c
44720 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44721 * method can wait for it to complete. Since you don't have a handle on the
44722 * URB used, you can't cancel the request.
44723 */
44724 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44725 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44726 __u8 requesttype, __u16 value, __u16 index, void *data,
44727 __u16 size, int timeout)
44728 {
44729 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44730 index aa38db4..0a08682 100644
44731 --- a/drivers/usb/core/sysfs.c
44732 +++ b/drivers/usb/core/sysfs.c
44733 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44734 struct usb_device *udev;
44735
44736 udev = to_usb_device(dev);
44737 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44738 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44739 }
44740 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44741
44742 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44743 index b10da72..43aa0b2 100644
44744 --- a/drivers/usb/core/usb.c
44745 +++ b/drivers/usb/core/usb.c
44746 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44747 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44748 dev->state = USB_STATE_ATTACHED;
44749 dev->lpm_disable_count = 1;
44750 - atomic_set(&dev->urbnum, 0);
44751 + atomic_set_unchecked(&dev->urbnum, 0);
44752
44753 INIT_LIST_HEAD(&dev->ep0.urb_list);
44754 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44755 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44756 index 5e29dde..eca992f 100644
44757 --- a/drivers/usb/early/ehci-dbgp.c
44758 +++ b/drivers/usb/early/ehci-dbgp.c
44759 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44760
44761 #ifdef CONFIG_KGDB
44762 static struct kgdb_io kgdbdbgp_io_ops;
44763 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44764 +static struct kgdb_io kgdbdbgp_io_ops_console;
44765 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44766 #else
44767 #define dbgp_kgdb_mode (0)
44768 #endif
44769 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44770 .write_char = kgdbdbgp_write_char,
44771 };
44772
44773 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44774 + .name = "kgdbdbgp",
44775 + .read_char = kgdbdbgp_read_char,
44776 + .write_char = kgdbdbgp_write_char,
44777 + .is_console = 1
44778 +};
44779 +
44780 static int kgdbdbgp_wait_time;
44781
44782 static int __init kgdbdbgp_parse_config(char *str)
44783 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44784 ptr++;
44785 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44786 }
44787 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44788 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44789 + if (early_dbgp_console.index != -1)
44790 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44791 + else
44792 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44793
44794 return 0;
44795 }
44796 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44797 index b369292..9f3ba40 100644
44798 --- a/drivers/usb/gadget/u_serial.c
44799 +++ b/drivers/usb/gadget/u_serial.c
44800 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44801 spin_lock_irq(&port->port_lock);
44802
44803 /* already open? Great. */
44804 - if (port->port.count) {
44805 + if (atomic_read(&port->port.count)) {
44806 status = 0;
44807 - port->port.count++;
44808 + atomic_inc(&port->port.count);
44809
44810 /* currently opening/closing? wait ... */
44811 } else if (port->openclose) {
44812 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44813 tty->driver_data = port;
44814 port->port.tty = tty;
44815
44816 - port->port.count = 1;
44817 + atomic_set(&port->port.count, 1);
44818 port->openclose = false;
44819
44820 /* if connected, start the I/O stream */
44821 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44822
44823 spin_lock_irq(&port->port_lock);
44824
44825 - if (port->port.count != 1) {
44826 - if (port->port.count == 0)
44827 + if (atomic_read(&port->port.count) != 1) {
44828 + if (atomic_read(&port->port.count) == 0)
44829 WARN_ON(1);
44830 else
44831 - --port->port.count;
44832 + atomic_dec(&port->port.count);
44833 goto exit;
44834 }
44835
44836 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44837 * and sleep if necessary
44838 */
44839 port->openclose = true;
44840 - port->port.count = 0;
44841 + atomic_set(&port->port.count, 0);
44842
44843 gser = port->port_usb;
44844 if (gser && gser->disconnect)
44845 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44846 int cond;
44847
44848 spin_lock_irq(&port->port_lock);
44849 - cond = (port->port.count == 0) && !port->openclose;
44850 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44851 spin_unlock_irq(&port->port_lock);
44852 return cond;
44853 }
44854 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44855 /* if it's already open, start I/O ... and notify the serial
44856 * protocol about open/close status (connect/disconnect).
44857 */
44858 - if (port->port.count) {
44859 + if (atomic_read(&port->port.count)) {
44860 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44861 gs_start_io(port);
44862 if (gser->connect)
44863 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44864
44865 port->port_usb = NULL;
44866 gser->ioport = NULL;
44867 - if (port->port.count > 0 || port->openclose) {
44868 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44869 wake_up_interruptible(&port->drain_wait);
44870 if (port->port.tty)
44871 tty_hangup(port->port.tty);
44872 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44873
44874 /* finally, free any unused/unusable I/O buffers */
44875 spin_lock_irqsave(&port->port_lock, flags);
44876 - if (port->port.count == 0 && !port->openclose)
44877 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44878 gs_buf_free(&port->port_write_buf);
44879 gs_free_requests(gser->out, &port->read_pool, NULL);
44880 gs_free_requests(gser->out, &port->read_queue, NULL);
44881 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44882 index 5f3bcd3..bfca43f 100644
44883 --- a/drivers/usb/serial/console.c
44884 +++ b/drivers/usb/serial/console.c
44885 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44886
44887 info->port = port;
44888
44889 - ++port->port.count;
44890 + atomic_inc(&port->port.count);
44891 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44892 if (serial->type->set_termios) {
44893 /*
44894 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44895 }
44896 /* Now that any required fake tty operations are completed restore
44897 * the tty port count */
44898 - --port->port.count;
44899 + atomic_dec(&port->port.count);
44900 /* The console is special in terms of closing the device so
44901 * indicate this port is now acting as a system console. */
44902 port->port.console = 1;
44903 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44904 free_tty:
44905 kfree(tty);
44906 reset_open_count:
44907 - port->port.count = 0;
44908 + atomic_set(&port->port.count, 0);
44909 usb_autopm_put_interface(serial->interface);
44910 error_get_interface:
44911 usb_serial_put(serial);
44912 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44913 index 75f70f0..d467e1a 100644
44914 --- a/drivers/usb/storage/usb.h
44915 +++ b/drivers/usb/storage/usb.h
44916 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44917 __u8 useProtocol;
44918 __u8 useTransport;
44919 int (*initFunction)(struct us_data *);
44920 -};
44921 +} __do_const;
44922
44923
44924 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44925 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44926 index d6bea3e..60b250e 100644
44927 --- a/drivers/usb/wusbcore/wa-hc.h
44928 +++ b/drivers/usb/wusbcore/wa-hc.h
44929 @@ -192,7 +192,7 @@ struct wahc {
44930 struct list_head xfer_delayed_list;
44931 spinlock_t xfer_list_lock;
44932 struct work_struct xfer_work;
44933 - atomic_t xfer_id_count;
44934 + atomic_unchecked_t xfer_id_count;
44935 };
44936
44937
44938 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44939 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44940 spin_lock_init(&wa->xfer_list_lock);
44941 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44942 - atomic_set(&wa->xfer_id_count, 1);
44943 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44944 }
44945
44946 /**
44947 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44948 index 6ef94bc..1b41265 100644
44949 --- a/drivers/usb/wusbcore/wa-xfer.c
44950 +++ b/drivers/usb/wusbcore/wa-xfer.c
44951 @@ -296,7 +296,7 @@ out:
44952 */
44953 static void wa_xfer_id_init(struct wa_xfer *xfer)
44954 {
44955 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44956 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44957 }
44958
44959 /*
44960 diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
44961 index f80d3dd..8ca5ac7 100644
44962 --- a/drivers/vhost/net.c
44963 +++ b/drivers/vhost/net.c
44964 @@ -150,6 +150,11 @@ static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs)
44965 {
44966 kref_put(&ubufs->kref, vhost_net_zerocopy_done_signal);
44967 wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
44968 +}
44969 +
44970 +static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs)
44971 +{
44972 + vhost_net_ubuf_put_and_wait(ubufs);
44973 kfree(ubufs);
44974 }
44975
44976 @@ -948,7 +953,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
44977 mutex_unlock(&vq->mutex);
44978
44979 if (oldubufs) {
44980 - vhost_net_ubuf_put_and_wait(oldubufs);
44981 + vhost_net_ubuf_put_wait_and_free(oldubufs);
44982 mutex_lock(&vq->mutex);
44983 vhost_zerocopy_signal_used(n, vq);
44984 mutex_unlock(&vq->mutex);
44985 @@ -966,7 +971,7 @@ err_used:
44986 rcu_assign_pointer(vq->private_data, oldsock);
44987 vhost_net_enable_vq(n, vq);
44988 if (ubufs)
44989 - vhost_net_ubuf_put_and_wait(ubufs);
44990 + vhost_net_ubuf_put_wait_and_free(ubufs);
44991 err_ubufs:
44992 fput(sock->file);
44993 err_vq:
44994 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
44995 index 5174eba..86e764a 100644
44996 --- a/drivers/vhost/vringh.c
44997 +++ b/drivers/vhost/vringh.c
44998 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
44999
45000 static inline int putu16_kern(u16 *p, u16 val)
45001 {
45002 - ACCESS_ONCE(*p) = val;
45003 + ACCESS_ONCE_RW(*p) = val;
45004 return 0;
45005 }
45006
45007 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45008 index 8c55011..eed4ae1a 100644
45009 --- a/drivers/video/aty/aty128fb.c
45010 +++ b/drivers/video/aty/aty128fb.c
45011 @@ -149,7 +149,7 @@ enum {
45012 };
45013
45014 /* Must match above enum */
45015 -static char * const r128_family[] = {
45016 +static const char * const r128_family[] = {
45017 "AGP",
45018 "PCI",
45019 "PRO AGP",
45020 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45021 index 4f27fdc..d3537e6 100644
45022 --- a/drivers/video/aty/atyfb_base.c
45023 +++ b/drivers/video/aty/atyfb_base.c
45024 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45025 par->accel_flags = var->accel_flags; /* hack */
45026
45027 if (var->accel_flags) {
45028 - info->fbops->fb_sync = atyfb_sync;
45029 + pax_open_kernel();
45030 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45031 + pax_close_kernel();
45032 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45033 } else {
45034 - info->fbops->fb_sync = NULL;
45035 + pax_open_kernel();
45036 + *(void **)&info->fbops->fb_sync = NULL;
45037 + pax_close_kernel();
45038 info->flags |= FBINFO_HWACCEL_DISABLED;
45039 }
45040
45041 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45042 index 95ec042..e6affdd 100644
45043 --- a/drivers/video/aty/mach64_cursor.c
45044 +++ b/drivers/video/aty/mach64_cursor.c
45045 @@ -7,6 +7,7 @@
45046 #include <linux/string.h>
45047
45048 #include <asm/io.h>
45049 +#include <asm/pgtable.h>
45050
45051 #ifdef __sparc__
45052 #include <asm/fbio.h>
45053 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45054 info->sprite.buf_align = 16; /* and 64 lines tall. */
45055 info->sprite.flags = FB_PIXMAP_IO;
45056
45057 - info->fbops->fb_cursor = atyfb_cursor;
45058 + pax_open_kernel();
45059 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45060 + pax_close_kernel();
45061
45062 return 0;
45063 }
45064 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45065 index bca6ccc..252107e 100644
45066 --- a/drivers/video/backlight/kb3886_bl.c
45067 +++ b/drivers/video/backlight/kb3886_bl.c
45068 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45069 static unsigned long kb3886bl_flags;
45070 #define KB3886BL_SUSPENDED 0x01
45071
45072 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45073 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45074 {
45075 .ident = "Sahara Touch-iT",
45076 .matches = {
45077 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45078 index 900aa4e..6d49418 100644
45079 --- a/drivers/video/fb_defio.c
45080 +++ b/drivers/video/fb_defio.c
45081 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45082
45083 BUG_ON(!fbdefio);
45084 mutex_init(&fbdefio->lock);
45085 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45086 + pax_open_kernel();
45087 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45088 + pax_close_kernel();
45089 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45090 INIT_LIST_HEAD(&fbdefio->pagelist);
45091 if (fbdefio->delay == 0) /* set a default of 1 s */
45092 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45093 page->mapping = NULL;
45094 }
45095
45096 - info->fbops->fb_mmap = NULL;
45097 + *(void **)&info->fbops->fb_mmap = NULL;
45098 mutex_destroy(&fbdefio->lock);
45099 }
45100 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45101 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45102 index 5c3960d..15cf8fc 100644
45103 --- a/drivers/video/fbcmap.c
45104 +++ b/drivers/video/fbcmap.c
45105 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45106 rc = -ENODEV;
45107 goto out;
45108 }
45109 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45110 - !info->fbops->fb_setcmap)) {
45111 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45112 rc = -EINVAL;
45113 goto out1;
45114 }
45115 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45116 index 098bfc6..796841d 100644
45117 --- a/drivers/video/fbmem.c
45118 +++ b/drivers/video/fbmem.c
45119 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45120 image->dx += image->width + 8;
45121 }
45122 } else if (rotate == FB_ROTATE_UD) {
45123 - for (x = 0; x < num && image->dx >= 0; x++) {
45124 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45125 info->fbops->fb_imageblit(info, image);
45126 image->dx -= image->width + 8;
45127 }
45128 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45129 image->dy += image->height + 8;
45130 }
45131 } else if (rotate == FB_ROTATE_CCW) {
45132 - for (x = 0; x < num && image->dy >= 0; x++) {
45133 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45134 info->fbops->fb_imageblit(info, image);
45135 image->dy -= image->height + 8;
45136 }
45137 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45138 return -EFAULT;
45139 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45140 return -EINVAL;
45141 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45142 + if (con2fb.framebuffer >= FB_MAX)
45143 return -EINVAL;
45144 if (!registered_fb[con2fb.framebuffer])
45145 request_module("fb%d", con2fb.framebuffer);
45146 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45147 index 7672d2e..b56437f 100644
45148 --- a/drivers/video/i810/i810_accel.c
45149 +++ b/drivers/video/i810/i810_accel.c
45150 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45151 }
45152 }
45153 printk("ringbuffer lockup!!!\n");
45154 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45155 i810_report_error(mmio);
45156 par->dev_flags |= LOCKUP;
45157 info->pixmap.scan_align = 1;
45158 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45159 index 3c14e43..eafa544 100644
45160 --- a/drivers/video/logo/logo_linux_clut224.ppm
45161 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45162 @@ -1,1604 +1,1123 @@
45163 P3
45164 -# Standard 224-color Linux logo
45165 80 80
45166 255
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 6 6 6 6 6 6 10 10 10 10 10 10
45177 - 10 10 10 6 6 6 6 6 6 6 6 6
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 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
45190 - 0 0 0 0 0 0 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 6 6 6 10 10 10 14 14 14
45196 - 22 22 22 26 26 26 30 30 30 34 34 34
45197 - 30 30 30 30 30 30 26 26 26 18 18 18
45198 - 14 14 14 10 10 10 6 6 6 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 1 0 0 1 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 6 6 6 14 14 14 26 26 26 42 42 42
45216 - 54 54 54 66 66 66 78 78 78 78 78 78
45217 - 78 78 78 74 74 74 66 66 66 54 54 54
45218 - 42 42 42 26 26 26 18 18 18 10 10 10
45219 - 6 6 6 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 1 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 10 10 10
45235 - 22 22 22 42 42 42 66 66 66 86 86 86
45236 - 66 66 66 38 38 38 38 38 38 22 22 22
45237 - 26 26 26 34 34 34 54 54 54 66 66 66
45238 - 86 86 86 70 70 70 46 46 46 26 26 26
45239 - 14 14 14 6 6 6 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 1 0 0 1 0 0 1 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 10 10 10 26 26 26
45255 - 50 50 50 82 82 82 58 58 58 6 6 6
45256 - 2 2 6 2 2 6 2 2 6 2 2 6
45257 - 2 2 6 2 2 6 2 2 6 2 2 6
45258 - 6 6 6 54 54 54 86 86 86 66 66 66
45259 - 38 38 38 18 18 18 6 6 6 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 6 6 6 22 22 22 50 50 50
45275 - 78 78 78 34 34 34 2 2 6 2 2 6
45276 - 2 2 6 2 2 6 2 2 6 2 2 6
45277 - 2 2 6 2 2 6 2 2 6 2 2 6
45278 - 2 2 6 2 2 6 6 6 6 70 70 70
45279 - 78 78 78 46 46 46 22 22 22 6 6 6
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 1 0 0 1 0 0 1 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 6 6 6 18 18 18 42 42 42 82 82 82
45295 - 26 26 26 2 2 6 2 2 6 2 2 6
45296 - 2 2 6 2 2 6 2 2 6 2 2 6
45297 - 2 2 6 2 2 6 2 2 6 14 14 14
45298 - 46 46 46 34 34 34 6 6 6 2 2 6
45299 - 42 42 42 78 78 78 42 42 42 18 18 18
45300 - 6 6 6 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 1 0 0 0 0 0 1 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 10 10 10 30 30 30 66 66 66 58 58 58
45315 - 2 2 6 2 2 6 2 2 6 2 2 6
45316 - 2 2 6 2 2 6 2 2 6 2 2 6
45317 - 2 2 6 2 2 6 2 2 6 26 26 26
45318 - 86 86 86 101 101 101 46 46 46 10 10 10
45319 - 2 2 6 58 58 58 70 70 70 34 34 34
45320 - 10 10 10 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 1 0 0 1 0 0 1 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 14 14 14 42 42 42 86 86 86 10 10 10
45335 - 2 2 6 2 2 6 2 2 6 2 2 6
45336 - 2 2 6 2 2 6 2 2 6 2 2 6
45337 - 2 2 6 2 2 6 2 2 6 30 30 30
45338 - 94 94 94 94 94 94 58 58 58 26 26 26
45339 - 2 2 6 6 6 6 78 78 78 54 54 54
45340 - 22 22 22 6 6 6 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 6 6 6
45354 - 22 22 22 62 62 62 62 62 62 2 2 6
45355 - 2 2 6 2 2 6 2 2 6 2 2 6
45356 - 2 2 6 2 2 6 2 2 6 2 2 6
45357 - 2 2 6 2 2 6 2 2 6 26 26 26
45358 - 54 54 54 38 38 38 18 18 18 10 10 10
45359 - 2 2 6 2 2 6 34 34 34 82 82 82
45360 - 38 38 38 14 14 14 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 1 0 0 1 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 6 6 6
45374 - 30 30 30 78 78 78 30 30 30 2 2 6
45375 - 2 2 6 2 2 6 2 2 6 2 2 6
45376 - 2 2 6 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 2 2 6 2 2 6 10 10 10
45378 - 10 10 10 2 2 6 2 2 6 2 2 6
45379 - 2 2 6 2 2 6 2 2 6 78 78 78
45380 - 50 50 50 18 18 18 6 6 6 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 1 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 10 10 10
45394 - 38 38 38 86 86 86 14 14 14 2 2 6
45395 - 2 2 6 2 2 6 2 2 6 2 2 6
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 2 2 6 2 2 6 2 2 6
45398 - 2 2 6 2 2 6 2 2 6 2 2 6
45399 - 2 2 6 2 2 6 2 2 6 54 54 54
45400 - 66 66 66 26 26 26 6 6 6 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 1 0 0 1 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 14 14 14
45414 - 42 42 42 82 82 82 2 2 6 2 2 6
45415 - 2 2 6 6 6 6 10 10 10 2 2 6
45416 - 2 2 6 2 2 6 2 2 6 2 2 6
45417 - 2 2 6 2 2 6 2 2 6 6 6 6
45418 - 14 14 14 10 10 10 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 2 2 6 18 18 18
45420 - 82 82 82 34 34 34 10 10 10 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 1 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 14 14 14
45434 - 46 46 46 86 86 86 2 2 6 2 2 6
45435 - 6 6 6 6 6 6 22 22 22 34 34 34
45436 - 6 6 6 2 2 6 2 2 6 2 2 6
45437 - 2 2 6 2 2 6 18 18 18 34 34 34
45438 - 10 10 10 50 50 50 22 22 22 2 2 6
45439 - 2 2 6 2 2 6 2 2 6 10 10 10
45440 - 86 86 86 42 42 42 14 14 14 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 1 0 0 1 0 0 1 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 14 14 14
45454 - 46 46 46 86 86 86 2 2 6 2 2 6
45455 - 38 38 38 116 116 116 94 94 94 22 22 22
45456 - 22 22 22 2 2 6 2 2 6 2 2 6
45457 - 14 14 14 86 86 86 138 138 138 162 162 162
45458 -154 154 154 38 38 38 26 26 26 6 6 6
45459 - 2 2 6 2 2 6 2 2 6 2 2 6
45460 - 86 86 86 46 46 46 14 14 14 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 14 14 14
45474 - 46 46 46 86 86 86 2 2 6 14 14 14
45475 -134 134 134 198 198 198 195 195 195 116 116 116
45476 - 10 10 10 2 2 6 2 2 6 6 6 6
45477 -101 98 89 187 187 187 210 210 210 218 218 218
45478 -214 214 214 134 134 134 14 14 14 6 6 6
45479 - 2 2 6 2 2 6 2 2 6 2 2 6
45480 - 86 86 86 50 50 50 18 18 18 6 6 6
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 1 0 0 0
45488 - 0 0 1 0 0 1 0 0 1 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 14 14 14
45494 - 46 46 46 86 86 86 2 2 6 54 54 54
45495 -218 218 218 195 195 195 226 226 226 246 246 246
45496 - 58 58 58 2 2 6 2 2 6 30 30 30
45497 -210 210 210 253 253 253 174 174 174 123 123 123
45498 -221 221 221 234 234 234 74 74 74 2 2 6
45499 - 2 2 6 2 2 6 2 2 6 2 2 6
45500 - 70 70 70 58 58 58 22 22 22 6 6 6
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 14 14 14
45514 - 46 46 46 82 82 82 2 2 6 106 106 106
45515 -170 170 170 26 26 26 86 86 86 226 226 226
45516 -123 123 123 10 10 10 14 14 14 46 46 46
45517 -231 231 231 190 190 190 6 6 6 70 70 70
45518 - 90 90 90 238 238 238 158 158 158 2 2 6
45519 - 2 2 6 2 2 6 2 2 6 2 2 6
45520 - 70 70 70 58 58 58 22 22 22 6 6 6
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 1 0 0 0
45528 - 0 0 1 0 0 1 0 0 1 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 14 14 14
45534 - 42 42 42 86 86 86 6 6 6 116 116 116
45535 -106 106 106 6 6 6 70 70 70 149 149 149
45536 -128 128 128 18 18 18 38 38 38 54 54 54
45537 -221 221 221 106 106 106 2 2 6 14 14 14
45538 - 46 46 46 190 190 190 198 198 198 2 2 6
45539 - 2 2 6 2 2 6 2 2 6 2 2 6
45540 - 74 74 74 62 62 62 22 22 22 6 6 6
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 1 0 0 0
45548 - 0 0 1 0 0 0 0 0 1 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 14 14 14
45554 - 42 42 42 94 94 94 14 14 14 101 101 101
45555 -128 128 128 2 2 6 18 18 18 116 116 116
45556 -118 98 46 121 92 8 121 92 8 98 78 10
45557 -162 162 162 106 106 106 2 2 6 2 2 6
45558 - 2 2 6 195 195 195 195 195 195 6 6 6
45559 - 2 2 6 2 2 6 2 2 6 2 2 6
45560 - 74 74 74 62 62 62 22 22 22 6 6 6
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 1 0 0 1
45568 - 0 0 1 0 0 0 0 0 1 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 10 10 10
45574 - 38 38 38 90 90 90 14 14 14 58 58 58
45575 -210 210 210 26 26 26 54 38 6 154 114 10
45576 -226 170 11 236 186 11 225 175 15 184 144 12
45577 -215 174 15 175 146 61 37 26 9 2 2 6
45578 - 70 70 70 246 246 246 138 138 138 2 2 6
45579 - 2 2 6 2 2 6 2 2 6 2 2 6
45580 - 70 70 70 66 66 66 26 26 26 6 6 6
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 10 10 10
45594 - 38 38 38 86 86 86 14 14 14 10 10 10
45595 -195 195 195 188 164 115 192 133 9 225 175 15
45596 -239 182 13 234 190 10 232 195 16 232 200 30
45597 -245 207 45 241 208 19 232 195 16 184 144 12
45598 -218 194 134 211 206 186 42 42 42 2 2 6
45599 - 2 2 6 2 2 6 2 2 6 2 2 6
45600 - 50 50 50 74 74 74 30 30 30 6 6 6
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 0 0 0
45608 - 0 0 0 0 0 0 0 0 0 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 10 10 10
45614 - 34 34 34 86 86 86 14 14 14 2 2 6
45615 -121 87 25 192 133 9 219 162 10 239 182 13
45616 -236 186 11 232 195 16 241 208 19 244 214 54
45617 -246 218 60 246 218 38 246 215 20 241 208 19
45618 -241 208 19 226 184 13 121 87 25 2 2 6
45619 - 2 2 6 2 2 6 2 2 6 2 2 6
45620 - 50 50 50 82 82 82 34 34 34 10 10 10
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 10 10 10
45634 - 34 34 34 82 82 82 30 30 30 61 42 6
45635 -180 123 7 206 145 10 230 174 11 239 182 13
45636 -234 190 10 238 202 15 241 208 19 246 218 74
45637 -246 218 38 246 215 20 246 215 20 246 215 20
45638 -226 184 13 215 174 15 184 144 12 6 6 6
45639 - 2 2 6 2 2 6 2 2 6 2 2 6
45640 - 26 26 26 94 94 94 42 42 42 14 14 14
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 0 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 10 10 10
45654 - 30 30 30 78 78 78 50 50 50 104 69 6
45655 -192 133 9 216 158 10 236 178 12 236 186 11
45656 -232 195 16 241 208 19 244 214 54 245 215 43
45657 -246 215 20 246 215 20 241 208 19 198 155 10
45658 -200 144 11 216 158 10 156 118 10 2 2 6
45659 - 2 2 6 2 2 6 2 2 6 2 2 6
45660 - 6 6 6 90 90 90 54 54 54 18 18 18
45661 - 6 6 6 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 10 10 10
45674 - 30 30 30 78 78 78 46 46 46 22 22 22
45675 -137 92 6 210 162 10 239 182 13 238 190 10
45676 -238 202 15 241 208 19 246 215 20 246 215 20
45677 -241 208 19 203 166 17 185 133 11 210 150 10
45678 -216 158 10 210 150 10 102 78 10 2 2 6
45679 - 6 6 6 54 54 54 14 14 14 2 2 6
45680 - 2 2 6 62 62 62 74 74 74 30 30 30
45681 - 10 10 10 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 10 10 10
45694 - 34 34 34 78 78 78 50 50 50 6 6 6
45695 - 94 70 30 139 102 15 190 146 13 226 184 13
45696 -232 200 30 232 195 16 215 174 15 190 146 13
45697 -168 122 10 192 133 9 210 150 10 213 154 11
45698 -202 150 34 182 157 106 101 98 89 2 2 6
45699 - 2 2 6 78 78 78 116 116 116 58 58 58
45700 - 2 2 6 22 22 22 90 90 90 46 46 46
45701 - 18 18 18 6 6 6 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 10 10 10
45714 - 38 38 38 86 86 86 50 50 50 6 6 6
45715 -128 128 128 174 154 114 156 107 11 168 122 10
45716 -198 155 10 184 144 12 197 138 11 200 144 11
45717 -206 145 10 206 145 10 197 138 11 188 164 115
45718 -195 195 195 198 198 198 174 174 174 14 14 14
45719 - 2 2 6 22 22 22 116 116 116 116 116 116
45720 - 22 22 22 2 2 6 74 74 74 70 70 70
45721 - 30 30 30 10 10 10 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 6 6 6 18 18 18
45734 - 50 50 50 101 101 101 26 26 26 10 10 10
45735 -138 138 138 190 190 190 174 154 114 156 107 11
45736 -197 138 11 200 144 11 197 138 11 192 133 9
45737 -180 123 7 190 142 34 190 178 144 187 187 187
45738 -202 202 202 221 221 221 214 214 214 66 66 66
45739 - 2 2 6 2 2 6 50 50 50 62 62 62
45740 - 6 6 6 2 2 6 10 10 10 90 90 90
45741 - 50 50 50 18 18 18 6 6 6 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 10 10 10 34 34 34
45754 - 74 74 74 74 74 74 2 2 6 6 6 6
45755 -144 144 144 198 198 198 190 190 190 178 166 146
45756 -154 121 60 156 107 11 156 107 11 168 124 44
45757 -174 154 114 187 187 187 190 190 190 210 210 210
45758 -246 246 246 253 253 253 253 253 253 182 182 182
45759 - 6 6 6 2 2 6 2 2 6 2 2 6
45760 - 2 2 6 2 2 6 2 2 6 62 62 62
45761 - 74 74 74 34 34 34 14 14 14 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 10 10 10 22 22 22 54 54 54
45774 - 94 94 94 18 18 18 2 2 6 46 46 46
45775 -234 234 234 221 221 221 190 190 190 190 190 190
45776 -190 190 190 187 187 187 187 187 187 190 190 190
45777 -190 190 190 195 195 195 214 214 214 242 242 242
45778 -253 253 253 253 253 253 253 253 253 253 253 253
45779 - 82 82 82 2 2 6 2 2 6 2 2 6
45780 - 2 2 6 2 2 6 2 2 6 14 14 14
45781 - 86 86 86 54 54 54 22 22 22 6 6 6
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 6 6 6 18 18 18 46 46 46 90 90 90
45794 - 46 46 46 18 18 18 6 6 6 182 182 182
45795 -253 253 253 246 246 246 206 206 206 190 190 190
45796 -190 190 190 190 190 190 190 190 190 190 190 190
45797 -206 206 206 231 231 231 250 250 250 253 253 253
45798 -253 253 253 253 253 253 253 253 253 253 253 253
45799 -202 202 202 14 14 14 2 2 6 2 2 6
45800 - 2 2 6 2 2 6 2 2 6 2 2 6
45801 - 42 42 42 86 86 86 42 42 42 18 18 18
45802 - 6 6 6 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 6 6 6
45813 - 14 14 14 38 38 38 74 74 74 66 66 66
45814 - 2 2 6 6 6 6 90 90 90 250 250 250
45815 -253 253 253 253 253 253 238 238 238 198 198 198
45816 -190 190 190 190 190 190 195 195 195 221 221 221
45817 -246 246 246 253 253 253 253 253 253 253 253 253
45818 -253 253 253 253 253 253 253 253 253 253 253 253
45819 -253 253 253 82 82 82 2 2 6 2 2 6
45820 - 2 2 6 2 2 6 2 2 6 2 2 6
45821 - 2 2 6 78 78 78 70 70 70 34 34 34
45822 - 14 14 14 6 6 6 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 14 14 14
45833 - 34 34 34 66 66 66 78 78 78 6 6 6
45834 - 2 2 6 18 18 18 218 218 218 253 253 253
45835 -253 253 253 253 253 253 253 253 253 246 246 246
45836 -226 226 226 231 231 231 246 246 246 253 253 253
45837 -253 253 253 253 253 253 253 253 253 253 253 253
45838 -253 253 253 253 253 253 253 253 253 253 253 253
45839 -253 253 253 178 178 178 2 2 6 2 2 6
45840 - 2 2 6 2 2 6 2 2 6 2 2 6
45841 - 2 2 6 18 18 18 90 90 90 62 62 62
45842 - 30 30 30 10 10 10 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 0 0 0 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 10 10 10 26 26 26
45853 - 58 58 58 90 90 90 18 18 18 2 2 6
45854 - 2 2 6 110 110 110 253 253 253 253 253 253
45855 -253 253 253 253 253 253 253 253 253 253 253 253
45856 -250 250 250 253 253 253 253 253 253 253 253 253
45857 -253 253 253 253 253 253 253 253 253 253 253 253
45858 -253 253 253 253 253 253 253 253 253 253 253 253
45859 -253 253 253 231 231 231 18 18 18 2 2 6
45860 - 2 2 6 2 2 6 2 2 6 2 2 6
45861 - 2 2 6 2 2 6 18 18 18 94 94 94
45862 - 54 54 54 26 26 26 10 10 10 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 6 6 6 22 22 22 50 50 50
45873 - 90 90 90 26 26 26 2 2 6 2 2 6
45874 - 14 14 14 195 195 195 250 250 250 253 253 253
45875 -253 253 253 253 253 253 253 253 253 253 253 253
45876 -253 253 253 253 253 253 253 253 253 253 253 253
45877 -253 253 253 253 253 253 253 253 253 253 253 253
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -250 250 250 242 242 242 54 54 54 2 2 6
45880 - 2 2 6 2 2 6 2 2 6 2 2 6
45881 - 2 2 6 2 2 6 2 2 6 38 38 38
45882 - 86 86 86 50 50 50 22 22 22 6 6 6
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 6 6 6 14 14 14 38 38 38 82 82 82
45893 - 34 34 34 2 2 6 2 2 6 2 2 6
45894 - 42 42 42 195 195 195 246 246 246 253 253 253
45895 -253 253 253 253 253 253 253 253 253 250 250 250
45896 -242 242 242 242 242 242 250 250 250 253 253 253
45897 -253 253 253 253 253 253 253 253 253 253 253 253
45898 -253 253 253 250 250 250 246 246 246 238 238 238
45899 -226 226 226 231 231 231 101 101 101 6 6 6
45900 - 2 2 6 2 2 6 2 2 6 2 2 6
45901 - 2 2 6 2 2 6 2 2 6 2 2 6
45902 - 38 38 38 82 82 82 42 42 42 14 14 14
45903 - 6 6 6 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 10 10 10 26 26 26 62 62 62 66 66 66
45913 - 2 2 6 2 2 6 2 2 6 6 6 6
45914 - 70 70 70 170 170 170 206 206 206 234 234 234
45915 -246 246 246 250 250 250 250 250 250 238 238 238
45916 -226 226 226 231 231 231 238 238 238 250 250 250
45917 -250 250 250 250 250 250 246 246 246 231 231 231
45918 -214 214 214 206 206 206 202 202 202 202 202 202
45919 -198 198 198 202 202 202 182 182 182 18 18 18
45920 - 2 2 6 2 2 6 2 2 6 2 2 6
45921 - 2 2 6 2 2 6 2 2 6 2 2 6
45922 - 2 2 6 62 62 62 66 66 66 30 30 30
45923 - 10 10 10 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 0 0 0 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 14 14 14 42 42 42 82 82 82 18 18 18
45933 - 2 2 6 2 2 6 2 2 6 10 10 10
45934 - 94 94 94 182 182 182 218 218 218 242 242 242
45935 -250 250 250 253 253 253 253 253 253 250 250 250
45936 -234 234 234 253 253 253 253 253 253 253 253 253
45937 -253 253 253 253 253 253 253 253 253 246 246 246
45938 -238 238 238 226 226 226 210 210 210 202 202 202
45939 -195 195 195 195 195 195 210 210 210 158 158 158
45940 - 6 6 6 14 14 14 50 50 50 14 14 14
45941 - 2 2 6 2 2 6 2 2 6 2 2 6
45942 - 2 2 6 6 6 6 86 86 86 46 46 46
45943 - 18 18 18 6 6 6 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 6 6 6
45952 - 22 22 22 54 54 54 70 70 70 2 2 6
45953 - 2 2 6 10 10 10 2 2 6 22 22 22
45954 -166 166 166 231 231 231 250 250 250 253 253 253
45955 -253 253 253 253 253 253 253 253 253 250 250 250
45956 -242 242 242 253 253 253 253 253 253 253 253 253
45957 -253 253 253 253 253 253 253 253 253 253 253 253
45958 -253 253 253 253 253 253 253 253 253 246 246 246
45959 -231 231 231 206 206 206 198 198 198 226 226 226
45960 - 94 94 94 2 2 6 6 6 6 38 38 38
45961 - 30 30 30 2 2 6 2 2 6 2 2 6
45962 - 2 2 6 2 2 6 62 62 62 66 66 66
45963 - 26 26 26 10 10 10 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 10 10 10
45972 - 30 30 30 74 74 74 50 50 50 2 2 6
45973 - 26 26 26 26 26 26 2 2 6 106 106 106
45974 -238 238 238 253 253 253 253 253 253 253 253 253
45975 -253 253 253 253 253 253 253 253 253 253 253 253
45976 -253 253 253 253 253 253 253 253 253 253 253 253
45977 -253 253 253 253 253 253 253 253 253 253 253 253
45978 -253 253 253 253 253 253 253 253 253 253 253 253
45979 -253 253 253 246 246 246 218 218 218 202 202 202
45980 -210 210 210 14 14 14 2 2 6 2 2 6
45981 - 30 30 30 22 22 22 2 2 6 2 2 6
45982 - 2 2 6 2 2 6 18 18 18 86 86 86
45983 - 42 42 42 14 14 14 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 14 14 14
45992 - 42 42 42 90 90 90 22 22 22 2 2 6
45993 - 42 42 42 2 2 6 18 18 18 218 218 218
45994 -253 253 253 253 253 253 253 253 253 253 253 253
45995 -253 253 253 253 253 253 253 253 253 253 253 253
45996 -253 253 253 253 253 253 253 253 253 253 253 253
45997 -253 253 253 253 253 253 253 253 253 253 253 253
45998 -253 253 253 253 253 253 253 253 253 253 253 253
45999 -253 253 253 253 253 253 250 250 250 221 221 221
46000 -218 218 218 101 101 101 2 2 6 14 14 14
46001 - 18 18 18 38 38 38 10 10 10 2 2 6
46002 - 2 2 6 2 2 6 2 2 6 78 78 78
46003 - 58 58 58 22 22 22 6 6 6 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 0 0 0 0 0 0
46006 - 0 0 0 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 6 6 6 18 18 18
46012 - 54 54 54 82 82 82 2 2 6 26 26 26
46013 - 22 22 22 2 2 6 123 123 123 253 253 253
46014 -253 253 253 253 253 253 253 253 253 253 253 253
46015 -253 253 253 253 253 253 253 253 253 253 253 253
46016 -253 253 253 253 253 253 253 253 253 253 253 253
46017 -253 253 253 253 253 253 253 253 253 253 253 253
46018 -253 253 253 253 253 253 253 253 253 253 253 253
46019 -253 253 253 253 253 253 253 253 253 250 250 250
46020 -238 238 238 198 198 198 6 6 6 38 38 38
46021 - 58 58 58 26 26 26 38 38 38 2 2 6
46022 - 2 2 6 2 2 6 2 2 6 46 46 46
46023 - 78 78 78 30 30 30 10 10 10 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 0 0 0 0 0 0
46026 - 0 0 0 0 0 0 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 10 10 10 30 30 30
46032 - 74 74 74 58 58 58 2 2 6 42 42 42
46033 - 2 2 6 22 22 22 231 231 231 253 253 253
46034 -253 253 253 253 253 253 253 253 253 253 253 253
46035 -253 253 253 253 253 253 253 253 253 250 250 250
46036 -253 253 253 253 253 253 253 253 253 253 253 253
46037 -253 253 253 253 253 253 253 253 253 253 253 253
46038 -253 253 253 253 253 253 253 253 253 253 253 253
46039 -253 253 253 253 253 253 253 253 253 253 253 253
46040 -253 253 253 246 246 246 46 46 46 38 38 38
46041 - 42 42 42 14 14 14 38 38 38 14 14 14
46042 - 2 2 6 2 2 6 2 2 6 6 6 6
46043 - 86 86 86 46 46 46 14 14 14 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 6 6 6 14 14 14 42 42 42
46052 - 90 90 90 18 18 18 18 18 18 26 26 26
46053 - 2 2 6 116 116 116 253 253 253 253 253 253
46054 -253 253 253 253 253 253 253 253 253 253 253 253
46055 -253 253 253 253 253 253 250 250 250 238 238 238
46056 -253 253 253 253 253 253 253 253 253 253 253 253
46057 -253 253 253 253 253 253 253 253 253 253 253 253
46058 -253 253 253 253 253 253 253 253 253 253 253 253
46059 -253 253 253 253 253 253 253 253 253 253 253 253
46060 -253 253 253 253 253 253 94 94 94 6 6 6
46061 - 2 2 6 2 2 6 10 10 10 34 34 34
46062 - 2 2 6 2 2 6 2 2 6 2 2 6
46063 - 74 74 74 58 58 58 22 22 22 6 6 6
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 0 0 0
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 10 10 10 26 26 26 66 66 66
46072 - 82 82 82 2 2 6 38 38 38 6 6 6
46073 - 14 14 14 210 210 210 253 253 253 253 253 253
46074 -253 253 253 253 253 253 253 253 253 253 253 253
46075 -253 253 253 253 253 253 246 246 246 242 242 242
46076 -253 253 253 253 253 253 253 253 253 253 253 253
46077 -253 253 253 253 253 253 253 253 253 253 253 253
46078 -253 253 253 253 253 253 253 253 253 253 253 253
46079 -253 253 253 253 253 253 253 253 253 253 253 253
46080 -253 253 253 253 253 253 144 144 144 2 2 6
46081 - 2 2 6 2 2 6 2 2 6 46 46 46
46082 - 2 2 6 2 2 6 2 2 6 2 2 6
46083 - 42 42 42 74 74 74 30 30 30 10 10 10
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 6 6 6 14 14 14 42 42 42 90 90 90
46092 - 26 26 26 6 6 6 42 42 42 2 2 6
46093 - 74 74 74 250 250 250 253 253 253 253 253 253
46094 -253 253 253 253 253 253 253 253 253 253 253 253
46095 -253 253 253 253 253 253 242 242 242 242 242 242
46096 -253 253 253 253 253 253 253 253 253 253 253 253
46097 -253 253 253 253 253 253 253 253 253 253 253 253
46098 -253 253 253 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 182 182 182 2 2 6
46101 - 2 2 6 2 2 6 2 2 6 46 46 46
46102 - 2 2 6 2 2 6 2 2 6 2 2 6
46103 - 10 10 10 86 86 86 38 38 38 10 10 10
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 0 0 0 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 10 10 10 26 26 26 66 66 66 82 82 82
46112 - 2 2 6 22 22 22 18 18 18 2 2 6
46113 -149 149 149 253 253 253 253 253 253 253 253 253
46114 -253 253 253 253 253 253 253 253 253 253 253 253
46115 -253 253 253 253 253 253 234 234 234 242 242 242
46116 -253 253 253 253 253 253 253 253 253 253 253 253
46117 -253 253 253 253 253 253 253 253 253 253 253 253
46118 -253 253 253 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 206 206 206 2 2 6
46121 - 2 2 6 2 2 6 2 2 6 38 38 38
46122 - 2 2 6 2 2 6 2 2 6 2 2 6
46123 - 6 6 6 86 86 86 46 46 46 14 14 14
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 0 0 0 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 6 6 6
46131 - 18 18 18 46 46 46 86 86 86 18 18 18
46132 - 2 2 6 34 34 34 10 10 10 6 6 6
46133 -210 210 210 253 253 253 253 253 253 253 253 253
46134 -253 253 253 253 253 253 253 253 253 253 253 253
46135 -253 253 253 253 253 253 234 234 234 242 242 242
46136 -253 253 253 253 253 253 253 253 253 253 253 253
46137 -253 253 253 253 253 253 253 253 253 253 253 253
46138 -253 253 253 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 253 253 253
46140 -253 253 253 253 253 253 221 221 221 6 6 6
46141 - 2 2 6 2 2 6 6 6 6 30 30 30
46142 - 2 2 6 2 2 6 2 2 6 2 2 6
46143 - 2 2 6 82 82 82 54 54 54 18 18 18
46144 - 6 6 6 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 10 10 10
46151 - 26 26 26 66 66 66 62 62 62 2 2 6
46152 - 2 2 6 38 38 38 10 10 10 26 26 26
46153 -238 238 238 253 253 253 253 253 253 253 253 253
46154 -253 253 253 253 253 253 253 253 253 253 253 253
46155 -253 253 253 253 253 253 231 231 231 238 238 238
46156 -253 253 253 253 253 253 253 253 253 253 253 253
46157 -253 253 253 253 253 253 253 253 253 253 253 253
46158 -253 253 253 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 253 253 253 253 253 253
46160 -253 253 253 253 253 253 231 231 231 6 6 6
46161 - 2 2 6 2 2 6 10 10 10 30 30 30
46162 - 2 2 6 2 2 6 2 2 6 2 2 6
46163 - 2 2 6 66 66 66 58 58 58 22 22 22
46164 - 6 6 6 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 0 0 0 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 10 10 10
46171 - 38 38 38 78 78 78 6 6 6 2 2 6
46172 - 2 2 6 46 46 46 14 14 14 42 42 42
46173 -246 246 246 253 253 253 253 253 253 253 253 253
46174 -253 253 253 253 253 253 253 253 253 253 253 253
46175 -253 253 253 253 253 253 231 231 231 242 242 242
46176 -253 253 253 253 253 253 253 253 253 253 253 253
46177 -253 253 253 253 253 253 253 253 253 253 253 253
46178 -253 253 253 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 253 253 253 253 253 253
46180 -253 253 253 253 253 253 234 234 234 10 10 10
46181 - 2 2 6 2 2 6 22 22 22 14 14 14
46182 - 2 2 6 2 2 6 2 2 6 2 2 6
46183 - 2 2 6 66 66 66 62 62 62 22 22 22
46184 - 6 6 6 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 6 6 6 18 18 18
46191 - 50 50 50 74 74 74 2 2 6 2 2 6
46192 - 14 14 14 70 70 70 34 34 34 62 62 62
46193 -250 250 250 253 253 253 253 253 253 253 253 253
46194 -253 253 253 253 253 253 253 253 253 253 253 253
46195 -253 253 253 253 253 253 231 231 231 246 246 246
46196 -253 253 253 253 253 253 253 253 253 253 253 253
46197 -253 253 253 253 253 253 253 253 253 253 253 253
46198 -253 253 253 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 253 253 253 253 253 253
46200 -253 253 253 253 253 253 234 234 234 14 14 14
46201 - 2 2 6 2 2 6 30 30 30 2 2 6
46202 - 2 2 6 2 2 6 2 2 6 2 2 6
46203 - 2 2 6 66 66 66 62 62 62 22 22 22
46204 - 6 6 6 0 0 0 0 0 0 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 6 6 6 18 18 18
46211 - 54 54 54 62 62 62 2 2 6 2 2 6
46212 - 2 2 6 30 30 30 46 46 46 70 70 70
46213 -250 250 250 253 253 253 253 253 253 253 253 253
46214 -253 253 253 253 253 253 253 253 253 253 253 253
46215 -253 253 253 253 253 253 231 231 231 246 246 246
46216 -253 253 253 253 253 253 253 253 253 253 253 253
46217 -253 253 253 253 253 253 253 253 253 253 253 253
46218 -253 253 253 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 253 253 253 253 253 253
46220 -253 253 253 253 253 253 226 226 226 10 10 10
46221 - 2 2 6 6 6 6 30 30 30 2 2 6
46222 - 2 2 6 2 2 6 2 2 6 2 2 6
46223 - 2 2 6 66 66 66 58 58 58 22 22 22
46224 - 6 6 6 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 0 0 0
46228 - 0 0 0 0 0 0 0 0 0 0 0 0
46229 - 0 0 0 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 6 6 6 22 22 22
46231 - 58 58 58 62 62 62 2 2 6 2 2 6
46232 - 2 2 6 2 2 6 30 30 30 78 78 78
46233 -250 250 250 253 253 253 253 253 253 253 253 253
46234 -253 253 253 253 253 253 253 253 253 253 253 253
46235 -253 253 253 253 253 253 231 231 231 246 246 246
46236 -253 253 253 253 253 253 253 253 253 253 253 253
46237 -253 253 253 253 253 253 253 253 253 253 253 253
46238 -253 253 253 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 253 253 253 253 253 253
46240 -253 253 253 253 253 253 206 206 206 2 2 6
46241 - 22 22 22 34 34 34 18 14 6 22 22 22
46242 - 26 26 26 18 18 18 6 6 6 2 2 6
46243 - 2 2 6 82 82 82 54 54 54 18 18 18
46244 - 6 6 6 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 0 0 0 0 0 0
46249 - 0 0 0 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 6 6 6 26 26 26
46251 - 62 62 62 106 106 106 74 54 14 185 133 11
46252 -210 162 10 121 92 8 6 6 6 62 62 62
46253 -238 238 238 253 253 253 253 253 253 253 253 253
46254 -253 253 253 253 253 253 253 253 253 253 253 253
46255 -253 253 253 253 253 253 231 231 231 246 246 246
46256 -253 253 253 253 253 253 253 253 253 253 253 253
46257 -253 253 253 253 253 253 253 253 253 253 253 253
46258 -253 253 253 253 253 253 253 253 253 253 253 253
46259 -253 253 253 253 253 253 253 253 253 253 253 253
46260 -253 253 253 253 253 253 158 158 158 18 18 18
46261 - 14 14 14 2 2 6 2 2 6 2 2 6
46262 - 6 6 6 18 18 18 66 66 66 38 38 38
46263 - 6 6 6 94 94 94 50 50 50 18 18 18
46264 - 6 6 6 0 0 0 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 0 0 0 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 0 0 0
46268 - 0 0 0 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 6 6 6
46270 - 10 10 10 10 10 10 18 18 18 38 38 38
46271 - 78 78 78 142 134 106 216 158 10 242 186 14
46272 -246 190 14 246 190 14 156 118 10 10 10 10
46273 - 90 90 90 238 238 238 253 253 253 253 253 253
46274 -253 253 253 253 253 253 253 253 253 253 253 253
46275 -253 253 253 253 253 253 231 231 231 250 250 250
46276 -253 253 253 253 253 253 253 253 253 253 253 253
46277 -253 253 253 253 253 253 253 253 253 253 253 253
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 253 253 253 246 230 190
46280 -238 204 91 238 204 91 181 142 44 37 26 9
46281 - 2 2 6 2 2 6 2 2 6 2 2 6
46282 - 2 2 6 2 2 6 38 38 38 46 46 46
46283 - 26 26 26 106 106 106 54 54 54 18 18 18
46284 - 6 6 6 0 0 0 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 0 0 0
46288 - 0 0 0 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 6 6 6 14 14 14 22 22 22
46290 - 30 30 30 38 38 38 50 50 50 70 70 70
46291 -106 106 106 190 142 34 226 170 11 242 186 14
46292 -246 190 14 246 190 14 246 190 14 154 114 10
46293 - 6 6 6 74 74 74 226 226 226 253 253 253
46294 -253 253 253 253 253 253 253 253 253 253 253 253
46295 -253 253 253 253 253 253 231 231 231 250 250 250
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 253 253 253 253 253 253
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 253 253 253 228 184 62
46300 -241 196 14 241 208 19 232 195 16 38 30 10
46301 - 2 2 6 2 2 6 2 2 6 2 2 6
46302 - 2 2 6 6 6 6 30 30 30 26 26 26
46303 -203 166 17 154 142 90 66 66 66 26 26 26
46304 - 6 6 6 0 0 0 0 0 0 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
46306 - 0 0 0 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 0 0 0
46308 - 0 0 0 0 0 0 0 0 0 0 0 0
46309 - 6 6 6 18 18 18 38 38 38 58 58 58
46310 - 78 78 78 86 86 86 101 101 101 123 123 123
46311 -175 146 61 210 150 10 234 174 13 246 186 14
46312 -246 190 14 246 190 14 246 190 14 238 190 10
46313 -102 78 10 2 2 6 46 46 46 198 198 198
46314 -253 253 253 253 253 253 253 253 253 253 253 253
46315 -253 253 253 253 253 253 234 234 234 242 242 242
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 253 253 253 253 253 253
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 253 253 253 224 178 62
46320 -242 186 14 241 196 14 210 166 10 22 18 6
46321 - 2 2 6 2 2 6 2 2 6 2 2 6
46322 - 2 2 6 2 2 6 6 6 6 121 92 8
46323 -238 202 15 232 195 16 82 82 82 34 34 34
46324 - 10 10 10 0 0 0 0 0 0 0 0 0
46325 - 0 0 0 0 0 0 0 0 0 0 0 0
46326 - 0 0 0 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 0 0 0
46328 - 0 0 0 0 0 0 0 0 0 0 0 0
46329 - 14 14 14 38 38 38 70 70 70 154 122 46
46330 -190 142 34 200 144 11 197 138 11 197 138 11
46331 -213 154 11 226 170 11 242 186 14 246 190 14
46332 -246 190 14 246 190 14 246 190 14 246 190 14
46333 -225 175 15 46 32 6 2 2 6 22 22 22
46334 -158 158 158 250 250 250 253 253 253 253 253 253
46335 -253 253 253 253 253 253 253 253 253 253 253 253
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 253 253 253 253 253 253 253 253 253
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 250 250 250 242 242 242 224 178 62
46340 -239 182 13 236 186 11 213 154 11 46 32 6
46341 - 2 2 6 2 2 6 2 2 6 2 2 6
46342 - 2 2 6 2 2 6 61 42 6 225 175 15
46343 -238 190 10 236 186 11 112 100 78 42 42 42
46344 - 14 14 14 0 0 0 0 0 0 0 0 0
46345 - 0 0 0 0 0 0 0 0 0 0 0 0
46346 - 0 0 0 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 0 0 0 0 0 0
46348 - 0 0 0 0 0 0 0 0 0 6 6 6
46349 - 22 22 22 54 54 54 154 122 46 213 154 11
46350 -226 170 11 230 174 11 226 170 11 226 170 11
46351 -236 178 12 242 186 14 246 190 14 246 190 14
46352 -246 190 14 246 190 14 246 190 14 246 190 14
46353 -241 196 14 184 144 12 10 10 10 2 2 6
46354 - 6 6 6 116 116 116 242 242 242 253 253 253
46355 -253 253 253 253 253 253 253 253 253 253 253 253
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -253 253 253 253 253 253 253 253 253 253 253 253
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 231 231 231 198 198 198 214 170 54
46360 -236 178 12 236 178 12 210 150 10 137 92 6
46361 - 18 14 6 2 2 6 2 2 6 2 2 6
46362 - 6 6 6 70 47 6 200 144 11 236 178 12
46363 -239 182 13 239 182 13 124 112 88 58 58 58
46364 - 22 22 22 6 6 6 0 0 0 0 0 0
46365 - 0 0 0 0 0 0 0 0 0 0 0 0
46366 - 0 0 0 0 0 0 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 0 0 0 0 0 0
46368 - 0 0 0 0 0 0 0 0 0 10 10 10
46369 - 30 30 30 70 70 70 180 133 36 226 170 11
46370 -239 182 13 242 186 14 242 186 14 246 186 14
46371 -246 190 14 246 190 14 246 190 14 246 190 14
46372 -246 190 14 246 190 14 246 190 14 246 190 14
46373 -246 190 14 232 195 16 98 70 6 2 2 6
46374 - 2 2 6 2 2 6 66 66 66 221 221 221
46375 -253 253 253 253 253 253 253 253 253 253 253 253
46376 -253 253 253 253 253 253 253 253 253 253 253 253
46377 -253 253 253 253 253 253 253 253 253 253 253 253
46378 -253 253 253 253 253 253 253 253 253 253 253 253
46379 -253 253 253 206 206 206 198 198 198 214 166 58
46380 -230 174 11 230 174 11 216 158 10 192 133 9
46381 -163 110 8 116 81 8 102 78 10 116 81 8
46382 -167 114 7 197 138 11 226 170 11 239 182 13
46383 -242 186 14 242 186 14 162 146 94 78 78 78
46384 - 34 34 34 14 14 14 6 6 6 0 0 0
46385 - 0 0 0 0 0 0 0 0 0 0 0 0
46386 - 0 0 0 0 0 0 0 0 0 0 0 0
46387 - 0 0 0 0 0 0 0 0 0 0 0 0
46388 - 0 0 0 0 0 0 0 0 0 6 6 6
46389 - 30 30 30 78 78 78 190 142 34 226 170 11
46390 -239 182 13 246 190 14 246 190 14 246 190 14
46391 -246 190 14 246 190 14 246 190 14 246 190 14
46392 -246 190 14 246 190 14 246 190 14 246 190 14
46393 -246 190 14 241 196 14 203 166 17 22 18 6
46394 - 2 2 6 2 2 6 2 2 6 38 38 38
46395 -218 218 218 253 253 253 253 253 253 253 253 253
46396 -253 253 253 253 253 253 253 253 253 253 253 253
46397 -253 253 253 253 253 253 253 253 253 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -250 250 250 206 206 206 198 198 198 202 162 69
46400 -226 170 11 236 178 12 224 166 10 210 150 10
46401 -200 144 11 197 138 11 192 133 9 197 138 11
46402 -210 150 10 226 170 11 242 186 14 246 190 14
46403 -246 190 14 246 186 14 225 175 15 124 112 88
46404 - 62 62 62 30 30 30 14 14 14 6 6 6
46405 - 0 0 0 0 0 0 0 0 0 0 0 0
46406 - 0 0 0 0 0 0 0 0 0 0 0 0
46407 - 0 0 0 0 0 0 0 0 0 0 0 0
46408 - 0 0 0 0 0 0 0 0 0 10 10 10
46409 - 30 30 30 78 78 78 174 135 50 224 166 10
46410 -239 182 13 246 190 14 246 190 14 246 190 14
46411 -246 190 14 246 190 14 246 190 14 246 190 14
46412 -246 190 14 246 190 14 246 190 14 246 190 14
46413 -246 190 14 246 190 14 241 196 14 139 102 15
46414 - 2 2 6 2 2 6 2 2 6 2 2 6
46415 - 78 78 78 250 250 250 253 253 253 253 253 253
46416 -253 253 253 253 253 253 253 253 253 253 253 253
46417 -253 253 253 253 253 253 253 253 253 253 253 253
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -250 250 250 214 214 214 198 198 198 190 150 46
46420 -219 162 10 236 178 12 234 174 13 224 166 10
46421 -216 158 10 213 154 11 213 154 11 216 158 10
46422 -226 170 11 239 182 13 246 190 14 246 190 14
46423 -246 190 14 246 190 14 242 186 14 206 162 42
46424 -101 101 101 58 58 58 30 30 30 14 14 14
46425 - 6 6 6 0 0 0 0 0 0 0 0 0
46426 - 0 0 0 0 0 0 0 0 0 0 0 0
46427 - 0 0 0 0 0 0 0 0 0 0 0 0
46428 - 0 0 0 0 0 0 0 0 0 10 10 10
46429 - 30 30 30 74 74 74 174 135 50 216 158 10
46430 -236 178 12 246 190 14 246 190 14 246 190 14
46431 -246 190 14 246 190 14 246 190 14 246 190 14
46432 -246 190 14 246 190 14 246 190 14 246 190 14
46433 -246 190 14 246 190 14 241 196 14 226 184 13
46434 - 61 42 6 2 2 6 2 2 6 2 2 6
46435 - 22 22 22 238 238 238 253 253 253 253 253 253
46436 -253 253 253 253 253 253 253 253 253 253 253 253
46437 -253 253 253 253 253 253 253 253 253 253 253 253
46438 -253 253 253 253 253 253 253 253 253 253 253 253
46439 -253 253 253 226 226 226 187 187 187 180 133 36
46440 -216 158 10 236 178 12 239 182 13 236 178 12
46441 -230 174 11 226 170 11 226 170 11 230 174 11
46442 -236 178 12 242 186 14 246 190 14 246 190 14
46443 -246 190 14 246 190 14 246 186 14 239 182 13
46444 -206 162 42 106 106 106 66 66 66 34 34 34
46445 - 14 14 14 6 6 6 0 0 0 0 0 0
46446 - 0 0 0 0 0 0 0 0 0 0 0 0
46447 - 0 0 0 0 0 0 0 0 0 0 0 0
46448 - 0 0 0 0 0 0 0 0 0 6 6 6
46449 - 26 26 26 70 70 70 163 133 67 213 154 11
46450 -236 178 12 246 190 14 246 190 14 246 190 14
46451 -246 190 14 246 190 14 246 190 14 246 190 14
46452 -246 190 14 246 190 14 246 190 14 246 190 14
46453 -246 190 14 246 190 14 246 190 14 241 196 14
46454 -190 146 13 18 14 6 2 2 6 2 2 6
46455 - 46 46 46 246 246 246 253 253 253 253 253 253
46456 -253 253 253 253 253 253 253 253 253 253 253 253
46457 -253 253 253 253 253 253 253 253 253 253 253 253
46458 -253 253 253 253 253 253 253 253 253 253 253 253
46459 -253 253 253 221 221 221 86 86 86 156 107 11
46460 -216 158 10 236 178 12 242 186 14 246 186 14
46461 -242 186 14 239 182 13 239 182 13 242 186 14
46462 -242 186 14 246 186 14 246 190 14 246 190 14
46463 -246 190 14 246 190 14 246 190 14 246 190 14
46464 -242 186 14 225 175 15 142 122 72 66 66 66
46465 - 30 30 30 10 10 10 0 0 0 0 0 0
46466 - 0 0 0 0 0 0 0 0 0 0 0 0
46467 - 0 0 0 0 0 0 0 0 0 0 0 0
46468 - 0 0 0 0 0 0 0 0 0 6 6 6
46469 - 26 26 26 70 70 70 163 133 67 210 150 10
46470 -236 178 12 246 190 14 246 190 14 246 190 14
46471 -246 190 14 246 190 14 246 190 14 246 190 14
46472 -246 190 14 246 190 14 246 190 14 246 190 14
46473 -246 190 14 246 190 14 246 190 14 246 190 14
46474 -232 195 16 121 92 8 34 34 34 106 106 106
46475 -221 221 221 253 253 253 253 253 253 253 253 253
46476 -253 253 253 253 253 253 253 253 253 253 253 253
46477 -253 253 253 253 253 253 253 253 253 253 253 253
46478 -253 253 253 253 253 253 253 253 253 253 253 253
46479 -242 242 242 82 82 82 18 14 6 163 110 8
46480 -216 158 10 236 178 12 242 186 14 246 190 14
46481 -246 190 14 246 190 14 246 190 14 246 190 14
46482 -246 190 14 246 190 14 246 190 14 246 190 14
46483 -246 190 14 246 190 14 246 190 14 246 190 14
46484 -246 190 14 246 190 14 242 186 14 163 133 67
46485 - 46 46 46 18 18 18 6 6 6 0 0 0
46486 - 0 0 0 0 0 0 0 0 0 0 0 0
46487 - 0 0 0 0 0 0 0 0 0 0 0 0
46488 - 0 0 0 0 0 0 0 0 0 10 10 10
46489 - 30 30 30 78 78 78 163 133 67 210 150 10
46490 -236 178 12 246 186 14 246 190 14 246 190 14
46491 -246 190 14 246 190 14 246 190 14 246 190 14
46492 -246 190 14 246 190 14 246 190 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 246 190 14
46494 -241 196 14 215 174 15 190 178 144 253 253 253
46495 -253 253 253 253 253 253 253 253 253 253 253 253
46496 -253 253 253 253 253 253 253 253 253 253 253 253
46497 -253 253 253 253 253 253 253 253 253 253 253 253
46498 -253 253 253 253 253 253 253 253 253 218 218 218
46499 - 58 58 58 2 2 6 22 18 6 167 114 7
46500 -216 158 10 236 178 12 246 186 14 246 190 14
46501 -246 190 14 246 190 14 246 190 14 246 190 14
46502 -246 190 14 246 190 14 246 190 14 246 190 14
46503 -246 190 14 246 190 14 246 190 14 246 190 14
46504 -246 190 14 246 186 14 242 186 14 190 150 46
46505 - 54 54 54 22 22 22 6 6 6 0 0 0
46506 - 0 0 0 0 0 0 0 0 0 0 0 0
46507 - 0 0 0 0 0 0 0 0 0 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 14 14 14
46509 - 38 38 38 86 86 86 180 133 36 213 154 11
46510 -236 178 12 246 186 14 246 190 14 246 190 14
46511 -246 190 14 246 190 14 246 190 14 246 190 14
46512 -246 190 14 246 190 14 246 190 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -246 190 14 232 195 16 190 146 13 214 214 214
46515 -253 253 253 253 253 253 253 253 253 253 253 253
46516 -253 253 253 253 253 253 253 253 253 253 253 253
46517 -253 253 253 253 253 253 253 253 253 253 253 253
46518 -253 253 253 250 250 250 170 170 170 26 26 26
46519 - 2 2 6 2 2 6 37 26 9 163 110 8
46520 -219 162 10 239 182 13 246 186 14 246 190 14
46521 -246 190 14 246 190 14 246 190 14 246 190 14
46522 -246 190 14 246 190 14 246 190 14 246 190 14
46523 -246 190 14 246 190 14 246 190 14 246 190 14
46524 -246 186 14 236 178 12 224 166 10 142 122 72
46525 - 46 46 46 18 18 18 6 6 6 0 0 0
46526 - 0 0 0 0 0 0 0 0 0 0 0 0
46527 - 0 0 0 0 0 0 0 0 0 0 0 0
46528 - 0 0 0 0 0 0 6 6 6 18 18 18
46529 - 50 50 50 109 106 95 192 133 9 224 166 10
46530 -242 186 14 246 190 14 246 190 14 246 190 14
46531 -246 190 14 246 190 14 246 190 14 246 190 14
46532 -246 190 14 246 190 14 246 190 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -242 186 14 226 184 13 210 162 10 142 110 46
46535 -226 226 226 253 253 253 253 253 253 253 253 253
46536 -253 253 253 253 253 253 253 253 253 253 253 253
46537 -253 253 253 253 253 253 253 253 253 253 253 253
46538 -198 198 198 66 66 66 2 2 6 2 2 6
46539 - 2 2 6 2 2 6 50 34 6 156 107 11
46540 -219 162 10 239 182 13 246 186 14 246 190 14
46541 -246 190 14 246 190 14 246 190 14 246 190 14
46542 -246 190 14 246 190 14 246 190 14 246 190 14
46543 -246 190 14 246 190 14 246 190 14 242 186 14
46544 -234 174 13 213 154 11 154 122 46 66 66 66
46545 - 30 30 30 10 10 10 0 0 0 0 0 0
46546 - 0 0 0 0 0 0 0 0 0 0 0 0
46547 - 0 0 0 0 0 0 0 0 0 0 0 0
46548 - 0 0 0 0 0 0 6 6 6 22 22 22
46549 - 58 58 58 154 121 60 206 145 10 234 174 13
46550 -242 186 14 246 186 14 246 190 14 246 190 14
46551 -246 190 14 246 190 14 246 190 14 246 190 14
46552 -246 190 14 246 190 14 246 190 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 186 14 236 178 12 210 162 10 163 110 8
46555 - 61 42 6 138 138 138 218 218 218 250 250 250
46556 -253 253 253 253 253 253 253 253 253 250 250 250
46557 -242 242 242 210 210 210 144 144 144 66 66 66
46558 - 6 6 6 2 2 6 2 2 6 2 2 6
46559 - 2 2 6 2 2 6 61 42 6 163 110 8
46560 -216 158 10 236 178 12 246 190 14 246 190 14
46561 -246 190 14 246 190 14 246 190 14 246 190 14
46562 -246 190 14 246 190 14 246 190 14 246 190 14
46563 -246 190 14 239 182 13 230 174 11 216 158 10
46564 -190 142 34 124 112 88 70 70 70 38 38 38
46565 - 18 18 18 6 6 6 0 0 0 0 0 0
46566 - 0 0 0 0 0 0 0 0 0 0 0 0
46567 - 0 0 0 0 0 0 0 0 0 0 0 0
46568 - 0 0 0 0 0 0 6 6 6 22 22 22
46569 - 62 62 62 168 124 44 206 145 10 224 166 10
46570 -236 178 12 239 182 13 242 186 14 242 186 14
46571 -246 186 14 246 190 14 246 190 14 246 190 14
46572 -246 190 14 246 190 14 246 190 14 246 190 14
46573 -246 190 14 246 190 14 246 190 14 246 190 14
46574 -246 190 14 236 178 12 216 158 10 175 118 6
46575 - 80 54 7 2 2 6 6 6 6 30 30 30
46576 - 54 54 54 62 62 62 50 50 50 38 38 38
46577 - 14 14 14 2 2 6 2 2 6 2 2 6
46578 - 2 2 6 2 2 6 2 2 6 2 2 6
46579 - 2 2 6 6 6 6 80 54 7 167 114 7
46580 -213 154 11 236 178 12 246 190 14 246 190 14
46581 -246 190 14 246 190 14 246 190 14 246 190 14
46582 -246 190 14 242 186 14 239 182 13 239 182 13
46583 -230 174 11 210 150 10 174 135 50 124 112 88
46584 - 82 82 82 54 54 54 34 34 34 18 18 18
46585 - 6 6 6 0 0 0 0 0 0 0 0 0
46586 - 0 0 0 0 0 0 0 0 0 0 0 0
46587 - 0 0 0 0 0 0 0 0 0 0 0 0
46588 - 0 0 0 0 0 0 6 6 6 18 18 18
46589 - 50 50 50 158 118 36 192 133 9 200 144 11
46590 -216 158 10 219 162 10 224 166 10 226 170 11
46591 -230 174 11 236 178 12 239 182 13 239 182 13
46592 -242 186 14 246 186 14 246 190 14 246 190 14
46593 -246 190 14 246 190 14 246 190 14 246 190 14
46594 -246 186 14 230 174 11 210 150 10 163 110 8
46595 -104 69 6 10 10 10 2 2 6 2 2 6
46596 - 2 2 6 2 2 6 2 2 6 2 2 6
46597 - 2 2 6 2 2 6 2 2 6 2 2 6
46598 - 2 2 6 2 2 6 2 2 6 2 2 6
46599 - 2 2 6 6 6 6 91 60 6 167 114 7
46600 -206 145 10 230 174 11 242 186 14 246 190 14
46601 -246 190 14 246 190 14 246 186 14 242 186 14
46602 -239 182 13 230 174 11 224 166 10 213 154 11
46603 -180 133 36 124 112 88 86 86 86 58 58 58
46604 - 38 38 38 22 22 22 10 10 10 6 6 6
46605 - 0 0 0 0 0 0 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 0 0 0
46607 - 0 0 0 0 0 0 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 0 0 0 14 14 14
46609 - 34 34 34 70 70 70 138 110 50 158 118 36
46610 -167 114 7 180 123 7 192 133 9 197 138 11
46611 -200 144 11 206 145 10 213 154 11 219 162 10
46612 -224 166 10 230 174 11 239 182 13 242 186 14
46613 -246 186 14 246 186 14 246 186 14 246 186 14
46614 -239 182 13 216 158 10 185 133 11 152 99 6
46615 -104 69 6 18 14 6 2 2 6 2 2 6
46616 - 2 2 6 2 2 6 2 2 6 2 2 6
46617 - 2 2 6 2 2 6 2 2 6 2 2 6
46618 - 2 2 6 2 2 6 2 2 6 2 2 6
46619 - 2 2 6 6 6 6 80 54 7 152 99 6
46620 -192 133 9 219 162 10 236 178 12 239 182 13
46621 -246 186 14 242 186 14 239 182 13 236 178 12
46622 -224 166 10 206 145 10 192 133 9 154 121 60
46623 - 94 94 94 62 62 62 42 42 42 22 22 22
46624 - 14 14 14 6 6 6 0 0 0 0 0 0
46625 - 0 0 0 0 0 0 0 0 0 0 0 0
46626 - 0 0 0 0 0 0 0 0 0 0 0 0
46627 - 0 0 0 0 0 0 0 0 0 0 0 0
46628 - 0 0 0 0 0 0 0 0 0 6 6 6
46629 - 18 18 18 34 34 34 58 58 58 78 78 78
46630 -101 98 89 124 112 88 142 110 46 156 107 11
46631 -163 110 8 167 114 7 175 118 6 180 123 7
46632 -185 133 11 197 138 11 210 150 10 219 162 10
46633 -226 170 11 236 178 12 236 178 12 234 174 13
46634 -219 162 10 197 138 11 163 110 8 130 83 6
46635 - 91 60 6 10 10 10 2 2 6 2 2 6
46636 - 18 18 18 38 38 38 38 38 38 38 38 38
46637 - 38 38 38 38 38 38 38 38 38 38 38 38
46638 - 38 38 38 38 38 38 26 26 26 2 2 6
46639 - 2 2 6 6 6 6 70 47 6 137 92 6
46640 -175 118 6 200 144 11 219 162 10 230 174 11
46641 -234 174 13 230 174 11 219 162 10 210 150 10
46642 -192 133 9 163 110 8 124 112 88 82 82 82
46643 - 50 50 50 30 30 30 14 14 14 6 6 6
46644 - 0 0 0 0 0 0 0 0 0 0 0 0
46645 - 0 0 0 0 0 0 0 0 0 0 0 0
46646 - 0 0 0 0 0 0 0 0 0 0 0 0
46647 - 0 0 0 0 0 0 0 0 0 0 0 0
46648 - 0 0 0 0 0 0 0 0 0 0 0 0
46649 - 6 6 6 14 14 14 22 22 22 34 34 34
46650 - 42 42 42 58 58 58 74 74 74 86 86 86
46651 -101 98 89 122 102 70 130 98 46 121 87 25
46652 -137 92 6 152 99 6 163 110 8 180 123 7
46653 -185 133 11 197 138 11 206 145 10 200 144 11
46654 -180 123 7 156 107 11 130 83 6 104 69 6
46655 - 50 34 6 54 54 54 110 110 110 101 98 89
46656 - 86 86 86 82 82 82 78 78 78 78 78 78
46657 - 78 78 78 78 78 78 78 78 78 78 78 78
46658 - 78 78 78 82 82 82 86 86 86 94 94 94
46659 -106 106 106 101 101 101 86 66 34 124 80 6
46660 -156 107 11 180 123 7 192 133 9 200 144 11
46661 -206 145 10 200 144 11 192 133 9 175 118 6
46662 -139 102 15 109 106 95 70 70 70 42 42 42
46663 - 22 22 22 10 10 10 0 0 0 0 0 0
46664 - 0 0 0 0 0 0 0 0 0 0 0 0
46665 - 0 0 0 0 0 0 0 0 0 0 0 0
46666 - 0 0 0 0 0 0 0 0 0 0 0 0
46667 - 0 0 0 0 0 0 0 0 0 0 0 0
46668 - 0 0 0 0 0 0 0 0 0 0 0 0
46669 - 0 0 0 0 0 0 6 6 6 10 10 10
46670 - 14 14 14 22 22 22 30 30 30 38 38 38
46671 - 50 50 50 62 62 62 74 74 74 90 90 90
46672 -101 98 89 112 100 78 121 87 25 124 80 6
46673 -137 92 6 152 99 6 152 99 6 152 99 6
46674 -138 86 6 124 80 6 98 70 6 86 66 30
46675 -101 98 89 82 82 82 58 58 58 46 46 46
46676 - 38 38 38 34 34 34 34 34 34 34 34 34
46677 - 34 34 34 34 34 34 34 34 34 34 34 34
46678 - 34 34 34 34 34 34 38 38 38 42 42 42
46679 - 54 54 54 82 82 82 94 86 76 91 60 6
46680 -134 86 6 156 107 11 167 114 7 175 118 6
46681 -175 118 6 167 114 7 152 99 6 121 87 25
46682 -101 98 89 62 62 62 34 34 34 18 18 18
46683 - 6 6 6 0 0 0 0 0 0 0 0 0
46684 - 0 0 0 0 0 0 0 0 0 0 0 0
46685 - 0 0 0 0 0 0 0 0 0 0 0 0
46686 - 0 0 0 0 0 0 0 0 0 0 0 0
46687 - 0 0 0 0 0 0 0 0 0 0 0 0
46688 - 0 0 0 0 0 0 0 0 0 0 0 0
46689 - 0 0 0 0 0 0 0 0 0 0 0 0
46690 - 0 0 0 6 6 6 6 6 6 10 10 10
46691 - 18 18 18 22 22 22 30 30 30 42 42 42
46692 - 50 50 50 66 66 66 86 86 86 101 98 89
46693 -106 86 58 98 70 6 104 69 6 104 69 6
46694 -104 69 6 91 60 6 82 62 34 90 90 90
46695 - 62 62 62 38 38 38 22 22 22 14 14 14
46696 - 10 10 10 10 10 10 10 10 10 10 10 10
46697 - 10 10 10 10 10 10 6 6 6 10 10 10
46698 - 10 10 10 10 10 10 10 10 10 14 14 14
46699 - 22 22 22 42 42 42 70 70 70 89 81 66
46700 - 80 54 7 104 69 6 124 80 6 137 92 6
46701 -134 86 6 116 81 8 100 82 52 86 86 86
46702 - 58 58 58 30 30 30 14 14 14 6 6 6
46703 - 0 0 0 0 0 0 0 0 0 0 0 0
46704 - 0 0 0 0 0 0 0 0 0 0 0 0
46705 - 0 0 0 0 0 0 0 0 0 0 0 0
46706 - 0 0 0 0 0 0 0 0 0 0 0 0
46707 - 0 0 0 0 0 0 0 0 0 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 0 0 0 0 0 0 0 0 0
46710 - 0 0 0 0 0 0 0 0 0 0 0 0
46711 - 0 0 0 6 6 6 10 10 10 14 14 14
46712 - 18 18 18 26 26 26 38 38 38 54 54 54
46713 - 70 70 70 86 86 86 94 86 76 89 81 66
46714 - 89 81 66 86 86 86 74 74 74 50 50 50
46715 - 30 30 30 14 14 14 6 6 6 0 0 0
46716 - 0 0 0 0 0 0 0 0 0 0 0 0
46717 - 0 0 0 0 0 0 0 0 0 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 6 6 6 18 18 18 34 34 34 58 58 58
46720 - 82 82 82 89 81 66 89 81 66 89 81 66
46721 - 94 86 66 94 86 76 74 74 74 50 50 50
46722 - 26 26 26 14 14 14 6 6 6 0 0 0
46723 - 0 0 0 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 0 0 0 0 0 0 0 0 0
46725 - 0 0 0 0 0 0 0 0 0 0 0 0
46726 - 0 0 0 0 0 0 0 0 0 0 0 0
46727 - 0 0 0 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 0 0 0 0 0 0 0 0 0
46731 - 0 0 0 0 0 0 0 0 0 0 0 0
46732 - 6 6 6 6 6 6 14 14 14 18 18 18
46733 - 30 30 30 38 38 38 46 46 46 54 54 54
46734 - 50 50 50 42 42 42 30 30 30 18 18 18
46735 - 10 10 10 0 0 0 0 0 0 0 0 0
46736 - 0 0 0 0 0 0 0 0 0 0 0 0
46737 - 0 0 0 0 0 0 0 0 0 0 0 0
46738 - 0 0 0 0 0 0 0 0 0 0 0 0
46739 - 0 0 0 6 6 6 14 14 14 26 26 26
46740 - 38 38 38 50 50 50 58 58 58 58 58 58
46741 - 54 54 54 42 42 42 30 30 30 18 18 18
46742 - 10 10 10 0 0 0 0 0 0 0 0 0
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 0 0 0 0 0 0 0 0 0 0 0 0
46745 - 0 0 0 0 0 0 0 0 0 0 0 0
46746 - 0 0 0 0 0 0 0 0 0 0 0 0
46747 - 0 0 0 0 0 0 0 0 0 0 0 0
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 0 0 0 0 0 0 0 0 0
46752 - 0 0 0 0 0 0 0 0 0 6 6 6
46753 - 6 6 6 10 10 10 14 14 14 18 18 18
46754 - 18 18 18 14 14 14 10 10 10 6 6 6
46755 - 0 0 0 0 0 0 0 0 0 0 0 0
46756 - 0 0 0 0 0 0 0 0 0 0 0 0
46757 - 0 0 0 0 0 0 0 0 0 0 0 0
46758 - 0 0 0 0 0 0 0 0 0 0 0 0
46759 - 0 0 0 0 0 0 0 0 0 6 6 6
46760 - 14 14 14 18 18 18 22 22 22 22 22 22
46761 - 18 18 18 14 14 14 10 10 10 6 6 6
46762 - 0 0 0 0 0 0 0 0 0 0 0 0
46763 - 0 0 0 0 0 0 0 0 0 0 0 0
46764 - 0 0 0 0 0 0 0 0 0 0 0 0
46765 - 0 0 0 0 0 0 0 0 0 0 0 0
46766 - 0 0 0 0 0 0 0 0 0 0 0 0
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46856 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46861 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46870 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46871 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46875 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46876 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46877 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46884 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46885 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46889 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46890 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46891 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46896 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46897 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46898 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46899 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46902 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46903 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46904 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46905 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46906 +4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46910 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46911 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46912 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46913 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46914 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46916 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46917 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46918 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46919 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46924 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46925 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46926 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46927 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46928 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46929 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46930 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46931 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46932 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46933 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46934 +4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46937 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46938 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46939 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46940 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46941 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46942 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46943 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46944 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46945 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46946 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46947 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46951 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46952 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46953 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46954 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46955 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46956 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46957 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46958 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46959 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46960 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46961 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46965 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46966 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46967 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46968 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46969 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46970 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46971 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46972 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46973 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46974 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46975 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46979 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46980 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46981 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46982 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46983 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46984 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46985 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46986 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46987 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46988 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46989 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46990 +4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46992 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46993 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46994 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46995 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46996 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46997 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46998 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46999 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47000 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47001 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47002 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47003 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47004 +4 4 4 4 4 4
47005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47006 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47007 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47008 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47009 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47010 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47011 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47012 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47013 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47014 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47015 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47016 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47017 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47018 +0 0 0 4 4 4
47019 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47020 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47021 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47022 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47023 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47024 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47025 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47026 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47027 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47028 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47029 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47030 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47031 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47032 +2 0 0 0 0 0
47033 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47034 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47035 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47036 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47037 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47038 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47039 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47040 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47041 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47042 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47043 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47044 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47045 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47046 +37 38 37 0 0 0
47047 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47048 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47049 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47050 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47051 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47052 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47053 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47054 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47055 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47056 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47057 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47058 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47059 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47060 +85 115 134 4 0 0
47061 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47062 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47063 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47064 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47065 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47066 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47067 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47068 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47069 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47070 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47071 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47072 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47073 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47074 +60 73 81 4 0 0
47075 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47076 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47077 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47078 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47079 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47080 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47081 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47082 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47083 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47084 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47085 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47086 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47087 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47088 +16 19 21 4 0 0
47089 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47090 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47091 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47092 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47093 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47094 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47095 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47096 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47097 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47098 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47099 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47100 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47101 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47102 +4 0 0 4 3 3
47103 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47104 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47105 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47106 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47107 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47108 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47109 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47110 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47111 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47112 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47113 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47114 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47115 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47116 +3 2 2 4 4 4
47117 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47118 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47119 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47120 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47121 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47122 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47123 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47124 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47125 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47126 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47127 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47128 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47129 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47130 +4 4 4 4 4 4
47131 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47132 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47133 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47134 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47135 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47136 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47137 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47138 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47139 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47140 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47141 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47142 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47143 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47144 +4 4 4 4 4 4
47145 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47146 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47147 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47148 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47149 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47150 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47151 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47152 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47153 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47154 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47155 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47156 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47157 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47158 +5 5 5 5 5 5
47159 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47160 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47161 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47162 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47163 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47164 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47165 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47166 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47167 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47168 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47169 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47170 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47171 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47172 +5 5 5 4 4 4
47173 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47174 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47175 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47176 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47177 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47178 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47179 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47180 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47181 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47182 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47183 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47184 +4 0 0 4 0 0 5 5 5 5 5 5 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
47187 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47188 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47189 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47190 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47191 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47192 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47193 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47194 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47195 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47196 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47197 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47198 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47200 +4 4 4 4 4 4
47201 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47202 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47203 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47204 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47205 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47206 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47207 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47208 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47209 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47210 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47211 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47214 +4 4 4 4 4 4
47215 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47216 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47217 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47218 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47219 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47220 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47221 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47222 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47223 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47224 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47225 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47228 +4 4 4 4 4 4
47229 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47230 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47231 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47232 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47233 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47234 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47235 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47236 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47237 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47238 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47239 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47242 +4 4 4 4 4 4
47243 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47244 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47245 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47246 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47247 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47248 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47249 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47250 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47251 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47252 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47253 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47256 +4 4 4 4 4 4
47257 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47258 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47259 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47260 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47261 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47262 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47263 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47264 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47265 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47266 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47267 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47270 +4 4 4 4 4 4
47271 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47272 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47273 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47274 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47275 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47276 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47277 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47278 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47279 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47280 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47281 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47284 +4 4 4 4 4 4
47285 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47286 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47287 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47288 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47289 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47290 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47291 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47292 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47293 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47294 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47295 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47298 +4 4 4 4 4 4
47299 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47300 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47301 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47302 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47303 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47304 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47305 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47306 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47307 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47308 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47309 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47312 +4 4 4 4 4 4
47313 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47314 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47315 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47316 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47317 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47318 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47319 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47320 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47321 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47322 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47323 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47326 +4 4 4 4 4 4
47327 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47328 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47329 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47330 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47331 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47332 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47333 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47334 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47335 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47336 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47337 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47340 +4 4 4 4 4 4
47341 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47342 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47343 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47344 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47345 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47346 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47347 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47348 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47349 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47350 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47351 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47354 +4 4 4 4 4 4
47355 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47356 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47357 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47358 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47359 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47360 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47361 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47362 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47363 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47364 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47365 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47368 +4 4 4 4 4 4
47369 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47370 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47371 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47372 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47373 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47374 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47375 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47376 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47377 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47378 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47379 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 4 4 4
47383 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47384 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47385 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47386 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47387 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47388 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47389 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47390 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47391 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47392 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47393 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4
47397 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47398 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47399 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47400 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47401 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47402 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47403 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47404 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47405 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47406 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47407 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4
47411 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47412 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47413 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47414 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47415 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47416 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47417 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47418 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47419 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47420 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47421 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4
47425 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47426 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47427 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47428 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47429 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47430 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47431 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47432 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47433 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47434 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47435 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47438 +4 4 4 4 4 4
47439 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47440 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47441 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47442 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47443 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47444 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47445 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47446 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47447 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47448 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47449 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47452 +4 4 4 4 4 4
47453 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47454 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47455 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47456 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47457 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47458 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47459 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47460 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47461 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47462 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47463 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47466 +4 4 4 4 4 4
47467 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47468 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47469 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47470 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47471 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47472 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47473 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47474 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47475 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47476 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47477 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47480 +4 4 4 4 4 4
47481 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47482 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47483 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47484 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47485 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47486 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47487 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47488 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47489 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47490 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47491 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47494 +4 4 4 4 4 4
47495 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47496 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47497 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47498 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47499 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47500 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47501 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47502 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47503 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47504 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47505 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47508 +4 4 4 4 4 4
47509 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47510 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47511 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47512 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47513 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47514 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47515 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47516 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47517 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47518 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47519 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47522 +4 4 4 4 4 4
47523 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47524 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47525 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47526 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47527 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47528 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47529 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47530 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47531 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47532 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47533 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47536 +4 4 4 4 4 4
47537 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47538 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47539 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47540 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47541 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47542 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47543 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47544 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47545 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47546 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47547 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47550 +4 4 4 4 4 4
47551 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47552 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47553 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47554 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47555 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47556 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47557 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47558 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47559 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47560 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47561 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47564 +4 4 4 4 4 4
47565 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47566 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47567 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47568 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47569 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47570 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47571 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47572 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47573 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47574 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47575 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47578 +4 4 4 4 4 4
47579 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47580 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47581 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47582 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47583 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47584 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47585 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47586 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47587 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47588 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47592 +4 4 4 4 4 4
47593 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47594 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47595 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47596 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47597 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47598 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47599 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47600 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47601 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47602 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47606 +4 4 4 4 4 4
47607 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47608 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47609 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47610 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47611 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47612 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47613 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47614 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47615 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47616 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47620 +4 4 4 4 4 4
47621 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47622 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47623 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47624 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47625 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47626 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47627 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47628 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47629 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47630 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47634 +4 4 4 4 4 4
47635 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47636 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47637 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47638 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47639 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47640 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47641 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47642 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47643 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47648 +4 4 4 4 4 4
47649 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47650 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47651 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47652 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47653 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47654 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47655 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47656 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47657 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47662 +4 4 4 4 4 4
47663 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47664 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47665 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47666 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47667 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47668 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47669 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47670 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47671 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47676 +4 4 4 4 4 4
47677 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47678 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47679 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47680 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47681 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47682 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47683 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47684 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47690 +4 4 4 4 4 4
47691 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47692 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47693 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47694 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47695 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47696 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47697 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47698 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47704 +4 4 4 4 4 4
47705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47706 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47707 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47708 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47709 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47710 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47711 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47712 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47718 +4 4 4 4 4 4
47719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47720 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47721 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47722 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47723 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47724 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47725 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47726 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47732 +4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47735 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47736 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47737 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47738 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47739 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47740 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47746 +4 4 4 4 4 4
47747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47749 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47750 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47751 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47752 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47753 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47754 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +4 4 4 4 4 4
47761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47764 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47765 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47766 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47767 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47778 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47779 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47780 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47781 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47788 +4 4 4 4 4 4
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47792 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47793 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47794 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47795 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47802 +4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47806 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47807 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47808 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47809 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47816 +4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47821 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47822 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47823 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47830 +4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47835 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47836 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47837 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47844 +4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47849 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47850 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47851 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47858 +4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47863 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47864 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47872 +4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47877 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47878 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47886 +4 4 4 4 4 4
47887 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47888 index fe92eed..106e085 100644
47889 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47890 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47891 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47892 struct mb862xxfb_par *par = info->par;
47893
47894 if (info->var.bits_per_pixel == 32) {
47895 - info->fbops->fb_fillrect = cfb_fillrect;
47896 - info->fbops->fb_copyarea = cfb_copyarea;
47897 - info->fbops->fb_imageblit = cfb_imageblit;
47898 + pax_open_kernel();
47899 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47900 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47901 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47902 + pax_close_kernel();
47903 } else {
47904 outreg(disp, GC_L0EM, 3);
47905 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47906 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47907 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47908 + pax_open_kernel();
47909 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47910 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47911 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47912 + pax_close_kernel();
47913 }
47914 outreg(draw, GDC_REG_DRAW_BASE, 0);
47915 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47916 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47917 index ff22871..b129bed 100644
47918 --- a/drivers/video/nvidia/nvidia.c
47919 +++ b/drivers/video/nvidia/nvidia.c
47920 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47921 info->fix.line_length = (info->var.xres_virtual *
47922 info->var.bits_per_pixel) >> 3;
47923 if (info->var.accel_flags) {
47924 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47925 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47926 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47927 - info->fbops->fb_sync = nvidiafb_sync;
47928 + pax_open_kernel();
47929 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47930 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47931 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47932 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47933 + pax_close_kernel();
47934 info->pixmap.scan_align = 4;
47935 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47936 info->flags |= FBINFO_READS_FAST;
47937 NVResetGraphics(info);
47938 } else {
47939 - info->fbops->fb_imageblit = cfb_imageblit;
47940 - info->fbops->fb_fillrect = cfb_fillrect;
47941 - info->fbops->fb_copyarea = cfb_copyarea;
47942 - info->fbops->fb_sync = NULL;
47943 + pax_open_kernel();
47944 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47945 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47946 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47947 + *(void **)&info->fbops->fb_sync = NULL;
47948 + pax_close_kernel();
47949 info->pixmap.scan_align = 1;
47950 info->flags |= FBINFO_HWACCEL_DISABLED;
47951 info->flags &= ~FBINFO_READS_FAST;
47952 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47953 info->pixmap.size = 8 * 1024;
47954 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47955
47956 - if (!hwcur)
47957 - info->fbops->fb_cursor = NULL;
47958 + if (!hwcur) {
47959 + pax_open_kernel();
47960 + *(void **)&info->fbops->fb_cursor = NULL;
47961 + pax_close_kernel();
47962 + }
47963
47964 info->var.accel_flags = (!noaccel);
47965
47966 diff --git a/drivers/video/output.c b/drivers/video/output.c
47967 index 0d6f2cd..6285b97 100644
47968 --- a/drivers/video/output.c
47969 +++ b/drivers/video/output.c
47970 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
47971 new_dev->props = op;
47972 new_dev->dev.class = &video_output_class;
47973 new_dev->dev.parent = dev;
47974 - dev_set_name(&new_dev->dev, name);
47975 + dev_set_name(&new_dev->dev, "%s", name);
47976 dev_set_drvdata(&new_dev->dev, devdata);
47977 ret_code = device_register(&new_dev->dev);
47978 if (ret_code) {
47979 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47980 index 05c2dc3..ea1f391 100644
47981 --- a/drivers/video/s1d13xxxfb.c
47982 +++ b/drivers/video/s1d13xxxfb.c
47983 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47984
47985 switch(prod_id) {
47986 case S1D13506_PROD_ID: /* activate acceleration */
47987 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47988 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47989 + pax_open_kernel();
47990 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47991 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47992 + pax_close_kernel();
47993 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47994 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47995 break;
47996 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47997 index b2b33fc..f9f4658 100644
47998 --- a/drivers/video/smscufx.c
47999 +++ b/drivers/video/smscufx.c
48000 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48001 fb_deferred_io_cleanup(info);
48002 kfree(info->fbdefio);
48003 info->fbdefio = NULL;
48004 - info->fbops->fb_mmap = ufx_ops_mmap;
48005 + pax_open_kernel();
48006 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48007 + pax_close_kernel();
48008 }
48009
48010 pr_debug("released /dev/fb%d user=%d count=%d",
48011 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48012 index ec03e72..f578436 100644
48013 --- a/drivers/video/udlfb.c
48014 +++ b/drivers/video/udlfb.c
48015 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48016 dlfb_urb_completion(urb);
48017
48018 error:
48019 - atomic_add(bytes_sent, &dev->bytes_sent);
48020 - atomic_add(bytes_identical, &dev->bytes_identical);
48021 - atomic_add(width*height*2, &dev->bytes_rendered);
48022 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48023 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48024 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48025 end_cycles = get_cycles();
48026 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48027 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48028 >> 10)), /* Kcycles */
48029 &dev->cpu_kcycles_used);
48030
48031 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48032 dlfb_urb_completion(urb);
48033
48034 error:
48035 - atomic_add(bytes_sent, &dev->bytes_sent);
48036 - atomic_add(bytes_identical, &dev->bytes_identical);
48037 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48038 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48039 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48040 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48041 end_cycles = get_cycles();
48042 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48043 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48044 >> 10)), /* Kcycles */
48045 &dev->cpu_kcycles_used);
48046 }
48047 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48048 fb_deferred_io_cleanup(info);
48049 kfree(info->fbdefio);
48050 info->fbdefio = NULL;
48051 - info->fbops->fb_mmap = dlfb_ops_mmap;
48052 + pax_open_kernel();
48053 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48054 + pax_close_kernel();
48055 }
48056
48057 pr_warn("released /dev/fb%d user=%d count=%d\n",
48058 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48059 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48060 struct dlfb_data *dev = fb_info->par;
48061 return snprintf(buf, PAGE_SIZE, "%u\n",
48062 - atomic_read(&dev->bytes_rendered));
48063 + atomic_read_unchecked(&dev->bytes_rendered));
48064 }
48065
48066 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48067 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48068 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48069 struct dlfb_data *dev = fb_info->par;
48070 return snprintf(buf, PAGE_SIZE, "%u\n",
48071 - atomic_read(&dev->bytes_identical));
48072 + atomic_read_unchecked(&dev->bytes_identical));
48073 }
48074
48075 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48076 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48077 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48078 struct dlfb_data *dev = fb_info->par;
48079 return snprintf(buf, PAGE_SIZE, "%u\n",
48080 - atomic_read(&dev->bytes_sent));
48081 + atomic_read_unchecked(&dev->bytes_sent));
48082 }
48083
48084 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48085 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48086 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48087 struct dlfb_data *dev = fb_info->par;
48088 return snprintf(buf, PAGE_SIZE, "%u\n",
48089 - atomic_read(&dev->cpu_kcycles_used));
48090 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48091 }
48092
48093 static ssize_t edid_show(
48094 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48095 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48096 struct dlfb_data *dev = fb_info->par;
48097
48098 - atomic_set(&dev->bytes_rendered, 0);
48099 - atomic_set(&dev->bytes_identical, 0);
48100 - atomic_set(&dev->bytes_sent, 0);
48101 - atomic_set(&dev->cpu_kcycles_used, 0);
48102 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48103 + atomic_set_unchecked(&dev->bytes_identical, 0);
48104 + atomic_set_unchecked(&dev->bytes_sent, 0);
48105 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48106
48107 return count;
48108 }
48109 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48110 index e328a61..1b08ecb 100644
48111 --- a/drivers/video/uvesafb.c
48112 +++ b/drivers/video/uvesafb.c
48113 @@ -19,6 +19,7 @@
48114 #include <linux/io.h>
48115 #include <linux/mutex.h>
48116 #include <linux/slab.h>
48117 +#include <linux/moduleloader.h>
48118 #include <video/edid.h>
48119 #include <video/uvesafb.h>
48120 #ifdef CONFIG_X86
48121 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48122 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48123 par->pmi_setpal = par->ypan = 0;
48124 } else {
48125 +
48126 +#ifdef CONFIG_PAX_KERNEXEC
48127 +#ifdef CONFIG_MODULES
48128 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48129 +#endif
48130 + if (!par->pmi_code) {
48131 + par->pmi_setpal = par->ypan = 0;
48132 + return 0;
48133 + }
48134 +#endif
48135 +
48136 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48137 + task->t.regs.edi);
48138 +
48139 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48140 + pax_open_kernel();
48141 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48142 + pax_close_kernel();
48143 +
48144 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48145 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48146 +#else
48147 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48148 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48149 +#endif
48150 +
48151 printk(KERN_INFO "uvesafb: protected mode interface info at "
48152 "%04x:%04x\n",
48153 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48154 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48155 par->ypan = ypan;
48156
48157 if (par->pmi_setpal || par->ypan) {
48158 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48159 if (__supported_pte_mask & _PAGE_NX) {
48160 par->pmi_setpal = par->ypan = 0;
48161 printk(KERN_WARNING "uvesafb: NX protection is actively."
48162 "We have better not to use the PMI.\n");
48163 - } else {
48164 + } else
48165 +#endif
48166 uvesafb_vbe_getpmi(task, par);
48167 - }
48168 }
48169 #else
48170 /* The protected mode interface is not available on non-x86. */
48171 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48172 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48173
48174 /* Disable blanking if the user requested so. */
48175 - if (!blank)
48176 - info->fbops->fb_blank = NULL;
48177 + if (!blank) {
48178 + pax_open_kernel();
48179 + *(void **)&info->fbops->fb_blank = NULL;
48180 + pax_close_kernel();
48181 + }
48182
48183 /*
48184 * Find out how much IO memory is required for the mode with
48185 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48186 info->flags = FBINFO_FLAG_DEFAULT |
48187 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48188
48189 - if (!par->ypan)
48190 - info->fbops->fb_pan_display = NULL;
48191 + if (!par->ypan) {
48192 + pax_open_kernel();
48193 + *(void **)&info->fbops->fb_pan_display = NULL;
48194 + pax_close_kernel();
48195 + }
48196 }
48197
48198 static void uvesafb_init_mtrr(struct fb_info *info)
48199 @@ -1836,6 +1866,11 @@ out:
48200 if (par->vbe_modes)
48201 kfree(par->vbe_modes);
48202
48203 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48204 + if (par->pmi_code)
48205 + module_free_exec(NULL, par->pmi_code);
48206 +#endif
48207 +
48208 framebuffer_release(info);
48209 return err;
48210 }
48211 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48212 kfree(par->vbe_state_orig);
48213 if (par->vbe_state_saved)
48214 kfree(par->vbe_state_saved);
48215 +
48216 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48217 + if (par->pmi_code)
48218 + module_free_exec(NULL, par->pmi_code);
48219 +#endif
48220 +
48221 }
48222
48223 framebuffer_release(info);
48224 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48225 index 501b340..d80aa17 100644
48226 --- a/drivers/video/vesafb.c
48227 +++ b/drivers/video/vesafb.c
48228 @@ -9,6 +9,7 @@
48229 */
48230
48231 #include <linux/module.h>
48232 +#include <linux/moduleloader.h>
48233 #include <linux/kernel.h>
48234 #include <linux/errno.h>
48235 #include <linux/string.h>
48236 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48237 static int vram_total __initdata; /* Set total amount of memory */
48238 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48239 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48240 -static void (*pmi_start)(void) __read_mostly;
48241 -static void (*pmi_pal) (void) __read_mostly;
48242 +static void (*pmi_start)(void) __read_only;
48243 +static void (*pmi_pal) (void) __read_only;
48244 static int depth __read_mostly;
48245 static int vga_compat __read_mostly;
48246 /* --------------------------------------------------------------------- */
48247 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48248 unsigned int size_vmode;
48249 unsigned int size_remap;
48250 unsigned int size_total;
48251 + void *pmi_code = NULL;
48252
48253 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48254 return -ENODEV;
48255 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48256 size_remap = size_total;
48257 vesafb_fix.smem_len = size_remap;
48258
48259 -#ifndef __i386__
48260 - screen_info.vesapm_seg = 0;
48261 -#endif
48262 -
48263 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48264 printk(KERN_WARNING
48265 "vesafb: cannot reserve video memory at 0x%lx\n",
48266 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48267 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48268 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48269
48270 +#ifdef __i386__
48271 +
48272 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48273 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48274 + if (!pmi_code)
48275 +#elif !defined(CONFIG_PAX_KERNEXEC)
48276 + if (0)
48277 +#endif
48278 +
48279 +#endif
48280 + screen_info.vesapm_seg = 0;
48281 +
48282 if (screen_info.vesapm_seg) {
48283 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48284 - screen_info.vesapm_seg,screen_info.vesapm_off);
48285 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48286 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48287 }
48288
48289 if (screen_info.vesapm_seg < 0xc000)
48290 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48291
48292 if (ypan || pmi_setpal) {
48293 unsigned short *pmi_base;
48294 +
48295 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48296 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48297 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48298 +
48299 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48300 + pax_open_kernel();
48301 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48302 +#else
48303 + pmi_code = pmi_base;
48304 +#endif
48305 +
48306 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48307 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48308 +
48309 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48310 + pmi_start = ktva_ktla(pmi_start);
48311 + pmi_pal = ktva_ktla(pmi_pal);
48312 + pax_close_kernel();
48313 +#endif
48314 +
48315 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48316 if (pmi_base[3]) {
48317 printk(KERN_INFO "vesafb: pmi: ports = ");
48318 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48319 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48320 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48321
48322 - if (!ypan)
48323 - info->fbops->fb_pan_display = NULL;
48324 + if (!ypan) {
48325 + pax_open_kernel();
48326 + *(void **)&info->fbops->fb_pan_display = NULL;
48327 + pax_close_kernel();
48328 + }
48329
48330 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48331 err = -ENOMEM;
48332 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48333 info->node, info->fix.id);
48334 return 0;
48335 err:
48336 +
48337 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48338 + module_free_exec(NULL, pmi_code);
48339 +#endif
48340 +
48341 if (info->screen_base)
48342 iounmap(info->screen_base);
48343 framebuffer_release(info);
48344 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48345 index 88714ae..16c2e11 100644
48346 --- a/drivers/video/via/via_clock.h
48347 +++ b/drivers/video/via/via_clock.h
48348 @@ -56,7 +56,7 @@ struct via_clock {
48349
48350 void (*set_engine_pll_state)(u8 state);
48351 void (*set_engine_pll)(struct via_pll_config config);
48352 -};
48353 +} __no_const;
48354
48355
48356 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48357 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48358 index fef20db..d28b1ab 100644
48359 --- a/drivers/xen/xenfs/xenstored.c
48360 +++ b/drivers/xen/xenfs/xenstored.c
48361 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48362 static int xsd_kva_open(struct inode *inode, struct file *file)
48363 {
48364 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48365 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48366 + NULL);
48367 +#else
48368 xen_store_interface);
48369 +#endif
48370 +
48371 if (!file->private_data)
48372 return -ENOMEM;
48373 return 0;
48374 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48375 index 055562c..fdfb10d 100644
48376 --- a/fs/9p/vfs_addr.c
48377 +++ b/fs/9p/vfs_addr.c
48378 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48379
48380 retval = v9fs_file_write_internal(inode,
48381 v9inode->writeback_fid,
48382 - (__force const char __user *)buffer,
48383 + (const char __force_user *)buffer,
48384 len, &offset, 0);
48385 if (retval > 0)
48386 retval = 0;
48387 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48388 index d86edc8..40ff2fb 100644
48389 --- a/fs/9p/vfs_inode.c
48390 +++ b/fs/9p/vfs_inode.c
48391 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48392 void
48393 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48394 {
48395 - char *s = nd_get_link(nd);
48396 + const char *s = nd_get_link(nd);
48397
48398 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48399 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48400 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48401 index 370b24c..ff0be7b 100644
48402 --- a/fs/Kconfig.binfmt
48403 +++ b/fs/Kconfig.binfmt
48404 @@ -103,7 +103,7 @@ config HAVE_AOUT
48405
48406 config BINFMT_AOUT
48407 tristate "Kernel support for a.out and ECOFF binaries"
48408 - depends on HAVE_AOUT
48409 + depends on HAVE_AOUT && BROKEN
48410 ---help---
48411 A.out (Assembler.OUTput) is a set of formats for libraries and
48412 executables used in the earliest versions of UNIX. Linux used
48413 diff --git a/fs/aio.c b/fs/aio.c
48414 index 2bbcacf..8614116 100644
48415 --- a/fs/aio.c
48416 +++ b/fs/aio.c
48417 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48418 size += sizeof(struct io_event) * nr_events;
48419 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48420
48421 - if (nr_pages < 0)
48422 + if (nr_pages <= 0)
48423 return -EINVAL;
48424
48425 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48426 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
48427 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48428 {
48429 ssize_t ret;
48430 + struct iovec iovstack;
48431
48432 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48433
48434 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48435 if (compat)
48436 ret = compat_rw_copy_check_uvector(rw,
48437 (struct compat_iovec __user *)kiocb->ki_buf,
48438 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48439 + kiocb->ki_nr_segs, 1, &iovstack,
48440 &kiocb->ki_iovec);
48441 else
48442 #endif
48443 ret = rw_copy_check_uvector(rw,
48444 (struct iovec __user *)kiocb->ki_buf,
48445 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48446 + kiocb->ki_nr_segs, 1, &iovstack,
48447 &kiocb->ki_iovec);
48448 if (ret < 0)
48449 return ret;
48450
48451 + if (kiocb->ki_iovec == &iovstack) {
48452 + kiocb->ki_inline_vec = iovstack;
48453 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48454 + }
48455 +
48456 /* ki_nbytes now reflect bytes instead of segs */
48457 kiocb->ki_nbytes = ret;
48458 return 0;
48459 diff --git a/fs/attr.c b/fs/attr.c
48460 index 1449adb..a2038c2 100644
48461 --- a/fs/attr.c
48462 +++ b/fs/attr.c
48463 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48464 unsigned long limit;
48465
48466 limit = rlimit(RLIMIT_FSIZE);
48467 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48468 if (limit != RLIM_INFINITY && offset > limit)
48469 goto out_sig;
48470 if (offset > inode->i_sb->s_maxbytes)
48471 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48472 index 3db70da..7aeec5b 100644
48473 --- a/fs/autofs4/waitq.c
48474 +++ b/fs/autofs4/waitq.c
48475 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48476 {
48477 unsigned long sigpipe, flags;
48478 mm_segment_t fs;
48479 - const char *data = (const char *)addr;
48480 + const char __user *data = (const char __force_user *)addr;
48481 ssize_t wr = 0;
48482
48483 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48484 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48485 return 1;
48486 }
48487
48488 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48489 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48490 +#endif
48491 +
48492 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48493 enum autofs_notify notify)
48494 {
48495 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48496
48497 /* If this is a direct mount request create a dummy name */
48498 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48499 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48500 + /* this name does get written to userland via autofs4_write() */
48501 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48502 +#else
48503 qstr.len = sprintf(name, "%p", dentry);
48504 +#endif
48505 else {
48506 qstr.len = autofs4_getpath(sbi, dentry, &name);
48507 if (!qstr.len) {
48508 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48509 index 2722387..c8dd2a7 100644
48510 --- a/fs/befs/endian.h
48511 +++ b/fs/befs/endian.h
48512 @@ -11,7 +11,7 @@
48513
48514 #include <asm/byteorder.h>
48515
48516 -static inline u64
48517 +static inline u64 __intentional_overflow(-1)
48518 fs64_to_cpu(const struct super_block *sb, fs64 n)
48519 {
48520 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48521 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48522 return (__force fs64)cpu_to_be64(n);
48523 }
48524
48525 -static inline u32
48526 +static inline u32 __intentional_overflow(-1)
48527 fs32_to_cpu(const struct super_block *sb, fs32 n)
48528 {
48529 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48530 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48531 index f95dddc..b1e2c1c 100644
48532 --- a/fs/befs/linuxvfs.c
48533 +++ b/fs/befs/linuxvfs.c
48534 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48535 {
48536 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48537 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48538 - char *link = nd_get_link(nd);
48539 + const char *link = nd_get_link(nd);
48540 if (!IS_ERR(link))
48541 kfree(link);
48542 }
48543 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48544 index bce8769..7fc7544 100644
48545 --- a/fs/binfmt_aout.c
48546 +++ b/fs/binfmt_aout.c
48547 @@ -16,6 +16,7 @@
48548 #include <linux/string.h>
48549 #include <linux/fs.h>
48550 #include <linux/file.h>
48551 +#include <linux/security.h>
48552 #include <linux/stat.h>
48553 #include <linux/fcntl.h>
48554 #include <linux/ptrace.h>
48555 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48556 #endif
48557 # define START_STACK(u) ((void __user *)u.start_stack)
48558
48559 + memset(&dump, 0, sizeof(dump));
48560 +
48561 fs = get_fs();
48562 set_fs(KERNEL_DS);
48563 has_dumped = 1;
48564 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48565
48566 /* If the size of the dump file exceeds the rlimit, then see what would happen
48567 if we wrote the stack, but not the data area. */
48568 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48569 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48570 dump.u_dsize = 0;
48571
48572 /* Make sure we have enough room to write the stack and data areas. */
48573 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48574 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48575 dump.u_ssize = 0;
48576
48577 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48578 rlim = rlimit(RLIMIT_DATA);
48579 if (rlim >= RLIM_INFINITY)
48580 rlim = ~0;
48581 +
48582 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48583 if (ex.a_data + ex.a_bss > rlim)
48584 return -ENOMEM;
48585
48586 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48587
48588 install_exec_creds(bprm);
48589
48590 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48591 + current->mm->pax_flags = 0UL;
48592 +#endif
48593 +
48594 +#ifdef CONFIG_PAX_PAGEEXEC
48595 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48596 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48597 +
48598 +#ifdef CONFIG_PAX_EMUTRAMP
48599 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48600 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48601 +#endif
48602 +
48603 +#ifdef CONFIG_PAX_MPROTECT
48604 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48605 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48606 +#endif
48607 +
48608 + }
48609 +#endif
48610 +
48611 if (N_MAGIC(ex) == OMAGIC) {
48612 unsigned long text_addr, map_size;
48613 loff_t pos;
48614 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48615 }
48616
48617 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48618 - PROT_READ | PROT_WRITE | PROT_EXEC,
48619 + PROT_READ | PROT_WRITE,
48620 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48621 fd_offset + ex.a_text);
48622 if (error != N_DATADDR(ex)) {
48623 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48624 index f8a0b0e..8186af0 100644
48625 --- a/fs/binfmt_elf.c
48626 +++ b/fs/binfmt_elf.c
48627 @@ -34,6 +34,7 @@
48628 #include <linux/utsname.h>
48629 #include <linux/coredump.h>
48630 #include <linux/sched.h>
48631 +#include <linux/xattr.h>
48632 #include <asm/uaccess.h>
48633 #include <asm/param.h>
48634 #include <asm/page.h>
48635 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48636 #define elf_core_dump NULL
48637 #endif
48638
48639 +#ifdef CONFIG_PAX_MPROTECT
48640 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48641 +#endif
48642 +
48643 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48644 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48645 #else
48646 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48647 .load_binary = load_elf_binary,
48648 .load_shlib = load_elf_library,
48649 .core_dump = elf_core_dump,
48650 +
48651 +#ifdef CONFIG_PAX_MPROTECT
48652 + .handle_mprotect= elf_handle_mprotect,
48653 +#endif
48654 +
48655 .min_coredump = ELF_EXEC_PAGESIZE,
48656 };
48657
48658 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48659
48660 static int set_brk(unsigned long start, unsigned long end)
48661 {
48662 + unsigned long e = end;
48663 +
48664 start = ELF_PAGEALIGN(start);
48665 end = ELF_PAGEALIGN(end);
48666 if (end > start) {
48667 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48668 if (BAD_ADDR(addr))
48669 return addr;
48670 }
48671 - current->mm->start_brk = current->mm->brk = end;
48672 + current->mm->start_brk = current->mm->brk = e;
48673 return 0;
48674 }
48675
48676 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48677 elf_addr_t __user *u_rand_bytes;
48678 const char *k_platform = ELF_PLATFORM;
48679 const char *k_base_platform = ELF_BASE_PLATFORM;
48680 - unsigned char k_rand_bytes[16];
48681 + u32 k_rand_bytes[4];
48682 int items;
48683 elf_addr_t *elf_info;
48684 int ei_index = 0;
48685 const struct cred *cred = current_cred();
48686 struct vm_area_struct *vma;
48687 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48688
48689 /*
48690 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48691 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48692 * Generate 16 random bytes for userspace PRNG seeding.
48693 */
48694 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48695 - u_rand_bytes = (elf_addr_t __user *)
48696 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48697 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
48698 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
48699 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
48700 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
48701 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48702 + u_rand_bytes = (elf_addr_t __user *) p;
48703 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48704 return -EFAULT;
48705
48706 @@ -318,9 +335,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48707 return -EFAULT;
48708 current->mm->env_end = p;
48709
48710 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48711 +
48712 /* Put the elf_info on the stack in the right place. */
48713 sp = (elf_addr_t __user *)envp + 1;
48714 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48715 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48716 return -EFAULT;
48717 return 0;
48718 }
48719 @@ -388,15 +407,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48720 an ELF header */
48721
48722 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48723 - struct file *interpreter, unsigned long *interp_map_addr,
48724 - unsigned long no_base)
48725 + struct file *interpreter, unsigned long no_base)
48726 {
48727 struct elf_phdr *elf_phdata;
48728 struct elf_phdr *eppnt;
48729 - unsigned long load_addr = 0;
48730 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48731 int load_addr_set = 0;
48732 unsigned long last_bss = 0, elf_bss = 0;
48733 - unsigned long error = ~0UL;
48734 + unsigned long error = -EINVAL;
48735 unsigned long total_size;
48736 int retval, i, size;
48737
48738 @@ -442,6 +460,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48739 goto out_close;
48740 }
48741
48742 +#ifdef CONFIG_PAX_SEGMEXEC
48743 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48744 + pax_task_size = SEGMEXEC_TASK_SIZE;
48745 +#endif
48746 +
48747 eppnt = elf_phdata;
48748 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48749 if (eppnt->p_type == PT_LOAD) {
48750 @@ -465,8 +488,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48751 map_addr = elf_map(interpreter, load_addr + vaddr,
48752 eppnt, elf_prot, elf_type, total_size);
48753 total_size = 0;
48754 - if (!*interp_map_addr)
48755 - *interp_map_addr = map_addr;
48756 error = map_addr;
48757 if (BAD_ADDR(map_addr))
48758 goto out_close;
48759 @@ -485,8 +506,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48760 k = load_addr + eppnt->p_vaddr;
48761 if (BAD_ADDR(k) ||
48762 eppnt->p_filesz > eppnt->p_memsz ||
48763 - eppnt->p_memsz > TASK_SIZE ||
48764 - TASK_SIZE - eppnt->p_memsz < k) {
48765 + eppnt->p_memsz > pax_task_size ||
48766 + pax_task_size - eppnt->p_memsz < k) {
48767 error = -ENOMEM;
48768 goto out_close;
48769 }
48770 @@ -538,6 +559,315 @@ out:
48771 return error;
48772 }
48773
48774 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48775 +#ifdef CONFIG_PAX_SOFTMODE
48776 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48777 +{
48778 + unsigned long pax_flags = 0UL;
48779 +
48780 +#ifdef CONFIG_PAX_PAGEEXEC
48781 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48782 + pax_flags |= MF_PAX_PAGEEXEC;
48783 +#endif
48784 +
48785 +#ifdef CONFIG_PAX_SEGMEXEC
48786 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48787 + pax_flags |= MF_PAX_SEGMEXEC;
48788 +#endif
48789 +
48790 +#ifdef CONFIG_PAX_EMUTRAMP
48791 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48792 + pax_flags |= MF_PAX_EMUTRAMP;
48793 +#endif
48794 +
48795 +#ifdef CONFIG_PAX_MPROTECT
48796 + if (elf_phdata->p_flags & PF_MPROTECT)
48797 + pax_flags |= MF_PAX_MPROTECT;
48798 +#endif
48799 +
48800 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48801 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48802 + pax_flags |= MF_PAX_RANDMMAP;
48803 +#endif
48804 +
48805 + return pax_flags;
48806 +}
48807 +#endif
48808 +
48809 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48810 +{
48811 + unsigned long pax_flags = 0UL;
48812 +
48813 +#ifdef CONFIG_PAX_PAGEEXEC
48814 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48815 + pax_flags |= MF_PAX_PAGEEXEC;
48816 +#endif
48817 +
48818 +#ifdef CONFIG_PAX_SEGMEXEC
48819 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48820 + pax_flags |= MF_PAX_SEGMEXEC;
48821 +#endif
48822 +
48823 +#ifdef CONFIG_PAX_EMUTRAMP
48824 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48825 + pax_flags |= MF_PAX_EMUTRAMP;
48826 +#endif
48827 +
48828 +#ifdef CONFIG_PAX_MPROTECT
48829 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48830 + pax_flags |= MF_PAX_MPROTECT;
48831 +#endif
48832 +
48833 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48834 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48835 + pax_flags |= MF_PAX_RANDMMAP;
48836 +#endif
48837 +
48838 + return pax_flags;
48839 +}
48840 +#endif
48841 +
48842 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48843 +#ifdef CONFIG_PAX_SOFTMODE
48844 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48845 +{
48846 + unsigned long pax_flags = 0UL;
48847 +
48848 +#ifdef CONFIG_PAX_PAGEEXEC
48849 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48850 + pax_flags |= MF_PAX_PAGEEXEC;
48851 +#endif
48852 +
48853 +#ifdef CONFIG_PAX_SEGMEXEC
48854 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48855 + pax_flags |= MF_PAX_SEGMEXEC;
48856 +#endif
48857 +
48858 +#ifdef CONFIG_PAX_EMUTRAMP
48859 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48860 + pax_flags |= MF_PAX_EMUTRAMP;
48861 +#endif
48862 +
48863 +#ifdef CONFIG_PAX_MPROTECT
48864 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48865 + pax_flags |= MF_PAX_MPROTECT;
48866 +#endif
48867 +
48868 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48869 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48870 + pax_flags |= MF_PAX_RANDMMAP;
48871 +#endif
48872 +
48873 + return pax_flags;
48874 +}
48875 +#endif
48876 +
48877 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48878 +{
48879 + unsigned long pax_flags = 0UL;
48880 +
48881 +#ifdef CONFIG_PAX_PAGEEXEC
48882 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48883 + pax_flags |= MF_PAX_PAGEEXEC;
48884 +#endif
48885 +
48886 +#ifdef CONFIG_PAX_SEGMEXEC
48887 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48888 + pax_flags |= MF_PAX_SEGMEXEC;
48889 +#endif
48890 +
48891 +#ifdef CONFIG_PAX_EMUTRAMP
48892 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48893 + pax_flags |= MF_PAX_EMUTRAMP;
48894 +#endif
48895 +
48896 +#ifdef CONFIG_PAX_MPROTECT
48897 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48898 + pax_flags |= MF_PAX_MPROTECT;
48899 +#endif
48900 +
48901 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48902 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48903 + pax_flags |= MF_PAX_RANDMMAP;
48904 +#endif
48905 +
48906 + return pax_flags;
48907 +}
48908 +#endif
48909 +
48910 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48911 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48912 +{
48913 + unsigned long pax_flags = 0UL;
48914 +
48915 +#ifdef CONFIG_PAX_EI_PAX
48916 +
48917 +#ifdef CONFIG_PAX_PAGEEXEC
48918 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48919 + pax_flags |= MF_PAX_PAGEEXEC;
48920 +#endif
48921 +
48922 +#ifdef CONFIG_PAX_SEGMEXEC
48923 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48924 + pax_flags |= MF_PAX_SEGMEXEC;
48925 +#endif
48926 +
48927 +#ifdef CONFIG_PAX_EMUTRAMP
48928 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48929 + pax_flags |= MF_PAX_EMUTRAMP;
48930 +#endif
48931 +
48932 +#ifdef CONFIG_PAX_MPROTECT
48933 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48934 + pax_flags |= MF_PAX_MPROTECT;
48935 +#endif
48936 +
48937 +#ifdef CONFIG_PAX_ASLR
48938 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48939 + pax_flags |= MF_PAX_RANDMMAP;
48940 +#endif
48941 +
48942 +#else
48943 +
48944 +#ifdef CONFIG_PAX_PAGEEXEC
48945 + pax_flags |= MF_PAX_PAGEEXEC;
48946 +#endif
48947 +
48948 +#ifdef CONFIG_PAX_SEGMEXEC
48949 + pax_flags |= MF_PAX_SEGMEXEC;
48950 +#endif
48951 +
48952 +#ifdef CONFIG_PAX_MPROTECT
48953 + pax_flags |= MF_PAX_MPROTECT;
48954 +#endif
48955 +
48956 +#ifdef CONFIG_PAX_RANDMMAP
48957 + if (randomize_va_space)
48958 + pax_flags |= MF_PAX_RANDMMAP;
48959 +#endif
48960 +
48961 +#endif
48962 +
48963 + return pax_flags;
48964 +}
48965 +
48966 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48967 +{
48968 +
48969 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48970 + unsigned long i;
48971 +
48972 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48973 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48974 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48975 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48976 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48977 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48978 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48979 + return ~0UL;
48980 +
48981 +#ifdef CONFIG_PAX_SOFTMODE
48982 + if (pax_softmode)
48983 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48984 + else
48985 +#endif
48986 +
48987 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48988 + break;
48989 + }
48990 +#endif
48991 +
48992 + return ~0UL;
48993 +}
48994 +
48995 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48996 +{
48997 +
48998 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48999 + ssize_t xattr_size, i;
49000 + unsigned char xattr_value[sizeof("pemrs") - 1];
49001 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49002 +
49003 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
49004 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
49005 + return ~0UL;
49006 +
49007 + for (i = 0; i < xattr_size; i++)
49008 + switch (xattr_value[i]) {
49009 + default:
49010 + return ~0UL;
49011 +
49012 +#define parse_flag(option1, option2, flag) \
49013 + case option1: \
49014 + if (pax_flags_hardmode & MF_PAX_##flag) \
49015 + return ~0UL; \
49016 + pax_flags_hardmode |= MF_PAX_##flag; \
49017 + break; \
49018 + case option2: \
49019 + if (pax_flags_softmode & MF_PAX_##flag) \
49020 + return ~0UL; \
49021 + pax_flags_softmode |= MF_PAX_##flag; \
49022 + break;
49023 +
49024 + parse_flag('p', 'P', PAGEEXEC);
49025 + parse_flag('e', 'E', EMUTRAMP);
49026 + parse_flag('m', 'M', MPROTECT);
49027 + parse_flag('r', 'R', RANDMMAP);
49028 + parse_flag('s', 'S', SEGMEXEC);
49029 +
49030 +#undef parse_flag
49031 + }
49032 +
49033 + if (pax_flags_hardmode & pax_flags_softmode)
49034 + return ~0UL;
49035 +
49036 +#ifdef CONFIG_PAX_SOFTMODE
49037 + if (pax_softmode)
49038 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49039 + else
49040 +#endif
49041 +
49042 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49043 +#else
49044 + return ~0UL;
49045 +#endif
49046 +
49047 +}
49048 +
49049 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49050 +{
49051 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49052 +
49053 + pax_flags = pax_parse_ei_pax(elf_ex);
49054 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49055 + xattr_pax_flags = pax_parse_xattr_pax(file);
49056 +
49057 + if (pt_pax_flags == ~0UL)
49058 + pt_pax_flags = xattr_pax_flags;
49059 + else if (xattr_pax_flags == ~0UL)
49060 + xattr_pax_flags = pt_pax_flags;
49061 + if (pt_pax_flags != xattr_pax_flags)
49062 + return -EINVAL;
49063 + if (pt_pax_flags != ~0UL)
49064 + pax_flags = pt_pax_flags;
49065 +
49066 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49067 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49068 + if ((__supported_pte_mask & _PAGE_NX))
49069 + pax_flags &= ~MF_PAX_SEGMEXEC;
49070 + else
49071 + pax_flags &= ~MF_PAX_PAGEEXEC;
49072 + }
49073 +#endif
49074 +
49075 + if (0 > pax_check_flags(&pax_flags))
49076 + return -EINVAL;
49077 +
49078 + current->mm->pax_flags = pax_flags;
49079 + return 0;
49080 +}
49081 +#endif
49082 +
49083 /*
49084 * These are the functions used to load ELF style executables and shared
49085 * libraries. There is no binary dependent code anywhere else.
49086 @@ -554,6 +884,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49087 {
49088 unsigned int random_variable = 0;
49089
49090 +#ifdef CONFIG_PAX_RANDUSTACK
49091 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49092 + return stack_top - current->mm->delta_stack;
49093 +#endif
49094 +
49095 if ((current->flags & PF_RANDOMIZE) &&
49096 !(current->personality & ADDR_NO_RANDOMIZE)) {
49097 random_variable = get_random_int() & STACK_RND_MASK;
49098 @@ -572,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49099 unsigned long load_addr = 0, load_bias = 0;
49100 int load_addr_set = 0;
49101 char * elf_interpreter = NULL;
49102 - unsigned long error;
49103 + unsigned long error = 0;
49104 struct elf_phdr *elf_ppnt, *elf_phdata;
49105 unsigned long elf_bss, elf_brk;
49106 int retval, i;
49107 @@ -582,12 +917,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49108 unsigned long start_code, end_code, start_data, end_data;
49109 unsigned long reloc_func_desc __maybe_unused = 0;
49110 int executable_stack = EXSTACK_DEFAULT;
49111 - unsigned long def_flags = 0;
49112 struct pt_regs *regs = current_pt_regs();
49113 struct {
49114 struct elfhdr elf_ex;
49115 struct elfhdr interp_elf_ex;
49116 } *loc;
49117 + unsigned long pax_task_size = TASK_SIZE;
49118
49119 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49120 if (!loc) {
49121 @@ -723,11 +1058,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49122 goto out_free_dentry;
49123
49124 /* OK, This is the point of no return */
49125 - current->mm->def_flags = def_flags;
49126 +
49127 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49128 + current->mm->pax_flags = 0UL;
49129 +#endif
49130 +
49131 +#ifdef CONFIG_PAX_DLRESOLVE
49132 + current->mm->call_dl_resolve = 0UL;
49133 +#endif
49134 +
49135 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49136 + current->mm->call_syscall = 0UL;
49137 +#endif
49138 +
49139 +#ifdef CONFIG_PAX_ASLR
49140 + current->mm->delta_mmap = 0UL;
49141 + current->mm->delta_stack = 0UL;
49142 +#endif
49143 +
49144 + current->mm->def_flags = 0;
49145 +
49146 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49147 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49148 + send_sig(SIGKILL, current, 0);
49149 + goto out_free_dentry;
49150 + }
49151 +#endif
49152 +
49153 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49154 + pax_set_initial_flags(bprm);
49155 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49156 + if (pax_set_initial_flags_func)
49157 + (pax_set_initial_flags_func)(bprm);
49158 +#endif
49159 +
49160 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49161 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49162 + current->mm->context.user_cs_limit = PAGE_SIZE;
49163 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49164 + }
49165 +#endif
49166 +
49167 +#ifdef CONFIG_PAX_SEGMEXEC
49168 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49169 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49170 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49171 + pax_task_size = SEGMEXEC_TASK_SIZE;
49172 + current->mm->def_flags |= VM_NOHUGEPAGE;
49173 + }
49174 +#endif
49175 +
49176 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49177 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49178 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49179 + put_cpu();
49180 + }
49181 +#endif
49182
49183 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49184 may depend on the personality. */
49185 SET_PERSONALITY(loc->elf_ex);
49186 +
49187 +#ifdef CONFIG_PAX_ASLR
49188 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49189 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49190 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49191 + }
49192 +#endif
49193 +
49194 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49195 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49196 + executable_stack = EXSTACK_DISABLE_X;
49197 + current->personality &= ~READ_IMPLIES_EXEC;
49198 + } else
49199 +#endif
49200 +
49201 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49202 current->personality |= READ_IMPLIES_EXEC;
49203
49204 @@ -819,6 +1224,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49205 #else
49206 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49207 #endif
49208 +
49209 +#ifdef CONFIG_PAX_RANDMMAP
49210 + /* PaX: randomize base address at the default exe base if requested */
49211 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49212 +#ifdef CONFIG_SPARC64
49213 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49214 +#else
49215 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49216 +#endif
49217 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49218 + elf_flags |= MAP_FIXED;
49219 + }
49220 +#endif
49221 +
49222 }
49223
49224 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49225 @@ -851,9 +1270,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49226 * allowed task size. Note that p_filesz must always be
49227 * <= p_memsz so it is only necessary to check p_memsz.
49228 */
49229 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49230 - elf_ppnt->p_memsz > TASK_SIZE ||
49231 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49232 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49233 + elf_ppnt->p_memsz > pax_task_size ||
49234 + pax_task_size - elf_ppnt->p_memsz < k) {
49235 /* set_brk can never work. Avoid overflows. */
49236 send_sig(SIGKILL, current, 0);
49237 retval = -EINVAL;
49238 @@ -892,17 +1311,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49239 goto out_free_dentry;
49240 }
49241 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49242 - send_sig(SIGSEGV, current, 0);
49243 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49244 - goto out_free_dentry;
49245 + /*
49246 + * This bss-zeroing can fail if the ELF
49247 + * file specifies odd protections. So
49248 + * we don't check the return value
49249 + */
49250 }
49251
49252 +#ifdef CONFIG_PAX_RANDMMAP
49253 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49254 + unsigned long start, size, flags;
49255 + vm_flags_t vm_flags;
49256 +
49257 + start = ELF_PAGEALIGN(elf_brk);
49258 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49259 + flags = MAP_FIXED | MAP_PRIVATE;
49260 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49261 +
49262 + down_write(&current->mm->mmap_sem);
49263 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49264 + retval = -ENOMEM;
49265 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49266 +// if (current->personality & ADDR_NO_RANDOMIZE)
49267 +// vm_flags |= VM_READ | VM_MAYREAD;
49268 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49269 + retval = IS_ERR_VALUE(start) ? start : 0;
49270 + }
49271 + up_write(&current->mm->mmap_sem);
49272 + if (retval == 0)
49273 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49274 + if (retval < 0) {
49275 + send_sig(SIGKILL, current, 0);
49276 + goto out_free_dentry;
49277 + }
49278 + }
49279 +#endif
49280 +
49281 if (elf_interpreter) {
49282 - unsigned long interp_map_addr = 0;
49283 -
49284 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49285 interpreter,
49286 - &interp_map_addr,
49287 load_bias);
49288 if (!IS_ERR((void *)elf_entry)) {
49289 /*
49290 @@ -1124,7 +1571,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49291 * Decide what to dump of a segment, part, all or none.
49292 */
49293 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49294 - unsigned long mm_flags)
49295 + unsigned long mm_flags, long signr)
49296 {
49297 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49298
49299 @@ -1162,7 +1609,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49300 if (vma->vm_file == NULL)
49301 return 0;
49302
49303 - if (FILTER(MAPPED_PRIVATE))
49304 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49305 goto whole;
49306
49307 /*
49308 @@ -1387,9 +1834,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49309 {
49310 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49311 int i = 0;
49312 - do
49313 + do {
49314 i += 2;
49315 - while (auxv[i - 2] != AT_NULL);
49316 + } while (auxv[i - 2] != AT_NULL);
49317 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49318 }
49319
49320 @@ -1398,7 +1845,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49321 {
49322 mm_segment_t old_fs = get_fs();
49323 set_fs(KERNEL_DS);
49324 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49325 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49326 set_fs(old_fs);
49327 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49328 }
49329 @@ -2019,14 +2466,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49330 }
49331
49332 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49333 - unsigned long mm_flags)
49334 + struct coredump_params *cprm)
49335 {
49336 struct vm_area_struct *vma;
49337 size_t size = 0;
49338
49339 for (vma = first_vma(current, gate_vma); vma != NULL;
49340 vma = next_vma(vma, gate_vma))
49341 - size += vma_dump_size(vma, mm_flags);
49342 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49343 return size;
49344 }
49345
49346 @@ -2119,7 +2566,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49347
49348 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49349
49350 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49351 + offset += elf_core_vma_data_size(gate_vma, cprm);
49352 offset += elf_core_extra_data_size();
49353 e_shoff = offset;
49354
49355 @@ -2133,10 +2580,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49356 offset = dataoff;
49357
49358 size += sizeof(*elf);
49359 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49360 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49361 goto end_coredump;
49362
49363 size += sizeof(*phdr4note);
49364 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49365 if (size > cprm->limit
49366 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49367 goto end_coredump;
49368 @@ -2150,7 +2599,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49369 phdr.p_offset = offset;
49370 phdr.p_vaddr = vma->vm_start;
49371 phdr.p_paddr = 0;
49372 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49373 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49374 phdr.p_memsz = vma->vm_end - vma->vm_start;
49375 offset += phdr.p_filesz;
49376 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49377 @@ -2161,6 +2610,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49378 phdr.p_align = ELF_EXEC_PAGESIZE;
49379
49380 size += sizeof(phdr);
49381 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49382 if (size > cprm->limit
49383 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49384 goto end_coredump;
49385 @@ -2185,7 +2635,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49386 unsigned long addr;
49387 unsigned long end;
49388
49389 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49390 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49391
49392 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49393 struct page *page;
49394 @@ -2194,6 +2644,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49395 page = get_dump_page(addr);
49396 if (page) {
49397 void *kaddr = kmap(page);
49398 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49399 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49400 !dump_write(cprm->file, kaddr,
49401 PAGE_SIZE);
49402 @@ -2211,6 +2662,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49403
49404 if (e_phnum == PN_XNUM) {
49405 size += sizeof(*shdr4extnum);
49406 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49407 if (size > cprm->limit
49408 || !dump_write(cprm->file, shdr4extnum,
49409 sizeof(*shdr4extnum)))
49410 @@ -2231,6 +2683,97 @@ out:
49411
49412 #endif /* CONFIG_ELF_CORE */
49413
49414 +#ifdef CONFIG_PAX_MPROTECT
49415 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49416 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49417 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49418 + *
49419 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49420 + * basis because we want to allow the common case and not the special ones.
49421 + */
49422 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49423 +{
49424 + struct elfhdr elf_h;
49425 + struct elf_phdr elf_p;
49426 + unsigned long i;
49427 + unsigned long oldflags;
49428 + bool is_textrel_rw, is_textrel_rx, is_relro;
49429 +
49430 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49431 + return;
49432 +
49433 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49434 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49435 +
49436 +#ifdef CONFIG_PAX_ELFRELOCS
49437 + /* possible TEXTREL */
49438 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49439 + 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);
49440 +#else
49441 + is_textrel_rw = false;
49442 + is_textrel_rx = false;
49443 +#endif
49444 +
49445 + /* possible RELRO */
49446 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49447 +
49448 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49449 + return;
49450 +
49451 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49452 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49453 +
49454 +#ifdef CONFIG_PAX_ETEXECRELOCS
49455 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49456 +#else
49457 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49458 +#endif
49459 +
49460 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49461 + !elf_check_arch(&elf_h) ||
49462 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49463 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49464 + return;
49465 +
49466 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49467 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49468 + return;
49469 + switch (elf_p.p_type) {
49470 + case PT_DYNAMIC:
49471 + if (!is_textrel_rw && !is_textrel_rx)
49472 + continue;
49473 + i = 0UL;
49474 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49475 + elf_dyn dyn;
49476 +
49477 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49478 + return;
49479 + if (dyn.d_tag == DT_NULL)
49480 + return;
49481 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49482 + gr_log_textrel(vma);
49483 + if (is_textrel_rw)
49484 + vma->vm_flags |= VM_MAYWRITE;
49485 + else
49486 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49487 + vma->vm_flags &= ~VM_MAYWRITE;
49488 + return;
49489 + }
49490 + i++;
49491 + }
49492 + return;
49493 +
49494 + case PT_GNU_RELRO:
49495 + if (!is_relro)
49496 + continue;
49497 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49498 + vma->vm_flags &= ~VM_MAYWRITE;
49499 + return;
49500 + }
49501 + }
49502 +}
49503 +#endif
49504 +
49505 static int __init init_elf_binfmt(void)
49506 {
49507 register_binfmt(&elf_format);
49508 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49509 index d50bbe5..af3b649 100644
49510 --- a/fs/binfmt_flat.c
49511 +++ b/fs/binfmt_flat.c
49512 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49513 realdatastart = (unsigned long) -ENOMEM;
49514 printk("Unable to allocate RAM for process data, errno %d\n",
49515 (int)-realdatastart);
49516 + down_write(&current->mm->mmap_sem);
49517 vm_munmap(textpos, text_len);
49518 + up_write(&current->mm->mmap_sem);
49519 ret = realdatastart;
49520 goto err;
49521 }
49522 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49523 }
49524 if (IS_ERR_VALUE(result)) {
49525 printk("Unable to read data+bss, errno %d\n", (int)-result);
49526 + down_write(&current->mm->mmap_sem);
49527 vm_munmap(textpos, text_len);
49528 vm_munmap(realdatastart, len);
49529 + up_write(&current->mm->mmap_sem);
49530 ret = result;
49531 goto err;
49532 }
49533 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49534 }
49535 if (IS_ERR_VALUE(result)) {
49536 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49537 + down_write(&current->mm->mmap_sem);
49538 vm_munmap(textpos, text_len + data_len + extra +
49539 MAX_SHARED_LIBS * sizeof(unsigned long));
49540 + up_write(&current->mm->mmap_sem);
49541 ret = result;
49542 goto err;
49543 }
49544 diff --git a/fs/bio.c b/fs/bio.c
49545 index 94bbc04..6fe78a4 100644
49546 --- a/fs/bio.c
49547 +++ b/fs/bio.c
49548 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49549 /*
49550 * Overflow, abort
49551 */
49552 - if (end < start)
49553 + if (end < start || end - start > INT_MAX - nr_pages)
49554 return ERR_PTR(-EINVAL);
49555
49556 nr_pages += end - start;
49557 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49558 /*
49559 * Overflow, abort
49560 */
49561 - if (end < start)
49562 + if (end < start || end - start > INT_MAX - nr_pages)
49563 return ERR_PTR(-EINVAL);
49564
49565 nr_pages += end - start;
49566 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49567 const int read = bio_data_dir(bio) == READ;
49568 struct bio_map_data *bmd = bio->bi_private;
49569 int i;
49570 - char *p = bmd->sgvecs[0].iov_base;
49571 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49572
49573 bio_for_each_segment_all(bvec, bio, i) {
49574 char *addr = page_address(bvec->bv_page);
49575 diff --git a/fs/block_dev.c b/fs/block_dev.c
49576 index 2091db8..81dafe9 100644
49577 --- a/fs/block_dev.c
49578 +++ b/fs/block_dev.c
49579 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49580 else if (bdev->bd_contains == bdev)
49581 return true; /* is a whole device which isn't held */
49582
49583 - else if (whole->bd_holder == bd_may_claim)
49584 + else if (whole->bd_holder == (void *)bd_may_claim)
49585 return true; /* is a partition of a device that is being partitioned */
49586 else if (whole->bd_holder != NULL)
49587 return false; /* is a partition of a held device */
49588 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49589 index 02fae7f..48da375 100644
49590 --- a/fs/btrfs/ctree.c
49591 +++ b/fs/btrfs/ctree.c
49592 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49593 free_extent_buffer(buf);
49594 add_root_to_dirty_list(root);
49595 } else {
49596 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49597 - parent_start = parent->start;
49598 - else
49599 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49600 + if (parent)
49601 + parent_start = parent->start;
49602 + else
49603 + parent_start = 0;
49604 + } else
49605 parent_start = 0;
49606
49607 WARN_ON(trans->transid != btrfs_header_generation(parent));
49608 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49609 index 0f81d67..0ad55fe 100644
49610 --- a/fs/btrfs/ioctl.c
49611 +++ b/fs/btrfs/ioctl.c
49612 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49613 for (i = 0; i < num_types; i++) {
49614 struct btrfs_space_info *tmp;
49615
49616 + /* Don't copy in more than we allocated */
49617 if (!slot_count)
49618 break;
49619
49620 + slot_count--;
49621 +
49622 info = NULL;
49623 rcu_read_lock();
49624 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49625 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49626 memcpy(dest, &space, sizeof(space));
49627 dest++;
49628 space_args.total_spaces++;
49629 - slot_count--;
49630 }
49631 - if (!slot_count)
49632 - break;
49633 }
49634 up_read(&info->groups_sem);
49635 }
49636 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49637 index f0857e0..e7023c5 100644
49638 --- a/fs/btrfs/super.c
49639 +++ b/fs/btrfs/super.c
49640 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49641 function, line, errstr);
49642 return;
49643 }
49644 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49645 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49646 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49647 }
49648 /*
49649 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49650 index 622f469..e8d2d55 100644
49651 --- a/fs/cachefiles/bind.c
49652 +++ b/fs/cachefiles/bind.c
49653 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49654 args);
49655
49656 /* start by checking things over */
49657 - ASSERT(cache->fstop_percent >= 0 &&
49658 - cache->fstop_percent < cache->fcull_percent &&
49659 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49660 cache->fcull_percent < cache->frun_percent &&
49661 cache->frun_percent < 100);
49662
49663 - ASSERT(cache->bstop_percent >= 0 &&
49664 - cache->bstop_percent < cache->bcull_percent &&
49665 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49666 cache->bcull_percent < cache->brun_percent &&
49667 cache->brun_percent < 100);
49668
49669 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49670 index 0a1467b..6a53245 100644
49671 --- a/fs/cachefiles/daemon.c
49672 +++ b/fs/cachefiles/daemon.c
49673 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49674 if (n > buflen)
49675 return -EMSGSIZE;
49676
49677 - if (copy_to_user(_buffer, buffer, n) != 0)
49678 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49679 return -EFAULT;
49680
49681 return n;
49682 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49683 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49684 return -EIO;
49685
49686 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49687 + if (datalen > PAGE_SIZE - 1)
49688 return -EOPNOTSUPP;
49689
49690 /* drag the command string into the kernel so we can parse it */
49691 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49692 if (args[0] != '%' || args[1] != '\0')
49693 return -EINVAL;
49694
49695 - if (fstop < 0 || fstop >= cache->fcull_percent)
49696 + if (fstop >= cache->fcull_percent)
49697 return cachefiles_daemon_range_error(cache, args);
49698
49699 cache->fstop_percent = fstop;
49700 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49701 if (args[0] != '%' || args[1] != '\0')
49702 return -EINVAL;
49703
49704 - if (bstop < 0 || bstop >= cache->bcull_percent)
49705 + if (bstop >= cache->bcull_percent)
49706 return cachefiles_daemon_range_error(cache, args);
49707
49708 cache->bstop_percent = bstop;
49709 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49710 index 4938251..7e01445 100644
49711 --- a/fs/cachefiles/internal.h
49712 +++ b/fs/cachefiles/internal.h
49713 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49714 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49715 struct rb_root active_nodes; /* active nodes (can't be culled) */
49716 rwlock_t active_lock; /* lock for active_nodes */
49717 - atomic_t gravecounter; /* graveyard uniquifier */
49718 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49719 unsigned frun_percent; /* when to stop culling (% files) */
49720 unsigned fcull_percent; /* when to start culling (% files) */
49721 unsigned fstop_percent; /* when to stop allocating (% files) */
49722 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49723 * proc.c
49724 */
49725 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49726 -extern atomic_t cachefiles_lookup_histogram[HZ];
49727 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49728 -extern atomic_t cachefiles_create_histogram[HZ];
49729 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49730 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49731 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49732
49733 extern int __init cachefiles_proc_init(void);
49734 extern void cachefiles_proc_cleanup(void);
49735 static inline
49736 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49737 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49738 {
49739 unsigned long jif = jiffies - start_jif;
49740 if (jif >= HZ)
49741 jif = HZ - 1;
49742 - atomic_inc(&histogram[jif]);
49743 + atomic_inc_unchecked(&histogram[jif]);
49744 }
49745
49746 #else
49747 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49748 index 8c01c5fc..15f982e 100644
49749 --- a/fs/cachefiles/namei.c
49750 +++ b/fs/cachefiles/namei.c
49751 @@ -317,7 +317,7 @@ try_again:
49752 /* first step is to make up a grave dentry in the graveyard */
49753 sprintf(nbuffer, "%08x%08x",
49754 (uint32_t) get_seconds(),
49755 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49756 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49757
49758 /* do the multiway lock magic */
49759 trap = lock_rename(cache->graveyard, dir);
49760 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49761 index eccd339..4c1d995 100644
49762 --- a/fs/cachefiles/proc.c
49763 +++ b/fs/cachefiles/proc.c
49764 @@ -14,9 +14,9 @@
49765 #include <linux/seq_file.h>
49766 #include "internal.h"
49767
49768 -atomic_t cachefiles_lookup_histogram[HZ];
49769 -atomic_t cachefiles_mkdir_histogram[HZ];
49770 -atomic_t cachefiles_create_histogram[HZ];
49771 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49772 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49773 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49774
49775 /*
49776 * display the latency histogram
49777 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49778 return 0;
49779 default:
49780 index = (unsigned long) v - 3;
49781 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49782 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49783 - z = atomic_read(&cachefiles_create_histogram[index]);
49784 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49785 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49786 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49787 if (x == 0 && y == 0 && z == 0)
49788 return 0;
49789
49790 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49791 index 317f9ee..3d24511 100644
49792 --- a/fs/cachefiles/rdwr.c
49793 +++ b/fs/cachefiles/rdwr.c
49794 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49795 old_fs = get_fs();
49796 set_fs(KERNEL_DS);
49797 ret = file->f_op->write(
49798 - file, (const void __user *) data, len, &pos);
49799 + file, (const void __force_user *) data, len, &pos);
49800 set_fs(old_fs);
49801 kunmap(page);
49802 file_end_write(file);
49803 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49804 index f02d82b..2632cf86 100644
49805 --- a/fs/ceph/dir.c
49806 +++ b/fs/ceph/dir.c
49807 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49808 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49809 struct ceph_mds_client *mdsc = fsc->mdsc;
49810 unsigned frag = fpos_frag(filp->f_pos);
49811 - int off = fpos_off(filp->f_pos);
49812 + unsigned int off = fpos_off(filp->f_pos);
49813 int err;
49814 u32 ftype;
49815 struct ceph_mds_reply_info_parsed *rinfo;
49816 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49817 index d597483..747901b 100644
49818 --- a/fs/cifs/cifs_debug.c
49819 +++ b/fs/cifs/cifs_debug.c
49820 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49821
49822 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49823 #ifdef CONFIG_CIFS_STATS2
49824 - atomic_set(&totBufAllocCount, 0);
49825 - atomic_set(&totSmBufAllocCount, 0);
49826 + atomic_set_unchecked(&totBufAllocCount, 0);
49827 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49828 #endif /* CONFIG_CIFS_STATS2 */
49829 spin_lock(&cifs_tcp_ses_lock);
49830 list_for_each(tmp1, &cifs_tcp_ses_list) {
49831 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49832 tcon = list_entry(tmp3,
49833 struct cifs_tcon,
49834 tcon_list);
49835 - atomic_set(&tcon->num_smbs_sent, 0);
49836 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49837 if (server->ops->clear_stats)
49838 server->ops->clear_stats(tcon);
49839 }
49840 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49841 smBufAllocCount.counter, cifs_min_small);
49842 #ifdef CONFIG_CIFS_STATS2
49843 seq_printf(m, "Total Large %d Small %d Allocations\n",
49844 - atomic_read(&totBufAllocCount),
49845 - atomic_read(&totSmBufAllocCount));
49846 + atomic_read_unchecked(&totBufAllocCount),
49847 + atomic_read_unchecked(&totSmBufAllocCount));
49848 #endif /* CONFIG_CIFS_STATS2 */
49849
49850 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49851 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49852 if (tcon->need_reconnect)
49853 seq_puts(m, "\tDISCONNECTED ");
49854 seq_printf(m, "\nSMBs: %d",
49855 - atomic_read(&tcon->num_smbs_sent));
49856 + atomic_read_unchecked(&tcon->num_smbs_sent));
49857 if (server->ops->print_stats)
49858 server->ops->print_stats(m, tcon);
49859 }
49860 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49861 index 3752b9f..8db5569 100644
49862 --- a/fs/cifs/cifsfs.c
49863 +++ b/fs/cifs/cifsfs.c
49864 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
49865 */
49866 cifs_req_cachep = kmem_cache_create("cifs_request",
49867 CIFSMaxBufSize + max_hdr_size, 0,
49868 - SLAB_HWCACHE_ALIGN, NULL);
49869 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49870 if (cifs_req_cachep == NULL)
49871 return -ENOMEM;
49872
49873 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
49874 efficient to alloc 1 per page off the slab compared to 17K (5page)
49875 alloc of large cifs buffers even when page debugging is on */
49876 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49877 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49878 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49879 NULL);
49880 if (cifs_sm_req_cachep == NULL) {
49881 mempool_destroy(cifs_req_poolp);
49882 @@ -1147,8 +1147,8 @@ init_cifs(void)
49883 atomic_set(&bufAllocCount, 0);
49884 atomic_set(&smBufAllocCount, 0);
49885 #ifdef CONFIG_CIFS_STATS2
49886 - atomic_set(&totBufAllocCount, 0);
49887 - atomic_set(&totSmBufAllocCount, 0);
49888 + atomic_set_unchecked(&totBufAllocCount, 0);
49889 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49890 #endif /* CONFIG_CIFS_STATS2 */
49891
49892 atomic_set(&midCount, 0);
49893 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49894 index 4f07f6f..55de8ce 100644
49895 --- a/fs/cifs/cifsglob.h
49896 +++ b/fs/cifs/cifsglob.h
49897 @@ -751,35 +751,35 @@ struct cifs_tcon {
49898 __u16 Flags; /* optional support bits */
49899 enum statusEnum tidStatus;
49900 #ifdef CONFIG_CIFS_STATS
49901 - atomic_t num_smbs_sent;
49902 + atomic_unchecked_t num_smbs_sent;
49903 union {
49904 struct {
49905 - atomic_t num_writes;
49906 - atomic_t num_reads;
49907 - atomic_t num_flushes;
49908 - atomic_t num_oplock_brks;
49909 - atomic_t num_opens;
49910 - atomic_t num_closes;
49911 - atomic_t num_deletes;
49912 - atomic_t num_mkdirs;
49913 - atomic_t num_posixopens;
49914 - atomic_t num_posixmkdirs;
49915 - atomic_t num_rmdirs;
49916 - atomic_t num_renames;
49917 - atomic_t num_t2renames;
49918 - atomic_t num_ffirst;
49919 - atomic_t num_fnext;
49920 - atomic_t num_fclose;
49921 - atomic_t num_hardlinks;
49922 - atomic_t num_symlinks;
49923 - atomic_t num_locks;
49924 - atomic_t num_acl_get;
49925 - atomic_t num_acl_set;
49926 + atomic_unchecked_t num_writes;
49927 + atomic_unchecked_t num_reads;
49928 + atomic_unchecked_t num_flushes;
49929 + atomic_unchecked_t num_oplock_brks;
49930 + atomic_unchecked_t num_opens;
49931 + atomic_unchecked_t num_closes;
49932 + atomic_unchecked_t num_deletes;
49933 + atomic_unchecked_t num_mkdirs;
49934 + atomic_unchecked_t num_posixopens;
49935 + atomic_unchecked_t num_posixmkdirs;
49936 + atomic_unchecked_t num_rmdirs;
49937 + atomic_unchecked_t num_renames;
49938 + atomic_unchecked_t num_t2renames;
49939 + atomic_unchecked_t num_ffirst;
49940 + atomic_unchecked_t num_fnext;
49941 + atomic_unchecked_t num_fclose;
49942 + atomic_unchecked_t num_hardlinks;
49943 + atomic_unchecked_t num_symlinks;
49944 + atomic_unchecked_t num_locks;
49945 + atomic_unchecked_t num_acl_get;
49946 + atomic_unchecked_t num_acl_set;
49947 } cifs_stats;
49948 #ifdef CONFIG_CIFS_SMB2
49949 struct {
49950 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49951 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49952 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49953 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49954 } smb2_stats;
49955 #endif /* CONFIG_CIFS_SMB2 */
49956 } stats;
49957 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49958 }
49959
49960 #ifdef CONFIG_CIFS_STATS
49961 -#define cifs_stats_inc atomic_inc
49962 +#define cifs_stats_inc atomic_inc_unchecked
49963
49964 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49965 unsigned int bytes)
49966 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49967 /* Various Debug counters */
49968 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49969 #ifdef CONFIG_CIFS_STATS2
49970 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49971 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49972 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49973 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49974 #endif
49975 GLOBAL_EXTERN atomic_t smBufAllocCount;
49976 GLOBAL_EXTERN atomic_t midCount;
49977 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49978 index b83c3f5..6437caa 100644
49979 --- a/fs/cifs/link.c
49980 +++ b/fs/cifs/link.c
49981 @@ -616,7 +616,7 @@ symlink_exit:
49982
49983 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49984 {
49985 - char *p = nd_get_link(nd);
49986 + const char *p = nd_get_link(nd);
49987 if (!IS_ERR(p))
49988 kfree(p);
49989 }
49990 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49991 index 1bec014..f329411 100644
49992 --- a/fs/cifs/misc.c
49993 +++ b/fs/cifs/misc.c
49994 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49995 memset(ret_buf, 0, buf_size + 3);
49996 atomic_inc(&bufAllocCount);
49997 #ifdef CONFIG_CIFS_STATS2
49998 - atomic_inc(&totBufAllocCount);
49999 + atomic_inc_unchecked(&totBufAllocCount);
50000 #endif /* CONFIG_CIFS_STATS2 */
50001 }
50002
50003 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50004 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50005 atomic_inc(&smBufAllocCount);
50006 #ifdef CONFIG_CIFS_STATS2
50007 - atomic_inc(&totSmBufAllocCount);
50008 + atomic_inc_unchecked(&totSmBufAllocCount);
50009 #endif /* CONFIG_CIFS_STATS2 */
50010
50011 }
50012 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50013 index 3efdb9d..e845a5e 100644
50014 --- a/fs/cifs/smb1ops.c
50015 +++ b/fs/cifs/smb1ops.c
50016 @@ -591,27 +591,27 @@ static void
50017 cifs_clear_stats(struct cifs_tcon *tcon)
50018 {
50019 #ifdef CONFIG_CIFS_STATS
50020 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50021 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50022 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50023 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50024 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50025 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50026 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50027 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50028 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50029 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50030 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50031 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50032 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50033 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50034 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50035 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50036 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50037 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50038 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50039 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50040 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50041 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50042 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50043 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50044 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50045 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50046 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50047 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50048 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50049 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50050 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50051 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50052 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50053 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50054 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50055 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50056 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50057 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50058 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50059 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50060 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50061 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50062 #endif
50063 }
50064
50065 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50066 {
50067 #ifdef CONFIG_CIFS_STATS
50068 seq_printf(m, " Oplocks breaks: %d",
50069 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50070 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50071 seq_printf(m, "\nReads: %d Bytes: %llu",
50072 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50073 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50074 (long long)(tcon->bytes_read));
50075 seq_printf(m, "\nWrites: %d Bytes: %llu",
50076 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50077 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50078 (long long)(tcon->bytes_written));
50079 seq_printf(m, "\nFlushes: %d",
50080 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50081 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50082 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50083 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50084 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50085 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50086 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50087 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50088 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50089 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50090 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50091 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50092 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50093 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50095 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50096 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50097 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50098 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50099 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50100 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50101 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50102 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50103 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50104 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50106 seq_printf(m, "\nRenames: %d T2 Renames %d",
50107 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50108 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50109 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50110 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50111 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50112 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50113 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50114 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50115 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50116 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50117 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50118 #endif
50119 }
50120
50121 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50122 index f2e76f3..c44fac7 100644
50123 --- a/fs/cifs/smb2ops.c
50124 +++ b/fs/cifs/smb2ops.c
50125 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50126 #ifdef CONFIG_CIFS_STATS
50127 int i;
50128 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50129 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50130 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50131 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50132 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50133 }
50134 #endif
50135 }
50136 @@ -284,66 +284,66 @@ static void
50137 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50138 {
50139 #ifdef CONFIG_CIFS_STATS
50140 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50141 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50142 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50143 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50144 seq_printf(m, "\nNegotiates: %d sent %d failed",
50145 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50146 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50147 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50148 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50149 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50150 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50151 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50152 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50153 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50154 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50155 seq_printf(m, "\nLogoffs: %d sent %d failed",
50156 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50157 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50158 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50159 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50160 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50161 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50162 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50163 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50164 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50165 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50166 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50167 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50168 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50169 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50170 seq_printf(m, "\nCreates: %d sent %d failed",
50171 - atomic_read(&sent[SMB2_CREATE_HE]),
50172 - atomic_read(&failed[SMB2_CREATE_HE]));
50173 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50174 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50175 seq_printf(m, "\nCloses: %d sent %d failed",
50176 - atomic_read(&sent[SMB2_CLOSE_HE]),
50177 - atomic_read(&failed[SMB2_CLOSE_HE]));
50178 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50179 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50180 seq_printf(m, "\nFlushes: %d sent %d failed",
50181 - atomic_read(&sent[SMB2_FLUSH_HE]),
50182 - atomic_read(&failed[SMB2_FLUSH_HE]));
50183 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50184 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50185 seq_printf(m, "\nReads: %d sent %d failed",
50186 - atomic_read(&sent[SMB2_READ_HE]),
50187 - atomic_read(&failed[SMB2_READ_HE]));
50188 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50189 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50190 seq_printf(m, "\nWrites: %d sent %d failed",
50191 - atomic_read(&sent[SMB2_WRITE_HE]),
50192 - atomic_read(&failed[SMB2_WRITE_HE]));
50193 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50194 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50195 seq_printf(m, "\nLocks: %d sent %d failed",
50196 - atomic_read(&sent[SMB2_LOCK_HE]),
50197 - atomic_read(&failed[SMB2_LOCK_HE]));
50198 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50199 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50200 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50201 - atomic_read(&sent[SMB2_IOCTL_HE]),
50202 - atomic_read(&failed[SMB2_IOCTL_HE]));
50203 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50204 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50205 seq_printf(m, "\nCancels: %d sent %d failed",
50206 - atomic_read(&sent[SMB2_CANCEL_HE]),
50207 - atomic_read(&failed[SMB2_CANCEL_HE]));
50208 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50209 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50210 seq_printf(m, "\nEchos: %d sent %d failed",
50211 - atomic_read(&sent[SMB2_ECHO_HE]),
50212 - atomic_read(&failed[SMB2_ECHO_HE]));
50213 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50214 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50215 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50216 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50217 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50218 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50219 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50220 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50221 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50222 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50223 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50224 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50225 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50226 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50227 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50228 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50229 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50230 seq_printf(m, "\nSetInfos: %d sent %d failed",
50231 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50232 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50233 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50234 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50235 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50236 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50237 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50238 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50239 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50240 #endif
50241 }
50242
50243 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50244 index 2b95ce2..d079d75 100644
50245 --- a/fs/cifs/smb2pdu.c
50246 +++ b/fs/cifs/smb2pdu.c
50247 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50248 default:
50249 cifs_dbg(VFS, "info level %u isn't supported\n",
50250 srch_inf->info_level);
50251 - rc = -EINVAL;
50252 - goto qdir_exit;
50253 + return -EINVAL;
50254 }
50255
50256 req->FileIndex = cpu_to_le32(index);
50257 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50258 index 1da168c..8bc7ff6 100644
50259 --- a/fs/coda/cache.c
50260 +++ b/fs/coda/cache.c
50261 @@ -24,7 +24,7 @@
50262 #include "coda_linux.h"
50263 #include "coda_cache.h"
50264
50265 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50266 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50267
50268 /* replace or extend an acl cache hit */
50269 void coda_cache_enter(struct inode *inode, int mask)
50270 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50271 struct coda_inode_info *cii = ITOC(inode);
50272
50273 spin_lock(&cii->c_lock);
50274 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50275 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50276 if (!uid_eq(cii->c_uid, current_fsuid())) {
50277 cii->c_uid = current_fsuid();
50278 cii->c_cached_perm = mask;
50279 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50280 {
50281 struct coda_inode_info *cii = ITOC(inode);
50282 spin_lock(&cii->c_lock);
50283 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50284 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50285 spin_unlock(&cii->c_lock);
50286 }
50287
50288 /* remove all acl caches */
50289 void coda_cache_clear_all(struct super_block *sb)
50290 {
50291 - atomic_inc(&permission_epoch);
50292 + atomic_inc_unchecked(&permission_epoch);
50293 }
50294
50295
50296 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50297 spin_lock(&cii->c_lock);
50298 hit = (mask & cii->c_cached_perm) == mask &&
50299 uid_eq(cii->c_uid, current_fsuid()) &&
50300 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50301 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50302 spin_unlock(&cii->c_lock);
50303
50304 return hit;
50305 diff --git a/fs/compat.c b/fs/compat.c
50306 index fc3b55d..7b568ae 100644
50307 --- a/fs/compat.c
50308 +++ b/fs/compat.c
50309 @@ -54,7 +54,7 @@
50310 #include <asm/ioctls.h>
50311 #include "internal.h"
50312
50313 -int compat_log = 1;
50314 +int compat_log = 0;
50315
50316 int compat_printk(const char *fmt, ...)
50317 {
50318 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50319
50320 set_fs(KERNEL_DS);
50321 /* The __user pointer cast is valid because of the set_fs() */
50322 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50323 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50324 set_fs(oldfs);
50325 /* truncating is ok because it's a user address */
50326 if (!ret)
50327 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50328 goto out;
50329
50330 ret = -EINVAL;
50331 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50332 + if (nr_segs > UIO_MAXIOV)
50333 goto out;
50334 if (nr_segs > fast_segs) {
50335 ret = -ENOMEM;
50336 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
50337
50338 struct compat_readdir_callback {
50339 struct compat_old_linux_dirent __user *dirent;
50340 + struct file * file;
50341 int result;
50342 };
50343
50344 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50345 buf->result = -EOVERFLOW;
50346 return -EOVERFLOW;
50347 }
50348 +
50349 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50350 + return 0;
50351 +
50352 buf->result++;
50353 dirent = buf->dirent;
50354 if (!access_ok(VERIFY_WRITE, dirent,
50355 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50356
50357 buf.result = 0;
50358 buf.dirent = dirent;
50359 + buf.file = f.file;
50360
50361 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50362 if (buf.result)
50363 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
50364 struct compat_getdents_callback {
50365 struct compat_linux_dirent __user *current_dir;
50366 struct compat_linux_dirent __user *previous;
50367 + struct file * file;
50368 int count;
50369 int error;
50370 };
50371 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50372 buf->error = -EOVERFLOW;
50373 return -EOVERFLOW;
50374 }
50375 +
50376 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50377 + return 0;
50378 +
50379 dirent = buf->previous;
50380 if (dirent) {
50381 if (__put_user(offset, &dirent->d_off))
50382 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50383 buf.previous = NULL;
50384 buf.count = count;
50385 buf.error = 0;
50386 + buf.file = f.file;
50387
50388 error = vfs_readdir(f.file, compat_filldir, &buf);
50389 if (error >= 0)
50390 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50391 struct compat_getdents_callback64 {
50392 struct linux_dirent64 __user *current_dir;
50393 struct linux_dirent64 __user *previous;
50394 + struct file * file;
50395 int count;
50396 int error;
50397 };
50398 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50399 buf->error = -EINVAL; /* only used if we fail.. */
50400 if (reclen > buf->count)
50401 return -EINVAL;
50402 +
50403 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50404 + return 0;
50405 +
50406 dirent = buf->previous;
50407
50408 if (dirent) {
50409 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50410 buf.previous = NULL;
50411 buf.count = count;
50412 buf.error = 0;
50413 + buf.file = f.file;
50414
50415 error = vfs_readdir(f.file, compat_filldir64, &buf);
50416 if (error >= 0)
50417 error = buf.error;
50418 lastdirent = buf.previous;
50419 if (lastdirent) {
50420 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50421 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50422 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50423 error = -EFAULT;
50424 else
50425 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50426 index a81147e..20bf2b5 100644
50427 --- a/fs/compat_binfmt_elf.c
50428 +++ b/fs/compat_binfmt_elf.c
50429 @@ -30,11 +30,13 @@
50430 #undef elf_phdr
50431 #undef elf_shdr
50432 #undef elf_note
50433 +#undef elf_dyn
50434 #undef elf_addr_t
50435 #define elfhdr elf32_hdr
50436 #define elf_phdr elf32_phdr
50437 #define elf_shdr elf32_shdr
50438 #define elf_note elf32_note
50439 +#define elf_dyn Elf32_Dyn
50440 #define elf_addr_t Elf32_Addr
50441
50442 /*
50443 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50444 index 996cdc5..15e2f33 100644
50445 --- a/fs/compat_ioctl.c
50446 +++ b/fs/compat_ioctl.c
50447 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50448 return -EFAULT;
50449 if (__get_user(udata, &ss32->iomem_base))
50450 return -EFAULT;
50451 - ss.iomem_base = compat_ptr(udata);
50452 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50453 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50454 __get_user(ss.port_high, &ss32->port_high))
50455 return -EFAULT;
50456 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50457 for (i = 0; i < nmsgs; i++) {
50458 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50459 return -EFAULT;
50460 - if (get_user(datap, &umsgs[i].buf) ||
50461 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50462 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50463 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50464 return -EFAULT;
50465 }
50466 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50467 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
50468 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50469 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50470 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50471 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50472 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50473 return -EFAULT;
50474
50475 return ioctl_preallocate(file, p);
50476 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50477 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50478 {
50479 unsigned int a, b;
50480 - a = *(unsigned int *)p;
50481 - b = *(unsigned int *)q;
50482 + a = *(const unsigned int *)p;
50483 + b = *(const unsigned int *)q;
50484 if (a > b)
50485 return 1;
50486 if (a < b)
50487 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50488 index 7aabc6a..34c1197 100644
50489 --- a/fs/configfs/dir.c
50490 +++ b/fs/configfs/dir.c
50491 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50492 }
50493 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50494 struct configfs_dirent *next;
50495 - const char * name;
50496 + const unsigned char * name;
50497 + char d_name[sizeof(next->s_dentry->d_iname)];
50498 int len;
50499 struct inode *inode = NULL;
50500
50501 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50502 continue;
50503
50504 name = configfs_get_name(next);
50505 - len = strlen(name);
50506 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50507 + len = next->s_dentry->d_name.len;
50508 + memcpy(d_name, name, len);
50509 + name = d_name;
50510 + } else
50511 + len = strlen(name);
50512
50513 /*
50514 * We'll have a dentry and an inode for
50515 diff --git a/fs/coredump.c b/fs/coredump.c
50516 index dafafba..10b3b27 100644
50517 --- a/fs/coredump.c
50518 +++ b/fs/coredump.c
50519 @@ -52,7 +52,7 @@ struct core_name {
50520 char *corename;
50521 int used, size;
50522 };
50523 -static atomic_t call_count = ATOMIC_INIT(1);
50524 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50525
50526 /* The maximal length of core_pattern is also specified in sysctl.c */
50527
50528 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50529 {
50530 char *old_corename = cn->corename;
50531
50532 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50533 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50534 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50535
50536 if (!cn->corename) {
50537 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50538 int pid_in_pattern = 0;
50539 int err = 0;
50540
50541 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50542 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50543 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50544 cn->used = 0;
50545
50546 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
50547 struct pipe_inode_info *pipe = file->private_data;
50548
50549 pipe_lock(pipe);
50550 - pipe->readers++;
50551 - pipe->writers--;
50552 + atomic_inc(&pipe->readers);
50553 + atomic_dec(&pipe->writers);
50554 wake_up_interruptible_sync(&pipe->wait);
50555 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50556 pipe_unlock(pipe);
50557 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
50558 * We actually want wait_event_freezable() but then we need
50559 * to clear TIF_SIGPENDING and improve dump_interrupted().
50560 */
50561 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
50562 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
50563
50564 pipe_lock(pipe);
50565 - pipe->readers--;
50566 - pipe->writers++;
50567 + atomic_dec(&pipe->readers);
50568 + atomic_inc(&pipe->writers);
50569 pipe_unlock(pipe);
50570 }
50571
50572 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
50573 struct files_struct *displaced;
50574 bool need_nonrelative = false;
50575 bool core_dumped = false;
50576 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50577 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50578 + long signr = siginfo->si_signo;
50579 struct coredump_params cprm = {
50580 .siginfo = siginfo,
50581 .regs = signal_pt_regs(),
50582 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
50583 .mm_flags = mm->flags,
50584 };
50585
50586 - audit_core_dumps(siginfo->si_signo);
50587 + audit_core_dumps(signr);
50588 +
50589 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50590 + gr_handle_brute_attach(cprm.mm_flags);
50591
50592 binfmt = mm->binfmt;
50593 if (!binfmt || !binfmt->core_dump)
50594 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
50595 need_nonrelative = true;
50596 }
50597
50598 - retval = coredump_wait(siginfo->si_signo, &core_state);
50599 + retval = coredump_wait(signr, &core_state);
50600 if (retval < 0)
50601 goto fail_creds;
50602
50603 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
50604 }
50605 cprm.limit = RLIM_INFINITY;
50606
50607 - dump_count = atomic_inc_return(&core_dump_count);
50608 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50609 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50610 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50611 task_tgid_vnr(current), current->comm);
50612 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
50613 } else {
50614 struct inode *inode;
50615
50616 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50617 +
50618 if (cprm.limit < binfmt->min_coredump)
50619 goto fail_unlock;
50620
50621 @@ -666,7 +672,7 @@ close_fail:
50622 filp_close(cprm.file, NULL);
50623 fail_dropcount:
50624 if (ispipe)
50625 - atomic_dec(&core_dump_count);
50626 + atomic_dec_unchecked(&core_dump_count);
50627 fail_unlock:
50628 kfree(cn.corename);
50629 fail_corename:
50630 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
50631 {
50632 return !dump_interrupted() &&
50633 access_ok(VERIFY_READ, addr, nr) &&
50634 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50635 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50636 }
50637 EXPORT_SYMBOL(dump_write);
50638
50639 diff --git a/fs/dcache.c b/fs/dcache.c
50640 index f09b908..4dd10d8 100644
50641 --- a/fs/dcache.c
50642 +++ b/fs/dcache.c
50643 @@ -3086,7 +3086,7 @@ void __init vfs_caches_init(unsigned long mempages)
50644 mempages -= reserve;
50645
50646 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50647 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50648 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50649
50650 dcache_init();
50651 inode_init();
50652 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50653 index 4888cb3..e0f7cf8 100644
50654 --- a/fs/debugfs/inode.c
50655 +++ b/fs/debugfs/inode.c
50656 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50657 */
50658 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50659 {
50660 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50661 + return __create_file(name, S_IFDIR | S_IRWXU,
50662 +#else
50663 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50664 +#endif
50665 parent, NULL, NULL);
50666 }
50667 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50668 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50669 index 5eab400..810a3f5 100644
50670 --- a/fs/ecryptfs/inode.c
50671 +++ b/fs/ecryptfs/inode.c
50672 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50673 old_fs = get_fs();
50674 set_fs(get_ds());
50675 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50676 - (char __user *)lower_buf,
50677 + (char __force_user *)lower_buf,
50678 PATH_MAX);
50679 set_fs(old_fs);
50680 if (rc < 0)
50681 @@ -706,7 +706,7 @@ out:
50682 static void
50683 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50684 {
50685 - char *buf = nd_get_link(nd);
50686 + const char *buf = nd_get_link(nd);
50687 if (!IS_ERR(buf)) {
50688 /* Free the char* */
50689 kfree(buf);
50690 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50691 index e4141f2..d8263e8 100644
50692 --- a/fs/ecryptfs/miscdev.c
50693 +++ b/fs/ecryptfs/miscdev.c
50694 @@ -304,7 +304,7 @@ check_list:
50695 goto out_unlock_msg_ctx;
50696 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50697 if (msg_ctx->msg) {
50698 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50699 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50700 goto out_unlock_msg_ctx;
50701 i += packet_length_size;
50702 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50703 diff --git a/fs/exec.c b/fs/exec.c
50704 index ffd7a81..e38107f 100644
50705 --- a/fs/exec.c
50706 +++ b/fs/exec.c
50707 @@ -55,8 +55,20 @@
50708 #include <linux/pipe_fs_i.h>
50709 #include <linux/oom.h>
50710 #include <linux/compat.h>
50711 +#include <linux/random.h>
50712 +#include <linux/seq_file.h>
50713 +#include <linux/coredump.h>
50714 +#include <linux/mman.h>
50715 +
50716 +#ifdef CONFIG_PAX_REFCOUNT
50717 +#include <linux/kallsyms.h>
50718 +#include <linux/kdebug.h>
50719 +#endif
50720 +
50721 +#include <trace/events/fs.h>
50722
50723 #include <asm/uaccess.h>
50724 +#include <asm/sections.h>
50725 #include <asm/mmu_context.h>
50726 #include <asm/tlb.h>
50727
50728 @@ -66,17 +78,32 @@
50729
50730 #include <trace/events/sched.h>
50731
50732 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50733 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50734 +{
50735 + 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");
50736 +}
50737 +#endif
50738 +
50739 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50740 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50741 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50742 +#endif
50743 +
50744 int suid_dumpable = 0;
50745
50746 static LIST_HEAD(formats);
50747 static DEFINE_RWLOCK(binfmt_lock);
50748
50749 +extern int gr_process_kernel_exec_ban(void);
50750 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
50751 +
50752 void __register_binfmt(struct linux_binfmt * fmt, int insert)
50753 {
50754 BUG_ON(!fmt);
50755 write_lock(&binfmt_lock);
50756 - insert ? list_add(&fmt->lh, &formats) :
50757 - list_add_tail(&fmt->lh, &formats);
50758 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50759 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50760 write_unlock(&binfmt_lock);
50761 }
50762
50763 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
50764 void unregister_binfmt(struct linux_binfmt * fmt)
50765 {
50766 write_lock(&binfmt_lock);
50767 - list_del(&fmt->lh);
50768 + pax_list_del((struct list_head *)&fmt->lh);
50769 write_unlock(&binfmt_lock);
50770 }
50771
50772 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50773 int write)
50774 {
50775 struct page *page;
50776 - int ret;
50777
50778 -#ifdef CONFIG_STACK_GROWSUP
50779 - if (write) {
50780 - ret = expand_downwards(bprm->vma, pos);
50781 - if (ret < 0)
50782 - return NULL;
50783 - }
50784 -#endif
50785 - ret = get_user_pages(current, bprm->mm, pos,
50786 - 1, write, 1, &page, NULL);
50787 - if (ret <= 0)
50788 + if (0 > expand_downwards(bprm->vma, pos))
50789 + return NULL;
50790 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50791 return NULL;
50792
50793 if (write) {
50794 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50795 if (size <= ARG_MAX)
50796 return page;
50797
50798 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50799 + // only allow 512KB for argv+env on suid/sgid binaries
50800 + // to prevent easy ASLR exhaustion
50801 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50802 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50803 + (size > (512 * 1024))) {
50804 + put_page(page);
50805 + return NULL;
50806 + }
50807 +#endif
50808 +
50809 /*
50810 * Limit to 1/4-th the stack size for the argv+env strings.
50811 * This ensures that:
50812 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50813 vma->vm_end = STACK_TOP_MAX;
50814 vma->vm_start = vma->vm_end - PAGE_SIZE;
50815 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50816 +
50817 +#ifdef CONFIG_PAX_SEGMEXEC
50818 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50819 +#endif
50820 +
50821 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50822 INIT_LIST_HEAD(&vma->anon_vma_chain);
50823
50824 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50825 mm->stack_vm = mm->total_vm = 1;
50826 up_write(&mm->mmap_sem);
50827 bprm->p = vma->vm_end - sizeof(void *);
50828 +
50829 +#ifdef CONFIG_PAX_RANDUSTACK
50830 + if (randomize_va_space)
50831 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
50832 +#endif
50833 +
50834 return 0;
50835 err:
50836 up_write(&mm->mmap_sem);
50837 @@ -396,7 +437,7 @@ struct user_arg_ptr {
50838 } ptr;
50839 };
50840
50841 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50842 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50843 {
50844 const char __user *native;
50845
50846 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50847 compat_uptr_t compat;
50848
50849 if (get_user(compat, argv.ptr.compat + nr))
50850 - return ERR_PTR(-EFAULT);
50851 + return (const char __force_user *)ERR_PTR(-EFAULT);
50852
50853 return compat_ptr(compat);
50854 }
50855 #endif
50856
50857 if (get_user(native, argv.ptr.native + nr))
50858 - return ERR_PTR(-EFAULT);
50859 + return (const char __force_user *)ERR_PTR(-EFAULT);
50860
50861 return native;
50862 }
50863 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
50864 if (!p)
50865 break;
50866
50867 - if (IS_ERR(p))
50868 + if (IS_ERR((const char __force_kernel *)p))
50869 return -EFAULT;
50870
50871 if (i >= max)
50872 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50873
50874 ret = -EFAULT;
50875 str = get_user_arg_ptr(argv, argc);
50876 - if (IS_ERR(str))
50877 + if (IS_ERR((const char __force_kernel *)str))
50878 goto out;
50879
50880 len = strnlen_user(str, MAX_ARG_STRLEN);
50881 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50882 int r;
50883 mm_segment_t oldfs = get_fs();
50884 struct user_arg_ptr argv = {
50885 - .ptr.native = (const char __user *const __user *)__argv,
50886 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50887 };
50888
50889 set_fs(KERNEL_DS);
50890 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50891 unsigned long new_end = old_end - shift;
50892 struct mmu_gather tlb;
50893
50894 - BUG_ON(new_start > new_end);
50895 + if (new_start >= new_end || new_start < mmap_min_addr)
50896 + return -ENOMEM;
50897
50898 /*
50899 * ensure there are no vmas between where we want to go
50900 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50901 if (vma != find_vma(mm, new_start))
50902 return -EFAULT;
50903
50904 +#ifdef CONFIG_PAX_SEGMEXEC
50905 + BUG_ON(pax_find_mirror_vma(vma));
50906 +#endif
50907 +
50908 /*
50909 * cover the whole range: [new_start, old_end)
50910 */
50911 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50912 stack_top = arch_align_stack(stack_top);
50913 stack_top = PAGE_ALIGN(stack_top);
50914
50915 - if (unlikely(stack_top < mmap_min_addr) ||
50916 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50917 - return -ENOMEM;
50918 -
50919 stack_shift = vma->vm_end - stack_top;
50920
50921 bprm->p -= stack_shift;
50922 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50923 bprm->exec -= stack_shift;
50924
50925 down_write(&mm->mmap_sem);
50926 +
50927 + /* Move stack pages down in memory. */
50928 + if (stack_shift) {
50929 + ret = shift_arg_pages(vma, stack_shift);
50930 + if (ret)
50931 + goto out_unlock;
50932 + }
50933 +
50934 vm_flags = VM_STACK_FLAGS;
50935
50936 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50937 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50938 + vm_flags &= ~VM_EXEC;
50939 +
50940 +#ifdef CONFIG_PAX_MPROTECT
50941 + if (mm->pax_flags & MF_PAX_MPROTECT)
50942 + vm_flags &= ~VM_MAYEXEC;
50943 +#endif
50944 +
50945 + }
50946 +#endif
50947 +
50948 /*
50949 * Adjust stack execute permissions; explicitly enable for
50950 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50951 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50952 goto out_unlock;
50953 BUG_ON(prev != vma);
50954
50955 - /* Move stack pages down in memory. */
50956 - if (stack_shift) {
50957 - ret = shift_arg_pages(vma, stack_shift);
50958 - if (ret)
50959 - goto out_unlock;
50960 - }
50961 -
50962 /* mprotect_fixup is overkill to remove the temporary stack flags */
50963 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50964
50965 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50966 #endif
50967 current->mm->start_stack = bprm->p;
50968 ret = expand_stack(vma, stack_base);
50969 +
50970 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50971 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50972 + unsigned long size;
50973 + vm_flags_t vm_flags;
50974 +
50975 + size = STACK_TOP - vma->vm_end;
50976 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50977 +
50978 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50979 +
50980 +#ifdef CONFIG_X86
50981 + if (!ret) {
50982 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50983 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50984 + }
50985 +#endif
50986 +
50987 + }
50988 +#endif
50989 +
50990 if (ret)
50991 ret = -EFAULT;
50992
50993 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
50994
50995 fsnotify_open(file);
50996
50997 + trace_open_exec(name);
50998 +
50999 err = deny_write_access(file);
51000 if (err)
51001 goto exit;
51002 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
51003 old_fs = get_fs();
51004 set_fs(get_ds());
51005 /* The cast to a user pointer is valid due to the set_fs() */
51006 - result = vfs_read(file, (void __user *)addr, count, &pos);
51007 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51008 set_fs(old_fs);
51009 return result;
51010 }
51011 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51012 }
51013 rcu_read_unlock();
51014
51015 - if (p->fs->users > n_fs) {
51016 + if (atomic_read(&p->fs->users) > n_fs) {
51017 bprm->unsafe |= LSM_UNSAFE_SHARE;
51018 } else {
51019 res = -EAGAIN;
51020 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51021
51022 EXPORT_SYMBOL(search_binary_handler);
51023
51024 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51025 +static DEFINE_PER_CPU(u64, exec_counter);
51026 +static int __init init_exec_counters(void)
51027 +{
51028 + unsigned int cpu;
51029 +
51030 + for_each_possible_cpu(cpu) {
51031 + per_cpu(exec_counter, cpu) = (u64)cpu;
51032 + }
51033 +
51034 + return 0;
51035 +}
51036 +early_initcall(init_exec_counters);
51037 +static inline void increment_exec_counter(void)
51038 +{
51039 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51040 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51041 +}
51042 +#else
51043 +static inline void increment_exec_counter(void) {}
51044 +#endif
51045 +
51046 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51047 + struct user_arg_ptr argv);
51048 +
51049 /*
51050 * sys_execve() executes a new program.
51051 */
51052 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
51053 struct user_arg_ptr argv,
51054 struct user_arg_ptr envp)
51055 {
51056 +#ifdef CONFIG_GRKERNSEC
51057 + struct file *old_exec_file;
51058 + struct acl_subject_label *old_acl;
51059 + struct rlimit old_rlim[RLIM_NLIMITS];
51060 +#endif
51061 struct linux_binprm *bprm;
51062 struct file *file;
51063 struct files_struct *displaced;
51064 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
51065 int retval;
51066 const struct cred *cred = current_cred();
51067
51068 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
51069 +
51070 /*
51071 * We move the actual failure in case of RLIMIT_NPROC excess from
51072 * set*uid() to execve() because too many poorly written programs
51073 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
51074 if (IS_ERR(file))
51075 goto out_unmark;
51076
51077 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51078 + retval = -EPERM;
51079 + goto out_file;
51080 + }
51081 +
51082 sched_exec();
51083
51084 bprm->file = file;
51085 bprm->filename = filename;
51086 bprm->interp = filename;
51087
51088 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
51089 + retval = -EACCES;
51090 + goto out_file;
51091 + }
51092 +
51093 retval = bprm_mm_init(bprm);
51094 if (retval)
51095 goto out_file;
51096 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
51097 if (retval < 0)
51098 goto out;
51099
51100 +#ifdef CONFIG_GRKERNSEC
51101 + old_acl = current->acl;
51102 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51103 + old_exec_file = current->exec_file;
51104 + get_file(file);
51105 + current->exec_file = file;
51106 +#endif
51107 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51108 + /* limit suid stack to 8MB
51109 + * we saved the old limits above and will restore them if this exec fails
51110 + */
51111 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51112 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51113 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51114 +#endif
51115 +
51116 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
51117 + retval = -EPERM;
51118 + goto out_fail;
51119 + }
51120 +
51121 + if (!gr_tpe_allow(file)) {
51122 + retval = -EACCES;
51123 + goto out_fail;
51124 + }
51125 +
51126 + if (gr_check_crash_exec(file)) {
51127 + retval = -EACCES;
51128 + goto out_fail;
51129 + }
51130 +
51131 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
51132 + bprm->unsafe);
51133 + if (retval < 0)
51134 + goto out_fail;
51135 +
51136 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51137 if (retval < 0)
51138 - goto out;
51139 + goto out_fail;
51140
51141 bprm->exec = bprm->p;
51142 retval = copy_strings(bprm->envc, envp, bprm);
51143 if (retval < 0)
51144 - goto out;
51145 + goto out_fail;
51146
51147 retval = copy_strings(bprm->argc, argv, bprm);
51148 if (retval < 0)
51149 - goto out;
51150 + goto out_fail;
51151 +
51152 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51153 +
51154 + gr_handle_exec_args(bprm, argv);
51155
51156 retval = search_binary_handler(bprm);
51157 if (retval < 0)
51158 - goto out;
51159 + goto out_fail;
51160 +#ifdef CONFIG_GRKERNSEC
51161 + if (old_exec_file)
51162 + fput(old_exec_file);
51163 +#endif
51164
51165 /* execve succeeded */
51166 +
51167 + increment_exec_counter();
51168 current->fs->in_exec = 0;
51169 current->in_execve = 0;
51170 acct_update_integrals(current);
51171 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
51172 put_files_struct(displaced);
51173 return retval;
51174
51175 +out_fail:
51176 +#ifdef CONFIG_GRKERNSEC
51177 + current->acl = old_acl;
51178 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51179 + fput(current->exec_file);
51180 + current->exec_file = old_exec_file;
51181 +#endif
51182 +
51183 out:
51184 if (bprm->mm) {
51185 acct_arg_size(bprm, 0);
51186 @@ -1701,3 +1875,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51187 return error;
51188 }
51189 #endif
51190 +
51191 +int pax_check_flags(unsigned long *flags)
51192 +{
51193 + int retval = 0;
51194 +
51195 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51196 + if (*flags & MF_PAX_SEGMEXEC)
51197 + {
51198 + *flags &= ~MF_PAX_SEGMEXEC;
51199 + retval = -EINVAL;
51200 + }
51201 +#endif
51202 +
51203 + if ((*flags & MF_PAX_PAGEEXEC)
51204 +
51205 +#ifdef CONFIG_PAX_PAGEEXEC
51206 + && (*flags & MF_PAX_SEGMEXEC)
51207 +#endif
51208 +
51209 + )
51210 + {
51211 + *flags &= ~MF_PAX_PAGEEXEC;
51212 + retval = -EINVAL;
51213 + }
51214 +
51215 + if ((*flags & MF_PAX_MPROTECT)
51216 +
51217 +#ifdef CONFIG_PAX_MPROTECT
51218 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51219 +#endif
51220 +
51221 + )
51222 + {
51223 + *flags &= ~MF_PAX_MPROTECT;
51224 + retval = -EINVAL;
51225 + }
51226 +
51227 + if ((*flags & MF_PAX_EMUTRAMP)
51228 +
51229 +#ifdef CONFIG_PAX_EMUTRAMP
51230 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51231 +#endif
51232 +
51233 + )
51234 + {
51235 + *flags &= ~MF_PAX_EMUTRAMP;
51236 + retval = -EINVAL;
51237 + }
51238 +
51239 + return retval;
51240 +}
51241 +
51242 +EXPORT_SYMBOL(pax_check_flags);
51243 +
51244 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51245 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51246 +{
51247 + struct task_struct *tsk = current;
51248 + struct mm_struct *mm = current->mm;
51249 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51250 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51251 + char *path_exec = NULL;
51252 + char *path_fault = NULL;
51253 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51254 + siginfo_t info = { };
51255 +
51256 + if (buffer_exec && buffer_fault) {
51257 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51258 +
51259 + down_read(&mm->mmap_sem);
51260 + vma = mm->mmap;
51261 + while (vma && (!vma_exec || !vma_fault)) {
51262 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51263 + vma_exec = vma;
51264 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51265 + vma_fault = vma;
51266 + vma = vma->vm_next;
51267 + }
51268 + if (vma_exec) {
51269 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51270 + if (IS_ERR(path_exec))
51271 + path_exec = "<path too long>";
51272 + else {
51273 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51274 + if (path_exec) {
51275 + *path_exec = 0;
51276 + path_exec = buffer_exec;
51277 + } else
51278 + path_exec = "<path too long>";
51279 + }
51280 + }
51281 + if (vma_fault) {
51282 + start = vma_fault->vm_start;
51283 + end = vma_fault->vm_end;
51284 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51285 + if (vma_fault->vm_file) {
51286 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51287 + if (IS_ERR(path_fault))
51288 + path_fault = "<path too long>";
51289 + else {
51290 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51291 + if (path_fault) {
51292 + *path_fault = 0;
51293 + path_fault = buffer_fault;
51294 + } else
51295 + path_fault = "<path too long>";
51296 + }
51297 + } else
51298 + path_fault = "<anonymous mapping>";
51299 + }
51300 + up_read(&mm->mmap_sem);
51301 + }
51302 + if (tsk->signal->curr_ip)
51303 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51304 + else
51305 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51306 + 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),
51307 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51308 + free_page((unsigned long)buffer_exec);
51309 + free_page((unsigned long)buffer_fault);
51310 + pax_report_insns(regs, pc, sp);
51311 + info.si_signo = SIGKILL;
51312 + info.si_errno = 0;
51313 + info.si_code = SI_KERNEL;
51314 + info.si_pid = 0;
51315 + info.si_uid = 0;
51316 + do_coredump(&info);
51317 +}
51318 +#endif
51319 +
51320 +#ifdef CONFIG_PAX_REFCOUNT
51321 +void pax_report_refcount_overflow(struct pt_regs *regs)
51322 +{
51323 + if (current->signal->curr_ip)
51324 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51325 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51326 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51327 + else
51328 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51329 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51330 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51331 + show_regs(regs);
51332 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51333 +}
51334 +#endif
51335 +
51336 +#ifdef CONFIG_PAX_USERCOPY
51337 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51338 +static noinline int check_stack_object(const void *obj, unsigned long len)
51339 +{
51340 + const void * const stack = task_stack_page(current);
51341 + const void * const stackend = stack + THREAD_SIZE;
51342 +
51343 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51344 + const void *frame = NULL;
51345 + const void *oldframe;
51346 +#endif
51347 +
51348 + if (obj + len < obj)
51349 + return -1;
51350 +
51351 + if (obj + len <= stack || stackend <= obj)
51352 + return 0;
51353 +
51354 + if (obj < stack || stackend < obj + len)
51355 + return -1;
51356 +
51357 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51358 + oldframe = __builtin_frame_address(1);
51359 + if (oldframe)
51360 + frame = __builtin_frame_address(2);
51361 + /*
51362 + low ----------------------------------------------> high
51363 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51364 + ^----------------^
51365 + allow copies only within here
51366 + */
51367 + while (stack <= frame && frame < stackend) {
51368 + /* if obj + len extends past the last frame, this
51369 + check won't pass and the next frame will be 0,
51370 + causing us to bail out and correctly report
51371 + the copy as invalid
51372 + */
51373 + if (obj + len <= frame)
51374 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51375 + oldframe = frame;
51376 + frame = *(const void * const *)frame;
51377 + }
51378 + return -1;
51379 +#else
51380 + return 1;
51381 +#endif
51382 +}
51383 +
51384 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51385 +{
51386 + if (current->signal->curr_ip)
51387 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51388 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51389 + else
51390 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51391 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51392 + dump_stack();
51393 + gr_handle_kernel_exploit();
51394 + do_group_exit(SIGKILL);
51395 +}
51396 +#endif
51397 +
51398 +#ifdef CONFIG_PAX_USERCOPY
51399 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51400 +{
51401 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51402 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51403 +#ifdef CONFIG_MODULES
51404 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51405 +#else
51406 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51407 +#endif
51408 +
51409 +#else
51410 + unsigned long textlow = (unsigned long)_stext;
51411 + unsigned long texthigh = (unsigned long)_etext;
51412 +#endif
51413 +
51414 + if (high <= textlow || low > texthigh)
51415 + return false;
51416 + else
51417 + return true;
51418 +}
51419 +#endif
51420 +
51421 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51422 +{
51423 +
51424 +#ifdef CONFIG_PAX_USERCOPY
51425 + const char *type;
51426 +
51427 + if (!n)
51428 + return;
51429 +
51430 + type = check_heap_object(ptr, n);
51431 + if (!type) {
51432 + int ret = check_stack_object(ptr, n);
51433 + if (ret == 1 || ret == 2)
51434 + return;
51435 + if (ret == 0) {
51436 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51437 + type = "<kernel text>";
51438 + else
51439 + return;
51440 + } else
51441 + type = "<process stack>";
51442 + }
51443 +
51444 + pax_report_usercopy(ptr, n, to_user, type);
51445 +#endif
51446 +
51447 +}
51448 +EXPORT_SYMBOL(__check_object_size);
51449 +
51450 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51451 +void pax_track_stack(void)
51452 +{
51453 + unsigned long sp = (unsigned long)&sp;
51454 + if (sp < current_thread_info()->lowest_stack &&
51455 + sp > (unsigned long)task_stack_page(current))
51456 + current_thread_info()->lowest_stack = sp;
51457 +}
51458 +EXPORT_SYMBOL(pax_track_stack);
51459 +#endif
51460 +
51461 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51462 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51463 +{
51464 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51465 + dump_stack();
51466 + do_group_exit(SIGKILL);
51467 +}
51468 +EXPORT_SYMBOL(report_size_overflow);
51469 +#endif
51470 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51471 index 9f9992b..8b59411 100644
51472 --- a/fs/ext2/balloc.c
51473 +++ b/fs/ext2/balloc.c
51474 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51475
51476 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51477 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51478 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51479 + if (free_blocks < root_blocks + 1 &&
51480 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51481 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51482 - !in_group_p (sbi->s_resgid))) {
51483 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51484 return 0;
51485 }
51486 return 1;
51487 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51488 index 22548f5..41521d8 100644
51489 --- a/fs/ext3/balloc.c
51490 +++ b/fs/ext3/balloc.c
51491 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51492
51493 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51494 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51495 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51496 + if (free_blocks < root_blocks + 1 &&
51497 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51498 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51499 - !in_group_p (sbi->s_resgid))) {
51500 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51501 return 0;
51502 }
51503 return 1;
51504 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51505 index d0f13ea..4b2dadd 100644
51506 --- a/fs/ext4/balloc.c
51507 +++ b/fs/ext4/balloc.c
51508 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51509 /* Hm, nope. Are (enough) root reserved clusters available? */
51510 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51511 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51512 - capable(CAP_SYS_RESOURCE) ||
51513 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51514 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51515 + capable_nolog(CAP_SYS_RESOURCE)) {
51516
51517 if (free_clusters >= (nclusters + dirty_clusters +
51518 resv_clusters))
51519 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51520 index 5aae3d1..b5da7f8 100644
51521 --- a/fs/ext4/ext4.h
51522 +++ b/fs/ext4/ext4.h
51523 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
51524 unsigned long s_mb_last_start;
51525
51526 /* stats for buddy allocator */
51527 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51528 - atomic_t s_bal_success; /* we found long enough chunks */
51529 - atomic_t s_bal_allocated; /* in blocks */
51530 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51531 - atomic_t s_bal_goals; /* goal hits */
51532 - atomic_t s_bal_breaks; /* too long searches */
51533 - atomic_t s_bal_2orders; /* 2^order hits */
51534 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51535 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51536 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51537 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51538 + atomic_unchecked_t s_bal_goals; /* goal hits */
51539 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51540 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51541 spinlock_t s_bal_lock;
51542 unsigned long s_mb_buddies_generated;
51543 unsigned long long s_mb_generation_time;
51544 - atomic_t s_mb_lost_chunks;
51545 - atomic_t s_mb_preallocated;
51546 - atomic_t s_mb_discarded;
51547 + atomic_unchecked_t s_mb_lost_chunks;
51548 + atomic_unchecked_t s_mb_preallocated;
51549 + atomic_unchecked_t s_mb_discarded;
51550 atomic_t s_lock_busy;
51551
51552 /* locality groups */
51553 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51554 index def8408..8253d11 100644
51555 --- a/fs/ext4/mballoc.c
51556 +++ b/fs/ext4/mballoc.c
51557 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51558 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51559
51560 if (EXT4_SB(sb)->s_mb_stats)
51561 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51562 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51563
51564 break;
51565 }
51566 @@ -2170,7 +2170,7 @@ repeat:
51567 ac->ac_status = AC_STATUS_CONTINUE;
51568 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51569 cr = 3;
51570 - atomic_inc(&sbi->s_mb_lost_chunks);
51571 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51572 goto repeat;
51573 }
51574 }
51575 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
51576 if (sbi->s_mb_stats) {
51577 ext4_msg(sb, KERN_INFO,
51578 "mballoc: %u blocks %u reqs (%u success)",
51579 - atomic_read(&sbi->s_bal_allocated),
51580 - atomic_read(&sbi->s_bal_reqs),
51581 - atomic_read(&sbi->s_bal_success));
51582 + atomic_read_unchecked(&sbi->s_bal_allocated),
51583 + atomic_read_unchecked(&sbi->s_bal_reqs),
51584 + atomic_read_unchecked(&sbi->s_bal_success));
51585 ext4_msg(sb, KERN_INFO,
51586 "mballoc: %u extents scanned, %u goal hits, "
51587 "%u 2^N hits, %u breaks, %u lost",
51588 - atomic_read(&sbi->s_bal_ex_scanned),
51589 - atomic_read(&sbi->s_bal_goals),
51590 - atomic_read(&sbi->s_bal_2orders),
51591 - atomic_read(&sbi->s_bal_breaks),
51592 - atomic_read(&sbi->s_mb_lost_chunks));
51593 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51594 + atomic_read_unchecked(&sbi->s_bal_goals),
51595 + atomic_read_unchecked(&sbi->s_bal_2orders),
51596 + atomic_read_unchecked(&sbi->s_bal_breaks),
51597 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51598 ext4_msg(sb, KERN_INFO,
51599 "mballoc: %lu generated and it took %Lu",
51600 sbi->s_mb_buddies_generated,
51601 sbi->s_mb_generation_time);
51602 ext4_msg(sb, KERN_INFO,
51603 "mballoc: %u preallocated, %u discarded",
51604 - atomic_read(&sbi->s_mb_preallocated),
51605 - atomic_read(&sbi->s_mb_discarded));
51606 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51607 + atomic_read_unchecked(&sbi->s_mb_discarded));
51608 }
51609
51610 free_percpu(sbi->s_locality_groups);
51611 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51612 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51613
51614 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51615 - atomic_inc(&sbi->s_bal_reqs);
51616 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51617 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51618 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51619 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51620 - atomic_inc(&sbi->s_bal_success);
51621 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51622 + atomic_inc_unchecked(&sbi->s_bal_success);
51623 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51624 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51625 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51626 - atomic_inc(&sbi->s_bal_goals);
51627 + atomic_inc_unchecked(&sbi->s_bal_goals);
51628 if (ac->ac_found > sbi->s_mb_max_to_scan)
51629 - atomic_inc(&sbi->s_bal_breaks);
51630 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51631 }
51632
51633 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51634 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51635 trace_ext4_mb_new_inode_pa(ac, pa);
51636
51637 ext4_mb_use_inode_pa(ac, pa);
51638 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51639 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51640
51641 ei = EXT4_I(ac->ac_inode);
51642 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51643 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51644 trace_ext4_mb_new_group_pa(ac, pa);
51645
51646 ext4_mb_use_group_pa(ac, pa);
51647 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51648 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51649
51650 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51651 lg = ac->ac_lg;
51652 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51653 * from the bitmap and continue.
51654 */
51655 }
51656 - atomic_add(free, &sbi->s_mb_discarded);
51657 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51658
51659 return err;
51660 }
51661 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51662 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51663 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51664 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51665 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51666 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51667 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51668
51669 return 0;
51670 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51671 index 214461e..3614c89 100644
51672 --- a/fs/ext4/mmp.c
51673 +++ b/fs/ext4/mmp.c
51674 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51675 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51676 const char *function, unsigned int line, const char *msg)
51677 {
51678 - __ext4_warning(sb, function, line, msg);
51679 + __ext4_warning(sb, function, line, "%s", msg);
51680 __ext4_warning(sb, function, line,
51681 "MMP failure info: last update time: %llu, last update "
51682 "node: %s, last update device: %s\n",
51683 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51684 index b27c96d..6ed4df2 100644
51685 --- a/fs/ext4/resize.c
51686 +++ b/fs/ext4/resize.c
51687 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51688 ext4_fsblk_t end = start + input->blocks_count;
51689 ext4_group_t group = input->group;
51690 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51691 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51692 - ext4_fsblk_t metaend = start + overhead;
51693 + unsigned overhead;
51694 + ext4_fsblk_t metaend;
51695 struct buffer_head *bh = NULL;
51696 ext4_grpblk_t free_blocks_count, offset;
51697 int err = -EINVAL;
51698
51699 + if (group != sbi->s_groups_count) {
51700 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51701 + input->group, sbi->s_groups_count);
51702 + return -EINVAL;
51703 + }
51704 +
51705 + overhead = ext4_group_overhead_blocks(sb, group);
51706 + metaend = start + overhead;
51707 input->free_blocks_count = free_blocks_count =
51708 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51709
51710 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51711 free_blocks_count, input->reserved_blocks);
51712
51713 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51714 - if (group != sbi->s_groups_count)
51715 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51716 - input->group, sbi->s_groups_count);
51717 - else if (offset != 0)
51718 + if (offset != 0)
51719 ext4_warning(sb, "Last group not full");
51720 else if (input->reserved_blocks > input->blocks_count / 5)
51721 ext4_warning(sb, "Reserved blocks too high (%u)",
51722 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51723 index 94cc84d..2490974 100644
51724 --- a/fs/ext4/super.c
51725 +++ b/fs/ext4/super.c
51726 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51727 }
51728
51729 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51730 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51731 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51732 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51733
51734 #ifdef CONFIG_QUOTA
51735 @@ -2378,7 +2378,7 @@ struct ext4_attr {
51736 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51737 const char *, size_t);
51738 int offset;
51739 -};
51740 +} __do_const;
51741
51742 static int parse_strtoull(const char *buf,
51743 unsigned long long max, unsigned long long *value)
51744 diff --git a/fs/fcntl.c b/fs/fcntl.c
51745 index 6599222..e7bf0de 100644
51746 --- a/fs/fcntl.c
51747 +++ b/fs/fcntl.c
51748 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51749 if (err)
51750 return err;
51751
51752 + if (gr_handle_chroot_fowner(pid, type))
51753 + return -ENOENT;
51754 + if (gr_check_protected_task_fowner(pid, type))
51755 + return -EACCES;
51756 +
51757 f_modown(filp, pid, type, force);
51758 return 0;
51759 }
51760 diff --git a/fs/fhandle.c b/fs/fhandle.c
51761 index 999ff5c..41f4109 100644
51762 --- a/fs/fhandle.c
51763 +++ b/fs/fhandle.c
51764 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51765 } else
51766 retval = 0;
51767 /* copy the mount id */
51768 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51769 - sizeof(*mnt_id)) ||
51770 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51771 copy_to_user(ufh, handle,
51772 sizeof(struct file_handle) + handle_bytes))
51773 retval = -EFAULT;
51774 diff --git a/fs/file.c b/fs/file.c
51775 index 4a78f98..9447397 100644
51776 --- a/fs/file.c
51777 +++ b/fs/file.c
51778 @@ -16,6 +16,7 @@
51779 #include <linux/slab.h>
51780 #include <linux/vmalloc.h>
51781 #include <linux/file.h>
51782 +#include <linux/security.h>
51783 #include <linux/fdtable.h>
51784 #include <linux/bitops.h>
51785 #include <linux/interrupt.h>
51786 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51787 if (!file)
51788 return __close_fd(files, fd);
51789
51790 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51791 if (fd >= rlimit(RLIMIT_NOFILE))
51792 return -EBADF;
51793
51794 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51795 if (unlikely(oldfd == newfd))
51796 return -EINVAL;
51797
51798 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51799 if (newfd >= rlimit(RLIMIT_NOFILE))
51800 return -EBADF;
51801
51802 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51803 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51804 {
51805 int err;
51806 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51807 if (from >= rlimit(RLIMIT_NOFILE))
51808 return -EINVAL;
51809 err = alloc_fd(from, flags);
51810 diff --git a/fs/filesystems.c b/fs/filesystems.c
51811 index 92567d9..fcd8cbf 100644
51812 --- a/fs/filesystems.c
51813 +++ b/fs/filesystems.c
51814 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51815 int len = dot ? dot - name : strlen(name);
51816
51817 fs = __get_fs_type(name, len);
51818 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51819 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51820 +#else
51821 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51822 +#endif
51823 fs = __get_fs_type(name, len);
51824
51825 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51826 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51827 index d8ac61d..79a36f0 100644
51828 --- a/fs/fs_struct.c
51829 +++ b/fs/fs_struct.c
51830 @@ -4,6 +4,7 @@
51831 #include <linux/path.h>
51832 #include <linux/slab.h>
51833 #include <linux/fs_struct.h>
51834 +#include <linux/grsecurity.h>
51835 #include "internal.h"
51836
51837 /*
51838 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51839 write_seqcount_begin(&fs->seq);
51840 old_root = fs->root;
51841 fs->root = *path;
51842 + gr_set_chroot_entries(current, path);
51843 write_seqcount_end(&fs->seq);
51844 spin_unlock(&fs->lock);
51845 if (old_root.dentry)
51846 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51847 int hits = 0;
51848 spin_lock(&fs->lock);
51849 write_seqcount_begin(&fs->seq);
51850 + /* this root replacement is only done by pivot_root,
51851 + leave grsec's chroot tagging alone for this task
51852 + so that a pivoted root isn't treated as a chroot
51853 + */
51854 hits += replace_path(&fs->root, old_root, new_root);
51855 hits += replace_path(&fs->pwd, old_root, new_root);
51856 write_seqcount_end(&fs->seq);
51857 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51858 task_lock(tsk);
51859 spin_lock(&fs->lock);
51860 tsk->fs = NULL;
51861 - kill = !--fs->users;
51862 + gr_clear_chroot_entries(tsk);
51863 + kill = !atomic_dec_return(&fs->users);
51864 spin_unlock(&fs->lock);
51865 task_unlock(tsk);
51866 if (kill)
51867 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51868 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51869 /* We don't need to lock fs - think why ;-) */
51870 if (fs) {
51871 - fs->users = 1;
51872 + atomic_set(&fs->users, 1);
51873 fs->in_exec = 0;
51874 spin_lock_init(&fs->lock);
51875 seqcount_init(&fs->seq);
51876 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51877 spin_lock(&old->lock);
51878 fs->root = old->root;
51879 path_get(&fs->root);
51880 + /* instead of calling gr_set_chroot_entries here,
51881 + we call it from every caller of this function
51882 + */
51883 fs->pwd = old->pwd;
51884 path_get(&fs->pwd);
51885 spin_unlock(&old->lock);
51886 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51887
51888 task_lock(current);
51889 spin_lock(&fs->lock);
51890 - kill = !--fs->users;
51891 + kill = !atomic_dec_return(&fs->users);
51892 current->fs = new_fs;
51893 + gr_set_chroot_entries(current, &new_fs->root);
51894 spin_unlock(&fs->lock);
51895 task_unlock(current);
51896
51897 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51898
51899 int current_umask(void)
51900 {
51901 - return current->fs->umask;
51902 + return current->fs->umask | gr_acl_umask();
51903 }
51904 EXPORT_SYMBOL(current_umask);
51905
51906 /* to be mentioned only in INIT_TASK */
51907 struct fs_struct init_fs = {
51908 - .users = 1,
51909 + .users = ATOMIC_INIT(1),
51910 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51911 .seq = SEQCNT_ZERO,
51912 .umask = 0022,
51913 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51914 index e2cba1f..17a25bb 100644
51915 --- a/fs/fscache/cookie.c
51916 +++ b/fs/fscache/cookie.c
51917 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51918 parent ? (char *) parent->def->name : "<no-parent>",
51919 def->name, netfs_data);
51920
51921 - fscache_stat(&fscache_n_acquires);
51922 + fscache_stat_unchecked(&fscache_n_acquires);
51923
51924 /* if there's no parent cookie, then we don't create one here either */
51925 if (!parent) {
51926 - fscache_stat(&fscache_n_acquires_null);
51927 + fscache_stat_unchecked(&fscache_n_acquires_null);
51928 _leave(" [no parent]");
51929 return NULL;
51930 }
51931 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51932 /* allocate and initialise a cookie */
51933 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51934 if (!cookie) {
51935 - fscache_stat(&fscache_n_acquires_oom);
51936 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51937 _leave(" [ENOMEM]");
51938 return NULL;
51939 }
51940 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51941
51942 switch (cookie->def->type) {
51943 case FSCACHE_COOKIE_TYPE_INDEX:
51944 - fscache_stat(&fscache_n_cookie_index);
51945 + fscache_stat_unchecked(&fscache_n_cookie_index);
51946 break;
51947 case FSCACHE_COOKIE_TYPE_DATAFILE:
51948 - fscache_stat(&fscache_n_cookie_data);
51949 + fscache_stat_unchecked(&fscache_n_cookie_data);
51950 break;
51951 default:
51952 - fscache_stat(&fscache_n_cookie_special);
51953 + fscache_stat_unchecked(&fscache_n_cookie_special);
51954 break;
51955 }
51956
51957 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51958 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51959 atomic_dec(&parent->n_children);
51960 __fscache_cookie_put(cookie);
51961 - fscache_stat(&fscache_n_acquires_nobufs);
51962 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51963 _leave(" = NULL");
51964 return NULL;
51965 }
51966 }
51967
51968 - fscache_stat(&fscache_n_acquires_ok);
51969 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51970 _leave(" = %p", cookie);
51971 return cookie;
51972 }
51973 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51974 cache = fscache_select_cache_for_object(cookie->parent);
51975 if (!cache) {
51976 up_read(&fscache_addremove_sem);
51977 - fscache_stat(&fscache_n_acquires_no_cache);
51978 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51979 _leave(" = -ENOMEDIUM [no cache]");
51980 return -ENOMEDIUM;
51981 }
51982 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51983 object = cache->ops->alloc_object(cache, cookie);
51984 fscache_stat_d(&fscache_n_cop_alloc_object);
51985 if (IS_ERR(object)) {
51986 - fscache_stat(&fscache_n_object_no_alloc);
51987 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51988 ret = PTR_ERR(object);
51989 goto error;
51990 }
51991
51992 - fscache_stat(&fscache_n_object_alloc);
51993 + fscache_stat_unchecked(&fscache_n_object_alloc);
51994
51995 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51996
51997 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51998
51999 _enter("{%s}", cookie->def->name);
52000
52001 - fscache_stat(&fscache_n_invalidates);
52002 + fscache_stat_unchecked(&fscache_n_invalidates);
52003
52004 /* Only permit invalidation of data files. Invalidating an index will
52005 * require the caller to release all its attachments to the tree rooted
52006 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52007 {
52008 struct fscache_object *object;
52009
52010 - fscache_stat(&fscache_n_updates);
52011 + fscache_stat_unchecked(&fscache_n_updates);
52012
52013 if (!cookie) {
52014 - fscache_stat(&fscache_n_updates_null);
52015 + fscache_stat_unchecked(&fscache_n_updates_null);
52016 _leave(" [no cookie]");
52017 return;
52018 }
52019 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52020 struct fscache_object *object;
52021 unsigned long event;
52022
52023 - fscache_stat(&fscache_n_relinquishes);
52024 + fscache_stat_unchecked(&fscache_n_relinquishes);
52025 if (retire)
52026 - fscache_stat(&fscache_n_relinquishes_retire);
52027 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52028
52029 if (!cookie) {
52030 - fscache_stat(&fscache_n_relinquishes_null);
52031 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52032 _leave(" [no cookie]");
52033 return;
52034 }
52035 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52036
52037 /* wait for the cookie to finish being instantiated (or to fail) */
52038 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52039 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52040 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52041 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52042 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52043 }
52044 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52045 index ee38fef..0a326d4 100644
52046 --- a/fs/fscache/internal.h
52047 +++ b/fs/fscache/internal.h
52048 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52049 * stats.c
52050 */
52051 #ifdef CONFIG_FSCACHE_STATS
52052 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52053 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52054 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52055 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52056
52057 -extern atomic_t fscache_n_op_pend;
52058 -extern atomic_t fscache_n_op_run;
52059 -extern atomic_t fscache_n_op_enqueue;
52060 -extern atomic_t fscache_n_op_deferred_release;
52061 -extern atomic_t fscache_n_op_release;
52062 -extern atomic_t fscache_n_op_gc;
52063 -extern atomic_t fscache_n_op_cancelled;
52064 -extern atomic_t fscache_n_op_rejected;
52065 +extern atomic_unchecked_t fscache_n_op_pend;
52066 +extern atomic_unchecked_t fscache_n_op_run;
52067 +extern atomic_unchecked_t fscache_n_op_enqueue;
52068 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52069 +extern atomic_unchecked_t fscache_n_op_release;
52070 +extern atomic_unchecked_t fscache_n_op_gc;
52071 +extern atomic_unchecked_t fscache_n_op_cancelled;
52072 +extern atomic_unchecked_t fscache_n_op_rejected;
52073
52074 -extern atomic_t fscache_n_attr_changed;
52075 -extern atomic_t fscache_n_attr_changed_ok;
52076 -extern atomic_t fscache_n_attr_changed_nobufs;
52077 -extern atomic_t fscache_n_attr_changed_nomem;
52078 -extern atomic_t fscache_n_attr_changed_calls;
52079 +extern atomic_unchecked_t fscache_n_attr_changed;
52080 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52081 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52082 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52083 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52084
52085 -extern atomic_t fscache_n_allocs;
52086 -extern atomic_t fscache_n_allocs_ok;
52087 -extern atomic_t fscache_n_allocs_wait;
52088 -extern atomic_t fscache_n_allocs_nobufs;
52089 -extern atomic_t fscache_n_allocs_intr;
52090 -extern atomic_t fscache_n_allocs_object_dead;
52091 -extern atomic_t fscache_n_alloc_ops;
52092 -extern atomic_t fscache_n_alloc_op_waits;
52093 +extern atomic_unchecked_t fscache_n_allocs;
52094 +extern atomic_unchecked_t fscache_n_allocs_ok;
52095 +extern atomic_unchecked_t fscache_n_allocs_wait;
52096 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52097 +extern atomic_unchecked_t fscache_n_allocs_intr;
52098 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52099 +extern atomic_unchecked_t fscache_n_alloc_ops;
52100 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52101
52102 -extern atomic_t fscache_n_retrievals;
52103 -extern atomic_t fscache_n_retrievals_ok;
52104 -extern atomic_t fscache_n_retrievals_wait;
52105 -extern atomic_t fscache_n_retrievals_nodata;
52106 -extern atomic_t fscache_n_retrievals_nobufs;
52107 -extern atomic_t fscache_n_retrievals_intr;
52108 -extern atomic_t fscache_n_retrievals_nomem;
52109 -extern atomic_t fscache_n_retrievals_object_dead;
52110 -extern atomic_t fscache_n_retrieval_ops;
52111 -extern atomic_t fscache_n_retrieval_op_waits;
52112 +extern atomic_unchecked_t fscache_n_retrievals;
52113 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52114 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52115 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52116 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52117 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52118 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52119 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52120 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52121 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52122
52123 -extern atomic_t fscache_n_stores;
52124 -extern atomic_t fscache_n_stores_ok;
52125 -extern atomic_t fscache_n_stores_again;
52126 -extern atomic_t fscache_n_stores_nobufs;
52127 -extern atomic_t fscache_n_stores_oom;
52128 -extern atomic_t fscache_n_store_ops;
52129 -extern atomic_t fscache_n_store_calls;
52130 -extern atomic_t fscache_n_store_pages;
52131 -extern atomic_t fscache_n_store_radix_deletes;
52132 -extern atomic_t fscache_n_store_pages_over_limit;
52133 +extern atomic_unchecked_t fscache_n_stores;
52134 +extern atomic_unchecked_t fscache_n_stores_ok;
52135 +extern atomic_unchecked_t fscache_n_stores_again;
52136 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52137 +extern atomic_unchecked_t fscache_n_stores_oom;
52138 +extern atomic_unchecked_t fscache_n_store_ops;
52139 +extern atomic_unchecked_t fscache_n_store_calls;
52140 +extern atomic_unchecked_t fscache_n_store_pages;
52141 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52142 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52143
52144 -extern atomic_t fscache_n_store_vmscan_not_storing;
52145 -extern atomic_t fscache_n_store_vmscan_gone;
52146 -extern atomic_t fscache_n_store_vmscan_busy;
52147 -extern atomic_t fscache_n_store_vmscan_cancelled;
52148 -extern atomic_t fscache_n_store_vmscan_wait;
52149 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52150 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52151 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52152 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52153 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52154
52155 -extern atomic_t fscache_n_marks;
52156 -extern atomic_t fscache_n_uncaches;
52157 +extern atomic_unchecked_t fscache_n_marks;
52158 +extern atomic_unchecked_t fscache_n_uncaches;
52159
52160 -extern atomic_t fscache_n_acquires;
52161 -extern atomic_t fscache_n_acquires_null;
52162 -extern atomic_t fscache_n_acquires_no_cache;
52163 -extern atomic_t fscache_n_acquires_ok;
52164 -extern atomic_t fscache_n_acquires_nobufs;
52165 -extern atomic_t fscache_n_acquires_oom;
52166 +extern atomic_unchecked_t fscache_n_acquires;
52167 +extern atomic_unchecked_t fscache_n_acquires_null;
52168 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52169 +extern atomic_unchecked_t fscache_n_acquires_ok;
52170 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52171 +extern atomic_unchecked_t fscache_n_acquires_oom;
52172
52173 -extern atomic_t fscache_n_invalidates;
52174 -extern atomic_t fscache_n_invalidates_run;
52175 +extern atomic_unchecked_t fscache_n_invalidates;
52176 +extern atomic_unchecked_t fscache_n_invalidates_run;
52177
52178 -extern atomic_t fscache_n_updates;
52179 -extern atomic_t fscache_n_updates_null;
52180 -extern atomic_t fscache_n_updates_run;
52181 +extern atomic_unchecked_t fscache_n_updates;
52182 +extern atomic_unchecked_t fscache_n_updates_null;
52183 +extern atomic_unchecked_t fscache_n_updates_run;
52184
52185 -extern atomic_t fscache_n_relinquishes;
52186 -extern atomic_t fscache_n_relinquishes_null;
52187 -extern atomic_t fscache_n_relinquishes_waitcrt;
52188 -extern atomic_t fscache_n_relinquishes_retire;
52189 +extern atomic_unchecked_t fscache_n_relinquishes;
52190 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52191 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52192 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52193
52194 -extern atomic_t fscache_n_cookie_index;
52195 -extern atomic_t fscache_n_cookie_data;
52196 -extern atomic_t fscache_n_cookie_special;
52197 +extern atomic_unchecked_t fscache_n_cookie_index;
52198 +extern atomic_unchecked_t fscache_n_cookie_data;
52199 +extern atomic_unchecked_t fscache_n_cookie_special;
52200
52201 -extern atomic_t fscache_n_object_alloc;
52202 -extern atomic_t fscache_n_object_no_alloc;
52203 -extern atomic_t fscache_n_object_lookups;
52204 -extern atomic_t fscache_n_object_lookups_negative;
52205 -extern atomic_t fscache_n_object_lookups_positive;
52206 -extern atomic_t fscache_n_object_lookups_timed_out;
52207 -extern atomic_t fscache_n_object_created;
52208 -extern atomic_t fscache_n_object_avail;
52209 -extern atomic_t fscache_n_object_dead;
52210 +extern atomic_unchecked_t fscache_n_object_alloc;
52211 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52212 +extern atomic_unchecked_t fscache_n_object_lookups;
52213 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52214 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52215 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52216 +extern atomic_unchecked_t fscache_n_object_created;
52217 +extern atomic_unchecked_t fscache_n_object_avail;
52218 +extern atomic_unchecked_t fscache_n_object_dead;
52219
52220 -extern atomic_t fscache_n_checkaux_none;
52221 -extern atomic_t fscache_n_checkaux_okay;
52222 -extern atomic_t fscache_n_checkaux_update;
52223 -extern atomic_t fscache_n_checkaux_obsolete;
52224 +extern atomic_unchecked_t fscache_n_checkaux_none;
52225 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52226 +extern atomic_unchecked_t fscache_n_checkaux_update;
52227 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52228
52229 extern atomic_t fscache_n_cop_alloc_object;
52230 extern atomic_t fscache_n_cop_lookup_object;
52231 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52232 atomic_inc(stat);
52233 }
52234
52235 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52236 +{
52237 + atomic_inc_unchecked(stat);
52238 +}
52239 +
52240 static inline void fscache_stat_d(atomic_t *stat)
52241 {
52242 atomic_dec(stat);
52243 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52244
52245 #define __fscache_stat(stat) (NULL)
52246 #define fscache_stat(stat) do {} while (0)
52247 +#define fscache_stat_unchecked(stat) do {} while (0)
52248 #define fscache_stat_d(stat) do {} while (0)
52249 #endif
52250
52251 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52252 index 50d41c1..10ee117 100644
52253 --- a/fs/fscache/object.c
52254 +++ b/fs/fscache/object.c
52255 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52256 /* Invalidate an object on disk */
52257 case FSCACHE_OBJECT_INVALIDATING:
52258 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52259 - fscache_stat(&fscache_n_invalidates_run);
52260 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52261 fscache_stat(&fscache_n_cop_invalidate_object);
52262 fscache_invalidate_object(object);
52263 fscache_stat_d(&fscache_n_cop_invalidate_object);
52264 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52265 /* update the object metadata on disk */
52266 case FSCACHE_OBJECT_UPDATING:
52267 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52268 - fscache_stat(&fscache_n_updates_run);
52269 + fscache_stat_unchecked(&fscache_n_updates_run);
52270 fscache_stat(&fscache_n_cop_update_object);
52271 object->cache->ops->update_object(object);
52272 fscache_stat_d(&fscache_n_cop_update_object);
52273 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52274 spin_lock(&object->lock);
52275 object->state = FSCACHE_OBJECT_DEAD;
52276 spin_unlock(&object->lock);
52277 - fscache_stat(&fscache_n_object_dead);
52278 + fscache_stat_unchecked(&fscache_n_object_dead);
52279 goto terminal_transit;
52280
52281 /* handle the parent cache of this object being withdrawn from
52282 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52283 spin_lock(&object->lock);
52284 object->state = FSCACHE_OBJECT_DEAD;
52285 spin_unlock(&object->lock);
52286 - fscache_stat(&fscache_n_object_dead);
52287 + fscache_stat_unchecked(&fscache_n_object_dead);
52288 goto terminal_transit;
52289
52290 /* complain about the object being woken up once it is
52291 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52292 parent->cookie->def->name, cookie->def->name,
52293 object->cache->tag->name);
52294
52295 - fscache_stat(&fscache_n_object_lookups);
52296 + fscache_stat_unchecked(&fscache_n_object_lookups);
52297 fscache_stat(&fscache_n_cop_lookup_object);
52298 ret = object->cache->ops->lookup_object(object);
52299 fscache_stat_d(&fscache_n_cop_lookup_object);
52300 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52301 if (ret == -ETIMEDOUT) {
52302 /* probably stuck behind another object, so move this one to
52303 * the back of the queue */
52304 - fscache_stat(&fscache_n_object_lookups_timed_out);
52305 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52306 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52307 }
52308
52309 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52310
52311 spin_lock(&object->lock);
52312 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52313 - fscache_stat(&fscache_n_object_lookups_negative);
52314 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52315
52316 /* transit here to allow write requests to begin stacking up
52317 * and read requests to begin returning ENODATA */
52318 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52319 * result, in which case there may be data available */
52320 spin_lock(&object->lock);
52321 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52322 - fscache_stat(&fscache_n_object_lookups_positive);
52323 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52324
52325 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52326
52327 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52328 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52329 } else {
52330 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52331 - fscache_stat(&fscache_n_object_created);
52332 + fscache_stat_unchecked(&fscache_n_object_created);
52333
52334 object->state = FSCACHE_OBJECT_AVAILABLE;
52335 spin_unlock(&object->lock);
52336 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52337 fscache_enqueue_dependents(object);
52338
52339 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52340 - fscache_stat(&fscache_n_object_avail);
52341 + fscache_stat_unchecked(&fscache_n_object_avail);
52342
52343 _leave("");
52344 }
52345 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52346 enum fscache_checkaux result;
52347
52348 if (!object->cookie->def->check_aux) {
52349 - fscache_stat(&fscache_n_checkaux_none);
52350 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52351 return FSCACHE_CHECKAUX_OKAY;
52352 }
52353
52354 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52355 switch (result) {
52356 /* entry okay as is */
52357 case FSCACHE_CHECKAUX_OKAY:
52358 - fscache_stat(&fscache_n_checkaux_okay);
52359 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52360 break;
52361
52362 /* entry requires update */
52363 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52364 - fscache_stat(&fscache_n_checkaux_update);
52365 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52366 break;
52367
52368 /* entry requires deletion */
52369 case FSCACHE_CHECKAUX_OBSOLETE:
52370 - fscache_stat(&fscache_n_checkaux_obsolete);
52371 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52372 break;
52373
52374 default:
52375 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52376 index 762a9ec..2023284 100644
52377 --- a/fs/fscache/operation.c
52378 +++ b/fs/fscache/operation.c
52379 @@ -17,7 +17,7 @@
52380 #include <linux/slab.h>
52381 #include "internal.h"
52382
52383 -atomic_t fscache_op_debug_id;
52384 +atomic_unchecked_t fscache_op_debug_id;
52385 EXPORT_SYMBOL(fscache_op_debug_id);
52386
52387 /**
52388 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52389 ASSERTCMP(atomic_read(&op->usage), >, 0);
52390 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52391
52392 - fscache_stat(&fscache_n_op_enqueue);
52393 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52394 switch (op->flags & FSCACHE_OP_TYPE) {
52395 case FSCACHE_OP_ASYNC:
52396 _debug("queue async");
52397 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52398 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52399 if (op->processor)
52400 fscache_enqueue_operation(op);
52401 - fscache_stat(&fscache_n_op_run);
52402 + fscache_stat_unchecked(&fscache_n_op_run);
52403 }
52404
52405 /*
52406 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52407 if (object->n_in_progress > 0) {
52408 atomic_inc(&op->usage);
52409 list_add_tail(&op->pend_link, &object->pending_ops);
52410 - fscache_stat(&fscache_n_op_pend);
52411 + fscache_stat_unchecked(&fscache_n_op_pend);
52412 } else if (!list_empty(&object->pending_ops)) {
52413 atomic_inc(&op->usage);
52414 list_add_tail(&op->pend_link, &object->pending_ops);
52415 - fscache_stat(&fscache_n_op_pend);
52416 + fscache_stat_unchecked(&fscache_n_op_pend);
52417 fscache_start_operations(object);
52418 } else {
52419 ASSERTCMP(object->n_in_progress, ==, 0);
52420 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52421 object->n_exclusive++; /* reads and writes must wait */
52422 atomic_inc(&op->usage);
52423 list_add_tail(&op->pend_link, &object->pending_ops);
52424 - fscache_stat(&fscache_n_op_pend);
52425 + fscache_stat_unchecked(&fscache_n_op_pend);
52426 ret = 0;
52427 } else {
52428 /* If we're in any other state, there must have been an I/O
52429 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52430 if (object->n_exclusive > 0) {
52431 atomic_inc(&op->usage);
52432 list_add_tail(&op->pend_link, &object->pending_ops);
52433 - fscache_stat(&fscache_n_op_pend);
52434 + fscache_stat_unchecked(&fscache_n_op_pend);
52435 } else if (!list_empty(&object->pending_ops)) {
52436 atomic_inc(&op->usage);
52437 list_add_tail(&op->pend_link, &object->pending_ops);
52438 - fscache_stat(&fscache_n_op_pend);
52439 + fscache_stat_unchecked(&fscache_n_op_pend);
52440 fscache_start_operations(object);
52441 } else {
52442 ASSERTCMP(object->n_exclusive, ==, 0);
52443 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52444 object->n_ops++;
52445 atomic_inc(&op->usage);
52446 list_add_tail(&op->pend_link, &object->pending_ops);
52447 - fscache_stat(&fscache_n_op_pend);
52448 + fscache_stat_unchecked(&fscache_n_op_pend);
52449 ret = 0;
52450 } else if (object->state == FSCACHE_OBJECT_DYING ||
52451 object->state == FSCACHE_OBJECT_LC_DYING ||
52452 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52453 - fscache_stat(&fscache_n_op_rejected);
52454 + fscache_stat_unchecked(&fscache_n_op_rejected);
52455 op->state = FSCACHE_OP_ST_CANCELLED;
52456 ret = -ENOBUFS;
52457 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52458 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52459 ret = -EBUSY;
52460 if (op->state == FSCACHE_OP_ST_PENDING) {
52461 ASSERT(!list_empty(&op->pend_link));
52462 - fscache_stat(&fscache_n_op_cancelled);
52463 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52464 list_del_init(&op->pend_link);
52465 if (do_cancel)
52466 do_cancel(op);
52467 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52468 while (!list_empty(&object->pending_ops)) {
52469 op = list_entry(object->pending_ops.next,
52470 struct fscache_operation, pend_link);
52471 - fscache_stat(&fscache_n_op_cancelled);
52472 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52473 list_del_init(&op->pend_link);
52474
52475 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52476 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52477 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52478 op->state = FSCACHE_OP_ST_DEAD;
52479
52480 - fscache_stat(&fscache_n_op_release);
52481 + fscache_stat_unchecked(&fscache_n_op_release);
52482
52483 if (op->release) {
52484 op->release(op);
52485 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52486 * lock, and defer it otherwise */
52487 if (!spin_trylock(&object->lock)) {
52488 _debug("defer put");
52489 - fscache_stat(&fscache_n_op_deferred_release);
52490 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52491
52492 cache = object->cache;
52493 spin_lock(&cache->op_gc_list_lock);
52494 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52495
52496 _debug("GC DEFERRED REL OBJ%x OP%x",
52497 object->debug_id, op->debug_id);
52498 - fscache_stat(&fscache_n_op_gc);
52499 + fscache_stat_unchecked(&fscache_n_op_gc);
52500
52501 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52502 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52503 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52504 index ff000e5..c44ec6d 100644
52505 --- a/fs/fscache/page.c
52506 +++ b/fs/fscache/page.c
52507 @@ -61,7 +61,7 @@ try_again:
52508 val = radix_tree_lookup(&cookie->stores, page->index);
52509 if (!val) {
52510 rcu_read_unlock();
52511 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52512 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52513 __fscache_uncache_page(cookie, page);
52514 return true;
52515 }
52516 @@ -91,11 +91,11 @@ try_again:
52517 spin_unlock(&cookie->stores_lock);
52518
52519 if (xpage) {
52520 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52521 - fscache_stat(&fscache_n_store_radix_deletes);
52522 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52523 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52524 ASSERTCMP(xpage, ==, page);
52525 } else {
52526 - fscache_stat(&fscache_n_store_vmscan_gone);
52527 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52528 }
52529
52530 wake_up_bit(&cookie->flags, 0);
52531 @@ -110,11 +110,11 @@ page_busy:
52532 * sleeping on memory allocation, so we may need to impose a timeout
52533 * too. */
52534 if (!(gfp & __GFP_WAIT)) {
52535 - fscache_stat(&fscache_n_store_vmscan_busy);
52536 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52537 return false;
52538 }
52539
52540 - fscache_stat(&fscache_n_store_vmscan_wait);
52541 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52542 __fscache_wait_on_page_write(cookie, page);
52543 gfp &= ~__GFP_WAIT;
52544 goto try_again;
52545 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52546 FSCACHE_COOKIE_STORING_TAG);
52547 if (!radix_tree_tag_get(&cookie->stores, page->index,
52548 FSCACHE_COOKIE_PENDING_TAG)) {
52549 - fscache_stat(&fscache_n_store_radix_deletes);
52550 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52551 xpage = radix_tree_delete(&cookie->stores, page->index);
52552 }
52553 spin_unlock(&cookie->stores_lock);
52554 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52555
52556 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52557
52558 - fscache_stat(&fscache_n_attr_changed_calls);
52559 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52560
52561 if (fscache_object_is_active(object)) {
52562 fscache_stat(&fscache_n_cop_attr_changed);
52563 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52564
52565 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52566
52567 - fscache_stat(&fscache_n_attr_changed);
52568 + fscache_stat_unchecked(&fscache_n_attr_changed);
52569
52570 op = kzalloc(sizeof(*op), GFP_KERNEL);
52571 if (!op) {
52572 - fscache_stat(&fscache_n_attr_changed_nomem);
52573 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52574 _leave(" = -ENOMEM");
52575 return -ENOMEM;
52576 }
52577 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52578 if (fscache_submit_exclusive_op(object, op) < 0)
52579 goto nobufs;
52580 spin_unlock(&cookie->lock);
52581 - fscache_stat(&fscache_n_attr_changed_ok);
52582 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52583 fscache_put_operation(op);
52584 _leave(" = 0");
52585 return 0;
52586 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52587 nobufs:
52588 spin_unlock(&cookie->lock);
52589 kfree(op);
52590 - fscache_stat(&fscache_n_attr_changed_nobufs);
52591 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52592 _leave(" = %d", -ENOBUFS);
52593 return -ENOBUFS;
52594 }
52595 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52596 /* allocate a retrieval operation and attempt to submit it */
52597 op = kzalloc(sizeof(*op), GFP_NOIO);
52598 if (!op) {
52599 - fscache_stat(&fscache_n_retrievals_nomem);
52600 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52601 return NULL;
52602 }
52603
52604 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52605 return 0;
52606 }
52607
52608 - fscache_stat(&fscache_n_retrievals_wait);
52609 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52610
52611 jif = jiffies;
52612 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52613 fscache_wait_bit_interruptible,
52614 TASK_INTERRUPTIBLE) != 0) {
52615 - fscache_stat(&fscache_n_retrievals_intr);
52616 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52617 _leave(" = -ERESTARTSYS");
52618 return -ERESTARTSYS;
52619 }
52620 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52621 */
52622 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52623 struct fscache_retrieval *op,
52624 - atomic_t *stat_op_waits,
52625 - atomic_t *stat_object_dead)
52626 + atomic_unchecked_t *stat_op_waits,
52627 + atomic_unchecked_t *stat_object_dead)
52628 {
52629 int ret;
52630
52631 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52632 goto check_if_dead;
52633
52634 _debug(">>> WT");
52635 - fscache_stat(stat_op_waits);
52636 + fscache_stat_unchecked(stat_op_waits);
52637 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52638 fscache_wait_bit_interruptible,
52639 TASK_INTERRUPTIBLE) != 0) {
52640 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52641
52642 check_if_dead:
52643 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52644 - fscache_stat(stat_object_dead);
52645 + fscache_stat_unchecked(stat_object_dead);
52646 _leave(" = -ENOBUFS [cancelled]");
52647 return -ENOBUFS;
52648 }
52649 if (unlikely(fscache_object_is_dead(object))) {
52650 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52651 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52652 - fscache_stat(stat_object_dead);
52653 + fscache_stat_unchecked(stat_object_dead);
52654 return -ENOBUFS;
52655 }
52656 return 0;
52657 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52658
52659 _enter("%p,%p,,,", cookie, page);
52660
52661 - fscache_stat(&fscache_n_retrievals);
52662 + fscache_stat_unchecked(&fscache_n_retrievals);
52663
52664 if (hlist_empty(&cookie->backing_objects))
52665 goto nobufs;
52666 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52667 goto nobufs_unlock_dec;
52668 spin_unlock(&cookie->lock);
52669
52670 - fscache_stat(&fscache_n_retrieval_ops);
52671 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52672
52673 /* pin the netfs read context in case we need to do the actual netfs
52674 * read because we've encountered a cache read failure */
52675 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52676
52677 error:
52678 if (ret == -ENOMEM)
52679 - fscache_stat(&fscache_n_retrievals_nomem);
52680 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52681 else if (ret == -ERESTARTSYS)
52682 - fscache_stat(&fscache_n_retrievals_intr);
52683 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52684 else if (ret == -ENODATA)
52685 - fscache_stat(&fscache_n_retrievals_nodata);
52686 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52687 else if (ret < 0)
52688 - fscache_stat(&fscache_n_retrievals_nobufs);
52689 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52690 else
52691 - fscache_stat(&fscache_n_retrievals_ok);
52692 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52693
52694 fscache_put_retrieval(op);
52695 _leave(" = %d", ret);
52696 @@ -467,7 +467,7 @@ nobufs_unlock:
52697 spin_unlock(&cookie->lock);
52698 kfree(op);
52699 nobufs:
52700 - fscache_stat(&fscache_n_retrievals_nobufs);
52701 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52702 _leave(" = -ENOBUFS");
52703 return -ENOBUFS;
52704 }
52705 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52706
52707 _enter("%p,,%d,,,", cookie, *nr_pages);
52708
52709 - fscache_stat(&fscache_n_retrievals);
52710 + fscache_stat_unchecked(&fscache_n_retrievals);
52711
52712 if (hlist_empty(&cookie->backing_objects))
52713 goto nobufs;
52714 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52715 goto nobufs_unlock_dec;
52716 spin_unlock(&cookie->lock);
52717
52718 - fscache_stat(&fscache_n_retrieval_ops);
52719 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52720
52721 /* pin the netfs read context in case we need to do the actual netfs
52722 * read because we've encountered a cache read failure */
52723 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52724
52725 error:
52726 if (ret == -ENOMEM)
52727 - fscache_stat(&fscache_n_retrievals_nomem);
52728 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52729 else if (ret == -ERESTARTSYS)
52730 - fscache_stat(&fscache_n_retrievals_intr);
52731 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52732 else if (ret == -ENODATA)
52733 - fscache_stat(&fscache_n_retrievals_nodata);
52734 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52735 else if (ret < 0)
52736 - fscache_stat(&fscache_n_retrievals_nobufs);
52737 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52738 else
52739 - fscache_stat(&fscache_n_retrievals_ok);
52740 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52741
52742 fscache_put_retrieval(op);
52743 _leave(" = %d", ret);
52744 @@ -591,7 +591,7 @@ nobufs_unlock:
52745 spin_unlock(&cookie->lock);
52746 kfree(op);
52747 nobufs:
52748 - fscache_stat(&fscache_n_retrievals_nobufs);
52749 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52750 _leave(" = -ENOBUFS");
52751 return -ENOBUFS;
52752 }
52753 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52754
52755 _enter("%p,%p,,,", cookie, page);
52756
52757 - fscache_stat(&fscache_n_allocs);
52758 + fscache_stat_unchecked(&fscache_n_allocs);
52759
52760 if (hlist_empty(&cookie->backing_objects))
52761 goto nobufs;
52762 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52763 goto nobufs_unlock;
52764 spin_unlock(&cookie->lock);
52765
52766 - fscache_stat(&fscache_n_alloc_ops);
52767 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52768
52769 ret = fscache_wait_for_retrieval_activation(
52770 object, op,
52771 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52772
52773 error:
52774 if (ret == -ERESTARTSYS)
52775 - fscache_stat(&fscache_n_allocs_intr);
52776 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52777 else if (ret < 0)
52778 - fscache_stat(&fscache_n_allocs_nobufs);
52779 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52780 else
52781 - fscache_stat(&fscache_n_allocs_ok);
52782 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52783
52784 fscache_put_retrieval(op);
52785 _leave(" = %d", ret);
52786 @@ -677,7 +677,7 @@ nobufs_unlock:
52787 spin_unlock(&cookie->lock);
52788 kfree(op);
52789 nobufs:
52790 - fscache_stat(&fscache_n_allocs_nobufs);
52791 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52792 _leave(" = -ENOBUFS");
52793 return -ENOBUFS;
52794 }
52795 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52796
52797 spin_lock(&cookie->stores_lock);
52798
52799 - fscache_stat(&fscache_n_store_calls);
52800 + fscache_stat_unchecked(&fscache_n_store_calls);
52801
52802 /* find a page to store */
52803 page = NULL;
52804 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52805 page = results[0];
52806 _debug("gang %d [%lx]", n, page->index);
52807 if (page->index > op->store_limit) {
52808 - fscache_stat(&fscache_n_store_pages_over_limit);
52809 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52810 goto superseded;
52811 }
52812
52813 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52814 spin_unlock(&cookie->stores_lock);
52815 spin_unlock(&object->lock);
52816
52817 - fscache_stat(&fscache_n_store_pages);
52818 + fscache_stat_unchecked(&fscache_n_store_pages);
52819 fscache_stat(&fscache_n_cop_write_page);
52820 ret = object->cache->ops->write_page(op, page);
52821 fscache_stat_d(&fscache_n_cop_write_page);
52822 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52823 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52824 ASSERT(PageFsCache(page));
52825
52826 - fscache_stat(&fscache_n_stores);
52827 + fscache_stat_unchecked(&fscache_n_stores);
52828
52829 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52830 _leave(" = -ENOBUFS [invalidating]");
52831 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52832 spin_unlock(&cookie->stores_lock);
52833 spin_unlock(&object->lock);
52834
52835 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52836 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52837 op->store_limit = object->store_limit;
52838
52839 if (fscache_submit_op(object, &op->op) < 0)
52840 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52841
52842 spin_unlock(&cookie->lock);
52843 radix_tree_preload_end();
52844 - fscache_stat(&fscache_n_store_ops);
52845 - fscache_stat(&fscache_n_stores_ok);
52846 + fscache_stat_unchecked(&fscache_n_store_ops);
52847 + fscache_stat_unchecked(&fscache_n_stores_ok);
52848
52849 /* the work queue now carries its own ref on the object */
52850 fscache_put_operation(&op->op);
52851 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52852 return 0;
52853
52854 already_queued:
52855 - fscache_stat(&fscache_n_stores_again);
52856 + fscache_stat_unchecked(&fscache_n_stores_again);
52857 already_pending:
52858 spin_unlock(&cookie->stores_lock);
52859 spin_unlock(&object->lock);
52860 spin_unlock(&cookie->lock);
52861 radix_tree_preload_end();
52862 kfree(op);
52863 - fscache_stat(&fscache_n_stores_ok);
52864 + fscache_stat_unchecked(&fscache_n_stores_ok);
52865 _leave(" = 0");
52866 return 0;
52867
52868 @@ -959,14 +959,14 @@ nobufs:
52869 spin_unlock(&cookie->lock);
52870 radix_tree_preload_end();
52871 kfree(op);
52872 - fscache_stat(&fscache_n_stores_nobufs);
52873 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52874 _leave(" = -ENOBUFS");
52875 return -ENOBUFS;
52876
52877 nomem_free:
52878 kfree(op);
52879 nomem:
52880 - fscache_stat(&fscache_n_stores_oom);
52881 + fscache_stat_unchecked(&fscache_n_stores_oom);
52882 _leave(" = -ENOMEM");
52883 return -ENOMEM;
52884 }
52885 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52886 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52887 ASSERTCMP(page, !=, NULL);
52888
52889 - fscache_stat(&fscache_n_uncaches);
52890 + fscache_stat_unchecked(&fscache_n_uncaches);
52891
52892 /* cache withdrawal may beat us to it */
52893 if (!PageFsCache(page))
52894 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52895 struct fscache_cookie *cookie = op->op.object->cookie;
52896
52897 #ifdef CONFIG_FSCACHE_STATS
52898 - atomic_inc(&fscache_n_marks);
52899 + atomic_inc_unchecked(&fscache_n_marks);
52900 #endif
52901
52902 _debug("- mark %p{%lx}", page, page->index);
52903 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52904 index 40d13c7..ddf52b9 100644
52905 --- a/fs/fscache/stats.c
52906 +++ b/fs/fscache/stats.c
52907 @@ -18,99 +18,99 @@
52908 /*
52909 * operation counters
52910 */
52911 -atomic_t fscache_n_op_pend;
52912 -atomic_t fscache_n_op_run;
52913 -atomic_t fscache_n_op_enqueue;
52914 -atomic_t fscache_n_op_requeue;
52915 -atomic_t fscache_n_op_deferred_release;
52916 -atomic_t fscache_n_op_release;
52917 -atomic_t fscache_n_op_gc;
52918 -atomic_t fscache_n_op_cancelled;
52919 -atomic_t fscache_n_op_rejected;
52920 +atomic_unchecked_t fscache_n_op_pend;
52921 +atomic_unchecked_t fscache_n_op_run;
52922 +atomic_unchecked_t fscache_n_op_enqueue;
52923 +atomic_unchecked_t fscache_n_op_requeue;
52924 +atomic_unchecked_t fscache_n_op_deferred_release;
52925 +atomic_unchecked_t fscache_n_op_release;
52926 +atomic_unchecked_t fscache_n_op_gc;
52927 +atomic_unchecked_t fscache_n_op_cancelled;
52928 +atomic_unchecked_t fscache_n_op_rejected;
52929
52930 -atomic_t fscache_n_attr_changed;
52931 -atomic_t fscache_n_attr_changed_ok;
52932 -atomic_t fscache_n_attr_changed_nobufs;
52933 -atomic_t fscache_n_attr_changed_nomem;
52934 -atomic_t fscache_n_attr_changed_calls;
52935 +atomic_unchecked_t fscache_n_attr_changed;
52936 +atomic_unchecked_t fscache_n_attr_changed_ok;
52937 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52938 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52939 +atomic_unchecked_t fscache_n_attr_changed_calls;
52940
52941 -atomic_t fscache_n_allocs;
52942 -atomic_t fscache_n_allocs_ok;
52943 -atomic_t fscache_n_allocs_wait;
52944 -atomic_t fscache_n_allocs_nobufs;
52945 -atomic_t fscache_n_allocs_intr;
52946 -atomic_t fscache_n_allocs_object_dead;
52947 -atomic_t fscache_n_alloc_ops;
52948 -atomic_t fscache_n_alloc_op_waits;
52949 +atomic_unchecked_t fscache_n_allocs;
52950 +atomic_unchecked_t fscache_n_allocs_ok;
52951 +atomic_unchecked_t fscache_n_allocs_wait;
52952 +atomic_unchecked_t fscache_n_allocs_nobufs;
52953 +atomic_unchecked_t fscache_n_allocs_intr;
52954 +atomic_unchecked_t fscache_n_allocs_object_dead;
52955 +atomic_unchecked_t fscache_n_alloc_ops;
52956 +atomic_unchecked_t fscache_n_alloc_op_waits;
52957
52958 -atomic_t fscache_n_retrievals;
52959 -atomic_t fscache_n_retrievals_ok;
52960 -atomic_t fscache_n_retrievals_wait;
52961 -atomic_t fscache_n_retrievals_nodata;
52962 -atomic_t fscache_n_retrievals_nobufs;
52963 -atomic_t fscache_n_retrievals_intr;
52964 -atomic_t fscache_n_retrievals_nomem;
52965 -atomic_t fscache_n_retrievals_object_dead;
52966 -atomic_t fscache_n_retrieval_ops;
52967 -atomic_t fscache_n_retrieval_op_waits;
52968 +atomic_unchecked_t fscache_n_retrievals;
52969 +atomic_unchecked_t fscache_n_retrievals_ok;
52970 +atomic_unchecked_t fscache_n_retrievals_wait;
52971 +atomic_unchecked_t fscache_n_retrievals_nodata;
52972 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52973 +atomic_unchecked_t fscache_n_retrievals_intr;
52974 +atomic_unchecked_t fscache_n_retrievals_nomem;
52975 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52976 +atomic_unchecked_t fscache_n_retrieval_ops;
52977 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52978
52979 -atomic_t fscache_n_stores;
52980 -atomic_t fscache_n_stores_ok;
52981 -atomic_t fscache_n_stores_again;
52982 -atomic_t fscache_n_stores_nobufs;
52983 -atomic_t fscache_n_stores_oom;
52984 -atomic_t fscache_n_store_ops;
52985 -atomic_t fscache_n_store_calls;
52986 -atomic_t fscache_n_store_pages;
52987 -atomic_t fscache_n_store_radix_deletes;
52988 -atomic_t fscache_n_store_pages_over_limit;
52989 +atomic_unchecked_t fscache_n_stores;
52990 +atomic_unchecked_t fscache_n_stores_ok;
52991 +atomic_unchecked_t fscache_n_stores_again;
52992 +atomic_unchecked_t fscache_n_stores_nobufs;
52993 +atomic_unchecked_t fscache_n_stores_oom;
52994 +atomic_unchecked_t fscache_n_store_ops;
52995 +atomic_unchecked_t fscache_n_store_calls;
52996 +atomic_unchecked_t fscache_n_store_pages;
52997 +atomic_unchecked_t fscache_n_store_radix_deletes;
52998 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52999
53000 -atomic_t fscache_n_store_vmscan_not_storing;
53001 -atomic_t fscache_n_store_vmscan_gone;
53002 -atomic_t fscache_n_store_vmscan_busy;
53003 -atomic_t fscache_n_store_vmscan_cancelled;
53004 -atomic_t fscache_n_store_vmscan_wait;
53005 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53006 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53007 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53008 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53009 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53010
53011 -atomic_t fscache_n_marks;
53012 -atomic_t fscache_n_uncaches;
53013 +atomic_unchecked_t fscache_n_marks;
53014 +atomic_unchecked_t fscache_n_uncaches;
53015
53016 -atomic_t fscache_n_acquires;
53017 -atomic_t fscache_n_acquires_null;
53018 -atomic_t fscache_n_acquires_no_cache;
53019 -atomic_t fscache_n_acquires_ok;
53020 -atomic_t fscache_n_acquires_nobufs;
53021 -atomic_t fscache_n_acquires_oom;
53022 +atomic_unchecked_t fscache_n_acquires;
53023 +atomic_unchecked_t fscache_n_acquires_null;
53024 +atomic_unchecked_t fscache_n_acquires_no_cache;
53025 +atomic_unchecked_t fscache_n_acquires_ok;
53026 +atomic_unchecked_t fscache_n_acquires_nobufs;
53027 +atomic_unchecked_t fscache_n_acquires_oom;
53028
53029 -atomic_t fscache_n_invalidates;
53030 -atomic_t fscache_n_invalidates_run;
53031 +atomic_unchecked_t fscache_n_invalidates;
53032 +atomic_unchecked_t fscache_n_invalidates_run;
53033
53034 -atomic_t fscache_n_updates;
53035 -atomic_t fscache_n_updates_null;
53036 -atomic_t fscache_n_updates_run;
53037 +atomic_unchecked_t fscache_n_updates;
53038 +atomic_unchecked_t fscache_n_updates_null;
53039 +atomic_unchecked_t fscache_n_updates_run;
53040
53041 -atomic_t fscache_n_relinquishes;
53042 -atomic_t fscache_n_relinquishes_null;
53043 -atomic_t fscache_n_relinquishes_waitcrt;
53044 -atomic_t fscache_n_relinquishes_retire;
53045 +atomic_unchecked_t fscache_n_relinquishes;
53046 +atomic_unchecked_t fscache_n_relinquishes_null;
53047 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53048 +atomic_unchecked_t fscache_n_relinquishes_retire;
53049
53050 -atomic_t fscache_n_cookie_index;
53051 -atomic_t fscache_n_cookie_data;
53052 -atomic_t fscache_n_cookie_special;
53053 +atomic_unchecked_t fscache_n_cookie_index;
53054 +atomic_unchecked_t fscache_n_cookie_data;
53055 +atomic_unchecked_t fscache_n_cookie_special;
53056
53057 -atomic_t fscache_n_object_alloc;
53058 -atomic_t fscache_n_object_no_alloc;
53059 -atomic_t fscache_n_object_lookups;
53060 -atomic_t fscache_n_object_lookups_negative;
53061 -atomic_t fscache_n_object_lookups_positive;
53062 -atomic_t fscache_n_object_lookups_timed_out;
53063 -atomic_t fscache_n_object_created;
53064 -atomic_t fscache_n_object_avail;
53065 -atomic_t fscache_n_object_dead;
53066 +atomic_unchecked_t fscache_n_object_alloc;
53067 +atomic_unchecked_t fscache_n_object_no_alloc;
53068 +atomic_unchecked_t fscache_n_object_lookups;
53069 +atomic_unchecked_t fscache_n_object_lookups_negative;
53070 +atomic_unchecked_t fscache_n_object_lookups_positive;
53071 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53072 +atomic_unchecked_t fscache_n_object_created;
53073 +atomic_unchecked_t fscache_n_object_avail;
53074 +atomic_unchecked_t fscache_n_object_dead;
53075
53076 -atomic_t fscache_n_checkaux_none;
53077 -atomic_t fscache_n_checkaux_okay;
53078 -atomic_t fscache_n_checkaux_update;
53079 -atomic_t fscache_n_checkaux_obsolete;
53080 +atomic_unchecked_t fscache_n_checkaux_none;
53081 +atomic_unchecked_t fscache_n_checkaux_okay;
53082 +atomic_unchecked_t fscache_n_checkaux_update;
53083 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53084
53085 atomic_t fscache_n_cop_alloc_object;
53086 atomic_t fscache_n_cop_lookup_object;
53087 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53088 seq_puts(m, "FS-Cache statistics\n");
53089
53090 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53091 - atomic_read(&fscache_n_cookie_index),
53092 - atomic_read(&fscache_n_cookie_data),
53093 - atomic_read(&fscache_n_cookie_special));
53094 + atomic_read_unchecked(&fscache_n_cookie_index),
53095 + atomic_read_unchecked(&fscache_n_cookie_data),
53096 + atomic_read_unchecked(&fscache_n_cookie_special));
53097
53098 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53099 - atomic_read(&fscache_n_object_alloc),
53100 - atomic_read(&fscache_n_object_no_alloc),
53101 - atomic_read(&fscache_n_object_avail),
53102 - atomic_read(&fscache_n_object_dead));
53103 + atomic_read_unchecked(&fscache_n_object_alloc),
53104 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53105 + atomic_read_unchecked(&fscache_n_object_avail),
53106 + atomic_read_unchecked(&fscache_n_object_dead));
53107 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53108 - atomic_read(&fscache_n_checkaux_none),
53109 - atomic_read(&fscache_n_checkaux_okay),
53110 - atomic_read(&fscache_n_checkaux_update),
53111 - atomic_read(&fscache_n_checkaux_obsolete));
53112 + atomic_read_unchecked(&fscache_n_checkaux_none),
53113 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53114 + atomic_read_unchecked(&fscache_n_checkaux_update),
53115 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53116
53117 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53118 - atomic_read(&fscache_n_marks),
53119 - atomic_read(&fscache_n_uncaches));
53120 + atomic_read_unchecked(&fscache_n_marks),
53121 + atomic_read_unchecked(&fscache_n_uncaches));
53122
53123 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53124 " oom=%u\n",
53125 - atomic_read(&fscache_n_acquires),
53126 - atomic_read(&fscache_n_acquires_null),
53127 - atomic_read(&fscache_n_acquires_no_cache),
53128 - atomic_read(&fscache_n_acquires_ok),
53129 - atomic_read(&fscache_n_acquires_nobufs),
53130 - atomic_read(&fscache_n_acquires_oom));
53131 + atomic_read_unchecked(&fscache_n_acquires),
53132 + atomic_read_unchecked(&fscache_n_acquires_null),
53133 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53134 + atomic_read_unchecked(&fscache_n_acquires_ok),
53135 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53136 + atomic_read_unchecked(&fscache_n_acquires_oom));
53137
53138 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53139 - atomic_read(&fscache_n_object_lookups),
53140 - atomic_read(&fscache_n_object_lookups_negative),
53141 - atomic_read(&fscache_n_object_lookups_positive),
53142 - atomic_read(&fscache_n_object_created),
53143 - atomic_read(&fscache_n_object_lookups_timed_out));
53144 + atomic_read_unchecked(&fscache_n_object_lookups),
53145 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53146 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53147 + atomic_read_unchecked(&fscache_n_object_created),
53148 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53149
53150 seq_printf(m, "Invals : n=%u run=%u\n",
53151 - atomic_read(&fscache_n_invalidates),
53152 - atomic_read(&fscache_n_invalidates_run));
53153 + atomic_read_unchecked(&fscache_n_invalidates),
53154 + atomic_read_unchecked(&fscache_n_invalidates_run));
53155
53156 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53157 - atomic_read(&fscache_n_updates),
53158 - atomic_read(&fscache_n_updates_null),
53159 - atomic_read(&fscache_n_updates_run));
53160 + atomic_read_unchecked(&fscache_n_updates),
53161 + atomic_read_unchecked(&fscache_n_updates_null),
53162 + atomic_read_unchecked(&fscache_n_updates_run));
53163
53164 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53165 - atomic_read(&fscache_n_relinquishes),
53166 - atomic_read(&fscache_n_relinquishes_null),
53167 - atomic_read(&fscache_n_relinquishes_waitcrt),
53168 - atomic_read(&fscache_n_relinquishes_retire));
53169 + atomic_read_unchecked(&fscache_n_relinquishes),
53170 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53171 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53172 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53173
53174 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53175 - atomic_read(&fscache_n_attr_changed),
53176 - atomic_read(&fscache_n_attr_changed_ok),
53177 - atomic_read(&fscache_n_attr_changed_nobufs),
53178 - atomic_read(&fscache_n_attr_changed_nomem),
53179 - atomic_read(&fscache_n_attr_changed_calls));
53180 + atomic_read_unchecked(&fscache_n_attr_changed),
53181 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53182 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53183 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53184 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53185
53186 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53187 - atomic_read(&fscache_n_allocs),
53188 - atomic_read(&fscache_n_allocs_ok),
53189 - atomic_read(&fscache_n_allocs_wait),
53190 - atomic_read(&fscache_n_allocs_nobufs),
53191 - atomic_read(&fscache_n_allocs_intr));
53192 + atomic_read_unchecked(&fscache_n_allocs),
53193 + atomic_read_unchecked(&fscache_n_allocs_ok),
53194 + atomic_read_unchecked(&fscache_n_allocs_wait),
53195 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53196 + atomic_read_unchecked(&fscache_n_allocs_intr));
53197 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53198 - atomic_read(&fscache_n_alloc_ops),
53199 - atomic_read(&fscache_n_alloc_op_waits),
53200 - atomic_read(&fscache_n_allocs_object_dead));
53201 + atomic_read_unchecked(&fscache_n_alloc_ops),
53202 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53203 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53204
53205 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53206 " int=%u oom=%u\n",
53207 - atomic_read(&fscache_n_retrievals),
53208 - atomic_read(&fscache_n_retrievals_ok),
53209 - atomic_read(&fscache_n_retrievals_wait),
53210 - atomic_read(&fscache_n_retrievals_nodata),
53211 - atomic_read(&fscache_n_retrievals_nobufs),
53212 - atomic_read(&fscache_n_retrievals_intr),
53213 - atomic_read(&fscache_n_retrievals_nomem));
53214 + atomic_read_unchecked(&fscache_n_retrievals),
53215 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53216 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53217 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53218 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53219 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53220 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53221 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53222 - atomic_read(&fscache_n_retrieval_ops),
53223 - atomic_read(&fscache_n_retrieval_op_waits),
53224 - atomic_read(&fscache_n_retrievals_object_dead));
53225 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53226 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53227 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53228
53229 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53230 - atomic_read(&fscache_n_stores),
53231 - atomic_read(&fscache_n_stores_ok),
53232 - atomic_read(&fscache_n_stores_again),
53233 - atomic_read(&fscache_n_stores_nobufs),
53234 - atomic_read(&fscache_n_stores_oom));
53235 + atomic_read_unchecked(&fscache_n_stores),
53236 + atomic_read_unchecked(&fscache_n_stores_ok),
53237 + atomic_read_unchecked(&fscache_n_stores_again),
53238 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53239 + atomic_read_unchecked(&fscache_n_stores_oom));
53240 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53241 - atomic_read(&fscache_n_store_ops),
53242 - atomic_read(&fscache_n_store_calls),
53243 - atomic_read(&fscache_n_store_pages),
53244 - atomic_read(&fscache_n_store_radix_deletes),
53245 - atomic_read(&fscache_n_store_pages_over_limit));
53246 + atomic_read_unchecked(&fscache_n_store_ops),
53247 + atomic_read_unchecked(&fscache_n_store_calls),
53248 + atomic_read_unchecked(&fscache_n_store_pages),
53249 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53250 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53251
53252 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53253 - atomic_read(&fscache_n_store_vmscan_not_storing),
53254 - atomic_read(&fscache_n_store_vmscan_gone),
53255 - atomic_read(&fscache_n_store_vmscan_busy),
53256 - atomic_read(&fscache_n_store_vmscan_cancelled),
53257 - atomic_read(&fscache_n_store_vmscan_wait));
53258 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53259 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53260 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53261 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53262 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53263
53264 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53265 - atomic_read(&fscache_n_op_pend),
53266 - atomic_read(&fscache_n_op_run),
53267 - atomic_read(&fscache_n_op_enqueue),
53268 - atomic_read(&fscache_n_op_cancelled),
53269 - atomic_read(&fscache_n_op_rejected));
53270 + atomic_read_unchecked(&fscache_n_op_pend),
53271 + atomic_read_unchecked(&fscache_n_op_run),
53272 + atomic_read_unchecked(&fscache_n_op_enqueue),
53273 + atomic_read_unchecked(&fscache_n_op_cancelled),
53274 + atomic_read_unchecked(&fscache_n_op_rejected));
53275 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53276 - atomic_read(&fscache_n_op_deferred_release),
53277 - atomic_read(&fscache_n_op_release),
53278 - atomic_read(&fscache_n_op_gc));
53279 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53280 + atomic_read_unchecked(&fscache_n_op_release),
53281 + atomic_read_unchecked(&fscache_n_op_gc));
53282
53283 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53284 atomic_read(&fscache_n_cop_alloc_object),
53285 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53286 index aef34b1..59bfd7b 100644
53287 --- a/fs/fuse/cuse.c
53288 +++ b/fs/fuse/cuse.c
53289 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
53290 INIT_LIST_HEAD(&cuse_conntbl[i]);
53291
53292 /* inherit and extend fuse_dev_operations */
53293 - cuse_channel_fops = fuse_dev_operations;
53294 - cuse_channel_fops.owner = THIS_MODULE;
53295 - cuse_channel_fops.open = cuse_channel_open;
53296 - cuse_channel_fops.release = cuse_channel_release;
53297 + pax_open_kernel();
53298 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53299 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53300 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53301 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53302 + pax_close_kernel();
53303
53304 cuse_class = class_create(THIS_MODULE, "cuse");
53305 if (IS_ERR(cuse_class))
53306 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53307 index 1d55f94..088da65 100644
53308 --- a/fs/fuse/dev.c
53309 +++ b/fs/fuse/dev.c
53310 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53311 ret = 0;
53312 pipe_lock(pipe);
53313
53314 - if (!pipe->readers) {
53315 + if (!atomic_read(&pipe->readers)) {
53316 send_sig(SIGPIPE, current, 0);
53317 if (!ret)
53318 ret = -EPIPE;
53319 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53320 page_nr++;
53321 ret += buf->len;
53322
53323 - if (pipe->files)
53324 + if (atomic_read(&pipe->files))
53325 do_wakeup = 1;
53326 }
53327
53328 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53329 index f3f783d..bf11a8e 100644
53330 --- a/fs/fuse/dir.c
53331 +++ b/fs/fuse/dir.c
53332 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
53333 return link;
53334 }
53335
53336 -static void free_link(char *link)
53337 +static void free_link(const char *link)
53338 {
53339 if (!IS_ERR(link))
53340 free_page((unsigned long) link);
53341 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53342 index 62b484e..0f9a140 100644
53343 --- a/fs/gfs2/inode.c
53344 +++ b/fs/gfs2/inode.c
53345 @@ -1441,7 +1441,7 @@ out:
53346
53347 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53348 {
53349 - char *s = nd_get_link(nd);
53350 + const char *s = nd_get_link(nd);
53351 if (!IS_ERR(s))
53352 kfree(s);
53353 }
53354 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53355 index a3f868a..bb308ae 100644
53356 --- a/fs/hugetlbfs/inode.c
53357 +++ b/fs/hugetlbfs/inode.c
53358 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53359 struct mm_struct *mm = current->mm;
53360 struct vm_area_struct *vma;
53361 struct hstate *h = hstate_file(file);
53362 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53363 struct vm_unmapped_area_info info;
53364
53365 if (len & ~huge_page_mask(h))
53366 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53367 return addr;
53368 }
53369
53370 +#ifdef CONFIG_PAX_RANDMMAP
53371 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53372 +#endif
53373 +
53374 if (addr) {
53375 addr = ALIGN(addr, huge_page_size(h));
53376 vma = find_vma(mm, addr);
53377 - if (TASK_SIZE - len >= addr &&
53378 - (!vma || addr + len <= vma->vm_start))
53379 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53380 return addr;
53381 }
53382
53383 info.flags = 0;
53384 info.length = len;
53385 info.low_limit = TASK_UNMAPPED_BASE;
53386 +
53387 +#ifdef CONFIG_PAX_RANDMMAP
53388 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53389 + info.low_limit += mm->delta_mmap;
53390 +#endif
53391 +
53392 info.high_limit = TASK_SIZE;
53393 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53394 info.align_offset = 0;
53395 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53396 };
53397 MODULE_ALIAS_FS("hugetlbfs");
53398
53399 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53400 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53401
53402 static int can_do_hugetlb_shm(void)
53403 {
53404 diff --git a/fs/inode.c b/fs/inode.c
53405 index 00d5fc3..98ce7d7 100644
53406 --- a/fs/inode.c
53407 +++ b/fs/inode.c
53408 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53409
53410 #ifdef CONFIG_SMP
53411 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53412 - static atomic_t shared_last_ino;
53413 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53414 + static atomic_unchecked_t shared_last_ino;
53415 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53416
53417 res = next - LAST_INO_BATCH;
53418 }
53419 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53420 index 4a6cf28..d3a29d3 100644
53421 --- a/fs/jffs2/erase.c
53422 +++ b/fs/jffs2/erase.c
53423 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53424 struct jffs2_unknown_node marker = {
53425 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53426 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53427 - .totlen = cpu_to_je32(c->cleanmarker_size)
53428 + .totlen = cpu_to_je32(c->cleanmarker_size),
53429 + .hdr_crc = cpu_to_je32(0)
53430 };
53431
53432 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53433 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53434 index a6597d6..41b30ec 100644
53435 --- a/fs/jffs2/wbuf.c
53436 +++ b/fs/jffs2/wbuf.c
53437 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53438 {
53439 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53440 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53441 - .totlen = constant_cpu_to_je32(8)
53442 + .totlen = constant_cpu_to_je32(8),
53443 + .hdr_crc = constant_cpu_to_je32(0)
53444 };
53445
53446 /*
53447 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53448 index 788e0a9..8433098 100644
53449 --- a/fs/jfs/super.c
53450 +++ b/fs/jfs/super.c
53451 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
53452
53453 jfs_inode_cachep =
53454 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53455 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53456 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53457 init_once);
53458 if (jfs_inode_cachep == NULL)
53459 return -ENOMEM;
53460 diff --git a/fs/libfs.c b/fs/libfs.c
53461 index 916da8c..1588998 100644
53462 --- a/fs/libfs.c
53463 +++ b/fs/libfs.c
53464 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53465
53466 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53467 struct dentry *next;
53468 + char d_name[sizeof(next->d_iname)];
53469 + const unsigned char *name;
53470 +
53471 next = list_entry(p, struct dentry, d_u.d_child);
53472 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53473 if (!simple_positive(next)) {
53474 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53475
53476 spin_unlock(&next->d_lock);
53477 spin_unlock(&dentry->d_lock);
53478 - if (filldir(dirent, next->d_name.name,
53479 + name = next->d_name.name;
53480 + if (name == next->d_iname) {
53481 + memcpy(d_name, name, next->d_name.len);
53482 + name = d_name;
53483 + }
53484 + if (filldir(dirent, name,
53485 next->d_name.len, filp->f_pos,
53486 next->d_inode->i_ino,
53487 dt_type(next->d_inode)) < 0)
53488 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53489 index 9760ecb..9b838ef 100644
53490 --- a/fs/lockd/clntproc.c
53491 +++ b/fs/lockd/clntproc.c
53492 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53493 /*
53494 * Cookie counter for NLM requests
53495 */
53496 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53497 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53498
53499 void nlmclnt_next_cookie(struct nlm_cookie *c)
53500 {
53501 - u32 cookie = atomic_inc_return(&nlm_cookie);
53502 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53503
53504 memcpy(c->data, &cookie, 4);
53505 c->len=4;
53506 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53507 index a2aa97d..10d6c41 100644
53508 --- a/fs/lockd/svc.c
53509 +++ b/fs/lockd/svc.c
53510 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53511 svc_sock_update_bufs(serv);
53512 serv->sv_maxconn = nlm_max_connections;
53513
53514 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53515 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53516 if (IS_ERR(nlmsvc_task)) {
53517 error = PTR_ERR(nlmsvc_task);
53518 printk(KERN_WARNING
53519 diff --git a/fs/locks.c b/fs/locks.c
53520 index cb424a4..850e4dd 100644
53521 --- a/fs/locks.c
53522 +++ b/fs/locks.c
53523 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53524 return;
53525
53526 if (filp->f_op && filp->f_op->flock) {
53527 - struct file_lock fl = {
53528 + struct file_lock flock = {
53529 .fl_pid = current->tgid,
53530 .fl_file = filp,
53531 .fl_flags = FL_FLOCK,
53532 .fl_type = F_UNLCK,
53533 .fl_end = OFFSET_MAX,
53534 };
53535 - filp->f_op->flock(filp, F_SETLKW, &fl);
53536 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53537 - fl.fl_ops->fl_release_private(&fl);
53538 + filp->f_op->flock(filp, F_SETLKW, &flock);
53539 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53540 + flock.fl_ops->fl_release_private(&flock);
53541 }
53542
53543 lock_flocks();
53544 diff --git a/fs/namei.c b/fs/namei.c
53545 index 9ed9361..2b72db1 100644
53546 --- a/fs/namei.c
53547 +++ b/fs/namei.c
53548 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53549 if (ret != -EACCES)
53550 return ret;
53551
53552 +#ifdef CONFIG_GRKERNSEC
53553 + /* we'll block if we have to log due to a denied capability use */
53554 + if (mask & MAY_NOT_BLOCK)
53555 + return -ECHILD;
53556 +#endif
53557 +
53558 if (S_ISDIR(inode->i_mode)) {
53559 /* DACs are overridable for directories */
53560 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53561 - return 0;
53562 if (!(mask & MAY_WRITE))
53563 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53564 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53565 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53566 return 0;
53567 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53568 + return 0;
53569 return -EACCES;
53570 }
53571 /*
53572 + * Searching includes executable on directories, else just read.
53573 + */
53574 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53575 + if (mask == MAY_READ)
53576 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53577 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53578 + return 0;
53579 +
53580 + /*
53581 * Read/write DACs are always overridable.
53582 * Executable DACs are overridable when there is
53583 * at least one exec bit set.
53584 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53585 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53586 return 0;
53587
53588 - /*
53589 - * Searching includes executable on directories, else just read.
53590 - */
53591 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53592 - if (mask == MAY_READ)
53593 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53594 - return 0;
53595 -
53596 return -EACCES;
53597 }
53598
53599 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53600 {
53601 struct dentry *dentry = link->dentry;
53602 int error;
53603 - char *s;
53604 + const char *s;
53605
53606 BUG_ON(nd->flags & LOOKUP_RCU);
53607
53608 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53609 if (error)
53610 goto out_put_nd_path;
53611
53612 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53613 + dentry->d_inode, dentry, nd->path.mnt)) {
53614 + error = -EACCES;
53615 + goto out_put_nd_path;
53616 + }
53617 +
53618 nd->last_type = LAST_BIND;
53619 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53620 error = PTR_ERR(*p);
53621 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53622 if (res)
53623 break;
53624 res = walk_component(nd, path, LOOKUP_FOLLOW);
53625 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53626 + res = -EACCES;
53627 put_link(nd, &link, cookie);
53628 } while (res > 0);
53629
53630 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53631 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53632 {
53633 unsigned long a, b, adata, bdata, mask, hash, len;
53634 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53635 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53636
53637 hash = a = 0;
53638 len = -sizeof(unsigned long);
53639 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53640 if (err)
53641 break;
53642 err = lookup_last(nd, &path);
53643 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53644 + err = -EACCES;
53645 put_link(nd, &link, cookie);
53646 }
53647 }
53648 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53649 if (!err)
53650 err = complete_walk(nd);
53651
53652 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53653 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53654 + path_put(&nd->path);
53655 + err = -ENOENT;
53656 + }
53657 + }
53658 +
53659 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53660 if (!can_lookup(nd->inode)) {
53661 path_put(&nd->path);
53662 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53663 retval = path_lookupat(dfd, name->name,
53664 flags | LOOKUP_REVAL, nd);
53665
53666 - if (likely(!retval))
53667 + if (likely(!retval)) {
53668 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53669 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53670 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53671 + path_put(&nd->path);
53672 + return -ENOENT;
53673 + }
53674 + }
53675 + }
53676 return retval;
53677 }
53678
53679 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53680 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53681 return -EPERM;
53682
53683 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53684 + return -EPERM;
53685 + if (gr_handle_rawio(inode))
53686 + return -EPERM;
53687 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53688 + return -EACCES;
53689 +
53690 return 0;
53691 }
53692
53693 @@ -2602,7 +2641,7 @@ looked_up:
53694 * cleared otherwise prior to returning.
53695 */
53696 static int lookup_open(struct nameidata *nd, struct path *path,
53697 - struct file *file,
53698 + struct path *link, struct file *file,
53699 const struct open_flags *op,
53700 bool got_write, int *opened)
53701 {
53702 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53703 /* Negative dentry, just create the file */
53704 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53705 umode_t mode = op->mode;
53706 +
53707 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53708 + error = -EACCES;
53709 + goto out_dput;
53710 + }
53711 +
53712 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53713 + error = -EACCES;
53714 + goto out_dput;
53715 + }
53716 +
53717 if (!IS_POSIXACL(dir->d_inode))
53718 mode &= ~current_umask();
53719 /*
53720 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53721 nd->flags & LOOKUP_EXCL);
53722 if (error)
53723 goto out_dput;
53724 + else
53725 + gr_handle_create(dentry, nd->path.mnt);
53726 }
53727 out_no_open:
53728 path->dentry = dentry;
53729 @@ -2672,7 +2724,7 @@ out_dput:
53730 /*
53731 * Handle the last step of open()
53732 */
53733 -static int do_last(struct nameidata *nd, struct path *path,
53734 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53735 struct file *file, const struct open_flags *op,
53736 int *opened, struct filename *name)
53737 {
53738 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53739 error = complete_walk(nd);
53740 if (error)
53741 return error;
53742 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53743 + error = -ENOENT;
53744 + goto out;
53745 + }
53746 audit_inode(name, nd->path.dentry, 0);
53747 if (open_flag & O_CREAT) {
53748 error = -EISDIR;
53749 goto out;
53750 }
53751 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53752 + error = -EACCES;
53753 + goto out;
53754 + }
53755 goto finish_open;
53756 case LAST_BIND:
53757 error = complete_walk(nd);
53758 if (error)
53759 return error;
53760 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53761 + error = -ENOENT;
53762 + goto out;
53763 + }
53764 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53765 + error = -EACCES;
53766 + goto out;
53767 + }
53768 audit_inode(name, dir, 0);
53769 goto finish_open;
53770 }
53771 @@ -2759,7 +2827,7 @@ retry_lookup:
53772 */
53773 }
53774 mutex_lock(&dir->d_inode->i_mutex);
53775 - error = lookup_open(nd, path, file, op, got_write, opened);
53776 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53777 mutex_unlock(&dir->d_inode->i_mutex);
53778
53779 if (error <= 0) {
53780 @@ -2783,11 +2851,28 @@ retry_lookup:
53781 goto finish_open_created;
53782 }
53783
53784 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53785 + error = -ENOENT;
53786 + goto exit_dput;
53787 + }
53788 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53789 + error = -EACCES;
53790 + goto exit_dput;
53791 + }
53792 +
53793 /*
53794 * create/update audit record if it already exists.
53795 */
53796 - if (path->dentry->d_inode)
53797 + if (path->dentry->d_inode) {
53798 + /* only check if O_CREAT is specified, all other checks need to go
53799 + into may_open */
53800 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53801 + error = -EACCES;
53802 + goto exit_dput;
53803 + }
53804 +
53805 audit_inode(name, path->dentry, 0);
53806 + }
53807
53808 /*
53809 * If atomic_open() acquired write access it is dropped now due to
53810 @@ -2828,6 +2913,11 @@ finish_lookup:
53811 }
53812 }
53813 BUG_ON(inode != path->dentry->d_inode);
53814 + /* if we're resolving a symlink to another symlink */
53815 + if (link && gr_handle_symlink_owner(link, inode)) {
53816 + error = -EACCES;
53817 + goto out;
53818 + }
53819 return 1;
53820 }
53821
53822 @@ -2837,7 +2927,6 @@ finish_lookup:
53823 save_parent.dentry = nd->path.dentry;
53824 save_parent.mnt = mntget(path->mnt);
53825 nd->path.dentry = path->dentry;
53826 -
53827 }
53828 nd->inode = inode;
53829 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53830 @@ -2846,6 +2935,16 @@ finish_lookup:
53831 path_put(&save_parent);
53832 return error;
53833 }
53834 +
53835 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53836 + error = -ENOENT;
53837 + goto out;
53838 + }
53839 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53840 + error = -EACCES;
53841 + goto out;
53842 + }
53843 +
53844 error = -EISDIR;
53845 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53846 goto out;
53847 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53848 if (unlikely(error))
53849 goto out;
53850
53851 - error = do_last(nd, &path, file, op, &opened, pathname);
53852 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53853 while (unlikely(error > 0)) { /* trailing symlink */
53854 struct path link = path;
53855 void *cookie;
53856 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53857 error = follow_link(&link, nd, &cookie);
53858 if (unlikely(error))
53859 break;
53860 - error = do_last(nd, &path, file, op, &opened, pathname);
53861 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53862 put_link(nd, &link, cookie);
53863 }
53864 out:
53865 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53866 goto unlock;
53867
53868 error = -EEXIST;
53869 - if (dentry->d_inode)
53870 + if (dentry->d_inode) {
53871 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53872 + error = -ENOENT;
53873 + }
53874 goto fail;
53875 + }
53876 /*
53877 * Special case - lookup gave negative, but... we had foo/bar/
53878 * From the vfs_mknod() POV we just have a negative dentry -
53879 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53880 }
53881 EXPORT_SYMBOL(user_path_create);
53882
53883 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53884 +{
53885 + struct filename *tmp = getname(pathname);
53886 + struct dentry *res;
53887 + if (IS_ERR(tmp))
53888 + return ERR_CAST(tmp);
53889 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53890 + if (IS_ERR(res))
53891 + putname(tmp);
53892 + else
53893 + *to = tmp;
53894 + return res;
53895 +}
53896 +
53897 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53898 {
53899 int error = may_create(dir, dentry);
53900 @@ -3177,6 +3294,17 @@ retry:
53901
53902 if (!IS_POSIXACL(path.dentry->d_inode))
53903 mode &= ~current_umask();
53904 +
53905 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53906 + error = -EPERM;
53907 + goto out;
53908 + }
53909 +
53910 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53911 + error = -EACCES;
53912 + goto out;
53913 + }
53914 +
53915 error = security_path_mknod(&path, dentry, mode, dev);
53916 if (error)
53917 goto out;
53918 @@ -3193,6 +3321,8 @@ retry:
53919 break;
53920 }
53921 out:
53922 + if (!error)
53923 + gr_handle_create(dentry, path.mnt);
53924 done_path_create(&path, dentry);
53925 if (retry_estale(error, lookup_flags)) {
53926 lookup_flags |= LOOKUP_REVAL;
53927 @@ -3245,9 +3375,16 @@ retry:
53928
53929 if (!IS_POSIXACL(path.dentry->d_inode))
53930 mode &= ~current_umask();
53931 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53932 + error = -EACCES;
53933 + goto out;
53934 + }
53935 error = security_path_mkdir(&path, dentry, mode);
53936 if (!error)
53937 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53938 + if (!error)
53939 + gr_handle_create(dentry, path.mnt);
53940 +out:
53941 done_path_create(&path, dentry);
53942 if (retry_estale(error, lookup_flags)) {
53943 lookup_flags |= LOOKUP_REVAL;
53944 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53945 struct filename *name;
53946 struct dentry *dentry;
53947 struct nameidata nd;
53948 + ino_t saved_ino = 0;
53949 + dev_t saved_dev = 0;
53950 unsigned int lookup_flags = 0;
53951 retry:
53952 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53953 @@ -3360,10 +3499,21 @@ retry:
53954 error = -ENOENT;
53955 goto exit3;
53956 }
53957 +
53958 + saved_ino = dentry->d_inode->i_ino;
53959 + saved_dev = gr_get_dev_from_dentry(dentry);
53960 +
53961 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53962 + error = -EACCES;
53963 + goto exit3;
53964 + }
53965 +
53966 error = security_path_rmdir(&nd.path, dentry);
53967 if (error)
53968 goto exit3;
53969 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53970 + if (!error && (saved_dev || saved_ino))
53971 + gr_handle_delete(saved_ino, saved_dev);
53972 exit3:
53973 dput(dentry);
53974 exit2:
53975 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53976 struct dentry *dentry;
53977 struct nameidata nd;
53978 struct inode *inode = NULL;
53979 + ino_t saved_ino = 0;
53980 + dev_t saved_dev = 0;
53981 unsigned int lookup_flags = 0;
53982 retry:
53983 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53984 @@ -3455,10 +3607,22 @@ retry:
53985 if (!inode)
53986 goto slashes;
53987 ihold(inode);
53988 +
53989 + if (inode->i_nlink <= 1) {
53990 + saved_ino = inode->i_ino;
53991 + saved_dev = gr_get_dev_from_dentry(dentry);
53992 + }
53993 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53994 + error = -EACCES;
53995 + goto exit2;
53996 + }
53997 +
53998 error = security_path_unlink(&nd.path, dentry);
53999 if (error)
54000 goto exit2;
54001 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54002 + if (!error && (saved_ino || saved_dev))
54003 + gr_handle_delete(saved_ino, saved_dev);
54004 exit2:
54005 dput(dentry);
54006 }
54007 @@ -3536,9 +3700,17 @@ retry:
54008 if (IS_ERR(dentry))
54009 goto out_putname;
54010
54011 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54012 + error = -EACCES;
54013 + goto out;
54014 + }
54015 +
54016 error = security_path_symlink(&path, dentry, from->name);
54017 if (!error)
54018 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54019 + if (!error)
54020 + gr_handle_create(dentry, path.mnt);
54021 +out:
54022 done_path_create(&path, dentry);
54023 if (retry_estale(error, lookup_flags)) {
54024 lookup_flags |= LOOKUP_REVAL;
54025 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54026 {
54027 struct dentry *new_dentry;
54028 struct path old_path, new_path;
54029 + struct filename *to = NULL;
54030 int how = 0;
54031 int error;
54032
54033 @@ -3635,7 +3808,7 @@ retry:
54034 if (error)
54035 return error;
54036
54037 - new_dentry = user_path_create(newdfd, newname, &new_path,
54038 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54039 (how & LOOKUP_REVAL));
54040 error = PTR_ERR(new_dentry);
54041 if (IS_ERR(new_dentry))
54042 @@ -3647,11 +3820,28 @@ retry:
54043 error = may_linkat(&old_path);
54044 if (unlikely(error))
54045 goto out_dput;
54046 +
54047 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54048 + old_path.dentry->d_inode,
54049 + old_path.dentry->d_inode->i_mode, to)) {
54050 + error = -EACCES;
54051 + goto out_dput;
54052 + }
54053 +
54054 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54055 + old_path.dentry, old_path.mnt, to)) {
54056 + error = -EACCES;
54057 + goto out_dput;
54058 + }
54059 +
54060 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54061 if (error)
54062 goto out_dput;
54063 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54064 + if (!error)
54065 + gr_handle_create(new_dentry, new_path.mnt);
54066 out_dput:
54067 + putname(to);
54068 done_path_create(&new_path, new_dentry);
54069 if (retry_estale(error, how)) {
54070 how |= LOOKUP_REVAL;
54071 @@ -3897,12 +4087,21 @@ retry:
54072 if (new_dentry == trap)
54073 goto exit5;
54074
54075 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54076 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54077 + to);
54078 + if (error)
54079 + goto exit5;
54080 +
54081 error = security_path_rename(&oldnd.path, old_dentry,
54082 &newnd.path, new_dentry);
54083 if (error)
54084 goto exit5;
54085 error = vfs_rename(old_dir->d_inode, old_dentry,
54086 new_dir->d_inode, new_dentry);
54087 + if (!error)
54088 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54089 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54090 exit5:
54091 dput(new_dentry);
54092 exit4:
54093 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54094
54095 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54096 {
54097 + char tmpbuf[64];
54098 + const char *newlink;
54099 int len;
54100
54101 len = PTR_ERR(link);
54102 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54103 len = strlen(link);
54104 if (len > (unsigned) buflen)
54105 len = buflen;
54106 - if (copy_to_user(buffer, link, len))
54107 +
54108 + if (len < sizeof(tmpbuf)) {
54109 + memcpy(tmpbuf, link, len);
54110 + newlink = tmpbuf;
54111 + } else
54112 + newlink = link;
54113 +
54114 + if (copy_to_user(buffer, newlink, len))
54115 len = -EFAULT;
54116 out:
54117 return len;
54118 diff --git a/fs/namespace.c b/fs/namespace.c
54119 index 7b1ca9b..6faeccf 100644
54120 --- a/fs/namespace.c
54121 +++ b/fs/namespace.c
54122 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
54123 if (!(sb->s_flags & MS_RDONLY))
54124 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54125 up_write(&sb->s_umount);
54126 +
54127 + gr_log_remount(mnt->mnt_devname, retval);
54128 +
54129 return retval;
54130 }
54131
54132 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
54133 }
54134 br_write_unlock(&vfsmount_lock);
54135 namespace_unlock();
54136 +
54137 + gr_log_unmount(mnt->mnt_devname, retval);
54138 +
54139 return retval;
54140 }
54141
54142 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
54143 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54144 */
54145
54146 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54147 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54148 {
54149 struct path path;
54150 struct mount *mnt;
54151 @@ -1342,7 +1348,7 @@ out:
54152 /*
54153 * The 2.0 compatible umount. No flags.
54154 */
54155 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54156 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54157 {
54158 return sys_umount(name, 0);
54159 }
54160 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54161 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54162 MS_STRICTATIME);
54163
54164 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54165 + retval = -EPERM;
54166 + goto dput_out;
54167 + }
54168 +
54169 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54170 + retval = -EPERM;
54171 + goto dput_out;
54172 + }
54173 +
54174 if (flags & MS_REMOUNT)
54175 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54176 data_page);
54177 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54178 dev_name, data_page);
54179 dput_out:
54180 path_put(&path);
54181 +
54182 + gr_log_mount(dev_name, dir_name, retval);
54183 +
54184 return retval;
54185 }
54186
54187 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54188 }
54189 EXPORT_SYMBOL(mount_subtree);
54190
54191 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54192 - char __user *, type, unsigned long, flags, void __user *, data)
54193 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54194 + const char __user *, type, unsigned long, flags, void __user *, data)
54195 {
54196 int ret;
54197 char *kernel_type;
54198 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54199 if (error)
54200 goto out2;
54201
54202 + if (gr_handle_chroot_pivot()) {
54203 + error = -EPERM;
54204 + goto out2;
54205 + }
54206 +
54207 get_fs_root(current->fs, &root);
54208 old_mp = lock_mount(&old);
54209 error = PTR_ERR(old_mp);
54210 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54211 !nsown_capable(CAP_SYS_ADMIN))
54212 return -EPERM;
54213
54214 - if (fs->users != 1)
54215 + if (atomic_read(&fs->users) != 1)
54216 return -EINVAL;
54217
54218 get_mnt_ns(mnt_ns);
54219 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54220 index cff089a..4c3d57a 100644
54221 --- a/fs/nfs/callback.c
54222 +++ b/fs/nfs/callback.c
54223 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54224 struct svc_rqst *rqstp;
54225 int (*callback_svc)(void *vrqstp);
54226 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54227 - char svc_name[12];
54228 int ret;
54229
54230 nfs_callback_bc_serv(minorversion, xprt, serv);
54231 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54232
54233 svc_sock_update_bufs(serv);
54234
54235 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54236 cb_info->serv = serv;
54237 cb_info->rqst = rqstp;
54238 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54239 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54240 if (IS_ERR(cb_info->task)) {
54241 ret = PTR_ERR(cb_info->task);
54242 svc_exit_thread(cb_info->rqst);
54243 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54244 index a35582c..ebbdcd5 100644
54245 --- a/fs/nfs/callback_xdr.c
54246 +++ b/fs/nfs/callback_xdr.c
54247 @@ -51,7 +51,7 @@ struct callback_op {
54248 callback_decode_arg_t decode_args;
54249 callback_encode_res_t encode_res;
54250 long res_maxsize;
54251 -};
54252 +} __do_const;
54253
54254 static struct callback_op callback_ops[];
54255
54256 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54257 index c1c7a9d..7afa0b8 100644
54258 --- a/fs/nfs/inode.c
54259 +++ b/fs/nfs/inode.c
54260 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54261 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54262 }
54263
54264 -static atomic_long_t nfs_attr_generation_counter;
54265 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54266
54267 static unsigned long nfs_read_attr_generation_counter(void)
54268 {
54269 - return atomic_long_read(&nfs_attr_generation_counter);
54270 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54271 }
54272
54273 unsigned long nfs_inc_attr_generation_counter(void)
54274 {
54275 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54276 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54277 }
54278
54279 void nfs_fattr_init(struct nfs_fattr *fattr)
54280 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54281 index 2c37442..9b9538b 100644
54282 --- a/fs/nfs/nfs4state.c
54283 +++ b/fs/nfs/nfs4state.c
54284 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54285 snprintf(buf, sizeof(buf), "%s-manager",
54286 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54287 rcu_read_unlock();
54288 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54289 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54290 if (IS_ERR(task)) {
54291 printk(KERN_ERR "%s: kthread_run: %ld\n",
54292 __func__, PTR_ERR(task));
54293 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54294 index 27d74a2..c4c2a73 100644
54295 --- a/fs/nfsd/nfs4proc.c
54296 +++ b/fs/nfsd/nfs4proc.c
54297 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
54298 nfsd4op_rsize op_rsize_bop;
54299 stateid_getter op_get_currentstateid;
54300 stateid_setter op_set_currentstateid;
54301 -};
54302 +} __do_const;
54303
54304 static struct nfsd4_operation nfsd4_ops[];
54305
54306 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54307 index 582321a..0224663 100644
54308 --- a/fs/nfsd/nfs4xdr.c
54309 +++ b/fs/nfsd/nfs4xdr.c
54310 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54311
54312 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54313
54314 -static nfsd4_dec nfsd4_dec_ops[] = {
54315 +static const nfsd4_dec nfsd4_dec_ops[] = {
54316 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54317 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54318 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54319 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54320 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54321 };
54322
54323 -static nfsd4_dec nfsd41_dec_ops[] = {
54324 +static const nfsd4_dec nfsd41_dec_ops[] = {
54325 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54326 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54327 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54328 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54329 };
54330
54331 struct nfsd4_minorversion_ops {
54332 - nfsd4_dec *decoders;
54333 + const nfsd4_dec *decoders;
54334 int nops;
54335 };
54336
54337 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54338 index e76244e..9fe8f2f1 100644
54339 --- a/fs/nfsd/nfscache.c
54340 +++ b/fs/nfsd/nfscache.c
54341 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54342 {
54343 struct svc_cacherep *rp = rqstp->rq_cacherep;
54344 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54345 - int len;
54346 + long len;
54347 size_t bufsize = 0;
54348
54349 if (!rp)
54350 return;
54351
54352 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54353 - len >>= 2;
54354 + if (statp) {
54355 + len = (char*)statp - (char*)resv->iov_base;
54356 + len = resv->iov_len - len;
54357 + len >>= 2;
54358 + }
54359
54360 /* Don't cache excessive amounts of data and XDR failures */
54361 if (!statp || len > (256 >> 2)) {
54362 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54363 index 84ce601..633d226 100644
54364 --- a/fs/nfsd/vfs.c
54365 +++ b/fs/nfsd/vfs.c
54366 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54367 } else {
54368 oldfs = get_fs();
54369 set_fs(KERNEL_DS);
54370 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54371 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54372 set_fs(oldfs);
54373 }
54374
54375 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54376
54377 /* Write the data. */
54378 oldfs = get_fs(); set_fs(KERNEL_DS);
54379 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54380 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54381 set_fs(oldfs);
54382 if (host_err < 0)
54383 goto out_nfserr;
54384 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54385 */
54386
54387 oldfs = get_fs(); set_fs(KERNEL_DS);
54388 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54389 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54390 set_fs(oldfs);
54391
54392 if (host_err < 0)
54393 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54394 index fea6bd5..8ee9d81 100644
54395 --- a/fs/nls/nls_base.c
54396 +++ b/fs/nls/nls_base.c
54397 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54398
54399 int register_nls(struct nls_table * nls)
54400 {
54401 - struct nls_table ** tmp = &tables;
54402 + struct nls_table *tmp = tables;
54403
54404 if (nls->next)
54405 return -EBUSY;
54406
54407 spin_lock(&nls_lock);
54408 - while (*tmp) {
54409 - if (nls == *tmp) {
54410 + while (tmp) {
54411 + if (nls == tmp) {
54412 spin_unlock(&nls_lock);
54413 return -EBUSY;
54414 }
54415 - tmp = &(*tmp)->next;
54416 + tmp = tmp->next;
54417 }
54418 - nls->next = tables;
54419 + pax_open_kernel();
54420 + *(struct nls_table **)&nls->next = tables;
54421 + pax_close_kernel();
54422 tables = nls;
54423 spin_unlock(&nls_lock);
54424 return 0;
54425 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54426
54427 int unregister_nls(struct nls_table * nls)
54428 {
54429 - struct nls_table ** tmp = &tables;
54430 + struct nls_table * const * tmp = &tables;
54431
54432 spin_lock(&nls_lock);
54433 while (*tmp) {
54434 if (nls == *tmp) {
54435 - *tmp = nls->next;
54436 + pax_open_kernel();
54437 + *(struct nls_table **)tmp = nls->next;
54438 + pax_close_kernel();
54439 spin_unlock(&nls_lock);
54440 return 0;
54441 }
54442 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54443 index 7424929..35f6be5 100644
54444 --- a/fs/nls/nls_euc-jp.c
54445 +++ b/fs/nls/nls_euc-jp.c
54446 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54447 p_nls = load_nls("cp932");
54448
54449 if (p_nls) {
54450 - table.charset2upper = p_nls->charset2upper;
54451 - table.charset2lower = p_nls->charset2lower;
54452 + pax_open_kernel();
54453 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54454 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54455 + pax_close_kernel();
54456 return register_nls(&table);
54457 }
54458
54459 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54460 index e7bc1d7..06bd4bb 100644
54461 --- a/fs/nls/nls_koi8-ru.c
54462 +++ b/fs/nls/nls_koi8-ru.c
54463 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54464 p_nls = load_nls("koi8-u");
54465
54466 if (p_nls) {
54467 - table.charset2upper = p_nls->charset2upper;
54468 - table.charset2lower = p_nls->charset2lower;
54469 + pax_open_kernel();
54470 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54471 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54472 + pax_close_kernel();
54473 return register_nls(&table);
54474 }
54475
54476 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54477 index 6c80083..a1e6299 100644
54478 --- a/fs/notify/fanotify/fanotify_user.c
54479 +++ b/fs/notify/fanotify/fanotify_user.c
54480 @@ -122,6 +122,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54481 metadata->event_len = FAN_EVENT_METADATA_LEN;
54482 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54483 metadata->vers = FANOTIFY_METADATA_VERSION;
54484 + metadata->reserved = 0;
54485 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54486 metadata->pid = pid_vnr(event->tgid);
54487 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54488 @@ -252,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54489
54490 fd = fanotify_event_metadata.fd;
54491 ret = -EFAULT;
54492 - if (copy_to_user(buf, &fanotify_event_metadata,
54493 - fanotify_event_metadata.event_len))
54494 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54495 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54496 goto out_close_fd;
54497
54498 ret = prepare_for_access_response(group, event, fd);
54499 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54500 index 7b51b05..5ea5ef6 100644
54501 --- a/fs/notify/notification.c
54502 +++ b/fs/notify/notification.c
54503 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54504 * get set to 0 so it will never get 'freed'
54505 */
54506 static struct fsnotify_event *q_overflow_event;
54507 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54508 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54509
54510 /**
54511 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54512 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54513 */
54514 u32 fsnotify_get_cookie(void)
54515 {
54516 - return atomic_inc_return(&fsnotify_sync_cookie);
54517 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54518 }
54519 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54520
54521 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54522 index aa411c3..c260a84 100644
54523 --- a/fs/ntfs/dir.c
54524 +++ b/fs/ntfs/dir.c
54525 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54526 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54527 ~(s64)(ndir->itype.index.block_size - 1)));
54528 /* Bounds checks. */
54529 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54530 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54531 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54532 "inode 0x%lx or driver bug.", vdir->i_ino);
54533 goto err_out;
54534 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54535 index c5670b8..01a3656 100644
54536 --- a/fs/ntfs/file.c
54537 +++ b/fs/ntfs/file.c
54538 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54539 #endif /* NTFS_RW */
54540 };
54541
54542 -const struct file_operations ntfs_empty_file_ops = {};
54543 +const struct file_operations ntfs_empty_file_ops __read_only;
54544
54545 -const struct inode_operations ntfs_empty_inode_ops = {};
54546 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54547 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54548 index aebeacd..0dcdd26 100644
54549 --- a/fs/ocfs2/localalloc.c
54550 +++ b/fs/ocfs2/localalloc.c
54551 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54552 goto bail;
54553 }
54554
54555 - atomic_inc(&osb->alloc_stats.moves);
54556 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54557
54558 bail:
54559 if (handle)
54560 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54561 index d355e6e..578d905 100644
54562 --- a/fs/ocfs2/ocfs2.h
54563 +++ b/fs/ocfs2/ocfs2.h
54564 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54565
54566 struct ocfs2_alloc_stats
54567 {
54568 - atomic_t moves;
54569 - atomic_t local_data;
54570 - atomic_t bitmap_data;
54571 - atomic_t bg_allocs;
54572 - atomic_t bg_extends;
54573 + atomic_unchecked_t moves;
54574 + atomic_unchecked_t local_data;
54575 + atomic_unchecked_t bitmap_data;
54576 + atomic_unchecked_t bg_allocs;
54577 + atomic_unchecked_t bg_extends;
54578 };
54579
54580 enum ocfs2_local_alloc_state
54581 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54582 index b7e74b5..19c6536 100644
54583 --- a/fs/ocfs2/suballoc.c
54584 +++ b/fs/ocfs2/suballoc.c
54585 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54586 mlog_errno(status);
54587 goto bail;
54588 }
54589 - atomic_inc(&osb->alloc_stats.bg_extends);
54590 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54591
54592 /* You should never ask for this much metadata */
54593 BUG_ON(bits_wanted >
54594 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54595 mlog_errno(status);
54596 goto bail;
54597 }
54598 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54599 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54600
54601 *suballoc_loc = res.sr_bg_blkno;
54602 *suballoc_bit_start = res.sr_bit_offset;
54603 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54604 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54605 res->sr_bits);
54606
54607 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54608 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54609
54610 BUG_ON(res->sr_bits != 1);
54611
54612 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54613 mlog_errno(status);
54614 goto bail;
54615 }
54616 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54617 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54618
54619 BUG_ON(res.sr_bits != 1);
54620
54621 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54622 cluster_start,
54623 num_clusters);
54624 if (!status)
54625 - atomic_inc(&osb->alloc_stats.local_data);
54626 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54627 } else {
54628 if (min_clusters > (osb->bitmap_cpg - 1)) {
54629 /* The only paths asking for contiguousness
54630 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54631 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54632 res.sr_bg_blkno,
54633 res.sr_bit_offset);
54634 - atomic_inc(&osb->alloc_stats.bitmap_data);
54635 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54636 *num_clusters = res.sr_bits;
54637 }
54638 }
54639 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54640 index 01b8516..579c4df 100644
54641 --- a/fs/ocfs2/super.c
54642 +++ b/fs/ocfs2/super.c
54643 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54644 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54645 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54646 "Stats",
54647 - atomic_read(&osb->alloc_stats.bitmap_data),
54648 - atomic_read(&osb->alloc_stats.local_data),
54649 - atomic_read(&osb->alloc_stats.bg_allocs),
54650 - atomic_read(&osb->alloc_stats.moves),
54651 - atomic_read(&osb->alloc_stats.bg_extends));
54652 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54653 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54654 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54655 + atomic_read_unchecked(&osb->alloc_stats.moves),
54656 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54657
54658 out += snprintf(buf + out, len - out,
54659 "%10s => State: %u Descriptor: %llu Size: %u bits "
54660 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54661 spin_lock_init(&osb->osb_xattr_lock);
54662 ocfs2_init_steal_slots(osb);
54663
54664 - atomic_set(&osb->alloc_stats.moves, 0);
54665 - atomic_set(&osb->alloc_stats.local_data, 0);
54666 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54667 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54668 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54669 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54670 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54671 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54672 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54673 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54674
54675 /* Copy the blockcheck stats from the superblock probe */
54676 osb->osb_ecc_stats = *stats;
54677 diff --git a/fs/open.c b/fs/open.c
54678 index 8c74100..4239c48 100644
54679 --- a/fs/open.c
54680 +++ b/fs/open.c
54681 @@ -32,6 +32,8 @@
54682 #include <linux/dnotify.h>
54683 #include <linux/compat.h>
54684
54685 +#define CREATE_TRACE_POINTS
54686 +#include <trace/events/fs.h>
54687 #include "internal.h"
54688
54689 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54690 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54691 error = locks_verify_truncate(inode, NULL, length);
54692 if (!error)
54693 error = security_path_truncate(path);
54694 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54695 + error = -EACCES;
54696 if (!error)
54697 error = do_truncate(path->dentry, length, 0, NULL);
54698
54699 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54700 error = locks_verify_truncate(inode, f.file, length);
54701 if (!error)
54702 error = security_path_truncate(&f.file->f_path);
54703 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54704 + error = -EACCES;
54705 if (!error)
54706 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54707 sb_end_write(inode->i_sb);
54708 @@ -360,6 +366,9 @@ retry:
54709 if (__mnt_is_readonly(path.mnt))
54710 res = -EROFS;
54711
54712 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54713 + res = -EACCES;
54714 +
54715 out_path_release:
54716 path_put(&path);
54717 if (retry_estale(res, lookup_flags)) {
54718 @@ -391,6 +400,8 @@ retry:
54719 if (error)
54720 goto dput_and_out;
54721
54722 + gr_log_chdir(path.dentry, path.mnt);
54723 +
54724 set_fs_pwd(current->fs, &path);
54725
54726 dput_and_out:
54727 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54728 goto out_putf;
54729
54730 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54731 +
54732 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54733 + error = -EPERM;
54734 +
54735 + if (!error)
54736 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54737 +
54738 if (!error)
54739 set_fs_pwd(current->fs, &f.file->f_path);
54740 out_putf:
54741 @@ -449,7 +467,13 @@ retry:
54742 if (error)
54743 goto dput_and_out;
54744
54745 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54746 + goto dput_and_out;
54747 +
54748 set_fs_root(current->fs, &path);
54749 +
54750 + gr_handle_chroot_chdir(&path);
54751 +
54752 error = 0;
54753 dput_and_out:
54754 path_put(&path);
54755 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
54756 if (error)
54757 return error;
54758 mutex_lock(&inode->i_mutex);
54759 +
54760 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54761 + error = -EACCES;
54762 + goto out_unlock;
54763 + }
54764 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54765 + error = -EACCES;
54766 + goto out_unlock;
54767 + }
54768 +
54769 error = security_path_chmod(path, mode);
54770 if (error)
54771 goto out_unlock;
54772 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54773 uid = make_kuid(current_user_ns(), user);
54774 gid = make_kgid(current_user_ns(), group);
54775
54776 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54777 + return -EACCES;
54778 +
54779 newattrs.ia_valid = ATTR_CTIME;
54780 if (user != (uid_t) -1) {
54781 if (!uid_valid(uid))
54782 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54783 } else {
54784 fsnotify_open(f);
54785 fd_install(fd, f);
54786 + trace_do_sys_open(tmp->name, flags, mode);
54787 }
54788 }
54789 putname(tmp);
54790 diff --git a/fs/pipe.c b/fs/pipe.c
54791 index d2c45e1..009fe1c 100644
54792 --- a/fs/pipe.c
54793 +++ b/fs/pipe.c
54794 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
54795
54796 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
54797 {
54798 - if (pipe->files)
54799 + if (atomic_read(&pipe->files))
54800 mutex_lock_nested(&pipe->mutex, subclass);
54801 }
54802
54803 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
54804
54805 void pipe_unlock(struct pipe_inode_info *pipe)
54806 {
54807 - if (pipe->files)
54808 + if (atomic_read(&pipe->files))
54809 mutex_unlock(&pipe->mutex);
54810 }
54811 EXPORT_SYMBOL(pipe_unlock);
54812 @@ -449,9 +449,9 @@ redo:
54813 }
54814 if (bufs) /* More to do? */
54815 continue;
54816 - if (!pipe->writers)
54817 + if (!atomic_read(&pipe->writers))
54818 break;
54819 - if (!pipe->waiting_writers) {
54820 + if (!atomic_read(&pipe->waiting_writers)) {
54821 /* syscall merging: Usually we must not sleep
54822 * if O_NONBLOCK is set, or if we got some data.
54823 * But if a writer sleeps in kernel space, then
54824 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54825 ret = 0;
54826 __pipe_lock(pipe);
54827
54828 - if (!pipe->readers) {
54829 + if (!atomic_read(&pipe->readers)) {
54830 send_sig(SIGPIPE, current, 0);
54831 ret = -EPIPE;
54832 goto out;
54833 @@ -562,7 +562,7 @@ redo1:
54834 for (;;) {
54835 int bufs;
54836
54837 - if (!pipe->readers) {
54838 + if (!atomic_read(&pipe->readers)) {
54839 send_sig(SIGPIPE, current, 0);
54840 if (!ret)
54841 ret = -EPIPE;
54842 @@ -653,9 +653,9 @@ redo2:
54843 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54844 do_wakeup = 0;
54845 }
54846 - pipe->waiting_writers++;
54847 + atomic_inc(&pipe->waiting_writers);
54848 pipe_wait(pipe);
54849 - pipe->waiting_writers--;
54850 + atomic_dec(&pipe->waiting_writers);
54851 }
54852 out:
54853 __pipe_unlock(pipe);
54854 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54855 mask = 0;
54856 if (filp->f_mode & FMODE_READ) {
54857 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54858 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54859 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54860 mask |= POLLHUP;
54861 }
54862
54863 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54864 * Most Unices do not set POLLERR for FIFOs but on Linux they
54865 * behave exactly like pipes for poll().
54866 */
54867 - if (!pipe->readers)
54868 + if (!atomic_read(&pipe->readers))
54869 mask |= POLLERR;
54870 }
54871
54872 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
54873
54874 __pipe_lock(pipe);
54875 if (file->f_mode & FMODE_READ)
54876 - pipe->readers--;
54877 + atomic_dec(&pipe->readers);
54878 if (file->f_mode & FMODE_WRITE)
54879 - pipe->writers--;
54880 + atomic_dec(&pipe->writers);
54881
54882 - if (pipe->readers || pipe->writers) {
54883 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
54884 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54885 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54886 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
54887 }
54888 spin_lock(&inode->i_lock);
54889 - if (!--pipe->files) {
54890 + if (atomic_dec_and_test(&pipe->files)) {
54891 inode->i_pipe = NULL;
54892 kill = 1;
54893 }
54894 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
54895 kfree(pipe);
54896 }
54897
54898 -static struct vfsmount *pipe_mnt __read_mostly;
54899 +struct vfsmount *pipe_mnt __read_mostly;
54900
54901 /*
54902 * pipefs_dname() is called from d_path().
54903 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
54904 goto fail_iput;
54905
54906 inode->i_pipe = pipe;
54907 - pipe->files = 2;
54908 - pipe->readers = pipe->writers = 1;
54909 + atomic_set(&pipe->files, 2);
54910 + atomic_set(&pipe->readers, 1);
54911 + atomic_set(&pipe->writers, 1);
54912 inode->i_fop = &pipefifo_fops;
54913
54914 /*
54915 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
54916 spin_lock(&inode->i_lock);
54917 if (inode->i_pipe) {
54918 pipe = inode->i_pipe;
54919 - pipe->files++;
54920 + atomic_inc(&pipe->files);
54921 spin_unlock(&inode->i_lock);
54922 } else {
54923 spin_unlock(&inode->i_lock);
54924 pipe = alloc_pipe_info();
54925 if (!pipe)
54926 return -ENOMEM;
54927 - pipe->files = 1;
54928 + atomic_set(&pipe->files, 1);
54929 spin_lock(&inode->i_lock);
54930 if (unlikely(inode->i_pipe)) {
54931 - inode->i_pipe->files++;
54932 + atomic_inc(&inode->i_pipe->files);
54933 spin_unlock(&inode->i_lock);
54934 free_pipe_info(pipe);
54935 pipe = inode->i_pipe;
54936 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
54937 * opened, even when there is no process writing the FIFO.
54938 */
54939 pipe->r_counter++;
54940 - if (pipe->readers++ == 0)
54941 + if (atomic_inc_return(&pipe->readers) == 1)
54942 wake_up_partner(pipe);
54943
54944 - if (!is_pipe && !pipe->writers) {
54945 + if (!is_pipe && !atomic_read(&pipe->writers)) {
54946 if ((filp->f_flags & O_NONBLOCK)) {
54947 /* suppress POLLHUP until we have
54948 * seen a writer */
54949 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
54950 * errno=ENXIO when there is no process reading the FIFO.
54951 */
54952 ret = -ENXIO;
54953 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
54954 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
54955 goto err;
54956
54957 pipe->w_counter++;
54958 - if (!pipe->writers++)
54959 + if (atomic_inc_return(&pipe->writers) == 1)
54960 wake_up_partner(pipe);
54961
54962 - if (!is_pipe && !pipe->readers) {
54963 + if (!is_pipe && !atomic_read(&pipe->readers)) {
54964 if (wait_for_partner(pipe, &pipe->r_counter))
54965 goto err_wr;
54966 }
54967 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
54968 * the process can at least talk to itself.
54969 */
54970
54971 - pipe->readers++;
54972 - pipe->writers++;
54973 + atomic_inc(&pipe->readers);
54974 + atomic_inc(&pipe->writers);
54975 pipe->r_counter++;
54976 pipe->w_counter++;
54977 - if (pipe->readers == 1 || pipe->writers == 1)
54978 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
54979 wake_up_partner(pipe);
54980 break;
54981
54982 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
54983 return 0;
54984
54985 err_rd:
54986 - if (!--pipe->readers)
54987 + if (atomic_dec_and_test(&pipe->readers))
54988 wake_up_interruptible(&pipe->wait);
54989 ret = -ERESTARTSYS;
54990 goto err;
54991
54992 err_wr:
54993 - if (!--pipe->writers)
54994 + if (atomic_dec_and_test(&pipe->writers))
54995 wake_up_interruptible(&pipe->wait);
54996 ret = -ERESTARTSYS;
54997 goto err;
54998
54999 err:
55000 spin_lock(&inode->i_lock);
55001 - if (!--pipe->files) {
55002 + if (atomic_dec_and_test(&pipe->files)) {
55003 inode->i_pipe = NULL;
55004 kill = 1;
55005 }
55006 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55007 index 15af622..0e9f4467 100644
55008 --- a/fs/proc/Kconfig
55009 +++ b/fs/proc/Kconfig
55010 @@ -30,12 +30,12 @@ config PROC_FS
55011
55012 config PROC_KCORE
55013 bool "/proc/kcore support" if !ARM
55014 - depends on PROC_FS && MMU
55015 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55016
55017 config PROC_VMCORE
55018 bool "/proc/vmcore support"
55019 - depends on PROC_FS && CRASH_DUMP
55020 - default y
55021 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55022 + default n
55023 help
55024 Exports the dump image of crashed kernel in ELF format.
55025
55026 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55027 limited in memory.
55028
55029 config PROC_PAGE_MONITOR
55030 - default y
55031 - depends on PROC_FS && MMU
55032 + default n
55033 + depends on PROC_FS && MMU && !GRKERNSEC
55034 bool "Enable /proc page monitoring" if EXPERT
55035 help
55036 Various /proc files exist to monitor process memory utilization:
55037 diff --git a/fs/proc/array.c b/fs/proc/array.c
55038 index cbd0f1b..adec3f0 100644
55039 --- a/fs/proc/array.c
55040 +++ b/fs/proc/array.c
55041 @@ -60,6 +60,7 @@
55042 #include <linux/tty.h>
55043 #include <linux/string.h>
55044 #include <linux/mman.h>
55045 +#include <linux/grsecurity.h>
55046 #include <linux/proc_fs.h>
55047 #include <linux/ioport.h>
55048 #include <linux/uaccess.h>
55049 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55050 seq_putc(m, '\n');
55051 }
55052
55053 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55054 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55055 +{
55056 + if (p->mm)
55057 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55058 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55059 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55060 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55061 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55062 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55063 + else
55064 + seq_printf(m, "PaX:\t-----\n");
55065 +}
55066 +#endif
55067 +
55068 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55069 struct pid *pid, struct task_struct *task)
55070 {
55071 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55072 task_cpus_allowed(m, task);
55073 cpuset_task_status_allowed(m, task);
55074 task_context_switch_counts(m, task);
55075 +
55076 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55077 + task_pax(m, task);
55078 +#endif
55079 +
55080 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55081 + task_grsec_rbac(m, task);
55082 +#endif
55083 +
55084 return 0;
55085 }
55086
55087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55088 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55089 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55090 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55091 +#endif
55092 +
55093 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55094 struct pid *pid, struct task_struct *task, int whole)
55095 {
55096 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55097 char tcomm[sizeof(task->comm)];
55098 unsigned long flags;
55099
55100 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55101 + if (current->exec_id != m->exec_id) {
55102 + gr_log_badprocpid("stat");
55103 + return 0;
55104 + }
55105 +#endif
55106 +
55107 state = *get_task_state(task);
55108 vsize = eip = esp = 0;
55109 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55110 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55111 gtime = task_gtime(task);
55112 }
55113
55114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55115 + if (PAX_RAND_FLAGS(mm)) {
55116 + eip = 0;
55117 + esp = 0;
55118 + wchan = 0;
55119 + }
55120 +#endif
55121 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55122 + wchan = 0;
55123 + eip =0;
55124 + esp =0;
55125 +#endif
55126 +
55127 /* scale priority and nice values from timeslices to -20..20 */
55128 /* to make it look like a "normal" Unix priority/nice value */
55129 priority = task_prio(task);
55130 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55131 seq_put_decimal_ull(m, ' ', vsize);
55132 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55133 seq_put_decimal_ull(m, ' ', rsslim);
55134 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55135 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55136 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55137 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55138 +#else
55139 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55140 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55141 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55142 +#endif
55143 seq_put_decimal_ull(m, ' ', esp);
55144 seq_put_decimal_ull(m, ' ', eip);
55145 /* The signal information here is obsolete.
55146 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55147 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55148 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55149
55150 - if (mm && permitted) {
55151 + if (mm && permitted
55152 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55153 + && !PAX_RAND_FLAGS(mm)
55154 +#endif
55155 + ) {
55156 seq_put_decimal_ull(m, ' ', mm->start_data);
55157 seq_put_decimal_ull(m, ' ', mm->end_data);
55158 seq_put_decimal_ull(m, ' ', mm->start_brk);
55159 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55160 struct pid *pid, struct task_struct *task)
55161 {
55162 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55163 - struct mm_struct *mm = get_task_mm(task);
55164 + struct mm_struct *mm;
55165
55166 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55167 + if (current->exec_id != m->exec_id) {
55168 + gr_log_badprocpid("statm");
55169 + return 0;
55170 + }
55171 +#endif
55172 + mm = get_task_mm(task);
55173 if (mm) {
55174 size = task_statm(mm, &shared, &text, &data, &resident);
55175 mmput(mm);
55176 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55177 return 0;
55178 }
55179
55180 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55181 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55182 +{
55183 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55184 +}
55185 +#endif
55186 +
55187 #ifdef CONFIG_CHECKPOINT_RESTORE
55188 static struct pid *
55189 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55190 diff --git a/fs/proc/base.c b/fs/proc/base.c
55191 index c3834da..b402b2b 100644
55192 --- a/fs/proc/base.c
55193 +++ b/fs/proc/base.c
55194 @@ -113,6 +113,14 @@ struct pid_entry {
55195 union proc_op op;
55196 };
55197
55198 +struct getdents_callback {
55199 + struct linux_dirent __user * current_dir;
55200 + struct linux_dirent __user * previous;
55201 + struct file * file;
55202 + int count;
55203 + int error;
55204 +};
55205 +
55206 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55207 .name = (NAME), \
55208 .len = sizeof(NAME) - 1, \
55209 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55210 if (!mm->arg_end)
55211 goto out_mm; /* Shh! No looking before we're done */
55212
55213 + if (gr_acl_handle_procpidmem(task))
55214 + goto out_mm;
55215 +
55216 len = mm->arg_end - mm->arg_start;
55217
55218 if (len > PAGE_SIZE)
55219 @@ -237,12 +248,28 @@ out:
55220 return res;
55221 }
55222
55223 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55224 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55225 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55226 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55227 +#endif
55228 +
55229 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55230 {
55231 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55232 int res = PTR_ERR(mm);
55233 if (mm && !IS_ERR(mm)) {
55234 unsigned int nwords = 0;
55235 +
55236 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55237 + /* allow if we're currently ptracing this task */
55238 + if (PAX_RAND_FLAGS(mm) &&
55239 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55240 + mmput(mm);
55241 + return 0;
55242 + }
55243 +#endif
55244 +
55245 do {
55246 nwords += 2;
55247 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55248 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55249 }
55250
55251
55252 -#ifdef CONFIG_KALLSYMS
55253 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55254 /*
55255 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55256 * Returns the resolved symbol. If that fails, simply return the address.
55257 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
55258 mutex_unlock(&task->signal->cred_guard_mutex);
55259 }
55260
55261 -#ifdef CONFIG_STACKTRACE
55262 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55263
55264 #define MAX_STACK_TRACE_DEPTH 64
55265
55266 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55267 return count;
55268 }
55269
55270 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55271 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55272 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55273 {
55274 long nr;
55275 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55276 /************************************************************************/
55277
55278 /* permission checks */
55279 -static int proc_fd_access_allowed(struct inode *inode)
55280 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55281 {
55282 struct task_struct *task;
55283 int allowed = 0;
55284 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55285 */
55286 task = get_proc_task(inode);
55287 if (task) {
55288 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55289 + if (log)
55290 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55291 + else
55292 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55293 put_task_struct(task);
55294 }
55295 return allowed;
55296 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55297 struct task_struct *task,
55298 int hide_pid_min)
55299 {
55300 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55301 + return false;
55302 +
55303 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55304 + rcu_read_lock();
55305 + {
55306 + const struct cred *tmpcred = current_cred();
55307 + const struct cred *cred = __task_cred(task);
55308 +
55309 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55310 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55311 + || in_group_p(grsec_proc_gid)
55312 +#endif
55313 + ) {
55314 + rcu_read_unlock();
55315 + return true;
55316 + }
55317 + }
55318 + rcu_read_unlock();
55319 +
55320 + if (!pid->hide_pid)
55321 + return false;
55322 +#endif
55323 +
55324 if (pid->hide_pid < hide_pid_min)
55325 return true;
55326 if (in_group_p(pid->pid_gid))
55327 return true;
55328 +
55329 return ptrace_may_access(task, PTRACE_MODE_READ);
55330 }
55331
55332 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55333 put_task_struct(task);
55334
55335 if (!has_perms) {
55336 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55337 + {
55338 +#else
55339 if (pid->hide_pid == 2) {
55340 +#endif
55341 /*
55342 * Let's make getdents(), stat(), and open()
55343 * consistent with each other. If a process
55344 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55345 if (!task)
55346 return -ESRCH;
55347
55348 + if (gr_acl_handle_procpidmem(task)) {
55349 + put_task_struct(task);
55350 + return -EPERM;
55351 + }
55352 +
55353 mm = mm_access(task, mode);
55354 put_task_struct(task);
55355
55356 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55357
55358 file->private_data = mm;
55359
55360 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55361 + file->f_version = current->exec_id;
55362 +#endif
55363 +
55364 return 0;
55365 }
55366
55367 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55368 ssize_t copied;
55369 char *page;
55370
55371 +#ifdef CONFIG_GRKERNSEC
55372 + if (write)
55373 + return -EPERM;
55374 +#endif
55375 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55376 + if (file->f_version != current->exec_id) {
55377 + gr_log_badprocpid("mem");
55378 + return 0;
55379 + }
55380 +#endif
55381 +
55382 if (!mm)
55383 return 0;
55384
55385 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55386 goto free;
55387
55388 while (count > 0) {
55389 - int this_len = min_t(int, count, PAGE_SIZE);
55390 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55391
55392 if (write && copy_from_user(page, buf, this_len)) {
55393 copied = -EFAULT;
55394 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55395 if (!mm)
55396 return 0;
55397
55398 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55399 + if (file->f_version != current->exec_id) {
55400 + gr_log_badprocpid("environ");
55401 + return 0;
55402 + }
55403 +#endif
55404 +
55405 page = (char *)__get_free_page(GFP_TEMPORARY);
55406 if (!page)
55407 return -ENOMEM;
55408 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55409 goto free;
55410 while (count > 0) {
55411 size_t this_len, max_len;
55412 - int retval;
55413 + ssize_t retval;
55414
55415 if (src >= (mm->env_end - mm->env_start))
55416 break;
55417 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55418 int error = -EACCES;
55419
55420 /* Are we allowed to snoop on the tasks file descriptors? */
55421 - if (!proc_fd_access_allowed(inode))
55422 + if (!proc_fd_access_allowed(inode, 0))
55423 goto out;
55424
55425 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55426 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55427 struct path path;
55428
55429 /* Are we allowed to snoop on the tasks file descriptors? */
55430 - if (!proc_fd_access_allowed(inode))
55431 - goto out;
55432 + /* logging this is needed for learning on chromium to work properly,
55433 + but we don't want to flood the logs from 'ps' which does a readlink
55434 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55435 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55436 + */
55437 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55438 + if (!proc_fd_access_allowed(inode,0))
55439 + goto out;
55440 + } else {
55441 + if (!proc_fd_access_allowed(inode,1))
55442 + goto out;
55443 + }
55444
55445 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55446 if (error)
55447 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55448 rcu_read_lock();
55449 cred = __task_cred(task);
55450 inode->i_uid = cred->euid;
55451 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55452 + inode->i_gid = grsec_proc_gid;
55453 +#else
55454 inode->i_gid = cred->egid;
55455 +#endif
55456 rcu_read_unlock();
55457 }
55458 security_task_to_inode(task, inode);
55459 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55460 return -ENOENT;
55461 }
55462 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55463 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55464 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55465 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55466 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55467 +#endif
55468 task_dumpable(task)) {
55469 cred = __task_cred(task);
55470 stat->uid = cred->euid;
55471 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55472 + stat->gid = grsec_proc_gid;
55473 +#else
55474 stat->gid = cred->egid;
55475 +#endif
55476 }
55477 }
55478 rcu_read_unlock();
55479 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55480
55481 if (task) {
55482 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55483 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55484 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55485 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55486 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55487 +#endif
55488 task_dumpable(task)) {
55489 rcu_read_lock();
55490 cred = __task_cred(task);
55491 inode->i_uid = cred->euid;
55492 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55493 + inode->i_gid = grsec_proc_gid;
55494 +#else
55495 inode->i_gid = cred->egid;
55496 +#endif
55497 rcu_read_unlock();
55498 } else {
55499 inode->i_uid = GLOBAL_ROOT_UID;
55500 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55501 if (!task)
55502 goto out_no_task;
55503
55504 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55505 + goto out;
55506 +
55507 /*
55508 * Yes, it does not scale. And it should not. Don't add
55509 * new entries into /proc/<tgid>/ without very good reasons.
55510 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
55511 if (!task)
55512 goto out_no_task;
55513
55514 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55515 + goto out;
55516 +
55517 ret = 0;
55518 i = filp->f_pos;
55519 switch (i) {
55520 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55521 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55522 #endif
55523 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55524 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55525 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55526 INF("syscall", S_IRUGO, proc_pid_syscall),
55527 #endif
55528 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55529 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55530 #ifdef CONFIG_SECURITY
55531 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55532 #endif
55533 -#ifdef CONFIG_KALLSYMS
55534 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55535 INF("wchan", S_IRUGO, proc_pid_wchan),
55536 #endif
55537 -#ifdef CONFIG_STACKTRACE
55538 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55539 ONE("stack", S_IRUGO, proc_pid_stack),
55540 #endif
55541 #ifdef CONFIG_SCHEDSTATS
55542 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55543 #ifdef CONFIG_HARDWALL
55544 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55545 #endif
55546 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55547 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55548 +#endif
55549 #ifdef CONFIG_USER_NS
55550 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55551 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55552 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55553 if (!inode)
55554 goto out;
55555
55556 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55557 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55558 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55559 + inode->i_gid = grsec_proc_gid;
55560 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55561 +#else
55562 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55563 +#endif
55564 inode->i_op = &proc_tgid_base_inode_operations;
55565 inode->i_fop = &proc_tgid_base_operations;
55566 inode->i_flags|=S_IMMUTABLE;
55567 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55568 if (!task)
55569 goto out;
55570
55571 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55572 + goto out_put_task;
55573 +
55574 result = proc_pid_instantiate(dir, dentry, task, NULL);
55575 +out_put_task:
55576 put_task_struct(task);
55577 out:
55578 return result;
55579 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55580 static int fake_filldir(void *buf, const char *name, int namelen,
55581 loff_t offset, u64 ino, unsigned d_type)
55582 {
55583 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55584 + __buf->error = -EINVAL;
55585 return 0;
55586 }
55587
55588 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
55589 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55590 #endif
55591 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55592 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55593 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55594 INF("syscall", S_IRUGO, proc_pid_syscall),
55595 #endif
55596 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55597 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
55598 #ifdef CONFIG_SECURITY
55599 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55600 #endif
55601 -#ifdef CONFIG_KALLSYMS
55602 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55603 INF("wchan", S_IRUGO, proc_pid_wchan),
55604 #endif
55605 -#ifdef CONFIG_STACKTRACE
55606 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55607 ONE("stack", S_IRUGO, proc_pid_stack),
55608 #endif
55609 #ifdef CONFIG_SCHEDSTATS
55610 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55611 index 82676e3..5f8518a 100644
55612 --- a/fs/proc/cmdline.c
55613 +++ b/fs/proc/cmdline.c
55614 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55615
55616 static int __init proc_cmdline_init(void)
55617 {
55618 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55619 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55620 +#else
55621 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55622 +#endif
55623 return 0;
55624 }
55625 module_init(proc_cmdline_init);
55626 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55627 index b143471..bb105e5 100644
55628 --- a/fs/proc/devices.c
55629 +++ b/fs/proc/devices.c
55630 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55631
55632 static int __init proc_devices_init(void)
55633 {
55634 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55635 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55636 +#else
55637 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55638 +#endif
55639 return 0;
55640 }
55641 module_init(proc_devices_init);
55642 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55643 index d7a4a28..0201742 100644
55644 --- a/fs/proc/fd.c
55645 +++ b/fs/proc/fd.c
55646 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55647 if (!task)
55648 return -ENOENT;
55649
55650 - files = get_files_struct(task);
55651 + if (!gr_acl_handle_procpidmem(task))
55652 + files = get_files_struct(task);
55653 put_task_struct(task);
55654
55655 if (files) {
55656 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55657 */
55658 int proc_fd_permission(struct inode *inode, int mask)
55659 {
55660 + struct task_struct *task;
55661 int rv = generic_permission(inode, mask);
55662 - if (rv == 0)
55663 - return 0;
55664 +
55665 if (task_pid(current) == proc_pid(inode))
55666 rv = 0;
55667 +
55668 + task = get_proc_task(inode);
55669 + if (task == NULL)
55670 + return rv;
55671 +
55672 + if (gr_acl_handle_procpidmem(task))
55673 + rv = -EACCES;
55674 +
55675 + put_task_struct(task);
55676 +
55677 return rv;
55678 }
55679
55680 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55681 index 073aea6..0630370 100644
55682 --- a/fs/proc/inode.c
55683 +++ b/fs/proc/inode.c
55684 @@ -23,11 +23,17 @@
55685 #include <linux/slab.h>
55686 #include <linux/mount.h>
55687 #include <linux/magic.h>
55688 +#include <linux/grsecurity.h>
55689
55690 #include <asm/uaccess.h>
55691
55692 #include "internal.h"
55693
55694 +#ifdef CONFIG_PROC_SYSCTL
55695 +extern const struct inode_operations proc_sys_inode_operations;
55696 +extern const struct inode_operations proc_sys_dir_operations;
55697 +#endif
55698 +
55699 static void proc_evict_inode(struct inode *inode)
55700 {
55701 struct proc_dir_entry *de;
55702 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
55703 ns = PROC_I(inode)->ns.ns;
55704 if (ns_ops && ns)
55705 ns_ops->put(ns);
55706 +
55707 +#ifdef CONFIG_PROC_SYSCTL
55708 + if (inode->i_op == &proc_sys_inode_operations ||
55709 + inode->i_op == &proc_sys_dir_operations)
55710 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55711 +#endif
55712 +
55713 }
55714
55715 static struct kmem_cache * proc_inode_cachep;
55716 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55717 if (de->mode) {
55718 inode->i_mode = de->mode;
55719 inode->i_uid = de->uid;
55720 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55721 + inode->i_gid = grsec_proc_gid;
55722 +#else
55723 inode->i_gid = de->gid;
55724 +#endif
55725 }
55726 if (de->size)
55727 inode->i_size = de->size;
55728 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55729 index d600fb0..3b495fe 100644
55730 --- a/fs/proc/internal.h
55731 +++ b/fs/proc/internal.h
55732 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
55733 struct pid *, struct task_struct *);
55734 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
55735 struct pid *, struct task_struct *);
55736 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55737 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55738 +#endif
55739
55740 /*
55741 * base.c
55742 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55743 index 0a22194..a9fc8c1 100644
55744 --- a/fs/proc/kcore.c
55745 +++ b/fs/proc/kcore.c
55746 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55747 * the addresses in the elf_phdr on our list.
55748 */
55749 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55750 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55751 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55752 + if (tsz > buflen)
55753 tsz = buflen;
55754 -
55755 +
55756 while (buflen) {
55757 struct kcore_list *m;
55758
55759 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55760 kfree(elf_buf);
55761 } else {
55762 if (kern_addr_valid(start)) {
55763 - unsigned long n;
55764 + char *elf_buf;
55765 + mm_segment_t oldfs;
55766
55767 - n = copy_to_user(buffer, (char *)start, tsz);
55768 - /*
55769 - * We cannot distinguish between fault on source
55770 - * and fault on destination. When this happens
55771 - * we clear too and hope it will trigger the
55772 - * EFAULT again.
55773 - */
55774 - if (n) {
55775 - if (clear_user(buffer + tsz - n,
55776 - n))
55777 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55778 + if (!elf_buf)
55779 + return -ENOMEM;
55780 + oldfs = get_fs();
55781 + set_fs(KERNEL_DS);
55782 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55783 + set_fs(oldfs);
55784 + if (copy_to_user(buffer, elf_buf, tsz)) {
55785 + kfree(elf_buf);
55786 return -EFAULT;
55787 + }
55788 }
55789 + set_fs(oldfs);
55790 + kfree(elf_buf);
55791 } else {
55792 if (clear_user(buffer, tsz))
55793 return -EFAULT;
55794 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55795
55796 static int open_kcore(struct inode *inode, struct file *filp)
55797 {
55798 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55799 + return -EPERM;
55800 +#endif
55801 if (!capable(CAP_SYS_RAWIO))
55802 return -EPERM;
55803 if (kcore_need_update)
55804 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55805 index 5aa847a..f77c8d4 100644
55806 --- a/fs/proc/meminfo.c
55807 +++ b/fs/proc/meminfo.c
55808 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55809 vmi.used >> 10,
55810 vmi.largest_chunk >> 10
55811 #ifdef CONFIG_MEMORY_FAILURE
55812 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55813 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55814 #endif
55815 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55816 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55817 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55818 index ccfd99b..1b7e255 100644
55819 --- a/fs/proc/nommu.c
55820 +++ b/fs/proc/nommu.c
55821 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55822 if (len < 1)
55823 len = 1;
55824 seq_printf(m, "%*c", len, ' ');
55825 - seq_path(m, &file->f_path, "");
55826 + seq_path(m, &file->f_path, "\n\\");
55827 }
55828
55829 seq_putc(m, '\n');
55830 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55831 index 986e832..6e8e859 100644
55832 --- a/fs/proc/proc_net.c
55833 +++ b/fs/proc/proc_net.c
55834 @@ -23,6 +23,7 @@
55835 #include <linux/nsproxy.h>
55836 #include <net/net_namespace.h>
55837 #include <linux/seq_file.h>
55838 +#include <linux/grsecurity.h>
55839
55840 #include "internal.h"
55841
55842 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55843 struct task_struct *task;
55844 struct nsproxy *ns;
55845 struct net *net = NULL;
55846 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55847 + const struct cred *cred = current_cred();
55848 +#endif
55849 +
55850 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55851 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55852 + return net;
55853 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55854 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55855 + return net;
55856 +#endif
55857
55858 rcu_read_lock();
55859 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55860 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55861 index ac05f33..1e6dc7e 100644
55862 --- a/fs/proc/proc_sysctl.c
55863 +++ b/fs/proc/proc_sysctl.c
55864 @@ -13,11 +13,15 @@
55865 #include <linux/module.h>
55866 #include "internal.h"
55867
55868 +extern int gr_handle_chroot_sysctl(const int op);
55869 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55870 + const int op);
55871 +
55872 static const struct dentry_operations proc_sys_dentry_operations;
55873 static const struct file_operations proc_sys_file_operations;
55874 -static const struct inode_operations proc_sys_inode_operations;
55875 +const struct inode_operations proc_sys_inode_operations;
55876 static const struct file_operations proc_sys_dir_file_operations;
55877 -static const struct inode_operations proc_sys_dir_operations;
55878 +const struct inode_operations proc_sys_dir_operations;
55879
55880 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55881 {
55882 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55883
55884 err = NULL;
55885 d_set_d_op(dentry, &proc_sys_dentry_operations);
55886 +
55887 + gr_handle_proc_create(dentry, inode);
55888 +
55889 d_add(dentry, inode);
55890
55891 out:
55892 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55893 struct inode *inode = file_inode(filp);
55894 struct ctl_table_header *head = grab_header(inode);
55895 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55896 + int op = write ? MAY_WRITE : MAY_READ;
55897 ssize_t error;
55898 size_t res;
55899
55900 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55901 * and won't be until we finish.
55902 */
55903 error = -EPERM;
55904 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55905 + if (sysctl_perm(head, table, op))
55906 goto out;
55907
55908 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55909 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55910 if (!table->proc_handler)
55911 goto out;
55912
55913 +#ifdef CONFIG_GRKERNSEC
55914 + error = -EPERM;
55915 + if (gr_handle_chroot_sysctl(op))
55916 + goto out;
55917 + dget(filp->f_path.dentry);
55918 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55919 + dput(filp->f_path.dentry);
55920 + goto out;
55921 + }
55922 + dput(filp->f_path.dentry);
55923 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55924 + goto out;
55925 + if (write && !capable(CAP_SYS_ADMIN))
55926 + goto out;
55927 +#endif
55928 +
55929 /* careful: calling conventions are nasty here */
55930 res = count;
55931 error = table->proc_handler(table, write, buf, &res, ppos);
55932 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55933 return -ENOMEM;
55934 } else {
55935 d_set_d_op(child, &proc_sys_dentry_operations);
55936 +
55937 + gr_handle_proc_create(child, inode);
55938 +
55939 d_add(child, inode);
55940 }
55941 } else {
55942 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55943 if ((*pos)++ < file->f_pos)
55944 return 0;
55945
55946 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55947 + return 0;
55948 +
55949 if (unlikely(S_ISLNK(table->mode)))
55950 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55951 else
55952 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55953 if (IS_ERR(head))
55954 return PTR_ERR(head);
55955
55956 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55957 + return -ENOENT;
55958 +
55959 generic_fillattr(inode, stat);
55960 if (table)
55961 stat->mode = (stat->mode & S_IFMT) | table->mode;
55962 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55963 .llseek = generic_file_llseek,
55964 };
55965
55966 -static const struct inode_operations proc_sys_inode_operations = {
55967 +const struct inode_operations proc_sys_inode_operations = {
55968 .permission = proc_sys_permission,
55969 .setattr = proc_sys_setattr,
55970 .getattr = proc_sys_getattr,
55971 };
55972
55973 -static const struct inode_operations proc_sys_dir_operations = {
55974 +const struct inode_operations proc_sys_dir_operations = {
55975 .lookup = proc_sys_lookup,
55976 .permission = proc_sys_permission,
55977 .setattr = proc_sys_setattr,
55978 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55979 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55980 const char *name, int namelen)
55981 {
55982 - struct ctl_table *table;
55983 + ctl_table_no_const *table;
55984 struct ctl_dir *new;
55985 struct ctl_node *node;
55986 char *new_name;
55987 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55988 return NULL;
55989
55990 node = (struct ctl_node *)(new + 1);
55991 - table = (struct ctl_table *)(node + 1);
55992 + table = (ctl_table_no_const *)(node + 1);
55993 new_name = (char *)(table + 2);
55994 memcpy(new_name, name, namelen);
55995 new_name[namelen] = '\0';
55996 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55997 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55998 struct ctl_table_root *link_root)
55999 {
56000 - struct ctl_table *link_table, *entry, *link;
56001 + ctl_table_no_const *link_table, *link;
56002 + struct ctl_table *entry;
56003 struct ctl_table_header *links;
56004 struct ctl_node *node;
56005 char *link_name;
56006 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56007 return NULL;
56008
56009 node = (struct ctl_node *)(links + 1);
56010 - link_table = (struct ctl_table *)(node + nr_entries);
56011 + link_table = (ctl_table_no_const *)(node + nr_entries);
56012 link_name = (char *)&link_table[nr_entries + 1];
56013
56014 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56015 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56016 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56017 struct ctl_table *table)
56018 {
56019 - struct ctl_table *ctl_table_arg = NULL;
56020 - struct ctl_table *entry, *files;
56021 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56022 + struct ctl_table *entry;
56023 int nr_files = 0;
56024 int nr_dirs = 0;
56025 int err = -ENOMEM;
56026 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56027 nr_files++;
56028 }
56029
56030 - files = table;
56031 /* If there are mixed files and directories we need a new table */
56032 if (nr_dirs && nr_files) {
56033 - struct ctl_table *new;
56034 + ctl_table_no_const *new;
56035 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56036 GFP_KERNEL);
56037 if (!files)
56038 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56039 /* Register everything except a directory full of subdirectories */
56040 if (nr_files || !nr_dirs) {
56041 struct ctl_table_header *header;
56042 - header = __register_sysctl_table(set, path, files);
56043 + header = __register_sysctl_table(set, path, files ? files : table);
56044 if (!header) {
56045 kfree(ctl_table_arg);
56046 goto out;
56047 diff --git a/fs/proc/root.c b/fs/proc/root.c
56048 index 41a6ea9..23eaa92 100644
56049 --- a/fs/proc/root.c
56050 +++ b/fs/proc/root.c
56051 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
56052 #ifdef CONFIG_PROC_DEVICETREE
56053 proc_device_tree_init();
56054 #endif
56055 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56056 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56057 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56058 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56059 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56060 +#endif
56061 +#else
56062 proc_mkdir("bus", NULL);
56063 +#endif
56064 proc_sys_init();
56065 }
56066
56067 diff --git a/fs/proc/self.c b/fs/proc/self.c
56068 index 6b6a993..807cccc 100644
56069 --- a/fs/proc/self.c
56070 +++ b/fs/proc/self.c
56071 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56072 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56073 void *cookie)
56074 {
56075 - char *s = nd_get_link(nd);
56076 + const char *s = nd_get_link(nd);
56077 if (!IS_ERR(s))
56078 kfree(s);
56079 }
56080 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56081 index 3e636d8..83e3b71 100644
56082 --- a/fs/proc/task_mmu.c
56083 +++ b/fs/proc/task_mmu.c
56084 @@ -11,12 +11,19 @@
56085 #include <linux/rmap.h>
56086 #include <linux/swap.h>
56087 #include <linux/swapops.h>
56088 +#include <linux/grsecurity.h>
56089
56090 #include <asm/elf.h>
56091 #include <asm/uaccess.h>
56092 #include <asm/tlbflush.h>
56093 #include "internal.h"
56094
56095 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56096 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56097 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56098 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56099 +#endif
56100 +
56101 void task_mem(struct seq_file *m, struct mm_struct *mm)
56102 {
56103 unsigned long data, text, lib, swap;
56104 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56105 "VmExe:\t%8lu kB\n"
56106 "VmLib:\t%8lu kB\n"
56107 "VmPTE:\t%8lu kB\n"
56108 - "VmSwap:\t%8lu kB\n",
56109 - hiwater_vm << (PAGE_SHIFT-10),
56110 + "VmSwap:\t%8lu kB\n"
56111 +
56112 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56113 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56114 +#endif
56115 +
56116 + ,hiwater_vm << (PAGE_SHIFT-10),
56117 total_vm << (PAGE_SHIFT-10),
56118 mm->locked_vm << (PAGE_SHIFT-10),
56119 mm->pinned_vm << (PAGE_SHIFT-10),
56120 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56121 data << (PAGE_SHIFT-10),
56122 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56123 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56124 - swap << (PAGE_SHIFT-10));
56125 + swap << (PAGE_SHIFT-10)
56126 +
56127 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56128 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56129 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56130 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56131 +#else
56132 + , mm->context.user_cs_base
56133 + , mm->context.user_cs_limit
56134 +#endif
56135 +#endif
56136 +
56137 + );
56138 }
56139
56140 unsigned long task_vsize(struct mm_struct *mm)
56141 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56142 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56143 }
56144
56145 - /* We don't show the stack guard page in /proc/maps */
56146 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56147 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56148 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56149 +#else
56150 start = vma->vm_start;
56151 - if (stack_guard_page_start(vma, start))
56152 - start += PAGE_SIZE;
56153 end = vma->vm_end;
56154 - if (stack_guard_page_end(vma, end))
56155 - end -= PAGE_SIZE;
56156 +#endif
56157
56158 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56159 start,
56160 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56161 flags & VM_WRITE ? 'w' : '-',
56162 flags & VM_EXEC ? 'x' : '-',
56163 flags & VM_MAYSHARE ? 's' : 'p',
56164 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56165 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56166 +#else
56167 pgoff,
56168 +#endif
56169 MAJOR(dev), MINOR(dev), ino, &len);
56170
56171 /*
56172 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56173 */
56174 if (file) {
56175 pad_len_spaces(m, len);
56176 - seq_path(m, &file->f_path, "\n");
56177 + seq_path(m, &file->f_path, "\n\\");
56178 goto done;
56179 }
56180
56181 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56182 * Thread stack in /proc/PID/task/TID/maps or
56183 * the main process stack.
56184 */
56185 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56186 - vma->vm_end >= mm->start_stack)) {
56187 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56188 + (vma->vm_start <= mm->start_stack &&
56189 + vma->vm_end >= mm->start_stack)) {
56190 name = "[stack]";
56191 } else {
56192 /* Thread stack in /proc/PID/maps */
56193 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56194 struct proc_maps_private *priv = m->private;
56195 struct task_struct *task = priv->task;
56196
56197 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56198 + if (current->exec_id != m->exec_id) {
56199 + gr_log_badprocpid("maps");
56200 + return 0;
56201 + }
56202 +#endif
56203 +
56204 show_map_vma(m, vma, is_pid);
56205
56206 if (m->count < m->size) /* vma is copied successfully */
56207 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56208 .private = &mss,
56209 };
56210
56211 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56212 + if (current->exec_id != m->exec_id) {
56213 + gr_log_badprocpid("smaps");
56214 + return 0;
56215 + }
56216 +#endif
56217 memset(&mss, 0, sizeof mss);
56218 - mss.vma = vma;
56219 - /* mmap_sem is held in m_start */
56220 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56221 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56222 -
56223 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56224 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56225 +#endif
56226 + mss.vma = vma;
56227 + /* mmap_sem is held in m_start */
56228 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56229 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56230 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56231 + }
56232 +#endif
56233 show_map_vma(m, vma, is_pid);
56234
56235 seq_printf(m,
56236 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56237 "KernelPageSize: %8lu kB\n"
56238 "MMUPageSize: %8lu kB\n"
56239 "Locked: %8lu kB\n",
56240 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56241 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56242 +#else
56243 (vma->vm_end - vma->vm_start) >> 10,
56244 +#endif
56245 mss.resident >> 10,
56246 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56247 mss.shared_clean >> 10,
56248 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56249 int n;
56250 char buffer[50];
56251
56252 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56253 + if (current->exec_id != m->exec_id) {
56254 + gr_log_badprocpid("numa_maps");
56255 + return 0;
56256 + }
56257 +#endif
56258 +
56259 if (!mm)
56260 return 0;
56261
56262 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56263 mpol_to_str(buffer, sizeof(buffer), pol);
56264 mpol_cond_put(pol);
56265
56266 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56267 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56268 +#else
56269 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56270 +#endif
56271
56272 if (file) {
56273 seq_printf(m, " file=");
56274 - seq_path(m, &file->f_path, "\n\t= ");
56275 + seq_path(m, &file->f_path, "\n\t\\= ");
56276 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56277 seq_printf(m, " heap");
56278 } else {
56279 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56280 index 56123a6..5a2f6ec 100644
56281 --- a/fs/proc/task_nommu.c
56282 +++ b/fs/proc/task_nommu.c
56283 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56284 else
56285 bytes += kobjsize(mm);
56286
56287 - if (current->fs && current->fs->users > 1)
56288 + if (current->fs && atomic_read(&current->fs->users) > 1)
56289 sbytes += kobjsize(current->fs);
56290 else
56291 bytes += kobjsize(current->fs);
56292 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56293
56294 if (file) {
56295 pad_len_spaces(m, len);
56296 - seq_path(m, &file->f_path, "");
56297 + seq_path(m, &file->f_path, "\n\\");
56298 } else if (mm) {
56299 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56300
56301 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56302 index 17f7e08..e4b1529 100644
56303 --- a/fs/proc/vmcore.c
56304 +++ b/fs/proc/vmcore.c
56305 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56306 nr_bytes = count;
56307
56308 /* If pfn is not ram, return zeros for sparse dump files */
56309 - if (pfn_is_ram(pfn) == 0)
56310 - memset(buf, 0, nr_bytes);
56311 - else {
56312 + if (pfn_is_ram(pfn) == 0) {
56313 + if (userbuf) {
56314 + if (clear_user((char __force_user *)buf, nr_bytes))
56315 + return -EFAULT;
56316 + } else
56317 + memset(buf, 0, nr_bytes);
56318 + } else {
56319 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56320 offset, userbuf);
56321 if (tmp < 0)
56322 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56323 if (tsz > nr_bytes)
56324 tsz = nr_bytes;
56325
56326 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56327 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56328 if (tmp < 0)
56329 return tmp;
56330 buflen -= tsz;
56331 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56332 index b00fcc9..e0c6381 100644
56333 --- a/fs/qnx6/qnx6.h
56334 +++ b/fs/qnx6/qnx6.h
56335 @@ -74,7 +74,7 @@ enum {
56336 BYTESEX_BE,
56337 };
56338
56339 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56340 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56341 {
56342 if (sbi->s_bytesex == BYTESEX_LE)
56343 return le64_to_cpu((__force __le64)n);
56344 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56345 return (__force __fs64)cpu_to_be64(n);
56346 }
56347
56348 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56349 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56350 {
56351 if (sbi->s_bytesex == BYTESEX_LE)
56352 return le32_to_cpu((__force __le32)n);
56353 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56354 index 16e8abb..2dcf914 100644
56355 --- a/fs/quota/netlink.c
56356 +++ b/fs/quota/netlink.c
56357 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56358 void quota_send_warning(struct kqid qid, dev_t dev,
56359 const char warntype)
56360 {
56361 - static atomic_t seq;
56362 + static atomic_unchecked_t seq;
56363 struct sk_buff *skb;
56364 void *msg_head;
56365 int ret;
56366 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56367 "VFS: Not enough memory to send quota warning.\n");
56368 return;
56369 }
56370 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56371 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56372 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56373 if (!msg_head) {
56374 printk(KERN_ERR
56375 diff --git a/fs/read_write.c b/fs/read_write.c
56376 index 2cefa41..c7e2fe0 100644
56377 --- a/fs/read_write.c
56378 +++ b/fs/read_write.c
56379 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56380
56381 old_fs = get_fs();
56382 set_fs(get_ds());
56383 - p = (__force const char __user *)buf;
56384 + p = (const char __force_user *)buf;
56385 if (count > MAX_RW_COUNT)
56386 count = MAX_RW_COUNT;
56387 if (file->f_op->write)
56388 diff --git a/fs/readdir.c b/fs/readdir.c
56389 index fee38e0..12fdf47 100644
56390 --- a/fs/readdir.c
56391 +++ b/fs/readdir.c
56392 @@ -17,6 +17,7 @@
56393 #include <linux/security.h>
56394 #include <linux/syscalls.h>
56395 #include <linux/unistd.h>
56396 +#include <linux/namei.h>
56397
56398 #include <asm/uaccess.h>
56399
56400 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56401
56402 struct readdir_callback {
56403 struct old_linux_dirent __user * dirent;
56404 + struct file * file;
56405 int result;
56406 };
56407
56408 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56409 buf->result = -EOVERFLOW;
56410 return -EOVERFLOW;
56411 }
56412 +
56413 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56414 + return 0;
56415 +
56416 buf->result++;
56417 dirent = buf->dirent;
56418 if (!access_ok(VERIFY_WRITE, dirent,
56419 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56420
56421 buf.result = 0;
56422 buf.dirent = dirent;
56423 + buf.file = f.file;
56424
56425 error = vfs_readdir(f.file, fillonedir, &buf);
56426 if (buf.result)
56427 @@ -139,6 +146,7 @@ struct linux_dirent {
56428 struct getdents_callback {
56429 struct linux_dirent __user * current_dir;
56430 struct linux_dirent __user * previous;
56431 + struct file * file;
56432 int count;
56433 int error;
56434 };
56435 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56436 buf->error = -EOVERFLOW;
56437 return -EOVERFLOW;
56438 }
56439 +
56440 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56441 + return 0;
56442 +
56443 dirent = buf->previous;
56444 if (dirent) {
56445 if (__put_user(offset, &dirent->d_off))
56446 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56447 buf.previous = NULL;
56448 buf.count = count;
56449 buf.error = 0;
56450 + buf.file = f.file;
56451
56452 error = vfs_readdir(f.file, filldir, &buf);
56453 if (error >= 0)
56454 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56455 struct getdents_callback64 {
56456 struct linux_dirent64 __user * current_dir;
56457 struct linux_dirent64 __user * previous;
56458 + struct file *file;
56459 int count;
56460 int error;
56461 };
56462 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56463 buf->error = -EINVAL; /* only used if we fail.. */
56464 if (reclen > buf->count)
56465 return -EINVAL;
56466 +
56467 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56468 + return 0;
56469 +
56470 dirent = buf->previous;
56471 if (dirent) {
56472 if (__put_user(offset, &dirent->d_off))
56473 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56474
56475 buf.current_dir = dirent;
56476 buf.previous = NULL;
56477 + buf.file = f.file;
56478 buf.count = count;
56479 buf.error = 0;
56480
56481 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56482 error = buf.error;
56483 lastdirent = buf.previous;
56484 if (lastdirent) {
56485 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56486 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56487 if (__put_user(d_off, &lastdirent->d_off))
56488 error = -EFAULT;
56489 else
56490 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56491 index 2b7882b..1c5ef48 100644
56492 --- a/fs/reiserfs/do_balan.c
56493 +++ b/fs/reiserfs/do_balan.c
56494 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56495 return;
56496 }
56497
56498 - atomic_inc(&(fs_generation(tb->tb_sb)));
56499 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56500 do_balance_starts(tb);
56501
56502 /* balance leaf returns 0 except if combining L R and S into
56503 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56504 index 33532f7..4846ade 100644
56505 --- a/fs/reiserfs/procfs.c
56506 +++ b/fs/reiserfs/procfs.c
56507 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56508 "SMALL_TAILS " : "NO_TAILS ",
56509 replay_only(sb) ? "REPLAY_ONLY " : "",
56510 convert_reiserfs(sb) ? "CONV " : "",
56511 - atomic_read(&r->s_generation_counter),
56512 + atomic_read_unchecked(&r->s_generation_counter),
56513 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56514 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56515 SF(s_good_search_by_key_reada), SF(s_bmaps),
56516 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56517 index 157e474..65a6114 100644
56518 --- a/fs/reiserfs/reiserfs.h
56519 +++ b/fs/reiserfs/reiserfs.h
56520 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56521 /* Comment? -Hans */
56522 wait_queue_head_t s_wait;
56523 /* To be obsoleted soon by per buffer seals.. -Hans */
56524 - atomic_t s_generation_counter; // increased by one every time the
56525 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56526 // tree gets re-balanced
56527 unsigned long s_properties; /* File system properties. Currently holds
56528 on-disk FS format */
56529 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56530 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56531
56532 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56533 -#define get_generation(s) atomic_read (&fs_generation(s))
56534 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56535 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56536 #define __fs_changed(gen,s) (gen != get_generation (s))
56537 #define fs_changed(gen,s) \
56538 diff --git a/fs/select.c b/fs/select.c
56539 index 8c1c96c..a0f9b6d 100644
56540 --- a/fs/select.c
56541 +++ b/fs/select.c
56542 @@ -20,6 +20,7 @@
56543 #include <linux/export.h>
56544 #include <linux/slab.h>
56545 #include <linux/poll.h>
56546 +#include <linux/security.h>
56547 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56548 #include <linux/file.h>
56549 #include <linux/fdtable.h>
56550 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56551 struct poll_list *walk = head;
56552 unsigned long todo = nfds;
56553
56554 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56555 if (nfds > rlimit(RLIMIT_NOFILE))
56556 return -EINVAL;
56557
56558 diff --git a/fs/seq_file.c b/fs/seq_file.c
56559 index 774c1eb..b67582a 100644
56560 --- a/fs/seq_file.c
56561 +++ b/fs/seq_file.c
56562 @@ -10,6 +10,7 @@
56563 #include <linux/seq_file.h>
56564 #include <linux/slab.h>
56565 #include <linux/cred.h>
56566 +#include <linux/sched.h>
56567
56568 #include <asm/uaccess.h>
56569 #include <asm/page.h>
56570 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56571 #ifdef CONFIG_USER_NS
56572 p->user_ns = file->f_cred->user_ns;
56573 #endif
56574 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56575 + p->exec_id = current->exec_id;
56576 +#endif
56577
56578 /*
56579 * Wrappers around seq_open(e.g. swaps_open) need to be
56580 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56581 return 0;
56582 }
56583 if (!m->buf) {
56584 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56585 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56586 if (!m->buf)
56587 return -ENOMEM;
56588 }
56589 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56590 Eoverflow:
56591 m->op->stop(m, p);
56592 kfree(m->buf);
56593 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56594 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56595 return !m->buf ? -ENOMEM : -EAGAIN;
56596 }
56597
56598 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56599
56600 /* grab buffer if we didn't have one */
56601 if (!m->buf) {
56602 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56603 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56604 if (!m->buf)
56605 goto Enomem;
56606 }
56607 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56608 goto Fill;
56609 m->op->stop(m, p);
56610 kfree(m->buf);
56611 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56612 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56613 if (!m->buf)
56614 goto Enomem;
56615 m->count = 0;
56616 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56617 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56618 void *data)
56619 {
56620 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56621 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56622 int res = -ENOMEM;
56623
56624 if (op) {
56625 diff --git a/fs/splice.c b/fs/splice.c
56626 index d37431d..81c3044 100644
56627 --- a/fs/splice.c
56628 +++ b/fs/splice.c
56629 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56630 pipe_lock(pipe);
56631
56632 for (;;) {
56633 - if (!pipe->readers) {
56634 + if (!atomic_read(&pipe->readers)) {
56635 send_sig(SIGPIPE, current, 0);
56636 if (!ret)
56637 ret = -EPIPE;
56638 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56639 page_nr++;
56640 ret += buf->len;
56641
56642 - if (pipe->files)
56643 + if (atomic_read(&pipe->files))
56644 do_wakeup = 1;
56645
56646 if (!--spd->nr_pages)
56647 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56648 do_wakeup = 0;
56649 }
56650
56651 - pipe->waiting_writers++;
56652 + atomic_inc(&pipe->waiting_writers);
56653 pipe_wait(pipe);
56654 - pipe->waiting_writers--;
56655 + atomic_dec(&pipe->waiting_writers);
56656 }
56657
56658 pipe_unlock(pipe);
56659 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56660 old_fs = get_fs();
56661 set_fs(get_ds());
56662 /* The cast to a user pointer is valid due to the set_fs() */
56663 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56664 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56665 set_fs(old_fs);
56666
56667 return res;
56668 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56669 old_fs = get_fs();
56670 set_fs(get_ds());
56671 /* The cast to a user pointer is valid due to the set_fs() */
56672 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56673 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56674 set_fs(old_fs);
56675
56676 return res;
56677 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56678 goto err;
56679
56680 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56681 - vec[i].iov_base = (void __user *) page_address(page);
56682 + vec[i].iov_base = (void __force_user *) page_address(page);
56683 vec[i].iov_len = this_len;
56684 spd.pages[i] = page;
56685 spd.nr_pages++;
56686 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
56687 ops->release(pipe, buf);
56688 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
56689 pipe->nrbufs--;
56690 - if (pipe->files)
56691 + if (atomic_read(&pipe->files))
56692 sd->need_wakeup = true;
56693 }
56694
56695 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56696 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56697 {
56698 while (!pipe->nrbufs) {
56699 - if (!pipe->writers)
56700 + if (!atomic_read(&pipe->writers))
56701 return 0;
56702
56703 - if (!pipe->waiting_writers && sd->num_spliced)
56704 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56705 return 0;
56706
56707 if (sd->flags & SPLICE_F_NONBLOCK)
56708 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56709 * out of the pipe right after the splice_to_pipe(). So set
56710 * PIPE_READERS appropriately.
56711 */
56712 - pipe->readers = 1;
56713 + atomic_set(&pipe->readers, 1);
56714
56715 current->splice_pipe = pipe;
56716 }
56717 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56718 ret = -ERESTARTSYS;
56719 break;
56720 }
56721 - if (!pipe->writers)
56722 + if (!atomic_read(&pipe->writers))
56723 break;
56724 - if (!pipe->waiting_writers) {
56725 + if (!atomic_read(&pipe->waiting_writers)) {
56726 if (flags & SPLICE_F_NONBLOCK) {
56727 ret = -EAGAIN;
56728 break;
56729 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56730 pipe_lock(pipe);
56731
56732 while (pipe->nrbufs >= pipe->buffers) {
56733 - if (!pipe->readers) {
56734 + if (!atomic_read(&pipe->readers)) {
56735 send_sig(SIGPIPE, current, 0);
56736 ret = -EPIPE;
56737 break;
56738 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56739 ret = -ERESTARTSYS;
56740 break;
56741 }
56742 - pipe->waiting_writers++;
56743 + atomic_inc(&pipe->waiting_writers);
56744 pipe_wait(pipe);
56745 - pipe->waiting_writers--;
56746 + atomic_dec(&pipe->waiting_writers);
56747 }
56748
56749 pipe_unlock(pipe);
56750 @@ -1854,14 +1854,14 @@ retry:
56751 pipe_double_lock(ipipe, opipe);
56752
56753 do {
56754 - if (!opipe->readers) {
56755 + if (!atomic_read(&opipe->readers)) {
56756 send_sig(SIGPIPE, current, 0);
56757 if (!ret)
56758 ret = -EPIPE;
56759 break;
56760 }
56761
56762 - if (!ipipe->nrbufs && !ipipe->writers)
56763 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56764 break;
56765
56766 /*
56767 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56768 pipe_double_lock(ipipe, opipe);
56769
56770 do {
56771 - if (!opipe->readers) {
56772 + if (!atomic_read(&opipe->readers)) {
56773 send_sig(SIGPIPE, current, 0);
56774 if (!ret)
56775 ret = -EPIPE;
56776 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56777 * return EAGAIN if we have the potential of some data in the
56778 * future, otherwise just return 0
56779 */
56780 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56781 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56782 ret = -EAGAIN;
56783
56784 pipe_unlock(ipipe);
56785 diff --git a/fs/stat.c b/fs/stat.c
56786 index 04ce1ac..a13dd1e 100644
56787 --- a/fs/stat.c
56788 +++ b/fs/stat.c
56789 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56790 stat->gid = inode->i_gid;
56791 stat->rdev = inode->i_rdev;
56792 stat->size = i_size_read(inode);
56793 - stat->atime = inode->i_atime;
56794 - stat->mtime = inode->i_mtime;
56795 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56796 + stat->atime = inode->i_ctime;
56797 + stat->mtime = inode->i_ctime;
56798 + } else {
56799 + stat->atime = inode->i_atime;
56800 + stat->mtime = inode->i_mtime;
56801 + }
56802 stat->ctime = inode->i_ctime;
56803 stat->blksize = (1 << inode->i_blkbits);
56804 stat->blocks = inode->i_blocks;
56805 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56806 if (retval)
56807 return retval;
56808
56809 - if (inode->i_op->getattr)
56810 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56811 + if (inode->i_op->getattr) {
56812 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56813 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56814 + stat->atime = stat->ctime;
56815 + stat->mtime = stat->ctime;
56816 + }
56817 + return retval;
56818 + }
56819
56820 generic_fillattr(inode, stat);
56821 return 0;
56822 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56823 index 15c68f9..36a8b3e 100644
56824 --- a/fs/sysfs/bin.c
56825 +++ b/fs/sysfs/bin.c
56826 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56827 return ret;
56828 }
56829
56830 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56831 - void *buf, int len, int write)
56832 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56833 + void *buf, size_t len, int write)
56834 {
56835 struct file *file = vma->vm_file;
56836 struct bin_buffer *bb = file->private_data;
56837 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56838 - int ret;
56839 + ssize_t ret;
56840
56841 if (!bb->vm_ops)
56842 return -EINVAL;
56843 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56844 index e8e0e71..79c28ac5 100644
56845 --- a/fs/sysfs/dir.c
56846 +++ b/fs/sysfs/dir.c
56847 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56848 *
56849 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56850 */
56851 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56852 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56853 {
56854 unsigned long hash = init_name_hash();
56855 unsigned int len = strlen(name);
56856 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56857 struct sysfs_dirent *sd;
56858 int rc;
56859
56860 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56861 + const char *parent_name = parent_sd->s_name;
56862 +
56863 + mode = S_IFDIR | S_IRWXU;
56864 +
56865 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56866 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56867 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
56868 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56869 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56870 +#endif
56871 +
56872 /* allocate */
56873 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56874 if (!sd)
56875 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56876 index 602f56d..6853db8 100644
56877 --- a/fs/sysfs/file.c
56878 +++ b/fs/sysfs/file.c
56879 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56880
56881 struct sysfs_open_dirent {
56882 atomic_t refcnt;
56883 - atomic_t event;
56884 + atomic_unchecked_t event;
56885 wait_queue_head_t poll;
56886 struct list_head buffers; /* goes through sysfs_buffer.list */
56887 };
56888 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56889 if (!sysfs_get_active(attr_sd))
56890 return -ENODEV;
56891
56892 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56893 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56894 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56895
56896 sysfs_put_active(attr_sd);
56897 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56898 return -ENOMEM;
56899
56900 atomic_set(&new_od->refcnt, 0);
56901 - atomic_set(&new_od->event, 1);
56902 + atomic_set_unchecked(&new_od->event, 1);
56903 init_waitqueue_head(&new_od->poll);
56904 INIT_LIST_HEAD(&new_od->buffers);
56905 goto retry;
56906 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56907
56908 sysfs_put_active(attr_sd);
56909
56910 - if (buffer->event != atomic_read(&od->event))
56911 + if (buffer->event != atomic_read_unchecked(&od->event))
56912 goto trigger;
56913
56914 return DEFAULT_POLLMASK;
56915 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56916
56917 od = sd->s_attr.open;
56918 if (od) {
56919 - atomic_inc(&od->event);
56920 + atomic_inc_unchecked(&od->event);
56921 wake_up_interruptible(&od->poll);
56922 }
56923
56924 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56925 index 8c940df..25b733e 100644
56926 --- a/fs/sysfs/symlink.c
56927 +++ b/fs/sysfs/symlink.c
56928 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56929
56930 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56931 {
56932 - char *page = nd_get_link(nd);
56933 + const char *page = nd_get_link(nd);
56934 if (!IS_ERR(page))
56935 free_page((unsigned long)page);
56936 }
56937 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56938 index 69d4889..a810bd4 100644
56939 --- a/fs/sysv/sysv.h
56940 +++ b/fs/sysv/sysv.h
56941 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56942 #endif
56943 }
56944
56945 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56946 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56947 {
56948 if (sbi->s_bytesex == BYTESEX_PDP)
56949 return PDP_swab((__force __u32)n);
56950 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56951 index e18b988..f1d4ad0f 100644
56952 --- a/fs/ubifs/io.c
56953 +++ b/fs/ubifs/io.c
56954 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56955 return err;
56956 }
56957
56958 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56959 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56960 {
56961 int err;
56962
56963 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56964 index c175b4d..8f36a16 100644
56965 --- a/fs/udf/misc.c
56966 +++ b/fs/udf/misc.c
56967 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56968
56969 u8 udf_tag_checksum(const struct tag *t)
56970 {
56971 - u8 *data = (u8 *)t;
56972 + const u8 *data = (const u8 *)t;
56973 u8 checksum = 0;
56974 int i;
56975 for (i = 0; i < sizeof(struct tag); ++i)
56976 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56977 index 8d974c4..b82f6ec 100644
56978 --- a/fs/ufs/swab.h
56979 +++ b/fs/ufs/swab.h
56980 @@ -22,7 +22,7 @@ enum {
56981 BYTESEX_BE
56982 };
56983
56984 -static inline u64
56985 +static inline u64 __intentional_overflow(-1)
56986 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56987 {
56988 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56989 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56990 return (__force __fs64)cpu_to_be64(n);
56991 }
56992
56993 -static inline u32
56994 +static inline u32 __intentional_overflow(-1)
56995 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56996 {
56997 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56998 diff --git a/fs/utimes.c b/fs/utimes.c
56999 index f4fb7ec..3fe03c0 100644
57000 --- a/fs/utimes.c
57001 +++ b/fs/utimes.c
57002 @@ -1,6 +1,7 @@
57003 #include <linux/compiler.h>
57004 #include <linux/file.h>
57005 #include <linux/fs.h>
57006 +#include <linux/security.h>
57007 #include <linux/linkage.h>
57008 #include <linux/mount.h>
57009 #include <linux/namei.h>
57010 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
57011 goto mnt_drop_write_and_out;
57012 }
57013 }
57014 +
57015 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
57016 + error = -EACCES;
57017 + goto mnt_drop_write_and_out;
57018 + }
57019 +
57020 mutex_lock(&inode->i_mutex);
57021 error = notify_change(path->dentry, &newattrs);
57022 mutex_unlock(&inode->i_mutex);
57023 diff --git a/fs/xattr.c b/fs/xattr.c
57024 index 3377dff..4d074d9 100644
57025 --- a/fs/xattr.c
57026 +++ b/fs/xattr.c
57027 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
57028 return rc;
57029 }
57030
57031 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
57032 +ssize_t
57033 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
57034 +{
57035 + struct inode *inode = dentry->d_inode;
57036 + ssize_t error;
57037 +
57038 + error = inode_permission(inode, MAY_EXEC);
57039 + if (error)
57040 + return error;
57041 +
57042 + if (inode->i_op->getxattr)
57043 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
57044 + else
57045 + error = -EOPNOTSUPP;
57046 +
57047 + return error;
57048 +}
57049 +EXPORT_SYMBOL(pax_getxattr);
57050 +#endif
57051 +
57052 ssize_t
57053 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
57054 {
57055 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57056 * Extended attribute SET operations
57057 */
57058 static long
57059 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57060 +setxattr(struct path *path, const char __user *name, const void __user *value,
57061 size_t size, int flags)
57062 {
57063 int error;
57064 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57065 posix_acl_fix_xattr_from_user(kvalue, size);
57066 }
57067
57068 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57069 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57070 + error = -EACCES;
57071 + goto out;
57072 + }
57073 +
57074 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57075 out:
57076 if (vvalue)
57077 vfree(vvalue);
57078 @@ -377,7 +403,7 @@ retry:
57079 return error;
57080 error = mnt_want_write(path.mnt);
57081 if (!error) {
57082 - error = setxattr(path.dentry, name, value, size, flags);
57083 + error = setxattr(&path, name, value, size, flags);
57084 mnt_drop_write(path.mnt);
57085 }
57086 path_put(&path);
57087 @@ -401,7 +427,7 @@ retry:
57088 return error;
57089 error = mnt_want_write(path.mnt);
57090 if (!error) {
57091 - error = setxattr(path.dentry, name, value, size, flags);
57092 + error = setxattr(&path, name, value, size, flags);
57093 mnt_drop_write(path.mnt);
57094 }
57095 path_put(&path);
57096 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57097 const void __user *,value, size_t, size, int, flags)
57098 {
57099 struct fd f = fdget(fd);
57100 - struct dentry *dentry;
57101 int error = -EBADF;
57102
57103 if (!f.file)
57104 return error;
57105 - dentry = f.file->f_path.dentry;
57106 - audit_inode(NULL, dentry, 0);
57107 + audit_inode(NULL, f.file->f_path.dentry, 0);
57108 error = mnt_want_write_file(f.file);
57109 if (!error) {
57110 - error = setxattr(dentry, name, value, size, flags);
57111 + error = setxattr(&f.file->f_path, name, value, size, flags);
57112 mnt_drop_write_file(f.file);
57113 }
57114 fdput(f);
57115 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57116 index 9fbea87..6b19972 100644
57117 --- a/fs/xattr_acl.c
57118 +++ b/fs/xattr_acl.c
57119 @@ -76,8 +76,8 @@ struct posix_acl *
57120 posix_acl_from_xattr(struct user_namespace *user_ns,
57121 const void *value, size_t size)
57122 {
57123 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57124 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57125 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57126 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57127 int count;
57128 struct posix_acl *acl;
57129 struct posix_acl_entry *acl_e;
57130 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57131 index 8904284..ee0e14b 100644
57132 --- a/fs/xfs/xfs_bmap.c
57133 +++ b/fs/xfs/xfs_bmap.c
57134 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
57135
57136 #else
57137 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
57138 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57139 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
57140 #endif /* DEBUG */
57141
57142 /*
57143 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57144 index 6157424..ac98f6d 100644
57145 --- a/fs/xfs/xfs_dir2_sf.c
57146 +++ b/fs/xfs/xfs_dir2_sf.c
57147 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57148 }
57149
57150 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57151 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57152 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57153 + char name[sfep->namelen];
57154 + memcpy(name, sfep->name, sfep->namelen);
57155 + if (filldir(dirent, name, sfep->namelen,
57156 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57157 + *offset = off & 0x7fffffff;
57158 + return 0;
57159 + }
57160 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57161 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57162 *offset = off & 0x7fffffff;
57163 return 0;
57164 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57165 index 5e99968..45bd327 100644
57166 --- a/fs/xfs/xfs_ioctl.c
57167 +++ b/fs/xfs/xfs_ioctl.c
57168 @@ -127,7 +127,7 @@ xfs_find_handle(
57169 }
57170
57171 error = -EFAULT;
57172 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57173 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57174 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57175 goto out_put;
57176
57177 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57178 index ca9ecaa..60100c7 100644
57179 --- a/fs/xfs/xfs_iops.c
57180 +++ b/fs/xfs/xfs_iops.c
57181 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57182 struct nameidata *nd,
57183 void *p)
57184 {
57185 - char *s = nd_get_link(nd);
57186 + const char *s = nd_get_link(nd);
57187
57188 if (!IS_ERR(s))
57189 kfree(s);
57190 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57191 new file mode 100644
57192 index 0000000..c9c4ac3
57193 --- /dev/null
57194 +++ b/grsecurity/Kconfig
57195 @@ -0,0 +1,1054 @@
57196 +#
57197 +# grecurity configuration
57198 +#
57199 +menu "Memory Protections"
57200 +depends on GRKERNSEC
57201 +
57202 +config GRKERNSEC_KMEM
57203 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57204 + default y if GRKERNSEC_CONFIG_AUTO
57205 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57206 + help
57207 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57208 + be written to or read from to modify or leak the contents of the running
57209 + kernel. /dev/port will also not be allowed to be opened and support
57210 + for /dev/cpu/*/msr will be removed. If you have module
57211 + support disabled, enabling this will close up five ways that are
57212 + currently used to insert malicious code into the running kernel.
57213 +
57214 + Even with all these features enabled, we still highly recommend that
57215 + you use the RBAC system, as it is still possible for an attacker to
57216 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57217 +
57218 + If you are not using XFree86, you may be able to stop this additional
57219 + case by enabling the 'Disable privileged I/O' option. Though nothing
57220 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57221 + but only to video memory, which is the only writing we allow in this
57222 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57223 + not be allowed to mprotect it with PROT_WRITE later.
57224 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57225 + from working.
57226 +
57227 + It is highly recommended that you say Y here if you meet all the
57228 + conditions above.
57229 +
57230 +config GRKERNSEC_VM86
57231 + bool "Restrict VM86 mode"
57232 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57233 + depends on X86_32
57234 +
57235 + help
57236 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57237 + make use of a special execution mode on 32bit x86 processors called
57238 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57239 + video cards and will still work with this option enabled. The purpose
57240 + of the option is to prevent exploitation of emulation errors in
57241 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57242 + Nearly all users should be able to enable this option.
57243 +
57244 +config GRKERNSEC_IO
57245 + bool "Disable privileged I/O"
57246 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57247 + depends on X86
57248 + select RTC_CLASS
57249 + select RTC_INTF_DEV
57250 + select RTC_DRV_CMOS
57251 +
57252 + help
57253 + If you say Y here, all ioperm and iopl calls will return an error.
57254 + Ioperm and iopl can be used to modify the running kernel.
57255 + Unfortunately, some programs need this access to operate properly,
57256 + the most notable of which are XFree86 and hwclock. hwclock can be
57257 + remedied by having RTC support in the kernel, so real-time
57258 + clock support is enabled if this option is enabled, to ensure
57259 + that hwclock operates correctly. XFree86 still will not
57260 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57261 + IF YOU USE XFree86. If you use XFree86 and you still want to
57262 + protect your kernel against modification, use the RBAC system.
57263 +
57264 +config GRKERNSEC_JIT_HARDEN
57265 + bool "Harden BPF JIT against spray attacks"
57266 + default y if GRKERNSEC_CONFIG_AUTO
57267 + depends on BPF_JIT
57268 + help
57269 + If you say Y here, the native code generated by the kernel's Berkeley
57270 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57271 + attacks that attempt to fit attacker-beneficial instructions in
57272 + 32bit immediate fields of JIT-generated native instructions. The
57273 + attacker will generally aim to cause an unintended instruction sequence
57274 + of JIT-generated native code to execute by jumping into the middle of
57275 + a generated instruction. This feature effectively randomizes the 32bit
57276 + immediate constants present in the generated code to thwart such attacks.
57277 +
57278 + If you're using KERNEXEC, it's recommended that you enable this option
57279 + to supplement the hardening of the kernel.
57280 +
57281 +config GRKERNSEC_PERF_HARDEN
57282 + bool "Disable unprivileged PERF_EVENTS usage by default"
57283 + default y if GRKERNSEC_CONFIG_AUTO
57284 + depends on PERF_EVENTS
57285 + help
57286 + If you say Y here, the range of acceptable values for the
57287 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57288 + default to a new value: 3. When the sysctl is set to this value, no
57289 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57290 +
57291 + Though PERF_EVENTS can be used legitimately for performance monitoring
57292 + and low-level application profiling, it is forced on regardless of
57293 + configuration, has been at fault for several vulnerabilities, and
57294 + creates new opportunities for side channels and other information leaks.
57295 +
57296 + This feature puts PERF_EVENTS into a secure default state and permits
57297 + the administrator to change out of it temporarily if unprivileged
57298 + application profiling is needed.
57299 +
57300 +config GRKERNSEC_RAND_THREADSTACK
57301 + bool "Insert random gaps between thread stacks"
57302 + default y if GRKERNSEC_CONFIG_AUTO
57303 + depends on PAX_RANDMMAP && !PPC
57304 + help
57305 + If you say Y here, a random-sized gap will be enforced between allocated
57306 + thread stacks. Glibc's NPTL and other threading libraries that
57307 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57308 + The implementation currently provides 8 bits of entropy for the gap.
57309 +
57310 + Many distributions do not compile threaded remote services with the
57311 + -fstack-check argument to GCC, causing the variable-sized stack-based
57312 + allocator, alloca(), to not probe the stack on allocation. This
57313 + permits an unbounded alloca() to skip over any guard page and potentially
57314 + modify another thread's stack reliably. An enforced random gap
57315 + reduces the reliability of such an attack and increases the chance
57316 + that such a read/write to another thread's stack instead lands in
57317 + an unmapped area, causing a crash and triggering grsecurity's
57318 + anti-bruteforcing logic.
57319 +
57320 +config GRKERNSEC_PROC_MEMMAP
57321 + bool "Harden ASLR against information leaks and entropy reduction"
57322 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57323 + depends on PAX_NOEXEC || PAX_ASLR
57324 + help
57325 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57326 + give no information about the addresses of its mappings if
57327 + PaX features that rely on random addresses are enabled on the task.
57328 + In addition to sanitizing this information and disabling other
57329 + dangerous sources of information, this option causes reads of sensitive
57330 + /proc/<pid> entries where the file descriptor was opened in a different
57331 + task than the one performing the read. Such attempts are logged.
57332 + This option also limits argv/env strings for suid/sgid binaries
57333 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57334 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57335 + binaries to prevent alternative mmap layouts from being abused.
57336 +
57337 + If you use PaX it is essential that you say Y here as it closes up
57338 + several holes that make full ASLR useless locally.
57339 +
57340 +config GRKERNSEC_BRUTE
57341 + bool "Deter exploit bruteforcing"
57342 + default y if GRKERNSEC_CONFIG_AUTO
57343 + help
57344 + If you say Y here, attempts to bruteforce exploits against forking
57345 + daemons such as apache or sshd, as well as against suid/sgid binaries
57346 + will be deterred. When a child of a forking daemon is killed by PaX
57347 + or crashes due to an illegal instruction or other suspicious signal,
57348 + the parent process will be delayed 30 seconds upon every subsequent
57349 + fork until the administrator is able to assess the situation and
57350 + restart the daemon.
57351 + In the suid/sgid case, the attempt is logged, the user has all their
57352 + existing instances of the suid/sgid binary terminated and will
57353 + be unable to execute any suid/sgid binaries for 15 minutes.
57354 +
57355 + It is recommended that you also enable signal logging in the auditing
57356 + section so that logs are generated when a process triggers a suspicious
57357 + signal.
57358 + If the sysctl option is enabled, a sysctl option with name
57359 + "deter_bruteforce" is created.
57360 +
57361 +
57362 +config GRKERNSEC_MODHARDEN
57363 + bool "Harden module auto-loading"
57364 + default y if GRKERNSEC_CONFIG_AUTO
57365 + depends on MODULES
57366 + help
57367 + If you say Y here, module auto-loading in response to use of some
57368 + feature implemented by an unloaded module will be restricted to
57369 + root users. Enabling this option helps defend against attacks
57370 + by unprivileged users who abuse the auto-loading behavior to
57371 + cause a vulnerable module to load that is then exploited.
57372 +
57373 + If this option prevents a legitimate use of auto-loading for a
57374 + non-root user, the administrator can execute modprobe manually
57375 + with the exact name of the module mentioned in the alert log.
57376 + Alternatively, the administrator can add the module to the list
57377 + of modules loaded at boot by modifying init scripts.
57378 +
57379 + Modification of init scripts will most likely be needed on
57380 + Ubuntu servers with encrypted home directory support enabled,
57381 + as the first non-root user logging in will cause the ecb(aes),
57382 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57383 +
57384 +config GRKERNSEC_HIDESYM
57385 + bool "Hide kernel symbols"
57386 + default y if GRKERNSEC_CONFIG_AUTO
57387 + select PAX_USERCOPY_SLABS
57388 + help
57389 + If you say Y here, getting information on loaded modules, and
57390 + displaying all kernel symbols through a syscall will be restricted
57391 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57392 + /proc/kallsyms will be restricted to the root user. The RBAC
57393 + system can hide that entry even from root.
57394 +
57395 + This option also prevents leaking of kernel addresses through
57396 + several /proc entries.
57397 +
57398 + Note that this option is only effective provided the following
57399 + conditions are met:
57400 + 1) The kernel using grsecurity is not precompiled by some distribution
57401 + 2) You have also enabled GRKERNSEC_DMESG
57402 + 3) You are using the RBAC system and hiding other files such as your
57403 + kernel image and System.map. Alternatively, enabling this option
57404 + causes the permissions on /boot, /lib/modules, and the kernel
57405 + source directory to change at compile time to prevent
57406 + reading by non-root users.
57407 + If the above conditions are met, this option will aid in providing a
57408 + useful protection against local kernel exploitation of overflows
57409 + and arbitrary read/write vulnerabilities.
57410 +
57411 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57412 + in addition to this feature.
57413 +
57414 +config GRKERNSEC_KERN_LOCKOUT
57415 + bool "Active kernel exploit response"
57416 + default y if GRKERNSEC_CONFIG_AUTO
57417 + depends on X86 || ARM || PPC || SPARC
57418 + help
57419 + If you say Y here, when a PaX alert is triggered due to suspicious
57420 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57421 + or an OOPS occurs due to bad memory accesses, instead of just
57422 + terminating the offending process (and potentially allowing
57423 + a subsequent exploit from the same user), we will take one of two
57424 + actions:
57425 + If the user was root, we will panic the system
57426 + If the user was non-root, we will log the attempt, terminate
57427 + all processes owned by the user, then prevent them from creating
57428 + any new processes until the system is restarted
57429 + This deters repeated kernel exploitation/bruteforcing attempts
57430 + and is useful for later forensics.
57431 +
57432 +endmenu
57433 +menu "Role Based Access Control Options"
57434 +depends on GRKERNSEC
57435 +
57436 +config GRKERNSEC_RBAC_DEBUG
57437 + bool
57438 +
57439 +config GRKERNSEC_NO_RBAC
57440 + bool "Disable RBAC system"
57441 + help
57442 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57443 + preventing the RBAC system from being enabled. You should only say Y
57444 + here if you have no intention of using the RBAC system, so as to prevent
57445 + an attacker with root access from misusing the RBAC system to hide files
57446 + and processes when loadable module support and /dev/[k]mem have been
57447 + locked down.
57448 +
57449 +config GRKERNSEC_ACL_HIDEKERN
57450 + bool "Hide kernel processes"
57451 + help
57452 + If you say Y here, all kernel threads will be hidden to all
57453 + processes but those whose subject has the "view hidden processes"
57454 + flag.
57455 +
57456 +config GRKERNSEC_ACL_MAXTRIES
57457 + int "Maximum tries before password lockout"
57458 + default 3
57459 + help
57460 + This option enforces the maximum number of times a user can attempt
57461 + to authorize themselves with the grsecurity RBAC system before being
57462 + denied the ability to attempt authorization again for a specified time.
57463 + The lower the number, the harder it will be to brute-force a password.
57464 +
57465 +config GRKERNSEC_ACL_TIMEOUT
57466 + int "Time to wait after max password tries, in seconds"
57467 + default 30
57468 + help
57469 + This option specifies the time the user must wait after attempting to
57470 + authorize to the RBAC system with the maximum number of invalid
57471 + passwords. The higher the number, the harder it will be to brute-force
57472 + a password.
57473 +
57474 +endmenu
57475 +menu "Filesystem Protections"
57476 +depends on GRKERNSEC
57477 +
57478 +config GRKERNSEC_PROC
57479 + bool "Proc restrictions"
57480 + default y if GRKERNSEC_CONFIG_AUTO
57481 + help
57482 + If you say Y here, the permissions of the /proc filesystem
57483 + will be altered to enhance system security and privacy. You MUST
57484 + choose either a user only restriction or a user and group restriction.
57485 + Depending upon the option you choose, you can either restrict users to
57486 + see only the processes they themselves run, or choose a group that can
57487 + view all processes and files normally restricted to root if you choose
57488 + the "restrict to user only" option. NOTE: If you're running identd or
57489 + ntpd as a non-root user, you will have to run it as the group you
57490 + specify here.
57491 +
57492 +config GRKERNSEC_PROC_USER
57493 + bool "Restrict /proc to user only"
57494 + depends on GRKERNSEC_PROC
57495 + help
57496 + If you say Y here, non-root users will only be able to view their own
57497 + processes, and restricts them from viewing network-related information,
57498 + and viewing kernel symbol and module information.
57499 +
57500 +config GRKERNSEC_PROC_USERGROUP
57501 + bool "Allow special group"
57502 + default y if GRKERNSEC_CONFIG_AUTO
57503 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57504 + help
57505 + If you say Y here, you will be able to select a group that will be
57506 + able to view all processes and network-related information. If you've
57507 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57508 + remain hidden. This option is useful if you want to run identd as
57509 + a non-root user. The group you select may also be chosen at boot time
57510 + via "grsec_proc_gid=" on the kernel commandline.
57511 +
57512 +config GRKERNSEC_PROC_GID
57513 + int "GID for special group"
57514 + depends on GRKERNSEC_PROC_USERGROUP
57515 + default 1001
57516 +
57517 +config GRKERNSEC_PROC_ADD
57518 + bool "Additional restrictions"
57519 + default y if GRKERNSEC_CONFIG_AUTO
57520 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57521 + help
57522 + If you say Y here, additional restrictions will be placed on
57523 + /proc that keep normal users from viewing device information and
57524 + slabinfo information that could be useful for exploits.
57525 +
57526 +config GRKERNSEC_LINK
57527 + bool "Linking restrictions"
57528 + default y if GRKERNSEC_CONFIG_AUTO
57529 + help
57530 + If you say Y here, /tmp race exploits will be prevented, since users
57531 + will no longer be able to follow symlinks owned by other users in
57532 + world-writable +t directories (e.g. /tmp), unless the owner of the
57533 + symlink is the owner of the directory. users will also not be
57534 + able to hardlink to files they do not own. If the sysctl option is
57535 + enabled, a sysctl option with name "linking_restrictions" is created.
57536 +
57537 +config GRKERNSEC_SYMLINKOWN
57538 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57539 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57540 + help
57541 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57542 + that prevents it from being used as a security feature. As Apache
57543 + verifies the symlink by performing a stat() against the target of
57544 + the symlink before it is followed, an attacker can setup a symlink
57545 + to point to a same-owned file, then replace the symlink with one
57546 + that targets another user's file just after Apache "validates" the
57547 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57548 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57549 + will be in place for the group you specify. If the sysctl option
57550 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57551 + created.
57552 +
57553 +config GRKERNSEC_SYMLINKOWN_GID
57554 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57555 + depends on GRKERNSEC_SYMLINKOWN
57556 + default 1006
57557 + help
57558 + Setting this GID determines what group kernel-enforced
57559 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57560 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57561 +
57562 +config GRKERNSEC_FIFO
57563 + bool "FIFO restrictions"
57564 + default y if GRKERNSEC_CONFIG_AUTO
57565 + help
57566 + If you say Y here, users will not be able to write to FIFOs they don't
57567 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57568 + the FIFO is the same owner of the directory it's held in. If the sysctl
57569 + option is enabled, a sysctl option with name "fifo_restrictions" is
57570 + created.
57571 +
57572 +config GRKERNSEC_SYSFS_RESTRICT
57573 + bool "Sysfs/debugfs restriction"
57574 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57575 + depends on SYSFS
57576 + help
57577 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57578 + any filesystem normally mounted under it (e.g. debugfs) will be
57579 + mostly accessible only by root. These filesystems generally provide access
57580 + to hardware and debug information that isn't appropriate for unprivileged
57581 + users of the system. Sysfs and debugfs have also become a large source
57582 + of new vulnerabilities, ranging from infoleaks to local compromise.
57583 + There has been very little oversight with an eye toward security involved
57584 + in adding new exporters of information to these filesystems, so their
57585 + use is discouraged.
57586 + For reasons of compatibility, a few directories have been whitelisted
57587 + for access by non-root users:
57588 + /sys/fs/selinux
57589 + /sys/fs/fuse
57590 + /sys/devices/system/cpu
57591 +
57592 +config GRKERNSEC_ROFS
57593 + bool "Runtime read-only mount protection"
57594 + help
57595 + If you say Y here, a sysctl option with name "romount_protect" will
57596 + be created. By setting this option to 1 at runtime, filesystems
57597 + will be protected in the following ways:
57598 + * No new writable mounts will be allowed
57599 + * Existing read-only mounts won't be able to be remounted read/write
57600 + * Write operations will be denied on all block devices
57601 + This option acts independently of grsec_lock: once it is set to 1,
57602 + it cannot be turned off. Therefore, please be mindful of the resulting
57603 + behavior if this option is enabled in an init script on a read-only
57604 + filesystem. This feature is mainly intended for secure embedded systems.
57605 +
57606 +config GRKERNSEC_DEVICE_SIDECHANNEL
57607 + bool "Eliminate stat/notify-based device sidechannels"
57608 + default y if GRKERNSEC_CONFIG_AUTO
57609 + help
57610 + If you say Y here, timing analyses on block or character
57611 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57612 + will be thwarted for unprivileged users. If a process without
57613 + CAP_MKNOD stats such a device, the last access and last modify times
57614 + will match the device's create time. No access or modify events
57615 + will be triggered through inotify/dnotify/fanotify for such devices.
57616 + This feature will prevent attacks that may at a minimum
57617 + allow an attacker to determine the administrator's password length.
57618 +
57619 +config GRKERNSEC_CHROOT
57620 + bool "Chroot jail restrictions"
57621 + default y if GRKERNSEC_CONFIG_AUTO
57622 + help
57623 + If you say Y here, you will be able to choose several options that will
57624 + make breaking out of a chrooted jail much more difficult. If you
57625 + encounter no software incompatibilities with the following options, it
57626 + is recommended that you enable each one.
57627 +
57628 +config GRKERNSEC_CHROOT_MOUNT
57629 + bool "Deny mounts"
57630 + default y if GRKERNSEC_CONFIG_AUTO
57631 + depends on GRKERNSEC_CHROOT
57632 + help
57633 + If you say Y here, processes inside a chroot will not be able to
57634 + mount or remount filesystems. If the sysctl option is enabled, a
57635 + sysctl option with name "chroot_deny_mount" is created.
57636 +
57637 +config GRKERNSEC_CHROOT_DOUBLE
57638 + bool "Deny double-chroots"
57639 + default y if GRKERNSEC_CONFIG_AUTO
57640 + depends on GRKERNSEC_CHROOT
57641 + help
57642 + If you say Y here, processes inside a chroot will not be able to chroot
57643 + again outside the chroot. This is a widely used method of breaking
57644 + out of a chroot jail and should not be allowed. If the sysctl
57645 + option is enabled, a sysctl option with name
57646 + "chroot_deny_chroot" is created.
57647 +
57648 +config GRKERNSEC_CHROOT_PIVOT
57649 + bool "Deny pivot_root in chroot"
57650 + default y if GRKERNSEC_CONFIG_AUTO
57651 + depends on GRKERNSEC_CHROOT
57652 + help
57653 + If you say Y here, processes inside a chroot will not be able to use
57654 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57655 + works similar to chroot in that it changes the root filesystem. This
57656 + function could be misused in a chrooted process to attempt to break out
57657 + of the chroot, and therefore should not be allowed. If the sysctl
57658 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57659 + created.
57660 +
57661 +config GRKERNSEC_CHROOT_CHDIR
57662 + bool "Enforce chdir(\"/\") on all chroots"
57663 + default y if GRKERNSEC_CONFIG_AUTO
57664 + depends on GRKERNSEC_CHROOT
57665 + help
57666 + If you say Y here, the current working directory of all newly-chrooted
57667 + applications will be set to the the root directory of the chroot.
57668 + The man page on chroot(2) states:
57669 + Note that this call does not change the current working
57670 + directory, so that `.' can be outside the tree rooted at
57671 + `/'. In particular, the super-user can escape from a
57672 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57673 +
57674 + It is recommended that you say Y here, since it's not known to break
57675 + any software. If the sysctl option is enabled, a sysctl option with
57676 + name "chroot_enforce_chdir" is created.
57677 +
57678 +config GRKERNSEC_CHROOT_CHMOD
57679 + bool "Deny (f)chmod +s"
57680 + default y if GRKERNSEC_CONFIG_AUTO
57681 + depends on GRKERNSEC_CHROOT
57682 + help
57683 + If you say Y here, processes inside a chroot will not be able to chmod
57684 + or fchmod files to make them have suid or sgid bits. This protects
57685 + against another published method of breaking a chroot. If the sysctl
57686 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57687 + created.
57688 +
57689 +config GRKERNSEC_CHROOT_FCHDIR
57690 + bool "Deny fchdir out of chroot"
57691 + default y if GRKERNSEC_CONFIG_AUTO
57692 + depends on GRKERNSEC_CHROOT
57693 + help
57694 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57695 + to a file descriptor of the chrooting process that points to a directory
57696 + outside the filesystem will be stopped. If the sysctl option
57697 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57698 +
57699 +config GRKERNSEC_CHROOT_MKNOD
57700 + bool "Deny mknod"
57701 + default y if GRKERNSEC_CONFIG_AUTO
57702 + depends on GRKERNSEC_CHROOT
57703 + help
57704 + If you say Y here, processes inside a chroot will not be allowed to
57705 + mknod. The problem with using mknod inside a chroot is that it
57706 + would allow an attacker to create a device entry that is the same
57707 + as one on the physical root of your system, which could range from
57708 + anything from the console device to a device for your harddrive (which
57709 + they could then use to wipe the drive or steal data). It is recommended
57710 + that you say Y here, unless you run into software incompatibilities.
57711 + If the sysctl option is enabled, a sysctl option with name
57712 + "chroot_deny_mknod" is created.
57713 +
57714 +config GRKERNSEC_CHROOT_SHMAT
57715 + bool "Deny shmat() out of chroot"
57716 + default y if GRKERNSEC_CONFIG_AUTO
57717 + depends on GRKERNSEC_CHROOT
57718 + help
57719 + If you say Y here, processes inside a chroot will not be able to attach
57720 + to shared memory segments that were created outside of the chroot jail.
57721 + It is recommended that you say Y here. If the sysctl option is enabled,
57722 + a sysctl option with name "chroot_deny_shmat" is created.
57723 +
57724 +config GRKERNSEC_CHROOT_UNIX
57725 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57726 + default y if GRKERNSEC_CONFIG_AUTO
57727 + depends on GRKERNSEC_CHROOT
57728 + help
57729 + If you say Y here, processes inside a chroot will not be able to
57730 + connect to abstract (meaning not belonging to a filesystem) Unix
57731 + domain sockets that were bound outside of a chroot. It is recommended
57732 + that you say Y here. If the sysctl option is enabled, a sysctl option
57733 + with name "chroot_deny_unix" is created.
57734 +
57735 +config GRKERNSEC_CHROOT_FINDTASK
57736 + bool "Protect outside processes"
57737 + default y if GRKERNSEC_CONFIG_AUTO
57738 + depends on GRKERNSEC_CHROOT
57739 + help
57740 + If you say Y here, processes inside a chroot will not be able to
57741 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57742 + getsid, or view any process outside of the chroot. If the sysctl
57743 + option is enabled, a sysctl option with name "chroot_findtask" is
57744 + created.
57745 +
57746 +config GRKERNSEC_CHROOT_NICE
57747 + bool "Restrict priority changes"
57748 + default y if GRKERNSEC_CONFIG_AUTO
57749 + depends on GRKERNSEC_CHROOT
57750 + help
57751 + If you say Y here, processes inside a chroot will not be able to raise
57752 + the priority of processes in the chroot, or alter the priority of
57753 + processes outside the chroot. This provides more security than simply
57754 + removing CAP_SYS_NICE from the process' capability set. If the
57755 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57756 + is created.
57757 +
57758 +config GRKERNSEC_CHROOT_SYSCTL
57759 + bool "Deny sysctl writes"
57760 + default y if GRKERNSEC_CONFIG_AUTO
57761 + depends on GRKERNSEC_CHROOT
57762 + help
57763 + If you say Y here, an attacker in a chroot will not be able to
57764 + write to sysctl entries, either by sysctl(2) or through a /proc
57765 + interface. It is strongly recommended that you say Y here. If the
57766 + sysctl option is enabled, a sysctl option with name
57767 + "chroot_deny_sysctl" is created.
57768 +
57769 +config GRKERNSEC_CHROOT_CAPS
57770 + bool "Capability restrictions"
57771 + default y if GRKERNSEC_CONFIG_AUTO
57772 + depends on GRKERNSEC_CHROOT
57773 + help
57774 + If you say Y here, the capabilities on all processes within a
57775 + chroot jail will be lowered to stop module insertion, raw i/o,
57776 + system and net admin tasks, rebooting the system, modifying immutable
57777 + files, modifying IPC owned by another, and changing the system time.
57778 + This is left an option because it can break some apps. Disable this
57779 + if your chrooted apps are having problems performing those kinds of
57780 + tasks. If the sysctl option is enabled, a sysctl option with
57781 + name "chroot_caps" is created.
57782 +
57783 +config GRKERNSEC_CHROOT_INITRD
57784 + bool "Exempt initrd tasks from restrictions"
57785 + default y if GRKERNSEC_CONFIG_AUTO
57786 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57787 + help
57788 + If you say Y here, tasks started prior to init will be exempted from
57789 + grsecurity's chroot restrictions. This option is mainly meant to
57790 + resolve Plymouth's performing privileged operations unnecessarily
57791 + in a chroot.
57792 +
57793 +endmenu
57794 +menu "Kernel Auditing"
57795 +depends on GRKERNSEC
57796 +
57797 +config GRKERNSEC_AUDIT_GROUP
57798 + bool "Single group for auditing"
57799 + help
57800 + If you say Y here, the exec and chdir logging features will only operate
57801 + on a group you specify. This option is recommended if you only want to
57802 + watch certain users instead of having a large amount of logs from the
57803 + entire system. If the sysctl option is enabled, a sysctl option with
57804 + name "audit_group" is created.
57805 +
57806 +config GRKERNSEC_AUDIT_GID
57807 + int "GID for auditing"
57808 + depends on GRKERNSEC_AUDIT_GROUP
57809 + default 1007
57810 +
57811 +config GRKERNSEC_EXECLOG
57812 + bool "Exec logging"
57813 + help
57814 + If you say Y here, all execve() calls will be logged (since the
57815 + other exec*() calls are frontends to execve(), all execution
57816 + will be logged). Useful for shell-servers that like to keep track
57817 + of their users. If the sysctl option is enabled, a sysctl option with
57818 + name "exec_logging" is created.
57819 + WARNING: This option when enabled will produce a LOT of logs, especially
57820 + on an active system.
57821 +
57822 +config GRKERNSEC_RESLOG
57823 + bool "Resource logging"
57824 + default y if GRKERNSEC_CONFIG_AUTO
57825 + help
57826 + If you say Y here, all attempts to overstep resource limits will
57827 + be logged with the resource name, the requested size, and the current
57828 + limit. It is highly recommended that you say Y here. If the sysctl
57829 + option is enabled, a sysctl option with name "resource_logging" is
57830 + created. If the RBAC system is enabled, the sysctl value is ignored.
57831 +
57832 +config GRKERNSEC_CHROOT_EXECLOG
57833 + bool "Log execs within chroot"
57834 + help
57835 + If you say Y here, all executions inside a chroot jail will be logged
57836 + to syslog. This can cause a large amount of logs if certain
57837 + applications (eg. djb's daemontools) are installed on the system, and
57838 + is therefore left as an option. If the sysctl option is enabled, a
57839 + sysctl option with name "chroot_execlog" is created.
57840 +
57841 +config GRKERNSEC_AUDIT_PTRACE
57842 + bool "Ptrace logging"
57843 + help
57844 + If you say Y here, all attempts to attach to a process via ptrace
57845 + will be logged. If the sysctl option is enabled, a sysctl option
57846 + with name "audit_ptrace" is created.
57847 +
57848 +config GRKERNSEC_AUDIT_CHDIR
57849 + bool "Chdir logging"
57850 + help
57851 + If you say Y here, all chdir() calls will be logged. If the sysctl
57852 + option is enabled, a sysctl option with name "audit_chdir" is created.
57853 +
57854 +config GRKERNSEC_AUDIT_MOUNT
57855 + bool "(Un)Mount logging"
57856 + help
57857 + If you say Y here, all mounts and unmounts will be logged. If the
57858 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57859 + created.
57860 +
57861 +config GRKERNSEC_SIGNAL
57862 + bool "Signal logging"
57863 + default y if GRKERNSEC_CONFIG_AUTO
57864 + help
57865 + If you say Y here, certain important signals will be logged, such as
57866 + SIGSEGV, which will as a result inform you of when a error in a program
57867 + occurred, which in some cases could mean a possible exploit attempt.
57868 + If the sysctl option is enabled, a sysctl option with name
57869 + "signal_logging" is created.
57870 +
57871 +config GRKERNSEC_FORKFAIL
57872 + bool "Fork failure logging"
57873 + help
57874 + If you say Y here, all failed fork() attempts will be logged.
57875 + This could suggest a fork bomb, or someone attempting to overstep
57876 + their process limit. If the sysctl option is enabled, a sysctl option
57877 + with name "forkfail_logging" is created.
57878 +
57879 +config GRKERNSEC_TIME
57880 + bool "Time change logging"
57881 + default y if GRKERNSEC_CONFIG_AUTO
57882 + help
57883 + If you say Y here, any changes of the system clock will be logged.
57884 + If the sysctl option is enabled, a sysctl option with name
57885 + "timechange_logging" is created.
57886 +
57887 +config GRKERNSEC_PROC_IPADDR
57888 + bool "/proc/<pid>/ipaddr support"
57889 + default y if GRKERNSEC_CONFIG_AUTO
57890 + help
57891 + If you say Y here, a new entry will be added to each /proc/<pid>
57892 + directory that contains the IP address of the person using the task.
57893 + The IP is carried across local TCP and AF_UNIX stream sockets.
57894 + This information can be useful for IDS/IPSes to perform remote response
57895 + to a local attack. The entry is readable by only the owner of the
57896 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57897 + the RBAC system), and thus does not create privacy concerns.
57898 +
57899 +config GRKERNSEC_RWXMAP_LOG
57900 + bool 'Denied RWX mmap/mprotect logging'
57901 + default y if GRKERNSEC_CONFIG_AUTO
57902 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57903 + help
57904 + If you say Y here, calls to mmap() and mprotect() with explicit
57905 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57906 + denied by the PAX_MPROTECT feature. If the sysctl option is
57907 + enabled, a sysctl option with name "rwxmap_logging" is created.
57908 +
57909 +config GRKERNSEC_AUDIT_TEXTREL
57910 + bool 'ELF text relocations logging (READ HELP)'
57911 + depends on PAX_MPROTECT
57912 + help
57913 + If you say Y here, text relocations will be logged with the filename
57914 + of the offending library or binary. The purpose of the feature is
57915 + to help Linux distribution developers get rid of libraries and
57916 + binaries that need text relocations which hinder the future progress
57917 + of PaX. Only Linux distribution developers should say Y here, and
57918 + never on a production machine, as this option creates an information
57919 + leak that could aid an attacker in defeating the randomization of
57920 + a single memory region. If the sysctl option is enabled, a sysctl
57921 + option with name "audit_textrel" is created.
57922 +
57923 +endmenu
57924 +
57925 +menu "Executable Protections"
57926 +depends on GRKERNSEC
57927 +
57928 +config GRKERNSEC_DMESG
57929 + bool "Dmesg(8) restriction"
57930 + default y if GRKERNSEC_CONFIG_AUTO
57931 + help
57932 + If you say Y here, non-root users will not be able to use dmesg(8)
57933 + to view the contents of the kernel's circular log buffer.
57934 + The kernel's log buffer often contains kernel addresses and other
57935 + identifying information useful to an attacker in fingerprinting a
57936 + system for a targeted exploit.
57937 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57938 + created.
57939 +
57940 +config GRKERNSEC_HARDEN_PTRACE
57941 + bool "Deter ptrace-based process snooping"
57942 + default y if GRKERNSEC_CONFIG_AUTO
57943 + help
57944 + If you say Y here, TTY sniffers and other malicious monitoring
57945 + programs implemented through ptrace will be defeated. If you
57946 + have been using the RBAC system, this option has already been
57947 + enabled for several years for all users, with the ability to make
57948 + fine-grained exceptions.
57949 +
57950 + This option only affects the ability of non-root users to ptrace
57951 + processes that are not a descendent of the ptracing process.
57952 + This means that strace ./binary and gdb ./binary will still work,
57953 + but attaching to arbitrary processes will not. If the sysctl
57954 + option is enabled, a sysctl option with name "harden_ptrace" is
57955 + created.
57956 +
57957 +config GRKERNSEC_PTRACE_READEXEC
57958 + bool "Require read access to ptrace sensitive binaries"
57959 + default y if GRKERNSEC_CONFIG_AUTO
57960 + help
57961 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57962 + binaries. This option is useful in environments that
57963 + remove the read bits (e.g. file mode 4711) from suid binaries to
57964 + prevent infoleaking of their contents. This option adds
57965 + consistency to the use of that file mode, as the binary could normally
57966 + be read out when run without privileges while ptracing.
57967 +
57968 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57969 + is created.
57970 +
57971 +config GRKERNSEC_SETXID
57972 + bool "Enforce consistent multithreaded privileges"
57973 + default y if GRKERNSEC_CONFIG_AUTO
57974 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57975 + help
57976 + If you say Y here, a change from a root uid to a non-root uid
57977 + in a multithreaded application will cause the resulting uids,
57978 + gids, supplementary groups, and capabilities in that thread
57979 + to be propagated to the other threads of the process. In most
57980 + cases this is unnecessary, as glibc will emulate this behavior
57981 + on behalf of the application. Other libcs do not act in the
57982 + same way, allowing the other threads of the process to continue
57983 + running with root privileges. If the sysctl option is enabled,
57984 + a sysctl option with name "consistent_setxid" is created.
57985 +
57986 +config GRKERNSEC_TPE
57987 + bool "Trusted Path Execution (TPE)"
57988 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57989 + help
57990 + If you say Y here, you will be able to choose a gid to add to the
57991 + supplementary groups of users you want to mark as "untrusted."
57992 + These users will not be able to execute any files that are not in
57993 + root-owned directories writable only by root. If the sysctl option
57994 + is enabled, a sysctl option with name "tpe" is created.
57995 +
57996 +config GRKERNSEC_TPE_ALL
57997 + bool "Partially restrict all non-root users"
57998 + depends on GRKERNSEC_TPE
57999 + help
58000 + If you say Y here, all non-root users will be covered under
58001 + a weaker TPE restriction. This is separate from, and in addition to,
58002 + the main TPE options that you have selected elsewhere. Thus, if a
58003 + "trusted" GID is chosen, this restriction applies to even that GID.
58004 + Under this restriction, all non-root users will only be allowed to
58005 + execute files in directories they own that are not group or
58006 + world-writable, or in directories owned by root and writable only by
58007 + root. If the sysctl option is enabled, a sysctl option with name
58008 + "tpe_restrict_all" is created.
58009 +
58010 +config GRKERNSEC_TPE_INVERT
58011 + bool "Invert GID option"
58012 + depends on GRKERNSEC_TPE
58013 + help
58014 + If you say Y here, the group you specify in the TPE configuration will
58015 + decide what group TPE restrictions will be *disabled* for. This
58016 + option is useful if you want TPE restrictions to be applied to most
58017 + users on the system. If the sysctl option is enabled, a sysctl option
58018 + with name "tpe_invert" is created. Unlike other sysctl options, this
58019 + entry will default to on for backward-compatibility.
58020 +
58021 +config GRKERNSEC_TPE_GID
58022 + int
58023 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
58024 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
58025 +
58026 +config GRKERNSEC_TPE_UNTRUSTED_GID
58027 + int "GID for TPE-untrusted users"
58028 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
58029 + default 1005
58030 + help
58031 + Setting this GID determines what group TPE restrictions will be
58032 + *enabled* for. If the sysctl option is enabled, a sysctl option
58033 + with name "tpe_gid" is created.
58034 +
58035 +config GRKERNSEC_TPE_TRUSTED_GID
58036 + int "GID for TPE-trusted users"
58037 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
58038 + default 1005
58039 + help
58040 + Setting this GID determines what group TPE restrictions will be
58041 + *disabled* for. If the sysctl option is enabled, a sysctl option
58042 + with name "tpe_gid" is created.
58043 +
58044 +endmenu
58045 +menu "Network Protections"
58046 +depends on GRKERNSEC
58047 +
58048 +config GRKERNSEC_RANDNET
58049 + bool "Larger entropy pools"
58050 + default y if GRKERNSEC_CONFIG_AUTO
58051 + help
58052 + If you say Y here, the entropy pools used for many features of Linux
58053 + and grsecurity will be doubled in size. Since several grsecurity
58054 + features use additional randomness, it is recommended that you say Y
58055 + here. Saying Y here has a similar effect as modifying
58056 + /proc/sys/kernel/random/poolsize.
58057 +
58058 +config GRKERNSEC_BLACKHOLE
58059 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
58060 + default y if GRKERNSEC_CONFIG_AUTO
58061 + depends on NET
58062 + help
58063 + If you say Y here, neither TCP resets nor ICMP
58064 + destination-unreachable packets will be sent in response to packets
58065 + sent to ports for which no associated listening process exists.
58066 + This feature supports both IPV4 and IPV6 and exempts the
58067 + loopback interface from blackholing. Enabling this feature
58068 + makes a host more resilient to DoS attacks and reduces network
58069 + visibility against scanners.
58070 +
58071 + The blackhole feature as-implemented is equivalent to the FreeBSD
58072 + blackhole feature, as it prevents RST responses to all packets, not
58073 + just SYNs. Under most application behavior this causes no
58074 + problems, but applications (like haproxy) may not close certain
58075 + connections in a way that cleanly terminates them on the remote
58076 + end, leaving the remote host in LAST_ACK state. Because of this
58077 + side-effect and to prevent intentional LAST_ACK DoSes, this
58078 + feature also adds automatic mitigation against such attacks.
58079 + The mitigation drastically reduces the amount of time a socket
58080 + can spend in LAST_ACK state. If you're using haproxy and not
58081 + all servers it connects to have this option enabled, consider
58082 + disabling this feature on the haproxy host.
58083 +
58084 + If the sysctl option is enabled, two sysctl options with names
58085 + "ip_blackhole" and "lastack_retries" will be created.
58086 + While "ip_blackhole" takes the standard zero/non-zero on/off
58087 + toggle, "lastack_retries" uses the same kinds of values as
58088 + "tcp_retries1" and "tcp_retries2". The default value of 4
58089 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58090 + state.
58091 +
58092 +config GRKERNSEC_NO_SIMULT_CONNECT
58093 + bool "Disable TCP Simultaneous Connect"
58094 + default y if GRKERNSEC_CONFIG_AUTO
58095 + depends on NET
58096 + help
58097 + If you say Y here, a feature by Willy Tarreau will be enabled that
58098 + removes a weakness in Linux's strict implementation of TCP that
58099 + allows two clients to connect to each other without either entering
58100 + a listening state. The weakness allows an attacker to easily prevent
58101 + a client from connecting to a known server provided the source port
58102 + for the connection is guessed correctly.
58103 +
58104 + As the weakness could be used to prevent an antivirus or IPS from
58105 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58106 + it should be eliminated by enabling this option. Though Linux is
58107 + one of few operating systems supporting simultaneous connect, it
58108 + has no legitimate use in practice and is rarely supported by firewalls.
58109 +
58110 +config GRKERNSEC_SOCKET
58111 + bool "Socket restrictions"
58112 + depends on NET
58113 + help
58114 + If you say Y here, you will be able to choose from several options.
58115 + If you assign a GID on your system and add it to the supplementary
58116 + groups of users you want to restrict socket access to, this patch
58117 + will perform up to three things, based on the option(s) you choose.
58118 +
58119 +config GRKERNSEC_SOCKET_ALL
58120 + bool "Deny any sockets to group"
58121 + depends on GRKERNSEC_SOCKET
58122 + help
58123 + If you say Y here, you will be able to choose a GID of whose users will
58124 + be unable to connect to other hosts from your machine or run server
58125 + applications from your machine. If the sysctl option is enabled, a
58126 + sysctl option with name "socket_all" is created.
58127 +
58128 +config GRKERNSEC_SOCKET_ALL_GID
58129 + int "GID to deny all sockets for"
58130 + depends on GRKERNSEC_SOCKET_ALL
58131 + default 1004
58132 + help
58133 + Here you can choose the GID to disable socket access for. Remember to
58134 + add the users you want socket access disabled for to the GID
58135 + specified here. If the sysctl option is enabled, a sysctl option
58136 + with name "socket_all_gid" is created.
58137 +
58138 +config GRKERNSEC_SOCKET_CLIENT
58139 + bool "Deny client sockets to group"
58140 + depends on GRKERNSEC_SOCKET
58141 + help
58142 + If you say Y here, you will be able to choose a GID of whose users will
58143 + be unable to connect to other hosts from your machine, but will be
58144 + able to run servers. If this option is enabled, all users in the group
58145 + you specify will have to use passive mode when initiating ftp transfers
58146 + from the shell on your machine. If the sysctl option is enabled, a
58147 + sysctl option with name "socket_client" is created.
58148 +
58149 +config GRKERNSEC_SOCKET_CLIENT_GID
58150 + int "GID to deny client sockets for"
58151 + depends on GRKERNSEC_SOCKET_CLIENT
58152 + default 1003
58153 + help
58154 + Here you can choose the GID to disable client socket access for.
58155 + Remember to add the users you want client socket access disabled for to
58156 + the GID specified here. If the sysctl option is enabled, a sysctl
58157 + option with name "socket_client_gid" is created.
58158 +
58159 +config GRKERNSEC_SOCKET_SERVER
58160 + bool "Deny server sockets to group"
58161 + depends on GRKERNSEC_SOCKET
58162 + help
58163 + If you say Y here, you will be able to choose a GID of whose users will
58164 + be unable to run server applications from your machine. If the sysctl
58165 + option is enabled, a sysctl option with name "socket_server" is created.
58166 +
58167 +config GRKERNSEC_SOCKET_SERVER_GID
58168 + int "GID to deny server sockets for"
58169 + depends on GRKERNSEC_SOCKET_SERVER
58170 + default 1002
58171 + help
58172 + Here you can choose the GID to disable server socket access for.
58173 + Remember to add the users you want server socket access disabled for to
58174 + the GID specified here. If the sysctl option is enabled, a sysctl
58175 + option with name "socket_server_gid" is created.
58176 +
58177 +endmenu
58178 +menu "Sysctl Support"
58179 +depends on GRKERNSEC && SYSCTL
58180 +
58181 +config GRKERNSEC_SYSCTL
58182 + bool "Sysctl support"
58183 + default y if GRKERNSEC_CONFIG_AUTO
58184 + help
58185 + If you say Y here, you will be able to change the options that
58186 + grsecurity runs with at bootup, without having to recompile your
58187 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58188 + to enable (1) or disable (0) various features. All the sysctl entries
58189 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58190 + All features enabled in the kernel configuration are disabled at boot
58191 + if you do not say Y to the "Turn on features by default" option.
58192 + All options should be set at startup, and the grsec_lock entry should
58193 + be set to a non-zero value after all the options are set.
58194 + *THIS IS EXTREMELY IMPORTANT*
58195 +
58196 +config GRKERNSEC_SYSCTL_DISTRO
58197 + bool "Extra sysctl support for distro makers (READ HELP)"
58198 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58199 + help
58200 + If you say Y here, additional sysctl options will be created
58201 + for features that affect processes running as root. Therefore,
58202 + it is critical when using this option that the grsec_lock entry be
58203 + enabled after boot. Only distros with prebuilt kernel packages
58204 + with this option enabled that can ensure grsec_lock is enabled
58205 + after boot should use this option.
58206 + *Failure to set grsec_lock after boot makes all grsec features
58207 + this option covers useless*
58208 +
58209 + Currently this option creates the following sysctl entries:
58210 + "Disable Privileged I/O": "disable_priv_io"
58211 +
58212 +config GRKERNSEC_SYSCTL_ON
58213 + bool "Turn on features by default"
58214 + default y if GRKERNSEC_CONFIG_AUTO
58215 + depends on GRKERNSEC_SYSCTL
58216 + help
58217 + If you say Y here, instead of having all features enabled in the
58218 + kernel configuration disabled at boot time, the features will be
58219 + enabled at boot time. It is recommended you say Y here unless
58220 + there is some reason you would want all sysctl-tunable features to
58221 + be disabled by default. As mentioned elsewhere, it is important
58222 + to enable the grsec_lock entry once you have finished modifying
58223 + the sysctl entries.
58224 +
58225 +endmenu
58226 +menu "Logging Options"
58227 +depends on GRKERNSEC
58228 +
58229 +config GRKERNSEC_FLOODTIME
58230 + int "Seconds in between log messages (minimum)"
58231 + default 10
58232 + help
58233 + This option allows you to enforce the number of seconds between
58234 + grsecurity log messages. The default should be suitable for most
58235 + people, however, if you choose to change it, choose a value small enough
58236 + to allow informative logs to be produced, but large enough to
58237 + prevent flooding.
58238 +
58239 +config GRKERNSEC_FLOODBURST
58240 + int "Number of messages in a burst (maximum)"
58241 + default 6
58242 + help
58243 + This option allows you to choose the maximum number of messages allowed
58244 + within the flood time interval you chose in a separate option. The
58245 + default should be suitable for most people, however if you find that
58246 + many of your logs are being interpreted as flooding, you may want to
58247 + raise this value.
58248 +
58249 +endmenu
58250 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58251 new file mode 100644
58252 index 0000000..1b9afa9
58253 --- /dev/null
58254 +++ b/grsecurity/Makefile
58255 @@ -0,0 +1,38 @@
58256 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58257 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58258 +# into an RBAC system
58259 +#
58260 +# All code in this directory and various hooks inserted throughout the kernel
58261 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58262 +# under the GPL v2 or higher
58263 +
58264 +KBUILD_CFLAGS += -Werror
58265 +
58266 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58267 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58268 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58269 +
58270 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58271 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58272 + gracl_learn.o grsec_log.o
58273 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58274 +
58275 +ifdef CONFIG_NET
58276 +obj-y += grsec_sock.o
58277 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58278 +endif
58279 +
58280 +ifndef CONFIG_GRKERNSEC
58281 +obj-y += grsec_disabled.o
58282 +endif
58283 +
58284 +ifdef CONFIG_GRKERNSEC_HIDESYM
58285 +extra-y := grsec_hidesym.o
58286 +$(obj)/grsec_hidesym.o:
58287 + @-chmod -f 500 /boot
58288 + @-chmod -f 500 /lib/modules
58289 + @-chmod -f 500 /lib64/modules
58290 + @-chmod -f 500 /lib32/modules
58291 + @-chmod -f 700 .
58292 + @echo ' grsec: protected kernel image paths'
58293 +endif
58294 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58295 new file mode 100644
58296 index 0000000..0d5c602
58297 --- /dev/null
58298 +++ b/grsecurity/gracl.c
58299 @@ -0,0 +1,4073 @@
58300 +#include <linux/kernel.h>
58301 +#include <linux/module.h>
58302 +#include <linux/sched.h>
58303 +#include <linux/mm.h>
58304 +#include <linux/file.h>
58305 +#include <linux/fs.h>
58306 +#include <linux/namei.h>
58307 +#include <linux/mount.h>
58308 +#include <linux/tty.h>
58309 +#include <linux/proc_fs.h>
58310 +#include <linux/lglock.h>
58311 +#include <linux/slab.h>
58312 +#include <linux/vmalloc.h>
58313 +#include <linux/types.h>
58314 +#include <linux/sysctl.h>
58315 +#include <linux/netdevice.h>
58316 +#include <linux/ptrace.h>
58317 +#include <linux/gracl.h>
58318 +#include <linux/gralloc.h>
58319 +#include <linux/security.h>
58320 +#include <linux/grinternal.h>
58321 +#include <linux/pid_namespace.h>
58322 +#include <linux/stop_machine.h>
58323 +#include <linux/fdtable.h>
58324 +#include <linux/percpu.h>
58325 +#include <linux/lglock.h>
58326 +#include <linux/hugetlb.h>
58327 +#include <linux/posix-timers.h>
58328 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58329 +#include <linux/magic.h>
58330 +#include <linux/pagemap.h>
58331 +#include "../fs/btrfs/async-thread.h"
58332 +#include "../fs/btrfs/ctree.h"
58333 +#include "../fs/btrfs/btrfs_inode.h"
58334 +#endif
58335 +#include "../fs/mount.h"
58336 +
58337 +#include <asm/uaccess.h>
58338 +#include <asm/errno.h>
58339 +#include <asm/mman.h>
58340 +
58341 +extern struct lglock vfsmount_lock;
58342 +
58343 +static struct acl_role_db acl_role_set;
58344 +static struct name_db name_set;
58345 +static struct inodev_db inodev_set;
58346 +
58347 +/* for keeping track of userspace pointers used for subjects, so we
58348 + can share references in the kernel as well
58349 +*/
58350 +
58351 +static struct path real_root;
58352 +
58353 +static struct acl_subj_map_db subj_map_set;
58354 +
58355 +static struct acl_role_label *default_role;
58356 +
58357 +static struct acl_role_label *role_list;
58358 +
58359 +static u16 acl_sp_role_value;
58360 +
58361 +extern char *gr_shared_page[4];
58362 +static DEFINE_MUTEX(gr_dev_mutex);
58363 +DEFINE_RWLOCK(gr_inode_lock);
58364 +
58365 +struct gr_arg *gr_usermode;
58366 +
58367 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58368 +
58369 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58370 +extern void gr_clear_learn_entries(void);
58371 +
58372 +unsigned char *gr_system_salt;
58373 +unsigned char *gr_system_sum;
58374 +
58375 +static struct sprole_pw **acl_special_roles = NULL;
58376 +static __u16 num_sprole_pws = 0;
58377 +
58378 +static struct acl_role_label *kernel_role = NULL;
58379 +
58380 +static unsigned int gr_auth_attempts = 0;
58381 +static unsigned long gr_auth_expires = 0UL;
58382 +
58383 +#ifdef CONFIG_NET
58384 +extern struct vfsmount *sock_mnt;
58385 +#endif
58386 +
58387 +extern struct vfsmount *pipe_mnt;
58388 +extern struct vfsmount *shm_mnt;
58389 +
58390 +#ifdef CONFIG_HUGETLBFS
58391 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58392 +#endif
58393 +
58394 +static struct acl_object_label *fakefs_obj_rw;
58395 +static struct acl_object_label *fakefs_obj_rwx;
58396 +
58397 +extern int gr_init_uidset(void);
58398 +extern void gr_free_uidset(void);
58399 +extern void gr_remove_uid(uid_t uid);
58400 +extern int gr_find_uid(uid_t uid);
58401 +
58402 +__inline__ int
58403 +gr_acl_is_enabled(void)
58404 +{
58405 + return (gr_status & GR_READY);
58406 +}
58407 +
58408 +static inline dev_t __get_dev(const struct dentry *dentry)
58409 +{
58410 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58411 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58412 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58413 + else
58414 +#endif
58415 + return dentry->d_sb->s_dev;
58416 +}
58417 +
58418 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58419 +{
58420 + return __get_dev(dentry);
58421 +}
58422 +
58423 +static char gr_task_roletype_to_char(struct task_struct *task)
58424 +{
58425 + switch (task->role->roletype &
58426 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58427 + GR_ROLE_SPECIAL)) {
58428 + case GR_ROLE_DEFAULT:
58429 + return 'D';
58430 + case GR_ROLE_USER:
58431 + return 'U';
58432 + case GR_ROLE_GROUP:
58433 + return 'G';
58434 + case GR_ROLE_SPECIAL:
58435 + return 'S';
58436 + }
58437 +
58438 + return 'X';
58439 +}
58440 +
58441 +char gr_roletype_to_char(void)
58442 +{
58443 + return gr_task_roletype_to_char(current);
58444 +}
58445 +
58446 +__inline__ int
58447 +gr_acl_tpe_check(void)
58448 +{
58449 + if (unlikely(!(gr_status & GR_READY)))
58450 + return 0;
58451 + if (current->role->roletype & GR_ROLE_TPE)
58452 + return 1;
58453 + else
58454 + return 0;
58455 +}
58456 +
58457 +int
58458 +gr_handle_rawio(const struct inode *inode)
58459 +{
58460 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58461 + if (inode && S_ISBLK(inode->i_mode) &&
58462 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58463 + !capable(CAP_SYS_RAWIO))
58464 + return 1;
58465 +#endif
58466 + return 0;
58467 +}
58468 +
58469 +static int
58470 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58471 +{
58472 + if (likely(lena != lenb))
58473 + return 0;
58474 +
58475 + return !memcmp(a, b, lena);
58476 +}
58477 +
58478 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58479 +{
58480 + *buflen -= namelen;
58481 + if (*buflen < 0)
58482 + return -ENAMETOOLONG;
58483 + *buffer -= namelen;
58484 + memcpy(*buffer, str, namelen);
58485 + return 0;
58486 +}
58487 +
58488 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58489 +{
58490 + return prepend(buffer, buflen, name->name, name->len);
58491 +}
58492 +
58493 +static int prepend_path(const struct path *path, struct path *root,
58494 + char **buffer, int *buflen)
58495 +{
58496 + struct dentry *dentry = path->dentry;
58497 + struct vfsmount *vfsmnt = path->mnt;
58498 + struct mount *mnt = real_mount(vfsmnt);
58499 + bool slash = false;
58500 + int error = 0;
58501 +
58502 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58503 + struct dentry * parent;
58504 +
58505 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58506 + /* Global root? */
58507 + if (!mnt_has_parent(mnt)) {
58508 + goto out;
58509 + }
58510 + dentry = mnt->mnt_mountpoint;
58511 + mnt = mnt->mnt_parent;
58512 + vfsmnt = &mnt->mnt;
58513 + continue;
58514 + }
58515 + parent = dentry->d_parent;
58516 + prefetch(parent);
58517 + spin_lock(&dentry->d_lock);
58518 + error = prepend_name(buffer, buflen, &dentry->d_name);
58519 + spin_unlock(&dentry->d_lock);
58520 + if (!error)
58521 + error = prepend(buffer, buflen, "/", 1);
58522 + if (error)
58523 + break;
58524 +
58525 + slash = true;
58526 + dentry = parent;
58527 + }
58528 +
58529 +out:
58530 + if (!error && !slash)
58531 + error = prepend(buffer, buflen, "/", 1);
58532 +
58533 + return error;
58534 +}
58535 +
58536 +/* this must be called with vfsmount_lock and rename_lock held */
58537 +
58538 +static char *__our_d_path(const struct path *path, struct path *root,
58539 + char *buf, int buflen)
58540 +{
58541 + char *res = buf + buflen;
58542 + int error;
58543 +
58544 + prepend(&res, &buflen, "\0", 1);
58545 + error = prepend_path(path, root, &res, &buflen);
58546 + if (error)
58547 + return ERR_PTR(error);
58548 +
58549 + return res;
58550 +}
58551 +
58552 +static char *
58553 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58554 +{
58555 + char *retval;
58556 +
58557 + retval = __our_d_path(path, root, buf, buflen);
58558 + if (unlikely(IS_ERR(retval)))
58559 + retval = strcpy(buf, "<path too long>");
58560 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58561 + retval[1] = '\0';
58562 +
58563 + return retval;
58564 +}
58565 +
58566 +static char *
58567 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58568 + char *buf, int buflen)
58569 +{
58570 + struct path path;
58571 + char *res;
58572 +
58573 + path.dentry = (struct dentry *)dentry;
58574 + path.mnt = (struct vfsmount *)vfsmnt;
58575 +
58576 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58577 + by the RBAC system */
58578 + res = gen_full_path(&path, &real_root, buf, buflen);
58579 +
58580 + return res;
58581 +}
58582 +
58583 +static char *
58584 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58585 + char *buf, int buflen)
58586 +{
58587 + char *res;
58588 + struct path path;
58589 + struct path root;
58590 + struct task_struct *reaper = init_pid_ns.child_reaper;
58591 +
58592 + path.dentry = (struct dentry *)dentry;
58593 + path.mnt = (struct vfsmount *)vfsmnt;
58594 +
58595 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58596 + get_fs_root(reaper->fs, &root);
58597 +
58598 + br_read_lock(&vfsmount_lock);
58599 + write_seqlock(&rename_lock);
58600 + res = gen_full_path(&path, &root, buf, buflen);
58601 + write_sequnlock(&rename_lock);
58602 + br_read_unlock(&vfsmount_lock);
58603 +
58604 + path_put(&root);
58605 + return res;
58606 +}
58607 +
58608 +static char *
58609 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58610 +{
58611 + char *ret;
58612 + br_read_lock(&vfsmount_lock);
58613 + write_seqlock(&rename_lock);
58614 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58615 + PAGE_SIZE);
58616 + write_sequnlock(&rename_lock);
58617 + br_read_unlock(&vfsmount_lock);
58618 + return ret;
58619 +}
58620 +
58621 +static char *
58622 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58623 +{
58624 + char *ret;
58625 + char *buf;
58626 + int buflen;
58627 +
58628 + br_read_lock(&vfsmount_lock);
58629 + write_seqlock(&rename_lock);
58630 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58631 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58632 + buflen = (int)(ret - buf);
58633 + if (buflen >= 5)
58634 + prepend(&ret, &buflen, "/proc", 5);
58635 + else
58636 + ret = strcpy(buf, "<path too long>");
58637 + write_sequnlock(&rename_lock);
58638 + br_read_unlock(&vfsmount_lock);
58639 + return ret;
58640 +}
58641 +
58642 +char *
58643 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58644 +{
58645 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58646 + PAGE_SIZE);
58647 +}
58648 +
58649 +char *
58650 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58651 +{
58652 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58653 + PAGE_SIZE);
58654 +}
58655 +
58656 +char *
58657 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58658 +{
58659 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58660 + PAGE_SIZE);
58661 +}
58662 +
58663 +char *
58664 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58665 +{
58666 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58667 + PAGE_SIZE);
58668 +}
58669 +
58670 +char *
58671 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58672 +{
58673 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58674 + PAGE_SIZE);
58675 +}
58676 +
58677 +__inline__ __u32
58678 +to_gr_audit(const __u32 reqmode)
58679 +{
58680 + /* masks off auditable permission flags, then shifts them to create
58681 + auditing flags, and adds the special case of append auditing if
58682 + we're requesting write */
58683 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58684 +}
58685 +
58686 +struct acl_subject_label *
58687 +lookup_subject_map(const struct acl_subject_label *userp)
58688 +{
58689 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58690 + struct subject_map *match;
58691 +
58692 + match = subj_map_set.s_hash[index];
58693 +
58694 + while (match && match->user != userp)
58695 + match = match->next;
58696 +
58697 + if (match != NULL)
58698 + return match->kernel;
58699 + else
58700 + return NULL;
58701 +}
58702 +
58703 +static void
58704 +insert_subj_map_entry(struct subject_map *subjmap)
58705 +{
58706 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58707 + struct subject_map **curr;
58708 +
58709 + subjmap->prev = NULL;
58710 +
58711 + curr = &subj_map_set.s_hash[index];
58712 + if (*curr != NULL)
58713 + (*curr)->prev = subjmap;
58714 +
58715 + subjmap->next = *curr;
58716 + *curr = subjmap;
58717 +
58718 + return;
58719 +}
58720 +
58721 +static struct acl_role_label *
58722 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58723 + const gid_t gid)
58724 +{
58725 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58726 + struct acl_role_label *match;
58727 + struct role_allowed_ip *ipp;
58728 + unsigned int x;
58729 + u32 curr_ip = task->signal->curr_ip;
58730 +
58731 + task->signal->saved_ip = curr_ip;
58732 +
58733 + match = acl_role_set.r_hash[index];
58734 +
58735 + while (match) {
58736 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58737 + for (x = 0; x < match->domain_child_num; x++) {
58738 + if (match->domain_children[x] == uid)
58739 + goto found;
58740 + }
58741 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58742 + break;
58743 + match = match->next;
58744 + }
58745 +found:
58746 + if (match == NULL) {
58747 + try_group:
58748 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58749 + match = acl_role_set.r_hash[index];
58750 +
58751 + while (match) {
58752 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58753 + for (x = 0; x < match->domain_child_num; x++) {
58754 + if (match->domain_children[x] == gid)
58755 + goto found2;
58756 + }
58757 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58758 + break;
58759 + match = match->next;
58760 + }
58761 +found2:
58762 + if (match == NULL)
58763 + match = default_role;
58764 + if (match->allowed_ips == NULL)
58765 + return match;
58766 + else {
58767 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58768 + if (likely
58769 + ((ntohl(curr_ip) & ipp->netmask) ==
58770 + (ntohl(ipp->addr) & ipp->netmask)))
58771 + return match;
58772 + }
58773 + match = default_role;
58774 + }
58775 + } else if (match->allowed_ips == NULL) {
58776 + return match;
58777 + } else {
58778 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58779 + if (likely
58780 + ((ntohl(curr_ip) & ipp->netmask) ==
58781 + (ntohl(ipp->addr) & ipp->netmask)))
58782 + return match;
58783 + }
58784 + goto try_group;
58785 + }
58786 +
58787 + return match;
58788 +}
58789 +
58790 +struct acl_subject_label *
58791 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58792 + const struct acl_role_label *role)
58793 +{
58794 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58795 + struct acl_subject_label *match;
58796 +
58797 + match = role->subj_hash[index];
58798 +
58799 + while (match && (match->inode != ino || match->device != dev ||
58800 + (match->mode & GR_DELETED))) {
58801 + match = match->next;
58802 + }
58803 +
58804 + if (match && !(match->mode & GR_DELETED))
58805 + return match;
58806 + else
58807 + return NULL;
58808 +}
58809 +
58810 +struct acl_subject_label *
58811 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58812 + const struct acl_role_label *role)
58813 +{
58814 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58815 + struct acl_subject_label *match;
58816 +
58817 + match = role->subj_hash[index];
58818 +
58819 + while (match && (match->inode != ino || match->device != dev ||
58820 + !(match->mode & GR_DELETED))) {
58821 + match = match->next;
58822 + }
58823 +
58824 + if (match && (match->mode & GR_DELETED))
58825 + return match;
58826 + else
58827 + return NULL;
58828 +}
58829 +
58830 +static struct acl_object_label *
58831 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58832 + const struct acl_subject_label *subj)
58833 +{
58834 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58835 + struct acl_object_label *match;
58836 +
58837 + match = subj->obj_hash[index];
58838 +
58839 + while (match && (match->inode != ino || match->device != dev ||
58840 + (match->mode & GR_DELETED))) {
58841 + match = match->next;
58842 + }
58843 +
58844 + if (match && !(match->mode & GR_DELETED))
58845 + return match;
58846 + else
58847 + return NULL;
58848 +}
58849 +
58850 +static struct acl_object_label *
58851 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58852 + const struct acl_subject_label *subj)
58853 +{
58854 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58855 + struct acl_object_label *match;
58856 +
58857 + match = subj->obj_hash[index];
58858 +
58859 + while (match && (match->inode != ino || match->device != dev ||
58860 + !(match->mode & GR_DELETED))) {
58861 + match = match->next;
58862 + }
58863 +
58864 + if (match && (match->mode & GR_DELETED))
58865 + return match;
58866 +
58867 + match = subj->obj_hash[index];
58868 +
58869 + while (match && (match->inode != ino || match->device != dev ||
58870 + (match->mode & GR_DELETED))) {
58871 + match = match->next;
58872 + }
58873 +
58874 + if (match && !(match->mode & GR_DELETED))
58875 + return match;
58876 + else
58877 + return NULL;
58878 +}
58879 +
58880 +static struct name_entry *
58881 +lookup_name_entry(const char *name)
58882 +{
58883 + unsigned int len = strlen(name);
58884 + unsigned int key = full_name_hash(name, len);
58885 + unsigned int index = key % name_set.n_size;
58886 + struct name_entry *match;
58887 +
58888 + match = name_set.n_hash[index];
58889 +
58890 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58891 + match = match->next;
58892 +
58893 + return match;
58894 +}
58895 +
58896 +static struct name_entry *
58897 +lookup_name_entry_create(const char *name)
58898 +{
58899 + unsigned int len = strlen(name);
58900 + unsigned int key = full_name_hash(name, len);
58901 + unsigned int index = key % name_set.n_size;
58902 + struct name_entry *match;
58903 +
58904 + match = name_set.n_hash[index];
58905 +
58906 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58907 + !match->deleted))
58908 + match = match->next;
58909 +
58910 + if (match && match->deleted)
58911 + return match;
58912 +
58913 + match = name_set.n_hash[index];
58914 +
58915 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58916 + match->deleted))
58917 + match = match->next;
58918 +
58919 + if (match && !match->deleted)
58920 + return match;
58921 + else
58922 + return NULL;
58923 +}
58924 +
58925 +static struct inodev_entry *
58926 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58927 +{
58928 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58929 + struct inodev_entry *match;
58930 +
58931 + match = inodev_set.i_hash[index];
58932 +
58933 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58934 + match = match->next;
58935 +
58936 + return match;
58937 +}
58938 +
58939 +static void
58940 +insert_inodev_entry(struct inodev_entry *entry)
58941 +{
58942 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58943 + inodev_set.i_size);
58944 + struct inodev_entry **curr;
58945 +
58946 + entry->prev = NULL;
58947 +
58948 + curr = &inodev_set.i_hash[index];
58949 + if (*curr != NULL)
58950 + (*curr)->prev = entry;
58951 +
58952 + entry->next = *curr;
58953 + *curr = entry;
58954 +
58955 + return;
58956 +}
58957 +
58958 +static void
58959 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58960 +{
58961 + unsigned int index =
58962 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58963 + struct acl_role_label **curr;
58964 + struct acl_role_label *tmp, *tmp2;
58965 +
58966 + curr = &acl_role_set.r_hash[index];
58967 +
58968 + /* simple case, slot is empty, just set it to our role */
58969 + if (*curr == NULL) {
58970 + *curr = role;
58971 + } else {
58972 + /* example:
58973 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58974 + 2 -> 3
58975 + */
58976 + /* first check to see if we can already be reached via this slot */
58977 + tmp = *curr;
58978 + while (tmp && tmp != role)
58979 + tmp = tmp->next;
58980 + if (tmp == role) {
58981 + /* we don't need to add ourselves to this slot's chain */
58982 + return;
58983 + }
58984 + /* we need to add ourselves to this chain, two cases */
58985 + if (role->next == NULL) {
58986 + /* simple case, append the current chain to our role */
58987 + role->next = *curr;
58988 + *curr = role;
58989 + } else {
58990 + /* 1 -> 2 -> 3 -> 4
58991 + 2 -> 3 -> 4
58992 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58993 + */
58994 + /* trickier case: walk our role's chain until we find
58995 + the role for the start of the current slot's chain */
58996 + tmp = role;
58997 + tmp2 = *curr;
58998 + while (tmp->next && tmp->next != tmp2)
58999 + tmp = tmp->next;
59000 + if (tmp->next == tmp2) {
59001 + /* from example above, we found 3, so just
59002 + replace this slot's chain with ours */
59003 + *curr = role;
59004 + } else {
59005 + /* we didn't find a subset of our role's chain
59006 + in the current slot's chain, so append their
59007 + chain to ours, and set us as the first role in
59008 + the slot's chain
59009 +
59010 + we could fold this case with the case above,
59011 + but making it explicit for clarity
59012 + */
59013 + tmp->next = tmp2;
59014 + *curr = role;
59015 + }
59016 + }
59017 + }
59018 +
59019 + return;
59020 +}
59021 +
59022 +static void
59023 +insert_acl_role_label(struct acl_role_label *role)
59024 +{
59025 + int i;
59026 +
59027 + if (role_list == NULL) {
59028 + role_list = role;
59029 + role->prev = NULL;
59030 + } else {
59031 + role->prev = role_list;
59032 + role_list = role;
59033 + }
59034 +
59035 + /* used for hash chains */
59036 + role->next = NULL;
59037 +
59038 + if (role->roletype & GR_ROLE_DOMAIN) {
59039 + for (i = 0; i < role->domain_child_num; i++)
59040 + __insert_acl_role_label(role, role->domain_children[i]);
59041 + } else
59042 + __insert_acl_role_label(role, role->uidgid);
59043 +}
59044 +
59045 +static int
59046 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
59047 +{
59048 + struct name_entry **curr, *nentry;
59049 + struct inodev_entry *ientry;
59050 + unsigned int len = strlen(name);
59051 + unsigned int key = full_name_hash(name, len);
59052 + unsigned int index = key % name_set.n_size;
59053 +
59054 + curr = &name_set.n_hash[index];
59055 +
59056 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
59057 + curr = &((*curr)->next);
59058 +
59059 + if (*curr != NULL)
59060 + return 1;
59061 +
59062 + nentry = acl_alloc(sizeof (struct name_entry));
59063 + if (nentry == NULL)
59064 + return 0;
59065 + ientry = acl_alloc(sizeof (struct inodev_entry));
59066 + if (ientry == NULL)
59067 + return 0;
59068 + ientry->nentry = nentry;
59069 +
59070 + nentry->key = key;
59071 + nentry->name = name;
59072 + nentry->inode = inode;
59073 + nentry->device = device;
59074 + nentry->len = len;
59075 + nentry->deleted = deleted;
59076 +
59077 + nentry->prev = NULL;
59078 + curr = &name_set.n_hash[index];
59079 + if (*curr != NULL)
59080 + (*curr)->prev = nentry;
59081 + nentry->next = *curr;
59082 + *curr = nentry;
59083 +
59084 + /* insert us into the table searchable by inode/dev */
59085 + insert_inodev_entry(ientry);
59086 +
59087 + return 1;
59088 +}
59089 +
59090 +static void
59091 +insert_acl_obj_label(struct acl_object_label *obj,
59092 + struct acl_subject_label *subj)
59093 +{
59094 + unsigned int index =
59095 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59096 + struct acl_object_label **curr;
59097 +
59098 +
59099 + obj->prev = NULL;
59100 +
59101 + curr = &subj->obj_hash[index];
59102 + if (*curr != NULL)
59103 + (*curr)->prev = obj;
59104 +
59105 + obj->next = *curr;
59106 + *curr = obj;
59107 +
59108 + return;
59109 +}
59110 +
59111 +static void
59112 +insert_acl_subj_label(struct acl_subject_label *obj,
59113 + struct acl_role_label *role)
59114 +{
59115 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59116 + struct acl_subject_label **curr;
59117 +
59118 + obj->prev = NULL;
59119 +
59120 + curr = &role->subj_hash[index];
59121 + if (*curr != NULL)
59122 + (*curr)->prev = obj;
59123 +
59124 + obj->next = *curr;
59125 + *curr = obj;
59126 +
59127 + return;
59128 +}
59129 +
59130 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59131 +
59132 +static void *
59133 +create_table(__u32 * len, int elementsize)
59134 +{
59135 + unsigned int table_sizes[] = {
59136 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59137 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59138 + 4194301, 8388593, 16777213, 33554393, 67108859
59139 + };
59140 + void *newtable = NULL;
59141 + unsigned int pwr = 0;
59142 +
59143 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59144 + table_sizes[pwr] <= *len)
59145 + pwr++;
59146 +
59147 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59148 + return newtable;
59149 +
59150 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59151 + newtable =
59152 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59153 + else
59154 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59155 +
59156 + *len = table_sizes[pwr];
59157 +
59158 + return newtable;
59159 +}
59160 +
59161 +static int
59162 +init_variables(const struct gr_arg *arg)
59163 +{
59164 + struct task_struct *reaper = init_pid_ns.child_reaper;
59165 + unsigned int stacksize;
59166 +
59167 + subj_map_set.s_size = arg->role_db.num_subjects;
59168 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59169 + name_set.n_size = arg->role_db.num_objects;
59170 + inodev_set.i_size = arg->role_db.num_objects;
59171 +
59172 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59173 + !name_set.n_size || !inodev_set.i_size)
59174 + return 1;
59175 +
59176 + if (!gr_init_uidset())
59177 + return 1;
59178 +
59179 + /* set up the stack that holds allocation info */
59180 +
59181 + stacksize = arg->role_db.num_pointers + 5;
59182 +
59183 + if (!acl_alloc_stack_init(stacksize))
59184 + return 1;
59185 +
59186 + /* grab reference for the real root dentry and vfsmount */
59187 + get_fs_root(reaper->fs, &real_root);
59188 +
59189 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59190 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59191 +#endif
59192 +
59193 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59194 + if (fakefs_obj_rw == NULL)
59195 + return 1;
59196 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59197 +
59198 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59199 + if (fakefs_obj_rwx == NULL)
59200 + return 1;
59201 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59202 +
59203 + subj_map_set.s_hash =
59204 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59205 + acl_role_set.r_hash =
59206 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59207 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59208 + inodev_set.i_hash =
59209 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59210 +
59211 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59212 + !name_set.n_hash || !inodev_set.i_hash)
59213 + return 1;
59214 +
59215 + memset(subj_map_set.s_hash, 0,
59216 + sizeof(struct subject_map *) * subj_map_set.s_size);
59217 + memset(acl_role_set.r_hash, 0,
59218 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59219 + memset(name_set.n_hash, 0,
59220 + sizeof (struct name_entry *) * name_set.n_size);
59221 + memset(inodev_set.i_hash, 0,
59222 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59223 +
59224 + return 0;
59225 +}
59226 +
59227 +/* free information not needed after startup
59228 + currently contains user->kernel pointer mappings for subjects
59229 +*/
59230 +
59231 +static void
59232 +free_init_variables(void)
59233 +{
59234 + __u32 i;
59235 +
59236 + if (subj_map_set.s_hash) {
59237 + for (i = 0; i < subj_map_set.s_size; i++) {
59238 + if (subj_map_set.s_hash[i]) {
59239 + kfree(subj_map_set.s_hash[i]);
59240 + subj_map_set.s_hash[i] = NULL;
59241 + }
59242 + }
59243 +
59244 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59245 + PAGE_SIZE)
59246 + kfree(subj_map_set.s_hash);
59247 + else
59248 + vfree(subj_map_set.s_hash);
59249 + }
59250 +
59251 + return;
59252 +}
59253 +
59254 +static void
59255 +free_variables(void)
59256 +{
59257 + struct acl_subject_label *s;
59258 + struct acl_role_label *r;
59259 + struct task_struct *task, *task2;
59260 + unsigned int x;
59261 +
59262 + gr_clear_learn_entries();
59263 +
59264 + read_lock(&tasklist_lock);
59265 + do_each_thread(task2, task) {
59266 + task->acl_sp_role = 0;
59267 + task->acl_role_id = 0;
59268 + task->acl = NULL;
59269 + task->role = NULL;
59270 + } while_each_thread(task2, task);
59271 + read_unlock(&tasklist_lock);
59272 +
59273 + /* release the reference to the real root dentry and vfsmount */
59274 + path_put(&real_root);
59275 + memset(&real_root, 0, sizeof(real_root));
59276 +
59277 + /* free all object hash tables */
59278 +
59279 + FOR_EACH_ROLE_START(r)
59280 + if (r->subj_hash == NULL)
59281 + goto next_role;
59282 + FOR_EACH_SUBJECT_START(r, s, x)
59283 + if (s->obj_hash == NULL)
59284 + break;
59285 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59286 + kfree(s->obj_hash);
59287 + else
59288 + vfree(s->obj_hash);
59289 + FOR_EACH_SUBJECT_END(s, x)
59290 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59291 + if (s->obj_hash == NULL)
59292 + break;
59293 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59294 + kfree(s->obj_hash);
59295 + else
59296 + vfree(s->obj_hash);
59297 + FOR_EACH_NESTED_SUBJECT_END(s)
59298 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59299 + kfree(r->subj_hash);
59300 + else
59301 + vfree(r->subj_hash);
59302 + r->subj_hash = NULL;
59303 +next_role:
59304 + FOR_EACH_ROLE_END(r)
59305 +
59306 + acl_free_all();
59307 +
59308 + if (acl_role_set.r_hash) {
59309 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59310 + PAGE_SIZE)
59311 + kfree(acl_role_set.r_hash);
59312 + else
59313 + vfree(acl_role_set.r_hash);
59314 + }
59315 + if (name_set.n_hash) {
59316 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59317 + PAGE_SIZE)
59318 + kfree(name_set.n_hash);
59319 + else
59320 + vfree(name_set.n_hash);
59321 + }
59322 +
59323 + if (inodev_set.i_hash) {
59324 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59325 + PAGE_SIZE)
59326 + kfree(inodev_set.i_hash);
59327 + else
59328 + vfree(inodev_set.i_hash);
59329 + }
59330 +
59331 + gr_free_uidset();
59332 +
59333 + memset(&name_set, 0, sizeof (struct name_db));
59334 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59335 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59336 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59337 +
59338 + default_role = NULL;
59339 + kernel_role = NULL;
59340 + role_list = NULL;
59341 +
59342 + return;
59343 +}
59344 +
59345 +static __u32
59346 +count_user_objs(struct acl_object_label *userp)
59347 +{
59348 + struct acl_object_label o_tmp;
59349 + __u32 num = 0;
59350 +
59351 + while (userp) {
59352 + if (copy_from_user(&o_tmp, userp,
59353 + sizeof (struct acl_object_label)))
59354 + break;
59355 +
59356 + userp = o_tmp.prev;
59357 + num++;
59358 + }
59359 +
59360 + return num;
59361 +}
59362 +
59363 +static struct acl_subject_label *
59364 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59365 +
59366 +static int
59367 +copy_user_glob(struct acl_object_label *obj)
59368 +{
59369 + struct acl_object_label *g_tmp, **guser;
59370 + unsigned int len;
59371 + char *tmp;
59372 +
59373 + if (obj->globbed == NULL)
59374 + return 0;
59375 +
59376 + guser = &obj->globbed;
59377 + while (*guser) {
59378 + g_tmp = (struct acl_object_label *)
59379 + acl_alloc(sizeof (struct acl_object_label));
59380 + if (g_tmp == NULL)
59381 + return -ENOMEM;
59382 +
59383 + if (copy_from_user(g_tmp, *guser,
59384 + sizeof (struct acl_object_label)))
59385 + return -EFAULT;
59386 +
59387 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59388 +
59389 + if (!len || len >= PATH_MAX)
59390 + return -EINVAL;
59391 +
59392 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59393 + return -ENOMEM;
59394 +
59395 + if (copy_from_user(tmp, g_tmp->filename, len))
59396 + return -EFAULT;
59397 + tmp[len-1] = '\0';
59398 + g_tmp->filename = tmp;
59399 +
59400 + *guser = g_tmp;
59401 + guser = &(g_tmp->next);
59402 + }
59403 +
59404 + return 0;
59405 +}
59406 +
59407 +static int
59408 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59409 + struct acl_role_label *role)
59410 +{
59411 + struct acl_object_label *o_tmp;
59412 + unsigned int len;
59413 + int ret;
59414 + char *tmp;
59415 +
59416 + while (userp) {
59417 + if ((o_tmp = (struct acl_object_label *)
59418 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59419 + return -ENOMEM;
59420 +
59421 + if (copy_from_user(o_tmp, userp,
59422 + sizeof (struct acl_object_label)))
59423 + return -EFAULT;
59424 +
59425 + userp = o_tmp->prev;
59426 +
59427 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59428 +
59429 + if (!len || len >= PATH_MAX)
59430 + return -EINVAL;
59431 +
59432 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59433 + return -ENOMEM;
59434 +
59435 + if (copy_from_user(tmp, o_tmp->filename, len))
59436 + return -EFAULT;
59437 + tmp[len-1] = '\0';
59438 + o_tmp->filename = tmp;
59439 +
59440 + insert_acl_obj_label(o_tmp, subj);
59441 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59442 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59443 + return -ENOMEM;
59444 +
59445 + ret = copy_user_glob(o_tmp);
59446 + if (ret)
59447 + return ret;
59448 +
59449 + if (o_tmp->nested) {
59450 + int already_copied;
59451 +
59452 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59453 + if (IS_ERR(o_tmp->nested))
59454 + return PTR_ERR(o_tmp->nested);
59455 +
59456 + /* insert into nested subject list if we haven't copied this one yet
59457 + to prevent duplicate entries */
59458 + if (!already_copied) {
59459 + o_tmp->nested->next = role->hash->first;
59460 + role->hash->first = o_tmp->nested;
59461 + }
59462 + }
59463 + }
59464 +
59465 + return 0;
59466 +}
59467 +
59468 +static __u32
59469 +count_user_subjs(struct acl_subject_label *userp)
59470 +{
59471 + struct acl_subject_label s_tmp;
59472 + __u32 num = 0;
59473 +
59474 + while (userp) {
59475 + if (copy_from_user(&s_tmp, userp,
59476 + sizeof (struct acl_subject_label)))
59477 + break;
59478 +
59479 + userp = s_tmp.prev;
59480 + }
59481 +
59482 + return num;
59483 +}
59484 +
59485 +static int
59486 +copy_user_allowedips(struct acl_role_label *rolep)
59487 +{
59488 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59489 +
59490 + ruserip = rolep->allowed_ips;
59491 +
59492 + while (ruserip) {
59493 + rlast = rtmp;
59494 +
59495 + if ((rtmp = (struct role_allowed_ip *)
59496 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59497 + return -ENOMEM;
59498 +
59499 + if (copy_from_user(rtmp, ruserip,
59500 + sizeof (struct role_allowed_ip)))
59501 + return -EFAULT;
59502 +
59503 + ruserip = rtmp->prev;
59504 +
59505 + if (!rlast) {
59506 + rtmp->prev = NULL;
59507 + rolep->allowed_ips = rtmp;
59508 + } else {
59509 + rlast->next = rtmp;
59510 + rtmp->prev = rlast;
59511 + }
59512 +
59513 + if (!ruserip)
59514 + rtmp->next = NULL;
59515 + }
59516 +
59517 + return 0;
59518 +}
59519 +
59520 +static int
59521 +copy_user_transitions(struct acl_role_label *rolep)
59522 +{
59523 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59524 +
59525 + unsigned int len;
59526 + char *tmp;
59527 +
59528 + rusertp = rolep->transitions;
59529 +
59530 + while (rusertp) {
59531 + rlast = rtmp;
59532 +
59533 + if ((rtmp = (struct role_transition *)
59534 + acl_alloc(sizeof (struct role_transition))) == NULL)
59535 + return -ENOMEM;
59536 +
59537 + if (copy_from_user(rtmp, rusertp,
59538 + sizeof (struct role_transition)))
59539 + return -EFAULT;
59540 +
59541 + rusertp = rtmp->prev;
59542 +
59543 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59544 +
59545 + if (!len || len >= GR_SPROLE_LEN)
59546 + return -EINVAL;
59547 +
59548 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59549 + return -ENOMEM;
59550 +
59551 + if (copy_from_user(tmp, rtmp->rolename, len))
59552 + return -EFAULT;
59553 + tmp[len-1] = '\0';
59554 + rtmp->rolename = tmp;
59555 +
59556 + if (!rlast) {
59557 + rtmp->prev = NULL;
59558 + rolep->transitions = rtmp;
59559 + } else {
59560 + rlast->next = rtmp;
59561 + rtmp->prev = rlast;
59562 + }
59563 +
59564 + if (!rusertp)
59565 + rtmp->next = NULL;
59566 + }
59567 +
59568 + return 0;
59569 +}
59570 +
59571 +static struct acl_subject_label *
59572 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59573 +{
59574 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59575 + unsigned int len;
59576 + char *tmp;
59577 + __u32 num_objs;
59578 + struct acl_ip_label **i_tmp, *i_utmp2;
59579 + struct gr_hash_struct ghash;
59580 + struct subject_map *subjmap;
59581 + unsigned int i_num;
59582 + int err;
59583 +
59584 + if (already_copied != NULL)
59585 + *already_copied = 0;
59586 +
59587 + s_tmp = lookup_subject_map(userp);
59588 +
59589 + /* we've already copied this subject into the kernel, just return
59590 + the reference to it, and don't copy it over again
59591 + */
59592 + if (s_tmp) {
59593 + if (already_copied != NULL)
59594 + *already_copied = 1;
59595 + return(s_tmp);
59596 + }
59597 +
59598 + if ((s_tmp = (struct acl_subject_label *)
59599 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59600 + return ERR_PTR(-ENOMEM);
59601 +
59602 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59603 + if (subjmap == NULL)
59604 + return ERR_PTR(-ENOMEM);
59605 +
59606 + subjmap->user = userp;
59607 + subjmap->kernel = s_tmp;
59608 + insert_subj_map_entry(subjmap);
59609 +
59610 + if (copy_from_user(s_tmp, userp,
59611 + sizeof (struct acl_subject_label)))
59612 + return ERR_PTR(-EFAULT);
59613 +
59614 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59615 +
59616 + if (!len || len >= PATH_MAX)
59617 + return ERR_PTR(-EINVAL);
59618 +
59619 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59620 + return ERR_PTR(-ENOMEM);
59621 +
59622 + if (copy_from_user(tmp, s_tmp->filename, len))
59623 + return ERR_PTR(-EFAULT);
59624 + tmp[len-1] = '\0';
59625 + s_tmp->filename = tmp;
59626 +
59627 + if (!strcmp(s_tmp->filename, "/"))
59628 + role->root_label = s_tmp;
59629 +
59630 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59631 + return ERR_PTR(-EFAULT);
59632 +
59633 + /* copy user and group transition tables */
59634 +
59635 + if (s_tmp->user_trans_num) {
59636 + uid_t *uidlist;
59637 +
59638 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59639 + if (uidlist == NULL)
59640 + return ERR_PTR(-ENOMEM);
59641 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59642 + return ERR_PTR(-EFAULT);
59643 +
59644 + s_tmp->user_transitions = uidlist;
59645 + }
59646 +
59647 + if (s_tmp->group_trans_num) {
59648 + gid_t *gidlist;
59649 +
59650 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59651 + if (gidlist == NULL)
59652 + return ERR_PTR(-ENOMEM);
59653 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59654 + return ERR_PTR(-EFAULT);
59655 +
59656 + s_tmp->group_transitions = gidlist;
59657 + }
59658 +
59659 + /* set up object hash table */
59660 + num_objs = count_user_objs(ghash.first);
59661 +
59662 + s_tmp->obj_hash_size = num_objs;
59663 + s_tmp->obj_hash =
59664 + (struct acl_object_label **)
59665 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59666 +
59667 + if (!s_tmp->obj_hash)
59668 + return ERR_PTR(-ENOMEM);
59669 +
59670 + memset(s_tmp->obj_hash, 0,
59671 + s_tmp->obj_hash_size *
59672 + sizeof (struct acl_object_label *));
59673 +
59674 + /* add in objects */
59675 + err = copy_user_objs(ghash.first, s_tmp, role);
59676 +
59677 + if (err)
59678 + return ERR_PTR(err);
59679 +
59680 + /* set pointer for parent subject */
59681 + if (s_tmp->parent_subject) {
59682 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59683 +
59684 + if (IS_ERR(s_tmp2))
59685 + return s_tmp2;
59686 +
59687 + s_tmp->parent_subject = s_tmp2;
59688 + }
59689 +
59690 + /* add in ip acls */
59691 +
59692 + if (!s_tmp->ip_num) {
59693 + s_tmp->ips = NULL;
59694 + goto insert;
59695 + }
59696 +
59697 + i_tmp =
59698 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59699 + sizeof (struct acl_ip_label *));
59700 +
59701 + if (!i_tmp)
59702 + return ERR_PTR(-ENOMEM);
59703 +
59704 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59705 + *(i_tmp + i_num) =
59706 + (struct acl_ip_label *)
59707 + acl_alloc(sizeof (struct acl_ip_label));
59708 + if (!*(i_tmp + i_num))
59709 + return ERR_PTR(-ENOMEM);
59710 +
59711 + if (copy_from_user
59712 + (&i_utmp2, s_tmp->ips + i_num,
59713 + sizeof (struct acl_ip_label *)))
59714 + return ERR_PTR(-EFAULT);
59715 +
59716 + if (copy_from_user
59717 + (*(i_tmp + i_num), i_utmp2,
59718 + sizeof (struct acl_ip_label)))
59719 + return ERR_PTR(-EFAULT);
59720 +
59721 + if ((*(i_tmp + i_num))->iface == NULL)
59722 + continue;
59723 +
59724 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59725 + if (!len || len >= IFNAMSIZ)
59726 + return ERR_PTR(-EINVAL);
59727 + tmp = acl_alloc(len);
59728 + if (tmp == NULL)
59729 + return ERR_PTR(-ENOMEM);
59730 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59731 + return ERR_PTR(-EFAULT);
59732 + (*(i_tmp + i_num))->iface = tmp;
59733 + }
59734 +
59735 + s_tmp->ips = i_tmp;
59736 +
59737 +insert:
59738 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59739 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59740 + return ERR_PTR(-ENOMEM);
59741 +
59742 + return s_tmp;
59743 +}
59744 +
59745 +static int
59746 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59747 +{
59748 + struct acl_subject_label s_pre;
59749 + struct acl_subject_label * ret;
59750 + int err;
59751 +
59752 + while (userp) {
59753 + if (copy_from_user(&s_pre, userp,
59754 + sizeof (struct acl_subject_label)))
59755 + return -EFAULT;
59756 +
59757 + ret = do_copy_user_subj(userp, role, NULL);
59758 +
59759 + err = PTR_ERR(ret);
59760 + if (IS_ERR(ret))
59761 + return err;
59762 +
59763 + insert_acl_subj_label(ret, role);
59764 +
59765 + userp = s_pre.prev;
59766 + }
59767 +
59768 + return 0;
59769 +}
59770 +
59771 +static int
59772 +copy_user_acl(struct gr_arg *arg)
59773 +{
59774 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59775 + struct acl_subject_label *subj_list;
59776 + struct sprole_pw *sptmp;
59777 + struct gr_hash_struct *ghash;
59778 + uid_t *domainlist;
59779 + unsigned int r_num;
59780 + unsigned int len;
59781 + char *tmp;
59782 + int err = 0;
59783 + __u16 i;
59784 + __u32 num_subjs;
59785 +
59786 + /* we need a default and kernel role */
59787 + if (arg->role_db.num_roles < 2)
59788 + return -EINVAL;
59789 +
59790 + /* copy special role authentication info from userspace */
59791 +
59792 + num_sprole_pws = arg->num_sprole_pws;
59793 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59794 +
59795 + if (!acl_special_roles && num_sprole_pws)
59796 + return -ENOMEM;
59797 +
59798 + for (i = 0; i < num_sprole_pws; i++) {
59799 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59800 + if (!sptmp)
59801 + return -ENOMEM;
59802 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59803 + sizeof (struct sprole_pw)))
59804 + return -EFAULT;
59805 +
59806 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59807 +
59808 + if (!len || len >= GR_SPROLE_LEN)
59809 + return -EINVAL;
59810 +
59811 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59812 + return -ENOMEM;
59813 +
59814 + if (copy_from_user(tmp, sptmp->rolename, len))
59815 + return -EFAULT;
59816 +
59817 + tmp[len-1] = '\0';
59818 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59819 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59820 +#endif
59821 + sptmp->rolename = tmp;
59822 + acl_special_roles[i] = sptmp;
59823 + }
59824 +
59825 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59826 +
59827 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59828 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59829 +
59830 + if (!r_tmp)
59831 + return -ENOMEM;
59832 +
59833 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59834 + sizeof (struct acl_role_label *)))
59835 + return -EFAULT;
59836 +
59837 + if (copy_from_user(r_tmp, r_utmp2,
59838 + sizeof (struct acl_role_label)))
59839 + return -EFAULT;
59840 +
59841 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59842 +
59843 + if (!len || len >= PATH_MAX)
59844 + return -EINVAL;
59845 +
59846 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59847 + return -ENOMEM;
59848 +
59849 + if (copy_from_user(tmp, r_tmp->rolename, len))
59850 + return -EFAULT;
59851 +
59852 + tmp[len-1] = '\0';
59853 + r_tmp->rolename = tmp;
59854 +
59855 + if (!strcmp(r_tmp->rolename, "default")
59856 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59857 + default_role = r_tmp;
59858 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59859 + kernel_role = r_tmp;
59860 + }
59861 +
59862 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59863 + return -ENOMEM;
59864 +
59865 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59866 + return -EFAULT;
59867 +
59868 + r_tmp->hash = ghash;
59869 +
59870 + num_subjs = count_user_subjs(r_tmp->hash->first);
59871 +
59872 + r_tmp->subj_hash_size = num_subjs;
59873 + r_tmp->subj_hash =
59874 + (struct acl_subject_label **)
59875 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59876 +
59877 + if (!r_tmp->subj_hash)
59878 + return -ENOMEM;
59879 +
59880 + err = copy_user_allowedips(r_tmp);
59881 + if (err)
59882 + return err;
59883 +
59884 + /* copy domain info */
59885 + if (r_tmp->domain_children != NULL) {
59886 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59887 + if (domainlist == NULL)
59888 + return -ENOMEM;
59889 +
59890 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59891 + return -EFAULT;
59892 +
59893 + r_tmp->domain_children = domainlist;
59894 + }
59895 +
59896 + err = copy_user_transitions(r_tmp);
59897 + if (err)
59898 + return err;
59899 +
59900 + memset(r_tmp->subj_hash, 0,
59901 + r_tmp->subj_hash_size *
59902 + sizeof (struct acl_subject_label *));
59903 +
59904 + /* acquire the list of subjects, then NULL out
59905 + the list prior to parsing the subjects for this role,
59906 + as during this parsing the list is replaced with a list
59907 + of *nested* subjects for the role
59908 + */
59909 + subj_list = r_tmp->hash->first;
59910 +
59911 + /* set nested subject list to null */
59912 + r_tmp->hash->first = NULL;
59913 +
59914 + err = copy_user_subjs(subj_list, r_tmp);
59915 +
59916 + if (err)
59917 + return err;
59918 +
59919 + insert_acl_role_label(r_tmp);
59920 + }
59921 +
59922 + if (default_role == NULL || kernel_role == NULL)
59923 + return -EINVAL;
59924 +
59925 + return err;
59926 +}
59927 +
59928 +static int
59929 +gracl_init(struct gr_arg *args)
59930 +{
59931 + int error = 0;
59932 +
59933 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59934 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59935 +
59936 + if (init_variables(args)) {
59937 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59938 + error = -ENOMEM;
59939 + free_variables();
59940 + goto out;
59941 + }
59942 +
59943 + error = copy_user_acl(args);
59944 + free_init_variables();
59945 + if (error) {
59946 + free_variables();
59947 + goto out;
59948 + }
59949 +
59950 + if ((error = gr_set_acls(0))) {
59951 + free_variables();
59952 + goto out;
59953 + }
59954 +
59955 + pax_open_kernel();
59956 + gr_status |= GR_READY;
59957 + pax_close_kernel();
59958 +
59959 + out:
59960 + return error;
59961 +}
59962 +
59963 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59964 +
59965 +static int
59966 +glob_match(const char *p, const char *n)
59967 +{
59968 + char c;
59969 +
59970 + while ((c = *p++) != '\0') {
59971 + switch (c) {
59972 + case '?':
59973 + if (*n == '\0')
59974 + return 1;
59975 + else if (*n == '/')
59976 + return 1;
59977 + break;
59978 + case '\\':
59979 + if (*n != c)
59980 + return 1;
59981 + break;
59982 + case '*':
59983 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59984 + if (*n == '/')
59985 + return 1;
59986 + else if (c == '?') {
59987 + if (*n == '\0')
59988 + return 1;
59989 + else
59990 + ++n;
59991 + }
59992 + }
59993 + if (c == '\0') {
59994 + return 0;
59995 + } else {
59996 + const char *endp;
59997 +
59998 + if ((endp = strchr(n, '/')) == NULL)
59999 + endp = n + strlen(n);
60000 +
60001 + if (c == '[') {
60002 + for (--p; n < endp; ++n)
60003 + if (!glob_match(p, n))
60004 + return 0;
60005 + } else if (c == '/') {
60006 + while (*n != '\0' && *n != '/')
60007 + ++n;
60008 + if (*n == '/' && !glob_match(p, n + 1))
60009 + return 0;
60010 + } else {
60011 + for (--p; n < endp; ++n)
60012 + if (*n == c && !glob_match(p, n))
60013 + return 0;
60014 + }
60015 +
60016 + return 1;
60017 + }
60018 + case '[':
60019 + {
60020 + int not;
60021 + char cold;
60022 +
60023 + if (*n == '\0' || *n == '/')
60024 + return 1;
60025 +
60026 + not = (*p == '!' || *p == '^');
60027 + if (not)
60028 + ++p;
60029 +
60030 + c = *p++;
60031 + for (;;) {
60032 + unsigned char fn = (unsigned char)*n;
60033 +
60034 + if (c == '\0')
60035 + return 1;
60036 + else {
60037 + if (c == fn)
60038 + goto matched;
60039 + cold = c;
60040 + c = *p++;
60041 +
60042 + if (c == '-' && *p != ']') {
60043 + unsigned char cend = *p++;
60044 +
60045 + if (cend == '\0')
60046 + return 1;
60047 +
60048 + if (cold <= fn && fn <= cend)
60049 + goto matched;
60050 +
60051 + c = *p++;
60052 + }
60053 + }
60054 +
60055 + if (c == ']')
60056 + break;
60057 + }
60058 + if (!not)
60059 + return 1;
60060 + break;
60061 + matched:
60062 + while (c != ']') {
60063 + if (c == '\0')
60064 + return 1;
60065 +
60066 + c = *p++;
60067 + }
60068 + if (not)
60069 + return 1;
60070 + }
60071 + break;
60072 + default:
60073 + if (c != *n)
60074 + return 1;
60075 + }
60076 +
60077 + ++n;
60078 + }
60079 +
60080 + if (*n == '\0')
60081 + return 0;
60082 +
60083 + if (*n == '/')
60084 + return 0;
60085 +
60086 + return 1;
60087 +}
60088 +
60089 +static struct acl_object_label *
60090 +chk_glob_label(struct acl_object_label *globbed,
60091 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60092 +{
60093 + struct acl_object_label *tmp;
60094 +
60095 + if (*path == NULL)
60096 + *path = gr_to_filename_nolock(dentry, mnt);
60097 +
60098 + tmp = globbed;
60099 +
60100 + while (tmp) {
60101 + if (!glob_match(tmp->filename, *path))
60102 + return tmp;
60103 + tmp = tmp->next;
60104 + }
60105 +
60106 + return NULL;
60107 +}
60108 +
60109 +static struct acl_object_label *
60110 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60111 + const ino_t curr_ino, const dev_t curr_dev,
60112 + const struct acl_subject_label *subj, char **path, const int checkglob)
60113 +{
60114 + struct acl_subject_label *tmpsubj;
60115 + struct acl_object_label *retval;
60116 + struct acl_object_label *retval2;
60117 +
60118 + tmpsubj = (struct acl_subject_label *) subj;
60119 + read_lock(&gr_inode_lock);
60120 + do {
60121 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60122 + if (retval) {
60123 + if (checkglob && retval->globbed) {
60124 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60125 + if (retval2)
60126 + retval = retval2;
60127 + }
60128 + break;
60129 + }
60130 + } while ((tmpsubj = tmpsubj->parent_subject));
60131 + read_unlock(&gr_inode_lock);
60132 +
60133 + return retval;
60134 +}
60135 +
60136 +static __inline__ struct acl_object_label *
60137 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60138 + struct dentry *curr_dentry,
60139 + const struct acl_subject_label *subj, char **path, const int checkglob)
60140 +{
60141 + int newglob = checkglob;
60142 + ino_t inode;
60143 + dev_t device;
60144 +
60145 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60146 + as we don't want a / * rule to match instead of the / object
60147 + don't do this for create lookups that call this function though, since they're looking up
60148 + on the parent and thus need globbing checks on all paths
60149 + */
60150 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60151 + newglob = GR_NO_GLOB;
60152 +
60153 + spin_lock(&curr_dentry->d_lock);
60154 + inode = curr_dentry->d_inode->i_ino;
60155 + device = __get_dev(curr_dentry);
60156 + spin_unlock(&curr_dentry->d_lock);
60157 +
60158 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60159 +}
60160 +
60161 +#ifdef CONFIG_HUGETLBFS
60162 +static inline bool
60163 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60164 +{
60165 + int i;
60166 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60167 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60168 + return true;
60169 + }
60170 +
60171 + return false;
60172 +}
60173 +#endif
60174 +
60175 +static struct acl_object_label *
60176 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60177 + const struct acl_subject_label *subj, char *path, const int checkglob)
60178 +{
60179 + struct dentry *dentry = (struct dentry *) l_dentry;
60180 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60181 + struct mount *real_mnt = real_mount(mnt);
60182 + struct acl_object_label *retval;
60183 + struct dentry *parent;
60184 +
60185 + br_read_lock(&vfsmount_lock);
60186 + write_seqlock(&rename_lock);
60187 +
60188 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60189 +#ifdef CONFIG_NET
60190 + mnt == sock_mnt ||
60191 +#endif
60192 +#ifdef CONFIG_HUGETLBFS
60193 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60194 +#endif
60195 + /* ignore Eric Biederman */
60196 + IS_PRIVATE(l_dentry->d_inode))) {
60197 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60198 + goto out;
60199 + }
60200 +
60201 + for (;;) {
60202 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60203 + break;
60204 +
60205 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60206 + if (!mnt_has_parent(real_mnt))
60207 + break;
60208 +
60209 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60210 + if (retval != NULL)
60211 + goto out;
60212 +
60213 + dentry = real_mnt->mnt_mountpoint;
60214 + real_mnt = real_mnt->mnt_parent;
60215 + mnt = &real_mnt->mnt;
60216 + continue;
60217 + }
60218 +
60219 + parent = dentry->d_parent;
60220 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60221 + if (retval != NULL)
60222 + goto out;
60223 +
60224 + dentry = parent;
60225 + }
60226 +
60227 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60228 +
60229 + /* real_root is pinned so we don't have to hold a reference */
60230 + if (retval == NULL)
60231 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60232 +out:
60233 + write_sequnlock(&rename_lock);
60234 + br_read_unlock(&vfsmount_lock);
60235 +
60236 + BUG_ON(retval == NULL);
60237 +
60238 + return retval;
60239 +}
60240 +
60241 +static __inline__ struct acl_object_label *
60242 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60243 + const struct acl_subject_label *subj)
60244 +{
60245 + char *path = NULL;
60246 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60247 +}
60248 +
60249 +static __inline__ struct acl_object_label *
60250 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60251 + const struct acl_subject_label *subj)
60252 +{
60253 + char *path = NULL;
60254 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60255 +}
60256 +
60257 +static __inline__ struct acl_object_label *
60258 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60259 + const struct acl_subject_label *subj, char *path)
60260 +{
60261 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60262 +}
60263 +
60264 +static struct acl_subject_label *
60265 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60266 + const struct acl_role_label *role)
60267 +{
60268 + struct dentry *dentry = (struct dentry *) l_dentry;
60269 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60270 + struct mount *real_mnt = real_mount(mnt);
60271 + struct acl_subject_label *retval;
60272 + struct dentry *parent;
60273 +
60274 + br_read_lock(&vfsmount_lock);
60275 + write_seqlock(&rename_lock);
60276 +
60277 + for (;;) {
60278 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60279 + break;
60280 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60281 + if (!mnt_has_parent(real_mnt))
60282 + break;
60283 +
60284 + spin_lock(&dentry->d_lock);
60285 + read_lock(&gr_inode_lock);
60286 + retval =
60287 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60288 + __get_dev(dentry), role);
60289 + read_unlock(&gr_inode_lock);
60290 + spin_unlock(&dentry->d_lock);
60291 + if (retval != NULL)
60292 + goto out;
60293 +
60294 + dentry = real_mnt->mnt_mountpoint;
60295 + real_mnt = real_mnt->mnt_parent;
60296 + mnt = &real_mnt->mnt;
60297 + continue;
60298 + }
60299 +
60300 + spin_lock(&dentry->d_lock);
60301 + read_lock(&gr_inode_lock);
60302 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60303 + __get_dev(dentry), role);
60304 + read_unlock(&gr_inode_lock);
60305 + parent = dentry->d_parent;
60306 + spin_unlock(&dentry->d_lock);
60307 +
60308 + if (retval != NULL)
60309 + goto out;
60310 +
60311 + dentry = parent;
60312 + }
60313 +
60314 + spin_lock(&dentry->d_lock);
60315 + read_lock(&gr_inode_lock);
60316 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60317 + __get_dev(dentry), role);
60318 + read_unlock(&gr_inode_lock);
60319 + spin_unlock(&dentry->d_lock);
60320 +
60321 + if (unlikely(retval == NULL)) {
60322 + /* real_root is pinned, we don't need to hold a reference */
60323 + read_lock(&gr_inode_lock);
60324 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60325 + __get_dev(real_root.dentry), role);
60326 + read_unlock(&gr_inode_lock);
60327 + }
60328 +out:
60329 + write_sequnlock(&rename_lock);
60330 + br_read_unlock(&vfsmount_lock);
60331 +
60332 + BUG_ON(retval == NULL);
60333 +
60334 + return retval;
60335 +}
60336 +
60337 +static void
60338 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60339 +{
60340 + struct task_struct *task = current;
60341 + const struct cred *cred = current_cred();
60342 +
60343 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60344 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60345 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60346 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60347 +
60348 + return;
60349 +}
60350 +
60351 +static void
60352 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60353 +{
60354 + struct task_struct *task = current;
60355 + const struct cred *cred = current_cred();
60356 +
60357 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60358 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60359 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60360 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60361 +
60362 + return;
60363 +}
60364 +
60365 +static void
60366 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60367 +{
60368 + struct task_struct *task = current;
60369 + const struct cred *cred = current_cred();
60370 +
60371 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60372 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60373 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60374 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60375 +
60376 + return;
60377 +}
60378 +
60379 +__u32
60380 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60381 + const struct vfsmount * mnt)
60382 +{
60383 + __u32 retval = mode;
60384 + struct acl_subject_label *curracl;
60385 + struct acl_object_label *currobj;
60386 +
60387 + if (unlikely(!(gr_status & GR_READY)))
60388 + return (mode & ~GR_AUDITS);
60389 +
60390 + curracl = current->acl;
60391 +
60392 + currobj = chk_obj_label(dentry, mnt, curracl);
60393 + retval = currobj->mode & mode;
60394 +
60395 + /* if we're opening a specified transfer file for writing
60396 + (e.g. /dev/initctl), then transfer our role to init
60397 + */
60398 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60399 + current->role->roletype & GR_ROLE_PERSIST)) {
60400 + struct task_struct *task = init_pid_ns.child_reaper;
60401 +
60402 + if (task->role != current->role) {
60403 + task->acl_sp_role = 0;
60404 + task->acl_role_id = current->acl_role_id;
60405 + task->role = current->role;
60406 + rcu_read_lock();
60407 + read_lock(&grsec_exec_file_lock);
60408 + gr_apply_subject_to_task(task);
60409 + read_unlock(&grsec_exec_file_lock);
60410 + rcu_read_unlock();
60411 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60412 + }
60413 + }
60414 +
60415 + if (unlikely
60416 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60417 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60418 + __u32 new_mode = mode;
60419 +
60420 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60421 +
60422 + retval = new_mode;
60423 +
60424 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60425 + new_mode |= GR_INHERIT;
60426 +
60427 + if (!(mode & GR_NOLEARN))
60428 + gr_log_learn(dentry, mnt, new_mode);
60429 + }
60430 +
60431 + return retval;
60432 +}
60433 +
60434 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60435 + const struct dentry *parent,
60436 + const struct vfsmount *mnt)
60437 +{
60438 + struct name_entry *match;
60439 + struct acl_object_label *matchpo;
60440 + struct acl_subject_label *curracl;
60441 + char *path;
60442 +
60443 + if (unlikely(!(gr_status & GR_READY)))
60444 + return NULL;
60445 +
60446 + preempt_disable();
60447 + path = gr_to_filename_rbac(new_dentry, mnt);
60448 + match = lookup_name_entry_create(path);
60449 +
60450 + curracl = current->acl;
60451 +
60452 + if (match) {
60453 + read_lock(&gr_inode_lock);
60454 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60455 + read_unlock(&gr_inode_lock);
60456 +
60457 + if (matchpo) {
60458 + preempt_enable();
60459 + return matchpo;
60460 + }
60461 + }
60462 +
60463 + // lookup parent
60464 +
60465 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60466 +
60467 + preempt_enable();
60468 + return matchpo;
60469 +}
60470 +
60471 +__u32
60472 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60473 + const struct vfsmount * mnt, const __u32 mode)
60474 +{
60475 + struct acl_object_label *matchpo;
60476 + __u32 retval;
60477 +
60478 + if (unlikely(!(gr_status & GR_READY)))
60479 + return (mode & ~GR_AUDITS);
60480 +
60481 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60482 +
60483 + retval = matchpo->mode & mode;
60484 +
60485 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60486 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60487 + __u32 new_mode = mode;
60488 +
60489 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60490 +
60491 + gr_log_learn(new_dentry, mnt, new_mode);
60492 + return new_mode;
60493 + }
60494 +
60495 + return retval;
60496 +}
60497 +
60498 +__u32
60499 +gr_check_link(const struct dentry * new_dentry,
60500 + const struct dentry * parent_dentry,
60501 + const struct vfsmount * parent_mnt,
60502 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60503 +{
60504 + struct acl_object_label *obj;
60505 + __u32 oldmode, newmode;
60506 + __u32 needmode;
60507 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60508 + GR_DELETE | GR_INHERIT;
60509 +
60510 + if (unlikely(!(gr_status & GR_READY)))
60511 + return (GR_CREATE | GR_LINK);
60512 +
60513 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60514 + oldmode = obj->mode;
60515 +
60516 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60517 + newmode = obj->mode;
60518 +
60519 + needmode = newmode & checkmodes;
60520 +
60521 + // old name for hardlink must have at least the permissions of the new name
60522 + if ((oldmode & needmode) != needmode)
60523 + goto bad;
60524 +
60525 + // if old name had restrictions/auditing, make sure the new name does as well
60526 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60527 +
60528 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60529 + if (is_privileged_binary(old_dentry))
60530 + needmode |= GR_SETID;
60531 +
60532 + if ((newmode & needmode) != needmode)
60533 + goto bad;
60534 +
60535 + // enforce minimum permissions
60536 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60537 + return newmode;
60538 +bad:
60539 + needmode = oldmode;
60540 + if (is_privileged_binary(old_dentry))
60541 + needmode |= GR_SETID;
60542 +
60543 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60544 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60545 + return (GR_CREATE | GR_LINK);
60546 + } else if (newmode & GR_SUPPRESS)
60547 + return GR_SUPPRESS;
60548 + else
60549 + return 0;
60550 +}
60551 +
60552 +int
60553 +gr_check_hidden_task(const struct task_struct *task)
60554 +{
60555 + if (unlikely(!(gr_status & GR_READY)))
60556 + return 0;
60557 +
60558 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60559 + return 1;
60560 +
60561 + return 0;
60562 +}
60563 +
60564 +int
60565 +gr_check_protected_task(const struct task_struct *task)
60566 +{
60567 + if (unlikely(!(gr_status & GR_READY) || !task))
60568 + return 0;
60569 +
60570 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60571 + task->acl != current->acl)
60572 + return 1;
60573 +
60574 + return 0;
60575 +}
60576 +
60577 +int
60578 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60579 +{
60580 + struct task_struct *p;
60581 + int ret = 0;
60582 +
60583 + if (unlikely(!(gr_status & GR_READY) || !pid))
60584 + return ret;
60585 +
60586 + read_lock(&tasklist_lock);
60587 + do_each_pid_task(pid, type, p) {
60588 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60589 + p->acl != current->acl) {
60590 + ret = 1;
60591 + goto out;
60592 + }
60593 + } while_each_pid_task(pid, type, p);
60594 +out:
60595 + read_unlock(&tasklist_lock);
60596 +
60597 + return ret;
60598 +}
60599 +
60600 +void
60601 +gr_copy_label(struct task_struct *tsk)
60602 +{
60603 + tsk->signal->used_accept = 0;
60604 + tsk->acl_sp_role = 0;
60605 + tsk->acl_role_id = current->acl_role_id;
60606 + tsk->acl = current->acl;
60607 + tsk->role = current->role;
60608 + tsk->signal->curr_ip = current->signal->curr_ip;
60609 + tsk->signal->saved_ip = current->signal->saved_ip;
60610 + if (current->exec_file)
60611 + get_file(current->exec_file);
60612 + tsk->exec_file = current->exec_file;
60613 + tsk->is_writable = current->is_writable;
60614 + if (unlikely(current->signal->used_accept)) {
60615 + current->signal->curr_ip = 0;
60616 + current->signal->saved_ip = 0;
60617 + }
60618 +
60619 + return;
60620 +}
60621 +
60622 +static void
60623 +gr_set_proc_res(struct task_struct *task)
60624 +{
60625 + struct acl_subject_label *proc;
60626 + unsigned short i;
60627 +
60628 + proc = task->acl;
60629 +
60630 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60631 + return;
60632 +
60633 + for (i = 0; i < RLIM_NLIMITS; i++) {
60634 + if (!(proc->resmask & (1U << i)))
60635 + continue;
60636 +
60637 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60638 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60639 +
60640 + if (i == RLIMIT_CPU)
60641 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60642 + }
60643 +
60644 + return;
60645 +}
60646 +
60647 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
60648 +
60649 +int
60650 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60651 +{
60652 + unsigned int i;
60653 + __u16 num;
60654 + uid_t *uidlist;
60655 + uid_t curuid;
60656 + int realok = 0;
60657 + int effectiveok = 0;
60658 + int fsok = 0;
60659 + uid_t globalreal, globaleffective, globalfs;
60660 +
60661 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
60662 + struct user_struct *user;
60663 +
60664 + if (!uid_valid(real))
60665 + goto skipit;
60666 +
60667 + /* find user based on global namespace */
60668 +
60669 + globalreal = GR_GLOBAL_UID(real);
60670 +
60671 + user = find_user(make_kuid(&init_user_ns, globalreal));
60672 + if (user == NULL)
60673 + goto skipit;
60674 +
60675 + if (gr_process_kernel_setuid_ban(user)) {
60676 + /* for find_user */
60677 + free_uid(user);
60678 + return 1;
60679 + }
60680 +
60681 + /* for find_user */
60682 + free_uid(user);
60683 +
60684 +skipit:
60685 +#endif
60686 +
60687 + if (unlikely(!(gr_status & GR_READY)))
60688 + return 0;
60689 +
60690 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60691 + gr_log_learn_uid_change(real, effective, fs);
60692 +
60693 + num = current->acl->user_trans_num;
60694 + uidlist = current->acl->user_transitions;
60695 +
60696 + if (uidlist == NULL)
60697 + return 0;
60698 +
60699 + if (!uid_valid(real)) {
60700 + realok = 1;
60701 + globalreal = (uid_t)-1;
60702 + } else {
60703 + globalreal = GR_GLOBAL_UID(real);
60704 + }
60705 + if (!uid_valid(effective)) {
60706 + effectiveok = 1;
60707 + globaleffective = (uid_t)-1;
60708 + } else {
60709 + globaleffective = GR_GLOBAL_UID(effective);
60710 + }
60711 + if (!uid_valid(fs)) {
60712 + fsok = 1;
60713 + globalfs = (uid_t)-1;
60714 + } else {
60715 + globalfs = GR_GLOBAL_UID(fs);
60716 + }
60717 +
60718 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60719 + for (i = 0; i < num; i++) {
60720 + curuid = uidlist[i];
60721 + if (globalreal == curuid)
60722 + realok = 1;
60723 + if (globaleffective == curuid)
60724 + effectiveok = 1;
60725 + if (globalfs == curuid)
60726 + fsok = 1;
60727 + }
60728 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60729 + for (i = 0; i < num; i++) {
60730 + curuid = uidlist[i];
60731 + if (globalreal == curuid)
60732 + break;
60733 + if (globaleffective == curuid)
60734 + break;
60735 + if (globalfs == curuid)
60736 + break;
60737 + }
60738 + /* not in deny list */
60739 + if (i == num) {
60740 + realok = 1;
60741 + effectiveok = 1;
60742 + fsok = 1;
60743 + }
60744 + }
60745 +
60746 + if (realok && effectiveok && fsok)
60747 + return 0;
60748 + else {
60749 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60750 + return 1;
60751 + }
60752 +}
60753 +
60754 +int
60755 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60756 +{
60757 + unsigned int i;
60758 + __u16 num;
60759 + gid_t *gidlist;
60760 + gid_t curgid;
60761 + int realok = 0;
60762 + int effectiveok = 0;
60763 + int fsok = 0;
60764 + gid_t globalreal, globaleffective, globalfs;
60765 +
60766 + if (unlikely(!(gr_status & GR_READY)))
60767 + return 0;
60768 +
60769 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60770 + gr_log_learn_gid_change(real, effective, fs);
60771 +
60772 + num = current->acl->group_trans_num;
60773 + gidlist = current->acl->group_transitions;
60774 +
60775 + if (gidlist == NULL)
60776 + return 0;
60777 +
60778 + if (!gid_valid(real)) {
60779 + realok = 1;
60780 + globalreal = (gid_t)-1;
60781 + } else {
60782 + globalreal = GR_GLOBAL_GID(real);
60783 + }
60784 + if (!gid_valid(effective)) {
60785 + effectiveok = 1;
60786 + globaleffective = (gid_t)-1;
60787 + } else {
60788 + globaleffective = GR_GLOBAL_GID(effective);
60789 + }
60790 + if (!gid_valid(fs)) {
60791 + fsok = 1;
60792 + globalfs = (gid_t)-1;
60793 + } else {
60794 + globalfs = GR_GLOBAL_GID(fs);
60795 + }
60796 +
60797 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60798 + for (i = 0; i < num; i++) {
60799 + curgid = gidlist[i];
60800 + if (globalreal == curgid)
60801 + realok = 1;
60802 + if (globaleffective == curgid)
60803 + effectiveok = 1;
60804 + if (globalfs == curgid)
60805 + fsok = 1;
60806 + }
60807 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60808 + for (i = 0; i < num; i++) {
60809 + curgid = gidlist[i];
60810 + if (globalreal == curgid)
60811 + break;
60812 + if (globaleffective == curgid)
60813 + break;
60814 + if (globalfs == curgid)
60815 + break;
60816 + }
60817 + /* not in deny list */
60818 + if (i == num) {
60819 + realok = 1;
60820 + effectiveok = 1;
60821 + fsok = 1;
60822 + }
60823 + }
60824 +
60825 + if (realok && effectiveok && fsok)
60826 + return 0;
60827 + else {
60828 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60829 + return 1;
60830 + }
60831 +}
60832 +
60833 +extern int gr_acl_is_capable(const int cap);
60834 +
60835 +void
60836 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60837 +{
60838 + struct acl_role_label *role = task->role;
60839 + struct acl_subject_label *subj = NULL;
60840 + struct acl_object_label *obj;
60841 + struct file *filp;
60842 + uid_t uid;
60843 + gid_t gid;
60844 +
60845 + if (unlikely(!(gr_status & GR_READY)))
60846 + return;
60847 +
60848 + uid = GR_GLOBAL_UID(kuid);
60849 + gid = GR_GLOBAL_GID(kgid);
60850 +
60851 + filp = task->exec_file;
60852 +
60853 + /* kernel process, we'll give them the kernel role */
60854 + if (unlikely(!filp)) {
60855 + task->role = kernel_role;
60856 + task->acl = kernel_role->root_label;
60857 + return;
60858 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60859 + role = lookup_acl_role_label(task, uid, gid);
60860 +
60861 + /* don't change the role if we're not a privileged process */
60862 + if (role && task->role != role &&
60863 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60864 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60865 + return;
60866 +
60867 + /* perform subject lookup in possibly new role
60868 + we can use this result below in the case where role == task->role
60869 + */
60870 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60871 +
60872 + /* if we changed uid/gid, but result in the same role
60873 + and are using inheritance, don't lose the inherited subject
60874 + if current subject is other than what normal lookup
60875 + would result in, we arrived via inheritance, don't
60876 + lose subject
60877 + */
60878 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60879 + (subj == task->acl)))
60880 + task->acl = subj;
60881 +
60882 + task->role = role;
60883 +
60884 + task->is_writable = 0;
60885 +
60886 + /* ignore additional mmap checks for processes that are writable
60887 + by the default ACL */
60888 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60889 + if (unlikely(obj->mode & GR_WRITE))
60890 + task->is_writable = 1;
60891 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60892 + if (unlikely(obj->mode & GR_WRITE))
60893 + task->is_writable = 1;
60894 +
60895 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60896 + 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);
60897 +#endif
60898 +
60899 + gr_set_proc_res(task);
60900 +
60901 + return;
60902 +}
60903 +
60904 +int
60905 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60906 + const int unsafe_flags)
60907 +{
60908 + struct task_struct *task = current;
60909 + struct acl_subject_label *newacl;
60910 + struct acl_object_label *obj;
60911 + __u32 retmode;
60912 +
60913 + if (unlikely(!(gr_status & GR_READY)))
60914 + return 0;
60915 +
60916 + newacl = chk_subj_label(dentry, mnt, task->role);
60917 +
60918 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60919 + did an exec
60920 + */
60921 + rcu_read_lock();
60922 + read_lock(&tasklist_lock);
60923 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60924 + (task->parent->acl->mode & GR_POVERRIDE))) {
60925 + read_unlock(&tasklist_lock);
60926 + rcu_read_unlock();
60927 + goto skip_check;
60928 + }
60929 + read_unlock(&tasklist_lock);
60930 + rcu_read_unlock();
60931 +
60932 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60933 + !(task->role->roletype & GR_ROLE_GOD) &&
60934 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60935 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60936 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60937 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60938 + else
60939 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60940 + return -EACCES;
60941 + }
60942 +
60943 +skip_check:
60944 +
60945 + obj = chk_obj_label(dentry, mnt, task->acl);
60946 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60947 +
60948 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60949 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60950 + if (obj->nested)
60951 + task->acl = obj->nested;
60952 + else
60953 + task->acl = newacl;
60954 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60955 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60956 +
60957 + task->is_writable = 0;
60958 +
60959 + /* ignore additional mmap checks for processes that are writable
60960 + by the default ACL */
60961 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60962 + if (unlikely(obj->mode & GR_WRITE))
60963 + task->is_writable = 1;
60964 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60965 + if (unlikely(obj->mode & GR_WRITE))
60966 + task->is_writable = 1;
60967 +
60968 + gr_set_proc_res(task);
60969 +
60970 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60971 + 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);
60972 +#endif
60973 + return 0;
60974 +}
60975 +
60976 +/* always called with valid inodev ptr */
60977 +static void
60978 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60979 +{
60980 + struct acl_object_label *matchpo;
60981 + struct acl_subject_label *matchps;
60982 + struct acl_subject_label *subj;
60983 + struct acl_role_label *role;
60984 + unsigned int x;
60985 +
60986 + FOR_EACH_ROLE_START(role)
60987 + FOR_EACH_SUBJECT_START(role, subj, x)
60988 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60989 + matchpo->mode |= GR_DELETED;
60990 + FOR_EACH_SUBJECT_END(subj,x)
60991 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60992 + /* nested subjects aren't in the role's subj_hash table */
60993 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60994 + matchpo->mode |= GR_DELETED;
60995 + FOR_EACH_NESTED_SUBJECT_END(subj)
60996 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60997 + matchps->mode |= GR_DELETED;
60998 + FOR_EACH_ROLE_END(role)
60999 +
61000 + inodev->nentry->deleted = 1;
61001 +
61002 + return;
61003 +}
61004 +
61005 +void
61006 +gr_handle_delete(const ino_t ino, const dev_t dev)
61007 +{
61008 + struct inodev_entry *inodev;
61009 +
61010 + if (unlikely(!(gr_status & GR_READY)))
61011 + return;
61012 +
61013 + write_lock(&gr_inode_lock);
61014 + inodev = lookup_inodev_entry(ino, dev);
61015 + if (inodev != NULL)
61016 + do_handle_delete(inodev, ino, dev);
61017 + write_unlock(&gr_inode_lock);
61018 +
61019 + return;
61020 +}
61021 +
61022 +static void
61023 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
61024 + const ino_t newinode, const dev_t newdevice,
61025 + struct acl_subject_label *subj)
61026 +{
61027 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
61028 + struct acl_object_label *match;
61029 +
61030 + match = subj->obj_hash[index];
61031 +
61032 + while (match && (match->inode != oldinode ||
61033 + match->device != olddevice ||
61034 + !(match->mode & GR_DELETED)))
61035 + match = match->next;
61036 +
61037 + if (match && (match->inode == oldinode)
61038 + && (match->device == olddevice)
61039 + && (match->mode & GR_DELETED)) {
61040 + if (match->prev == NULL) {
61041 + subj->obj_hash[index] = match->next;
61042 + if (match->next != NULL)
61043 + match->next->prev = NULL;
61044 + } else {
61045 + match->prev->next = match->next;
61046 + if (match->next != NULL)
61047 + match->next->prev = match->prev;
61048 + }
61049 + match->prev = NULL;
61050 + match->next = NULL;
61051 + match->inode = newinode;
61052 + match->device = newdevice;
61053 + match->mode &= ~GR_DELETED;
61054 +
61055 + insert_acl_obj_label(match, subj);
61056 + }
61057 +
61058 + return;
61059 +}
61060 +
61061 +static void
61062 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
61063 + const ino_t newinode, const dev_t newdevice,
61064 + struct acl_role_label *role)
61065 +{
61066 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
61067 + struct acl_subject_label *match;
61068 +
61069 + match = role->subj_hash[index];
61070 +
61071 + while (match && (match->inode != oldinode ||
61072 + match->device != olddevice ||
61073 + !(match->mode & GR_DELETED)))
61074 + match = match->next;
61075 +
61076 + if (match && (match->inode == oldinode)
61077 + && (match->device == olddevice)
61078 + && (match->mode & GR_DELETED)) {
61079 + if (match->prev == NULL) {
61080 + role->subj_hash[index] = match->next;
61081 + if (match->next != NULL)
61082 + match->next->prev = NULL;
61083 + } else {
61084 + match->prev->next = match->next;
61085 + if (match->next != NULL)
61086 + match->next->prev = match->prev;
61087 + }
61088 + match->prev = NULL;
61089 + match->next = NULL;
61090 + match->inode = newinode;
61091 + match->device = newdevice;
61092 + match->mode &= ~GR_DELETED;
61093 +
61094 + insert_acl_subj_label(match, role);
61095 + }
61096 +
61097 + return;
61098 +}
61099 +
61100 +static void
61101 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61102 + const ino_t newinode, const dev_t newdevice)
61103 +{
61104 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61105 + struct inodev_entry *match;
61106 +
61107 + match = inodev_set.i_hash[index];
61108 +
61109 + while (match && (match->nentry->inode != oldinode ||
61110 + match->nentry->device != olddevice || !match->nentry->deleted))
61111 + match = match->next;
61112 +
61113 + if (match && (match->nentry->inode == oldinode)
61114 + && (match->nentry->device == olddevice) &&
61115 + match->nentry->deleted) {
61116 + if (match->prev == NULL) {
61117 + inodev_set.i_hash[index] = match->next;
61118 + if (match->next != NULL)
61119 + match->next->prev = NULL;
61120 + } else {
61121 + match->prev->next = match->next;
61122 + if (match->next != NULL)
61123 + match->next->prev = match->prev;
61124 + }
61125 + match->prev = NULL;
61126 + match->next = NULL;
61127 + match->nentry->inode = newinode;
61128 + match->nentry->device = newdevice;
61129 + match->nentry->deleted = 0;
61130 +
61131 + insert_inodev_entry(match);
61132 + }
61133 +
61134 + return;
61135 +}
61136 +
61137 +static void
61138 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61139 +{
61140 + struct acl_subject_label *subj;
61141 + struct acl_role_label *role;
61142 + unsigned int x;
61143 +
61144 + FOR_EACH_ROLE_START(role)
61145 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61146 +
61147 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61148 + if ((subj->inode == ino) && (subj->device == dev)) {
61149 + subj->inode = ino;
61150 + subj->device = dev;
61151 + }
61152 + /* nested subjects aren't in the role's subj_hash table */
61153 + update_acl_obj_label(matchn->inode, matchn->device,
61154 + ino, dev, subj);
61155 + FOR_EACH_NESTED_SUBJECT_END(subj)
61156 + FOR_EACH_SUBJECT_START(role, subj, x)
61157 + update_acl_obj_label(matchn->inode, matchn->device,
61158 + ino, dev, subj);
61159 + FOR_EACH_SUBJECT_END(subj,x)
61160 + FOR_EACH_ROLE_END(role)
61161 +
61162 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61163 +
61164 + return;
61165 +}
61166 +
61167 +static void
61168 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61169 + const struct vfsmount *mnt)
61170 +{
61171 + ino_t ino = dentry->d_inode->i_ino;
61172 + dev_t dev = __get_dev(dentry);
61173 +
61174 + __do_handle_create(matchn, ino, dev);
61175 +
61176 + return;
61177 +}
61178 +
61179 +void
61180 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61181 +{
61182 + struct name_entry *matchn;
61183 +
61184 + if (unlikely(!(gr_status & GR_READY)))
61185 + return;
61186 +
61187 + preempt_disable();
61188 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61189 +
61190 + if (unlikely((unsigned long)matchn)) {
61191 + write_lock(&gr_inode_lock);
61192 + do_handle_create(matchn, dentry, mnt);
61193 + write_unlock(&gr_inode_lock);
61194 + }
61195 + preempt_enable();
61196 +
61197 + return;
61198 +}
61199 +
61200 +void
61201 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61202 +{
61203 + struct name_entry *matchn;
61204 +
61205 + if (unlikely(!(gr_status & GR_READY)))
61206 + return;
61207 +
61208 + preempt_disable();
61209 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61210 +
61211 + if (unlikely((unsigned long)matchn)) {
61212 + write_lock(&gr_inode_lock);
61213 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61214 + write_unlock(&gr_inode_lock);
61215 + }
61216 + preempt_enable();
61217 +
61218 + return;
61219 +}
61220 +
61221 +void
61222 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61223 + struct dentry *old_dentry,
61224 + struct dentry *new_dentry,
61225 + struct vfsmount *mnt, const __u8 replace)
61226 +{
61227 + struct name_entry *matchn;
61228 + struct inodev_entry *inodev;
61229 + struct inode *inode = new_dentry->d_inode;
61230 + ino_t old_ino = old_dentry->d_inode->i_ino;
61231 + dev_t old_dev = __get_dev(old_dentry);
61232 +
61233 + /* vfs_rename swaps the name and parent link for old_dentry and
61234 + new_dentry
61235 + at this point, old_dentry has the new name, parent link, and inode
61236 + for the renamed file
61237 + if a file is being replaced by a rename, new_dentry has the inode
61238 + and name for the replaced file
61239 + */
61240 +
61241 + if (unlikely(!(gr_status & GR_READY)))
61242 + return;
61243 +
61244 + preempt_disable();
61245 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61246 +
61247 + /* we wouldn't have to check d_inode if it weren't for
61248 + NFS silly-renaming
61249 + */
61250 +
61251 + write_lock(&gr_inode_lock);
61252 + if (unlikely(replace && inode)) {
61253 + ino_t new_ino = inode->i_ino;
61254 + dev_t new_dev = __get_dev(new_dentry);
61255 +
61256 + inodev = lookup_inodev_entry(new_ino, new_dev);
61257 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61258 + do_handle_delete(inodev, new_ino, new_dev);
61259 + }
61260 +
61261 + inodev = lookup_inodev_entry(old_ino, old_dev);
61262 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61263 + do_handle_delete(inodev, old_ino, old_dev);
61264 +
61265 + if (unlikely((unsigned long)matchn))
61266 + do_handle_create(matchn, old_dentry, mnt);
61267 +
61268 + write_unlock(&gr_inode_lock);
61269 + preempt_enable();
61270 +
61271 + return;
61272 +}
61273 +
61274 +static int
61275 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61276 + unsigned char **sum)
61277 +{
61278 + struct acl_role_label *r;
61279 + struct role_allowed_ip *ipp;
61280 + struct role_transition *trans;
61281 + unsigned int i;
61282 + int found = 0;
61283 + u32 curr_ip = current->signal->curr_ip;
61284 +
61285 + current->signal->saved_ip = curr_ip;
61286 +
61287 + /* check transition table */
61288 +
61289 + for (trans = current->role->transitions; trans; trans = trans->next) {
61290 + if (!strcmp(rolename, trans->rolename)) {
61291 + found = 1;
61292 + break;
61293 + }
61294 + }
61295 +
61296 + if (!found)
61297 + return 0;
61298 +
61299 + /* handle special roles that do not require authentication
61300 + and check ip */
61301 +
61302 + FOR_EACH_ROLE_START(r)
61303 + if (!strcmp(rolename, r->rolename) &&
61304 + (r->roletype & GR_ROLE_SPECIAL)) {
61305 + found = 0;
61306 + if (r->allowed_ips != NULL) {
61307 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61308 + if ((ntohl(curr_ip) & ipp->netmask) ==
61309 + (ntohl(ipp->addr) & ipp->netmask))
61310 + found = 1;
61311 + }
61312 + } else
61313 + found = 2;
61314 + if (!found)
61315 + return 0;
61316 +
61317 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61318 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61319 + *salt = NULL;
61320 + *sum = NULL;
61321 + return 1;
61322 + }
61323 + }
61324 + FOR_EACH_ROLE_END(r)
61325 +
61326 + for (i = 0; i < num_sprole_pws; i++) {
61327 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61328 + *salt = acl_special_roles[i]->salt;
61329 + *sum = acl_special_roles[i]->sum;
61330 + return 1;
61331 + }
61332 + }
61333 +
61334 + return 0;
61335 +}
61336 +
61337 +static void
61338 +assign_special_role(char *rolename)
61339 +{
61340 + struct acl_object_label *obj;
61341 + struct acl_role_label *r;
61342 + struct acl_role_label *assigned = NULL;
61343 + struct task_struct *tsk;
61344 + struct file *filp;
61345 +
61346 + FOR_EACH_ROLE_START(r)
61347 + if (!strcmp(rolename, r->rolename) &&
61348 + (r->roletype & GR_ROLE_SPECIAL)) {
61349 + assigned = r;
61350 + break;
61351 + }
61352 + FOR_EACH_ROLE_END(r)
61353 +
61354 + if (!assigned)
61355 + return;
61356 +
61357 + read_lock(&tasklist_lock);
61358 + read_lock(&grsec_exec_file_lock);
61359 +
61360 + tsk = current->real_parent;
61361 + if (tsk == NULL)
61362 + goto out_unlock;
61363 +
61364 + filp = tsk->exec_file;
61365 + if (filp == NULL)
61366 + goto out_unlock;
61367 +
61368 + tsk->is_writable = 0;
61369 +
61370 + tsk->acl_sp_role = 1;
61371 + tsk->acl_role_id = ++acl_sp_role_value;
61372 + tsk->role = assigned;
61373 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61374 +
61375 + /* ignore additional mmap checks for processes that are writable
61376 + by the default ACL */
61377 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61378 + if (unlikely(obj->mode & GR_WRITE))
61379 + tsk->is_writable = 1;
61380 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61381 + if (unlikely(obj->mode & GR_WRITE))
61382 + tsk->is_writable = 1;
61383 +
61384 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61385 + 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));
61386 +#endif
61387 +
61388 +out_unlock:
61389 + read_unlock(&grsec_exec_file_lock);
61390 + read_unlock(&tasklist_lock);
61391 + return;
61392 +}
61393 +
61394 +int gr_check_secure_terminal(struct task_struct *task)
61395 +{
61396 + struct task_struct *p, *p2, *p3;
61397 + struct files_struct *files;
61398 + struct fdtable *fdt;
61399 + struct file *our_file = NULL, *file;
61400 + int i;
61401 +
61402 + if (task->signal->tty == NULL)
61403 + return 1;
61404 +
61405 + files = get_files_struct(task);
61406 + if (files != NULL) {
61407 + rcu_read_lock();
61408 + fdt = files_fdtable(files);
61409 + for (i=0; i < fdt->max_fds; i++) {
61410 + file = fcheck_files(files, i);
61411 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61412 + get_file(file);
61413 + our_file = file;
61414 + }
61415 + }
61416 + rcu_read_unlock();
61417 + put_files_struct(files);
61418 + }
61419 +
61420 + if (our_file == NULL)
61421 + return 1;
61422 +
61423 + read_lock(&tasklist_lock);
61424 + do_each_thread(p2, p) {
61425 + files = get_files_struct(p);
61426 + if (files == NULL ||
61427 + (p->signal && p->signal->tty == task->signal->tty)) {
61428 + if (files != NULL)
61429 + put_files_struct(files);
61430 + continue;
61431 + }
61432 + rcu_read_lock();
61433 + fdt = files_fdtable(files);
61434 + for (i=0; i < fdt->max_fds; i++) {
61435 + file = fcheck_files(files, i);
61436 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61437 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61438 + p3 = task;
61439 + while (task_pid_nr(p3) > 0) {
61440 + if (p3 == p)
61441 + break;
61442 + p3 = p3->real_parent;
61443 + }
61444 + if (p3 == p)
61445 + break;
61446 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61447 + gr_handle_alertkill(p);
61448 + rcu_read_unlock();
61449 + put_files_struct(files);
61450 + read_unlock(&tasklist_lock);
61451 + fput(our_file);
61452 + return 0;
61453 + }
61454 + }
61455 + rcu_read_unlock();
61456 + put_files_struct(files);
61457 + } while_each_thread(p2, p);
61458 + read_unlock(&tasklist_lock);
61459 +
61460 + fput(our_file);
61461 + return 1;
61462 +}
61463 +
61464 +static int gr_rbac_disable(void *unused)
61465 +{
61466 + pax_open_kernel();
61467 + gr_status &= ~GR_READY;
61468 + pax_close_kernel();
61469 +
61470 + return 0;
61471 +}
61472 +
61473 +ssize_t
61474 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61475 +{
61476 + struct gr_arg_wrapper uwrap;
61477 + unsigned char *sprole_salt = NULL;
61478 + unsigned char *sprole_sum = NULL;
61479 + int error = sizeof (struct gr_arg_wrapper);
61480 + int error2 = 0;
61481 +
61482 + mutex_lock(&gr_dev_mutex);
61483 +
61484 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61485 + error = -EPERM;
61486 + goto out;
61487 + }
61488 +
61489 + if (count != sizeof (struct gr_arg_wrapper)) {
61490 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61491 + error = -EINVAL;
61492 + goto out;
61493 + }
61494 +
61495 +
61496 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61497 + gr_auth_expires = 0;
61498 + gr_auth_attempts = 0;
61499 + }
61500 +
61501 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61502 + error = -EFAULT;
61503 + goto out;
61504 + }
61505 +
61506 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61507 + error = -EINVAL;
61508 + goto out;
61509 + }
61510 +
61511 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61512 + error = -EFAULT;
61513 + goto out;
61514 + }
61515 +
61516 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61517 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61518 + time_after(gr_auth_expires, get_seconds())) {
61519 + error = -EBUSY;
61520 + goto out;
61521 + }
61522 +
61523 + /* if non-root trying to do anything other than use a special role,
61524 + do not attempt authentication, do not count towards authentication
61525 + locking
61526 + */
61527 +
61528 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61529 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61530 + gr_is_global_nonroot(current_uid())) {
61531 + error = -EPERM;
61532 + goto out;
61533 + }
61534 +
61535 + /* ensure pw and special role name are null terminated */
61536 +
61537 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61538 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61539 +
61540 + /* Okay.
61541 + * We have our enough of the argument structure..(we have yet
61542 + * to copy_from_user the tables themselves) . Copy the tables
61543 + * only if we need them, i.e. for loading operations. */
61544 +
61545 + switch (gr_usermode->mode) {
61546 + case GR_STATUS:
61547 + if (gr_status & GR_READY) {
61548 + error = 1;
61549 + if (!gr_check_secure_terminal(current))
61550 + error = 3;
61551 + } else
61552 + error = 2;
61553 + goto out;
61554 + case GR_SHUTDOWN:
61555 + if ((gr_status & GR_READY)
61556 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61557 + stop_machine(gr_rbac_disable, NULL, NULL);
61558 + free_variables();
61559 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61560 + memset(gr_system_salt, 0, GR_SALT_LEN);
61561 + memset(gr_system_sum, 0, GR_SHA_LEN);
61562 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61563 + } else if (gr_status & GR_READY) {
61564 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61565 + error = -EPERM;
61566 + } else {
61567 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61568 + error = -EAGAIN;
61569 + }
61570 + break;
61571 + case GR_ENABLE:
61572 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61573 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61574 + else {
61575 + if (gr_status & GR_READY)
61576 + error = -EAGAIN;
61577 + else
61578 + error = error2;
61579 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61580 + }
61581 + break;
61582 + case GR_RELOAD:
61583 + if (!(gr_status & GR_READY)) {
61584 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61585 + error = -EAGAIN;
61586 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61587 + stop_machine(gr_rbac_disable, NULL, NULL);
61588 + free_variables();
61589 + error2 = gracl_init(gr_usermode);
61590 + if (!error2)
61591 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61592 + else {
61593 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61594 + error = error2;
61595 + }
61596 + } else {
61597 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61598 + error = -EPERM;
61599 + }
61600 + break;
61601 + case GR_SEGVMOD:
61602 + if (unlikely(!(gr_status & GR_READY))) {
61603 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61604 + error = -EAGAIN;
61605 + break;
61606 + }
61607 +
61608 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61609 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61610 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61611 + struct acl_subject_label *segvacl;
61612 + segvacl =
61613 + lookup_acl_subj_label(gr_usermode->segv_inode,
61614 + gr_usermode->segv_device,
61615 + current->role);
61616 + if (segvacl) {
61617 + segvacl->crashes = 0;
61618 + segvacl->expires = 0;
61619 + }
61620 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61621 + gr_remove_uid(gr_usermode->segv_uid);
61622 + }
61623 + } else {
61624 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61625 + error = -EPERM;
61626 + }
61627 + break;
61628 + case GR_SPROLE:
61629 + case GR_SPROLEPAM:
61630 + if (unlikely(!(gr_status & GR_READY))) {
61631 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61632 + error = -EAGAIN;
61633 + break;
61634 + }
61635 +
61636 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61637 + current->role->expires = 0;
61638 + current->role->auth_attempts = 0;
61639 + }
61640 +
61641 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61642 + time_after(current->role->expires, get_seconds())) {
61643 + error = -EBUSY;
61644 + goto out;
61645 + }
61646 +
61647 + if (lookup_special_role_auth
61648 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61649 + && ((!sprole_salt && !sprole_sum)
61650 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61651 + char *p = "";
61652 + assign_special_role(gr_usermode->sp_role);
61653 + read_lock(&tasklist_lock);
61654 + if (current->real_parent)
61655 + p = current->real_parent->role->rolename;
61656 + read_unlock(&tasklist_lock);
61657 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61658 + p, acl_sp_role_value);
61659 + } else {
61660 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61661 + error = -EPERM;
61662 + if(!(current->role->auth_attempts++))
61663 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61664 +
61665 + goto out;
61666 + }
61667 + break;
61668 + case GR_UNSPROLE:
61669 + if (unlikely(!(gr_status & GR_READY))) {
61670 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61671 + error = -EAGAIN;
61672 + break;
61673 + }
61674 +
61675 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61676 + char *p = "";
61677 + int i = 0;
61678 +
61679 + read_lock(&tasklist_lock);
61680 + if (current->real_parent) {
61681 + p = current->real_parent->role->rolename;
61682 + i = current->real_parent->acl_role_id;
61683 + }
61684 + read_unlock(&tasklist_lock);
61685 +
61686 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61687 + gr_set_acls(1);
61688 + } else {
61689 + error = -EPERM;
61690 + goto out;
61691 + }
61692 + break;
61693 + default:
61694 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61695 + error = -EINVAL;
61696 + break;
61697 + }
61698 +
61699 + if (error != -EPERM)
61700 + goto out;
61701 +
61702 + if(!(gr_auth_attempts++))
61703 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61704 +
61705 + out:
61706 + mutex_unlock(&gr_dev_mutex);
61707 + return error;
61708 +}
61709 +
61710 +/* must be called with
61711 + rcu_read_lock();
61712 + read_lock(&tasklist_lock);
61713 + read_lock(&grsec_exec_file_lock);
61714 +*/
61715 +int gr_apply_subject_to_task(struct task_struct *task)
61716 +{
61717 + struct acl_object_label *obj;
61718 + char *tmpname;
61719 + struct acl_subject_label *tmpsubj;
61720 + struct file *filp;
61721 + struct name_entry *nmatch;
61722 +
61723 + filp = task->exec_file;
61724 + if (filp == NULL)
61725 + return 0;
61726 +
61727 + /* the following is to apply the correct subject
61728 + on binaries running when the RBAC system
61729 + is enabled, when the binaries have been
61730 + replaced or deleted since their execution
61731 + -----
61732 + when the RBAC system starts, the inode/dev
61733 + from exec_file will be one the RBAC system
61734 + is unaware of. It only knows the inode/dev
61735 + of the present file on disk, or the absence
61736 + of it.
61737 + */
61738 + preempt_disable();
61739 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61740 +
61741 + nmatch = lookup_name_entry(tmpname);
61742 + preempt_enable();
61743 + tmpsubj = NULL;
61744 + if (nmatch) {
61745 + if (nmatch->deleted)
61746 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61747 + else
61748 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61749 + if (tmpsubj != NULL)
61750 + task->acl = tmpsubj;
61751 + }
61752 + if (tmpsubj == NULL)
61753 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61754 + task->role);
61755 + if (task->acl) {
61756 + task->is_writable = 0;
61757 + /* ignore additional mmap checks for processes that are writable
61758 + by the default ACL */
61759 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61760 + if (unlikely(obj->mode & GR_WRITE))
61761 + task->is_writable = 1;
61762 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61763 + if (unlikely(obj->mode & GR_WRITE))
61764 + task->is_writable = 1;
61765 +
61766 + gr_set_proc_res(task);
61767 +
61768 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61769 + 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);
61770 +#endif
61771 + } else {
61772 + return 1;
61773 + }
61774 +
61775 + return 0;
61776 +}
61777 +
61778 +int
61779 +gr_set_acls(const int type)
61780 +{
61781 + struct task_struct *task, *task2;
61782 + struct acl_role_label *role = current->role;
61783 + __u16 acl_role_id = current->acl_role_id;
61784 + const struct cred *cred;
61785 + int ret;
61786 +
61787 + rcu_read_lock();
61788 + read_lock(&tasklist_lock);
61789 + read_lock(&grsec_exec_file_lock);
61790 + do_each_thread(task2, task) {
61791 + /* check to see if we're called from the exit handler,
61792 + if so, only replace ACLs that have inherited the admin
61793 + ACL */
61794 +
61795 + if (type && (task->role != role ||
61796 + task->acl_role_id != acl_role_id))
61797 + continue;
61798 +
61799 + task->acl_role_id = 0;
61800 + task->acl_sp_role = 0;
61801 +
61802 + if (task->exec_file) {
61803 + cred = __task_cred(task);
61804 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61805 + ret = gr_apply_subject_to_task(task);
61806 + if (ret) {
61807 + read_unlock(&grsec_exec_file_lock);
61808 + read_unlock(&tasklist_lock);
61809 + rcu_read_unlock();
61810 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61811 + return ret;
61812 + }
61813 + } else {
61814 + // it's a kernel process
61815 + task->role = kernel_role;
61816 + task->acl = kernel_role->root_label;
61817 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61818 + task->acl->mode &= ~GR_PROCFIND;
61819 +#endif
61820 + }
61821 + } while_each_thread(task2, task);
61822 + read_unlock(&grsec_exec_file_lock);
61823 + read_unlock(&tasklist_lock);
61824 + rcu_read_unlock();
61825 +
61826 + return 0;
61827 +}
61828 +
61829 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61830 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61831 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61832 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61833 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61834 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61835 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61836 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61837 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61838 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61839 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61840 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61841 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61842 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61843 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61844 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61845 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61846 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61847 +};
61848 +
61849 +void
61850 +gr_learn_resource(const struct task_struct *task,
61851 + const int res, const unsigned long wanted, const int gt)
61852 +{
61853 + struct acl_subject_label *acl;
61854 + const struct cred *cred;
61855 +
61856 + if (unlikely((gr_status & GR_READY) &&
61857 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61858 + goto skip_reslog;
61859 +
61860 + gr_log_resource(task, res, wanted, gt);
61861 +skip_reslog:
61862 +
61863 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61864 + return;
61865 +
61866 + acl = task->acl;
61867 +
61868 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61869 + !(acl->resmask & (1U << (unsigned short) res))))
61870 + return;
61871 +
61872 + if (wanted >= acl->res[res].rlim_cur) {
61873 + unsigned long res_add;
61874 +
61875 + res_add = wanted + res_learn_bumps[res];
61876 +
61877 + acl->res[res].rlim_cur = res_add;
61878 +
61879 + if (wanted > acl->res[res].rlim_max)
61880 + acl->res[res].rlim_max = res_add;
61881 +
61882 + /* only log the subject filename, since resource logging is supported for
61883 + single-subject learning only */
61884 + rcu_read_lock();
61885 + cred = __task_cred(task);
61886 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61887 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61888 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61889 + "", (unsigned long) res, &task->signal->saved_ip);
61890 + rcu_read_unlock();
61891 + }
61892 +
61893 + return;
61894 +}
61895 +EXPORT_SYMBOL(gr_learn_resource);
61896 +#endif
61897 +
61898 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61899 +void
61900 +pax_set_initial_flags(struct linux_binprm *bprm)
61901 +{
61902 + struct task_struct *task = current;
61903 + struct acl_subject_label *proc;
61904 + unsigned long flags;
61905 +
61906 + if (unlikely(!(gr_status & GR_READY)))
61907 + return;
61908 +
61909 + flags = pax_get_flags(task);
61910 +
61911 + proc = task->acl;
61912 +
61913 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61914 + flags &= ~MF_PAX_PAGEEXEC;
61915 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61916 + flags &= ~MF_PAX_SEGMEXEC;
61917 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61918 + flags &= ~MF_PAX_RANDMMAP;
61919 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61920 + flags &= ~MF_PAX_EMUTRAMP;
61921 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61922 + flags &= ~MF_PAX_MPROTECT;
61923 +
61924 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61925 + flags |= MF_PAX_PAGEEXEC;
61926 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61927 + flags |= MF_PAX_SEGMEXEC;
61928 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61929 + flags |= MF_PAX_RANDMMAP;
61930 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61931 + flags |= MF_PAX_EMUTRAMP;
61932 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61933 + flags |= MF_PAX_MPROTECT;
61934 +
61935 + pax_set_flags(task, flags);
61936 +
61937 + return;
61938 +}
61939 +#endif
61940 +
61941 +int
61942 +gr_handle_proc_ptrace(struct task_struct *task)
61943 +{
61944 + struct file *filp;
61945 + struct task_struct *tmp = task;
61946 + struct task_struct *curtemp = current;
61947 + __u32 retmode;
61948 +
61949 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61950 + if (unlikely(!(gr_status & GR_READY)))
61951 + return 0;
61952 +#endif
61953 +
61954 + read_lock(&tasklist_lock);
61955 + read_lock(&grsec_exec_file_lock);
61956 + filp = task->exec_file;
61957 +
61958 + while (task_pid_nr(tmp) > 0) {
61959 + if (tmp == curtemp)
61960 + break;
61961 + tmp = tmp->real_parent;
61962 + }
61963 +
61964 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61965 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61966 + read_unlock(&grsec_exec_file_lock);
61967 + read_unlock(&tasklist_lock);
61968 + return 1;
61969 + }
61970 +
61971 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61972 + if (!(gr_status & GR_READY)) {
61973 + read_unlock(&grsec_exec_file_lock);
61974 + read_unlock(&tasklist_lock);
61975 + return 0;
61976 + }
61977 +#endif
61978 +
61979 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61980 + read_unlock(&grsec_exec_file_lock);
61981 + read_unlock(&tasklist_lock);
61982 +
61983 + if (retmode & GR_NOPTRACE)
61984 + return 1;
61985 +
61986 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61987 + && (current->acl != task->acl || (current->acl != current->role->root_label
61988 + && task_pid_nr(current) != task_pid_nr(task))))
61989 + return 1;
61990 +
61991 + return 0;
61992 +}
61993 +
61994 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61995 +{
61996 + if (unlikely(!(gr_status & GR_READY)))
61997 + return;
61998 +
61999 + if (!(current->role->roletype & GR_ROLE_GOD))
62000 + return;
62001 +
62002 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
62003 + p->role->rolename, gr_task_roletype_to_char(p),
62004 + p->acl->filename);
62005 +}
62006 +
62007 +int
62008 +gr_handle_ptrace(struct task_struct *task, const long request)
62009 +{
62010 + struct task_struct *tmp = task;
62011 + struct task_struct *curtemp = current;
62012 + __u32 retmode;
62013 +
62014 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62015 + if (unlikely(!(gr_status & GR_READY)))
62016 + return 0;
62017 +#endif
62018 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
62019 + read_lock(&tasklist_lock);
62020 + while (task_pid_nr(tmp) > 0) {
62021 + if (tmp == curtemp)
62022 + break;
62023 + tmp = tmp->real_parent;
62024 + }
62025 +
62026 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62027 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
62028 + read_unlock(&tasklist_lock);
62029 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62030 + return 1;
62031 + }
62032 + read_unlock(&tasklist_lock);
62033 + }
62034 +
62035 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62036 + if (!(gr_status & GR_READY))
62037 + return 0;
62038 +#endif
62039 +
62040 + read_lock(&grsec_exec_file_lock);
62041 + if (unlikely(!task->exec_file)) {
62042 + read_unlock(&grsec_exec_file_lock);
62043 + return 0;
62044 + }
62045 +
62046 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
62047 + read_unlock(&grsec_exec_file_lock);
62048 +
62049 + if (retmode & GR_NOPTRACE) {
62050 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62051 + return 1;
62052 + }
62053 +
62054 + if (retmode & GR_PTRACERD) {
62055 + switch (request) {
62056 + case PTRACE_SEIZE:
62057 + case PTRACE_POKETEXT:
62058 + case PTRACE_POKEDATA:
62059 + case PTRACE_POKEUSR:
62060 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
62061 + case PTRACE_SETREGS:
62062 + case PTRACE_SETFPREGS:
62063 +#endif
62064 +#ifdef CONFIG_X86
62065 + case PTRACE_SETFPXREGS:
62066 +#endif
62067 +#ifdef CONFIG_ALTIVEC
62068 + case PTRACE_SETVRREGS:
62069 +#endif
62070 + return 1;
62071 + default:
62072 + return 0;
62073 + }
62074 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
62075 + !(current->role->roletype & GR_ROLE_GOD) &&
62076 + (current->acl != task->acl)) {
62077 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62078 + return 1;
62079 + }
62080 +
62081 + return 0;
62082 +}
62083 +
62084 +static int is_writable_mmap(const struct file *filp)
62085 +{
62086 + struct task_struct *task = current;
62087 + struct acl_object_label *obj, *obj2;
62088 +
62089 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62090 + !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))) {
62091 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62092 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62093 + task->role->root_label);
62094 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62095 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62096 + return 1;
62097 + }
62098 + }
62099 + return 0;
62100 +}
62101 +
62102 +int
62103 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62104 +{
62105 + __u32 mode;
62106 +
62107 + if (unlikely(!file || !(prot & PROT_EXEC)))
62108 + return 1;
62109 +
62110 + if (is_writable_mmap(file))
62111 + return 0;
62112 +
62113 + mode =
62114 + gr_search_file(file->f_path.dentry,
62115 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62116 + file->f_path.mnt);
62117 +
62118 + if (!gr_tpe_allow(file))
62119 + return 0;
62120 +
62121 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62122 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62123 + return 0;
62124 + } else if (unlikely(!(mode & GR_EXEC))) {
62125 + return 0;
62126 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62127 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62128 + return 1;
62129 + }
62130 +
62131 + return 1;
62132 +}
62133 +
62134 +int
62135 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62136 +{
62137 + __u32 mode;
62138 +
62139 + if (unlikely(!file || !(prot & PROT_EXEC)))
62140 + return 1;
62141 +
62142 + if (is_writable_mmap(file))
62143 + return 0;
62144 +
62145 + mode =
62146 + gr_search_file(file->f_path.dentry,
62147 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62148 + file->f_path.mnt);
62149 +
62150 + if (!gr_tpe_allow(file))
62151 + return 0;
62152 +
62153 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62154 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62155 + return 0;
62156 + } else if (unlikely(!(mode & GR_EXEC))) {
62157 + return 0;
62158 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62159 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62160 + return 1;
62161 + }
62162 +
62163 + return 1;
62164 +}
62165 +
62166 +void
62167 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62168 +{
62169 + unsigned long runtime;
62170 + unsigned long cputime;
62171 + unsigned int wday, cday;
62172 + __u8 whr, chr;
62173 + __u8 wmin, cmin;
62174 + __u8 wsec, csec;
62175 + struct timespec timeval;
62176 +
62177 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62178 + !(task->acl->mode & GR_PROCACCT)))
62179 + return;
62180 +
62181 + do_posix_clock_monotonic_gettime(&timeval);
62182 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62183 + wday = runtime / (3600 * 24);
62184 + runtime -= wday * (3600 * 24);
62185 + whr = runtime / 3600;
62186 + runtime -= whr * 3600;
62187 + wmin = runtime / 60;
62188 + runtime -= wmin * 60;
62189 + wsec = runtime;
62190 +
62191 + cputime = (task->utime + task->stime) / HZ;
62192 + cday = cputime / (3600 * 24);
62193 + cputime -= cday * (3600 * 24);
62194 + chr = cputime / 3600;
62195 + cputime -= chr * 3600;
62196 + cmin = cputime / 60;
62197 + cputime -= cmin * 60;
62198 + csec = cputime;
62199 +
62200 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62201 +
62202 + return;
62203 +}
62204 +
62205 +void gr_set_kernel_label(struct task_struct *task)
62206 +{
62207 + if (gr_status & GR_READY) {
62208 + task->role = kernel_role;
62209 + task->acl = kernel_role->root_label;
62210 + }
62211 + return;
62212 +}
62213 +
62214 +#ifdef CONFIG_TASKSTATS
62215 +int gr_is_taskstats_denied(int pid)
62216 +{
62217 + struct task_struct *task;
62218 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62219 + const struct cred *cred;
62220 +#endif
62221 + int ret = 0;
62222 +
62223 + /* restrict taskstats viewing to un-chrooted root users
62224 + who have the 'view' subject flag if the RBAC system is enabled
62225 + */
62226 +
62227 + rcu_read_lock();
62228 + read_lock(&tasklist_lock);
62229 + task = find_task_by_vpid(pid);
62230 + if (task) {
62231 +#ifdef CONFIG_GRKERNSEC_CHROOT
62232 + if (proc_is_chrooted(task))
62233 + ret = -EACCES;
62234 +#endif
62235 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62236 + cred = __task_cred(task);
62237 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62238 + if (gr_is_global_nonroot(cred->uid))
62239 + ret = -EACCES;
62240 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62241 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62242 + ret = -EACCES;
62243 +#endif
62244 +#endif
62245 + if (gr_status & GR_READY) {
62246 + if (!(task->acl->mode & GR_VIEW))
62247 + ret = -EACCES;
62248 + }
62249 + } else
62250 + ret = -ENOENT;
62251 +
62252 + read_unlock(&tasklist_lock);
62253 + rcu_read_unlock();
62254 +
62255 + return ret;
62256 +}
62257 +#endif
62258 +
62259 +/* AUXV entries are filled via a descendant of search_binary_handler
62260 + after we've already applied the subject for the target
62261 +*/
62262 +int gr_acl_enable_at_secure(void)
62263 +{
62264 + if (unlikely(!(gr_status & GR_READY)))
62265 + return 0;
62266 +
62267 + if (current->acl->mode & GR_ATSECURE)
62268 + return 1;
62269 +
62270 + return 0;
62271 +}
62272 +
62273 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62274 +{
62275 + struct task_struct *task = current;
62276 + struct dentry *dentry = file->f_path.dentry;
62277 + struct vfsmount *mnt = file->f_path.mnt;
62278 + struct acl_object_label *obj, *tmp;
62279 + struct acl_subject_label *subj;
62280 + unsigned int bufsize;
62281 + int is_not_root;
62282 + char *path;
62283 + dev_t dev = __get_dev(dentry);
62284 +
62285 + if (unlikely(!(gr_status & GR_READY)))
62286 + return 1;
62287 +
62288 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62289 + return 1;
62290 +
62291 + /* ignore Eric Biederman */
62292 + if (IS_PRIVATE(dentry->d_inode))
62293 + return 1;
62294 +
62295 + subj = task->acl;
62296 + read_lock(&gr_inode_lock);
62297 + do {
62298 + obj = lookup_acl_obj_label(ino, dev, subj);
62299 + if (obj != NULL) {
62300 + read_unlock(&gr_inode_lock);
62301 + return (obj->mode & GR_FIND) ? 1 : 0;
62302 + }
62303 + } while ((subj = subj->parent_subject));
62304 + read_unlock(&gr_inode_lock);
62305 +
62306 + /* this is purely an optimization since we're looking for an object
62307 + for the directory we're doing a readdir on
62308 + if it's possible for any globbed object to match the entry we're
62309 + filling into the directory, then the object we find here will be
62310 + an anchor point with attached globbed objects
62311 + */
62312 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62313 + if (obj->globbed == NULL)
62314 + return (obj->mode & GR_FIND) ? 1 : 0;
62315 +
62316 + is_not_root = ((obj->filename[0] == '/') &&
62317 + (obj->filename[1] == '\0')) ? 0 : 1;
62318 + bufsize = PAGE_SIZE - namelen - is_not_root;
62319 +
62320 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62321 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62322 + return 1;
62323 +
62324 + preempt_disable();
62325 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62326 + bufsize);
62327 +
62328 + bufsize = strlen(path);
62329 +
62330 + /* if base is "/", don't append an additional slash */
62331 + if (is_not_root)
62332 + *(path + bufsize) = '/';
62333 + memcpy(path + bufsize + is_not_root, name, namelen);
62334 + *(path + bufsize + namelen + is_not_root) = '\0';
62335 +
62336 + tmp = obj->globbed;
62337 + while (tmp) {
62338 + if (!glob_match(tmp->filename, path)) {
62339 + preempt_enable();
62340 + return (tmp->mode & GR_FIND) ? 1 : 0;
62341 + }
62342 + tmp = tmp->next;
62343 + }
62344 + preempt_enable();
62345 + return (obj->mode & GR_FIND) ? 1 : 0;
62346 +}
62347 +
62348 +void gr_put_exec_file(struct task_struct *task)
62349 +{
62350 + struct file *filp;
62351 +
62352 + write_lock(&grsec_exec_file_lock);
62353 + filp = task->exec_file;
62354 + task->exec_file = NULL;
62355 + write_unlock(&grsec_exec_file_lock);
62356 +
62357 + if (filp)
62358 + fput(filp);
62359 +
62360 + return;
62361 +}
62362 +
62363 +
62364 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62365 +EXPORT_SYMBOL(gr_acl_is_enabled);
62366 +#endif
62367 +EXPORT_SYMBOL(gr_set_kernel_label);
62368 +#ifdef CONFIG_SECURITY
62369 +EXPORT_SYMBOL(gr_check_user_change);
62370 +EXPORT_SYMBOL(gr_check_group_change);
62371 +#endif
62372 +
62373 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62374 new file mode 100644
62375 index 0000000..34fefda
62376 --- /dev/null
62377 +++ b/grsecurity/gracl_alloc.c
62378 @@ -0,0 +1,105 @@
62379 +#include <linux/kernel.h>
62380 +#include <linux/mm.h>
62381 +#include <linux/slab.h>
62382 +#include <linux/vmalloc.h>
62383 +#include <linux/gracl.h>
62384 +#include <linux/grsecurity.h>
62385 +
62386 +static unsigned long alloc_stack_next = 1;
62387 +static unsigned long alloc_stack_size = 1;
62388 +static void **alloc_stack;
62389 +
62390 +static __inline__ int
62391 +alloc_pop(void)
62392 +{
62393 + if (alloc_stack_next == 1)
62394 + return 0;
62395 +
62396 + kfree(alloc_stack[alloc_stack_next - 2]);
62397 +
62398 + alloc_stack_next--;
62399 +
62400 + return 1;
62401 +}
62402 +
62403 +static __inline__ int
62404 +alloc_push(void *buf)
62405 +{
62406 + if (alloc_stack_next >= alloc_stack_size)
62407 + return 1;
62408 +
62409 + alloc_stack[alloc_stack_next - 1] = buf;
62410 +
62411 + alloc_stack_next++;
62412 +
62413 + return 0;
62414 +}
62415 +
62416 +void *
62417 +acl_alloc(unsigned long len)
62418 +{
62419 + void *ret = NULL;
62420 +
62421 + if (!len || len > PAGE_SIZE)
62422 + goto out;
62423 +
62424 + ret = kmalloc(len, GFP_KERNEL);
62425 +
62426 + if (ret) {
62427 + if (alloc_push(ret)) {
62428 + kfree(ret);
62429 + ret = NULL;
62430 + }
62431 + }
62432 +
62433 +out:
62434 + return ret;
62435 +}
62436 +
62437 +void *
62438 +acl_alloc_num(unsigned long num, unsigned long len)
62439 +{
62440 + if (!len || (num > (PAGE_SIZE / len)))
62441 + return NULL;
62442 +
62443 + return acl_alloc(num * len);
62444 +}
62445 +
62446 +void
62447 +acl_free_all(void)
62448 +{
62449 + if (gr_acl_is_enabled() || !alloc_stack)
62450 + return;
62451 +
62452 + while (alloc_pop()) ;
62453 +
62454 + if (alloc_stack) {
62455 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62456 + kfree(alloc_stack);
62457 + else
62458 + vfree(alloc_stack);
62459 + }
62460 +
62461 + alloc_stack = NULL;
62462 + alloc_stack_size = 1;
62463 + alloc_stack_next = 1;
62464 +
62465 + return;
62466 +}
62467 +
62468 +int
62469 +acl_alloc_stack_init(unsigned long size)
62470 +{
62471 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62472 + alloc_stack =
62473 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62474 + else
62475 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62476 +
62477 + alloc_stack_size = size;
62478 +
62479 + if (!alloc_stack)
62480 + return 0;
62481 + else
62482 + return 1;
62483 +}
62484 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62485 new file mode 100644
62486 index 0000000..bdd51ea
62487 --- /dev/null
62488 +++ b/grsecurity/gracl_cap.c
62489 @@ -0,0 +1,110 @@
62490 +#include <linux/kernel.h>
62491 +#include <linux/module.h>
62492 +#include <linux/sched.h>
62493 +#include <linux/gracl.h>
62494 +#include <linux/grsecurity.h>
62495 +#include <linux/grinternal.h>
62496 +
62497 +extern const char *captab_log[];
62498 +extern int captab_log_entries;
62499 +
62500 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62501 +{
62502 + struct acl_subject_label *curracl;
62503 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62504 + kernel_cap_t cap_audit = __cap_empty_set;
62505 +
62506 + if (!gr_acl_is_enabled())
62507 + return 1;
62508 +
62509 + curracl = task->acl;
62510 +
62511 + cap_drop = curracl->cap_lower;
62512 + cap_mask = curracl->cap_mask;
62513 + cap_audit = curracl->cap_invert_audit;
62514 +
62515 + while ((curracl = curracl->parent_subject)) {
62516 + /* if the cap isn't specified in the current computed mask but is specified in the
62517 + current level subject, and is lowered in the current level subject, then add
62518 + it to the set of dropped capabilities
62519 + otherwise, add the current level subject's mask to the current computed mask
62520 + */
62521 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62522 + cap_raise(cap_mask, cap);
62523 + if (cap_raised(curracl->cap_lower, cap))
62524 + cap_raise(cap_drop, cap);
62525 + if (cap_raised(curracl->cap_invert_audit, cap))
62526 + cap_raise(cap_audit, cap);
62527 + }
62528 + }
62529 +
62530 + if (!cap_raised(cap_drop, cap)) {
62531 + if (cap_raised(cap_audit, cap))
62532 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62533 + return 1;
62534 + }
62535 +
62536 + curracl = task->acl;
62537 +
62538 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62539 + && cap_raised(cred->cap_effective, cap)) {
62540 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62541 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62542 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62543 + gr_to_filename(task->exec_file->f_path.dentry,
62544 + task->exec_file->f_path.mnt) : curracl->filename,
62545 + curracl->filename, 0UL,
62546 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62547 + return 1;
62548 + }
62549 +
62550 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62551 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62552 +
62553 + return 0;
62554 +}
62555 +
62556 +int
62557 +gr_acl_is_capable(const int cap)
62558 +{
62559 + return gr_task_acl_is_capable(current, current_cred(), cap);
62560 +}
62561 +
62562 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62563 +{
62564 + struct acl_subject_label *curracl;
62565 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62566 +
62567 + if (!gr_acl_is_enabled())
62568 + return 1;
62569 +
62570 + curracl = task->acl;
62571 +
62572 + cap_drop = curracl->cap_lower;
62573 + cap_mask = curracl->cap_mask;
62574 +
62575 + while ((curracl = curracl->parent_subject)) {
62576 + /* if the cap isn't specified in the current computed mask but is specified in the
62577 + current level subject, and is lowered in the current level subject, then add
62578 + it to the set of dropped capabilities
62579 + otherwise, add the current level subject's mask to the current computed mask
62580 + */
62581 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62582 + cap_raise(cap_mask, cap);
62583 + if (cap_raised(curracl->cap_lower, cap))
62584 + cap_raise(cap_drop, cap);
62585 + }
62586 + }
62587 +
62588 + if (!cap_raised(cap_drop, cap))
62589 + return 1;
62590 +
62591 + return 0;
62592 +}
62593 +
62594 +int
62595 +gr_acl_is_capable_nolog(const int cap)
62596 +{
62597 + return gr_task_acl_is_capable_nolog(current, cap);
62598 +}
62599 +
62600 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62601 new file mode 100644
62602 index 0000000..a340c17
62603 --- /dev/null
62604 +++ b/grsecurity/gracl_fs.c
62605 @@ -0,0 +1,431 @@
62606 +#include <linux/kernel.h>
62607 +#include <linux/sched.h>
62608 +#include <linux/types.h>
62609 +#include <linux/fs.h>
62610 +#include <linux/file.h>
62611 +#include <linux/stat.h>
62612 +#include <linux/grsecurity.h>
62613 +#include <linux/grinternal.h>
62614 +#include <linux/gracl.h>
62615 +
62616 +umode_t
62617 +gr_acl_umask(void)
62618 +{
62619 + if (unlikely(!gr_acl_is_enabled()))
62620 + return 0;
62621 +
62622 + return current->role->umask;
62623 +}
62624 +
62625 +__u32
62626 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62627 + const struct vfsmount * mnt)
62628 +{
62629 + __u32 mode;
62630 +
62631 + if (unlikely(!dentry->d_inode))
62632 + return GR_FIND;
62633 +
62634 + mode =
62635 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62636 +
62637 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62638 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62639 + return mode;
62640 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62641 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62642 + return 0;
62643 + } else if (unlikely(!(mode & GR_FIND)))
62644 + return 0;
62645 +
62646 + return GR_FIND;
62647 +}
62648 +
62649 +__u32
62650 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62651 + int acc_mode)
62652 +{
62653 + __u32 reqmode = GR_FIND;
62654 + __u32 mode;
62655 +
62656 + if (unlikely(!dentry->d_inode))
62657 + return reqmode;
62658 +
62659 + if (acc_mode & MAY_APPEND)
62660 + reqmode |= GR_APPEND;
62661 + else if (acc_mode & MAY_WRITE)
62662 + reqmode |= GR_WRITE;
62663 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62664 + reqmode |= GR_READ;
62665 +
62666 + mode =
62667 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62668 + mnt);
62669 +
62670 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62671 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62672 + reqmode & GR_READ ? " reading" : "",
62673 + reqmode & GR_WRITE ? " writing" : reqmode &
62674 + GR_APPEND ? " appending" : "");
62675 + return reqmode;
62676 + } else
62677 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62678 + {
62679 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62680 + reqmode & GR_READ ? " reading" : "",
62681 + reqmode & GR_WRITE ? " writing" : reqmode &
62682 + GR_APPEND ? " appending" : "");
62683 + return 0;
62684 + } else if (unlikely((mode & reqmode) != reqmode))
62685 + return 0;
62686 +
62687 + return reqmode;
62688 +}
62689 +
62690 +__u32
62691 +gr_acl_handle_creat(const struct dentry * dentry,
62692 + const struct dentry * p_dentry,
62693 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62694 + const int imode)
62695 +{
62696 + __u32 reqmode = GR_WRITE | GR_CREATE;
62697 + __u32 mode;
62698 +
62699 + if (acc_mode & MAY_APPEND)
62700 + reqmode |= GR_APPEND;
62701 + // if a directory was required or the directory already exists, then
62702 + // don't count this open as a read
62703 + if ((acc_mode & MAY_READ) &&
62704 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62705 + reqmode |= GR_READ;
62706 + if ((open_flags & O_CREAT) &&
62707 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62708 + reqmode |= GR_SETID;
62709 +
62710 + mode =
62711 + gr_check_create(dentry, p_dentry, p_mnt,
62712 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62713 +
62714 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62715 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62716 + reqmode & GR_READ ? " reading" : "",
62717 + reqmode & GR_WRITE ? " writing" : reqmode &
62718 + GR_APPEND ? " appending" : "");
62719 + return reqmode;
62720 + } else
62721 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62722 + {
62723 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62724 + reqmode & GR_READ ? " reading" : "",
62725 + reqmode & GR_WRITE ? " writing" : reqmode &
62726 + GR_APPEND ? " appending" : "");
62727 + return 0;
62728 + } else if (unlikely((mode & reqmode) != reqmode))
62729 + return 0;
62730 +
62731 + return reqmode;
62732 +}
62733 +
62734 +__u32
62735 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62736 + const int fmode)
62737 +{
62738 + __u32 mode, reqmode = GR_FIND;
62739 +
62740 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62741 + reqmode |= GR_EXEC;
62742 + if (fmode & S_IWOTH)
62743 + reqmode |= GR_WRITE;
62744 + if (fmode & S_IROTH)
62745 + reqmode |= GR_READ;
62746 +
62747 + mode =
62748 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62749 + mnt);
62750 +
62751 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62752 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62753 + reqmode & GR_READ ? " reading" : "",
62754 + reqmode & GR_WRITE ? " writing" : "",
62755 + reqmode & GR_EXEC ? " executing" : "");
62756 + return reqmode;
62757 + } else
62758 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62759 + {
62760 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62761 + reqmode & GR_READ ? " reading" : "",
62762 + reqmode & GR_WRITE ? " writing" : "",
62763 + reqmode & GR_EXEC ? " executing" : "");
62764 + return 0;
62765 + } else if (unlikely((mode & reqmode) != reqmode))
62766 + return 0;
62767 +
62768 + return reqmode;
62769 +}
62770 +
62771 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62772 +{
62773 + __u32 mode;
62774 +
62775 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62776 +
62777 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62778 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62779 + return mode;
62780 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62781 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62782 + return 0;
62783 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62784 + return 0;
62785 +
62786 + return (reqmode);
62787 +}
62788 +
62789 +__u32
62790 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62791 +{
62792 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62793 +}
62794 +
62795 +__u32
62796 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62797 +{
62798 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62799 +}
62800 +
62801 +__u32
62802 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62803 +{
62804 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62805 +}
62806 +
62807 +__u32
62808 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62809 +{
62810 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62811 +}
62812 +
62813 +__u32
62814 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62815 + umode_t *modeptr)
62816 +{
62817 + umode_t mode;
62818 +
62819 + *modeptr &= ~gr_acl_umask();
62820 + mode = *modeptr;
62821 +
62822 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62823 + return 1;
62824 +
62825 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62826 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62827 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62828 + GR_CHMOD_ACL_MSG);
62829 + } else {
62830 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62831 + }
62832 +}
62833 +
62834 +__u32
62835 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62836 +{
62837 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62838 +}
62839 +
62840 +__u32
62841 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62842 +{
62843 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62844 +}
62845 +
62846 +__u32
62847 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62848 +{
62849 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62850 +}
62851 +
62852 +__u32
62853 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62854 +{
62855 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62856 + GR_UNIXCONNECT_ACL_MSG);
62857 +}
62858 +
62859 +/* hardlinks require at minimum create and link permission,
62860 + any additional privilege required is based on the
62861 + privilege of the file being linked to
62862 +*/
62863 +__u32
62864 +gr_acl_handle_link(const struct dentry * new_dentry,
62865 + const struct dentry * parent_dentry,
62866 + const struct vfsmount * parent_mnt,
62867 + const struct dentry * old_dentry,
62868 + const struct vfsmount * old_mnt, const struct filename *to)
62869 +{
62870 + __u32 mode;
62871 + __u32 needmode = GR_CREATE | GR_LINK;
62872 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62873 +
62874 + mode =
62875 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62876 + old_mnt);
62877 +
62878 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62879 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62880 + return mode;
62881 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62882 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62883 + return 0;
62884 + } else if (unlikely((mode & needmode) != needmode))
62885 + return 0;
62886 +
62887 + return 1;
62888 +}
62889 +
62890 +__u32
62891 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62892 + const struct dentry * parent_dentry,
62893 + const struct vfsmount * parent_mnt, const struct filename *from)
62894 +{
62895 + __u32 needmode = GR_WRITE | GR_CREATE;
62896 + __u32 mode;
62897 +
62898 + mode =
62899 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62900 + GR_CREATE | GR_AUDIT_CREATE |
62901 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62902 +
62903 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62904 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62905 + return mode;
62906 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62907 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62908 + return 0;
62909 + } else if (unlikely((mode & needmode) != needmode))
62910 + return 0;
62911 +
62912 + return (GR_WRITE | GR_CREATE);
62913 +}
62914 +
62915 +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)
62916 +{
62917 + __u32 mode;
62918 +
62919 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62920 +
62921 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62922 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62923 + return mode;
62924 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62925 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62926 + return 0;
62927 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62928 + return 0;
62929 +
62930 + return (reqmode);
62931 +}
62932 +
62933 +__u32
62934 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62935 + const struct dentry * parent_dentry,
62936 + const struct vfsmount * parent_mnt,
62937 + const int mode)
62938 +{
62939 + __u32 reqmode = GR_WRITE | GR_CREATE;
62940 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62941 + reqmode |= GR_SETID;
62942 +
62943 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62944 + reqmode, GR_MKNOD_ACL_MSG);
62945 +}
62946 +
62947 +__u32
62948 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62949 + const struct dentry *parent_dentry,
62950 + const struct vfsmount *parent_mnt)
62951 +{
62952 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62953 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62954 +}
62955 +
62956 +#define RENAME_CHECK_SUCCESS(old, new) \
62957 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62958 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62959 +
62960 +int
62961 +gr_acl_handle_rename(struct dentry *new_dentry,
62962 + struct dentry *parent_dentry,
62963 + const struct vfsmount *parent_mnt,
62964 + struct dentry *old_dentry,
62965 + struct inode *old_parent_inode,
62966 + struct vfsmount *old_mnt, const struct filename *newname)
62967 +{
62968 + __u32 comp1, comp2;
62969 + int error = 0;
62970 +
62971 + if (unlikely(!gr_acl_is_enabled()))
62972 + return 0;
62973 +
62974 + if (!new_dentry->d_inode) {
62975 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62976 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62977 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62978 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62979 + GR_DELETE | GR_AUDIT_DELETE |
62980 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62981 + GR_SUPPRESS, old_mnt);
62982 + } else {
62983 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62984 + GR_CREATE | GR_DELETE |
62985 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62986 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62987 + GR_SUPPRESS, parent_mnt);
62988 + comp2 =
62989 + gr_search_file(old_dentry,
62990 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62991 + GR_DELETE | GR_AUDIT_DELETE |
62992 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62993 + }
62994 +
62995 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62996 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62997 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62998 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62999 + && !(comp2 & GR_SUPPRESS)) {
63000 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63001 + error = -EACCES;
63002 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
63003 + error = -EACCES;
63004 +
63005 + return error;
63006 +}
63007 +
63008 +void
63009 +gr_acl_handle_exit(void)
63010 +{
63011 + u16 id;
63012 + char *rolename;
63013 +
63014 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
63015 + !(current->role->roletype & GR_ROLE_PERSIST))) {
63016 + id = current->acl_role_id;
63017 + rolename = current->role->rolename;
63018 + gr_set_acls(1);
63019 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
63020 + }
63021 +
63022 + gr_put_exec_file(current);
63023 + return;
63024 +}
63025 +
63026 +int
63027 +gr_acl_handle_procpidmem(const struct task_struct *task)
63028 +{
63029 + if (unlikely(!gr_acl_is_enabled()))
63030 + return 0;
63031 +
63032 + if (task != current && task->acl->mode & GR_PROTPROCFD)
63033 + return -EACCES;
63034 +
63035 + return 0;
63036 +}
63037 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
63038 new file mode 100644
63039 index 0000000..8132048
63040 --- /dev/null
63041 +++ b/grsecurity/gracl_ip.c
63042 @@ -0,0 +1,387 @@
63043 +#include <linux/kernel.h>
63044 +#include <asm/uaccess.h>
63045 +#include <asm/errno.h>
63046 +#include <net/sock.h>
63047 +#include <linux/file.h>
63048 +#include <linux/fs.h>
63049 +#include <linux/net.h>
63050 +#include <linux/in.h>
63051 +#include <linux/skbuff.h>
63052 +#include <linux/ip.h>
63053 +#include <linux/udp.h>
63054 +#include <linux/types.h>
63055 +#include <linux/sched.h>
63056 +#include <linux/netdevice.h>
63057 +#include <linux/inetdevice.h>
63058 +#include <linux/gracl.h>
63059 +#include <linux/grsecurity.h>
63060 +#include <linux/grinternal.h>
63061 +
63062 +#define GR_BIND 0x01
63063 +#define GR_CONNECT 0x02
63064 +#define GR_INVERT 0x04
63065 +#define GR_BINDOVERRIDE 0x08
63066 +#define GR_CONNECTOVERRIDE 0x10
63067 +#define GR_SOCK_FAMILY 0x20
63068 +
63069 +static const char * gr_protocols[IPPROTO_MAX] = {
63070 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
63071 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
63072 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
63073 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
63074 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
63075 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
63076 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
63077 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
63078 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
63079 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63080 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63081 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63082 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63083 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63084 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63085 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63086 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63087 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63088 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63089 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63090 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63091 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63092 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63093 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63094 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63095 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63096 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63097 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63098 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63099 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63100 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63101 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63102 + };
63103 +
63104 +static const char * gr_socktypes[SOCK_MAX] = {
63105 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63106 + "unknown:7", "unknown:8", "unknown:9", "packet"
63107 + };
63108 +
63109 +static const char * gr_sockfamilies[AF_MAX+1] = {
63110 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63111 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63112 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63113 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63114 + };
63115 +
63116 +const char *
63117 +gr_proto_to_name(unsigned char proto)
63118 +{
63119 + return gr_protocols[proto];
63120 +}
63121 +
63122 +const char *
63123 +gr_socktype_to_name(unsigned char type)
63124 +{
63125 + return gr_socktypes[type];
63126 +}
63127 +
63128 +const char *
63129 +gr_sockfamily_to_name(unsigned char family)
63130 +{
63131 + return gr_sockfamilies[family];
63132 +}
63133 +
63134 +int
63135 +gr_search_socket(const int domain, const int type, const int protocol)
63136 +{
63137 + struct acl_subject_label *curr;
63138 + const struct cred *cred = current_cred();
63139 +
63140 + if (unlikely(!gr_acl_is_enabled()))
63141 + goto exit;
63142 +
63143 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63144 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63145 + goto exit; // let the kernel handle it
63146 +
63147 + curr = current->acl;
63148 +
63149 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63150 + /* the family is allowed, if this is PF_INET allow it only if
63151 + the extra sock type/protocol checks pass */
63152 + if (domain == PF_INET)
63153 + goto inet_check;
63154 + goto exit;
63155 + } else {
63156 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63157 + __u32 fakeip = 0;
63158 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63159 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63160 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63161 + gr_to_filename(current->exec_file->f_path.dentry,
63162 + current->exec_file->f_path.mnt) :
63163 + curr->filename, curr->filename,
63164 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63165 + &current->signal->saved_ip);
63166 + goto exit;
63167 + }
63168 + goto exit_fail;
63169 + }
63170 +
63171 +inet_check:
63172 + /* the rest of this checking is for IPv4 only */
63173 + if (!curr->ips)
63174 + goto exit;
63175 +
63176 + if ((curr->ip_type & (1U << type)) &&
63177 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63178 + goto exit;
63179 +
63180 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63181 + /* we don't place acls on raw sockets , and sometimes
63182 + dgram/ip sockets are opened for ioctl and not
63183 + bind/connect, so we'll fake a bind learn log */
63184 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63185 + __u32 fakeip = 0;
63186 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63187 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63188 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63189 + gr_to_filename(current->exec_file->f_path.dentry,
63190 + current->exec_file->f_path.mnt) :
63191 + curr->filename, curr->filename,
63192 + &fakeip, 0, type,
63193 + protocol, GR_CONNECT, &current->signal->saved_ip);
63194 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63195 + __u32 fakeip = 0;
63196 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63197 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63198 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63199 + gr_to_filename(current->exec_file->f_path.dentry,
63200 + current->exec_file->f_path.mnt) :
63201 + curr->filename, curr->filename,
63202 + &fakeip, 0, type,
63203 + protocol, GR_BIND, &current->signal->saved_ip);
63204 + }
63205 + /* we'll log when they use connect or bind */
63206 + goto exit;
63207 + }
63208 +
63209 +exit_fail:
63210 + if (domain == PF_INET)
63211 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63212 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63213 + else
63214 +#ifndef CONFIG_IPV6
63215 + if (domain != PF_INET6)
63216 +#endif
63217 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63218 + gr_socktype_to_name(type), protocol);
63219 +
63220 + return 0;
63221 +exit:
63222 + return 1;
63223 +}
63224 +
63225 +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)
63226 +{
63227 + if ((ip->mode & mode) &&
63228 + (ip_port >= ip->low) &&
63229 + (ip_port <= ip->high) &&
63230 + ((ntohl(ip_addr) & our_netmask) ==
63231 + (ntohl(our_addr) & our_netmask))
63232 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63233 + && (ip->type & (1U << type))) {
63234 + if (ip->mode & GR_INVERT)
63235 + return 2; // specifically denied
63236 + else
63237 + return 1; // allowed
63238 + }
63239 +
63240 + return 0; // not specifically allowed, may continue parsing
63241 +}
63242 +
63243 +static int
63244 +gr_search_connectbind(const int full_mode, struct sock *sk,
63245 + struct sockaddr_in *addr, const int type)
63246 +{
63247 + char iface[IFNAMSIZ] = {0};
63248 + struct acl_subject_label *curr;
63249 + struct acl_ip_label *ip;
63250 + struct inet_sock *isk;
63251 + struct net_device *dev;
63252 + struct in_device *idev;
63253 + unsigned long i;
63254 + int ret;
63255 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63256 + __u32 ip_addr = 0;
63257 + __u32 our_addr;
63258 + __u32 our_netmask;
63259 + char *p;
63260 + __u16 ip_port = 0;
63261 + const struct cred *cred = current_cred();
63262 +
63263 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63264 + return 0;
63265 +
63266 + curr = current->acl;
63267 + isk = inet_sk(sk);
63268 +
63269 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63270 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63271 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63272 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63273 + struct sockaddr_in saddr;
63274 + int err;
63275 +
63276 + saddr.sin_family = AF_INET;
63277 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63278 + saddr.sin_port = isk->inet_sport;
63279 +
63280 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63281 + if (err)
63282 + return err;
63283 +
63284 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63285 + if (err)
63286 + return err;
63287 + }
63288 +
63289 + if (!curr->ips)
63290 + return 0;
63291 +
63292 + ip_addr = addr->sin_addr.s_addr;
63293 + ip_port = ntohs(addr->sin_port);
63294 +
63295 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63296 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63297 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63298 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63299 + gr_to_filename(current->exec_file->f_path.dentry,
63300 + current->exec_file->f_path.mnt) :
63301 + curr->filename, curr->filename,
63302 + &ip_addr, ip_port, type,
63303 + sk->sk_protocol, mode, &current->signal->saved_ip);
63304 + return 0;
63305 + }
63306 +
63307 + for (i = 0; i < curr->ip_num; i++) {
63308 + ip = *(curr->ips + i);
63309 + if (ip->iface != NULL) {
63310 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63311 + p = strchr(iface, ':');
63312 + if (p != NULL)
63313 + *p = '\0';
63314 + dev = dev_get_by_name(sock_net(sk), iface);
63315 + if (dev == NULL)
63316 + continue;
63317 + idev = in_dev_get(dev);
63318 + if (idev == NULL) {
63319 + dev_put(dev);
63320 + continue;
63321 + }
63322 + rcu_read_lock();
63323 + for_ifa(idev) {
63324 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63325 + our_addr = ifa->ifa_address;
63326 + our_netmask = 0xffffffff;
63327 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63328 + if (ret == 1) {
63329 + rcu_read_unlock();
63330 + in_dev_put(idev);
63331 + dev_put(dev);
63332 + return 0;
63333 + } else if (ret == 2) {
63334 + rcu_read_unlock();
63335 + in_dev_put(idev);
63336 + dev_put(dev);
63337 + goto denied;
63338 + }
63339 + }
63340 + } endfor_ifa(idev);
63341 + rcu_read_unlock();
63342 + in_dev_put(idev);
63343 + dev_put(dev);
63344 + } else {
63345 + our_addr = ip->addr;
63346 + our_netmask = ip->netmask;
63347 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63348 + if (ret == 1)
63349 + return 0;
63350 + else if (ret == 2)
63351 + goto denied;
63352 + }
63353 + }
63354 +
63355 +denied:
63356 + if (mode == GR_BIND)
63357 + 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));
63358 + else if (mode == GR_CONNECT)
63359 + 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));
63360 +
63361 + return -EACCES;
63362 +}
63363 +
63364 +int
63365 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63366 +{
63367 + /* always allow disconnection of dgram sockets with connect */
63368 + if (addr->sin_family == AF_UNSPEC)
63369 + return 0;
63370 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63371 +}
63372 +
63373 +int
63374 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63375 +{
63376 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63377 +}
63378 +
63379 +int gr_search_listen(struct socket *sock)
63380 +{
63381 + struct sock *sk = sock->sk;
63382 + struct sockaddr_in addr;
63383 +
63384 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63385 + addr.sin_port = inet_sk(sk)->inet_sport;
63386 +
63387 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63388 +}
63389 +
63390 +int gr_search_accept(struct socket *sock)
63391 +{
63392 + struct sock *sk = sock->sk;
63393 + struct sockaddr_in addr;
63394 +
63395 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63396 + addr.sin_port = inet_sk(sk)->inet_sport;
63397 +
63398 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63399 +}
63400 +
63401 +int
63402 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63403 +{
63404 + if (addr)
63405 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63406 + else {
63407 + struct sockaddr_in sin;
63408 + const struct inet_sock *inet = inet_sk(sk);
63409 +
63410 + sin.sin_addr.s_addr = inet->inet_daddr;
63411 + sin.sin_port = inet->inet_dport;
63412 +
63413 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63414 + }
63415 +}
63416 +
63417 +int
63418 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63419 +{
63420 + struct sockaddr_in sin;
63421 +
63422 + if (unlikely(skb->len < sizeof (struct udphdr)))
63423 + return 0; // skip this packet
63424 +
63425 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63426 + sin.sin_port = udp_hdr(skb)->source;
63427 +
63428 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63429 +}
63430 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63431 new file mode 100644
63432 index 0000000..25f54ef
63433 --- /dev/null
63434 +++ b/grsecurity/gracl_learn.c
63435 @@ -0,0 +1,207 @@
63436 +#include <linux/kernel.h>
63437 +#include <linux/mm.h>
63438 +#include <linux/sched.h>
63439 +#include <linux/poll.h>
63440 +#include <linux/string.h>
63441 +#include <linux/file.h>
63442 +#include <linux/types.h>
63443 +#include <linux/vmalloc.h>
63444 +#include <linux/grinternal.h>
63445 +
63446 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63447 + size_t count, loff_t *ppos);
63448 +extern int gr_acl_is_enabled(void);
63449 +
63450 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63451 +static int gr_learn_attached;
63452 +
63453 +/* use a 512k buffer */
63454 +#define LEARN_BUFFER_SIZE (512 * 1024)
63455 +
63456 +static DEFINE_SPINLOCK(gr_learn_lock);
63457 +static DEFINE_MUTEX(gr_learn_user_mutex);
63458 +
63459 +/* we need to maintain two buffers, so that the kernel context of grlearn
63460 + uses a semaphore around the userspace copying, and the other kernel contexts
63461 + use a spinlock when copying into the buffer, since they cannot sleep
63462 +*/
63463 +static char *learn_buffer;
63464 +static char *learn_buffer_user;
63465 +static int learn_buffer_len;
63466 +static int learn_buffer_user_len;
63467 +
63468 +static ssize_t
63469 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63470 +{
63471 + DECLARE_WAITQUEUE(wait, current);
63472 + ssize_t retval = 0;
63473 +
63474 + add_wait_queue(&learn_wait, &wait);
63475 + set_current_state(TASK_INTERRUPTIBLE);
63476 + do {
63477 + mutex_lock(&gr_learn_user_mutex);
63478 + spin_lock(&gr_learn_lock);
63479 + if (learn_buffer_len)
63480 + break;
63481 + spin_unlock(&gr_learn_lock);
63482 + mutex_unlock(&gr_learn_user_mutex);
63483 + if (file->f_flags & O_NONBLOCK) {
63484 + retval = -EAGAIN;
63485 + goto out;
63486 + }
63487 + if (signal_pending(current)) {
63488 + retval = -ERESTARTSYS;
63489 + goto out;
63490 + }
63491 +
63492 + schedule();
63493 + } while (1);
63494 +
63495 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63496 + learn_buffer_user_len = learn_buffer_len;
63497 + retval = learn_buffer_len;
63498 + learn_buffer_len = 0;
63499 +
63500 + spin_unlock(&gr_learn_lock);
63501 +
63502 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63503 + retval = -EFAULT;
63504 +
63505 + mutex_unlock(&gr_learn_user_mutex);
63506 +out:
63507 + set_current_state(TASK_RUNNING);
63508 + remove_wait_queue(&learn_wait, &wait);
63509 + return retval;
63510 +}
63511 +
63512 +static unsigned int
63513 +poll_learn(struct file * file, poll_table * wait)
63514 +{
63515 + poll_wait(file, &learn_wait, wait);
63516 +
63517 + if (learn_buffer_len)
63518 + return (POLLIN | POLLRDNORM);
63519 +
63520 + return 0;
63521 +}
63522 +
63523 +void
63524 +gr_clear_learn_entries(void)
63525 +{
63526 + char *tmp;
63527 +
63528 + mutex_lock(&gr_learn_user_mutex);
63529 + spin_lock(&gr_learn_lock);
63530 + tmp = learn_buffer;
63531 + learn_buffer = NULL;
63532 + spin_unlock(&gr_learn_lock);
63533 + if (tmp)
63534 + vfree(tmp);
63535 + if (learn_buffer_user != NULL) {
63536 + vfree(learn_buffer_user);
63537 + learn_buffer_user = NULL;
63538 + }
63539 + learn_buffer_len = 0;
63540 + mutex_unlock(&gr_learn_user_mutex);
63541 +
63542 + return;
63543 +}
63544 +
63545 +void
63546 +gr_add_learn_entry(const char *fmt, ...)
63547 +{
63548 + va_list args;
63549 + unsigned int len;
63550 +
63551 + if (!gr_learn_attached)
63552 + return;
63553 +
63554 + spin_lock(&gr_learn_lock);
63555 +
63556 + /* leave a gap at the end so we know when it's "full" but don't have to
63557 + compute the exact length of the string we're trying to append
63558 + */
63559 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63560 + spin_unlock(&gr_learn_lock);
63561 + wake_up_interruptible(&learn_wait);
63562 + return;
63563 + }
63564 + if (learn_buffer == NULL) {
63565 + spin_unlock(&gr_learn_lock);
63566 + return;
63567 + }
63568 +
63569 + va_start(args, fmt);
63570 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63571 + va_end(args);
63572 +
63573 + learn_buffer_len += len + 1;
63574 +
63575 + spin_unlock(&gr_learn_lock);
63576 + wake_up_interruptible(&learn_wait);
63577 +
63578 + return;
63579 +}
63580 +
63581 +static int
63582 +open_learn(struct inode *inode, struct file *file)
63583 +{
63584 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63585 + return -EBUSY;
63586 + if (file->f_mode & FMODE_READ) {
63587 + int retval = 0;
63588 + mutex_lock(&gr_learn_user_mutex);
63589 + if (learn_buffer == NULL)
63590 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63591 + if (learn_buffer_user == NULL)
63592 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63593 + if (learn_buffer == NULL) {
63594 + retval = -ENOMEM;
63595 + goto out_error;
63596 + }
63597 + if (learn_buffer_user == NULL) {
63598 + retval = -ENOMEM;
63599 + goto out_error;
63600 + }
63601 + learn_buffer_len = 0;
63602 + learn_buffer_user_len = 0;
63603 + gr_learn_attached = 1;
63604 +out_error:
63605 + mutex_unlock(&gr_learn_user_mutex);
63606 + return retval;
63607 + }
63608 + return 0;
63609 +}
63610 +
63611 +static int
63612 +close_learn(struct inode *inode, struct file *file)
63613 +{
63614 + if (file->f_mode & FMODE_READ) {
63615 + char *tmp = NULL;
63616 + mutex_lock(&gr_learn_user_mutex);
63617 + spin_lock(&gr_learn_lock);
63618 + tmp = learn_buffer;
63619 + learn_buffer = NULL;
63620 + spin_unlock(&gr_learn_lock);
63621 + if (tmp)
63622 + vfree(tmp);
63623 + if (learn_buffer_user != NULL) {
63624 + vfree(learn_buffer_user);
63625 + learn_buffer_user = NULL;
63626 + }
63627 + learn_buffer_len = 0;
63628 + learn_buffer_user_len = 0;
63629 + gr_learn_attached = 0;
63630 + mutex_unlock(&gr_learn_user_mutex);
63631 + }
63632 +
63633 + return 0;
63634 +}
63635 +
63636 +const struct file_operations grsec_fops = {
63637 + .read = read_learn,
63638 + .write = write_grsec_handler,
63639 + .open = open_learn,
63640 + .release = close_learn,
63641 + .poll = poll_learn,
63642 +};
63643 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63644 new file mode 100644
63645 index 0000000..39645c9
63646 --- /dev/null
63647 +++ b/grsecurity/gracl_res.c
63648 @@ -0,0 +1,68 @@
63649 +#include <linux/kernel.h>
63650 +#include <linux/sched.h>
63651 +#include <linux/gracl.h>
63652 +#include <linux/grinternal.h>
63653 +
63654 +static const char *restab_log[] = {
63655 + [RLIMIT_CPU] = "RLIMIT_CPU",
63656 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63657 + [RLIMIT_DATA] = "RLIMIT_DATA",
63658 + [RLIMIT_STACK] = "RLIMIT_STACK",
63659 + [RLIMIT_CORE] = "RLIMIT_CORE",
63660 + [RLIMIT_RSS] = "RLIMIT_RSS",
63661 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63662 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63663 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63664 + [RLIMIT_AS] = "RLIMIT_AS",
63665 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63666 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63667 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63668 + [RLIMIT_NICE] = "RLIMIT_NICE",
63669 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63670 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63671 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63672 +};
63673 +
63674 +void
63675 +gr_log_resource(const struct task_struct *task,
63676 + const int res, const unsigned long wanted, const int gt)
63677 +{
63678 + const struct cred *cred;
63679 + unsigned long rlim;
63680 +
63681 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63682 + return;
63683 +
63684 + // not yet supported resource
63685 + if (unlikely(!restab_log[res]))
63686 + return;
63687 +
63688 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63689 + rlim = task_rlimit_max(task, res);
63690 + else
63691 + rlim = task_rlimit(task, res);
63692 +
63693 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63694 + return;
63695 +
63696 + rcu_read_lock();
63697 + cred = __task_cred(task);
63698 +
63699 + if (res == RLIMIT_NPROC &&
63700 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63701 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63702 + goto out_rcu_unlock;
63703 + else if (res == RLIMIT_MEMLOCK &&
63704 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63705 + goto out_rcu_unlock;
63706 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63707 + goto out_rcu_unlock;
63708 + rcu_read_unlock();
63709 +
63710 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63711 +
63712 + return;
63713 +out_rcu_unlock:
63714 + rcu_read_unlock();
63715 + return;
63716 +}
63717 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63718 new file mode 100644
63719 index 0000000..3c38bfe
63720 --- /dev/null
63721 +++ b/grsecurity/gracl_segv.c
63722 @@ -0,0 +1,305 @@
63723 +#include <linux/kernel.h>
63724 +#include <linux/mm.h>
63725 +#include <asm/uaccess.h>
63726 +#include <asm/errno.h>
63727 +#include <asm/mman.h>
63728 +#include <net/sock.h>
63729 +#include <linux/file.h>
63730 +#include <linux/fs.h>
63731 +#include <linux/net.h>
63732 +#include <linux/in.h>
63733 +#include <linux/slab.h>
63734 +#include <linux/types.h>
63735 +#include <linux/sched.h>
63736 +#include <linux/timer.h>
63737 +#include <linux/gracl.h>
63738 +#include <linux/grsecurity.h>
63739 +#include <linux/grinternal.h>
63740 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63741 +#include <linux/magic.h>
63742 +#include <linux/pagemap.h>
63743 +#include "../fs/btrfs/async-thread.h"
63744 +#include "../fs/btrfs/ctree.h"
63745 +#include "../fs/btrfs/btrfs_inode.h"
63746 +#endif
63747 +
63748 +static struct crash_uid *uid_set;
63749 +static unsigned short uid_used;
63750 +static DEFINE_SPINLOCK(gr_uid_lock);
63751 +extern rwlock_t gr_inode_lock;
63752 +extern struct acl_subject_label *
63753 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63754 + struct acl_role_label *role);
63755 +
63756 +static inline dev_t __get_dev(const struct dentry *dentry)
63757 +{
63758 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63759 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63760 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63761 + else
63762 +#endif
63763 + return dentry->d_sb->s_dev;
63764 +}
63765 +
63766 +int
63767 +gr_init_uidset(void)
63768 +{
63769 + uid_set =
63770 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63771 + uid_used = 0;
63772 +
63773 + return uid_set ? 1 : 0;
63774 +}
63775 +
63776 +void
63777 +gr_free_uidset(void)
63778 +{
63779 + if (uid_set)
63780 + kfree(uid_set);
63781 +
63782 + return;
63783 +}
63784 +
63785 +int
63786 +gr_find_uid(const uid_t uid)
63787 +{
63788 + struct crash_uid *tmp = uid_set;
63789 + uid_t buid;
63790 + int low = 0, high = uid_used - 1, mid;
63791 +
63792 + while (high >= low) {
63793 + mid = (low + high) >> 1;
63794 + buid = tmp[mid].uid;
63795 + if (buid == uid)
63796 + return mid;
63797 + if (buid > uid)
63798 + high = mid - 1;
63799 + if (buid < uid)
63800 + low = mid + 1;
63801 + }
63802 +
63803 + return -1;
63804 +}
63805 +
63806 +static __inline__ void
63807 +gr_insertsort(void)
63808 +{
63809 + unsigned short i, j;
63810 + struct crash_uid index;
63811 +
63812 + for (i = 1; i < uid_used; i++) {
63813 + index = uid_set[i];
63814 + j = i;
63815 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63816 + uid_set[j] = uid_set[j - 1];
63817 + j--;
63818 + }
63819 + uid_set[j] = index;
63820 + }
63821 +
63822 + return;
63823 +}
63824 +
63825 +static __inline__ void
63826 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63827 +{
63828 + int loc;
63829 + uid_t uid = GR_GLOBAL_UID(kuid);
63830 +
63831 + if (uid_used == GR_UIDTABLE_MAX)
63832 + return;
63833 +
63834 + loc = gr_find_uid(uid);
63835 +
63836 + if (loc >= 0) {
63837 + uid_set[loc].expires = expires;
63838 + return;
63839 + }
63840 +
63841 + uid_set[uid_used].uid = uid;
63842 + uid_set[uid_used].expires = expires;
63843 + uid_used++;
63844 +
63845 + gr_insertsort();
63846 +
63847 + return;
63848 +}
63849 +
63850 +void
63851 +gr_remove_uid(const unsigned short loc)
63852 +{
63853 + unsigned short i;
63854 +
63855 + for (i = loc + 1; i < uid_used; i++)
63856 + uid_set[i - 1] = uid_set[i];
63857 +
63858 + uid_used--;
63859 +
63860 + return;
63861 +}
63862 +
63863 +int
63864 +gr_check_crash_uid(const kuid_t kuid)
63865 +{
63866 + int loc;
63867 + int ret = 0;
63868 + uid_t uid;
63869 +
63870 + if (unlikely(!gr_acl_is_enabled()))
63871 + return 0;
63872 +
63873 + uid = GR_GLOBAL_UID(kuid);
63874 +
63875 + spin_lock(&gr_uid_lock);
63876 + loc = gr_find_uid(uid);
63877 +
63878 + if (loc < 0)
63879 + goto out_unlock;
63880 +
63881 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63882 + gr_remove_uid(loc);
63883 + else
63884 + ret = 1;
63885 +
63886 +out_unlock:
63887 + spin_unlock(&gr_uid_lock);
63888 + return ret;
63889 +}
63890 +
63891 +static __inline__ int
63892 +proc_is_setxid(const struct cred *cred)
63893 +{
63894 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63895 + !uid_eq(cred->uid, cred->fsuid))
63896 + return 1;
63897 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63898 + !gid_eq(cred->gid, cred->fsgid))
63899 + return 1;
63900 +
63901 + return 0;
63902 +}
63903 +
63904 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63905 +
63906 +void
63907 +gr_handle_crash(struct task_struct *task, const int sig)
63908 +{
63909 + struct acl_subject_label *curr;
63910 + struct task_struct *tsk, *tsk2;
63911 + const struct cred *cred;
63912 + const struct cred *cred2;
63913 +
63914 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63915 + return;
63916 +
63917 + if (unlikely(!gr_acl_is_enabled()))
63918 + return;
63919 +
63920 + curr = task->acl;
63921 +
63922 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63923 + return;
63924 +
63925 + if (time_before_eq(curr->expires, get_seconds())) {
63926 + curr->expires = 0;
63927 + curr->crashes = 0;
63928 + }
63929 +
63930 + curr->crashes++;
63931 +
63932 + if (!curr->expires)
63933 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63934 +
63935 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63936 + time_after(curr->expires, get_seconds())) {
63937 + rcu_read_lock();
63938 + cred = __task_cred(task);
63939 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63940 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63941 + spin_lock(&gr_uid_lock);
63942 + gr_insert_uid(cred->uid, curr->expires);
63943 + spin_unlock(&gr_uid_lock);
63944 + curr->expires = 0;
63945 + curr->crashes = 0;
63946 + read_lock(&tasklist_lock);
63947 + do_each_thread(tsk2, tsk) {
63948 + cred2 = __task_cred(tsk);
63949 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63950 + gr_fake_force_sig(SIGKILL, tsk);
63951 + } while_each_thread(tsk2, tsk);
63952 + read_unlock(&tasklist_lock);
63953 + } else {
63954 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63955 + read_lock(&tasklist_lock);
63956 + read_lock(&grsec_exec_file_lock);
63957 + do_each_thread(tsk2, tsk) {
63958 + if (likely(tsk != task)) {
63959 + // if this thread has the same subject as the one that triggered
63960 + // RES_CRASH and it's the same binary, kill it
63961 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
63962 + gr_fake_force_sig(SIGKILL, tsk);
63963 + }
63964 + } while_each_thread(tsk2, tsk);
63965 + read_unlock(&grsec_exec_file_lock);
63966 + read_unlock(&tasklist_lock);
63967 + }
63968 + rcu_read_unlock();
63969 + }
63970 +
63971 + return;
63972 +}
63973 +
63974 +int
63975 +gr_check_crash_exec(const struct file *filp)
63976 +{
63977 + struct acl_subject_label *curr;
63978 +
63979 + if (unlikely(!gr_acl_is_enabled()))
63980 + return 0;
63981 +
63982 + read_lock(&gr_inode_lock);
63983 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63984 + __get_dev(filp->f_path.dentry),
63985 + current->role);
63986 + read_unlock(&gr_inode_lock);
63987 +
63988 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63989 + (!curr->crashes && !curr->expires))
63990 + return 0;
63991 +
63992 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63993 + time_after(curr->expires, get_seconds()))
63994 + return 1;
63995 + else if (time_before_eq(curr->expires, get_seconds())) {
63996 + curr->crashes = 0;
63997 + curr->expires = 0;
63998 + }
63999 +
64000 + return 0;
64001 +}
64002 +
64003 +void
64004 +gr_handle_alertkill(struct task_struct *task)
64005 +{
64006 + struct acl_subject_label *curracl;
64007 + __u32 curr_ip;
64008 + struct task_struct *p, *p2;
64009 +
64010 + if (unlikely(!gr_acl_is_enabled()))
64011 + return;
64012 +
64013 + curracl = task->acl;
64014 + curr_ip = task->signal->curr_ip;
64015 +
64016 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
64017 + read_lock(&tasklist_lock);
64018 + do_each_thread(p2, p) {
64019 + if (p->signal->curr_ip == curr_ip)
64020 + gr_fake_force_sig(SIGKILL, p);
64021 + } while_each_thread(p2, p);
64022 + read_unlock(&tasklist_lock);
64023 + } else if (curracl->mode & GR_KILLPROC)
64024 + gr_fake_force_sig(SIGKILL, task);
64025 +
64026 + return;
64027 +}
64028 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
64029 new file mode 100644
64030 index 0000000..98011b0
64031 --- /dev/null
64032 +++ b/grsecurity/gracl_shm.c
64033 @@ -0,0 +1,40 @@
64034 +#include <linux/kernel.h>
64035 +#include <linux/mm.h>
64036 +#include <linux/sched.h>
64037 +#include <linux/file.h>
64038 +#include <linux/ipc.h>
64039 +#include <linux/gracl.h>
64040 +#include <linux/grsecurity.h>
64041 +#include <linux/grinternal.h>
64042 +
64043 +int
64044 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64045 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64046 +{
64047 + struct task_struct *task;
64048 +
64049 + if (!gr_acl_is_enabled())
64050 + return 1;
64051 +
64052 + rcu_read_lock();
64053 + read_lock(&tasklist_lock);
64054 +
64055 + task = find_task_by_vpid(shm_cprid);
64056 +
64057 + if (unlikely(!task))
64058 + task = find_task_by_vpid(shm_lapid);
64059 +
64060 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
64061 + (task_pid_nr(task) == shm_lapid)) &&
64062 + (task->acl->mode & GR_PROTSHM) &&
64063 + (task->acl != current->acl))) {
64064 + read_unlock(&tasklist_lock);
64065 + rcu_read_unlock();
64066 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
64067 + return 0;
64068 + }
64069 + read_unlock(&tasklist_lock);
64070 + rcu_read_unlock();
64071 +
64072 + return 1;
64073 +}
64074 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
64075 new file mode 100644
64076 index 0000000..bc0be01
64077 --- /dev/null
64078 +++ b/grsecurity/grsec_chdir.c
64079 @@ -0,0 +1,19 @@
64080 +#include <linux/kernel.h>
64081 +#include <linux/sched.h>
64082 +#include <linux/fs.h>
64083 +#include <linux/file.h>
64084 +#include <linux/grsecurity.h>
64085 +#include <linux/grinternal.h>
64086 +
64087 +void
64088 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64089 +{
64090 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64091 + if ((grsec_enable_chdir && grsec_enable_group &&
64092 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64093 + !grsec_enable_group)) {
64094 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64095 + }
64096 +#endif
64097 + return;
64098 +}
64099 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64100 new file mode 100644
64101 index 0000000..bd6e105
64102 --- /dev/null
64103 +++ b/grsecurity/grsec_chroot.c
64104 @@ -0,0 +1,370 @@
64105 +#include <linux/kernel.h>
64106 +#include <linux/module.h>
64107 +#include <linux/sched.h>
64108 +#include <linux/file.h>
64109 +#include <linux/fs.h>
64110 +#include <linux/mount.h>
64111 +#include <linux/types.h>
64112 +#include "../fs/mount.h"
64113 +#include <linux/grsecurity.h>
64114 +#include <linux/grinternal.h>
64115 +
64116 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64117 +static int gr_init_ran;
64118 +#endif
64119 +
64120 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
64121 +{
64122 +#ifdef CONFIG_GRKERNSEC
64123 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64124 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64125 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64126 + && gr_init_ran
64127 +#endif
64128 + )
64129 + task->gr_is_chrooted = 1;
64130 + else {
64131 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64132 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64133 + gr_init_ran = 1;
64134 +#endif
64135 + task->gr_is_chrooted = 0;
64136 + }
64137 +
64138 + task->gr_chroot_dentry = path->dentry;
64139 +#endif
64140 + return;
64141 +}
64142 +
64143 +void gr_clear_chroot_entries(struct task_struct *task)
64144 +{
64145 +#ifdef CONFIG_GRKERNSEC
64146 + task->gr_is_chrooted = 0;
64147 + task->gr_chroot_dentry = NULL;
64148 +#endif
64149 + return;
64150 +}
64151 +
64152 +int
64153 +gr_handle_chroot_unix(const pid_t pid)
64154 +{
64155 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64156 + struct task_struct *p;
64157 +
64158 + if (unlikely(!grsec_enable_chroot_unix))
64159 + return 1;
64160 +
64161 + if (likely(!proc_is_chrooted(current)))
64162 + return 1;
64163 +
64164 + rcu_read_lock();
64165 + read_lock(&tasklist_lock);
64166 + p = find_task_by_vpid_unrestricted(pid);
64167 + if (unlikely(p && !have_same_root(current, p))) {
64168 + read_unlock(&tasklist_lock);
64169 + rcu_read_unlock();
64170 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64171 + return 0;
64172 + }
64173 + read_unlock(&tasklist_lock);
64174 + rcu_read_unlock();
64175 +#endif
64176 + return 1;
64177 +}
64178 +
64179 +int
64180 +gr_handle_chroot_nice(void)
64181 +{
64182 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64183 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64184 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64185 + return -EPERM;
64186 + }
64187 +#endif
64188 + return 0;
64189 +}
64190 +
64191 +int
64192 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64193 +{
64194 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64195 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64196 + && proc_is_chrooted(current)) {
64197 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64198 + return -EACCES;
64199 + }
64200 +#endif
64201 + return 0;
64202 +}
64203 +
64204 +int
64205 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64206 +{
64207 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64208 + struct task_struct *p;
64209 + int ret = 0;
64210 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64211 + return ret;
64212 +
64213 + read_lock(&tasklist_lock);
64214 + do_each_pid_task(pid, type, p) {
64215 + if (!have_same_root(current, p)) {
64216 + ret = 1;
64217 + goto out;
64218 + }
64219 + } while_each_pid_task(pid, type, p);
64220 +out:
64221 + read_unlock(&tasklist_lock);
64222 + return ret;
64223 +#endif
64224 + return 0;
64225 +}
64226 +
64227 +int
64228 +gr_pid_is_chrooted(struct task_struct *p)
64229 +{
64230 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64231 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64232 + return 0;
64233 +
64234 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64235 + !have_same_root(current, p)) {
64236 + return 1;
64237 + }
64238 +#endif
64239 + return 0;
64240 +}
64241 +
64242 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64243 +
64244 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64245 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64246 +{
64247 + struct path path, currentroot;
64248 + int ret = 0;
64249 +
64250 + path.dentry = (struct dentry *)u_dentry;
64251 + path.mnt = (struct vfsmount *)u_mnt;
64252 + get_fs_root(current->fs, &currentroot);
64253 + if (path_is_under(&path, &currentroot))
64254 + ret = 1;
64255 + path_put(&currentroot);
64256 +
64257 + return ret;
64258 +}
64259 +#endif
64260 +
64261 +int
64262 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64263 +{
64264 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64265 + if (!grsec_enable_chroot_fchdir)
64266 + return 1;
64267 +
64268 + if (!proc_is_chrooted(current))
64269 + return 1;
64270 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64271 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64272 + return 0;
64273 + }
64274 +#endif
64275 + return 1;
64276 +}
64277 +
64278 +int
64279 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64280 + const time_t shm_createtime)
64281 +{
64282 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64283 + struct task_struct *p;
64284 + time_t starttime;
64285 +
64286 + if (unlikely(!grsec_enable_chroot_shmat))
64287 + return 1;
64288 +
64289 + if (likely(!proc_is_chrooted(current)))
64290 + return 1;
64291 +
64292 + rcu_read_lock();
64293 + read_lock(&tasklist_lock);
64294 +
64295 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64296 + starttime = p->start_time.tv_sec;
64297 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64298 + if (have_same_root(current, p)) {
64299 + goto allow;
64300 + } else {
64301 + read_unlock(&tasklist_lock);
64302 + rcu_read_unlock();
64303 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64304 + return 0;
64305 + }
64306 + }
64307 + /* creator exited, pid reuse, fall through to next check */
64308 + }
64309 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64310 + if (unlikely(!have_same_root(current, p))) {
64311 + read_unlock(&tasklist_lock);
64312 + rcu_read_unlock();
64313 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64314 + return 0;
64315 + }
64316 + }
64317 +
64318 +allow:
64319 + read_unlock(&tasklist_lock);
64320 + rcu_read_unlock();
64321 +#endif
64322 + return 1;
64323 +}
64324 +
64325 +void
64326 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64327 +{
64328 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64329 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64330 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64331 +#endif
64332 + return;
64333 +}
64334 +
64335 +int
64336 +gr_handle_chroot_mknod(const struct dentry *dentry,
64337 + const struct vfsmount *mnt, const int mode)
64338 +{
64339 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64340 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64341 + proc_is_chrooted(current)) {
64342 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64343 + return -EPERM;
64344 + }
64345 +#endif
64346 + return 0;
64347 +}
64348 +
64349 +int
64350 +gr_handle_chroot_mount(const struct dentry *dentry,
64351 + const struct vfsmount *mnt, const char *dev_name)
64352 +{
64353 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64354 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64355 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64356 + return -EPERM;
64357 + }
64358 +#endif
64359 + return 0;
64360 +}
64361 +
64362 +int
64363 +gr_handle_chroot_pivot(void)
64364 +{
64365 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64366 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64367 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64368 + return -EPERM;
64369 + }
64370 +#endif
64371 + return 0;
64372 +}
64373 +
64374 +int
64375 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64376 +{
64377 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64378 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64379 + !gr_is_outside_chroot(dentry, mnt)) {
64380 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64381 + return -EPERM;
64382 + }
64383 +#endif
64384 + return 0;
64385 +}
64386 +
64387 +extern const char *captab_log[];
64388 +extern int captab_log_entries;
64389 +
64390 +int
64391 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64392 +{
64393 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64394 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64395 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64396 + if (cap_raised(chroot_caps, cap)) {
64397 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64398 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64399 + }
64400 + return 0;
64401 + }
64402 + }
64403 +#endif
64404 + return 1;
64405 +}
64406 +
64407 +int
64408 +gr_chroot_is_capable(const int cap)
64409 +{
64410 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64411 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64412 +#endif
64413 + return 1;
64414 +}
64415 +
64416 +int
64417 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64418 +{
64419 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64420 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64421 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64422 + if (cap_raised(chroot_caps, cap)) {
64423 + return 0;
64424 + }
64425 + }
64426 +#endif
64427 + return 1;
64428 +}
64429 +
64430 +int
64431 +gr_chroot_is_capable_nolog(const int cap)
64432 +{
64433 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64434 + return gr_task_chroot_is_capable_nolog(current, cap);
64435 +#endif
64436 + return 1;
64437 +}
64438 +
64439 +int
64440 +gr_handle_chroot_sysctl(const int op)
64441 +{
64442 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64443 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64444 + proc_is_chrooted(current))
64445 + return -EACCES;
64446 +#endif
64447 + return 0;
64448 +}
64449 +
64450 +void
64451 +gr_handle_chroot_chdir(const struct path *path)
64452 +{
64453 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64454 + if (grsec_enable_chroot_chdir)
64455 + set_fs_pwd(current->fs, path);
64456 +#endif
64457 + return;
64458 +}
64459 +
64460 +int
64461 +gr_handle_chroot_chmod(const struct dentry *dentry,
64462 + const struct vfsmount *mnt, const int mode)
64463 +{
64464 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64465 + /* allow chmod +s on directories, but not files */
64466 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64467 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64468 + proc_is_chrooted(current)) {
64469 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64470 + return -EPERM;
64471 + }
64472 +#endif
64473 + return 0;
64474 +}
64475 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64476 new file mode 100644
64477 index 0000000..ce65ceb
64478 --- /dev/null
64479 +++ b/grsecurity/grsec_disabled.c
64480 @@ -0,0 +1,434 @@
64481 +#include <linux/kernel.h>
64482 +#include <linux/module.h>
64483 +#include <linux/sched.h>
64484 +#include <linux/file.h>
64485 +#include <linux/fs.h>
64486 +#include <linux/kdev_t.h>
64487 +#include <linux/net.h>
64488 +#include <linux/in.h>
64489 +#include <linux/ip.h>
64490 +#include <linux/skbuff.h>
64491 +#include <linux/sysctl.h>
64492 +
64493 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64494 +void
64495 +pax_set_initial_flags(struct linux_binprm *bprm)
64496 +{
64497 + return;
64498 +}
64499 +#endif
64500 +
64501 +#ifdef CONFIG_SYSCTL
64502 +__u32
64503 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64504 +{
64505 + return 0;
64506 +}
64507 +#endif
64508 +
64509 +#ifdef CONFIG_TASKSTATS
64510 +int gr_is_taskstats_denied(int pid)
64511 +{
64512 + return 0;
64513 +}
64514 +#endif
64515 +
64516 +int
64517 +gr_acl_is_enabled(void)
64518 +{
64519 + return 0;
64520 +}
64521 +
64522 +void
64523 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64524 +{
64525 + return;
64526 +}
64527 +
64528 +int
64529 +gr_handle_rawio(const struct inode *inode)
64530 +{
64531 + return 0;
64532 +}
64533 +
64534 +void
64535 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64536 +{
64537 + return;
64538 +}
64539 +
64540 +int
64541 +gr_handle_ptrace(struct task_struct *task, const long request)
64542 +{
64543 + return 0;
64544 +}
64545 +
64546 +int
64547 +gr_handle_proc_ptrace(struct task_struct *task)
64548 +{
64549 + return 0;
64550 +}
64551 +
64552 +int
64553 +gr_set_acls(const int type)
64554 +{
64555 + return 0;
64556 +}
64557 +
64558 +int
64559 +gr_check_hidden_task(const struct task_struct *tsk)
64560 +{
64561 + return 0;
64562 +}
64563 +
64564 +int
64565 +gr_check_protected_task(const struct task_struct *task)
64566 +{
64567 + return 0;
64568 +}
64569 +
64570 +int
64571 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64572 +{
64573 + return 0;
64574 +}
64575 +
64576 +void
64577 +gr_copy_label(struct task_struct *tsk)
64578 +{
64579 + return;
64580 +}
64581 +
64582 +void
64583 +gr_set_pax_flags(struct task_struct *task)
64584 +{
64585 + return;
64586 +}
64587 +
64588 +int
64589 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64590 + const int unsafe_share)
64591 +{
64592 + return 0;
64593 +}
64594 +
64595 +void
64596 +gr_handle_delete(const ino_t ino, const dev_t dev)
64597 +{
64598 + return;
64599 +}
64600 +
64601 +void
64602 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64603 +{
64604 + return;
64605 +}
64606 +
64607 +void
64608 +gr_handle_crash(struct task_struct *task, const int sig)
64609 +{
64610 + return;
64611 +}
64612 +
64613 +int
64614 +gr_check_crash_exec(const struct file *filp)
64615 +{
64616 + return 0;
64617 +}
64618 +
64619 +int
64620 +gr_check_crash_uid(const kuid_t uid)
64621 +{
64622 + return 0;
64623 +}
64624 +
64625 +void
64626 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64627 + struct dentry *old_dentry,
64628 + struct dentry *new_dentry,
64629 + struct vfsmount *mnt, const __u8 replace)
64630 +{
64631 + return;
64632 +}
64633 +
64634 +int
64635 +gr_search_socket(const int family, const int type, const int protocol)
64636 +{
64637 + return 1;
64638 +}
64639 +
64640 +int
64641 +gr_search_connectbind(const int mode, const struct socket *sock,
64642 + const struct sockaddr_in *addr)
64643 +{
64644 + return 0;
64645 +}
64646 +
64647 +void
64648 +gr_handle_alertkill(struct task_struct *task)
64649 +{
64650 + return;
64651 +}
64652 +
64653 +__u32
64654 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64655 +{
64656 + return 1;
64657 +}
64658 +
64659 +__u32
64660 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64661 + const struct vfsmount * mnt)
64662 +{
64663 + return 1;
64664 +}
64665 +
64666 +__u32
64667 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64668 + int acc_mode)
64669 +{
64670 + return 1;
64671 +}
64672 +
64673 +__u32
64674 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64675 +{
64676 + return 1;
64677 +}
64678 +
64679 +__u32
64680 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64681 +{
64682 + return 1;
64683 +}
64684 +
64685 +int
64686 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64687 + unsigned int *vm_flags)
64688 +{
64689 + return 1;
64690 +}
64691 +
64692 +__u32
64693 +gr_acl_handle_truncate(const struct dentry * dentry,
64694 + const struct vfsmount * mnt)
64695 +{
64696 + return 1;
64697 +}
64698 +
64699 +__u32
64700 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64701 +{
64702 + return 1;
64703 +}
64704 +
64705 +__u32
64706 +gr_acl_handle_access(const struct dentry * dentry,
64707 + const struct vfsmount * mnt, const int fmode)
64708 +{
64709 + return 1;
64710 +}
64711 +
64712 +__u32
64713 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64714 + umode_t *mode)
64715 +{
64716 + return 1;
64717 +}
64718 +
64719 +__u32
64720 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64721 +{
64722 + return 1;
64723 +}
64724 +
64725 +__u32
64726 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64727 +{
64728 + return 1;
64729 +}
64730 +
64731 +void
64732 +grsecurity_init(void)
64733 +{
64734 + return;
64735 +}
64736 +
64737 +umode_t gr_acl_umask(void)
64738 +{
64739 + return 0;
64740 +}
64741 +
64742 +__u32
64743 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64744 + const struct dentry * parent_dentry,
64745 + const struct vfsmount * parent_mnt,
64746 + const int mode)
64747 +{
64748 + return 1;
64749 +}
64750 +
64751 +__u32
64752 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64753 + const struct dentry * parent_dentry,
64754 + const struct vfsmount * parent_mnt)
64755 +{
64756 + return 1;
64757 +}
64758 +
64759 +__u32
64760 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64761 + const struct dentry * parent_dentry,
64762 + const struct vfsmount * parent_mnt, const struct filename *from)
64763 +{
64764 + return 1;
64765 +}
64766 +
64767 +__u32
64768 +gr_acl_handle_link(const struct dentry * new_dentry,
64769 + const struct dentry * parent_dentry,
64770 + const struct vfsmount * parent_mnt,
64771 + const struct dentry * old_dentry,
64772 + const struct vfsmount * old_mnt, const struct filename *to)
64773 +{
64774 + return 1;
64775 +}
64776 +
64777 +int
64778 +gr_acl_handle_rename(const struct dentry *new_dentry,
64779 + const struct dentry *parent_dentry,
64780 + const struct vfsmount *parent_mnt,
64781 + const struct dentry *old_dentry,
64782 + const struct inode *old_parent_inode,
64783 + const struct vfsmount *old_mnt, const struct filename *newname)
64784 +{
64785 + return 0;
64786 +}
64787 +
64788 +int
64789 +gr_acl_handle_filldir(const struct file *file, const char *name,
64790 + const int namelen, const ino_t ino)
64791 +{
64792 + return 1;
64793 +}
64794 +
64795 +int
64796 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64797 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64798 +{
64799 + return 1;
64800 +}
64801 +
64802 +int
64803 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64804 +{
64805 + return 0;
64806 +}
64807 +
64808 +int
64809 +gr_search_accept(const struct socket *sock)
64810 +{
64811 + return 0;
64812 +}
64813 +
64814 +int
64815 +gr_search_listen(const struct socket *sock)
64816 +{
64817 + return 0;
64818 +}
64819 +
64820 +int
64821 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64822 +{
64823 + return 0;
64824 +}
64825 +
64826 +__u32
64827 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64828 +{
64829 + return 1;
64830 +}
64831 +
64832 +__u32
64833 +gr_acl_handle_creat(const struct dentry * dentry,
64834 + const struct dentry * p_dentry,
64835 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64836 + const int imode)
64837 +{
64838 + return 1;
64839 +}
64840 +
64841 +void
64842 +gr_acl_handle_exit(void)
64843 +{
64844 + return;
64845 +}
64846 +
64847 +int
64848 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64849 +{
64850 + return 1;
64851 +}
64852 +
64853 +void
64854 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64855 +{
64856 + return;
64857 +}
64858 +
64859 +int
64860 +gr_acl_handle_procpidmem(const struct task_struct *task)
64861 +{
64862 + return 0;
64863 +}
64864 +
64865 +int
64866 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64867 +{
64868 + return 0;
64869 +}
64870 +
64871 +int
64872 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64873 +{
64874 + return 0;
64875 +}
64876 +
64877 +void
64878 +gr_set_kernel_label(struct task_struct *task)
64879 +{
64880 + return;
64881 +}
64882 +
64883 +int
64884 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64885 +{
64886 + return 0;
64887 +}
64888 +
64889 +int
64890 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64891 +{
64892 + return 0;
64893 +}
64894 +
64895 +int gr_acl_enable_at_secure(void)
64896 +{
64897 + return 0;
64898 +}
64899 +
64900 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64901 +{
64902 + return dentry->d_sb->s_dev;
64903 +}
64904 +
64905 +void gr_put_exec_file(struct task_struct *task)
64906 +{
64907 + return;
64908 +}
64909 +
64910 +EXPORT_SYMBOL(gr_set_kernel_label);
64911 +#ifdef CONFIG_SECURITY
64912 +EXPORT_SYMBOL(gr_check_user_change);
64913 +EXPORT_SYMBOL(gr_check_group_change);
64914 +#endif
64915 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64916 new file mode 100644
64917 index 0000000..387032b
64918 --- /dev/null
64919 +++ b/grsecurity/grsec_exec.c
64920 @@ -0,0 +1,187 @@
64921 +#include <linux/kernel.h>
64922 +#include <linux/sched.h>
64923 +#include <linux/file.h>
64924 +#include <linux/binfmts.h>
64925 +#include <linux/fs.h>
64926 +#include <linux/types.h>
64927 +#include <linux/grdefs.h>
64928 +#include <linux/grsecurity.h>
64929 +#include <linux/grinternal.h>
64930 +#include <linux/capability.h>
64931 +#include <linux/module.h>
64932 +#include <linux/compat.h>
64933 +
64934 +#include <asm/uaccess.h>
64935 +
64936 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64937 +static char gr_exec_arg_buf[132];
64938 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64939 +#endif
64940 +
64941 +struct user_arg_ptr {
64942 +#ifdef CONFIG_COMPAT
64943 + bool is_compat;
64944 +#endif
64945 + union {
64946 + const char __user *const __user *native;
64947 +#ifdef CONFIG_COMPAT
64948 + const compat_uptr_t __user *compat;
64949 +#endif
64950 + } ptr;
64951 +};
64952 +
64953 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64954 +
64955 +void
64956 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64957 +{
64958 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64959 + char *grarg = gr_exec_arg_buf;
64960 + unsigned int i, x, execlen = 0;
64961 + char c;
64962 +
64963 + if (!((grsec_enable_execlog && grsec_enable_group &&
64964 + in_group_p(grsec_audit_gid))
64965 + || (grsec_enable_execlog && !grsec_enable_group)))
64966 + return;
64967 +
64968 + mutex_lock(&gr_exec_arg_mutex);
64969 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64970 +
64971 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64972 + const char __user *p;
64973 + unsigned int len;
64974 +
64975 + p = get_user_arg_ptr(argv, i);
64976 + if (IS_ERR(p))
64977 + goto log;
64978 +
64979 + len = strnlen_user(p, 128 - execlen);
64980 + if (len > 128 - execlen)
64981 + len = 128 - execlen;
64982 + else if (len > 0)
64983 + len--;
64984 + if (copy_from_user(grarg + execlen, p, len))
64985 + goto log;
64986 +
64987 + /* rewrite unprintable characters */
64988 + for (x = 0; x < len; x++) {
64989 + c = *(grarg + execlen + x);
64990 + if (c < 32 || c > 126)
64991 + *(grarg + execlen + x) = ' ';
64992 + }
64993 +
64994 + execlen += len;
64995 + *(grarg + execlen) = ' ';
64996 + *(grarg + execlen + 1) = '\0';
64997 + execlen++;
64998 + }
64999 +
65000 + log:
65001 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
65002 + bprm->file->f_path.mnt, grarg);
65003 + mutex_unlock(&gr_exec_arg_mutex);
65004 +#endif
65005 + return;
65006 +}
65007 +
65008 +#ifdef CONFIG_GRKERNSEC
65009 +extern int gr_acl_is_capable(const int cap);
65010 +extern int gr_acl_is_capable_nolog(const int cap);
65011 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65012 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
65013 +extern int gr_chroot_is_capable(const int cap);
65014 +extern int gr_chroot_is_capable_nolog(const int cap);
65015 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65016 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
65017 +#endif
65018 +
65019 +const char *captab_log[] = {
65020 + "CAP_CHOWN",
65021 + "CAP_DAC_OVERRIDE",
65022 + "CAP_DAC_READ_SEARCH",
65023 + "CAP_FOWNER",
65024 + "CAP_FSETID",
65025 + "CAP_KILL",
65026 + "CAP_SETGID",
65027 + "CAP_SETUID",
65028 + "CAP_SETPCAP",
65029 + "CAP_LINUX_IMMUTABLE",
65030 + "CAP_NET_BIND_SERVICE",
65031 + "CAP_NET_BROADCAST",
65032 + "CAP_NET_ADMIN",
65033 + "CAP_NET_RAW",
65034 + "CAP_IPC_LOCK",
65035 + "CAP_IPC_OWNER",
65036 + "CAP_SYS_MODULE",
65037 + "CAP_SYS_RAWIO",
65038 + "CAP_SYS_CHROOT",
65039 + "CAP_SYS_PTRACE",
65040 + "CAP_SYS_PACCT",
65041 + "CAP_SYS_ADMIN",
65042 + "CAP_SYS_BOOT",
65043 + "CAP_SYS_NICE",
65044 + "CAP_SYS_RESOURCE",
65045 + "CAP_SYS_TIME",
65046 + "CAP_SYS_TTY_CONFIG",
65047 + "CAP_MKNOD",
65048 + "CAP_LEASE",
65049 + "CAP_AUDIT_WRITE",
65050 + "CAP_AUDIT_CONTROL",
65051 + "CAP_SETFCAP",
65052 + "CAP_MAC_OVERRIDE",
65053 + "CAP_MAC_ADMIN",
65054 + "CAP_SYSLOG",
65055 + "CAP_WAKE_ALARM"
65056 +};
65057 +
65058 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
65059 +
65060 +int gr_is_capable(const int cap)
65061 +{
65062 +#ifdef CONFIG_GRKERNSEC
65063 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
65064 + return 1;
65065 + return 0;
65066 +#else
65067 + return 1;
65068 +#endif
65069 +}
65070 +
65071 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65072 +{
65073 +#ifdef CONFIG_GRKERNSEC
65074 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
65075 + return 1;
65076 + return 0;
65077 +#else
65078 + return 1;
65079 +#endif
65080 +}
65081 +
65082 +int gr_is_capable_nolog(const int cap)
65083 +{
65084 +#ifdef CONFIG_GRKERNSEC
65085 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
65086 + return 1;
65087 + return 0;
65088 +#else
65089 + return 1;
65090 +#endif
65091 +}
65092 +
65093 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
65094 +{
65095 +#ifdef CONFIG_GRKERNSEC
65096 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65097 + return 1;
65098 + return 0;
65099 +#else
65100 + return 1;
65101 +#endif
65102 +}
65103 +
65104 +EXPORT_SYMBOL(gr_is_capable);
65105 +EXPORT_SYMBOL(gr_is_capable_nolog);
65106 +EXPORT_SYMBOL(gr_task_is_capable);
65107 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65108 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65109 new file mode 100644
65110 index 0000000..06cc6ea
65111 --- /dev/null
65112 +++ b/grsecurity/grsec_fifo.c
65113 @@ -0,0 +1,24 @@
65114 +#include <linux/kernel.h>
65115 +#include <linux/sched.h>
65116 +#include <linux/fs.h>
65117 +#include <linux/file.h>
65118 +#include <linux/grinternal.h>
65119 +
65120 +int
65121 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65122 + const struct dentry *dir, const int flag, const int acc_mode)
65123 +{
65124 +#ifdef CONFIG_GRKERNSEC_FIFO
65125 + const struct cred *cred = current_cred();
65126 +
65127 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65128 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65129 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65130 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65131 + if (!inode_permission(dentry->d_inode, acc_mode))
65132 + 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));
65133 + return -EACCES;
65134 + }
65135 +#endif
65136 + return 0;
65137 +}
65138 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65139 new file mode 100644
65140 index 0000000..8ca18bf
65141 --- /dev/null
65142 +++ b/grsecurity/grsec_fork.c
65143 @@ -0,0 +1,23 @@
65144 +#include <linux/kernel.h>
65145 +#include <linux/sched.h>
65146 +#include <linux/grsecurity.h>
65147 +#include <linux/grinternal.h>
65148 +#include <linux/errno.h>
65149 +
65150 +void
65151 +gr_log_forkfail(const int retval)
65152 +{
65153 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65154 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65155 + switch (retval) {
65156 + case -EAGAIN:
65157 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65158 + break;
65159 + case -ENOMEM:
65160 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65161 + break;
65162 + }
65163 + }
65164 +#endif
65165 + return;
65166 +}
65167 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65168 new file mode 100644
65169 index 0000000..a862e9f
65170 --- /dev/null
65171 +++ b/grsecurity/grsec_init.c
65172 @@ -0,0 +1,283 @@
65173 +#include <linux/kernel.h>
65174 +#include <linux/sched.h>
65175 +#include <linux/mm.h>
65176 +#include <linux/gracl.h>
65177 +#include <linux/slab.h>
65178 +#include <linux/vmalloc.h>
65179 +#include <linux/percpu.h>
65180 +#include <linux/module.h>
65181 +
65182 +int grsec_enable_ptrace_readexec;
65183 +int grsec_enable_setxid;
65184 +int grsec_enable_symlinkown;
65185 +kgid_t grsec_symlinkown_gid;
65186 +int grsec_enable_brute;
65187 +int grsec_enable_link;
65188 +int grsec_enable_dmesg;
65189 +int grsec_enable_harden_ptrace;
65190 +int grsec_enable_fifo;
65191 +int grsec_enable_execlog;
65192 +int grsec_enable_signal;
65193 +int grsec_enable_forkfail;
65194 +int grsec_enable_audit_ptrace;
65195 +int grsec_enable_time;
65196 +int grsec_enable_audit_textrel;
65197 +int grsec_enable_group;
65198 +kgid_t grsec_audit_gid;
65199 +int grsec_enable_chdir;
65200 +int grsec_enable_mount;
65201 +int grsec_enable_rofs;
65202 +int grsec_enable_chroot_findtask;
65203 +int grsec_enable_chroot_mount;
65204 +int grsec_enable_chroot_shmat;
65205 +int grsec_enable_chroot_fchdir;
65206 +int grsec_enable_chroot_double;
65207 +int grsec_enable_chroot_pivot;
65208 +int grsec_enable_chroot_chdir;
65209 +int grsec_enable_chroot_chmod;
65210 +int grsec_enable_chroot_mknod;
65211 +int grsec_enable_chroot_nice;
65212 +int grsec_enable_chroot_execlog;
65213 +int grsec_enable_chroot_caps;
65214 +int grsec_enable_chroot_sysctl;
65215 +int grsec_enable_chroot_unix;
65216 +int grsec_enable_tpe;
65217 +kgid_t grsec_tpe_gid;
65218 +int grsec_enable_blackhole;
65219 +#ifdef CONFIG_IPV6_MODULE
65220 +EXPORT_SYMBOL(grsec_enable_blackhole);
65221 +#endif
65222 +int grsec_lastack_retries;
65223 +int grsec_enable_tpe_all;
65224 +int grsec_enable_tpe_invert;
65225 +int grsec_enable_socket_all;
65226 +kgid_t grsec_socket_all_gid;
65227 +int grsec_enable_socket_client;
65228 +kgid_t grsec_socket_client_gid;
65229 +int grsec_enable_socket_server;
65230 +kgid_t grsec_socket_server_gid;
65231 +int grsec_resource_logging;
65232 +int grsec_disable_privio;
65233 +int grsec_enable_log_rwxmaps;
65234 +int grsec_lock;
65235 +
65236 +DEFINE_SPINLOCK(grsec_alert_lock);
65237 +unsigned long grsec_alert_wtime = 0;
65238 +unsigned long grsec_alert_fyet = 0;
65239 +
65240 +DEFINE_SPINLOCK(grsec_audit_lock);
65241 +
65242 +DEFINE_RWLOCK(grsec_exec_file_lock);
65243 +
65244 +char *gr_shared_page[4];
65245 +
65246 +char *gr_alert_log_fmt;
65247 +char *gr_audit_log_fmt;
65248 +char *gr_alert_log_buf;
65249 +char *gr_audit_log_buf;
65250 +
65251 +extern struct gr_arg *gr_usermode;
65252 +extern unsigned char *gr_system_salt;
65253 +extern unsigned char *gr_system_sum;
65254 +
65255 +void __init
65256 +grsecurity_init(void)
65257 +{
65258 + int j;
65259 + /* create the per-cpu shared pages */
65260 +
65261 +#ifdef CONFIG_X86
65262 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65263 +#endif
65264 +
65265 + for (j = 0; j < 4; j++) {
65266 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65267 + if (gr_shared_page[j] == NULL) {
65268 + panic("Unable to allocate grsecurity shared page");
65269 + return;
65270 + }
65271 + }
65272 +
65273 + /* allocate log buffers */
65274 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65275 + if (!gr_alert_log_fmt) {
65276 + panic("Unable to allocate grsecurity alert log format buffer");
65277 + return;
65278 + }
65279 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65280 + if (!gr_audit_log_fmt) {
65281 + panic("Unable to allocate grsecurity audit log format buffer");
65282 + return;
65283 + }
65284 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65285 + if (!gr_alert_log_buf) {
65286 + panic("Unable to allocate grsecurity alert log buffer");
65287 + return;
65288 + }
65289 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65290 + if (!gr_audit_log_buf) {
65291 + panic("Unable to allocate grsecurity audit log buffer");
65292 + return;
65293 + }
65294 +
65295 + /* allocate memory for authentication structure */
65296 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65297 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65298 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65299 +
65300 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65301 + panic("Unable to allocate grsecurity authentication structure");
65302 + return;
65303 + }
65304 +
65305 +
65306 +#ifdef CONFIG_GRKERNSEC_IO
65307 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65308 + grsec_disable_privio = 1;
65309 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65310 + grsec_disable_privio = 1;
65311 +#else
65312 + grsec_disable_privio = 0;
65313 +#endif
65314 +#endif
65315 +
65316 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65317 + /* for backward compatibility, tpe_invert always defaults to on if
65318 + enabled in the kernel
65319 + */
65320 + grsec_enable_tpe_invert = 1;
65321 +#endif
65322 +
65323 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65324 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65325 + grsec_lock = 1;
65326 +#endif
65327 +
65328 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65329 + grsec_enable_audit_textrel = 1;
65330 +#endif
65331 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65332 + grsec_enable_log_rwxmaps = 1;
65333 +#endif
65334 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65335 + grsec_enable_group = 1;
65336 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65337 +#endif
65338 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65339 + grsec_enable_ptrace_readexec = 1;
65340 +#endif
65341 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65342 + grsec_enable_chdir = 1;
65343 +#endif
65344 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65345 + grsec_enable_harden_ptrace = 1;
65346 +#endif
65347 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65348 + grsec_enable_mount = 1;
65349 +#endif
65350 +#ifdef CONFIG_GRKERNSEC_LINK
65351 + grsec_enable_link = 1;
65352 +#endif
65353 +#ifdef CONFIG_GRKERNSEC_BRUTE
65354 + grsec_enable_brute = 1;
65355 +#endif
65356 +#ifdef CONFIG_GRKERNSEC_DMESG
65357 + grsec_enable_dmesg = 1;
65358 +#endif
65359 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65360 + grsec_enable_blackhole = 1;
65361 + grsec_lastack_retries = 4;
65362 +#endif
65363 +#ifdef CONFIG_GRKERNSEC_FIFO
65364 + grsec_enable_fifo = 1;
65365 +#endif
65366 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65367 + grsec_enable_execlog = 1;
65368 +#endif
65369 +#ifdef CONFIG_GRKERNSEC_SETXID
65370 + grsec_enable_setxid = 1;
65371 +#endif
65372 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65373 + grsec_enable_signal = 1;
65374 +#endif
65375 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65376 + grsec_enable_forkfail = 1;
65377 +#endif
65378 +#ifdef CONFIG_GRKERNSEC_TIME
65379 + grsec_enable_time = 1;
65380 +#endif
65381 +#ifdef CONFIG_GRKERNSEC_RESLOG
65382 + grsec_resource_logging = 1;
65383 +#endif
65384 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65385 + grsec_enable_chroot_findtask = 1;
65386 +#endif
65387 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65388 + grsec_enable_chroot_unix = 1;
65389 +#endif
65390 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65391 + grsec_enable_chroot_mount = 1;
65392 +#endif
65393 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65394 + grsec_enable_chroot_fchdir = 1;
65395 +#endif
65396 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65397 + grsec_enable_chroot_shmat = 1;
65398 +#endif
65399 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65400 + grsec_enable_audit_ptrace = 1;
65401 +#endif
65402 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65403 + grsec_enable_chroot_double = 1;
65404 +#endif
65405 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65406 + grsec_enable_chroot_pivot = 1;
65407 +#endif
65408 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65409 + grsec_enable_chroot_chdir = 1;
65410 +#endif
65411 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65412 + grsec_enable_chroot_chmod = 1;
65413 +#endif
65414 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65415 + grsec_enable_chroot_mknod = 1;
65416 +#endif
65417 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65418 + grsec_enable_chroot_nice = 1;
65419 +#endif
65420 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65421 + grsec_enable_chroot_execlog = 1;
65422 +#endif
65423 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65424 + grsec_enable_chroot_caps = 1;
65425 +#endif
65426 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65427 + grsec_enable_chroot_sysctl = 1;
65428 +#endif
65429 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65430 + grsec_enable_symlinkown = 1;
65431 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65432 +#endif
65433 +#ifdef CONFIG_GRKERNSEC_TPE
65434 + grsec_enable_tpe = 1;
65435 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65436 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65437 + grsec_enable_tpe_all = 1;
65438 +#endif
65439 +#endif
65440 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65441 + grsec_enable_socket_all = 1;
65442 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65443 +#endif
65444 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65445 + grsec_enable_socket_client = 1;
65446 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65447 +#endif
65448 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65449 + grsec_enable_socket_server = 1;
65450 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65451 +#endif
65452 +#endif
65453 +
65454 + return;
65455 +}
65456 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65457 new file mode 100644
65458 index 0000000..5e05e20
65459 --- /dev/null
65460 +++ b/grsecurity/grsec_link.c
65461 @@ -0,0 +1,58 @@
65462 +#include <linux/kernel.h>
65463 +#include <linux/sched.h>
65464 +#include <linux/fs.h>
65465 +#include <linux/file.h>
65466 +#include <linux/grinternal.h>
65467 +
65468 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65469 +{
65470 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65471 + const struct inode *link_inode = link->dentry->d_inode;
65472 +
65473 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65474 + /* ignore root-owned links, e.g. /proc/self */
65475 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65476 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65477 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65478 + return 1;
65479 + }
65480 +#endif
65481 + return 0;
65482 +}
65483 +
65484 +int
65485 +gr_handle_follow_link(const struct inode *parent,
65486 + const struct inode *inode,
65487 + const struct dentry *dentry, const struct vfsmount *mnt)
65488 +{
65489 +#ifdef CONFIG_GRKERNSEC_LINK
65490 + const struct cred *cred = current_cred();
65491 +
65492 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65493 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65494 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65495 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65496 + return -EACCES;
65497 + }
65498 +#endif
65499 + return 0;
65500 +}
65501 +
65502 +int
65503 +gr_handle_hardlink(const struct dentry *dentry,
65504 + const struct vfsmount *mnt,
65505 + struct inode *inode, const int mode, const struct filename *to)
65506 +{
65507 +#ifdef CONFIG_GRKERNSEC_LINK
65508 + const struct cred *cred = current_cred();
65509 +
65510 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65511 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65512 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65513 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65514 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65515 + return -EPERM;
65516 + }
65517 +#endif
65518 + return 0;
65519 +}
65520 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65521 new file mode 100644
65522 index 0000000..7c06085
65523 --- /dev/null
65524 +++ b/grsecurity/grsec_log.c
65525 @@ -0,0 +1,326 @@
65526 +#include <linux/kernel.h>
65527 +#include <linux/sched.h>
65528 +#include <linux/file.h>
65529 +#include <linux/tty.h>
65530 +#include <linux/fs.h>
65531 +#include <linux/grinternal.h>
65532 +
65533 +#ifdef CONFIG_TREE_PREEMPT_RCU
65534 +#define DISABLE_PREEMPT() preempt_disable()
65535 +#define ENABLE_PREEMPT() preempt_enable()
65536 +#else
65537 +#define DISABLE_PREEMPT()
65538 +#define ENABLE_PREEMPT()
65539 +#endif
65540 +
65541 +#define BEGIN_LOCKS(x) \
65542 + DISABLE_PREEMPT(); \
65543 + rcu_read_lock(); \
65544 + read_lock(&tasklist_lock); \
65545 + read_lock(&grsec_exec_file_lock); \
65546 + if (x != GR_DO_AUDIT) \
65547 + spin_lock(&grsec_alert_lock); \
65548 + else \
65549 + spin_lock(&grsec_audit_lock)
65550 +
65551 +#define END_LOCKS(x) \
65552 + if (x != GR_DO_AUDIT) \
65553 + spin_unlock(&grsec_alert_lock); \
65554 + else \
65555 + spin_unlock(&grsec_audit_lock); \
65556 + read_unlock(&grsec_exec_file_lock); \
65557 + read_unlock(&tasklist_lock); \
65558 + rcu_read_unlock(); \
65559 + ENABLE_PREEMPT(); \
65560 + if (x == GR_DONT_AUDIT) \
65561 + gr_handle_alertkill(current)
65562 +
65563 +enum {
65564 + FLOODING,
65565 + NO_FLOODING
65566 +};
65567 +
65568 +extern char *gr_alert_log_fmt;
65569 +extern char *gr_audit_log_fmt;
65570 +extern char *gr_alert_log_buf;
65571 +extern char *gr_audit_log_buf;
65572 +
65573 +static int gr_log_start(int audit)
65574 +{
65575 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65576 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65577 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65578 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65579 + unsigned long curr_secs = get_seconds();
65580 +
65581 + if (audit == GR_DO_AUDIT)
65582 + goto set_fmt;
65583 +
65584 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65585 + grsec_alert_wtime = curr_secs;
65586 + grsec_alert_fyet = 0;
65587 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65588 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65589 + grsec_alert_fyet++;
65590 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65591 + grsec_alert_wtime = curr_secs;
65592 + grsec_alert_fyet++;
65593 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65594 + return FLOODING;
65595 + }
65596 + else return FLOODING;
65597 +
65598 +set_fmt:
65599 +#endif
65600 + memset(buf, 0, PAGE_SIZE);
65601 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65602 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65603 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65604 + } else if (current->signal->curr_ip) {
65605 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65606 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65607 + } else if (gr_acl_is_enabled()) {
65608 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65609 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65610 + } else {
65611 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65612 + strcpy(buf, fmt);
65613 + }
65614 +
65615 + return NO_FLOODING;
65616 +}
65617 +
65618 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65619 + __attribute__ ((format (printf, 2, 0)));
65620 +
65621 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65622 +{
65623 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65624 + unsigned int len = strlen(buf);
65625 +
65626 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65627 +
65628 + return;
65629 +}
65630 +
65631 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65632 + __attribute__ ((format (printf, 2, 3)));
65633 +
65634 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65635 +{
65636 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65637 + unsigned int len = strlen(buf);
65638 + va_list ap;
65639 +
65640 + va_start(ap, msg);
65641 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65642 + va_end(ap);
65643 +
65644 + return;
65645 +}
65646 +
65647 +static void gr_log_end(int audit, int append_default)
65648 +{
65649 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65650 + if (append_default) {
65651 + struct task_struct *task = current;
65652 + struct task_struct *parent = task->real_parent;
65653 + const struct cred *cred = __task_cred(task);
65654 + const struct cred *pcred = __task_cred(parent);
65655 + unsigned int len = strlen(buf);
65656 +
65657 + 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));
65658 + }
65659 +
65660 + printk("%s\n", buf);
65661 +
65662 + return;
65663 +}
65664 +
65665 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65666 +{
65667 + int logtype;
65668 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65669 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65670 + void *voidptr = NULL;
65671 + int num1 = 0, num2 = 0;
65672 + unsigned long ulong1 = 0, ulong2 = 0;
65673 + struct dentry *dentry = NULL;
65674 + struct vfsmount *mnt = NULL;
65675 + struct file *file = NULL;
65676 + struct task_struct *task = NULL;
65677 + const struct cred *cred, *pcred;
65678 + va_list ap;
65679 +
65680 + BEGIN_LOCKS(audit);
65681 + logtype = gr_log_start(audit);
65682 + if (logtype == FLOODING) {
65683 + END_LOCKS(audit);
65684 + return;
65685 + }
65686 + va_start(ap, argtypes);
65687 + switch (argtypes) {
65688 + case GR_TTYSNIFF:
65689 + task = va_arg(ap, struct task_struct *);
65690 + 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));
65691 + break;
65692 + case GR_SYSCTL_HIDDEN:
65693 + str1 = va_arg(ap, char *);
65694 + gr_log_middle_varargs(audit, msg, result, str1);
65695 + break;
65696 + case GR_RBAC:
65697 + dentry = va_arg(ap, struct dentry *);
65698 + mnt = va_arg(ap, struct vfsmount *);
65699 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65700 + break;
65701 + case GR_RBAC_STR:
65702 + dentry = va_arg(ap, struct dentry *);
65703 + mnt = va_arg(ap, struct vfsmount *);
65704 + str1 = va_arg(ap, char *);
65705 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65706 + break;
65707 + case GR_STR_RBAC:
65708 + str1 = va_arg(ap, char *);
65709 + dentry = va_arg(ap, struct dentry *);
65710 + mnt = va_arg(ap, struct vfsmount *);
65711 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65712 + break;
65713 + case GR_RBAC_MODE2:
65714 + dentry = va_arg(ap, struct dentry *);
65715 + mnt = va_arg(ap, struct vfsmount *);
65716 + str1 = va_arg(ap, char *);
65717 + str2 = va_arg(ap, char *);
65718 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65719 + break;
65720 + case GR_RBAC_MODE3:
65721 + dentry = va_arg(ap, struct dentry *);
65722 + mnt = va_arg(ap, struct vfsmount *);
65723 + str1 = va_arg(ap, char *);
65724 + str2 = va_arg(ap, char *);
65725 + str3 = va_arg(ap, char *);
65726 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65727 + break;
65728 + case GR_FILENAME:
65729 + dentry = va_arg(ap, struct dentry *);
65730 + mnt = va_arg(ap, struct vfsmount *);
65731 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65732 + break;
65733 + case GR_STR_FILENAME:
65734 + str1 = va_arg(ap, char *);
65735 + dentry = va_arg(ap, struct dentry *);
65736 + mnt = va_arg(ap, struct vfsmount *);
65737 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65738 + break;
65739 + case GR_FILENAME_STR:
65740 + dentry = va_arg(ap, struct dentry *);
65741 + mnt = va_arg(ap, struct vfsmount *);
65742 + str1 = va_arg(ap, char *);
65743 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65744 + break;
65745 + case GR_FILENAME_TWO_INT:
65746 + dentry = va_arg(ap, struct dentry *);
65747 + mnt = va_arg(ap, struct vfsmount *);
65748 + num1 = va_arg(ap, int);
65749 + num2 = va_arg(ap, int);
65750 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65751 + break;
65752 + case GR_FILENAME_TWO_INT_STR:
65753 + dentry = va_arg(ap, struct dentry *);
65754 + mnt = va_arg(ap, struct vfsmount *);
65755 + num1 = va_arg(ap, int);
65756 + num2 = va_arg(ap, int);
65757 + str1 = va_arg(ap, char *);
65758 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65759 + break;
65760 + case GR_TEXTREL:
65761 + file = va_arg(ap, struct file *);
65762 + ulong1 = va_arg(ap, unsigned long);
65763 + ulong2 = va_arg(ap, unsigned long);
65764 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65765 + break;
65766 + case GR_PTRACE:
65767 + task = va_arg(ap, struct task_struct *);
65768 + 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));
65769 + break;
65770 + case GR_RESOURCE:
65771 + task = va_arg(ap, struct task_struct *);
65772 + cred = __task_cred(task);
65773 + pcred = __task_cred(task->real_parent);
65774 + ulong1 = va_arg(ap, unsigned long);
65775 + str1 = va_arg(ap, char *);
65776 + ulong2 = va_arg(ap, unsigned long);
65777 + 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));
65778 + break;
65779 + case GR_CAP:
65780 + task = va_arg(ap, struct task_struct *);
65781 + cred = __task_cred(task);
65782 + pcred = __task_cred(task->real_parent);
65783 + str1 = va_arg(ap, char *);
65784 + 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));
65785 + break;
65786 + case GR_SIG:
65787 + str1 = va_arg(ap, char *);
65788 + voidptr = va_arg(ap, void *);
65789 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65790 + break;
65791 + case GR_SIG2:
65792 + task = va_arg(ap, struct task_struct *);
65793 + cred = __task_cred(task);
65794 + pcred = __task_cred(task->real_parent);
65795 + num1 = va_arg(ap, int);
65796 + 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));
65797 + break;
65798 + case GR_CRASH1:
65799 + task = va_arg(ap, struct task_struct *);
65800 + cred = __task_cred(task);
65801 + pcred = __task_cred(task->real_parent);
65802 + ulong1 = va_arg(ap, unsigned long);
65803 + 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);
65804 + break;
65805 + case GR_CRASH2:
65806 + task = va_arg(ap, struct task_struct *);
65807 + cred = __task_cred(task);
65808 + pcred = __task_cred(task->real_parent);
65809 + ulong1 = va_arg(ap, unsigned long);
65810 + 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);
65811 + break;
65812 + case GR_RWXMAP:
65813 + file = va_arg(ap, struct file *);
65814 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65815 + break;
65816 + case GR_PSACCT:
65817 + {
65818 + unsigned int wday, cday;
65819 + __u8 whr, chr;
65820 + __u8 wmin, cmin;
65821 + __u8 wsec, csec;
65822 + char cur_tty[64] = { 0 };
65823 + char parent_tty[64] = { 0 };
65824 +
65825 + task = va_arg(ap, struct task_struct *);
65826 + wday = va_arg(ap, unsigned int);
65827 + cday = va_arg(ap, unsigned int);
65828 + whr = va_arg(ap, int);
65829 + chr = va_arg(ap, int);
65830 + wmin = va_arg(ap, int);
65831 + cmin = va_arg(ap, int);
65832 + wsec = va_arg(ap, int);
65833 + csec = va_arg(ap, int);
65834 + ulong1 = va_arg(ap, unsigned long);
65835 + cred = __task_cred(task);
65836 + pcred = __task_cred(task->real_parent);
65837 +
65838 + 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));
65839 + }
65840 + break;
65841 + default:
65842 + gr_log_middle(audit, msg, ap);
65843 + }
65844 + va_end(ap);
65845 + // these don't need DEFAULTSECARGS printed on the end
65846 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65847 + gr_log_end(audit, 0);
65848 + else
65849 + gr_log_end(audit, 1);
65850 + END_LOCKS(audit);
65851 +}
65852 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65853 new file mode 100644
65854 index 0000000..f536303
65855 --- /dev/null
65856 +++ b/grsecurity/grsec_mem.c
65857 @@ -0,0 +1,40 @@
65858 +#include <linux/kernel.h>
65859 +#include <linux/sched.h>
65860 +#include <linux/mm.h>
65861 +#include <linux/mman.h>
65862 +#include <linux/grinternal.h>
65863 +
65864 +void
65865 +gr_handle_ioperm(void)
65866 +{
65867 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65868 + return;
65869 +}
65870 +
65871 +void
65872 +gr_handle_iopl(void)
65873 +{
65874 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65875 + return;
65876 +}
65877 +
65878 +void
65879 +gr_handle_mem_readwrite(u64 from, u64 to)
65880 +{
65881 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65882 + return;
65883 +}
65884 +
65885 +void
65886 +gr_handle_vm86(void)
65887 +{
65888 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65889 + return;
65890 +}
65891 +
65892 +void
65893 +gr_log_badprocpid(const char *entry)
65894 +{
65895 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65896 + return;
65897 +}
65898 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65899 new file mode 100644
65900 index 0000000..2131422
65901 --- /dev/null
65902 +++ b/grsecurity/grsec_mount.c
65903 @@ -0,0 +1,62 @@
65904 +#include <linux/kernel.h>
65905 +#include <linux/sched.h>
65906 +#include <linux/mount.h>
65907 +#include <linux/grsecurity.h>
65908 +#include <linux/grinternal.h>
65909 +
65910 +void
65911 +gr_log_remount(const char *devname, const int retval)
65912 +{
65913 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65914 + if (grsec_enable_mount && (retval >= 0))
65915 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65916 +#endif
65917 + return;
65918 +}
65919 +
65920 +void
65921 +gr_log_unmount(const char *devname, const int retval)
65922 +{
65923 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65924 + if (grsec_enable_mount && (retval >= 0))
65925 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65926 +#endif
65927 + return;
65928 +}
65929 +
65930 +void
65931 +gr_log_mount(const char *from, const char *to, const int retval)
65932 +{
65933 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65934 + if (grsec_enable_mount && (retval >= 0))
65935 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65936 +#endif
65937 + return;
65938 +}
65939 +
65940 +int
65941 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65942 +{
65943 +#ifdef CONFIG_GRKERNSEC_ROFS
65944 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65945 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65946 + return -EPERM;
65947 + } else
65948 + return 0;
65949 +#endif
65950 + return 0;
65951 +}
65952 +
65953 +int
65954 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65955 +{
65956 +#ifdef CONFIG_GRKERNSEC_ROFS
65957 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65958 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65959 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65960 + return -EPERM;
65961 + } else
65962 + return 0;
65963 +#endif
65964 + return 0;
65965 +}
65966 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65967 new file mode 100644
65968 index 0000000..a3b12a0
65969 --- /dev/null
65970 +++ b/grsecurity/grsec_pax.c
65971 @@ -0,0 +1,36 @@
65972 +#include <linux/kernel.h>
65973 +#include <linux/sched.h>
65974 +#include <linux/mm.h>
65975 +#include <linux/file.h>
65976 +#include <linux/grinternal.h>
65977 +#include <linux/grsecurity.h>
65978 +
65979 +void
65980 +gr_log_textrel(struct vm_area_struct * vma)
65981 +{
65982 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65983 + if (grsec_enable_audit_textrel)
65984 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65985 +#endif
65986 + return;
65987 +}
65988 +
65989 +void
65990 +gr_log_rwxmmap(struct file *file)
65991 +{
65992 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65993 + if (grsec_enable_log_rwxmaps)
65994 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65995 +#endif
65996 + return;
65997 +}
65998 +
65999 +void
66000 +gr_log_rwxmprotect(struct file *file)
66001 +{
66002 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66003 + if (grsec_enable_log_rwxmaps)
66004 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
66005 +#endif
66006 + return;
66007 +}
66008 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
66009 new file mode 100644
66010 index 0000000..f7f29aa
66011 --- /dev/null
66012 +++ b/grsecurity/grsec_ptrace.c
66013 @@ -0,0 +1,30 @@
66014 +#include <linux/kernel.h>
66015 +#include <linux/sched.h>
66016 +#include <linux/grinternal.h>
66017 +#include <linux/security.h>
66018 +
66019 +void
66020 +gr_audit_ptrace(struct task_struct *task)
66021 +{
66022 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66023 + if (grsec_enable_audit_ptrace)
66024 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
66025 +#endif
66026 + return;
66027 +}
66028 +
66029 +int
66030 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
66031 +{
66032 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66033 + const struct dentry *dentry = file->f_path.dentry;
66034 + const struct vfsmount *mnt = file->f_path.mnt;
66035 +
66036 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
66037 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
66038 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
66039 + return -EACCES;
66040 + }
66041 +#endif
66042 + return 0;
66043 +}
66044 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
66045 new file mode 100644
66046 index 0000000..4e29cc7
66047 --- /dev/null
66048 +++ b/grsecurity/grsec_sig.c
66049 @@ -0,0 +1,246 @@
66050 +#include <linux/kernel.h>
66051 +#include <linux/sched.h>
66052 +#include <linux/fs.h>
66053 +#include <linux/delay.h>
66054 +#include <linux/grsecurity.h>
66055 +#include <linux/grinternal.h>
66056 +#include <linux/hardirq.h>
66057 +
66058 +char *signames[] = {
66059 + [SIGSEGV] = "Segmentation fault",
66060 + [SIGILL] = "Illegal instruction",
66061 + [SIGABRT] = "Abort",
66062 + [SIGBUS] = "Invalid alignment/Bus error"
66063 +};
66064 +
66065 +void
66066 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
66067 +{
66068 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66069 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
66070 + (sig == SIGABRT) || (sig == SIGBUS))) {
66071 + if (task_pid_nr(t) == task_pid_nr(current)) {
66072 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
66073 + } else {
66074 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
66075 + }
66076 + }
66077 +#endif
66078 + return;
66079 +}
66080 +
66081 +int
66082 +gr_handle_signal(const struct task_struct *p, const int sig)
66083 +{
66084 +#ifdef CONFIG_GRKERNSEC
66085 + /* ignore the 0 signal for protected task checks */
66086 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
66087 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
66088 + return -EPERM;
66089 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
66090 + return -EPERM;
66091 + }
66092 +#endif
66093 + return 0;
66094 +}
66095 +
66096 +#ifdef CONFIG_GRKERNSEC
66097 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66098 +
66099 +int gr_fake_force_sig(int sig, struct task_struct *t)
66100 +{
66101 + unsigned long int flags;
66102 + int ret, blocked, ignored;
66103 + struct k_sigaction *action;
66104 +
66105 + spin_lock_irqsave(&t->sighand->siglock, flags);
66106 + action = &t->sighand->action[sig-1];
66107 + ignored = action->sa.sa_handler == SIG_IGN;
66108 + blocked = sigismember(&t->blocked, sig);
66109 + if (blocked || ignored) {
66110 + action->sa.sa_handler = SIG_DFL;
66111 + if (blocked) {
66112 + sigdelset(&t->blocked, sig);
66113 + recalc_sigpending_and_wake(t);
66114 + }
66115 + }
66116 + if (action->sa.sa_handler == SIG_DFL)
66117 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66118 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66119 +
66120 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66121 +
66122 + return ret;
66123 +}
66124 +#endif
66125 +
66126 +#ifdef CONFIG_GRKERNSEC_BRUTE
66127 +#define GR_USER_BAN_TIME (15 * 60)
66128 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66129 +
66130 +static int __get_dumpable(unsigned long mm_flags)
66131 +{
66132 + int ret;
66133 +
66134 + ret = mm_flags & MMF_DUMPABLE_MASK;
66135 + return (ret >= 2) ? 2 : ret;
66136 +}
66137 +#endif
66138 +
66139 +void gr_handle_brute_attach(unsigned long mm_flags)
66140 +{
66141 +#ifdef CONFIG_GRKERNSEC_BRUTE
66142 + struct task_struct *p = current;
66143 + kuid_t uid = GLOBAL_ROOT_UID;
66144 + int daemon = 0;
66145 +
66146 + if (!grsec_enable_brute)
66147 + return;
66148 +
66149 + rcu_read_lock();
66150 + read_lock(&tasklist_lock);
66151 + read_lock(&grsec_exec_file_lock);
66152 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
66153 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66154 + p->real_parent->brute = 1;
66155 + daemon = 1;
66156 + } else {
66157 + const struct cred *cred = __task_cred(p), *cred2;
66158 + struct task_struct *tsk, *tsk2;
66159 +
66160 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66161 + struct user_struct *user;
66162 +
66163 + uid = cred->uid;
66164 +
66165 + /* this is put upon execution past expiration */
66166 + user = find_user(uid);
66167 + if (user == NULL)
66168 + goto unlock;
66169 + user->suid_banned = 1;
66170 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
66171 + if (user->suid_ban_expires == ~0UL)
66172 + user->suid_ban_expires--;
66173 +
66174 + /* only kill other threads of the same binary, from the same user */
66175 + do_each_thread(tsk2, tsk) {
66176 + cred2 = __task_cred(tsk);
66177 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
66178 + gr_fake_force_sig(SIGKILL, tsk);
66179 + } while_each_thread(tsk2, tsk);
66180 + }
66181 + }
66182 +unlock:
66183 + read_unlock(&grsec_exec_file_lock);
66184 + read_unlock(&tasklist_lock);
66185 + rcu_read_unlock();
66186 +
66187 + if (gr_is_global_nonroot(uid))
66188 + gr_log_fs_int2(GR_DONT_AUDIT, GR_BRUTE_SUID_MSG, p->exec_file->f_path.dentry, p->exec_file->f_path.mnt, GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66189 + else if (daemon)
66190 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66191 +
66192 +#endif
66193 + return;
66194 +}
66195 +
66196 +void gr_handle_brute_check(void)
66197 +{
66198 +#ifdef CONFIG_GRKERNSEC_BRUTE
66199 + struct task_struct *p = current;
66200 +
66201 + if (unlikely(p->brute)) {
66202 + if (!grsec_enable_brute)
66203 + p->brute = 0;
66204 + else if (time_before(get_seconds(), p->brute_expires))
66205 + msleep(30 * 1000);
66206 + }
66207 +#endif
66208 + return;
66209 +}
66210 +
66211 +void gr_handle_kernel_exploit(void)
66212 +{
66213 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66214 + const struct cred *cred;
66215 + struct task_struct *tsk, *tsk2;
66216 + struct user_struct *user;
66217 + kuid_t uid;
66218 +
66219 + if (in_irq() || in_serving_softirq() || in_nmi())
66220 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66221 +
66222 + uid = current_uid();
66223 +
66224 + if (gr_is_global_root(uid))
66225 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66226 + else {
66227 + /* kill all the processes of this user, hold a reference
66228 + to their creds struct, and prevent them from creating
66229 + another process until system reset
66230 + */
66231 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66232 + GR_GLOBAL_UID(uid));
66233 + /* we intentionally leak this ref */
66234 + user = get_uid(current->cred->user);
66235 + if (user)
66236 + user->kernel_banned = 1;
66237 +
66238 + /* kill all processes of this user */
66239 + read_lock(&tasklist_lock);
66240 + do_each_thread(tsk2, tsk) {
66241 + cred = __task_cred(tsk);
66242 + if (uid_eq(cred->uid, uid))
66243 + gr_fake_force_sig(SIGKILL, tsk);
66244 + } while_each_thread(tsk2, tsk);
66245 + read_unlock(&tasklist_lock);
66246 + }
66247 +#endif
66248 +}
66249 +
66250 +#ifdef CONFIG_GRKERNSEC_BRUTE
66251 +static bool suid_ban_expired(struct user_struct *user)
66252 +{
66253 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
66254 + user->suid_banned = 0;
66255 + user->suid_ban_expires = 0;
66256 + free_uid(user);
66257 + return true;
66258 + }
66259 +
66260 + return false;
66261 +}
66262 +#endif
66263 +
66264 +int gr_process_kernel_exec_ban(void)
66265 +{
66266 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66267 + if (unlikely(current->cred->user->kernel_banned))
66268 + return -EPERM;
66269 +#endif
66270 + return 0;
66271 +}
66272 +
66273 +int gr_process_kernel_setuid_ban(struct user_struct *user)
66274 +{
66275 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66276 + if (unlikely(user->kernel_banned))
66277 + gr_fake_force_sig(SIGKILL, current);
66278 +#endif
66279 + return 0;
66280 +}
66281 +
66282 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
66283 +{
66284 +#ifdef CONFIG_GRKERNSEC_BRUTE
66285 + struct user_struct *user = current->cred->user;
66286 + if (unlikely(user->suid_banned)) {
66287 + if (suid_ban_expired(user))
66288 + return 0;
66289 + /* disallow execution of suid binaries only */
66290 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
66291 + return -EPERM;
66292 + }
66293 +#endif
66294 + return 0;
66295 +}
66296 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66297 new file mode 100644
66298 index 0000000..4030d57
66299 --- /dev/null
66300 +++ b/grsecurity/grsec_sock.c
66301 @@ -0,0 +1,244 @@
66302 +#include <linux/kernel.h>
66303 +#include <linux/module.h>
66304 +#include <linux/sched.h>
66305 +#include <linux/file.h>
66306 +#include <linux/net.h>
66307 +#include <linux/in.h>
66308 +#include <linux/ip.h>
66309 +#include <net/sock.h>
66310 +#include <net/inet_sock.h>
66311 +#include <linux/grsecurity.h>
66312 +#include <linux/grinternal.h>
66313 +#include <linux/gracl.h>
66314 +
66315 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66316 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66317 +
66318 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66319 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66320 +
66321 +#ifdef CONFIG_UNIX_MODULE
66322 +EXPORT_SYMBOL(gr_acl_handle_unix);
66323 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66324 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66325 +EXPORT_SYMBOL(gr_handle_create);
66326 +#endif
66327 +
66328 +#ifdef CONFIG_GRKERNSEC
66329 +#define gr_conn_table_size 32749
66330 +struct conn_table_entry {
66331 + struct conn_table_entry *next;
66332 + struct signal_struct *sig;
66333 +};
66334 +
66335 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66336 +DEFINE_SPINLOCK(gr_conn_table_lock);
66337 +
66338 +extern const char * gr_socktype_to_name(unsigned char type);
66339 +extern const char * gr_proto_to_name(unsigned char proto);
66340 +extern const char * gr_sockfamily_to_name(unsigned char family);
66341 +
66342 +static __inline__ int
66343 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66344 +{
66345 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66346 +}
66347 +
66348 +static __inline__ int
66349 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66350 + __u16 sport, __u16 dport)
66351 +{
66352 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66353 + sig->gr_sport == sport && sig->gr_dport == dport))
66354 + return 1;
66355 + else
66356 + return 0;
66357 +}
66358 +
66359 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66360 +{
66361 + struct conn_table_entry **match;
66362 + unsigned int index;
66363 +
66364 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66365 + sig->gr_sport, sig->gr_dport,
66366 + gr_conn_table_size);
66367 +
66368 + newent->sig = sig;
66369 +
66370 + match = &gr_conn_table[index];
66371 + newent->next = *match;
66372 + *match = newent;
66373 +
66374 + return;
66375 +}
66376 +
66377 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66378 +{
66379 + struct conn_table_entry *match, *last = NULL;
66380 + unsigned int index;
66381 +
66382 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66383 + sig->gr_sport, sig->gr_dport,
66384 + gr_conn_table_size);
66385 +
66386 + match = gr_conn_table[index];
66387 + while (match && !conn_match(match->sig,
66388 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66389 + sig->gr_dport)) {
66390 + last = match;
66391 + match = match->next;
66392 + }
66393 +
66394 + if (match) {
66395 + if (last)
66396 + last->next = match->next;
66397 + else
66398 + gr_conn_table[index] = NULL;
66399 + kfree(match);
66400 + }
66401 +
66402 + return;
66403 +}
66404 +
66405 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66406 + __u16 sport, __u16 dport)
66407 +{
66408 + struct conn_table_entry *match;
66409 + unsigned int index;
66410 +
66411 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66412 +
66413 + match = gr_conn_table[index];
66414 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66415 + match = match->next;
66416 +
66417 + if (match)
66418 + return match->sig;
66419 + else
66420 + return NULL;
66421 +}
66422 +
66423 +#endif
66424 +
66425 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66426 +{
66427 +#ifdef CONFIG_GRKERNSEC
66428 + struct signal_struct *sig = task->signal;
66429 + struct conn_table_entry *newent;
66430 +
66431 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66432 + if (newent == NULL)
66433 + return;
66434 + /* no bh lock needed since we are called with bh disabled */
66435 + spin_lock(&gr_conn_table_lock);
66436 + gr_del_task_from_ip_table_nolock(sig);
66437 + sig->gr_saddr = inet->inet_rcv_saddr;
66438 + sig->gr_daddr = inet->inet_daddr;
66439 + sig->gr_sport = inet->inet_sport;
66440 + sig->gr_dport = inet->inet_dport;
66441 + gr_add_to_task_ip_table_nolock(sig, newent);
66442 + spin_unlock(&gr_conn_table_lock);
66443 +#endif
66444 + return;
66445 +}
66446 +
66447 +void gr_del_task_from_ip_table(struct task_struct *task)
66448 +{
66449 +#ifdef CONFIG_GRKERNSEC
66450 + spin_lock_bh(&gr_conn_table_lock);
66451 + gr_del_task_from_ip_table_nolock(task->signal);
66452 + spin_unlock_bh(&gr_conn_table_lock);
66453 +#endif
66454 + return;
66455 +}
66456 +
66457 +void
66458 +gr_attach_curr_ip(const struct sock *sk)
66459 +{
66460 +#ifdef CONFIG_GRKERNSEC
66461 + struct signal_struct *p, *set;
66462 + const struct inet_sock *inet = inet_sk(sk);
66463 +
66464 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66465 + return;
66466 +
66467 + set = current->signal;
66468 +
66469 + spin_lock_bh(&gr_conn_table_lock);
66470 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66471 + inet->inet_dport, inet->inet_sport);
66472 + if (unlikely(p != NULL)) {
66473 + set->curr_ip = p->curr_ip;
66474 + set->used_accept = 1;
66475 + gr_del_task_from_ip_table_nolock(p);
66476 + spin_unlock_bh(&gr_conn_table_lock);
66477 + return;
66478 + }
66479 + spin_unlock_bh(&gr_conn_table_lock);
66480 +
66481 + set->curr_ip = inet->inet_daddr;
66482 + set->used_accept = 1;
66483 +#endif
66484 + return;
66485 +}
66486 +
66487 +int
66488 +gr_handle_sock_all(const int family, const int type, const int protocol)
66489 +{
66490 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66491 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66492 + (family != AF_UNIX)) {
66493 + if (family == AF_INET)
66494 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66495 + else
66496 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66497 + return -EACCES;
66498 + }
66499 +#endif
66500 + return 0;
66501 +}
66502 +
66503 +int
66504 +gr_handle_sock_server(const struct sockaddr *sck)
66505 +{
66506 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66507 + if (grsec_enable_socket_server &&
66508 + in_group_p(grsec_socket_server_gid) &&
66509 + sck && (sck->sa_family != AF_UNIX) &&
66510 + (sck->sa_family != AF_LOCAL)) {
66511 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66512 + return -EACCES;
66513 + }
66514 +#endif
66515 + return 0;
66516 +}
66517 +
66518 +int
66519 +gr_handle_sock_server_other(const struct sock *sck)
66520 +{
66521 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66522 + if (grsec_enable_socket_server &&
66523 + in_group_p(grsec_socket_server_gid) &&
66524 + sck && (sck->sk_family != AF_UNIX) &&
66525 + (sck->sk_family != AF_LOCAL)) {
66526 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66527 + return -EACCES;
66528 + }
66529 +#endif
66530 + return 0;
66531 +}
66532 +
66533 +int
66534 +gr_handle_sock_client(const struct sockaddr *sck)
66535 +{
66536 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66537 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66538 + sck && (sck->sa_family != AF_UNIX) &&
66539 + (sck->sa_family != AF_LOCAL)) {
66540 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66541 + return -EACCES;
66542 + }
66543 +#endif
66544 + return 0;
66545 +}
66546 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66547 new file mode 100644
66548 index 0000000..f55ef0f
66549 --- /dev/null
66550 +++ b/grsecurity/grsec_sysctl.c
66551 @@ -0,0 +1,469 @@
66552 +#include <linux/kernel.h>
66553 +#include <linux/sched.h>
66554 +#include <linux/sysctl.h>
66555 +#include <linux/grsecurity.h>
66556 +#include <linux/grinternal.h>
66557 +
66558 +int
66559 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66560 +{
66561 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66562 + if (dirname == NULL || name == NULL)
66563 + return 0;
66564 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66565 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66566 + return -EACCES;
66567 + }
66568 +#endif
66569 + return 0;
66570 +}
66571 +
66572 +#ifdef CONFIG_GRKERNSEC_ROFS
66573 +static int __maybe_unused one = 1;
66574 +#endif
66575 +
66576 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66577 +struct ctl_table grsecurity_table[] = {
66578 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66579 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66580 +#ifdef CONFIG_GRKERNSEC_IO
66581 + {
66582 + .procname = "disable_priv_io",
66583 + .data = &grsec_disable_privio,
66584 + .maxlen = sizeof(int),
66585 + .mode = 0600,
66586 + .proc_handler = &proc_dointvec,
66587 + },
66588 +#endif
66589 +#endif
66590 +#ifdef CONFIG_GRKERNSEC_LINK
66591 + {
66592 + .procname = "linking_restrictions",
66593 + .data = &grsec_enable_link,
66594 + .maxlen = sizeof(int),
66595 + .mode = 0600,
66596 + .proc_handler = &proc_dointvec,
66597 + },
66598 +#endif
66599 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66600 + {
66601 + .procname = "enforce_symlinksifowner",
66602 + .data = &grsec_enable_symlinkown,
66603 + .maxlen = sizeof(int),
66604 + .mode = 0600,
66605 + .proc_handler = &proc_dointvec,
66606 + },
66607 + {
66608 + .procname = "symlinkown_gid",
66609 + .data = &grsec_symlinkown_gid,
66610 + .maxlen = sizeof(int),
66611 + .mode = 0600,
66612 + .proc_handler = &proc_dointvec,
66613 + },
66614 +#endif
66615 +#ifdef CONFIG_GRKERNSEC_BRUTE
66616 + {
66617 + .procname = "deter_bruteforce",
66618 + .data = &grsec_enable_brute,
66619 + .maxlen = sizeof(int),
66620 + .mode = 0600,
66621 + .proc_handler = &proc_dointvec,
66622 + },
66623 +#endif
66624 +#ifdef CONFIG_GRKERNSEC_FIFO
66625 + {
66626 + .procname = "fifo_restrictions",
66627 + .data = &grsec_enable_fifo,
66628 + .maxlen = sizeof(int),
66629 + .mode = 0600,
66630 + .proc_handler = &proc_dointvec,
66631 + },
66632 +#endif
66633 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66634 + {
66635 + .procname = "ptrace_readexec",
66636 + .data = &grsec_enable_ptrace_readexec,
66637 + .maxlen = sizeof(int),
66638 + .mode = 0600,
66639 + .proc_handler = &proc_dointvec,
66640 + },
66641 +#endif
66642 +#ifdef CONFIG_GRKERNSEC_SETXID
66643 + {
66644 + .procname = "consistent_setxid",
66645 + .data = &grsec_enable_setxid,
66646 + .maxlen = sizeof(int),
66647 + .mode = 0600,
66648 + .proc_handler = &proc_dointvec,
66649 + },
66650 +#endif
66651 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66652 + {
66653 + .procname = "ip_blackhole",
66654 + .data = &grsec_enable_blackhole,
66655 + .maxlen = sizeof(int),
66656 + .mode = 0600,
66657 + .proc_handler = &proc_dointvec,
66658 + },
66659 + {
66660 + .procname = "lastack_retries",
66661 + .data = &grsec_lastack_retries,
66662 + .maxlen = sizeof(int),
66663 + .mode = 0600,
66664 + .proc_handler = &proc_dointvec,
66665 + },
66666 +#endif
66667 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66668 + {
66669 + .procname = "exec_logging",
66670 + .data = &grsec_enable_execlog,
66671 + .maxlen = sizeof(int),
66672 + .mode = 0600,
66673 + .proc_handler = &proc_dointvec,
66674 + },
66675 +#endif
66676 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66677 + {
66678 + .procname = "rwxmap_logging",
66679 + .data = &grsec_enable_log_rwxmaps,
66680 + .maxlen = sizeof(int),
66681 + .mode = 0600,
66682 + .proc_handler = &proc_dointvec,
66683 + },
66684 +#endif
66685 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66686 + {
66687 + .procname = "signal_logging",
66688 + .data = &grsec_enable_signal,
66689 + .maxlen = sizeof(int),
66690 + .mode = 0600,
66691 + .proc_handler = &proc_dointvec,
66692 + },
66693 +#endif
66694 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66695 + {
66696 + .procname = "forkfail_logging",
66697 + .data = &grsec_enable_forkfail,
66698 + .maxlen = sizeof(int),
66699 + .mode = 0600,
66700 + .proc_handler = &proc_dointvec,
66701 + },
66702 +#endif
66703 +#ifdef CONFIG_GRKERNSEC_TIME
66704 + {
66705 + .procname = "timechange_logging",
66706 + .data = &grsec_enable_time,
66707 + .maxlen = sizeof(int),
66708 + .mode = 0600,
66709 + .proc_handler = &proc_dointvec,
66710 + },
66711 +#endif
66712 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66713 + {
66714 + .procname = "chroot_deny_shmat",
66715 + .data = &grsec_enable_chroot_shmat,
66716 + .maxlen = sizeof(int),
66717 + .mode = 0600,
66718 + .proc_handler = &proc_dointvec,
66719 + },
66720 +#endif
66721 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66722 + {
66723 + .procname = "chroot_deny_unix",
66724 + .data = &grsec_enable_chroot_unix,
66725 + .maxlen = sizeof(int),
66726 + .mode = 0600,
66727 + .proc_handler = &proc_dointvec,
66728 + },
66729 +#endif
66730 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66731 + {
66732 + .procname = "chroot_deny_mount",
66733 + .data = &grsec_enable_chroot_mount,
66734 + .maxlen = sizeof(int),
66735 + .mode = 0600,
66736 + .proc_handler = &proc_dointvec,
66737 + },
66738 +#endif
66739 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66740 + {
66741 + .procname = "chroot_deny_fchdir",
66742 + .data = &grsec_enable_chroot_fchdir,
66743 + .maxlen = sizeof(int),
66744 + .mode = 0600,
66745 + .proc_handler = &proc_dointvec,
66746 + },
66747 +#endif
66748 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66749 + {
66750 + .procname = "chroot_deny_chroot",
66751 + .data = &grsec_enable_chroot_double,
66752 + .maxlen = sizeof(int),
66753 + .mode = 0600,
66754 + .proc_handler = &proc_dointvec,
66755 + },
66756 +#endif
66757 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66758 + {
66759 + .procname = "chroot_deny_pivot",
66760 + .data = &grsec_enable_chroot_pivot,
66761 + .maxlen = sizeof(int),
66762 + .mode = 0600,
66763 + .proc_handler = &proc_dointvec,
66764 + },
66765 +#endif
66766 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66767 + {
66768 + .procname = "chroot_enforce_chdir",
66769 + .data = &grsec_enable_chroot_chdir,
66770 + .maxlen = sizeof(int),
66771 + .mode = 0600,
66772 + .proc_handler = &proc_dointvec,
66773 + },
66774 +#endif
66775 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66776 + {
66777 + .procname = "chroot_deny_chmod",
66778 + .data = &grsec_enable_chroot_chmod,
66779 + .maxlen = sizeof(int),
66780 + .mode = 0600,
66781 + .proc_handler = &proc_dointvec,
66782 + },
66783 +#endif
66784 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66785 + {
66786 + .procname = "chroot_deny_mknod",
66787 + .data = &grsec_enable_chroot_mknod,
66788 + .maxlen = sizeof(int),
66789 + .mode = 0600,
66790 + .proc_handler = &proc_dointvec,
66791 + },
66792 +#endif
66793 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66794 + {
66795 + .procname = "chroot_restrict_nice",
66796 + .data = &grsec_enable_chroot_nice,
66797 + .maxlen = sizeof(int),
66798 + .mode = 0600,
66799 + .proc_handler = &proc_dointvec,
66800 + },
66801 +#endif
66802 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66803 + {
66804 + .procname = "chroot_execlog",
66805 + .data = &grsec_enable_chroot_execlog,
66806 + .maxlen = sizeof(int),
66807 + .mode = 0600,
66808 + .proc_handler = &proc_dointvec,
66809 + },
66810 +#endif
66811 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66812 + {
66813 + .procname = "chroot_caps",
66814 + .data = &grsec_enable_chroot_caps,
66815 + .maxlen = sizeof(int),
66816 + .mode = 0600,
66817 + .proc_handler = &proc_dointvec,
66818 + },
66819 +#endif
66820 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66821 + {
66822 + .procname = "chroot_deny_sysctl",
66823 + .data = &grsec_enable_chroot_sysctl,
66824 + .maxlen = sizeof(int),
66825 + .mode = 0600,
66826 + .proc_handler = &proc_dointvec,
66827 + },
66828 +#endif
66829 +#ifdef CONFIG_GRKERNSEC_TPE
66830 + {
66831 + .procname = "tpe",
66832 + .data = &grsec_enable_tpe,
66833 + .maxlen = sizeof(int),
66834 + .mode = 0600,
66835 + .proc_handler = &proc_dointvec,
66836 + },
66837 + {
66838 + .procname = "tpe_gid",
66839 + .data = &grsec_tpe_gid,
66840 + .maxlen = sizeof(int),
66841 + .mode = 0600,
66842 + .proc_handler = &proc_dointvec,
66843 + },
66844 +#endif
66845 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66846 + {
66847 + .procname = "tpe_invert",
66848 + .data = &grsec_enable_tpe_invert,
66849 + .maxlen = sizeof(int),
66850 + .mode = 0600,
66851 + .proc_handler = &proc_dointvec,
66852 + },
66853 +#endif
66854 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66855 + {
66856 + .procname = "tpe_restrict_all",
66857 + .data = &grsec_enable_tpe_all,
66858 + .maxlen = sizeof(int),
66859 + .mode = 0600,
66860 + .proc_handler = &proc_dointvec,
66861 + },
66862 +#endif
66863 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66864 + {
66865 + .procname = "socket_all",
66866 + .data = &grsec_enable_socket_all,
66867 + .maxlen = sizeof(int),
66868 + .mode = 0600,
66869 + .proc_handler = &proc_dointvec,
66870 + },
66871 + {
66872 + .procname = "socket_all_gid",
66873 + .data = &grsec_socket_all_gid,
66874 + .maxlen = sizeof(int),
66875 + .mode = 0600,
66876 + .proc_handler = &proc_dointvec,
66877 + },
66878 +#endif
66879 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66880 + {
66881 + .procname = "socket_client",
66882 + .data = &grsec_enable_socket_client,
66883 + .maxlen = sizeof(int),
66884 + .mode = 0600,
66885 + .proc_handler = &proc_dointvec,
66886 + },
66887 + {
66888 + .procname = "socket_client_gid",
66889 + .data = &grsec_socket_client_gid,
66890 + .maxlen = sizeof(int),
66891 + .mode = 0600,
66892 + .proc_handler = &proc_dointvec,
66893 + },
66894 +#endif
66895 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66896 + {
66897 + .procname = "socket_server",
66898 + .data = &grsec_enable_socket_server,
66899 + .maxlen = sizeof(int),
66900 + .mode = 0600,
66901 + .proc_handler = &proc_dointvec,
66902 + },
66903 + {
66904 + .procname = "socket_server_gid",
66905 + .data = &grsec_socket_server_gid,
66906 + .maxlen = sizeof(int),
66907 + .mode = 0600,
66908 + .proc_handler = &proc_dointvec,
66909 + },
66910 +#endif
66911 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66912 + {
66913 + .procname = "audit_group",
66914 + .data = &grsec_enable_group,
66915 + .maxlen = sizeof(int),
66916 + .mode = 0600,
66917 + .proc_handler = &proc_dointvec,
66918 + },
66919 + {
66920 + .procname = "audit_gid",
66921 + .data = &grsec_audit_gid,
66922 + .maxlen = sizeof(int),
66923 + .mode = 0600,
66924 + .proc_handler = &proc_dointvec,
66925 + },
66926 +#endif
66927 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66928 + {
66929 + .procname = "audit_chdir",
66930 + .data = &grsec_enable_chdir,
66931 + .maxlen = sizeof(int),
66932 + .mode = 0600,
66933 + .proc_handler = &proc_dointvec,
66934 + },
66935 +#endif
66936 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66937 + {
66938 + .procname = "audit_mount",
66939 + .data = &grsec_enable_mount,
66940 + .maxlen = sizeof(int),
66941 + .mode = 0600,
66942 + .proc_handler = &proc_dointvec,
66943 + },
66944 +#endif
66945 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66946 + {
66947 + .procname = "audit_textrel",
66948 + .data = &grsec_enable_audit_textrel,
66949 + .maxlen = sizeof(int),
66950 + .mode = 0600,
66951 + .proc_handler = &proc_dointvec,
66952 + },
66953 +#endif
66954 +#ifdef CONFIG_GRKERNSEC_DMESG
66955 + {
66956 + .procname = "dmesg",
66957 + .data = &grsec_enable_dmesg,
66958 + .maxlen = sizeof(int),
66959 + .mode = 0600,
66960 + .proc_handler = &proc_dointvec,
66961 + },
66962 +#endif
66963 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66964 + {
66965 + .procname = "chroot_findtask",
66966 + .data = &grsec_enable_chroot_findtask,
66967 + .maxlen = sizeof(int),
66968 + .mode = 0600,
66969 + .proc_handler = &proc_dointvec,
66970 + },
66971 +#endif
66972 +#ifdef CONFIG_GRKERNSEC_RESLOG
66973 + {
66974 + .procname = "resource_logging",
66975 + .data = &grsec_resource_logging,
66976 + .maxlen = sizeof(int),
66977 + .mode = 0600,
66978 + .proc_handler = &proc_dointvec,
66979 + },
66980 +#endif
66981 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66982 + {
66983 + .procname = "audit_ptrace",
66984 + .data = &grsec_enable_audit_ptrace,
66985 + .maxlen = sizeof(int),
66986 + .mode = 0600,
66987 + .proc_handler = &proc_dointvec,
66988 + },
66989 +#endif
66990 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66991 + {
66992 + .procname = "harden_ptrace",
66993 + .data = &grsec_enable_harden_ptrace,
66994 + .maxlen = sizeof(int),
66995 + .mode = 0600,
66996 + .proc_handler = &proc_dointvec,
66997 + },
66998 +#endif
66999 + {
67000 + .procname = "grsec_lock",
67001 + .data = &grsec_lock,
67002 + .maxlen = sizeof(int),
67003 + .mode = 0600,
67004 + .proc_handler = &proc_dointvec,
67005 + },
67006 +#endif
67007 +#ifdef CONFIG_GRKERNSEC_ROFS
67008 + {
67009 + .procname = "romount_protect",
67010 + .data = &grsec_enable_rofs,
67011 + .maxlen = sizeof(int),
67012 + .mode = 0600,
67013 + .proc_handler = &proc_dointvec_minmax,
67014 + .extra1 = &one,
67015 + .extra2 = &one,
67016 + },
67017 +#endif
67018 + { }
67019 +};
67020 +#endif
67021 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
67022 new file mode 100644
67023 index 0000000..0dc13c3
67024 --- /dev/null
67025 +++ b/grsecurity/grsec_time.c
67026 @@ -0,0 +1,16 @@
67027 +#include <linux/kernel.h>
67028 +#include <linux/sched.h>
67029 +#include <linux/grinternal.h>
67030 +#include <linux/module.h>
67031 +
67032 +void
67033 +gr_log_timechange(void)
67034 +{
67035 +#ifdef CONFIG_GRKERNSEC_TIME
67036 + if (grsec_enable_time)
67037 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
67038 +#endif
67039 + return;
67040 +}
67041 +
67042 +EXPORT_SYMBOL(gr_log_timechange);
67043 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
67044 new file mode 100644
67045 index 0000000..ee57dcf
67046 --- /dev/null
67047 +++ b/grsecurity/grsec_tpe.c
67048 @@ -0,0 +1,73 @@
67049 +#include <linux/kernel.h>
67050 +#include <linux/sched.h>
67051 +#include <linux/file.h>
67052 +#include <linux/fs.h>
67053 +#include <linux/grinternal.h>
67054 +
67055 +extern int gr_acl_tpe_check(void);
67056 +
67057 +int
67058 +gr_tpe_allow(const struct file *file)
67059 +{
67060 +#ifdef CONFIG_GRKERNSEC
67061 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
67062 + const struct cred *cred = current_cred();
67063 + char *msg = NULL;
67064 + char *msg2 = NULL;
67065 +
67066 + // never restrict root
67067 + if (gr_is_global_root(cred->uid))
67068 + return 1;
67069 +
67070 + if (grsec_enable_tpe) {
67071 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67072 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
67073 + msg = "not being in trusted group";
67074 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
67075 + msg = "being in untrusted group";
67076 +#else
67077 + if (in_group_p(grsec_tpe_gid))
67078 + msg = "being in untrusted group";
67079 +#endif
67080 + }
67081 + if (!msg && gr_acl_tpe_check())
67082 + msg = "being in untrusted role";
67083 +
67084 + // not in any affected group/role
67085 + if (!msg)
67086 + goto next_check;
67087 +
67088 + if (gr_is_global_nonroot(inode->i_uid))
67089 + msg2 = "file in non-root-owned directory";
67090 + else if (inode->i_mode & S_IWOTH)
67091 + msg2 = "file in world-writable directory";
67092 + else if (inode->i_mode & S_IWGRP)
67093 + msg2 = "file in group-writable directory";
67094 +
67095 + if (msg && msg2) {
67096 + char fullmsg[70] = {0};
67097 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
67098 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
67099 + return 0;
67100 + }
67101 + msg = NULL;
67102 +next_check:
67103 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67104 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
67105 + return 1;
67106 +
67107 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
67108 + msg = "directory not owned by user";
67109 + else if (inode->i_mode & S_IWOTH)
67110 + msg = "file in world-writable directory";
67111 + else if (inode->i_mode & S_IWGRP)
67112 + msg = "file in group-writable directory";
67113 +
67114 + if (msg) {
67115 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67116 + return 0;
67117 + }
67118 +#endif
67119 +#endif
67120 + return 1;
67121 +}
67122 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67123 new file mode 100644
67124 index 0000000..9f7b1ac
67125 --- /dev/null
67126 +++ b/grsecurity/grsum.c
67127 @@ -0,0 +1,61 @@
67128 +#include <linux/err.h>
67129 +#include <linux/kernel.h>
67130 +#include <linux/sched.h>
67131 +#include <linux/mm.h>
67132 +#include <linux/scatterlist.h>
67133 +#include <linux/crypto.h>
67134 +#include <linux/gracl.h>
67135 +
67136 +
67137 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67138 +#error "crypto and sha256 must be built into the kernel"
67139 +#endif
67140 +
67141 +int
67142 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67143 +{
67144 + char *p;
67145 + struct crypto_hash *tfm;
67146 + struct hash_desc desc;
67147 + struct scatterlist sg;
67148 + unsigned char temp_sum[GR_SHA_LEN];
67149 + volatile int retval = 0;
67150 + volatile int dummy = 0;
67151 + unsigned int i;
67152 +
67153 + sg_init_table(&sg, 1);
67154 +
67155 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67156 + if (IS_ERR(tfm)) {
67157 + /* should never happen, since sha256 should be built in */
67158 + return 1;
67159 + }
67160 +
67161 + desc.tfm = tfm;
67162 + desc.flags = 0;
67163 +
67164 + crypto_hash_init(&desc);
67165 +
67166 + p = salt;
67167 + sg_set_buf(&sg, p, GR_SALT_LEN);
67168 + crypto_hash_update(&desc, &sg, sg.length);
67169 +
67170 + p = entry->pw;
67171 + sg_set_buf(&sg, p, strlen(p));
67172 +
67173 + crypto_hash_update(&desc, &sg, sg.length);
67174 +
67175 + crypto_hash_final(&desc, temp_sum);
67176 +
67177 + memset(entry->pw, 0, GR_PW_LEN);
67178 +
67179 + for (i = 0; i < GR_SHA_LEN; i++)
67180 + if (sum[i] != temp_sum[i])
67181 + retval = 1;
67182 + else
67183 + dummy = 1; // waste a cycle
67184 +
67185 + crypto_free_hash(tfm);
67186 +
67187 + return retval;
67188 +}
67189 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67190 index 77ff547..181834f 100644
67191 --- a/include/asm-generic/4level-fixup.h
67192 +++ b/include/asm-generic/4level-fixup.h
67193 @@ -13,8 +13,10 @@
67194 #define pmd_alloc(mm, pud, address) \
67195 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67196 NULL: pmd_offset(pud, address))
67197 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67198
67199 #define pud_alloc(mm, pgd, address) (pgd)
67200 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67201 #define pud_offset(pgd, start) (pgd)
67202 #define pud_none(pud) 0
67203 #define pud_bad(pud) 0
67204 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67205 index b7babf0..04ad282 100644
67206 --- a/include/asm-generic/atomic-long.h
67207 +++ b/include/asm-generic/atomic-long.h
67208 @@ -22,6 +22,12 @@
67209
67210 typedef atomic64_t atomic_long_t;
67211
67212 +#ifdef CONFIG_PAX_REFCOUNT
67213 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67214 +#else
67215 +typedef atomic64_t atomic_long_unchecked_t;
67216 +#endif
67217 +
67218 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67219
67220 static inline long atomic_long_read(atomic_long_t *l)
67221 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67222 return (long)atomic64_read(v);
67223 }
67224
67225 +#ifdef CONFIG_PAX_REFCOUNT
67226 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67227 +{
67228 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67229 +
67230 + return (long)atomic64_read_unchecked(v);
67231 +}
67232 +#endif
67233 +
67234 static inline void atomic_long_set(atomic_long_t *l, long i)
67235 {
67236 atomic64_t *v = (atomic64_t *)l;
67237 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67238 atomic64_set(v, i);
67239 }
67240
67241 +#ifdef CONFIG_PAX_REFCOUNT
67242 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67243 +{
67244 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67245 +
67246 + atomic64_set_unchecked(v, i);
67247 +}
67248 +#endif
67249 +
67250 static inline void atomic_long_inc(atomic_long_t *l)
67251 {
67252 atomic64_t *v = (atomic64_t *)l;
67253 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67254 atomic64_inc(v);
67255 }
67256
67257 +#ifdef CONFIG_PAX_REFCOUNT
67258 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67259 +{
67260 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67261 +
67262 + atomic64_inc_unchecked(v);
67263 +}
67264 +#endif
67265 +
67266 static inline void atomic_long_dec(atomic_long_t *l)
67267 {
67268 atomic64_t *v = (atomic64_t *)l;
67269 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67270 atomic64_dec(v);
67271 }
67272
67273 +#ifdef CONFIG_PAX_REFCOUNT
67274 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67275 +{
67276 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67277 +
67278 + atomic64_dec_unchecked(v);
67279 +}
67280 +#endif
67281 +
67282 static inline void atomic_long_add(long i, atomic_long_t *l)
67283 {
67284 atomic64_t *v = (atomic64_t *)l;
67285 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67286 atomic64_add(i, v);
67287 }
67288
67289 +#ifdef CONFIG_PAX_REFCOUNT
67290 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67291 +{
67292 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67293 +
67294 + atomic64_add_unchecked(i, v);
67295 +}
67296 +#endif
67297 +
67298 static inline void atomic_long_sub(long i, atomic_long_t *l)
67299 {
67300 atomic64_t *v = (atomic64_t *)l;
67301 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67302 atomic64_sub(i, v);
67303 }
67304
67305 +#ifdef CONFIG_PAX_REFCOUNT
67306 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67307 +{
67308 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67309 +
67310 + atomic64_sub_unchecked(i, v);
67311 +}
67312 +#endif
67313 +
67314 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67315 {
67316 atomic64_t *v = (atomic64_t *)l;
67317 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67318 return (long)atomic64_add_return(i, v);
67319 }
67320
67321 +#ifdef CONFIG_PAX_REFCOUNT
67322 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67323 +{
67324 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67325 +
67326 + return (long)atomic64_add_return_unchecked(i, v);
67327 +}
67328 +#endif
67329 +
67330 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67331 {
67332 atomic64_t *v = (atomic64_t *)l;
67333 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67334 return (long)atomic64_inc_return(v);
67335 }
67336
67337 +#ifdef CONFIG_PAX_REFCOUNT
67338 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67339 +{
67340 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67341 +
67342 + return (long)atomic64_inc_return_unchecked(v);
67343 +}
67344 +#endif
67345 +
67346 static inline long atomic_long_dec_return(atomic_long_t *l)
67347 {
67348 atomic64_t *v = (atomic64_t *)l;
67349 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67350
67351 typedef atomic_t atomic_long_t;
67352
67353 +#ifdef CONFIG_PAX_REFCOUNT
67354 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67355 +#else
67356 +typedef atomic_t atomic_long_unchecked_t;
67357 +#endif
67358 +
67359 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67360 static inline long atomic_long_read(atomic_long_t *l)
67361 {
67362 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67363 return (long)atomic_read(v);
67364 }
67365
67366 +#ifdef CONFIG_PAX_REFCOUNT
67367 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67368 +{
67369 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67370 +
67371 + return (long)atomic_read_unchecked(v);
67372 +}
67373 +#endif
67374 +
67375 static inline void atomic_long_set(atomic_long_t *l, long i)
67376 {
67377 atomic_t *v = (atomic_t *)l;
67378 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67379 atomic_set(v, i);
67380 }
67381
67382 +#ifdef CONFIG_PAX_REFCOUNT
67383 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67384 +{
67385 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67386 +
67387 + atomic_set_unchecked(v, i);
67388 +}
67389 +#endif
67390 +
67391 static inline void atomic_long_inc(atomic_long_t *l)
67392 {
67393 atomic_t *v = (atomic_t *)l;
67394 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67395 atomic_inc(v);
67396 }
67397
67398 +#ifdef CONFIG_PAX_REFCOUNT
67399 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67400 +{
67401 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67402 +
67403 + atomic_inc_unchecked(v);
67404 +}
67405 +#endif
67406 +
67407 static inline void atomic_long_dec(atomic_long_t *l)
67408 {
67409 atomic_t *v = (atomic_t *)l;
67410 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67411 atomic_dec(v);
67412 }
67413
67414 +#ifdef CONFIG_PAX_REFCOUNT
67415 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67416 +{
67417 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67418 +
67419 + atomic_dec_unchecked(v);
67420 +}
67421 +#endif
67422 +
67423 static inline void atomic_long_add(long i, atomic_long_t *l)
67424 {
67425 atomic_t *v = (atomic_t *)l;
67426 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67427 atomic_add(i, v);
67428 }
67429
67430 +#ifdef CONFIG_PAX_REFCOUNT
67431 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67432 +{
67433 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67434 +
67435 + atomic_add_unchecked(i, v);
67436 +}
67437 +#endif
67438 +
67439 static inline void atomic_long_sub(long i, atomic_long_t *l)
67440 {
67441 atomic_t *v = (atomic_t *)l;
67442 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67443 atomic_sub(i, v);
67444 }
67445
67446 +#ifdef CONFIG_PAX_REFCOUNT
67447 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67448 +{
67449 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67450 +
67451 + atomic_sub_unchecked(i, v);
67452 +}
67453 +#endif
67454 +
67455 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67456 {
67457 atomic_t *v = (atomic_t *)l;
67458 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67459 return (long)atomic_add_return(i, v);
67460 }
67461
67462 +#ifdef CONFIG_PAX_REFCOUNT
67463 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67464 +{
67465 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67466 +
67467 + return (long)atomic_add_return_unchecked(i, v);
67468 +}
67469 +
67470 +#endif
67471 +
67472 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67473 {
67474 atomic_t *v = (atomic_t *)l;
67475 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67476 return (long)atomic_inc_return(v);
67477 }
67478
67479 +#ifdef CONFIG_PAX_REFCOUNT
67480 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67481 +{
67482 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67483 +
67484 + return (long)atomic_inc_return_unchecked(v);
67485 +}
67486 +#endif
67487 +
67488 static inline long atomic_long_dec_return(atomic_long_t *l)
67489 {
67490 atomic_t *v = (atomic_t *)l;
67491 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67492
67493 #endif /* BITS_PER_LONG == 64 */
67494
67495 +#ifdef CONFIG_PAX_REFCOUNT
67496 +static inline void pax_refcount_needs_these_functions(void)
67497 +{
67498 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67499 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67500 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67501 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67502 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67503 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67504 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67505 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67506 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67507 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67508 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67509 +#ifdef CONFIG_X86
67510 + atomic_clear_mask_unchecked(0, NULL);
67511 + atomic_set_mask_unchecked(0, NULL);
67512 +#endif
67513 +
67514 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67515 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67516 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67517 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67518 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67519 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67520 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67521 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67522 +}
67523 +#else
67524 +#define atomic_read_unchecked(v) atomic_read(v)
67525 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67526 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67527 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67528 +#define atomic_inc_unchecked(v) atomic_inc(v)
67529 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67530 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67531 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67532 +#define atomic_dec_unchecked(v) atomic_dec(v)
67533 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67534 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67535 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67536 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67537 +
67538 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67539 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67540 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67541 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67542 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67543 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67544 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67545 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67546 +#endif
67547 +
67548 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67549 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67550 index 33bd2de..f31bff97 100644
67551 --- a/include/asm-generic/atomic.h
67552 +++ b/include/asm-generic/atomic.h
67553 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67554 * Atomically clears the bits set in @mask from @v
67555 */
67556 #ifndef atomic_clear_mask
67557 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67558 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67559 {
67560 unsigned long flags;
67561
67562 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67563 index b18ce4f..2ee2843 100644
67564 --- a/include/asm-generic/atomic64.h
67565 +++ b/include/asm-generic/atomic64.h
67566 @@ -16,6 +16,8 @@ typedef struct {
67567 long long counter;
67568 } atomic64_t;
67569
67570 +typedef atomic64_t atomic64_unchecked_t;
67571 +
67572 #define ATOMIC64_INIT(i) { (i) }
67573
67574 extern long long atomic64_read(const atomic64_t *v);
67575 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67576 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67577 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67578
67579 +#define atomic64_read_unchecked(v) atomic64_read(v)
67580 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67581 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67582 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67583 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67584 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67585 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67586 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67587 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67588 +
67589 #endif /* _ASM_GENERIC_ATOMIC64_H */
67590 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67591 index 1bfcfe5..e04c5c9 100644
67592 --- a/include/asm-generic/cache.h
67593 +++ b/include/asm-generic/cache.h
67594 @@ -6,7 +6,7 @@
67595 * cache lines need to provide their own cache.h.
67596 */
67597
67598 -#define L1_CACHE_SHIFT 5
67599 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67600 +#define L1_CACHE_SHIFT 5UL
67601 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67602
67603 #endif /* __ASM_GENERIC_CACHE_H */
67604 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67605 index 0d68a1e..b74a761 100644
67606 --- a/include/asm-generic/emergency-restart.h
67607 +++ b/include/asm-generic/emergency-restart.h
67608 @@ -1,7 +1,7 @@
67609 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67610 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67611
67612 -static inline void machine_emergency_restart(void)
67613 +static inline __noreturn void machine_emergency_restart(void)
67614 {
67615 machine_restart(NULL);
67616 }
67617 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67618 index 90f99c7..00ce236 100644
67619 --- a/include/asm-generic/kmap_types.h
67620 +++ b/include/asm-generic/kmap_types.h
67621 @@ -2,9 +2,9 @@
67622 #define _ASM_GENERIC_KMAP_TYPES_H
67623
67624 #ifdef __WITH_KM_FENCE
67625 -# define KM_TYPE_NR 41
67626 +# define KM_TYPE_NR 42
67627 #else
67628 -# define KM_TYPE_NR 20
67629 +# define KM_TYPE_NR 21
67630 #endif
67631
67632 #endif
67633 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67634 index 9ceb03b..62b0b8f 100644
67635 --- a/include/asm-generic/local.h
67636 +++ b/include/asm-generic/local.h
67637 @@ -23,24 +23,37 @@ typedef struct
67638 atomic_long_t a;
67639 } local_t;
67640
67641 +typedef struct {
67642 + atomic_long_unchecked_t a;
67643 +} local_unchecked_t;
67644 +
67645 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67646
67647 #define local_read(l) atomic_long_read(&(l)->a)
67648 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67649 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67650 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67651 #define local_inc(l) atomic_long_inc(&(l)->a)
67652 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67653 #define local_dec(l) atomic_long_dec(&(l)->a)
67654 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67655 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67656 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67657 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67658 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67659
67660 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67661 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67662 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67663 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67664 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67665 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67666 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67667 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67668 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67669
67670 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67671 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67672 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67673 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67674 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67675 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67676 index 725612b..9cc513a 100644
67677 --- a/include/asm-generic/pgtable-nopmd.h
67678 +++ b/include/asm-generic/pgtable-nopmd.h
67679 @@ -1,14 +1,19 @@
67680 #ifndef _PGTABLE_NOPMD_H
67681 #define _PGTABLE_NOPMD_H
67682
67683 -#ifndef __ASSEMBLY__
67684 -
67685 #include <asm-generic/pgtable-nopud.h>
67686
67687 -struct mm_struct;
67688 -
67689 #define __PAGETABLE_PMD_FOLDED
67690
67691 +#define PMD_SHIFT PUD_SHIFT
67692 +#define PTRS_PER_PMD 1
67693 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67694 +#define PMD_MASK (~(PMD_SIZE-1))
67695 +
67696 +#ifndef __ASSEMBLY__
67697 +
67698 +struct mm_struct;
67699 +
67700 /*
67701 * Having the pmd type consist of a pud gets the size right, and allows
67702 * us to conceptually access the pud entry that this pmd is folded into
67703 @@ -16,11 +21,6 @@ struct mm_struct;
67704 */
67705 typedef struct { pud_t pud; } pmd_t;
67706
67707 -#define PMD_SHIFT PUD_SHIFT
67708 -#define PTRS_PER_PMD 1
67709 -#define PMD_SIZE (1UL << PMD_SHIFT)
67710 -#define PMD_MASK (~(PMD_SIZE-1))
67711 -
67712 /*
67713 * The "pud_xxx()" functions here are trivial for a folded two-level
67714 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67715 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67716 index 810431d..0ec4804f 100644
67717 --- a/include/asm-generic/pgtable-nopud.h
67718 +++ b/include/asm-generic/pgtable-nopud.h
67719 @@ -1,10 +1,15 @@
67720 #ifndef _PGTABLE_NOPUD_H
67721 #define _PGTABLE_NOPUD_H
67722
67723 -#ifndef __ASSEMBLY__
67724 -
67725 #define __PAGETABLE_PUD_FOLDED
67726
67727 +#define PUD_SHIFT PGDIR_SHIFT
67728 +#define PTRS_PER_PUD 1
67729 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67730 +#define PUD_MASK (~(PUD_SIZE-1))
67731 +
67732 +#ifndef __ASSEMBLY__
67733 +
67734 /*
67735 * Having the pud type consist of a pgd gets the size right, and allows
67736 * us to conceptually access the pgd entry that this pud is folded into
67737 @@ -12,11 +17,6 @@
67738 */
67739 typedef struct { pgd_t pgd; } pud_t;
67740
67741 -#define PUD_SHIFT PGDIR_SHIFT
67742 -#define PTRS_PER_PUD 1
67743 -#define PUD_SIZE (1UL << PUD_SHIFT)
67744 -#define PUD_MASK (~(PUD_SIZE-1))
67745 -
67746 /*
67747 * The "pgd_xxx()" functions here are trivial for a folded two-level
67748 * setup: the pud is never bad, and a pud always exists (as it's folded
67749 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67750 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67751
67752 #define pgd_populate(mm, pgd, pud) do { } while (0)
67753 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67754 /*
67755 * (puds are folded into pgds so this doesn't get actually called,
67756 * but the define is needed for a generic inline function.)
67757 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67758 index a59ff51..2594a70 100644
67759 --- a/include/asm-generic/pgtable.h
67760 +++ b/include/asm-generic/pgtable.h
67761 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67762 }
67763 #endif /* CONFIG_NUMA_BALANCING */
67764
67765 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67766 +static inline unsigned long pax_open_kernel(void) { return 0; }
67767 +#endif
67768 +
67769 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67770 +static inline unsigned long pax_close_kernel(void) { return 0; }
67771 +#endif
67772 +
67773 #endif /* CONFIG_MMU */
67774
67775 #endif /* !__ASSEMBLY__ */
67776 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67777 index eb58d2d..df131bf 100644
67778 --- a/include/asm-generic/vmlinux.lds.h
67779 +++ b/include/asm-generic/vmlinux.lds.h
67780 @@ -239,6 +239,7 @@
67781 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67782 VMLINUX_SYMBOL(__start_rodata) = .; \
67783 *(.rodata) *(.rodata.*) \
67784 + *(.data..read_only) \
67785 *(__vermagic) /* Kernel version magic */ \
67786 . = ALIGN(8); \
67787 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67788 @@ -749,17 +750,18 @@
67789 * section in the linker script will go there too. @phdr should have
67790 * a leading colon.
67791 *
67792 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67793 + * Note that this macros defines per_cpu_load as an absolute symbol.
67794 * If there is no need to put the percpu section at a predetermined
67795 * address, use PERCPU_SECTION.
67796 */
67797 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67798 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67799 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67800 + per_cpu_load = .; \
67801 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67802 - LOAD_OFFSET) { \
67803 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67804 PERCPU_INPUT(cacheline) \
67805 } phdr \
67806 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67807 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67808
67809 /**
67810 * PERCPU_SECTION - define output section for percpu area, simple version
67811 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67812 index 418d270..bfd2794 100644
67813 --- a/include/crypto/algapi.h
67814 +++ b/include/crypto/algapi.h
67815 @@ -34,7 +34,7 @@ struct crypto_type {
67816 unsigned int maskclear;
67817 unsigned int maskset;
67818 unsigned int tfmsize;
67819 -};
67820 +} __do_const;
67821
67822 struct crypto_instance {
67823 struct crypto_alg alg;
67824 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67825 index 63d17ee..716de2b 100644
67826 --- a/include/drm/drmP.h
67827 +++ b/include/drm/drmP.h
67828 @@ -72,6 +72,7 @@
67829 #include <linux/workqueue.h>
67830 #include <linux/poll.h>
67831 #include <asm/pgalloc.h>
67832 +#include <asm/local.h>
67833 #include <drm/drm.h>
67834 #include <drm/drm_sarea.h>
67835
67836 @@ -296,10 +297,12 @@ do { \
67837 * \param cmd command.
67838 * \param arg argument.
67839 */
67840 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67841 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67842 + struct drm_file *file_priv);
67843 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67844 struct drm_file *file_priv);
67845
67846 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67847 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67848 unsigned long arg);
67849
67850 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67851 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67852 struct drm_ioctl_desc {
67853 unsigned int cmd;
67854 int flags;
67855 - drm_ioctl_t *func;
67856 + drm_ioctl_t func;
67857 unsigned int cmd_drv;
67858 const char *name;
67859 -};
67860 +} __do_const;
67861
67862 /**
67863 * Creates a driver or general drm_ioctl_desc array entry for the given
67864 @@ -1015,7 +1018,7 @@ struct drm_info_list {
67865 int (*show)(struct seq_file*, void*); /** show callback */
67866 u32 driver_features; /**< Required driver features for this entry */
67867 void *data;
67868 -};
67869 +} __do_const;
67870
67871 /**
67872 * debugfs node structure. This structure represents a debugfs file.
67873 @@ -1088,7 +1091,7 @@ struct drm_device {
67874
67875 /** \name Usage Counters */
67876 /*@{ */
67877 - int open_count; /**< Outstanding files open */
67878 + local_t open_count; /**< Outstanding files open */
67879 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67880 atomic_t vma_count; /**< Outstanding vma areas open */
67881 int buf_use; /**< Buffers in use -- cannot alloc */
67882 @@ -1099,7 +1102,7 @@ struct drm_device {
67883 /*@{ */
67884 unsigned long counters;
67885 enum drm_stat_type types[15];
67886 - atomic_t counts[15];
67887 + atomic_unchecked_t counts[15];
67888 /*@} */
67889
67890 struct list_head filelist;
67891 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67892 index f43d556..94d9343 100644
67893 --- a/include/drm/drm_crtc_helper.h
67894 +++ b/include/drm/drm_crtc_helper.h
67895 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67896 struct drm_connector *connector);
67897 /* disable encoder when not in use - more explicit than dpms off */
67898 void (*disable)(struct drm_encoder *encoder);
67899 -};
67900 +} __no_const;
67901
67902 /**
67903 * drm_connector_helper_funcs - helper operations for connectors
67904 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67905 index 72dcbe8..8db58d7 100644
67906 --- a/include/drm/ttm/ttm_memory.h
67907 +++ b/include/drm/ttm/ttm_memory.h
67908 @@ -48,7 +48,7 @@
67909
67910 struct ttm_mem_shrink {
67911 int (*do_shrink) (struct ttm_mem_shrink *);
67912 -};
67913 +} __no_const;
67914
67915 /**
67916 * struct ttm_mem_global - Global memory accounting structure.
67917 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67918 index 4b840e8..155d235 100644
67919 --- a/include/keys/asymmetric-subtype.h
67920 +++ b/include/keys/asymmetric-subtype.h
67921 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67922 /* Verify the signature on a key of this subtype (optional) */
67923 int (*verify_signature)(const struct key *key,
67924 const struct public_key_signature *sig);
67925 -};
67926 +} __do_const;
67927
67928 /**
67929 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67930 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67931 index c1da539..1dcec55 100644
67932 --- a/include/linux/atmdev.h
67933 +++ b/include/linux/atmdev.h
67934 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67935 #endif
67936
67937 struct k_atm_aal_stats {
67938 -#define __HANDLE_ITEM(i) atomic_t i
67939 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67940 __AAL_STAT_ITEMS
67941 #undef __HANDLE_ITEM
67942 };
67943 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67944 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67945 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67946 struct module *owner;
67947 -};
67948 +} __do_const ;
67949
67950 struct atmphy_ops {
67951 int (*start)(struct atm_dev *dev);
67952 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67953 index 70cf138..cabb82e 100644
67954 --- a/include/linux/binfmts.h
67955 +++ b/include/linux/binfmts.h
67956 @@ -73,8 +73,9 @@ struct linux_binfmt {
67957 int (*load_binary)(struct linux_binprm *);
67958 int (*load_shlib)(struct file *);
67959 int (*core_dump)(struct coredump_params *cprm);
67960 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67961 unsigned long min_coredump; /* minimal dump size */
67962 -};
67963 +} __do_const;
67964
67965 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67966
67967 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67968 index 2fdb4a4..54aad7e 100644
67969 --- a/include/linux/blkdev.h
67970 +++ b/include/linux/blkdev.h
67971 @@ -1526,7 +1526,7 @@ struct block_device_operations {
67972 /* this callback is with swap_lock and sometimes page table lock held */
67973 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67974 struct module *owner;
67975 -};
67976 +} __do_const;
67977
67978 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67979 unsigned long);
67980 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67981 index 7c2e030..b72475d 100644
67982 --- a/include/linux/blktrace_api.h
67983 +++ b/include/linux/blktrace_api.h
67984 @@ -23,7 +23,7 @@ struct blk_trace {
67985 struct dentry *dir;
67986 struct dentry *dropped_file;
67987 struct dentry *msg_file;
67988 - atomic_t dropped;
67989 + atomic_unchecked_t dropped;
67990 };
67991
67992 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67993 diff --git a/include/linux/cache.h b/include/linux/cache.h
67994 index 4c57065..4307975 100644
67995 --- a/include/linux/cache.h
67996 +++ b/include/linux/cache.h
67997 @@ -16,6 +16,10 @@
67998 #define __read_mostly
67999 #endif
68000
68001 +#ifndef __read_only
68002 +#define __read_only __read_mostly
68003 +#endif
68004 +
68005 #ifndef ____cacheline_aligned
68006 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
68007 #endif
68008 diff --git a/include/linux/capability.h b/include/linux/capability.h
68009 index d9a4f7f4..19f77d6 100644
68010 --- a/include/linux/capability.h
68011 +++ b/include/linux/capability.h
68012 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
68013 extern bool nsown_capable(int cap);
68014 extern bool inode_capable(const struct inode *inode, int cap);
68015 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
68016 +extern bool capable_nolog(int cap);
68017 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
68018 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
68019
68020 /* audit system wants to get cap info from files as well */
68021 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
68022
68023 +extern int is_privileged_binary(const struct dentry *dentry);
68024 +
68025 #endif /* !_LINUX_CAPABILITY_H */
68026 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
68027 index 8609d57..86e4d79 100644
68028 --- a/include/linux/cdrom.h
68029 +++ b/include/linux/cdrom.h
68030 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
68031
68032 /* driver specifications */
68033 const int capability; /* capability flags */
68034 - int n_minors; /* number of active minor devices */
68035 /* handle uniform packets for scsi type devices (scsi,atapi) */
68036 int (*generic_packet) (struct cdrom_device_info *,
68037 struct packet_command *);
68038 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
68039 index 4ce9056..86caac6 100644
68040 --- a/include/linux/cleancache.h
68041 +++ b/include/linux/cleancache.h
68042 @@ -31,7 +31,7 @@ struct cleancache_ops {
68043 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
68044 void (*invalidate_inode)(int, struct cleancache_filekey);
68045 void (*invalidate_fs)(int);
68046 -};
68047 +} __no_const;
68048
68049 extern struct cleancache_ops *
68050 cleancache_register_ops(struct cleancache_ops *ops);
68051 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
68052 index 1186098..f87e53d 100644
68053 --- a/include/linux/clk-provider.h
68054 +++ b/include/linux/clk-provider.h
68055 @@ -132,6 +132,7 @@ struct clk_ops {
68056 unsigned long);
68057 void (*init)(struct clk_hw *hw);
68058 };
68059 +typedef struct clk_ops __no_const clk_ops_no_const;
68060
68061 /**
68062 * struct clk_init_data - holds init data that's common to all clocks and is
68063 diff --git a/include/linux/compat.h b/include/linux/compat.h
68064 index 7f0c1dd..b5729c6 100644
68065 --- a/include/linux/compat.h
68066 +++ b/include/linux/compat.h
68067 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
68068 compat_size_t __user *len_ptr);
68069
68070 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
68071 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
68072 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
68073 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
68074 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
68075 compat_ssize_t msgsz, int msgflg);
68076 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
68077 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
68078 compat_ulong_t addr, compat_ulong_t data);
68079 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
68080 - compat_long_t addr, compat_long_t data);
68081 + compat_ulong_t addr, compat_ulong_t data);
68082
68083 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
68084 /*
68085 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
68086 index 842de22..7f3a41f 100644
68087 --- a/include/linux/compiler-gcc4.h
68088 +++ b/include/linux/compiler-gcc4.h
68089 @@ -39,9 +39,29 @@
68090 # define __compiletime_warning(message) __attribute__((warning(message)))
68091 # define __compiletime_error(message) __attribute__((error(message)))
68092 #endif /* __CHECKER__ */
68093 +
68094 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
68095 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
68096 +#define __bos0(ptr) __bos((ptr), 0)
68097 +#define __bos1(ptr) __bos((ptr), 1)
68098 #endif /* GCC_VERSION >= 40300 */
68099
68100 #if GCC_VERSION >= 40500
68101 +
68102 +#ifdef CONSTIFY_PLUGIN
68103 +#define __no_const __attribute__((no_const))
68104 +#define __do_const __attribute__((do_const))
68105 +#endif
68106 +
68107 +#ifdef SIZE_OVERFLOW_PLUGIN
68108 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
68109 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
68110 +#endif
68111 +
68112 +#ifdef LATENT_ENTROPY_PLUGIN
68113 +#define __latent_entropy __attribute__((latent_entropy))
68114 +#endif
68115 +
68116 /*
68117 * Mark a position in code as unreachable. This can be used to
68118 * suppress control flow warnings after asm blocks that transfer
68119 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68120 index 92669cd..1771a15 100644
68121 --- a/include/linux/compiler.h
68122 +++ b/include/linux/compiler.h
68123 @@ -5,11 +5,14 @@
68124
68125 #ifdef __CHECKER__
68126 # define __user __attribute__((noderef, address_space(1)))
68127 +# define __force_user __force __user
68128 # define __kernel __attribute__((address_space(0)))
68129 +# define __force_kernel __force __kernel
68130 # define __safe __attribute__((safe))
68131 # define __force __attribute__((force))
68132 # define __nocast __attribute__((nocast))
68133 # define __iomem __attribute__((noderef, address_space(2)))
68134 +# define __force_iomem __force __iomem
68135 # define __must_hold(x) __attribute__((context(x,1,1)))
68136 # define __acquires(x) __attribute__((context(x,0,1)))
68137 # define __releases(x) __attribute__((context(x,1,0)))
68138 @@ -17,20 +20,37 @@
68139 # define __release(x) __context__(x,-1)
68140 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68141 # define __percpu __attribute__((noderef, address_space(3)))
68142 +# define __force_percpu __force __percpu
68143 #ifdef CONFIG_SPARSE_RCU_POINTER
68144 # define __rcu __attribute__((noderef, address_space(4)))
68145 +# define __force_rcu __force __rcu
68146 #else
68147 # define __rcu
68148 +# define __force_rcu
68149 #endif
68150 extern void __chk_user_ptr(const volatile void __user *);
68151 extern void __chk_io_ptr(const volatile void __iomem *);
68152 #else
68153 -# define __user
68154 -# define __kernel
68155 +# ifdef CHECKER_PLUGIN
68156 +//# define __user
68157 +//# define __force_user
68158 +//# define __kernel
68159 +//# define __force_kernel
68160 +# else
68161 +# ifdef STRUCTLEAK_PLUGIN
68162 +# define __user __attribute__((user))
68163 +# else
68164 +# define __user
68165 +# endif
68166 +# define __force_user
68167 +# define __kernel
68168 +# define __force_kernel
68169 +# endif
68170 # define __safe
68171 # define __force
68172 # define __nocast
68173 # define __iomem
68174 +# define __force_iomem
68175 # define __chk_user_ptr(x) (void)0
68176 # define __chk_io_ptr(x) (void)0
68177 # define __builtin_warning(x, y...) (1)
68178 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68179 # define __release(x) (void)0
68180 # define __cond_lock(x,c) (c)
68181 # define __percpu
68182 +# define __force_percpu
68183 # define __rcu
68184 +# define __force_rcu
68185 #endif
68186
68187 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68188 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68189 # define __attribute_const__ /* unimplemented */
68190 #endif
68191
68192 +#ifndef __no_const
68193 +# define __no_const
68194 +#endif
68195 +
68196 +#ifndef __do_const
68197 +# define __do_const
68198 +#endif
68199 +
68200 +#ifndef __size_overflow
68201 +# define __size_overflow(...)
68202 +#endif
68203 +
68204 +#ifndef __intentional_overflow
68205 +# define __intentional_overflow(...)
68206 +#endif
68207 +
68208 +#ifndef __latent_entropy
68209 +# define __latent_entropy
68210 +#endif
68211 +
68212 /*
68213 * Tell gcc if a function is cold. The compiler will assume any path
68214 * directly leading to the call is unlikely.
68215 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68216 #define __cold
68217 #endif
68218
68219 +#ifndef __alloc_size
68220 +#define __alloc_size(...)
68221 +#endif
68222 +
68223 +#ifndef __bos
68224 +#define __bos(ptr, arg)
68225 +#endif
68226 +
68227 +#ifndef __bos0
68228 +#define __bos0(ptr)
68229 +#endif
68230 +
68231 +#ifndef __bos1
68232 +#define __bos1(ptr)
68233 +#endif
68234 +
68235 /* Simple shorthand for a section definition */
68236 #ifndef __section
68237 # define __section(S) __attribute__ ((__section__(#S)))
68238 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68239 * use is to mediate communication between process-level code and irq/NMI
68240 * handlers, all running on the same CPU.
68241 */
68242 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68243 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68244 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68245
68246 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
68247 #ifdef CONFIG_KPROBES
68248 diff --git a/include/linux/completion.h b/include/linux/completion.h
68249 index 33f0280..35c6568 100644
68250 --- a/include/linux/completion.h
68251 +++ b/include/linux/completion.h
68252 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68253 extern void wait_for_completion(struct completion *);
68254 extern void wait_for_completion_io(struct completion *);
68255 extern int wait_for_completion_interruptible(struct completion *x);
68256 -extern int wait_for_completion_killable(struct completion *x);
68257 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68258 extern unsigned long wait_for_completion_timeout(struct completion *x,
68259 unsigned long timeout);
68260 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68261 unsigned long timeout);
68262 extern long wait_for_completion_interruptible_timeout(
68263 - struct completion *x, unsigned long timeout);
68264 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68265 extern long wait_for_completion_killable_timeout(
68266 - struct completion *x, unsigned long timeout);
68267 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68268 extern bool try_wait_for_completion(struct completion *x);
68269 extern bool completion_done(struct completion *x);
68270
68271 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68272 index 34025df..d94bbbc 100644
68273 --- a/include/linux/configfs.h
68274 +++ b/include/linux/configfs.h
68275 @@ -125,7 +125,7 @@ struct configfs_attribute {
68276 const char *ca_name;
68277 struct module *ca_owner;
68278 umode_t ca_mode;
68279 -};
68280 +} __do_const;
68281
68282 /*
68283 * Users often need to create attribute structures for their configurable
68284 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68285 index 9f3c7e8..a18c7b6 100644
68286 --- a/include/linux/cpu.h
68287 +++ b/include/linux/cpu.h
68288 @@ -115,7 +115,7 @@ enum {
68289 /* Need to know about CPUs going up/down? */
68290 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68291 #define cpu_notifier(fn, pri) { \
68292 - static struct notifier_block fn##_nb __cpuinitdata = \
68293 + static struct notifier_block fn##_nb = \
68294 { .notifier_call = fn, .priority = pri }; \
68295 register_cpu_notifier(&fn##_nb); \
68296 }
68297 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68298 index 037d36a..ca5fe6e 100644
68299 --- a/include/linux/cpufreq.h
68300 +++ b/include/linux/cpufreq.h
68301 @@ -262,7 +262,7 @@ struct cpufreq_driver {
68302 int (*suspend) (struct cpufreq_policy *policy);
68303 int (*resume) (struct cpufreq_policy *policy);
68304 struct freq_attr **attr;
68305 -};
68306 +} __do_const;
68307
68308 /* flags */
68309
68310 @@ -321,6 +321,7 @@ struct global_attr {
68311 ssize_t (*store)(struct kobject *a, struct attribute *b,
68312 const char *c, size_t count);
68313 };
68314 +typedef struct global_attr __no_const global_attr_no_const;
68315
68316 #define define_one_global_ro(_name) \
68317 static struct global_attr _name = \
68318 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68319 index 8f04062..900239a 100644
68320 --- a/include/linux/cpuidle.h
68321 +++ b/include/linux/cpuidle.h
68322 @@ -52,7 +52,8 @@ struct cpuidle_state {
68323 int index);
68324
68325 int (*enter_dead) (struct cpuidle_device *dev, int index);
68326 -};
68327 +} __do_const;
68328 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68329
68330 /* Idle State Flags */
68331 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68332 @@ -191,7 +192,7 @@ struct cpuidle_governor {
68333 void (*reflect) (struct cpuidle_device *dev, int index);
68334
68335 struct module *owner;
68336 -};
68337 +} __do_const;
68338
68339 #ifdef CONFIG_CPU_IDLE
68340
68341 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68342 index d08e4d2..95fad61 100644
68343 --- a/include/linux/cpumask.h
68344 +++ b/include/linux/cpumask.h
68345 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68346 }
68347
68348 /* Valid inputs for n are -1 and 0. */
68349 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68350 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68351 {
68352 return n+1;
68353 }
68354
68355 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68356 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68357 {
68358 return n+1;
68359 }
68360
68361 -static inline unsigned int cpumask_next_and(int n,
68362 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68363 const struct cpumask *srcp,
68364 const struct cpumask *andp)
68365 {
68366 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68367 *
68368 * Returns >= nr_cpu_ids if no further cpus set.
68369 */
68370 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68371 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68372 {
68373 /* -1 is a legal arg here. */
68374 if (n != -1)
68375 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68376 *
68377 * Returns >= nr_cpu_ids if no further cpus unset.
68378 */
68379 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68380 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68381 {
68382 /* -1 is a legal arg here. */
68383 if (n != -1)
68384 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68385 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68386 }
68387
68388 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68389 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68390 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68391
68392 /**
68393 diff --git a/include/linux/cred.h b/include/linux/cred.h
68394 index 04421e8..6bce4ef 100644
68395 --- a/include/linux/cred.h
68396 +++ b/include/linux/cred.h
68397 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68398 static inline void validate_process_creds(void)
68399 {
68400 }
68401 +static inline void validate_task_creds(struct task_struct *task)
68402 +{
68403 +}
68404 #endif
68405
68406 /**
68407 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68408 index b92eadf..b4ecdc1 100644
68409 --- a/include/linux/crypto.h
68410 +++ b/include/linux/crypto.h
68411 @@ -373,7 +373,7 @@ struct cipher_tfm {
68412 const u8 *key, unsigned int keylen);
68413 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68414 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68415 -};
68416 +} __no_const;
68417
68418 struct hash_tfm {
68419 int (*init)(struct hash_desc *desc);
68420 @@ -394,13 +394,13 @@ struct compress_tfm {
68421 int (*cot_decompress)(struct crypto_tfm *tfm,
68422 const u8 *src, unsigned int slen,
68423 u8 *dst, unsigned int *dlen);
68424 -};
68425 +} __no_const;
68426
68427 struct rng_tfm {
68428 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68429 unsigned int dlen);
68430 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68431 -};
68432 +} __no_const;
68433
68434 #define crt_ablkcipher crt_u.ablkcipher
68435 #define crt_aead crt_u.aead
68436 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68437 index 653589e..4ef254a 100644
68438 --- a/include/linux/ctype.h
68439 +++ b/include/linux/ctype.h
68440 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68441 * Fast implementation of tolower() for internal usage. Do not use in your
68442 * code.
68443 */
68444 -static inline char _tolower(const char c)
68445 +static inline unsigned char _tolower(const unsigned char c)
68446 {
68447 return c | 0x20;
68448 }
68449 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68450 index 7925bf0..d5143d2 100644
68451 --- a/include/linux/decompress/mm.h
68452 +++ b/include/linux/decompress/mm.h
68453 @@ -77,7 +77,7 @@ static void free(void *where)
68454 * warnings when not needed (indeed large_malloc / large_free are not
68455 * needed by inflate */
68456
68457 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68458 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68459 #define free(a) kfree(a)
68460
68461 #define large_malloc(a) vmalloc(a)
68462 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68463 index fe8c447..bdc1f33 100644
68464 --- a/include/linux/devfreq.h
68465 +++ b/include/linux/devfreq.h
68466 @@ -114,7 +114,7 @@ struct devfreq_governor {
68467 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68468 int (*event_handler)(struct devfreq *devfreq,
68469 unsigned int event, void *data);
68470 -};
68471 +} __do_const;
68472
68473 /**
68474 * struct devfreq - Device devfreq structure
68475 diff --git a/include/linux/device.h b/include/linux/device.h
68476 index c0a1261..dba7569 100644
68477 --- a/include/linux/device.h
68478 +++ b/include/linux/device.h
68479 @@ -290,7 +290,7 @@ struct subsys_interface {
68480 struct list_head node;
68481 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68482 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68483 -};
68484 +} __do_const;
68485
68486 int subsys_interface_register(struct subsys_interface *sif);
68487 void subsys_interface_unregister(struct subsys_interface *sif);
68488 @@ -473,7 +473,7 @@ struct device_type {
68489 void (*release)(struct device *dev);
68490
68491 const struct dev_pm_ops *pm;
68492 -};
68493 +} __do_const;
68494
68495 /* interface for exporting device attributes */
68496 struct device_attribute {
68497 @@ -483,11 +483,12 @@ struct device_attribute {
68498 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68499 const char *buf, size_t count);
68500 };
68501 +typedef struct device_attribute __no_const device_attribute_no_const;
68502
68503 struct dev_ext_attribute {
68504 struct device_attribute attr;
68505 void *var;
68506 -};
68507 +} __do_const;
68508
68509 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68510 char *buf);
68511 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68512 index 94af418..b1ca7a2 100644
68513 --- a/include/linux/dma-mapping.h
68514 +++ b/include/linux/dma-mapping.h
68515 @@ -54,7 +54,7 @@ struct dma_map_ops {
68516 u64 (*get_required_mask)(struct device *dev);
68517 #endif
68518 int is_phys;
68519 -};
68520 +} __do_const;
68521
68522 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68523
68524 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68525 index 96d3e4a..dc36433 100644
68526 --- a/include/linux/dmaengine.h
68527 +++ b/include/linux/dmaengine.h
68528 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
68529 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68530 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68531
68532 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68533 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68534 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68535 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68536 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68537 struct dma_pinned_list *pinned_list, struct page *page,
68538 unsigned int offset, size_t len);
68539
68540 diff --git a/include/linux/efi.h b/include/linux/efi.h
68541 index 2bc0ad7..3f7b006 100644
68542 --- a/include/linux/efi.h
68543 +++ b/include/linux/efi.h
68544 @@ -745,6 +745,7 @@ struct efivar_operations {
68545 efi_set_variable_t *set_variable;
68546 efi_query_variable_store_t *query_variable_store;
68547 };
68548 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68549
68550 struct efivars {
68551 /*
68552 diff --git a/include/linux/elf.h b/include/linux/elf.h
68553 index 40a3c0e..4c45a38 100644
68554 --- a/include/linux/elf.h
68555 +++ b/include/linux/elf.h
68556 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68557 #define elf_note elf32_note
68558 #define elf_addr_t Elf32_Off
68559 #define Elf_Half Elf32_Half
68560 +#define elf_dyn Elf32_Dyn
68561
68562 #else
68563
68564 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68565 #define elf_note elf64_note
68566 #define elf_addr_t Elf64_Off
68567 #define Elf_Half Elf64_Half
68568 +#define elf_dyn Elf64_Dyn
68569
68570 #endif
68571
68572 diff --git a/include/linux/err.h b/include/linux/err.h
68573 index f2edce2..cc2082c 100644
68574 --- a/include/linux/err.h
68575 +++ b/include/linux/err.h
68576 @@ -19,12 +19,12 @@
68577
68578 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68579
68580 -static inline void * __must_check ERR_PTR(long error)
68581 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68582 {
68583 return (void *) error;
68584 }
68585
68586 -static inline long __must_check PTR_ERR(const void *ptr)
68587 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68588 {
68589 return (long) ptr;
68590 }
68591 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68592 index fcb51c8..bdafcf6 100644
68593 --- a/include/linux/extcon.h
68594 +++ b/include/linux/extcon.h
68595 @@ -134,7 +134,7 @@ struct extcon_dev {
68596 /* /sys/class/extcon/.../mutually_exclusive/... */
68597 struct attribute_group attr_g_muex;
68598 struct attribute **attrs_muex;
68599 - struct device_attribute *d_attrs_muex;
68600 + device_attribute_no_const *d_attrs_muex;
68601 };
68602
68603 /**
68604 diff --git a/include/linux/fb.h b/include/linux/fb.h
68605 index d49c60f..2834fbe 100644
68606 --- a/include/linux/fb.h
68607 +++ b/include/linux/fb.h
68608 @@ -304,7 +304,7 @@ struct fb_ops {
68609 /* called at KDB enter and leave time to prepare the console */
68610 int (*fb_debug_enter)(struct fb_info *info);
68611 int (*fb_debug_leave)(struct fb_info *info);
68612 -};
68613 +} __do_const;
68614
68615 #ifdef CONFIG_FB_TILEBLITTING
68616 #define FB_TILE_CURSOR_NONE 0
68617 diff --git a/include/linux/filter.h b/include/linux/filter.h
68618 index f65f5a6..2f4f93a 100644
68619 --- a/include/linux/filter.h
68620 +++ b/include/linux/filter.h
68621 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68622
68623 struct sk_buff;
68624 struct sock;
68625 +struct bpf_jit_work;
68626
68627 struct sk_filter
68628 {
68629 @@ -27,6 +28,9 @@ struct sk_filter
68630 unsigned int len; /* Number of filter blocks */
68631 unsigned int (*bpf_func)(const struct sk_buff *skb,
68632 const struct sock_filter *filter);
68633 +#ifdef CONFIG_BPF_JIT
68634 + struct bpf_jit_work *work;
68635 +#endif
68636 struct rcu_head rcu;
68637 struct sock_filter insns[0];
68638 };
68639 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68640 index 8293262..2b3b8bd 100644
68641 --- a/include/linux/frontswap.h
68642 +++ b/include/linux/frontswap.h
68643 @@ -11,7 +11,7 @@ struct frontswap_ops {
68644 int (*load)(unsigned, pgoff_t, struct page *);
68645 void (*invalidate_page)(unsigned, pgoff_t);
68646 void (*invalidate_area)(unsigned);
68647 -};
68648 +} __no_const;
68649
68650 extern bool frontswap_enabled;
68651 extern struct frontswap_ops *
68652 diff --git a/include/linux/fs.h b/include/linux/fs.h
68653 index 65c2be2..4c53f6e 100644
68654 --- a/include/linux/fs.h
68655 +++ b/include/linux/fs.h
68656 @@ -1543,7 +1543,8 @@ struct file_operations {
68657 long (*fallocate)(struct file *file, int mode, loff_t offset,
68658 loff_t len);
68659 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68660 -};
68661 +} __do_const;
68662 +typedef struct file_operations __no_const file_operations_no_const;
68663
68664 struct inode_operations {
68665 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68666 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68667 inode->i_flags |= S_NOSEC;
68668 }
68669
68670 +static inline bool is_sidechannel_device(const struct inode *inode)
68671 +{
68672 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68673 + umode_t mode = inode->i_mode;
68674 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68675 +#else
68676 + return false;
68677 +#endif
68678 +}
68679 +
68680 #endif /* _LINUX_FS_H */
68681 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68682 index 2b93a9a..855d94a 100644
68683 --- a/include/linux/fs_struct.h
68684 +++ b/include/linux/fs_struct.h
68685 @@ -6,7 +6,7 @@
68686 #include <linux/seqlock.h>
68687
68688 struct fs_struct {
68689 - int users;
68690 + atomic_t users;
68691 spinlock_t lock;
68692 seqcount_t seq;
68693 int umask;
68694 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68695 index 5dfa0aa..6acf322 100644
68696 --- a/include/linux/fscache-cache.h
68697 +++ b/include/linux/fscache-cache.h
68698 @@ -112,7 +112,7 @@ struct fscache_operation {
68699 fscache_operation_release_t release;
68700 };
68701
68702 -extern atomic_t fscache_op_debug_id;
68703 +extern atomic_unchecked_t fscache_op_debug_id;
68704 extern void fscache_op_work_func(struct work_struct *work);
68705
68706 extern void fscache_enqueue_operation(struct fscache_operation *);
68707 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68708 INIT_WORK(&op->work, fscache_op_work_func);
68709 atomic_set(&op->usage, 1);
68710 op->state = FSCACHE_OP_ST_INITIALISED;
68711 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68712 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68713 op->processor = processor;
68714 op->release = release;
68715 INIT_LIST_HEAD(&op->pend_link);
68716 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68717 index 7a08623..4c07b0f 100644
68718 --- a/include/linux/fscache.h
68719 +++ b/include/linux/fscache.h
68720 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68721 * - this is mandatory for any object that may have data
68722 */
68723 void (*now_uncached)(void *cookie_netfs_data);
68724 -};
68725 +} __do_const;
68726
68727 /*
68728 * fscache cached network filesystem type
68729 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68730 index a78680a..87bd73e 100644
68731 --- a/include/linux/fsnotify.h
68732 +++ b/include/linux/fsnotify.h
68733 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68734 struct inode *inode = path->dentry->d_inode;
68735 __u32 mask = FS_ACCESS;
68736
68737 + if (is_sidechannel_device(inode))
68738 + return;
68739 +
68740 if (S_ISDIR(inode->i_mode))
68741 mask |= FS_ISDIR;
68742
68743 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68744 struct inode *inode = path->dentry->d_inode;
68745 __u32 mask = FS_MODIFY;
68746
68747 + if (is_sidechannel_device(inode))
68748 + return;
68749 +
68750 if (S_ISDIR(inode->i_mode))
68751 mask |= FS_ISDIR;
68752
68753 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68754 */
68755 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68756 {
68757 - return kstrdup(name, GFP_KERNEL);
68758 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68759 }
68760
68761 /*
68762 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68763 index 9f3c275..911b591 100644
68764 --- a/include/linux/genhd.h
68765 +++ b/include/linux/genhd.h
68766 @@ -194,7 +194,7 @@ struct gendisk {
68767 struct kobject *slave_dir;
68768
68769 struct timer_rand_state *random;
68770 - atomic_t sync_io; /* RAID */
68771 + atomic_unchecked_t sync_io; /* RAID */
68772 struct disk_events *ev;
68773 #ifdef CONFIG_BLK_DEV_INTEGRITY
68774 struct blk_integrity *integrity;
68775 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68776 index 023bc34..b02b46a 100644
68777 --- a/include/linux/genl_magic_func.h
68778 +++ b/include/linux/genl_magic_func.h
68779 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68780 },
68781
68782 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68783 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68784 +static struct genl_ops ZZZ_genl_ops[] = {
68785 #include GENL_MAGIC_INCLUDE_FILE
68786 };
68787
68788 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68789 index 0f615eb..5c3832f 100644
68790 --- a/include/linux/gfp.h
68791 +++ b/include/linux/gfp.h
68792 @@ -35,6 +35,13 @@ struct vm_area_struct;
68793 #define ___GFP_NO_KSWAPD 0x400000u
68794 #define ___GFP_OTHER_NODE 0x800000u
68795 #define ___GFP_WRITE 0x1000000u
68796 +
68797 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68798 +#define ___GFP_USERCOPY 0x2000000u
68799 +#else
68800 +#define ___GFP_USERCOPY 0
68801 +#endif
68802 +
68803 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68804
68805 /*
68806 @@ -92,6 +99,7 @@ struct vm_area_struct;
68807 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68808 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68809 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68810 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68811
68812 /*
68813 * This may seem redundant, but it's a way of annotating false positives vs.
68814 @@ -99,7 +107,7 @@ struct vm_area_struct;
68815 */
68816 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68817
68818 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68819 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68820 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68821
68822 /* This equals 0, but use constants in case they ever change */
68823 @@ -153,6 +161,8 @@ struct vm_area_struct;
68824 /* 4GB DMA on some platforms */
68825 #define GFP_DMA32 __GFP_DMA32
68826
68827 +#define GFP_USERCOPY __GFP_USERCOPY
68828 +
68829 /* Convert GFP flags to their corresponding migrate type */
68830 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68831 {
68832 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68833 new file mode 100644
68834 index 0000000..ebe6d72
68835 --- /dev/null
68836 +++ b/include/linux/gracl.h
68837 @@ -0,0 +1,319 @@
68838 +#ifndef GR_ACL_H
68839 +#define GR_ACL_H
68840 +
68841 +#include <linux/grdefs.h>
68842 +#include <linux/resource.h>
68843 +#include <linux/capability.h>
68844 +#include <linux/dcache.h>
68845 +#include <asm/resource.h>
68846 +
68847 +/* Major status information */
68848 +
68849 +#define GR_VERSION "grsecurity 2.9.1"
68850 +#define GRSECURITY_VERSION 0x2901
68851 +
68852 +enum {
68853 + GR_SHUTDOWN = 0,
68854 + GR_ENABLE = 1,
68855 + GR_SPROLE = 2,
68856 + GR_RELOAD = 3,
68857 + GR_SEGVMOD = 4,
68858 + GR_STATUS = 5,
68859 + GR_UNSPROLE = 6,
68860 + GR_PASSSET = 7,
68861 + GR_SPROLEPAM = 8,
68862 +};
68863 +
68864 +/* Password setup definitions
68865 + * kernel/grhash.c */
68866 +enum {
68867 + GR_PW_LEN = 128,
68868 + GR_SALT_LEN = 16,
68869 + GR_SHA_LEN = 32,
68870 +};
68871 +
68872 +enum {
68873 + GR_SPROLE_LEN = 64,
68874 +};
68875 +
68876 +enum {
68877 + GR_NO_GLOB = 0,
68878 + GR_REG_GLOB,
68879 + GR_CREATE_GLOB
68880 +};
68881 +
68882 +#define GR_NLIMITS 32
68883 +
68884 +/* Begin Data Structures */
68885 +
68886 +struct sprole_pw {
68887 + unsigned char *rolename;
68888 + unsigned char salt[GR_SALT_LEN];
68889 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68890 +};
68891 +
68892 +struct name_entry {
68893 + __u32 key;
68894 + ino_t inode;
68895 + dev_t device;
68896 + char *name;
68897 + __u16 len;
68898 + __u8 deleted;
68899 + struct name_entry *prev;
68900 + struct name_entry *next;
68901 +};
68902 +
68903 +struct inodev_entry {
68904 + struct name_entry *nentry;
68905 + struct inodev_entry *prev;
68906 + struct inodev_entry *next;
68907 +};
68908 +
68909 +struct acl_role_db {
68910 + struct acl_role_label **r_hash;
68911 + __u32 r_size;
68912 +};
68913 +
68914 +struct inodev_db {
68915 + struct inodev_entry **i_hash;
68916 + __u32 i_size;
68917 +};
68918 +
68919 +struct name_db {
68920 + struct name_entry **n_hash;
68921 + __u32 n_size;
68922 +};
68923 +
68924 +struct crash_uid {
68925 + uid_t uid;
68926 + unsigned long expires;
68927 +};
68928 +
68929 +struct gr_hash_struct {
68930 + void **table;
68931 + void **nametable;
68932 + void *first;
68933 + __u32 table_size;
68934 + __u32 used_size;
68935 + int type;
68936 +};
68937 +
68938 +/* Userspace Grsecurity ACL data structures */
68939 +
68940 +struct acl_subject_label {
68941 + char *filename;
68942 + ino_t inode;
68943 + dev_t device;
68944 + __u32 mode;
68945 + kernel_cap_t cap_mask;
68946 + kernel_cap_t cap_lower;
68947 + kernel_cap_t cap_invert_audit;
68948 +
68949 + struct rlimit res[GR_NLIMITS];
68950 + __u32 resmask;
68951 +
68952 + __u8 user_trans_type;
68953 + __u8 group_trans_type;
68954 + uid_t *user_transitions;
68955 + gid_t *group_transitions;
68956 + __u16 user_trans_num;
68957 + __u16 group_trans_num;
68958 +
68959 + __u32 sock_families[2];
68960 + __u32 ip_proto[8];
68961 + __u32 ip_type;
68962 + struct acl_ip_label **ips;
68963 + __u32 ip_num;
68964 + __u32 inaddr_any_override;
68965 +
68966 + __u32 crashes;
68967 + unsigned long expires;
68968 +
68969 + struct acl_subject_label *parent_subject;
68970 + struct gr_hash_struct *hash;
68971 + struct acl_subject_label *prev;
68972 + struct acl_subject_label *next;
68973 +
68974 + struct acl_object_label **obj_hash;
68975 + __u32 obj_hash_size;
68976 + __u16 pax_flags;
68977 +};
68978 +
68979 +struct role_allowed_ip {
68980 + __u32 addr;
68981 + __u32 netmask;
68982 +
68983 + struct role_allowed_ip *prev;
68984 + struct role_allowed_ip *next;
68985 +};
68986 +
68987 +struct role_transition {
68988 + char *rolename;
68989 +
68990 + struct role_transition *prev;
68991 + struct role_transition *next;
68992 +};
68993 +
68994 +struct acl_role_label {
68995 + char *rolename;
68996 + uid_t uidgid;
68997 + __u16 roletype;
68998 +
68999 + __u16 auth_attempts;
69000 + unsigned long expires;
69001 +
69002 + struct acl_subject_label *root_label;
69003 + struct gr_hash_struct *hash;
69004 +
69005 + struct acl_role_label *prev;
69006 + struct acl_role_label *next;
69007 +
69008 + struct role_transition *transitions;
69009 + struct role_allowed_ip *allowed_ips;
69010 + uid_t *domain_children;
69011 + __u16 domain_child_num;
69012 +
69013 + umode_t umask;
69014 +
69015 + struct acl_subject_label **subj_hash;
69016 + __u32 subj_hash_size;
69017 +};
69018 +
69019 +struct user_acl_role_db {
69020 + struct acl_role_label **r_table;
69021 + __u32 num_pointers; /* Number of allocations to track */
69022 + __u32 num_roles; /* Number of roles */
69023 + __u32 num_domain_children; /* Number of domain children */
69024 + __u32 num_subjects; /* Number of subjects */
69025 + __u32 num_objects; /* Number of objects */
69026 +};
69027 +
69028 +struct acl_object_label {
69029 + char *filename;
69030 + ino_t inode;
69031 + dev_t device;
69032 + __u32 mode;
69033 +
69034 + struct acl_subject_label *nested;
69035 + struct acl_object_label *globbed;
69036 +
69037 + /* next two structures not used */
69038 +
69039 + struct acl_object_label *prev;
69040 + struct acl_object_label *next;
69041 +};
69042 +
69043 +struct acl_ip_label {
69044 + char *iface;
69045 + __u32 addr;
69046 + __u32 netmask;
69047 + __u16 low, high;
69048 + __u8 mode;
69049 + __u32 type;
69050 + __u32 proto[8];
69051 +
69052 + /* next two structures not used */
69053 +
69054 + struct acl_ip_label *prev;
69055 + struct acl_ip_label *next;
69056 +};
69057 +
69058 +struct gr_arg {
69059 + struct user_acl_role_db role_db;
69060 + unsigned char pw[GR_PW_LEN];
69061 + unsigned char salt[GR_SALT_LEN];
69062 + unsigned char sum[GR_SHA_LEN];
69063 + unsigned char sp_role[GR_SPROLE_LEN];
69064 + struct sprole_pw *sprole_pws;
69065 + dev_t segv_device;
69066 + ino_t segv_inode;
69067 + uid_t segv_uid;
69068 + __u16 num_sprole_pws;
69069 + __u16 mode;
69070 +};
69071 +
69072 +struct gr_arg_wrapper {
69073 + struct gr_arg *arg;
69074 + __u32 version;
69075 + __u32 size;
69076 +};
69077 +
69078 +struct subject_map {
69079 + struct acl_subject_label *user;
69080 + struct acl_subject_label *kernel;
69081 + struct subject_map *prev;
69082 + struct subject_map *next;
69083 +};
69084 +
69085 +struct acl_subj_map_db {
69086 + struct subject_map **s_hash;
69087 + __u32 s_size;
69088 +};
69089 +
69090 +/* End Data Structures Section */
69091 +
69092 +/* Hash functions generated by empirical testing by Brad Spengler
69093 + Makes good use of the low bits of the inode. Generally 0-1 times
69094 + in loop for successful match. 0-3 for unsuccessful match.
69095 + Shift/add algorithm with modulus of table size and an XOR*/
69096 +
69097 +static __inline__ unsigned int
69098 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
69099 +{
69100 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
69101 +}
69102 +
69103 + static __inline__ unsigned int
69104 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
69105 +{
69106 + return ((const unsigned long)userp % sz);
69107 +}
69108 +
69109 +static __inline__ unsigned int
69110 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69111 +{
69112 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69113 +}
69114 +
69115 +static __inline__ unsigned int
69116 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69117 +{
69118 + return full_name_hash((const unsigned char *)name, len) % sz;
69119 +}
69120 +
69121 +#define FOR_EACH_ROLE_START(role) \
69122 + role = role_list; \
69123 + while (role) {
69124 +
69125 +#define FOR_EACH_ROLE_END(role) \
69126 + role = role->prev; \
69127 + }
69128 +
69129 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69130 + subj = NULL; \
69131 + iter = 0; \
69132 + while (iter < role->subj_hash_size) { \
69133 + if (subj == NULL) \
69134 + subj = role->subj_hash[iter]; \
69135 + if (subj == NULL) { \
69136 + iter++; \
69137 + continue; \
69138 + }
69139 +
69140 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69141 + subj = subj->next; \
69142 + if (subj == NULL) \
69143 + iter++; \
69144 + }
69145 +
69146 +
69147 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69148 + subj = role->hash->first; \
69149 + while (subj != NULL) {
69150 +
69151 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69152 + subj = subj->next; \
69153 + }
69154 +
69155 +#endif
69156 +
69157 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69158 new file mode 100644
69159 index 0000000..323ecf2
69160 --- /dev/null
69161 +++ b/include/linux/gralloc.h
69162 @@ -0,0 +1,9 @@
69163 +#ifndef __GRALLOC_H
69164 +#define __GRALLOC_H
69165 +
69166 +void acl_free_all(void);
69167 +int acl_alloc_stack_init(unsigned long size);
69168 +void *acl_alloc(unsigned long len);
69169 +void *acl_alloc_num(unsigned long num, unsigned long len);
69170 +
69171 +#endif
69172 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69173 new file mode 100644
69174 index 0000000..be66033
69175 --- /dev/null
69176 +++ b/include/linux/grdefs.h
69177 @@ -0,0 +1,140 @@
69178 +#ifndef GRDEFS_H
69179 +#define GRDEFS_H
69180 +
69181 +/* Begin grsecurity status declarations */
69182 +
69183 +enum {
69184 + GR_READY = 0x01,
69185 + GR_STATUS_INIT = 0x00 // disabled state
69186 +};
69187 +
69188 +/* Begin ACL declarations */
69189 +
69190 +/* Role flags */
69191 +
69192 +enum {
69193 + GR_ROLE_USER = 0x0001,
69194 + GR_ROLE_GROUP = 0x0002,
69195 + GR_ROLE_DEFAULT = 0x0004,
69196 + GR_ROLE_SPECIAL = 0x0008,
69197 + GR_ROLE_AUTH = 0x0010,
69198 + GR_ROLE_NOPW = 0x0020,
69199 + GR_ROLE_GOD = 0x0040,
69200 + GR_ROLE_LEARN = 0x0080,
69201 + GR_ROLE_TPE = 0x0100,
69202 + GR_ROLE_DOMAIN = 0x0200,
69203 + GR_ROLE_PAM = 0x0400,
69204 + GR_ROLE_PERSIST = 0x0800
69205 +};
69206 +
69207 +/* ACL Subject and Object mode flags */
69208 +enum {
69209 + GR_DELETED = 0x80000000
69210 +};
69211 +
69212 +/* ACL Object-only mode flags */
69213 +enum {
69214 + GR_READ = 0x00000001,
69215 + GR_APPEND = 0x00000002,
69216 + GR_WRITE = 0x00000004,
69217 + GR_EXEC = 0x00000008,
69218 + GR_FIND = 0x00000010,
69219 + GR_INHERIT = 0x00000020,
69220 + GR_SETID = 0x00000040,
69221 + GR_CREATE = 0x00000080,
69222 + GR_DELETE = 0x00000100,
69223 + GR_LINK = 0x00000200,
69224 + GR_AUDIT_READ = 0x00000400,
69225 + GR_AUDIT_APPEND = 0x00000800,
69226 + GR_AUDIT_WRITE = 0x00001000,
69227 + GR_AUDIT_EXEC = 0x00002000,
69228 + GR_AUDIT_FIND = 0x00004000,
69229 + GR_AUDIT_INHERIT= 0x00008000,
69230 + GR_AUDIT_SETID = 0x00010000,
69231 + GR_AUDIT_CREATE = 0x00020000,
69232 + GR_AUDIT_DELETE = 0x00040000,
69233 + GR_AUDIT_LINK = 0x00080000,
69234 + GR_PTRACERD = 0x00100000,
69235 + GR_NOPTRACE = 0x00200000,
69236 + GR_SUPPRESS = 0x00400000,
69237 + GR_NOLEARN = 0x00800000,
69238 + GR_INIT_TRANSFER= 0x01000000
69239 +};
69240 +
69241 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69242 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69243 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69244 +
69245 +/* ACL subject-only mode flags */
69246 +enum {
69247 + GR_KILL = 0x00000001,
69248 + GR_VIEW = 0x00000002,
69249 + GR_PROTECTED = 0x00000004,
69250 + GR_LEARN = 0x00000008,
69251 + GR_OVERRIDE = 0x00000010,
69252 + /* just a placeholder, this mode is only used in userspace */
69253 + GR_DUMMY = 0x00000020,
69254 + GR_PROTSHM = 0x00000040,
69255 + GR_KILLPROC = 0x00000080,
69256 + GR_KILLIPPROC = 0x00000100,
69257 + /* just a placeholder, this mode is only used in userspace */
69258 + GR_NOTROJAN = 0x00000200,
69259 + GR_PROTPROCFD = 0x00000400,
69260 + GR_PROCACCT = 0x00000800,
69261 + GR_RELAXPTRACE = 0x00001000,
69262 + //GR_NESTED = 0x00002000,
69263 + GR_INHERITLEARN = 0x00004000,
69264 + GR_PROCFIND = 0x00008000,
69265 + GR_POVERRIDE = 0x00010000,
69266 + GR_KERNELAUTH = 0x00020000,
69267 + GR_ATSECURE = 0x00040000,
69268 + GR_SHMEXEC = 0x00080000
69269 +};
69270 +
69271 +enum {
69272 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69273 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69274 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69275 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69276 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69277 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69278 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69279 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69280 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69281 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69282 +};
69283 +
69284 +enum {
69285 + GR_ID_USER = 0x01,
69286 + GR_ID_GROUP = 0x02,
69287 +};
69288 +
69289 +enum {
69290 + GR_ID_ALLOW = 0x01,
69291 + GR_ID_DENY = 0x02,
69292 +};
69293 +
69294 +#define GR_CRASH_RES 31
69295 +#define GR_UIDTABLE_MAX 500
69296 +
69297 +/* begin resource learning section */
69298 +enum {
69299 + GR_RLIM_CPU_BUMP = 60,
69300 + GR_RLIM_FSIZE_BUMP = 50000,
69301 + GR_RLIM_DATA_BUMP = 10000,
69302 + GR_RLIM_STACK_BUMP = 1000,
69303 + GR_RLIM_CORE_BUMP = 10000,
69304 + GR_RLIM_RSS_BUMP = 500000,
69305 + GR_RLIM_NPROC_BUMP = 1,
69306 + GR_RLIM_NOFILE_BUMP = 5,
69307 + GR_RLIM_MEMLOCK_BUMP = 50000,
69308 + GR_RLIM_AS_BUMP = 500000,
69309 + GR_RLIM_LOCKS_BUMP = 2,
69310 + GR_RLIM_SIGPENDING_BUMP = 5,
69311 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69312 + GR_RLIM_NICE_BUMP = 1,
69313 + GR_RLIM_RTPRIO_BUMP = 1,
69314 + GR_RLIM_RTTIME_BUMP = 1000000
69315 +};
69316 +
69317 +#endif
69318 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69319 new file mode 100644
69320 index 0000000..12994b5
69321 --- /dev/null
69322 +++ b/include/linux/grinternal.h
69323 @@ -0,0 +1,227 @@
69324 +#ifndef __GRINTERNAL_H
69325 +#define __GRINTERNAL_H
69326 +
69327 +#ifdef CONFIG_GRKERNSEC
69328 +
69329 +#include <linux/fs.h>
69330 +#include <linux/mnt_namespace.h>
69331 +#include <linux/nsproxy.h>
69332 +#include <linux/gracl.h>
69333 +#include <linux/grdefs.h>
69334 +#include <linux/grmsg.h>
69335 +
69336 +void gr_add_learn_entry(const char *fmt, ...)
69337 + __attribute__ ((format (printf, 1, 2)));
69338 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69339 + const struct vfsmount *mnt);
69340 +__u32 gr_check_create(const struct dentry *new_dentry,
69341 + const struct dentry *parent,
69342 + const struct vfsmount *mnt, const __u32 mode);
69343 +int gr_check_protected_task(const struct task_struct *task);
69344 +__u32 to_gr_audit(const __u32 reqmode);
69345 +int gr_set_acls(const int type);
69346 +int gr_apply_subject_to_task(struct task_struct *task);
69347 +int gr_acl_is_enabled(void);
69348 +char gr_roletype_to_char(void);
69349 +
69350 +void gr_handle_alertkill(struct task_struct *task);
69351 +char *gr_to_filename(const struct dentry *dentry,
69352 + const struct vfsmount *mnt);
69353 +char *gr_to_filename1(const struct dentry *dentry,
69354 + const struct vfsmount *mnt);
69355 +char *gr_to_filename2(const struct dentry *dentry,
69356 + const struct vfsmount *mnt);
69357 +char *gr_to_filename3(const struct dentry *dentry,
69358 + const struct vfsmount *mnt);
69359 +
69360 +extern int grsec_enable_ptrace_readexec;
69361 +extern int grsec_enable_harden_ptrace;
69362 +extern int grsec_enable_link;
69363 +extern int grsec_enable_fifo;
69364 +extern int grsec_enable_execve;
69365 +extern int grsec_enable_shm;
69366 +extern int grsec_enable_execlog;
69367 +extern int grsec_enable_signal;
69368 +extern int grsec_enable_audit_ptrace;
69369 +extern int grsec_enable_forkfail;
69370 +extern int grsec_enable_time;
69371 +extern int grsec_enable_rofs;
69372 +extern int grsec_enable_chroot_shmat;
69373 +extern int grsec_enable_chroot_mount;
69374 +extern int grsec_enable_chroot_double;
69375 +extern int grsec_enable_chroot_pivot;
69376 +extern int grsec_enable_chroot_chdir;
69377 +extern int grsec_enable_chroot_chmod;
69378 +extern int grsec_enable_chroot_mknod;
69379 +extern int grsec_enable_chroot_fchdir;
69380 +extern int grsec_enable_chroot_nice;
69381 +extern int grsec_enable_chroot_execlog;
69382 +extern int grsec_enable_chroot_caps;
69383 +extern int grsec_enable_chroot_sysctl;
69384 +extern int grsec_enable_chroot_unix;
69385 +extern int grsec_enable_symlinkown;
69386 +extern kgid_t grsec_symlinkown_gid;
69387 +extern int grsec_enable_tpe;
69388 +extern kgid_t grsec_tpe_gid;
69389 +extern int grsec_enable_tpe_all;
69390 +extern int grsec_enable_tpe_invert;
69391 +extern int grsec_enable_socket_all;
69392 +extern kgid_t grsec_socket_all_gid;
69393 +extern int grsec_enable_socket_client;
69394 +extern kgid_t grsec_socket_client_gid;
69395 +extern int grsec_enable_socket_server;
69396 +extern kgid_t grsec_socket_server_gid;
69397 +extern kgid_t grsec_audit_gid;
69398 +extern int grsec_enable_group;
69399 +extern int grsec_enable_audit_textrel;
69400 +extern int grsec_enable_log_rwxmaps;
69401 +extern int grsec_enable_mount;
69402 +extern int grsec_enable_chdir;
69403 +extern int grsec_resource_logging;
69404 +extern int grsec_enable_blackhole;
69405 +extern int grsec_lastack_retries;
69406 +extern int grsec_enable_brute;
69407 +extern int grsec_lock;
69408 +
69409 +extern spinlock_t grsec_alert_lock;
69410 +extern unsigned long grsec_alert_wtime;
69411 +extern unsigned long grsec_alert_fyet;
69412 +
69413 +extern spinlock_t grsec_audit_lock;
69414 +
69415 +extern rwlock_t grsec_exec_file_lock;
69416 +
69417 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69418 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69419 + (tsk)->exec_file->f_path.mnt) : "/")
69420 +
69421 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69422 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69423 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69424 +
69425 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69426 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69427 + (tsk)->exec_file->f_path.mnt) : "/")
69428 +
69429 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69430 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69431 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69432 +
69433 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69434 +
69435 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69436 +
69437 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
69438 +{
69439 + if (file1 && file2) {
69440 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
69441 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
69442 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
69443 + return true;
69444 + }
69445 +
69446 + return false;
69447 +}
69448 +
69449 +#define GR_CHROOT_CAPS {{ \
69450 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69451 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69452 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69453 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69454 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69455 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69456 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69457 +
69458 +#define security_learn(normal_msg,args...) \
69459 +({ \
69460 + read_lock(&grsec_exec_file_lock); \
69461 + gr_add_learn_entry(normal_msg "\n", ## args); \
69462 + read_unlock(&grsec_exec_file_lock); \
69463 +})
69464 +
69465 +enum {
69466 + GR_DO_AUDIT,
69467 + GR_DONT_AUDIT,
69468 + /* used for non-audit messages that we shouldn't kill the task on */
69469 + GR_DONT_AUDIT_GOOD
69470 +};
69471 +
69472 +enum {
69473 + GR_TTYSNIFF,
69474 + GR_RBAC,
69475 + GR_RBAC_STR,
69476 + GR_STR_RBAC,
69477 + GR_RBAC_MODE2,
69478 + GR_RBAC_MODE3,
69479 + GR_FILENAME,
69480 + GR_SYSCTL_HIDDEN,
69481 + GR_NOARGS,
69482 + GR_ONE_INT,
69483 + GR_ONE_INT_TWO_STR,
69484 + GR_ONE_STR,
69485 + GR_STR_INT,
69486 + GR_TWO_STR_INT,
69487 + GR_TWO_INT,
69488 + GR_TWO_U64,
69489 + GR_THREE_INT,
69490 + GR_FIVE_INT_TWO_STR,
69491 + GR_TWO_STR,
69492 + GR_THREE_STR,
69493 + GR_FOUR_STR,
69494 + GR_STR_FILENAME,
69495 + GR_FILENAME_STR,
69496 + GR_FILENAME_TWO_INT,
69497 + GR_FILENAME_TWO_INT_STR,
69498 + GR_TEXTREL,
69499 + GR_PTRACE,
69500 + GR_RESOURCE,
69501 + GR_CAP,
69502 + GR_SIG,
69503 + GR_SIG2,
69504 + GR_CRASH1,
69505 + GR_CRASH2,
69506 + GR_PSACCT,
69507 + GR_RWXMAP
69508 +};
69509 +
69510 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69511 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69512 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69513 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69514 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69515 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69516 +#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)
69517 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69518 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69519 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69520 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69521 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69522 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69523 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69524 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69525 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69526 +#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)
69527 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69528 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69529 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69530 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69531 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69532 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69533 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69534 +#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)
69535 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69536 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69537 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69538 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69539 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69540 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69541 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69542 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69543 +#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)
69544 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69545 +
69546 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69547 +
69548 +#endif
69549 +
69550 +#endif
69551 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69552 new file mode 100644
69553 index 0000000..2f159b5
69554 --- /dev/null
69555 +++ b/include/linux/grmsg.h
69556 @@ -0,0 +1,112 @@
69557 +#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"
69558 +#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"
69559 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69560 +#define GR_STOPMOD_MSG "denied modification of module state by "
69561 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69562 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69563 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69564 +#define GR_IOPL_MSG "denied use of iopl() by "
69565 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69566 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69567 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69568 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69569 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69570 +#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"
69571 +#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"
69572 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69573 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69574 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69575 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69576 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69577 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69578 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69579 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69580 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69581 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69582 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69583 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69584 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69585 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69586 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69587 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69588 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69589 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69590 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69591 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69592 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69593 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69594 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69595 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69596 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69597 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69598 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69599 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69600 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69601 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69602 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69603 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69604 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69605 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69606 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69607 +#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"
69608 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69609 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69610 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69611 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69612 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69613 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69614 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69615 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69616 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69617 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69618 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69619 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69620 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69621 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69622 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69623 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69624 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69625 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69626 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69627 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69628 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69629 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69630 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69631 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69632 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69633 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69634 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69635 +#define GR_TIME_MSG "time set by "
69636 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69637 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69638 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69639 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69640 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69641 +#define GR_BIND_MSG "denied bind() by "
69642 +#define GR_CONNECT_MSG "denied connect() by "
69643 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69644 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69645 +#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"
69646 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69647 +#define GR_CAP_ACL_MSG "use of %s denied for "
69648 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69649 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69650 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69651 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69652 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69653 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69654 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69655 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69656 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69657 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69658 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69659 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69660 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69661 +#define GR_VM86_MSG "denied use of vm86 by "
69662 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69663 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69664 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69665 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69666 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69667 +#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 "
69668 +#define GR_BRUTE_SUID_MSG "bruteforce prevention initiated due to crash of %.950s against uid %u, banning suid/sgid execs for %u minutes. Please investigate the crash report for "
69669 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69670 new file mode 100644
69671 index 0000000..d957f6d
69672 --- /dev/null
69673 +++ b/include/linux/grsecurity.h
69674 @@ -0,0 +1,241 @@
69675 +#ifndef GR_SECURITY_H
69676 +#define GR_SECURITY_H
69677 +#include <linux/fs.h>
69678 +#include <linux/fs_struct.h>
69679 +#include <linux/binfmts.h>
69680 +#include <linux/gracl.h>
69681 +
69682 +/* notify of brain-dead configs */
69683 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69684 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69685 +#endif
69686 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69687 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69688 +#endif
69689 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69690 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69691 +#endif
69692 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69693 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69694 +#endif
69695 +
69696 +void gr_handle_brute_attach(unsigned long mm_flags);
69697 +void gr_handle_brute_check(void);
69698 +void gr_handle_kernel_exploit(void);
69699 +
69700 +char gr_roletype_to_char(void);
69701 +
69702 +int gr_acl_enable_at_secure(void);
69703 +
69704 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69705 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69706 +
69707 +void gr_del_task_from_ip_table(struct task_struct *p);
69708 +
69709 +int gr_pid_is_chrooted(struct task_struct *p);
69710 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69711 +int gr_handle_chroot_nice(void);
69712 +int gr_handle_chroot_sysctl(const int op);
69713 +int gr_handle_chroot_setpriority(struct task_struct *p,
69714 + const int niceval);
69715 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69716 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69717 + const struct vfsmount *mnt);
69718 +void gr_handle_chroot_chdir(const struct path *path);
69719 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69720 + const struct vfsmount *mnt, const int mode);
69721 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69722 + const struct vfsmount *mnt, const int mode);
69723 +int gr_handle_chroot_mount(const struct dentry *dentry,
69724 + const struct vfsmount *mnt,
69725 + const char *dev_name);
69726 +int gr_handle_chroot_pivot(void);
69727 +int gr_handle_chroot_unix(const pid_t pid);
69728 +
69729 +int gr_handle_rawio(const struct inode *inode);
69730 +
69731 +void gr_handle_ioperm(void);
69732 +void gr_handle_iopl(void);
69733 +
69734 +umode_t gr_acl_umask(void);
69735 +
69736 +int gr_tpe_allow(const struct file *file);
69737 +
69738 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69739 +void gr_clear_chroot_entries(struct task_struct *task);
69740 +
69741 +void gr_log_forkfail(const int retval);
69742 +void gr_log_timechange(void);
69743 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69744 +void gr_log_chdir(const struct dentry *dentry,
69745 + const struct vfsmount *mnt);
69746 +void gr_log_chroot_exec(const struct dentry *dentry,
69747 + const struct vfsmount *mnt);
69748 +void gr_log_remount(const char *devname, const int retval);
69749 +void gr_log_unmount(const char *devname, const int retval);
69750 +void gr_log_mount(const char *from, const char *to, const int retval);
69751 +void gr_log_textrel(struct vm_area_struct *vma);
69752 +void gr_log_rwxmmap(struct file *file);
69753 +void gr_log_rwxmprotect(struct file *file);
69754 +
69755 +int gr_handle_follow_link(const struct inode *parent,
69756 + const struct inode *inode,
69757 + const struct dentry *dentry,
69758 + const struct vfsmount *mnt);
69759 +int gr_handle_fifo(const struct dentry *dentry,
69760 + const struct vfsmount *mnt,
69761 + const struct dentry *dir, const int flag,
69762 + const int acc_mode);
69763 +int gr_handle_hardlink(const struct dentry *dentry,
69764 + const struct vfsmount *mnt,
69765 + struct inode *inode,
69766 + const int mode, const struct filename *to);
69767 +
69768 +int gr_is_capable(const int cap);
69769 +int gr_is_capable_nolog(const int cap);
69770 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69771 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69772 +
69773 +void gr_copy_label(struct task_struct *tsk);
69774 +void gr_handle_crash(struct task_struct *task, const int sig);
69775 +int gr_handle_signal(const struct task_struct *p, const int sig);
69776 +int gr_check_crash_uid(const kuid_t uid);
69777 +int gr_check_protected_task(const struct task_struct *task);
69778 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69779 +int gr_acl_handle_mmap(const struct file *file,
69780 + const unsigned long prot);
69781 +int gr_acl_handle_mprotect(const struct file *file,
69782 + const unsigned long prot);
69783 +int gr_check_hidden_task(const struct task_struct *tsk);
69784 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69785 + const struct vfsmount *mnt);
69786 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69787 + const struct vfsmount *mnt);
69788 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69789 + const struct vfsmount *mnt, const int fmode);
69790 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69791 + const struct vfsmount *mnt, umode_t *mode);
69792 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69793 + const struct vfsmount *mnt);
69794 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69795 + const struct vfsmount *mnt);
69796 +int gr_handle_ptrace(struct task_struct *task, const long request);
69797 +int gr_handle_proc_ptrace(struct task_struct *task);
69798 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69799 + const struct vfsmount *mnt);
69800 +int gr_check_crash_exec(const struct file *filp);
69801 +int gr_acl_is_enabled(void);
69802 +void gr_set_kernel_label(struct task_struct *task);
69803 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69804 + const kgid_t gid);
69805 +int gr_set_proc_label(const struct dentry *dentry,
69806 + const struct vfsmount *mnt,
69807 + const int unsafe_flags);
69808 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69809 + const struct vfsmount *mnt);
69810 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69811 + const struct vfsmount *mnt, int acc_mode);
69812 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69813 + const struct dentry *p_dentry,
69814 + const struct vfsmount *p_mnt,
69815 + int open_flags, int acc_mode, const int imode);
69816 +void gr_handle_create(const struct dentry *dentry,
69817 + const struct vfsmount *mnt);
69818 +void gr_handle_proc_create(const struct dentry *dentry,
69819 + const struct inode *inode);
69820 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69821 + const struct dentry *parent_dentry,
69822 + const struct vfsmount *parent_mnt,
69823 + const int mode);
69824 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69825 + const struct dentry *parent_dentry,
69826 + const struct vfsmount *parent_mnt);
69827 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69828 + const struct vfsmount *mnt);
69829 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69830 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69831 + const struct vfsmount *mnt);
69832 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69833 + const struct dentry *parent_dentry,
69834 + const struct vfsmount *parent_mnt,
69835 + const struct filename *from);
69836 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69837 + const struct dentry *parent_dentry,
69838 + const struct vfsmount *parent_mnt,
69839 + const struct dentry *old_dentry,
69840 + const struct vfsmount *old_mnt, const struct filename *to);
69841 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69842 +int gr_acl_handle_rename(struct dentry *new_dentry,
69843 + struct dentry *parent_dentry,
69844 + const struct vfsmount *parent_mnt,
69845 + struct dentry *old_dentry,
69846 + struct inode *old_parent_inode,
69847 + struct vfsmount *old_mnt, const struct filename *newname);
69848 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69849 + struct dentry *old_dentry,
69850 + struct dentry *new_dentry,
69851 + struct vfsmount *mnt, const __u8 replace);
69852 +__u32 gr_check_link(const struct dentry *new_dentry,
69853 + const struct dentry *parent_dentry,
69854 + const struct vfsmount *parent_mnt,
69855 + const struct dentry *old_dentry,
69856 + const struct vfsmount *old_mnt);
69857 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69858 + const unsigned int namelen, const ino_t ino);
69859 +
69860 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69861 + const struct vfsmount *mnt);
69862 +void gr_acl_handle_exit(void);
69863 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69864 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69865 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69866 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69867 +void gr_audit_ptrace(struct task_struct *task);
69868 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69869 +void gr_put_exec_file(struct task_struct *task);
69870 +
69871 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69872 +
69873 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69874 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69875 + const unsigned long wanted, const int gt);
69876 +#else
69877 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69878 + const unsigned long wanted, const int gt)
69879 +{
69880 +}
69881 +#endif
69882 +
69883 +#ifdef CONFIG_GRKERNSEC_RESLOG
69884 +extern void gr_log_resource(const struct task_struct *task, const int res,
69885 + const unsigned long wanted, const int gt);
69886 +#else
69887 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69888 + const unsigned long wanted, const int gt)
69889 +{
69890 +}
69891 +#endif
69892 +
69893 +#ifdef CONFIG_GRKERNSEC
69894 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69895 +void gr_handle_vm86(void);
69896 +void gr_handle_mem_readwrite(u64 from, u64 to);
69897 +
69898 +void gr_log_badprocpid(const char *entry);
69899 +
69900 +extern int grsec_enable_dmesg;
69901 +extern int grsec_disable_privio;
69902 +
69903 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69904 +extern kgid_t grsec_proc_gid;
69905 +#endif
69906 +
69907 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69908 +extern int grsec_enable_chroot_findtask;
69909 +#endif
69910 +#ifdef CONFIG_GRKERNSEC_SETXID
69911 +extern int grsec_enable_setxid;
69912 +#endif
69913 +#endif
69914 +
69915 +#endif
69916 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69917 new file mode 100644
69918 index 0000000..e7ffaaf
69919 --- /dev/null
69920 +++ b/include/linux/grsock.h
69921 @@ -0,0 +1,19 @@
69922 +#ifndef __GRSOCK_H
69923 +#define __GRSOCK_H
69924 +
69925 +extern void gr_attach_curr_ip(const struct sock *sk);
69926 +extern int gr_handle_sock_all(const int family, const int type,
69927 + const int protocol);
69928 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69929 +extern int gr_handle_sock_server_other(const struct sock *sck);
69930 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69931 +extern int gr_search_connect(struct socket * sock,
69932 + struct sockaddr_in * addr);
69933 +extern int gr_search_bind(struct socket * sock,
69934 + struct sockaddr_in * addr);
69935 +extern int gr_search_listen(struct socket * sock);
69936 +extern int gr_search_accept(struct socket * sock);
69937 +extern int gr_search_socket(const int domain, const int type,
69938 + const int protocol);
69939 +
69940 +#endif
69941 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69942 index 7fb31da..08b5114 100644
69943 --- a/include/linux/highmem.h
69944 +++ b/include/linux/highmem.h
69945 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69946 kunmap_atomic(kaddr);
69947 }
69948
69949 +static inline void sanitize_highpage(struct page *page)
69950 +{
69951 + void *kaddr;
69952 + unsigned long flags;
69953 +
69954 + local_irq_save(flags);
69955 + kaddr = kmap_atomic(page);
69956 + clear_page(kaddr);
69957 + kunmap_atomic(kaddr);
69958 + local_irq_restore(flags);
69959 +}
69960 +
69961 static inline void zero_user_segments(struct page *page,
69962 unsigned start1, unsigned end1,
69963 unsigned start2, unsigned end2)
69964 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69965 index 1c7b89a..7f52502 100644
69966 --- a/include/linux/hwmon-sysfs.h
69967 +++ b/include/linux/hwmon-sysfs.h
69968 @@ -25,7 +25,8 @@
69969 struct sensor_device_attribute{
69970 struct device_attribute dev_attr;
69971 int index;
69972 -};
69973 +} __do_const;
69974 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69975 #define to_sensor_dev_attr(_dev_attr) \
69976 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69977
69978 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69979 struct device_attribute dev_attr;
69980 u8 index;
69981 u8 nr;
69982 -};
69983 +} __do_const;
69984 #define to_sensor_dev_attr_2(_dev_attr) \
69985 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69986
69987 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69988 index e988fa9..ff9f17e 100644
69989 --- a/include/linux/i2c.h
69990 +++ b/include/linux/i2c.h
69991 @@ -366,6 +366,7 @@ struct i2c_algorithm {
69992 /* To determine what the adapter supports */
69993 u32 (*functionality) (struct i2c_adapter *);
69994 };
69995 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69996
69997 /**
69998 * struct i2c_bus_recovery_info - I2C bus recovery information
69999 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
70000 index d23c3c2..eb63c81 100644
70001 --- a/include/linux/i2o.h
70002 +++ b/include/linux/i2o.h
70003 @@ -565,7 +565,7 @@ struct i2o_controller {
70004 struct i2o_device *exec; /* Executive */
70005 #if BITS_PER_LONG == 64
70006 spinlock_t context_list_lock; /* lock for context_list */
70007 - atomic_t context_list_counter; /* needed for unique contexts */
70008 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
70009 struct list_head context_list; /* list of context id's
70010 and pointers */
70011 #endif
70012 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
70013 index aff7ad8..3942bbd 100644
70014 --- a/include/linux/if_pppox.h
70015 +++ b/include/linux/if_pppox.h
70016 @@ -76,7 +76,7 @@ struct pppox_proto {
70017 int (*ioctl)(struct socket *sock, unsigned int cmd,
70018 unsigned long arg);
70019 struct module *owner;
70020 -};
70021 +} __do_const;
70022
70023 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
70024 extern void unregister_pppox_proto(int proto_num);
70025 diff --git a/include/linux/init.h b/include/linux/init.h
70026 index 8618147..0821126 100644
70027 --- a/include/linux/init.h
70028 +++ b/include/linux/init.h
70029 @@ -39,9 +39,36 @@
70030 * Also note, that this data cannot be "const".
70031 */
70032
70033 +#ifdef MODULE
70034 +#define add_init_latent_entropy
70035 +#define add_devinit_latent_entropy
70036 +#define add_cpuinit_latent_entropy
70037 +#define add_meminit_latent_entropy
70038 +#else
70039 +#define add_init_latent_entropy __latent_entropy
70040 +
70041 +#ifdef CONFIG_HOTPLUG
70042 +#define add_devinit_latent_entropy
70043 +#else
70044 +#define add_devinit_latent_entropy __latent_entropy
70045 +#endif
70046 +
70047 +#ifdef CONFIG_HOTPLUG_CPU
70048 +#define add_cpuinit_latent_entropy
70049 +#else
70050 +#define add_cpuinit_latent_entropy __latent_entropy
70051 +#endif
70052 +
70053 +#ifdef CONFIG_MEMORY_HOTPLUG
70054 +#define add_meminit_latent_entropy
70055 +#else
70056 +#define add_meminit_latent_entropy __latent_entropy
70057 +#endif
70058 +#endif
70059 +
70060 /* These are for everybody (although not all archs will actually
70061 discard it in modules) */
70062 -#define __init __section(.init.text) __cold notrace
70063 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
70064 #define __initdata __section(.init.data)
70065 #define __initconst __constsection(.init.rodata)
70066 #define __exitdata __section(.exit.data)
70067 @@ -94,7 +121,7 @@
70068 #define __exit __section(.exit.text) __exitused __cold notrace
70069
70070 /* Used for HOTPLUG_CPU */
70071 -#define __cpuinit __section(.cpuinit.text) __cold notrace
70072 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
70073 #define __cpuinitdata __section(.cpuinit.data)
70074 #define __cpuinitconst __constsection(.cpuinit.rodata)
70075 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
70076 @@ -102,7 +129,7 @@
70077 #define __cpuexitconst __constsection(.cpuexit.rodata)
70078
70079 /* Used for MEMORY_HOTPLUG */
70080 -#define __meminit __section(.meminit.text) __cold notrace
70081 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
70082 #define __meminitdata __section(.meminit.data)
70083 #define __meminitconst __constsection(.meminit.rodata)
70084 #define __memexit __section(.memexit.text) __exitused __cold notrace
70085 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
70086 index 5cd0f09..c9f67cc 100644
70087 --- a/include/linux/init_task.h
70088 +++ b/include/linux/init_task.h
70089 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
70090
70091 #define INIT_TASK_COMM "swapper"
70092
70093 +#ifdef CONFIG_X86
70094 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
70095 +#else
70096 +#define INIT_TASK_THREAD_INFO
70097 +#endif
70098 +
70099 /*
70100 * INIT_TASK is used to set up the first task table, touch at
70101 * your own risk!. Base=0, limit=0x1fffff (=2MB)
70102 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
70103 RCU_POINTER_INITIALIZER(cred, &init_cred), \
70104 .comm = INIT_TASK_COMM, \
70105 .thread = INIT_THREAD, \
70106 + INIT_TASK_THREAD_INFO \
70107 .fs = &init_fs, \
70108 .files = &init_files, \
70109 .signal = &init_signals, \
70110 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
70111 index 5fa5afe..ac55b25 100644
70112 --- a/include/linux/interrupt.h
70113 +++ b/include/linux/interrupt.h
70114 @@ -430,7 +430,7 @@ enum
70115 /* map softirq index to softirq name. update 'softirq_to_name' in
70116 * kernel/softirq.c when adding a new softirq.
70117 */
70118 -extern char *softirq_to_name[NR_SOFTIRQS];
70119 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70120
70121 /* softirq mask and active fields moved to irq_cpustat_t in
70122 * asm/hardirq.h to get better cache usage. KAO
70123 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70124
70125 struct softirq_action
70126 {
70127 - void (*action)(struct softirq_action *);
70128 -};
70129 + void (*action)(void);
70130 +} __no_const;
70131
70132 asmlinkage void do_softirq(void);
70133 asmlinkage void __do_softirq(void);
70134 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70135 +extern void open_softirq(int nr, void (*action)(void));
70136 extern void softirq_init(void);
70137 extern void __raise_softirq_irqoff(unsigned int nr);
70138
70139 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70140 index 3aeb730..2177f39 100644
70141 --- a/include/linux/iommu.h
70142 +++ b/include/linux/iommu.h
70143 @@ -113,7 +113,7 @@ struct iommu_ops {
70144 u32 (*domain_get_windows)(struct iommu_domain *domain);
70145
70146 unsigned long pgsize_bitmap;
70147 -};
70148 +} __do_const;
70149
70150 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70151 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70152 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70153 index 89b7c24..382af74 100644
70154 --- a/include/linux/ioport.h
70155 +++ b/include/linux/ioport.h
70156 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70157 int adjust_resource(struct resource *res, resource_size_t start,
70158 resource_size_t size);
70159 resource_size_t resource_alignment(struct resource *res);
70160 -static inline resource_size_t resource_size(const struct resource *res)
70161 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70162 {
70163 return res->end - res->start + 1;
70164 }
70165 diff --git a/include/linux/irq.h b/include/linux/irq.h
70166 index bc4e066..50468a9 100644
70167 --- a/include/linux/irq.h
70168 +++ b/include/linux/irq.h
70169 @@ -328,7 +328,8 @@ struct irq_chip {
70170 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70171
70172 unsigned long flags;
70173 -};
70174 +} __do_const;
70175 +typedef struct irq_chip __no_const irq_chip_no_const;
70176
70177 /*
70178 * irq_chip specific flags
70179 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
70180 index 3e203eb..3fe68d0 100644
70181 --- a/include/linux/irqchip/arm-gic.h
70182 +++ b/include/linux/irqchip/arm-gic.h
70183 @@ -59,9 +59,11 @@
70184
70185 #ifndef __ASSEMBLY__
70186
70187 +#include <linux/irq.h>
70188 +
70189 struct device_node;
70190
70191 -extern struct irq_chip gic_arch_extn;
70192 +extern irq_chip_no_const gic_arch_extn;
70193
70194 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
70195 u32 offset, struct device_node *);
70196 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70197 index 6883e19..06992b1 100644
70198 --- a/include/linux/kallsyms.h
70199 +++ b/include/linux/kallsyms.h
70200 @@ -15,7 +15,8 @@
70201
70202 struct module;
70203
70204 -#ifdef CONFIG_KALLSYMS
70205 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70206 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70207 /* Lookup the address for a symbol. Returns 0 if not found. */
70208 unsigned long kallsyms_lookup_name(const char *name);
70209
70210 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70211 /* Stupid that this does nothing, but I didn't create this mess. */
70212 #define __print_symbol(fmt, addr)
70213 #endif /*CONFIG_KALLSYMS*/
70214 +#else /* when included by kallsyms.c, vsnprintf.c, or
70215 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70216 +extern void __print_symbol(const char *fmt, unsigned long address);
70217 +extern int sprint_backtrace(char *buffer, unsigned long address);
70218 +extern int sprint_symbol(char *buffer, unsigned long address);
70219 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70220 +const char *kallsyms_lookup(unsigned long addr,
70221 + unsigned long *symbolsize,
70222 + unsigned long *offset,
70223 + char **modname, char *namebuf);
70224 +#endif
70225
70226 /* This macro allows us to keep printk typechecking */
70227 static __printf(1, 2)
70228 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70229 index 518a53a..5e28358 100644
70230 --- a/include/linux/key-type.h
70231 +++ b/include/linux/key-type.h
70232 @@ -125,7 +125,7 @@ struct key_type {
70233 /* internal fields */
70234 struct list_head link; /* link in types list */
70235 struct lock_class_key lock_class; /* key->sem lock class */
70236 -};
70237 +} __do_const;
70238
70239 extern struct key_type key_type_keyring;
70240
70241 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70242 index c6e091b..a940adf 100644
70243 --- a/include/linux/kgdb.h
70244 +++ b/include/linux/kgdb.h
70245 @@ -52,7 +52,7 @@ extern int kgdb_connected;
70246 extern int kgdb_io_module_registered;
70247
70248 extern atomic_t kgdb_setting_breakpoint;
70249 -extern atomic_t kgdb_cpu_doing_single_step;
70250 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70251
70252 extern struct task_struct *kgdb_usethread;
70253 extern struct task_struct *kgdb_contthread;
70254 @@ -254,7 +254,7 @@ struct kgdb_arch {
70255 void (*correct_hw_break)(void);
70256
70257 void (*enable_nmi)(bool on);
70258 -};
70259 +} __do_const;
70260
70261 /**
70262 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70263 @@ -279,7 +279,7 @@ struct kgdb_io {
70264 void (*pre_exception) (void);
70265 void (*post_exception) (void);
70266 int is_console;
70267 -};
70268 +} __do_const;
70269
70270 extern struct kgdb_arch arch_kgdb_ops;
70271
70272 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70273 index 0555cc6..b16a7a4 100644
70274 --- a/include/linux/kmod.h
70275 +++ b/include/linux/kmod.h
70276 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70277 * usually useless though. */
70278 extern __printf(2, 3)
70279 int __request_module(bool wait, const char *name, ...);
70280 +extern __printf(3, 4)
70281 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70282 #define request_module(mod...) __request_module(true, mod)
70283 #define request_module_nowait(mod...) __request_module(false, mod)
70284 #define try_then_request_module(x, mod...) \
70285 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70286 index 939b112..ed6ed51 100644
70287 --- a/include/linux/kobject.h
70288 +++ b/include/linux/kobject.h
70289 @@ -111,7 +111,7 @@ struct kobj_type {
70290 struct attribute **default_attrs;
70291 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70292 const void *(*namespace)(struct kobject *kobj);
70293 -};
70294 +} __do_const;
70295
70296 struct kobj_uevent_env {
70297 char *envp[UEVENT_NUM_ENVP];
70298 @@ -134,6 +134,7 @@ struct kobj_attribute {
70299 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70300 const char *buf, size_t count);
70301 };
70302 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70303
70304 extern const struct sysfs_ops kobj_sysfs_ops;
70305
70306 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70307 index f66b065..c2c29b4 100644
70308 --- a/include/linux/kobject_ns.h
70309 +++ b/include/linux/kobject_ns.h
70310 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70311 const void *(*netlink_ns)(struct sock *sk);
70312 const void *(*initial_ns)(void);
70313 void (*drop_ns)(void *);
70314 -};
70315 +} __do_const;
70316
70317 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70318 int kobj_ns_type_registered(enum kobj_ns_type type);
70319 diff --git a/include/linux/kref.h b/include/linux/kref.h
70320 index 484604d..0f6c5b6 100644
70321 --- a/include/linux/kref.h
70322 +++ b/include/linux/kref.h
70323 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
70324 static inline int kref_sub(struct kref *kref, unsigned int count,
70325 void (*release)(struct kref *kref))
70326 {
70327 - WARN_ON(release == NULL);
70328 + BUG_ON(release == NULL);
70329
70330 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70331 release(kref);
70332 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70333 index 8db53cf..c21121d 100644
70334 --- a/include/linux/kvm_host.h
70335 +++ b/include/linux/kvm_host.h
70336 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
70337 {
70338 }
70339 #endif
70340 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70341 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70342 struct module *module);
70343 void kvm_exit(void);
70344
70345 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70346 struct kvm_guest_debug *dbg);
70347 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70348
70349 -int kvm_arch_init(void *opaque);
70350 +int kvm_arch_init(const void *opaque);
70351 void kvm_arch_exit(void);
70352
70353 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70354 diff --git a/include/linux/libata.h b/include/linux/libata.h
70355 index eae7a05..2cdd875 100644
70356 --- a/include/linux/libata.h
70357 +++ b/include/linux/libata.h
70358 @@ -919,7 +919,7 @@ struct ata_port_operations {
70359 * fields must be pointers.
70360 */
70361 const struct ata_port_operations *inherits;
70362 -};
70363 +} __do_const;
70364
70365 struct ata_port_info {
70366 unsigned long flags;
70367 diff --git a/include/linux/list.h b/include/linux/list.h
70368 index b83e565..baa6c1d 100644
70369 --- a/include/linux/list.h
70370 +++ b/include/linux/list.h
70371 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70372 extern void list_del(struct list_head *entry);
70373 #endif
70374
70375 +extern void __pax_list_add(struct list_head *new,
70376 + struct list_head *prev,
70377 + struct list_head *next);
70378 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70379 +{
70380 + __pax_list_add(new, head, head->next);
70381 +}
70382 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70383 +{
70384 + __pax_list_add(new, head->prev, head);
70385 +}
70386 +extern void pax_list_del(struct list_head *entry);
70387 +
70388 /**
70389 * list_replace - replace old entry by new one
70390 * @old : the element to be replaced
70391 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70392 INIT_LIST_HEAD(entry);
70393 }
70394
70395 +extern void pax_list_del_init(struct list_head *entry);
70396 +
70397 /**
70398 * list_move - delete from one list and add as another's head
70399 * @list: the entry to move
70400 diff --git a/include/linux/math64.h b/include/linux/math64.h
70401 index 2913b86..4209244 100644
70402 --- a/include/linux/math64.h
70403 +++ b/include/linux/math64.h
70404 @@ -15,7 +15,7 @@
70405 * This is commonly provided by 32bit archs to provide an optimized 64bit
70406 * divide.
70407 */
70408 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70409 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70410 {
70411 *remainder = dividend % divisor;
70412 return dividend / divisor;
70413 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70414 #define div64_ul(x, y) div_u64((x), (y))
70415
70416 #ifndef div_u64_rem
70417 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70418 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70419 {
70420 *remainder = do_div(dividend, divisor);
70421 return dividend;
70422 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70423 * divide.
70424 */
70425 #ifndef div_u64
70426 -static inline u64 div_u64(u64 dividend, u32 divisor)
70427 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70428 {
70429 u32 remainder;
70430 return div_u64_rem(dividend, divisor, &remainder);
70431 diff --git a/include/linux/mm.h b/include/linux/mm.h
70432 index e0c8528..bcf0c29 100644
70433 --- a/include/linux/mm.h
70434 +++ b/include/linux/mm.h
70435 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
70436 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70437 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70438 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70439 +
70440 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70441 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70442 +#endif
70443 +
70444 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70445
70446 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70447 @@ -205,8 +210,8 @@ struct vm_operations_struct {
70448 /* called by access_process_vm when get_user_pages() fails, typically
70449 * for use by special VMAs that can switch between memory and hardware
70450 */
70451 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70452 - void *buf, int len, int write);
70453 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70454 + void *buf, size_t len, int write);
70455 #ifdef CONFIG_NUMA
70456 /*
70457 * set_policy() op must add a reference to any non-NULL @new mempolicy
70458 @@ -236,6 +241,7 @@ struct vm_operations_struct {
70459 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70460 unsigned long size, pgoff_t pgoff);
70461 };
70462 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70463
70464 struct mmu_gather;
70465 struct inode;
70466 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70467 unsigned long *pfn);
70468 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70469 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70470 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70471 - void *buf, int len, int write);
70472 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70473 + void *buf, size_t len, int write);
70474
70475 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70476 loff_t const holebegin, loff_t const holelen)
70477 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70478 }
70479 #endif
70480
70481 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70482 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70483 - void *buf, int len, int write);
70484 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70485 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70486 + void *buf, size_t len, int write);
70487
70488 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70489 unsigned long start, unsigned long nr_pages,
70490 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
70491 int set_page_dirty_lock(struct page *page);
70492 int clear_page_dirty_for_io(struct page *page);
70493
70494 -/* Is the vma a continuation of the stack vma above it? */
70495 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70496 -{
70497 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70498 -}
70499 -
70500 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70501 - unsigned long addr)
70502 -{
70503 - return (vma->vm_flags & VM_GROWSDOWN) &&
70504 - (vma->vm_start == addr) &&
70505 - !vma_growsdown(vma->vm_prev, addr);
70506 -}
70507 -
70508 -/* Is the vma a continuation of the stack vma below it? */
70509 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70510 -{
70511 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70512 -}
70513 -
70514 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70515 - unsigned long addr)
70516 -{
70517 - return (vma->vm_flags & VM_GROWSUP) &&
70518 - (vma->vm_end == addr) &&
70519 - !vma_growsup(vma->vm_next, addr);
70520 -}
70521 -
70522 extern pid_t
70523 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70524
70525 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70526 }
70527 #endif
70528
70529 +#ifdef CONFIG_MMU
70530 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70531 +#else
70532 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70533 +{
70534 + return __pgprot(0);
70535 +}
70536 +#endif
70537 +
70538 int vma_wants_writenotify(struct vm_area_struct *vma);
70539
70540 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70541 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70542 {
70543 return 0;
70544 }
70545 +
70546 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70547 + unsigned long address)
70548 +{
70549 + return 0;
70550 +}
70551 #else
70552 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70553 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70554 #endif
70555
70556 #ifdef __PAGETABLE_PMD_FOLDED
70557 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70558 {
70559 return 0;
70560 }
70561 +
70562 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70563 + unsigned long address)
70564 +{
70565 + return 0;
70566 +}
70567 #else
70568 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70569 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70570 #endif
70571
70572 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70573 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70574 NULL: pud_offset(pgd, address);
70575 }
70576
70577 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70578 +{
70579 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70580 + NULL: pud_offset(pgd, address);
70581 +}
70582 +
70583 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70584 {
70585 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70586 NULL: pmd_offset(pud, address);
70587 }
70588 +
70589 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70590 +{
70591 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70592 + NULL: pmd_offset(pud, address);
70593 +}
70594 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70595
70596 #if USE_SPLIT_PTLOCKS
70597 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70598 unsigned long len, unsigned long prot, unsigned long flags,
70599 unsigned long pgoff, unsigned long *populate);
70600 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70601 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70602
70603 #ifdef CONFIG_MMU
70604 extern int __mm_populate(unsigned long addr, unsigned long len,
70605 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
70606 unsigned long high_limit;
70607 unsigned long align_mask;
70608 unsigned long align_offset;
70609 + unsigned long threadstack_offset;
70610 };
70611
70612 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70613 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70614 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
70615 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
70616
70617 /*
70618 * Search for an unmapped address range.
70619 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70620 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
70621 */
70622 static inline unsigned long
70623 -vm_unmapped_area(struct vm_unmapped_area_info *info)
70624 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
70625 {
70626 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
70627 return unmapped_area(info);
70628 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70629 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70630 struct vm_area_struct **pprev);
70631
70632 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70633 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70634 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70635 +
70636 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70637 NULL if none. Assume start_addr < end_addr. */
70638 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70639 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70640 return vma;
70641 }
70642
70643 -#ifdef CONFIG_MMU
70644 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70645 -#else
70646 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70647 -{
70648 - return __pgprot(0);
70649 -}
70650 -#endif
70651 -
70652 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70653 unsigned long change_prot_numa(struct vm_area_struct *vma,
70654 unsigned long start, unsigned long end);
70655 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70656 static inline void vm_stat_account(struct mm_struct *mm,
70657 unsigned long flags, struct file *file, long pages)
70658 {
70659 +
70660 +#ifdef CONFIG_PAX_RANDMMAP
70661 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70662 +#endif
70663 +
70664 mm->total_vm += pages;
70665 }
70666 #endif /* CONFIG_PROC_FS */
70667 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
70668 extern int sysctl_memory_failure_early_kill;
70669 extern int sysctl_memory_failure_recovery;
70670 extern void shake_page(struct page *p, int access);
70671 -extern atomic_long_t num_poisoned_pages;
70672 +extern atomic_long_unchecked_t num_poisoned_pages;
70673 extern int soft_offline_page(struct page *page, int flags);
70674
70675 extern void dump_page(struct page *page);
70676 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
70677 static inline void setup_nr_node_ids(void) {}
70678 #endif
70679
70680 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70681 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70682 +#else
70683 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70684 +#endif
70685 +
70686 #endif /* __KERNEL__ */
70687 #endif /* _LINUX_MM_H */
70688 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70689 index ace9a5f..81bdb59 100644
70690 --- a/include/linux/mm_types.h
70691 +++ b/include/linux/mm_types.h
70692 @@ -289,6 +289,8 @@ struct vm_area_struct {
70693 #ifdef CONFIG_NUMA
70694 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70695 #endif
70696 +
70697 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70698 };
70699
70700 struct core_thread {
70701 @@ -437,6 +439,24 @@ struct mm_struct {
70702 int first_nid;
70703 #endif
70704 struct uprobes_state uprobes_state;
70705 +
70706 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70707 + unsigned long pax_flags;
70708 +#endif
70709 +
70710 +#ifdef CONFIG_PAX_DLRESOLVE
70711 + unsigned long call_dl_resolve;
70712 +#endif
70713 +
70714 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70715 + unsigned long call_syscall;
70716 +#endif
70717 +
70718 +#ifdef CONFIG_PAX_ASLR
70719 + unsigned long delta_mmap; /* randomized offset */
70720 + unsigned long delta_stack; /* randomized offset */
70721 +#endif
70722 +
70723 };
70724
70725 /* first nid will either be a valid NID or one of these values */
70726 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70727 index c5d5278..f0b68c8 100644
70728 --- a/include/linux/mmiotrace.h
70729 +++ b/include/linux/mmiotrace.h
70730 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70731 /* Called from ioremap.c */
70732 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70733 void __iomem *addr);
70734 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70735 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70736
70737 /* For anyone to insert markers. Remember trailing newline. */
70738 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70739 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70740 {
70741 }
70742
70743 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70744 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70745 {
70746 }
70747
70748 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70749 index 5c76737..61f518e 100644
70750 --- a/include/linux/mmzone.h
70751 +++ b/include/linux/mmzone.h
70752 @@ -396,7 +396,7 @@ struct zone {
70753 unsigned long flags; /* zone flags, see below */
70754
70755 /* Zone statistics */
70756 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70757 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70758
70759 /*
70760 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70761 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70762 index b508016..237cfe5 100644
70763 --- a/include/linux/mod_devicetable.h
70764 +++ b/include/linux/mod_devicetable.h
70765 @@ -13,7 +13,7 @@
70766 typedef unsigned long kernel_ulong_t;
70767 #endif
70768
70769 -#define PCI_ANY_ID (~0)
70770 +#define PCI_ANY_ID ((__u16)~0)
70771
70772 struct pci_device_id {
70773 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70774 @@ -139,7 +139,7 @@ struct usb_device_id {
70775 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70776 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70777
70778 -#define HID_ANY_ID (~0)
70779 +#define HID_ANY_ID (~0U)
70780 #define HID_BUS_ANY 0xffff
70781 #define HID_GROUP_ANY 0x0000
70782
70783 @@ -465,7 +465,7 @@ struct dmi_system_id {
70784 const char *ident;
70785 struct dmi_strmatch matches[4];
70786 void *driver_data;
70787 -};
70788 +} __do_const;
70789 /*
70790 * struct dmi_device_id appears during expansion of
70791 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70792 diff --git a/include/linux/module.h b/include/linux/module.h
70793 index 46f1ea0..a34ca37 100644
70794 --- a/include/linux/module.h
70795 +++ b/include/linux/module.h
70796 @@ -17,9 +17,11 @@
70797 #include <linux/moduleparam.h>
70798 #include <linux/tracepoint.h>
70799 #include <linux/export.h>
70800 +#include <linux/fs.h>
70801
70802 #include <linux/percpu.h>
70803 #include <asm/module.h>
70804 +#include <asm/pgtable.h>
70805
70806 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70807 #define MODULE_SIG_STRING "~Module signature appended~\n"
70808 @@ -54,12 +56,13 @@ struct module_attribute {
70809 int (*test)(struct module *);
70810 void (*free)(struct module *);
70811 };
70812 +typedef struct module_attribute __no_const module_attribute_no_const;
70813
70814 struct module_version_attribute {
70815 struct module_attribute mattr;
70816 const char *module_name;
70817 const char *version;
70818 -} __attribute__ ((__aligned__(sizeof(void *))));
70819 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70820
70821 extern ssize_t __modver_version_show(struct module_attribute *,
70822 struct module_kobject *, char *);
70823 @@ -232,7 +235,7 @@ struct module
70824
70825 /* Sysfs stuff. */
70826 struct module_kobject mkobj;
70827 - struct module_attribute *modinfo_attrs;
70828 + module_attribute_no_const *modinfo_attrs;
70829 const char *version;
70830 const char *srcversion;
70831 struct kobject *holders_dir;
70832 @@ -281,19 +284,16 @@ struct module
70833 int (*init)(void);
70834
70835 /* If this is non-NULL, vfree after init() returns */
70836 - void *module_init;
70837 + void *module_init_rx, *module_init_rw;
70838
70839 /* Here is the actual code + data, vfree'd on unload. */
70840 - void *module_core;
70841 + void *module_core_rx, *module_core_rw;
70842
70843 /* Here are the sizes of the init and core sections */
70844 - unsigned int init_size, core_size;
70845 + unsigned int init_size_rw, core_size_rw;
70846
70847 /* The size of the executable code in each section. */
70848 - unsigned int init_text_size, core_text_size;
70849 -
70850 - /* Size of RO sections of the module (text+rodata) */
70851 - unsigned int init_ro_size, core_ro_size;
70852 + unsigned int init_size_rx, core_size_rx;
70853
70854 /* Arch-specific module values */
70855 struct mod_arch_specific arch;
70856 @@ -349,6 +349,10 @@ struct module
70857 #ifdef CONFIG_EVENT_TRACING
70858 struct ftrace_event_call **trace_events;
70859 unsigned int num_trace_events;
70860 + struct file_operations trace_id;
70861 + struct file_operations trace_enable;
70862 + struct file_operations trace_format;
70863 + struct file_operations trace_filter;
70864 #endif
70865 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70866 unsigned int num_ftrace_callsites;
70867 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70868 bool is_module_percpu_address(unsigned long addr);
70869 bool is_module_text_address(unsigned long addr);
70870
70871 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70872 +{
70873 +
70874 +#ifdef CONFIG_PAX_KERNEXEC
70875 + if (ktla_ktva(addr) >= (unsigned long)start &&
70876 + ktla_ktva(addr) < (unsigned long)start + size)
70877 + return 1;
70878 +#endif
70879 +
70880 + return ((void *)addr >= start && (void *)addr < start + size);
70881 +}
70882 +
70883 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70884 +{
70885 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70886 +}
70887 +
70888 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70889 +{
70890 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70891 +}
70892 +
70893 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70894 +{
70895 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70896 +}
70897 +
70898 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70899 +{
70900 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70901 +}
70902 +
70903 static inline int within_module_core(unsigned long addr, const struct module *mod)
70904 {
70905 - return (unsigned long)mod->module_core <= addr &&
70906 - addr < (unsigned long)mod->module_core + mod->core_size;
70907 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70908 }
70909
70910 static inline int within_module_init(unsigned long addr, const struct module *mod)
70911 {
70912 - return (unsigned long)mod->module_init <= addr &&
70913 - addr < (unsigned long)mod->module_init + mod->init_size;
70914 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70915 }
70916
70917 /* Search for module by name: must hold module_mutex. */
70918 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70919 index 560ca53..ef621ef 100644
70920 --- a/include/linux/moduleloader.h
70921 +++ b/include/linux/moduleloader.h
70922 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70923 sections. Returns NULL on failure. */
70924 void *module_alloc(unsigned long size);
70925
70926 +#ifdef CONFIG_PAX_KERNEXEC
70927 +void *module_alloc_exec(unsigned long size);
70928 +#else
70929 +#define module_alloc_exec(x) module_alloc(x)
70930 +#endif
70931 +
70932 /* Free memory returned from module_alloc. */
70933 void module_free(struct module *mod, void *module_region);
70934
70935 +#ifdef CONFIG_PAX_KERNEXEC
70936 +void module_free_exec(struct module *mod, void *module_region);
70937 +#else
70938 +#define module_free_exec(x, y) module_free((x), (y))
70939 +#endif
70940 +
70941 /*
70942 * Apply the given relocation to the (simplified) ELF. Return -error
70943 * or 0.
70944 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70945 unsigned int relsec,
70946 struct module *me)
70947 {
70948 +#ifdef CONFIG_MODULES
70949 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70950 +#endif
70951 return -ENOEXEC;
70952 }
70953 #endif
70954 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70955 unsigned int relsec,
70956 struct module *me)
70957 {
70958 +#ifdef CONFIG_MODULES
70959 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70960 +#endif
70961 return -ENOEXEC;
70962 }
70963 #endif
70964 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70965 index 137b419..fe663ec 100644
70966 --- a/include/linux/moduleparam.h
70967 +++ b/include/linux/moduleparam.h
70968 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70969 * @len is usually just sizeof(string).
70970 */
70971 #define module_param_string(name, string, len, perm) \
70972 - static const struct kparam_string __param_string_##name \
70973 + static const struct kparam_string __param_string_##name __used \
70974 = { len, string }; \
70975 __module_param_call(MODULE_PARAM_PREFIX, name, \
70976 &param_ops_string, \
70977 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70978 */
70979 #define module_param_array_named(name, array, type, nump, perm) \
70980 param_check_##type(name, &(array)[0]); \
70981 - static const struct kparam_array __param_arr_##name \
70982 + static const struct kparam_array __param_arr_##name __used \
70983 = { .max = ARRAY_SIZE(array), .num = nump, \
70984 .ops = &param_ops_##type, \
70985 .elemsize = sizeof(array[0]), .elem = array }; \
70986 diff --git a/include/linux/namei.h b/include/linux/namei.h
70987 index 5a5ff57..5ae5070 100644
70988 --- a/include/linux/namei.h
70989 +++ b/include/linux/namei.h
70990 @@ -19,7 +19,7 @@ struct nameidata {
70991 unsigned seq;
70992 int last_type;
70993 unsigned depth;
70994 - char *saved_names[MAX_NESTED_LINKS + 1];
70995 + const char *saved_names[MAX_NESTED_LINKS + 1];
70996 };
70997
70998 /*
70999 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
71000
71001 extern void nd_jump_link(struct nameidata *nd, struct path *path);
71002
71003 -static inline void nd_set_link(struct nameidata *nd, char *path)
71004 +static inline void nd_set_link(struct nameidata *nd, const char *path)
71005 {
71006 nd->saved_names[nd->depth] = path;
71007 }
71008
71009 -static inline char *nd_get_link(struct nameidata *nd)
71010 +static inline const char *nd_get_link(const struct nameidata *nd)
71011 {
71012 return nd->saved_names[nd->depth];
71013 }
71014 diff --git a/include/linux/net.h b/include/linux/net.h
71015 index 99c9f0c..e1cf296 100644
71016 --- a/include/linux/net.h
71017 +++ b/include/linux/net.h
71018 @@ -183,7 +183,7 @@ struct net_proto_family {
71019 int (*create)(struct net *net, struct socket *sock,
71020 int protocol, int kern);
71021 struct module *owner;
71022 -};
71023 +} __do_const;
71024
71025 struct iovec;
71026 struct kvec;
71027 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
71028 index 96e4c21..9cc8278 100644
71029 --- a/include/linux/netdevice.h
71030 +++ b/include/linux/netdevice.h
71031 @@ -1026,6 +1026,7 @@ struct net_device_ops {
71032 int (*ndo_change_carrier)(struct net_device *dev,
71033 bool new_carrier);
71034 };
71035 +typedef struct net_device_ops __no_const net_device_ops_no_const;
71036
71037 /*
71038 * The DEVICE structure.
71039 @@ -1094,7 +1095,7 @@ struct net_device {
71040 int iflink;
71041
71042 struct net_device_stats stats;
71043 - atomic_long_t rx_dropped; /* dropped packets by core network
71044 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
71045 * Do not use this in drivers.
71046 */
71047
71048 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
71049 index 0060fde..481c6ae 100644
71050 --- a/include/linux/netfilter.h
71051 +++ b/include/linux/netfilter.h
71052 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
71053 #endif
71054 /* Use the module struct to lock set/get code in place */
71055 struct module *owner;
71056 -};
71057 +} __do_const;
71058
71059 /* Function to register/unregister hook points. */
71060 int nf_register_hook(struct nf_hook_ops *reg);
71061 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
71062 index d80e275..c3510b8 100644
71063 --- a/include/linux/netfilter/ipset/ip_set.h
71064 +++ b/include/linux/netfilter/ipset/ip_set.h
71065 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
71066 /* Return true if "b" set is the same as "a"
71067 * according to the create set parameters */
71068 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
71069 -};
71070 +} __do_const;
71071
71072 /* The core set type structure */
71073 struct ip_set_type {
71074 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
71075 index cadb740..d7c37c0 100644
71076 --- a/include/linux/netfilter/nfnetlink.h
71077 +++ b/include/linux/netfilter/nfnetlink.h
71078 @@ -16,7 +16,7 @@ struct nfnl_callback {
71079 const struct nlattr * const cda[]);
71080 const struct nla_policy *policy; /* netlink attribute policy */
71081 const u_int16_t attr_count; /* number of nlattr's */
71082 -};
71083 +} __do_const;
71084
71085 struct nfnetlink_subsystem {
71086 const char *name;
71087 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
71088 new file mode 100644
71089 index 0000000..33f4af8
71090 --- /dev/null
71091 +++ b/include/linux/netfilter/xt_gradm.h
71092 @@ -0,0 +1,9 @@
71093 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
71094 +#define _LINUX_NETFILTER_XT_GRADM_H 1
71095 +
71096 +struct xt_gradm_mtinfo {
71097 + __u16 flags;
71098 + __u16 invflags;
71099 +};
71100 +
71101 +#endif
71102 diff --git a/include/linux/nls.h b/include/linux/nls.h
71103 index 5dc635f..35f5e11 100644
71104 --- a/include/linux/nls.h
71105 +++ b/include/linux/nls.h
71106 @@ -31,7 +31,7 @@ struct nls_table {
71107 const unsigned char *charset2upper;
71108 struct module *owner;
71109 struct nls_table *next;
71110 -};
71111 +} __do_const;
71112
71113 /* this value hold the maximum octet of charset */
71114 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71115 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71116 index d14a4c3..a078786 100644
71117 --- a/include/linux/notifier.h
71118 +++ b/include/linux/notifier.h
71119 @@ -54,7 +54,8 @@ struct notifier_block {
71120 notifier_fn_t notifier_call;
71121 struct notifier_block __rcu *next;
71122 int priority;
71123 -};
71124 +} __do_const;
71125 +typedef struct notifier_block __no_const notifier_block_no_const;
71126
71127 struct atomic_notifier_head {
71128 spinlock_t lock;
71129 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71130 index a4c5624..79d6d88 100644
71131 --- a/include/linux/oprofile.h
71132 +++ b/include/linux/oprofile.h
71133 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71134 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71135 char const * name, ulong * val);
71136
71137 -/** Create a file for read-only access to an atomic_t. */
71138 +/** Create a file for read-only access to an atomic_unchecked_t. */
71139 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71140 - char const * name, atomic_t * val);
71141 + char const * name, atomic_unchecked_t * val);
71142
71143 /** create a directory */
71144 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71145 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71146 index 8db71dc..a76bf2c 100644
71147 --- a/include/linux/pci_hotplug.h
71148 +++ b/include/linux/pci_hotplug.h
71149 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71150 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71151 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71152 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71153 -};
71154 +} __do_const;
71155 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71156
71157 /**
71158 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71159 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71160 index c5b6dbf..b124155 100644
71161 --- a/include/linux/perf_event.h
71162 +++ b/include/linux/perf_event.h
71163 @@ -318,8 +318,8 @@ struct perf_event {
71164
71165 enum perf_event_active_state state;
71166 unsigned int attach_state;
71167 - local64_t count;
71168 - atomic64_t child_count;
71169 + local64_t count; /* PaX: fix it one day */
71170 + atomic64_unchecked_t child_count;
71171
71172 /*
71173 * These are the total time in nanoseconds that the event
71174 @@ -370,8 +370,8 @@ struct perf_event {
71175 * These accumulate total time (in nanoseconds) that children
71176 * events have been enabled and running, respectively.
71177 */
71178 - atomic64_t child_total_time_enabled;
71179 - atomic64_t child_total_time_running;
71180 + atomic64_unchecked_t child_total_time_enabled;
71181 + atomic64_unchecked_t child_total_time_running;
71182
71183 /*
71184 * Protect attach/detach and child_list:
71185 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
71186 entry->ip[entry->nr++] = ip;
71187 }
71188
71189 -extern int sysctl_perf_event_paranoid;
71190 +extern int sysctl_perf_event_legitimately_concerned;
71191 extern int sysctl_perf_event_mlock;
71192 extern int sysctl_perf_event_sample_rate;
71193
71194 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
71195 void __user *buffer, size_t *lenp,
71196 loff_t *ppos);
71197
71198 +static inline bool perf_paranoid_any(void)
71199 +{
71200 + return sysctl_perf_event_legitimately_concerned > 2;
71201 +}
71202 +
71203 static inline bool perf_paranoid_tracepoint_raw(void)
71204 {
71205 - return sysctl_perf_event_paranoid > -1;
71206 + return sysctl_perf_event_legitimately_concerned > -1;
71207 }
71208
71209 static inline bool perf_paranoid_cpu(void)
71210 {
71211 - return sysctl_perf_event_paranoid > 0;
71212 + return sysctl_perf_event_legitimately_concerned > 0;
71213 }
71214
71215 static inline bool perf_paranoid_kernel(void)
71216 {
71217 - return sysctl_perf_event_paranoid > 1;
71218 + return sysctl_perf_event_legitimately_concerned > 1;
71219 }
71220
71221 extern void perf_event_init(void);
71222 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
71223 */
71224 #define perf_cpu_notifier(fn) \
71225 do { \
71226 - static struct notifier_block fn##_nb __cpuinitdata = \
71227 + static struct notifier_block fn##_nb = \
71228 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71229 unsigned long cpu = smp_processor_id(); \
71230 unsigned long flags; \
71231 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
71232 struct device_attribute attr;
71233 u64 id;
71234 const char *event_str;
71235 -};
71236 +} __do_const;
71237
71238 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
71239 static struct perf_pmu_events_attr _var = { \
71240 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71241 index b8809fe..ae4ccd0 100644
71242 --- a/include/linux/pipe_fs_i.h
71243 +++ b/include/linux/pipe_fs_i.h
71244 @@ -47,10 +47,10 @@ struct pipe_inode_info {
71245 struct mutex mutex;
71246 wait_queue_head_t wait;
71247 unsigned int nrbufs, curbuf, buffers;
71248 - unsigned int readers;
71249 - unsigned int writers;
71250 - unsigned int files;
71251 - unsigned int waiting_writers;
71252 + atomic_t readers;
71253 + atomic_t writers;
71254 + atomic_t files;
71255 + atomic_t waiting_writers;
71256 unsigned int r_counter;
71257 unsigned int w_counter;
71258 struct page *tmp_page;
71259 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71260 index 5f28cae..3d23723 100644
71261 --- a/include/linux/platform_data/usb-ehci-s5p.h
71262 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71263 @@ -14,7 +14,7 @@
71264 struct s5p_ehci_platdata {
71265 int (*phy_init)(struct platform_device *pdev, int type);
71266 int (*phy_exit)(struct platform_device *pdev, int type);
71267 -};
71268 +} __no_const;
71269
71270 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71271
71272 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
71273 index c256c59..8ea94c7 100644
71274 --- a/include/linux/platform_data/usb-ohci-exynos.h
71275 +++ b/include/linux/platform_data/usb-ohci-exynos.h
71276 @@ -14,7 +14,7 @@
71277 struct exynos4_ohci_platdata {
71278 int (*phy_init)(struct platform_device *pdev, int type);
71279 int (*phy_exit)(struct platform_device *pdev, int type);
71280 -};
71281 +} __no_const;
71282
71283 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71284
71285 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71286 index 7c1d252..c5c773e 100644
71287 --- a/include/linux/pm_domain.h
71288 +++ b/include/linux/pm_domain.h
71289 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71290
71291 struct gpd_cpu_data {
71292 unsigned int saved_exit_latency;
71293 - struct cpuidle_state *idle_state;
71294 + cpuidle_state_no_const *idle_state;
71295 };
71296
71297 struct generic_pm_domain {
71298 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71299 index 7d7e09e..8671ef8 100644
71300 --- a/include/linux/pm_runtime.h
71301 +++ b/include/linux/pm_runtime.h
71302 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71303
71304 static inline void pm_runtime_mark_last_busy(struct device *dev)
71305 {
71306 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71307 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71308 }
71309
71310 #else /* !CONFIG_PM_RUNTIME */
71311 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71312 index 195aafc..49a7bc2 100644
71313 --- a/include/linux/pnp.h
71314 +++ b/include/linux/pnp.h
71315 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71316 struct pnp_fixup {
71317 char id[7];
71318 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71319 -};
71320 +} __do_const;
71321
71322 /* config parameters */
71323 #define PNP_CONFIG_NORMAL 0x0001
71324 diff --git a/include/linux/poison.h b/include/linux/poison.h
71325 index 2110a81..13a11bb 100644
71326 --- a/include/linux/poison.h
71327 +++ b/include/linux/poison.h
71328 @@ -19,8 +19,8 @@
71329 * under normal circumstances, used to verify that nobody uses
71330 * non-initialized list entries.
71331 */
71332 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71333 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71334 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71335 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71336
71337 /********** include/linux/timer.h **********/
71338 /*
71339 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71340 index c0f44c2..1572583 100644
71341 --- a/include/linux/power/smartreflex.h
71342 +++ b/include/linux/power/smartreflex.h
71343 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71344 int (*notify)(struct omap_sr *sr, u32 status);
71345 u8 notify_flags;
71346 u8 class_type;
71347 -};
71348 +} __do_const;
71349
71350 /**
71351 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71352 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71353 index 4ea1d37..80f4b33 100644
71354 --- a/include/linux/ppp-comp.h
71355 +++ b/include/linux/ppp-comp.h
71356 @@ -84,7 +84,7 @@ struct compressor {
71357 struct module *owner;
71358 /* Extra skb space needed by the compressor algorithm */
71359 unsigned int comp_extra;
71360 -};
71361 +} __do_const;
71362
71363 /*
71364 * The return value from decompress routine is the length of the
71365 diff --git a/include/linux/printk.h b/include/linux/printk.h
71366 index 22c7052..ad3fa0a 100644
71367 --- a/include/linux/printk.h
71368 +++ b/include/linux/printk.h
71369 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
71370 void early_printk(const char *s, ...) { }
71371 #endif
71372
71373 +extern int kptr_restrict;
71374 +
71375 #ifdef CONFIG_PRINTK
71376 asmlinkage __printf(5, 0)
71377 int vprintk_emit(int facility, int level,
71378 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71379
71380 extern int printk_delay_msec;
71381 extern int dmesg_restrict;
71382 -extern int kptr_restrict;
71383
71384 extern void wake_up_klogd(void);
71385
71386 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71387 index 608e60a..c26f864 100644
71388 --- a/include/linux/proc_fs.h
71389 +++ b/include/linux/proc_fs.h
71390 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
71391 return proc_create_data(name, mode, parent, proc_fops, NULL);
71392 }
71393
71394 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71395 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71396 +{
71397 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71398 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71399 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71400 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71401 +#else
71402 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71403 +#endif
71404 +}
71405 +
71406 +
71407 extern void proc_set_size(struct proc_dir_entry *, loff_t);
71408 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
71409 extern void *PDE_DATA(const struct inode *);
71410 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
71411 index 34a1e10..03a6d03 100644
71412 --- a/include/linux/proc_ns.h
71413 +++ b/include/linux/proc_ns.h
71414 @@ -14,7 +14,7 @@ struct proc_ns_operations {
71415 void (*put)(void *ns);
71416 int (*install)(struct nsproxy *nsproxy, void *ns);
71417 unsigned int (*inum)(void *ns);
71418 -};
71419 +} __do_const;
71420
71421 struct proc_ns {
71422 void *ns;
71423 diff --git a/include/linux/random.h b/include/linux/random.h
71424 index 3b9377d..61b506a 100644
71425 --- a/include/linux/random.h
71426 +++ b/include/linux/random.h
71427 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
71428 u32 prandom_u32_state(struct rnd_state *);
71429 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71430
71431 +static inline unsigned long pax_get_random_long(void)
71432 +{
71433 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71434 +}
71435 +
71436 /*
71437 * Handle minimum values for seeds
71438 */
71439 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71440 index f4b1001..8ddb2b6 100644
71441 --- a/include/linux/rculist.h
71442 +++ b/include/linux/rculist.h
71443 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71444 struct list_head *prev, struct list_head *next);
71445 #endif
71446
71447 +extern void __pax_list_add_rcu(struct list_head *new,
71448 + struct list_head *prev, struct list_head *next);
71449 +
71450 /**
71451 * list_add_rcu - add a new entry to rcu-protected list
71452 * @new: new entry to be added
71453 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71454 __list_add_rcu(new, head, head->next);
71455 }
71456
71457 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71458 +{
71459 + __pax_list_add_rcu(new, head, head->next);
71460 +}
71461 +
71462 /**
71463 * list_add_tail_rcu - add a new entry to rcu-protected list
71464 * @new: new entry to be added
71465 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71466 __list_add_rcu(new, head->prev, head);
71467 }
71468
71469 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71470 + struct list_head *head)
71471 +{
71472 + __pax_list_add_rcu(new, head->prev, head);
71473 +}
71474 +
71475 /**
71476 * list_del_rcu - deletes entry from list without re-initialization
71477 * @entry: the element to delete from the list.
71478 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71479 entry->prev = LIST_POISON2;
71480 }
71481
71482 +extern void pax_list_del_rcu(struct list_head *entry);
71483 +
71484 /**
71485 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71486 * @n: the element to delete from the hash list.
71487 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71488 index 23b3630..e1bc12b 100644
71489 --- a/include/linux/reboot.h
71490 +++ b/include/linux/reboot.h
71491 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71492 * Architecture-specific implementations of sys_reboot commands.
71493 */
71494
71495 -extern void machine_restart(char *cmd);
71496 -extern void machine_halt(void);
71497 -extern void machine_power_off(void);
71498 +extern void machine_restart(char *cmd) __noreturn;
71499 +extern void machine_halt(void) __noreturn;
71500 +extern void machine_power_off(void) __noreturn;
71501
71502 extern void machine_shutdown(void);
71503 struct pt_regs;
71504 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71505 */
71506
71507 extern void kernel_restart_prepare(char *cmd);
71508 -extern void kernel_restart(char *cmd);
71509 -extern void kernel_halt(void);
71510 -extern void kernel_power_off(void);
71511 +extern void kernel_restart(char *cmd) __noreturn;
71512 +extern void kernel_halt(void) __noreturn;
71513 +extern void kernel_power_off(void) __noreturn;
71514
71515 extern int C_A_D; /* for sysctl */
71516 void ctrl_alt_del(void);
71517 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71518 * Emergency restart, callable from an interrupt handler.
71519 */
71520
71521 -extern void emergency_restart(void);
71522 +extern void emergency_restart(void) __noreturn;
71523 #include <asm/emergency-restart.h>
71524
71525 #endif /* _LINUX_REBOOT_H */
71526 diff --git a/include/linux/regset.h b/include/linux/regset.h
71527 index 8e0c9fe..ac4d221 100644
71528 --- a/include/linux/regset.h
71529 +++ b/include/linux/regset.h
71530 @@ -161,7 +161,8 @@ struct user_regset {
71531 unsigned int align;
71532 unsigned int bias;
71533 unsigned int core_note_type;
71534 -};
71535 +} __do_const;
71536 +typedef struct user_regset __no_const user_regset_no_const;
71537
71538 /**
71539 * struct user_regset_view - available regsets
71540 diff --git a/include/linux/relay.h b/include/linux/relay.h
71541 index d7c8359..818daf5 100644
71542 --- a/include/linux/relay.h
71543 +++ b/include/linux/relay.h
71544 @@ -157,7 +157,7 @@ struct rchan_callbacks
71545 * The callback should return 0 if successful, negative if not.
71546 */
71547 int (*remove_buf_file)(struct dentry *dentry);
71548 -};
71549 +} __no_const;
71550
71551 /*
71552 * CONFIG_RELAY kernel API, kernel/relay.c
71553 diff --git a/include/linux/rio.h b/include/linux/rio.h
71554 index 18e0993..8ab5b21 100644
71555 --- a/include/linux/rio.h
71556 +++ b/include/linux/rio.h
71557 @@ -345,7 +345,7 @@ struct rio_ops {
71558 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71559 u64 rstart, u32 size, u32 flags);
71560 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71561 -};
71562 +} __no_const;
71563
71564 #define RIO_RESOURCE_MEM 0x00000100
71565 #define RIO_RESOURCE_DOORBELL 0x00000200
71566 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71567 index 6dacb93..6174423 100644
71568 --- a/include/linux/rmap.h
71569 +++ b/include/linux/rmap.h
71570 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71571 void anon_vma_init(void); /* create anon_vma_cachep */
71572 int anon_vma_prepare(struct vm_area_struct *);
71573 void unlink_anon_vmas(struct vm_area_struct *);
71574 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71575 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71576 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71577 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71578
71579 static inline void anon_vma_merge(struct vm_area_struct *vma,
71580 struct vm_area_struct *next)
71581 diff --git a/include/linux/sched.h b/include/linux/sched.h
71582 index 178a8d9..52e71a3 100644
71583 --- a/include/linux/sched.h
71584 +++ b/include/linux/sched.h
71585 @@ -62,6 +62,7 @@ struct bio_list;
71586 struct fs_struct;
71587 struct perf_event_context;
71588 struct blk_plug;
71589 +struct linux_binprm;
71590
71591 /*
71592 * List of flags we want to share for kernel threads,
71593 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
71594 extern int in_sched_functions(unsigned long addr);
71595
71596 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71597 -extern signed long schedule_timeout(signed long timeout);
71598 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71599 extern signed long schedule_timeout_interruptible(signed long timeout);
71600 extern signed long schedule_timeout_killable(signed long timeout);
71601 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71602 @@ -314,6 +315,19 @@ struct nsproxy;
71603 struct user_namespace;
71604
71605 #ifdef CONFIG_MMU
71606 +
71607 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71608 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71609 +#else
71610 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71611 +{
71612 + return 0;
71613 +}
71614 +#endif
71615 +
71616 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71617 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71618 +
71619 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71620 extern unsigned long
71621 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71622 @@ -591,6 +605,17 @@ struct signal_struct {
71623 #ifdef CONFIG_TASKSTATS
71624 struct taskstats *stats;
71625 #endif
71626 +
71627 +#ifdef CONFIG_GRKERNSEC
71628 + u32 curr_ip;
71629 + u32 saved_ip;
71630 + u32 gr_saddr;
71631 + u32 gr_daddr;
71632 + u16 gr_sport;
71633 + u16 gr_dport;
71634 + u8 used_accept:1;
71635 +#endif
71636 +
71637 #ifdef CONFIG_AUDIT
71638 unsigned audit_tty;
71639 unsigned audit_tty_log_passwd;
71640 @@ -671,6 +696,14 @@ struct user_struct {
71641 struct key *session_keyring; /* UID's default session keyring */
71642 #endif
71643
71644 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71645 + unsigned char kernel_banned;
71646 +#endif
71647 +#ifdef CONFIG_GRKERNSEC_BRUTE
71648 + unsigned char suid_banned;
71649 + unsigned long suid_ban_expires;
71650 +#endif
71651 +
71652 /* Hash table maintenance information */
71653 struct hlist_node uidhash_node;
71654 kuid_t uid;
71655 @@ -1158,8 +1191,8 @@ struct task_struct {
71656 struct list_head thread_group;
71657
71658 struct completion *vfork_done; /* for vfork() */
71659 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71660 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71661 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71662 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71663
71664 cputime_t utime, stime, utimescaled, stimescaled;
71665 cputime_t gtime;
71666 @@ -1184,11 +1217,6 @@ struct task_struct {
71667 struct task_cputime cputime_expires;
71668 struct list_head cpu_timers[3];
71669
71670 -/* process credentials */
71671 - const struct cred __rcu *real_cred; /* objective and real subjective task
71672 - * credentials (COW) */
71673 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71674 - * credentials (COW) */
71675 char comm[TASK_COMM_LEN]; /* executable name excluding path
71676 - access with [gs]et_task_comm (which lock
71677 it with task_lock())
71678 @@ -1205,6 +1233,10 @@ struct task_struct {
71679 #endif
71680 /* CPU-specific state of this task */
71681 struct thread_struct thread;
71682 +/* thread_info moved to task_struct */
71683 +#ifdef CONFIG_X86
71684 + struct thread_info tinfo;
71685 +#endif
71686 /* filesystem information */
71687 struct fs_struct *fs;
71688 /* open file information */
71689 @@ -1278,6 +1310,10 @@ struct task_struct {
71690 gfp_t lockdep_reclaim_gfp;
71691 #endif
71692
71693 +/* process credentials */
71694 + const struct cred __rcu *real_cred; /* objective and real subjective task
71695 + * credentials (COW) */
71696 +
71697 /* journalling filesystem info */
71698 void *journal_info;
71699
71700 @@ -1316,6 +1352,10 @@ struct task_struct {
71701 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71702 struct list_head cg_list;
71703 #endif
71704 +
71705 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71706 + * credentials (COW) */
71707 +
71708 #ifdef CONFIG_FUTEX
71709 struct robust_list_head __user *robust_list;
71710 #ifdef CONFIG_COMPAT
71711 @@ -1416,8 +1456,74 @@ struct task_struct {
71712 unsigned int sequential_io;
71713 unsigned int sequential_io_avg;
71714 #endif
71715 +
71716 +#ifdef CONFIG_GRKERNSEC
71717 + /* grsecurity */
71718 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71719 + u64 exec_id;
71720 +#endif
71721 +#ifdef CONFIG_GRKERNSEC_SETXID
71722 + const struct cred *delayed_cred;
71723 +#endif
71724 + struct dentry *gr_chroot_dentry;
71725 + struct acl_subject_label *acl;
71726 + struct acl_role_label *role;
71727 + struct file *exec_file;
71728 + unsigned long brute_expires;
71729 + u16 acl_role_id;
71730 + /* is this the task that authenticated to the special role */
71731 + u8 acl_sp_role;
71732 + u8 is_writable;
71733 + u8 brute;
71734 + u8 gr_is_chrooted;
71735 +#endif
71736 +
71737 };
71738
71739 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71740 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71741 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71742 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71743 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71744 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71745 +
71746 +#ifdef CONFIG_PAX_SOFTMODE
71747 +extern int pax_softmode;
71748 +#endif
71749 +
71750 +extern int pax_check_flags(unsigned long *);
71751 +
71752 +/* if tsk != current then task_lock must be held on it */
71753 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71754 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71755 +{
71756 + if (likely(tsk->mm))
71757 + return tsk->mm->pax_flags;
71758 + else
71759 + return 0UL;
71760 +}
71761 +
71762 +/* if tsk != current then task_lock must be held on it */
71763 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71764 +{
71765 + if (likely(tsk->mm)) {
71766 + tsk->mm->pax_flags = flags;
71767 + return 0;
71768 + }
71769 + return -EINVAL;
71770 +}
71771 +#endif
71772 +
71773 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71774 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71775 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71776 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71777 +#endif
71778 +
71779 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71780 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71781 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71782 +
71783 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71784 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71785
71786 @@ -1476,7 +1582,7 @@ struct pid_namespace;
71787 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71788 struct pid_namespace *ns);
71789
71790 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71791 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71792 {
71793 return tsk->pid;
71794 }
71795 @@ -1919,7 +2025,9 @@ void yield(void);
71796 extern struct exec_domain default_exec_domain;
71797
71798 union thread_union {
71799 +#ifndef CONFIG_X86
71800 struct thread_info thread_info;
71801 +#endif
71802 unsigned long stack[THREAD_SIZE/sizeof(long)];
71803 };
71804
71805 @@ -1952,6 +2060,7 @@ extern struct pid_namespace init_pid_ns;
71806 */
71807
71808 extern struct task_struct *find_task_by_vpid(pid_t nr);
71809 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71810 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71811 struct pid_namespace *ns);
71812
71813 @@ -2118,7 +2227,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71814 extern void exit_itimers(struct signal_struct *);
71815 extern void flush_itimer_signals(void);
71816
71817 -extern void do_group_exit(int);
71818 +extern __noreturn void do_group_exit(int);
71819
71820 extern int allow_signal(int);
71821 extern int disallow_signal(int);
71822 @@ -2309,9 +2418,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71823
71824 #endif
71825
71826 -static inline int object_is_on_stack(void *obj)
71827 +static inline int object_starts_on_stack(void *obj)
71828 {
71829 - void *stack = task_stack_page(current);
71830 + const void *stack = task_stack_page(current);
71831
71832 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71833 }
71834 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71835 index bf8086b..962b035 100644
71836 --- a/include/linux/sched/sysctl.h
71837 +++ b/include/linux/sched/sysctl.h
71838 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71839 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71840
71841 extern int sysctl_max_map_count;
71842 +extern unsigned long sysctl_heap_stack_gap;
71843
71844 extern unsigned int sysctl_sched_latency;
71845 extern unsigned int sysctl_sched_min_granularity;
71846 diff --git a/include/linux/security.h b/include/linux/security.h
71847 index 4686491..2bd210e 100644
71848 --- a/include/linux/security.h
71849 +++ b/include/linux/security.h
71850 @@ -26,6 +26,7 @@
71851 #include <linux/capability.h>
71852 #include <linux/slab.h>
71853 #include <linux/err.h>
71854 +#include <linux/grsecurity.h>
71855
71856 struct linux_binprm;
71857 struct cred;
71858 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71859 index 2da29ac..aac448ec 100644
71860 --- a/include/linux/seq_file.h
71861 +++ b/include/linux/seq_file.h
71862 @@ -26,6 +26,9 @@ struct seq_file {
71863 struct mutex lock;
71864 const struct seq_operations *op;
71865 int poll_event;
71866 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71867 + u64 exec_id;
71868 +#endif
71869 #ifdef CONFIG_USER_NS
71870 struct user_namespace *user_ns;
71871 #endif
71872 @@ -38,6 +41,7 @@ struct seq_operations {
71873 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71874 int (*show) (struct seq_file *m, void *v);
71875 };
71876 +typedef struct seq_operations __no_const seq_operations_no_const;
71877
71878 #define SEQ_SKIP 1
71879
71880 diff --git a/include/linux/shm.h b/include/linux/shm.h
71881 index 429c199..4d42e38 100644
71882 --- a/include/linux/shm.h
71883 +++ b/include/linux/shm.h
71884 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71885
71886 /* The task created the shm object. NULL if the task is dead. */
71887 struct task_struct *shm_creator;
71888 +#ifdef CONFIG_GRKERNSEC
71889 + time_t shm_createtime;
71890 + pid_t shm_lapid;
71891 +#endif
71892 };
71893
71894 /* shm_mode upper byte flags */
71895 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71896 index dec1748..112c1f9 100644
71897 --- a/include/linux/skbuff.h
71898 +++ b/include/linux/skbuff.h
71899 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71900 extern struct sk_buff *__alloc_skb(unsigned int size,
71901 gfp_t priority, int flags, int node);
71902 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71903 -static inline struct sk_buff *alloc_skb(unsigned int size,
71904 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71905 gfp_t priority)
71906 {
71907 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71908 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71909 */
71910 static inline int skb_queue_empty(const struct sk_buff_head *list)
71911 {
71912 - return list->next == (struct sk_buff *)list;
71913 + return list->next == (const struct sk_buff *)list;
71914 }
71915
71916 /**
71917 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71918 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71919 const struct sk_buff *skb)
71920 {
71921 - return skb->next == (struct sk_buff *)list;
71922 + return skb->next == (const struct sk_buff *)list;
71923 }
71924
71925 /**
71926 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71927 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71928 const struct sk_buff *skb)
71929 {
71930 - return skb->prev == (struct sk_buff *)list;
71931 + return skb->prev == (const struct sk_buff *)list;
71932 }
71933
71934 /**
71935 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71936 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71937 */
71938 #ifndef NET_SKB_PAD
71939 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71940 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71941 #endif
71942
71943 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71944 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71945 int noblock, int *err);
71946 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71947 struct poll_table_struct *wait);
71948 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71949 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71950 int offset, struct iovec *to,
71951 int size);
71952 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71953 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
71954 nf_bridge_put(skb->nf_bridge);
71955 skb->nf_bridge = NULL;
71956 #endif
71957 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71958 + skb->nf_trace = 0;
71959 +#endif
71960 }
71961
71962 static inline void nf_reset_trace(struct sk_buff *skb)
71963 diff --git a/include/linux/slab.h b/include/linux/slab.h
71964 index 0c62175..9ece3d8 100644
71965 --- a/include/linux/slab.h
71966 +++ b/include/linux/slab.h
71967 @@ -12,13 +12,20 @@
71968 #include <linux/gfp.h>
71969 #include <linux/types.h>
71970 #include <linux/workqueue.h>
71971 -
71972 +#include <linux/err.h>
71973
71974 /*
71975 * Flags to pass to kmem_cache_create().
71976 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71977 */
71978 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71979 +
71980 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71981 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71982 +#else
71983 +#define SLAB_USERCOPY 0x00000000UL
71984 +#endif
71985 +
71986 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71987 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71988 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71989 @@ -89,10 +96,13 @@
71990 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71991 * Both make kfree a no-op.
71992 */
71993 -#define ZERO_SIZE_PTR ((void *)16)
71994 +#define ZERO_SIZE_PTR \
71995 +({ \
71996 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71997 + (void *)(-MAX_ERRNO-1L); \
71998 +})
71999
72000 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
72001 - (unsigned long)ZERO_SIZE_PTR)
72002 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
72003
72004
72005 struct mem_cgroup;
72006 @@ -132,6 +142,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
72007 void kfree(const void *);
72008 void kzfree(const void *);
72009 size_t ksize(const void *);
72010 +const char *check_heap_object(const void *ptr, unsigned long n);
72011 +bool is_usercopy_object(const void *ptr);
72012
72013 /*
72014 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
72015 @@ -164,7 +176,7 @@ struct kmem_cache {
72016 unsigned int align; /* Alignment as calculated */
72017 unsigned long flags; /* Active flags on the slab */
72018 const char *name; /* Slab name for sysfs */
72019 - int refcount; /* Use counter */
72020 + atomic_t refcount; /* Use counter */
72021 void (*ctor)(void *); /* Called on object slot creation */
72022 struct list_head list; /* List of all slab caches on the system */
72023 };
72024 @@ -226,6 +238,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
72025 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72026 #endif
72027
72028 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72029 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
72030 +#endif
72031 +
72032 /*
72033 * Figure out which kmalloc slab an allocation of a certain size
72034 * belongs to.
72035 @@ -234,7 +250,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72036 * 2 = 120 .. 192 bytes
72037 * n = 2^(n-1) .. 2^n -1
72038 */
72039 -static __always_inline int kmalloc_index(size_t size)
72040 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
72041 {
72042 if (!size)
72043 return 0;
72044 @@ -406,6 +422,7 @@ void print_slabinfo_header(struct seq_file *m);
72045 * for general use, and so are not documented here. For a full list of
72046 * potential flags, always refer to linux/gfp.h.
72047 */
72048 +
72049 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
72050 {
72051 if (size != 0 && n > SIZE_MAX / size)
72052 @@ -465,7 +482,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
72053 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72054 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72055 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72056 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72057 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
72058 #define kmalloc_track_caller(size, flags) \
72059 __kmalloc_track_caller(size, flags, _RET_IP_)
72060 #else
72061 @@ -485,7 +502,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72062 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72063 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72064 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72065 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
72066 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
72067 #define kmalloc_node_track_caller(size, flags, node) \
72068 __kmalloc_node_track_caller(size, flags, node, \
72069 _RET_IP_)
72070 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
72071 index cd40158..d9dc02c 100644
72072 --- a/include/linux/slab_def.h
72073 +++ b/include/linux/slab_def.h
72074 @@ -50,7 +50,7 @@ struct kmem_cache {
72075 /* 4) cache creation/removal */
72076 const char *name;
72077 struct list_head list;
72078 - int refcount;
72079 + atomic_t refcount;
72080 int object_size;
72081 int align;
72082
72083 @@ -66,10 +66,10 @@ struct kmem_cache {
72084 unsigned long node_allocs;
72085 unsigned long node_frees;
72086 unsigned long node_overflow;
72087 - atomic_t allochit;
72088 - atomic_t allocmiss;
72089 - atomic_t freehit;
72090 - atomic_t freemiss;
72091 + atomic_unchecked_t allochit;
72092 + atomic_unchecked_t allocmiss;
72093 + atomic_unchecked_t freehit;
72094 + atomic_unchecked_t freemiss;
72095
72096 /*
72097 * If debugging is enabled, then the allocator can add additional
72098 @@ -103,7 +103,7 @@ struct kmem_cache {
72099 };
72100
72101 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72102 -void *__kmalloc(size_t size, gfp_t flags);
72103 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
72104
72105 #ifdef CONFIG_TRACING
72106 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
72107 @@ -136,6 +136,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72108 cachep = kmalloc_dma_caches[i];
72109 else
72110 #endif
72111 +
72112 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72113 + if (flags & GFP_USERCOPY)
72114 + cachep = kmalloc_usercopy_caches[i];
72115 + else
72116 +#endif
72117 +
72118 cachep = kmalloc_caches[i];
72119
72120 ret = kmem_cache_alloc_trace(cachep, flags, size);
72121 @@ -146,7 +153,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72122 }
72123
72124 #ifdef CONFIG_NUMA
72125 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72126 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72127 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72128
72129 #ifdef CONFIG_TRACING
72130 @@ -185,6 +192,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72131 cachep = kmalloc_dma_caches[i];
72132 else
72133 #endif
72134 +
72135 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72136 + if (flags & GFP_USERCOPY)
72137 + cachep = kmalloc_usercopy_caches[i];
72138 + else
72139 +#endif
72140 +
72141 cachep = kmalloc_caches[i];
72142
72143 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72144 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72145 index f28e14a..7831211 100644
72146 --- a/include/linux/slob_def.h
72147 +++ b/include/linux/slob_def.h
72148 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72149 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72150 }
72151
72152 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72153 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72154
72155 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72156 {
72157 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72158 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72159 }
72160
72161 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72162 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72163 {
72164 return kmalloc(size, flags);
72165 }
72166 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72167 index 027276f..092bfe8 100644
72168 --- a/include/linux/slub_def.h
72169 +++ b/include/linux/slub_def.h
72170 @@ -80,7 +80,7 @@ struct kmem_cache {
72171 struct kmem_cache_order_objects max;
72172 struct kmem_cache_order_objects min;
72173 gfp_t allocflags; /* gfp flags to use on each alloc */
72174 - int refcount; /* Refcount for slab cache destroy */
72175 + atomic_t refcount; /* Refcount for slab cache destroy */
72176 void (*ctor)(void *);
72177 int inuse; /* Offset to metadata */
72178 int align; /* Alignment */
72179 @@ -105,7 +105,7 @@ struct kmem_cache {
72180 };
72181
72182 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72183 -void *__kmalloc(size_t size, gfp_t flags);
72184 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72185
72186 static __always_inline void *
72187 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72188 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72189 }
72190 #endif
72191
72192 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72193 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72194 {
72195 unsigned int order = get_order(size);
72196 return kmalloc_order_trace(size, flags, order);
72197 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72198 }
72199
72200 #ifdef CONFIG_NUMA
72201 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72202 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72203 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72204
72205 #ifdef CONFIG_TRACING
72206 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72207 index 54f91d3..be2c379 100644
72208 --- a/include/linux/sock_diag.h
72209 +++ b/include/linux/sock_diag.h
72210 @@ -11,7 +11,7 @@ struct sock;
72211 struct sock_diag_handler {
72212 __u8 family;
72213 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72214 -};
72215 +} __do_const;
72216
72217 int sock_diag_register(const struct sock_diag_handler *h);
72218 void sock_diag_unregister(const struct sock_diag_handler *h);
72219 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72220 index 680f9a3..f13aeb0 100644
72221 --- a/include/linux/sonet.h
72222 +++ b/include/linux/sonet.h
72223 @@ -7,7 +7,7 @@
72224 #include <uapi/linux/sonet.h>
72225
72226 struct k_sonet_stats {
72227 -#define __HANDLE_ITEM(i) atomic_t i
72228 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72229 __SONET_ITEMS
72230 #undef __HANDLE_ITEM
72231 };
72232 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
72233 index 07d8e53..dc934c9 100644
72234 --- a/include/linux/sunrpc/addr.h
72235 +++ b/include/linux/sunrpc/addr.h
72236 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72237 {
72238 switch (sap->sa_family) {
72239 case AF_INET:
72240 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72241 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72242 case AF_INET6:
72243 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72244 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72245 }
72246 return 0;
72247 }
72248 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72249 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72250 const struct sockaddr *src)
72251 {
72252 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72253 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72254 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72255
72256 dsin->sin_family = ssin->sin_family;
72257 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72258 if (sa->sa_family != AF_INET6)
72259 return 0;
72260
72261 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72262 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72263 }
72264
72265 #endif /* _LINUX_SUNRPC_ADDR_H */
72266 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72267 index bfe11be..12bc8c4 100644
72268 --- a/include/linux/sunrpc/clnt.h
72269 +++ b/include/linux/sunrpc/clnt.h
72270 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72271 unsigned int p_timer; /* Which RTT timer to use */
72272 u32 p_statidx; /* Which procedure to account */
72273 const char * p_name; /* name of procedure */
72274 -};
72275 +} __do_const;
72276
72277 #ifdef __KERNEL__
72278
72279 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72280 index 1f0216b..6a4fa50 100644
72281 --- a/include/linux/sunrpc/svc.h
72282 +++ b/include/linux/sunrpc/svc.h
72283 @@ -411,7 +411,7 @@ struct svc_procedure {
72284 unsigned int pc_count; /* call count */
72285 unsigned int pc_cachetype; /* cache info (NFS) */
72286 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72287 -};
72288 +} __do_const;
72289
72290 /*
72291 * Function prototypes.
72292 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72293 index 0b8e3e6..33e0a01 100644
72294 --- a/include/linux/sunrpc/svc_rdma.h
72295 +++ b/include/linux/sunrpc/svc_rdma.h
72296 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72297 extern unsigned int svcrdma_max_requests;
72298 extern unsigned int svcrdma_max_req_size;
72299
72300 -extern atomic_t rdma_stat_recv;
72301 -extern atomic_t rdma_stat_read;
72302 -extern atomic_t rdma_stat_write;
72303 -extern atomic_t rdma_stat_sq_starve;
72304 -extern atomic_t rdma_stat_rq_starve;
72305 -extern atomic_t rdma_stat_rq_poll;
72306 -extern atomic_t rdma_stat_rq_prod;
72307 -extern atomic_t rdma_stat_sq_poll;
72308 -extern atomic_t rdma_stat_sq_prod;
72309 +extern atomic_unchecked_t rdma_stat_recv;
72310 +extern atomic_unchecked_t rdma_stat_read;
72311 +extern atomic_unchecked_t rdma_stat_write;
72312 +extern atomic_unchecked_t rdma_stat_sq_starve;
72313 +extern atomic_unchecked_t rdma_stat_rq_starve;
72314 +extern atomic_unchecked_t rdma_stat_rq_poll;
72315 +extern atomic_unchecked_t rdma_stat_rq_prod;
72316 +extern atomic_unchecked_t rdma_stat_sq_poll;
72317 +extern atomic_unchecked_t rdma_stat_sq_prod;
72318
72319 #define RPCRDMA_VERSION 1
72320
72321 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72322 index ff374ab..7fd2ecb 100644
72323 --- a/include/linux/sunrpc/svcauth.h
72324 +++ b/include/linux/sunrpc/svcauth.h
72325 @@ -109,7 +109,7 @@ struct auth_ops {
72326 int (*release)(struct svc_rqst *rq);
72327 void (*domain_release)(struct auth_domain *);
72328 int (*set_client)(struct svc_rqst *rq);
72329 -};
72330 +} __do_const;
72331
72332 #define SVC_GARBAGE 1
72333 #define SVC_SYSERR 2
72334 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72335 index a5ffd32..0935dea 100644
72336 --- a/include/linux/swiotlb.h
72337 +++ b/include/linux/swiotlb.h
72338 @@ -60,7 +60,8 @@ extern void
72339
72340 extern void
72341 swiotlb_free_coherent(struct device *hwdev, size_t size,
72342 - void *vaddr, dma_addr_t dma_handle);
72343 + void *vaddr, dma_addr_t dma_handle,
72344 + struct dma_attrs *attrs);
72345
72346 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72347 unsigned long offset, size_t size,
72348 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72349 index 4147d70..31a1791 100644
72350 --- a/include/linux/syscalls.h
72351 +++ b/include/linux/syscalls.h
72352 @@ -362,11 +362,11 @@ asmlinkage long sys_sync(void);
72353 asmlinkage long sys_fsync(unsigned int fd);
72354 asmlinkage long sys_fdatasync(unsigned int fd);
72355 asmlinkage long sys_bdflush(int func, long data);
72356 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
72357 - char __user *type, unsigned long flags,
72358 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
72359 + const char __user *type, unsigned long flags,
72360 void __user *data);
72361 -asmlinkage long sys_umount(char __user *name, int flags);
72362 -asmlinkage long sys_oldumount(char __user *name);
72363 +asmlinkage long sys_umount(const char __user *name, int flags);
72364 +asmlinkage long sys_oldumount(const char __user *name);
72365 asmlinkage long sys_truncate(const char __user *path, long length);
72366 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
72367 asmlinkage long sys_stat(const char __user *filename,
72368 @@ -578,7 +578,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72369 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72370 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72371 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72372 - struct sockaddr __user *, int);
72373 + struct sockaddr __user *, int) __intentional_overflow(0);
72374 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72375 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72376 unsigned int vlen, unsigned flags);
72377 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72378 index 27b3b0b..e093dd9 100644
72379 --- a/include/linux/syscore_ops.h
72380 +++ b/include/linux/syscore_ops.h
72381 @@ -16,7 +16,7 @@ struct syscore_ops {
72382 int (*suspend)(void);
72383 void (*resume)(void);
72384 void (*shutdown)(void);
72385 -};
72386 +} __do_const;
72387
72388 extern void register_syscore_ops(struct syscore_ops *ops);
72389 extern void unregister_syscore_ops(struct syscore_ops *ops);
72390 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72391 index 14a8ff2..af52bad 100644
72392 --- a/include/linux/sysctl.h
72393 +++ b/include/linux/sysctl.h
72394 @@ -34,13 +34,13 @@ struct ctl_table_root;
72395 struct ctl_table_header;
72396 struct ctl_dir;
72397
72398 -typedef struct ctl_table ctl_table;
72399 -
72400 typedef int proc_handler (struct ctl_table *ctl, int write,
72401 void __user *buffer, size_t *lenp, loff_t *ppos);
72402
72403 extern int proc_dostring(struct ctl_table *, int,
72404 void __user *, size_t *, loff_t *);
72405 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72406 + void __user *, size_t *, loff_t *);
72407 extern int proc_dointvec(struct ctl_table *, int,
72408 void __user *, size_t *, loff_t *);
72409 extern int proc_dointvec_minmax(struct ctl_table *, int,
72410 @@ -115,7 +115,9 @@ struct ctl_table
72411 struct ctl_table_poll *poll;
72412 void *extra1;
72413 void *extra2;
72414 -};
72415 +} __do_const;
72416 +typedef struct ctl_table __no_const ctl_table_no_const;
72417 +typedef struct ctl_table ctl_table;
72418
72419 struct ctl_node {
72420 struct rb_node node;
72421 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72422 index e2cee22..3ddb921 100644
72423 --- a/include/linux/sysfs.h
72424 +++ b/include/linux/sysfs.h
72425 @@ -31,7 +31,8 @@ struct attribute {
72426 struct lock_class_key *key;
72427 struct lock_class_key skey;
72428 #endif
72429 -};
72430 +} __do_const;
72431 +typedef struct attribute __no_const attribute_no_const;
72432
72433 /**
72434 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72435 @@ -59,8 +60,8 @@ struct attribute_group {
72436 umode_t (*is_visible)(struct kobject *,
72437 struct attribute *, int);
72438 struct attribute **attrs;
72439 -};
72440 -
72441 +} __do_const;
72442 +typedef struct attribute_group __no_const attribute_group_no_const;
72443
72444
72445 /**
72446 @@ -107,7 +108,8 @@ struct bin_attribute {
72447 char *, loff_t, size_t);
72448 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72449 struct vm_area_struct *vma);
72450 -};
72451 +} __do_const;
72452 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72453
72454 /**
72455 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72456 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72457 index 7faf933..9b85a0c 100644
72458 --- a/include/linux/sysrq.h
72459 +++ b/include/linux/sysrq.h
72460 @@ -16,6 +16,7 @@
72461
72462 #include <linux/errno.h>
72463 #include <linux/types.h>
72464 +#include <linux/compiler.h>
72465
72466 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72467 #define SYSRQ_DEFAULT_ENABLE 1
72468 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72469 char *help_msg;
72470 char *action_msg;
72471 int enable_mask;
72472 -};
72473 +} __do_const;
72474
72475 #ifdef CONFIG_MAGIC_SYSRQ
72476
72477 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72478 index e7e0473..7989295 100644
72479 --- a/include/linux/thread_info.h
72480 +++ b/include/linux/thread_info.h
72481 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72482 #error "no set_restore_sigmask() provided and default one won't work"
72483 #endif
72484
72485 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72486 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72487 +{
72488 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72489 + if (!__builtin_constant_p(n))
72490 +#endif
72491 + __check_object_size(ptr, n, to_user);
72492 +}
72493 +
72494 #endif /* __KERNEL__ */
72495
72496 #endif /* _LINUX_THREAD_INFO_H */
72497 diff --git a/include/linux/tty.h b/include/linux/tty.h
72498 index 8780bd2..d1ae08b 100644
72499 --- a/include/linux/tty.h
72500 +++ b/include/linux/tty.h
72501 @@ -194,7 +194,7 @@ struct tty_port {
72502 const struct tty_port_operations *ops; /* Port operations */
72503 spinlock_t lock; /* Lock protecting tty field */
72504 int blocked_open; /* Waiting to open */
72505 - int count; /* Usage count */
72506 + atomic_t count; /* Usage count */
72507 wait_queue_head_t open_wait; /* Open waiters */
72508 wait_queue_head_t close_wait; /* Close waiters */
72509 wait_queue_head_t delta_msr_wait; /* Modem status change */
72510 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
72511 struct tty_struct *tty, struct file *filp);
72512 static inline int tty_port_users(struct tty_port *port)
72513 {
72514 - return port->count + port->blocked_open;
72515 + return atomic_read(&port->count) + port->blocked_open;
72516 }
72517
72518 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72519 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72520 index 756a609..b302dd6 100644
72521 --- a/include/linux/tty_driver.h
72522 +++ b/include/linux/tty_driver.h
72523 @@ -285,7 +285,7 @@ struct tty_operations {
72524 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72525 #endif
72526 const struct file_operations *proc_fops;
72527 -};
72528 +} __do_const;
72529
72530 struct tty_driver {
72531 int magic; /* magic number for this structure */
72532 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72533 index 58390c7..95e214c 100644
72534 --- a/include/linux/tty_ldisc.h
72535 +++ b/include/linux/tty_ldisc.h
72536 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72537
72538 struct module *owner;
72539
72540 - int refcount;
72541 + atomic_t refcount;
72542 };
72543
72544 struct tty_ldisc {
72545 diff --git a/include/linux/types.h b/include/linux/types.h
72546 index 4d118ba..c3ee9bf 100644
72547 --- a/include/linux/types.h
72548 +++ b/include/linux/types.h
72549 @@ -176,10 +176,26 @@ typedef struct {
72550 int counter;
72551 } atomic_t;
72552
72553 +#ifdef CONFIG_PAX_REFCOUNT
72554 +typedef struct {
72555 + int counter;
72556 +} atomic_unchecked_t;
72557 +#else
72558 +typedef atomic_t atomic_unchecked_t;
72559 +#endif
72560 +
72561 #ifdef CONFIG_64BIT
72562 typedef struct {
72563 long counter;
72564 } atomic64_t;
72565 +
72566 +#ifdef CONFIG_PAX_REFCOUNT
72567 +typedef struct {
72568 + long counter;
72569 +} atomic64_unchecked_t;
72570 +#else
72571 +typedef atomic64_t atomic64_unchecked_t;
72572 +#endif
72573 #endif
72574
72575 struct list_head {
72576 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72577 index 5ca0951..ab496a5 100644
72578 --- a/include/linux/uaccess.h
72579 +++ b/include/linux/uaccess.h
72580 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72581 long ret; \
72582 mm_segment_t old_fs = get_fs(); \
72583 \
72584 - set_fs(KERNEL_DS); \
72585 pagefault_disable(); \
72586 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72587 - pagefault_enable(); \
72588 + set_fs(KERNEL_DS); \
72589 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72590 set_fs(old_fs); \
72591 + pagefault_enable(); \
72592 ret; \
72593 })
72594
72595 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72596 index 8e522cbc..aa8572d 100644
72597 --- a/include/linux/uidgid.h
72598 +++ b/include/linux/uidgid.h
72599 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72600
72601 #endif /* CONFIG_USER_NS */
72602
72603 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72604 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72605 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72606 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72607 +
72608 #endif /* _LINUX_UIDGID_H */
72609 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72610 index 99c1b4d..562e6f3 100644
72611 --- a/include/linux/unaligned/access_ok.h
72612 +++ b/include/linux/unaligned/access_ok.h
72613 @@ -4,34 +4,34 @@
72614 #include <linux/kernel.h>
72615 #include <asm/byteorder.h>
72616
72617 -static inline u16 get_unaligned_le16(const void *p)
72618 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72619 {
72620 - return le16_to_cpup((__le16 *)p);
72621 + return le16_to_cpup((const __le16 *)p);
72622 }
72623
72624 -static inline u32 get_unaligned_le32(const void *p)
72625 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72626 {
72627 - return le32_to_cpup((__le32 *)p);
72628 + return le32_to_cpup((const __le32 *)p);
72629 }
72630
72631 -static inline u64 get_unaligned_le64(const void *p)
72632 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72633 {
72634 - return le64_to_cpup((__le64 *)p);
72635 + return le64_to_cpup((const __le64 *)p);
72636 }
72637
72638 -static inline u16 get_unaligned_be16(const void *p)
72639 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72640 {
72641 - return be16_to_cpup((__be16 *)p);
72642 + return be16_to_cpup((const __be16 *)p);
72643 }
72644
72645 -static inline u32 get_unaligned_be32(const void *p)
72646 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72647 {
72648 - return be32_to_cpup((__be32 *)p);
72649 + return be32_to_cpup((const __be32 *)p);
72650 }
72651
72652 -static inline u64 get_unaligned_be64(const void *p)
72653 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72654 {
72655 - return be64_to_cpup((__be64 *)p);
72656 + return be64_to_cpup((const __be64 *)p);
72657 }
72658
72659 static inline void put_unaligned_le16(u16 val, void *p)
72660 diff --git a/include/linux/usb.h b/include/linux/usb.h
72661 index a0bee5a..5533a52 100644
72662 --- a/include/linux/usb.h
72663 +++ b/include/linux/usb.h
72664 @@ -552,7 +552,7 @@ struct usb_device {
72665 int maxchild;
72666
72667 u32 quirks;
72668 - atomic_t urbnum;
72669 + atomic_unchecked_t urbnum;
72670
72671 unsigned long active_duration;
72672
72673 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72674
72675 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72676 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72677 - void *data, __u16 size, int timeout);
72678 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72679 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72680 void *data, int len, int *actual_length, int timeout);
72681 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72682 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72683 index e452ba6..78f8e80 100644
72684 --- a/include/linux/usb/renesas_usbhs.h
72685 +++ b/include/linux/usb/renesas_usbhs.h
72686 @@ -39,7 +39,7 @@ enum {
72687 */
72688 struct renesas_usbhs_driver_callback {
72689 int (*notify_hotplug)(struct platform_device *pdev);
72690 -};
72691 +} __no_const;
72692
72693 /*
72694 * callback functions for platform
72695 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72696 index 6f8fbcf..8259001 100644
72697 --- a/include/linux/vermagic.h
72698 +++ b/include/linux/vermagic.h
72699 @@ -25,9 +25,35 @@
72700 #define MODULE_ARCH_VERMAGIC ""
72701 #endif
72702
72703 +#ifdef CONFIG_PAX_REFCOUNT
72704 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72705 +#else
72706 +#define MODULE_PAX_REFCOUNT ""
72707 +#endif
72708 +
72709 +#ifdef CONSTIFY_PLUGIN
72710 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72711 +#else
72712 +#define MODULE_CONSTIFY_PLUGIN ""
72713 +#endif
72714 +
72715 +#ifdef STACKLEAK_PLUGIN
72716 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72717 +#else
72718 +#define MODULE_STACKLEAK_PLUGIN ""
72719 +#endif
72720 +
72721 +#ifdef CONFIG_GRKERNSEC
72722 +#define MODULE_GRSEC "GRSEC "
72723 +#else
72724 +#define MODULE_GRSEC ""
72725 +#endif
72726 +
72727 #define VERMAGIC_STRING \
72728 UTS_RELEASE " " \
72729 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72730 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72731 - MODULE_ARCH_VERMAGIC
72732 + MODULE_ARCH_VERMAGIC \
72733 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72734 + MODULE_GRSEC
72735
72736 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72737 index 7d5773a..541c01c 100644
72738 --- a/include/linux/vmalloc.h
72739 +++ b/include/linux/vmalloc.h
72740 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72741 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72742 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72743 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72744 +
72745 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72746 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72747 +#endif
72748 +
72749 /* bits [20..32] reserved for arch specific ioremap internals */
72750
72751 /*
72752 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
72753 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72754 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72755 unsigned long start, unsigned long end, gfp_t gfp_mask,
72756 - pgprot_t prot, int node, const void *caller);
72757 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72758 extern void vfree(const void *addr);
72759
72760 extern void *vmap(struct page **pages, unsigned int count,
72761 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72762 extern void free_vm_area(struct vm_struct *area);
72763
72764 /* for /dev/kmem */
72765 -extern long vread(char *buf, char *addr, unsigned long count);
72766 -extern long vwrite(char *buf, char *addr, unsigned long count);
72767 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72768 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72769
72770 /*
72771 * Internals. Dont't use..
72772 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72773 index c586679..f06b389 100644
72774 --- a/include/linux/vmstat.h
72775 +++ b/include/linux/vmstat.h
72776 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
72777 /*
72778 * Zone based page accounting with per cpu differentials.
72779 */
72780 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72781 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72782
72783 static inline void zone_page_state_add(long x, struct zone *zone,
72784 enum zone_stat_item item)
72785 {
72786 - atomic_long_add(x, &zone->vm_stat[item]);
72787 - atomic_long_add(x, &vm_stat[item]);
72788 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72789 + atomic_long_add_unchecked(x, &vm_stat[item]);
72790 }
72791
72792 static inline unsigned long global_page_state(enum zone_stat_item item)
72793 {
72794 - long x = atomic_long_read(&vm_stat[item]);
72795 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72796 #ifdef CONFIG_SMP
72797 if (x < 0)
72798 x = 0;
72799 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72800 static inline unsigned long zone_page_state(struct zone *zone,
72801 enum zone_stat_item item)
72802 {
72803 - long x = atomic_long_read(&zone->vm_stat[item]);
72804 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72805 #ifdef CONFIG_SMP
72806 if (x < 0)
72807 x = 0;
72808 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72809 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72810 enum zone_stat_item item)
72811 {
72812 - long x = atomic_long_read(&zone->vm_stat[item]);
72813 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72814
72815 #ifdef CONFIG_SMP
72816 int cpu;
72817 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72818
72819 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72820 {
72821 - atomic_long_inc(&zone->vm_stat[item]);
72822 - atomic_long_inc(&vm_stat[item]);
72823 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72824 + atomic_long_inc_unchecked(&vm_stat[item]);
72825 }
72826
72827 static inline void __inc_zone_page_state(struct page *page,
72828 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
72829
72830 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72831 {
72832 - atomic_long_dec(&zone->vm_stat[item]);
72833 - atomic_long_dec(&vm_stat[item]);
72834 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72835 + atomic_long_dec_unchecked(&vm_stat[item]);
72836 }
72837
72838 static inline void __dec_zone_page_state(struct page *page,
72839 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72840 index fdbafc6..49dfe4f 100644
72841 --- a/include/linux/xattr.h
72842 +++ b/include/linux/xattr.h
72843 @@ -28,7 +28,7 @@ struct xattr_handler {
72844 size_t size, int handler_flags);
72845 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72846 size_t size, int flags, int handler_flags);
72847 -};
72848 +} __do_const;
72849
72850 struct xattr {
72851 char *name;
72852 @@ -37,6 +37,9 @@ struct xattr {
72853 };
72854
72855 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72856 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72857 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72858 +#endif
72859 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72860 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72861 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72862 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72863 index 9c5a6b4..09c9438 100644
72864 --- a/include/linux/zlib.h
72865 +++ b/include/linux/zlib.h
72866 @@ -31,6 +31,7 @@
72867 #define _ZLIB_H
72868
72869 #include <linux/zconf.h>
72870 +#include <linux/compiler.h>
72871
72872 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72873 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72874 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72875
72876 /* basic functions */
72877
72878 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72879 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72880 /*
72881 Returns the number of bytes that needs to be allocated for a per-
72882 stream workspace with the specified parameters. A pointer to this
72883 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72884 index 95d1c91..6798cca 100644
72885 --- a/include/media/v4l2-dev.h
72886 +++ b/include/media/v4l2-dev.h
72887 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72888 int (*mmap) (struct file *, struct vm_area_struct *);
72889 int (*open) (struct file *);
72890 int (*release) (struct file *);
72891 -};
72892 +} __do_const;
72893
72894 /*
72895 * Newer version of video_device, handled by videodev2.c
72896 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72897 index adcbb20..62c2559 100644
72898 --- a/include/net/9p/transport.h
72899 +++ b/include/net/9p/transport.h
72900 @@ -57,7 +57,7 @@ struct p9_trans_module {
72901 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72902 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72903 char *, char *, int , int, int, int);
72904 -};
72905 +} __do_const;
72906
72907 void v9fs_register_trans(struct p9_trans_module *m);
72908 void v9fs_unregister_trans(struct p9_trans_module *m);
72909 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72910 index fb94cf1..7c0c987 100644
72911 --- a/include/net/bluetooth/l2cap.h
72912 +++ b/include/net/bluetooth/l2cap.h
72913 @@ -551,7 +551,7 @@ struct l2cap_ops {
72914 void (*defer) (struct l2cap_chan *chan);
72915 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72916 unsigned long len, int nb);
72917 -};
72918 +} __do_const;
72919
72920 struct l2cap_conn {
72921 struct hci_conn *hcon;
72922 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72923 index f2ae33d..c457cf0 100644
72924 --- a/include/net/caif/cfctrl.h
72925 +++ b/include/net/caif/cfctrl.h
72926 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72927 void (*radioset_rsp)(void);
72928 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72929 struct cflayer *client_layer);
72930 -};
72931 +} __no_const;
72932
72933 /* Link Setup Parameters for CAIF-Links. */
72934 struct cfctrl_link_param {
72935 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72936 struct cfctrl {
72937 struct cfsrvl serv;
72938 struct cfctrl_rsp res;
72939 - atomic_t req_seq_no;
72940 - atomic_t rsp_seq_no;
72941 + atomic_unchecked_t req_seq_no;
72942 + atomic_unchecked_t rsp_seq_no;
72943 struct list_head list;
72944 /* Protects from simultaneous access to first_req list */
72945 spinlock_t info_list_lock;
72946 diff --git a/include/net/flow.h b/include/net/flow.h
72947 index 628e11b..4c475df 100644
72948 --- a/include/net/flow.h
72949 +++ b/include/net/flow.h
72950 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72951
72952 extern void flow_cache_flush(void);
72953 extern void flow_cache_flush_deferred(void);
72954 -extern atomic_t flow_cache_genid;
72955 +extern atomic_unchecked_t flow_cache_genid;
72956
72957 #endif
72958 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72959 index 93024a4..eeb6b6e 100644
72960 --- a/include/net/genetlink.h
72961 +++ b/include/net/genetlink.h
72962 @@ -119,7 +119,7 @@ struct genl_ops {
72963 struct netlink_callback *cb);
72964 int (*done)(struct netlink_callback *cb);
72965 struct list_head ops_list;
72966 -};
72967 +} __do_const;
72968
72969 extern int genl_register_family(struct genl_family *family);
72970 extern int genl_register_family_with_ops(struct genl_family *family,
72971 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72972 index 734d9b5..48a9a4b 100644
72973 --- a/include/net/gro_cells.h
72974 +++ b/include/net/gro_cells.h
72975 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72976 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72977
72978 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72979 - atomic_long_inc(&dev->rx_dropped);
72980 + atomic_long_inc_unchecked(&dev->rx_dropped);
72981 kfree_skb(skb);
72982 return;
72983 }
72984 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72985 index de2c785..0588a6b 100644
72986 --- a/include/net/inet_connection_sock.h
72987 +++ b/include/net/inet_connection_sock.h
72988 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72989 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72990 int (*bind_conflict)(const struct sock *sk,
72991 const struct inet_bind_bucket *tb, bool relax);
72992 -};
72993 +} __do_const;
72994
72995 /** inet_connection_sock - INET connection oriented sock
72996 *
72997 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72998 index 53f464d..ba76aaa 100644
72999 --- a/include/net/inetpeer.h
73000 +++ b/include/net/inetpeer.h
73001 @@ -47,8 +47,8 @@ struct inet_peer {
73002 */
73003 union {
73004 struct {
73005 - atomic_t rid; /* Frag reception counter */
73006 - atomic_t ip_id_count; /* IP ID for the next packet */
73007 + atomic_unchecked_t rid; /* Frag reception counter */
73008 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
73009 };
73010 struct rcu_head rcu;
73011 struct inet_peer *gc_next;
73012 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
73013 more++;
73014 inet_peer_refcheck(p);
73015 do {
73016 - old = atomic_read(&p->ip_id_count);
73017 + old = atomic_read_unchecked(&p->ip_id_count);
73018 new = old + more;
73019 if (!new)
73020 new = 1;
73021 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
73022 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
73023 return new;
73024 }
73025
73026 diff --git a/include/net/ip.h b/include/net/ip.h
73027 index a68f838..74518ab 100644
73028 --- a/include/net/ip.h
73029 +++ b/include/net/ip.h
73030 @@ -202,7 +202,7 @@ extern struct local_ports {
73031 } sysctl_local_ports;
73032 extern void inet_get_local_port_range(int *low, int *high);
73033
73034 -extern unsigned long *sysctl_local_reserved_ports;
73035 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
73036 static inline int inet_is_reserved_local_port(int port)
73037 {
73038 return test_bit(port, sysctl_local_reserved_ports);
73039 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
73040 index e49db91..76a81de 100644
73041 --- a/include/net/ip_fib.h
73042 +++ b/include/net/ip_fib.h
73043 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
73044
73045 #define FIB_RES_SADDR(net, res) \
73046 ((FIB_RES_NH(res).nh_saddr_genid == \
73047 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
73048 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
73049 FIB_RES_NH(res).nh_saddr : \
73050 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
73051 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
73052 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
73053 index 4c062cc..3562c31 100644
73054 --- a/include/net/ip_vs.h
73055 +++ b/include/net/ip_vs.h
73056 @@ -612,7 +612,7 @@ struct ip_vs_conn {
73057 struct ip_vs_conn *control; /* Master control connection */
73058 atomic_t n_control; /* Number of controlled ones */
73059 struct ip_vs_dest *dest; /* real server */
73060 - atomic_t in_pkts; /* incoming packet counter */
73061 + atomic_unchecked_t in_pkts; /* incoming packet counter */
73062
73063 /* packet transmitter for different forwarding methods. If it
73064 mangles the packet, it must return NF_DROP or better NF_STOLEN,
73065 @@ -761,7 +761,7 @@ struct ip_vs_dest {
73066 __be16 port; /* port number of the server */
73067 union nf_inet_addr addr; /* IP address of the server */
73068 volatile unsigned int flags; /* dest status flags */
73069 - atomic_t conn_flags; /* flags to copy to conn */
73070 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
73071 atomic_t weight; /* server weight */
73072
73073 atomic_t refcnt; /* reference counter */
73074 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
73075 /* ip_vs_lblc */
73076 int sysctl_lblc_expiration;
73077 struct ctl_table_header *lblc_ctl_header;
73078 - struct ctl_table *lblc_ctl_table;
73079 + ctl_table_no_const *lblc_ctl_table;
73080 /* ip_vs_lblcr */
73081 int sysctl_lblcr_expiration;
73082 struct ctl_table_header *lblcr_ctl_header;
73083 - struct ctl_table *lblcr_ctl_table;
73084 + ctl_table_no_const *lblcr_ctl_table;
73085 /* ip_vs_est */
73086 struct list_head est_list; /* estimator list */
73087 spinlock_t est_lock;
73088 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
73089 index 80ffde3..968b0f4 100644
73090 --- a/include/net/irda/ircomm_tty.h
73091 +++ b/include/net/irda/ircomm_tty.h
73092 @@ -35,6 +35,7 @@
73093 #include <linux/termios.h>
73094 #include <linux/timer.h>
73095 #include <linux/tty.h> /* struct tty_struct */
73096 +#include <asm/local.h>
73097
73098 #include <net/irda/irias_object.h>
73099 #include <net/irda/ircomm_core.h>
73100 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
73101 index 714cc9a..ea05f3e 100644
73102 --- a/include/net/iucv/af_iucv.h
73103 +++ b/include/net/iucv/af_iucv.h
73104 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
73105 struct iucv_sock_list {
73106 struct hlist_head head;
73107 rwlock_t lock;
73108 - atomic_t autobind_name;
73109 + atomic_unchecked_t autobind_name;
73110 };
73111
73112 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73113 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73114 index df83f69..9b640b8 100644
73115 --- a/include/net/llc_c_ac.h
73116 +++ b/include/net/llc_c_ac.h
73117 @@ -87,7 +87,7 @@
73118 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73119 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73120
73121 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73122 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73123
73124 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73125 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73126 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73127 index 6ca3113..f8026dd 100644
73128 --- a/include/net/llc_c_ev.h
73129 +++ b/include/net/llc_c_ev.h
73130 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73131 return (struct llc_conn_state_ev *)skb->cb;
73132 }
73133
73134 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73135 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73136 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73137 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73138
73139 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73140 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73141 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73142 index 0e79cfb..f46db31 100644
73143 --- a/include/net/llc_c_st.h
73144 +++ b/include/net/llc_c_st.h
73145 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73146 u8 next_state;
73147 llc_conn_ev_qfyr_t *ev_qualifiers;
73148 llc_conn_action_t *ev_actions;
73149 -};
73150 +} __do_const;
73151
73152 struct llc_conn_state {
73153 u8 current_state;
73154 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73155 index 37a3bbd..55a4241 100644
73156 --- a/include/net/llc_s_ac.h
73157 +++ b/include/net/llc_s_ac.h
73158 @@ -23,7 +23,7 @@
73159 #define SAP_ACT_TEST_IND 9
73160
73161 /* All action functions must look like this */
73162 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73163 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73164
73165 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73166 struct sk_buff *skb);
73167 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73168 index 567c681..cd73ac0 100644
73169 --- a/include/net/llc_s_st.h
73170 +++ b/include/net/llc_s_st.h
73171 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73172 llc_sap_ev_t ev;
73173 u8 next_state;
73174 llc_sap_action_t *ev_actions;
73175 -};
73176 +} __do_const;
73177
73178 struct llc_sap_state {
73179 u8 curr_state;
73180 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73181 index 885898a..cdace34 100644
73182 --- a/include/net/mac80211.h
73183 +++ b/include/net/mac80211.h
73184 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
73185 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73186 struct dentry *dir);
73187 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73188 -};
73189 +} __do_const;
73190
73191 static inline int rate_supported(struct ieee80211_sta *sta,
73192 enum ieee80211_band band,
73193 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73194 index 7e748ad..5c6229b 100644
73195 --- a/include/net/neighbour.h
73196 +++ b/include/net/neighbour.h
73197 @@ -123,7 +123,7 @@ struct neigh_ops {
73198 void (*error_report)(struct neighbour *, struct sk_buff *);
73199 int (*output)(struct neighbour *, struct sk_buff *);
73200 int (*connected_output)(struct neighbour *, struct sk_buff *);
73201 -};
73202 +} __do_const;
73203
73204 struct pneigh_entry {
73205 struct pneigh_entry *next;
73206 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73207 index b176978..ea169f4 100644
73208 --- a/include/net/net_namespace.h
73209 +++ b/include/net/net_namespace.h
73210 @@ -117,7 +117,7 @@ struct net {
73211 #endif
73212 struct netns_ipvs *ipvs;
73213 struct sock *diag_nlsk;
73214 - atomic_t rt_genid;
73215 + atomic_unchecked_t rt_genid;
73216 };
73217
73218 /*
73219 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73220 #define __net_init __init
73221 #define __net_exit __exit_refok
73222 #define __net_initdata __initdata
73223 +#ifdef CONSTIFY_PLUGIN
73224 #define __net_initconst __initconst
73225 +#else
73226 +#define __net_initconst __initdata
73227 +#endif
73228 #endif
73229
73230 struct pernet_operations {
73231 @@ -284,7 +288,7 @@ struct pernet_operations {
73232 void (*exit_batch)(struct list_head *net_exit_list);
73233 int *id;
73234 size_t size;
73235 -};
73236 +} __do_const;
73237
73238 /*
73239 * Use these carefully. If you implement a network device and it
73240 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73241
73242 static inline int rt_genid(struct net *net)
73243 {
73244 - return atomic_read(&net->rt_genid);
73245 + return atomic_read_unchecked(&net->rt_genid);
73246 }
73247
73248 static inline void rt_genid_bump(struct net *net)
73249 {
73250 - atomic_inc(&net->rt_genid);
73251 + atomic_inc_unchecked(&net->rt_genid);
73252 }
73253
73254 #endif /* __NET_NET_NAMESPACE_H */
73255 diff --git a/include/net/netdma.h b/include/net/netdma.h
73256 index 8ba8ce2..99b7fff 100644
73257 --- a/include/net/netdma.h
73258 +++ b/include/net/netdma.h
73259 @@ -24,7 +24,7 @@
73260 #include <linux/dmaengine.h>
73261 #include <linux/skbuff.h>
73262
73263 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73264 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73265 struct sk_buff *skb, int offset, struct iovec *to,
73266 size_t len, struct dma_pinned_list *pinned_list);
73267
73268 diff --git a/include/net/netlink.h b/include/net/netlink.h
73269 index 9690b0f..87aded7 100644
73270 --- a/include/net/netlink.h
73271 +++ b/include/net/netlink.h
73272 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73273 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73274 {
73275 if (mark)
73276 - skb_trim(skb, (unsigned char *) mark - skb->data);
73277 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73278 }
73279
73280 /**
73281 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73282 index c9c0c53..53f24c3 100644
73283 --- a/include/net/netns/conntrack.h
73284 +++ b/include/net/netns/conntrack.h
73285 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73286 struct nf_proto_net {
73287 #ifdef CONFIG_SYSCTL
73288 struct ctl_table_header *ctl_table_header;
73289 - struct ctl_table *ctl_table;
73290 + ctl_table_no_const *ctl_table;
73291 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73292 struct ctl_table_header *ctl_compat_header;
73293 - struct ctl_table *ctl_compat_table;
73294 + ctl_table_no_const *ctl_compat_table;
73295 #endif
73296 #endif
73297 unsigned int users;
73298 @@ -58,7 +58,7 @@ struct nf_ip_net {
73299 struct nf_icmp_net icmpv6;
73300 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73301 struct ctl_table_header *ctl_table_header;
73302 - struct ctl_table *ctl_table;
73303 + ctl_table_no_const *ctl_table;
73304 #endif
73305 };
73306
73307 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73308 index 2ba9de8..47bd6c7 100644
73309 --- a/include/net/netns/ipv4.h
73310 +++ b/include/net/netns/ipv4.h
73311 @@ -67,7 +67,7 @@ struct netns_ipv4 {
73312 kgid_t sysctl_ping_group_range[2];
73313 long sysctl_tcp_mem[3];
73314
73315 - atomic_t dev_addr_genid;
73316 + atomic_unchecked_t dev_addr_genid;
73317
73318 #ifdef CONFIG_IP_MROUTE
73319 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73320 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
73321 index 005e2c2..023d340 100644
73322 --- a/include/net/netns/ipv6.h
73323 +++ b/include/net/netns/ipv6.h
73324 @@ -71,7 +71,7 @@ struct netns_ipv6 {
73325 struct fib_rules_ops *mr6_rules_ops;
73326 #endif
73327 #endif
73328 - atomic_t dev_addr_genid;
73329 + atomic_unchecked_t dev_addr_genid;
73330 };
73331
73332 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
73333 diff --git a/include/net/protocol.h b/include/net/protocol.h
73334 index 047c047..b9dad15 100644
73335 --- a/include/net/protocol.h
73336 +++ b/include/net/protocol.h
73337 @@ -44,7 +44,7 @@ struct net_protocol {
73338 void (*err_handler)(struct sk_buff *skb, u32 info);
73339 unsigned int no_policy:1,
73340 netns_ok:1;
73341 -};
73342 +} __do_const;
73343
73344 #if IS_ENABLED(CONFIG_IPV6)
73345 struct inet6_protocol {
73346 @@ -57,7 +57,7 @@ struct inet6_protocol {
73347 u8 type, u8 code, int offset,
73348 __be32 info);
73349 unsigned int flags; /* INET6_PROTO_xxx */
73350 -};
73351 +} __do_const;
73352
73353 #define INET6_PROTO_NOPOLICY 0x1
73354 #define INET6_PROTO_FINAL 0x2
73355 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73356 index 7026648..584cc8c 100644
73357 --- a/include/net/rtnetlink.h
73358 +++ b/include/net/rtnetlink.h
73359 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73360 const struct net_device *dev);
73361 unsigned int (*get_num_tx_queues)(void);
73362 unsigned int (*get_num_rx_queues)(void);
73363 -};
73364 +} __do_const;
73365
73366 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73367 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73368 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73369 index cd89510..d67810f 100644
73370 --- a/include/net/sctp/sctp.h
73371 +++ b/include/net/sctp/sctp.h
73372 @@ -330,9 +330,9 @@ do { \
73373
73374 #else /* SCTP_DEBUG */
73375
73376 -#define SCTP_DEBUG_PRINTK(whatever...)
73377 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73378 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73379 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73380 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73381 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73382 #define SCTP_ENABLE_DEBUG
73383 #define SCTP_DISABLE_DEBUG
73384 #define SCTP_ASSERT(expr, str, func)
73385 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73386 index 2a82d13..62a31c2 100644
73387 --- a/include/net/sctp/sm.h
73388 +++ b/include/net/sctp/sm.h
73389 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73390 typedef struct {
73391 sctp_state_fn_t *fn;
73392 const char *name;
73393 -} sctp_sm_table_entry_t;
73394 +} __do_const sctp_sm_table_entry_t;
73395
73396 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73397 * currently in use.
73398 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73399 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73400
73401 /* Extern declarations for major data structures. */
73402 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73403 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73404
73405
73406 /* Get the size of a DATA chunk payload. */
73407 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73408 index 1bd4c41..9250b5b 100644
73409 --- a/include/net/sctp/structs.h
73410 +++ b/include/net/sctp/structs.h
73411 @@ -516,7 +516,7 @@ struct sctp_pf {
73412 struct sctp_association *asoc);
73413 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73414 struct sctp_af *af;
73415 -};
73416 +} __do_const;
73417
73418
73419 /* Structure to track chunk fragments that have been acked, but peer
73420 diff --git a/include/net/sock.h b/include/net/sock.h
73421 index 66772cf..25bc45b 100644
73422 --- a/include/net/sock.h
73423 +++ b/include/net/sock.h
73424 @@ -325,7 +325,7 @@ struct sock {
73425 #ifdef CONFIG_RPS
73426 __u32 sk_rxhash;
73427 #endif
73428 - atomic_t sk_drops;
73429 + atomic_unchecked_t sk_drops;
73430 int sk_rcvbuf;
73431
73432 struct sk_filter __rcu *sk_filter;
73433 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73434 }
73435
73436 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73437 - char __user *from, char *to,
73438 + char __user *from, unsigned char *to,
73439 int copy, int offset)
73440 {
73441 if (skb->ip_summed == CHECKSUM_NONE) {
73442 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73443 }
73444 }
73445
73446 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73447 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73448
73449 /**
73450 * sk_page_frag - return an appropriate page_frag
73451 diff --git a/include/net/tcp.h b/include/net/tcp.h
73452 index 5bba80f..8520a82 100644
73453 --- a/include/net/tcp.h
73454 +++ b/include/net/tcp.h
73455 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73456 extern void tcp_xmit_retransmit_queue(struct sock *);
73457 extern void tcp_simple_retransmit(struct sock *);
73458 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73459 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73460 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73461
73462 extern void tcp_send_probe0(struct sock *);
73463 extern void tcp_send_partial(struct sock *);
73464 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
73465 struct inet6_skb_parm h6;
73466 #endif
73467 } header; /* For incoming frames */
73468 - __u32 seq; /* Starting sequence number */
73469 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73470 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73471 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73472 __u32 when; /* used to compute rtt's */
73473 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73474
73475 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
73476
73477 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73478 /* 1 byte hole */
73479 - __u32 ack_seq; /* Sequence number ACK'd */
73480 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73481 };
73482
73483 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73484 diff --git a/include/net/udp.h b/include/net/udp.h
73485 index 065f379..ad99eed 100644
73486 --- a/include/net/udp.h
73487 +++ b/include/net/udp.h
73488 @@ -181,6 +181,7 @@ extern int udp_get_port(struct sock *sk, unsigned short snum,
73489 extern void udp_err(struct sk_buff *, u32);
73490 extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
73491 struct msghdr *msg, size_t len);
73492 +extern int udp_push_pending_frames(struct sock *sk);
73493 extern void udp_flush_pending_frames(struct sock *sk);
73494 extern int udp_rcv(struct sk_buff *skb);
73495 extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
73496 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73497 index 94ce082..62b278d 100644
73498 --- a/include/net/xfrm.h
73499 +++ b/include/net/xfrm.h
73500 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
73501 struct net_device *dev,
73502 const struct flowi *fl);
73503 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73504 -};
73505 +} __do_const;
73506
73507 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73508 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73509 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
73510 struct sk_buff *skb);
73511 int (*transport_finish)(struct sk_buff *skb,
73512 int async);
73513 -};
73514 +} __do_const;
73515
73516 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73517 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73518 @@ -424,7 +424,7 @@ struct xfrm_mode {
73519 struct module *owner;
73520 unsigned int encap;
73521 int flags;
73522 -};
73523 +} __do_const;
73524
73525 /* Flags for xfrm_mode. */
73526 enum {
73527 @@ -521,7 +521,7 @@ struct xfrm_policy {
73528 struct timer_list timer;
73529
73530 struct flow_cache_object flo;
73531 - atomic_t genid;
73532 + atomic_unchecked_t genid;
73533 u32 priority;
73534 u32 index;
73535 struct xfrm_mark mark;
73536 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73537 index 1a046b1..ee0bef0 100644
73538 --- a/include/rdma/iw_cm.h
73539 +++ b/include/rdma/iw_cm.h
73540 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73541 int backlog);
73542
73543 int (*destroy_listen)(struct iw_cm_id *cm_id);
73544 -};
73545 +} __no_const;
73546
73547 /**
73548 * iw_create_cm_id - Create an IW CM identifier.
73549 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73550 index e1379b4..67eafbe 100644
73551 --- a/include/scsi/libfc.h
73552 +++ b/include/scsi/libfc.h
73553 @@ -762,6 +762,7 @@ struct libfc_function_template {
73554 */
73555 void (*disc_stop_final) (struct fc_lport *);
73556 };
73557 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73558
73559 /**
73560 * struct fc_disc - Discovery context
73561 @@ -866,7 +867,7 @@ struct fc_lport {
73562 struct fc_vport *vport;
73563
73564 /* Operational Information */
73565 - struct libfc_function_template tt;
73566 + libfc_function_template_no_const tt;
73567 u8 link_up;
73568 u8 qfull;
73569 enum fc_lport_state state;
73570 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73571 index cc64587..608f523 100644
73572 --- a/include/scsi/scsi_device.h
73573 +++ b/include/scsi/scsi_device.h
73574 @@ -171,9 +171,9 @@ struct scsi_device {
73575 unsigned int max_device_blocked; /* what device_blocked counts down from */
73576 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73577
73578 - atomic_t iorequest_cnt;
73579 - atomic_t iodone_cnt;
73580 - atomic_t ioerr_cnt;
73581 + atomic_unchecked_t iorequest_cnt;
73582 + atomic_unchecked_t iodone_cnt;
73583 + atomic_unchecked_t ioerr_cnt;
73584
73585 struct device sdev_gendev,
73586 sdev_dev;
73587 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73588 index b797e8f..8e2c3aa 100644
73589 --- a/include/scsi/scsi_transport_fc.h
73590 +++ b/include/scsi/scsi_transport_fc.h
73591 @@ -751,7 +751,8 @@ struct fc_function_template {
73592 unsigned long show_host_system_hostname:1;
73593
73594 unsigned long disable_target_scan:1;
73595 -};
73596 +} __do_const;
73597 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73598
73599
73600 /**
73601 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73602 index 9031a26..750d592 100644
73603 --- a/include/sound/compress_driver.h
73604 +++ b/include/sound/compress_driver.h
73605 @@ -128,7 +128,7 @@ struct snd_compr_ops {
73606 struct snd_compr_caps *caps);
73607 int (*get_codec_caps) (struct snd_compr_stream *stream,
73608 struct snd_compr_codec_caps *codec);
73609 -};
73610 +} __no_const;
73611
73612 /**
73613 * struct snd_compr: Compressed device
73614 diff --git a/include/sound/soc.h b/include/sound/soc.h
73615 index 85c1522..f44bad1 100644
73616 --- a/include/sound/soc.h
73617 +++ b/include/sound/soc.h
73618 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
73619 /* probe ordering - for components with runtime dependencies */
73620 int probe_order;
73621 int remove_order;
73622 -};
73623 +} __do_const;
73624
73625 /* SoC platform interface */
73626 struct snd_soc_platform_driver {
73627 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
73628 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73629 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73630 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73631 -};
73632 +} __do_const;
73633
73634 struct snd_soc_platform {
73635 const char *name;
73636 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73637 index 4ea4f98..a63629b 100644
73638 --- a/include/target/target_core_base.h
73639 +++ b/include/target/target_core_base.h
73640 @@ -653,7 +653,7 @@ struct se_device {
73641 spinlock_t stats_lock;
73642 /* Active commands on this virtual SE device */
73643 atomic_t simple_cmds;
73644 - atomic_t dev_ordered_id;
73645 + atomic_unchecked_t dev_ordered_id;
73646 atomic_t dev_ordered_sync;
73647 atomic_t dev_qf_count;
73648 int export_count;
73649 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73650 new file mode 100644
73651 index 0000000..fb634b7
73652 --- /dev/null
73653 +++ b/include/trace/events/fs.h
73654 @@ -0,0 +1,53 @@
73655 +#undef TRACE_SYSTEM
73656 +#define TRACE_SYSTEM fs
73657 +
73658 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73659 +#define _TRACE_FS_H
73660 +
73661 +#include <linux/fs.h>
73662 +#include <linux/tracepoint.h>
73663 +
73664 +TRACE_EVENT(do_sys_open,
73665 +
73666 + TP_PROTO(const char *filename, int flags, int mode),
73667 +
73668 + TP_ARGS(filename, flags, mode),
73669 +
73670 + TP_STRUCT__entry(
73671 + __string( filename, filename )
73672 + __field( int, flags )
73673 + __field( int, mode )
73674 + ),
73675 +
73676 + TP_fast_assign(
73677 + __assign_str(filename, filename);
73678 + __entry->flags = flags;
73679 + __entry->mode = mode;
73680 + ),
73681 +
73682 + TP_printk("\"%s\" %x %o",
73683 + __get_str(filename), __entry->flags, __entry->mode)
73684 +);
73685 +
73686 +TRACE_EVENT(open_exec,
73687 +
73688 + TP_PROTO(const char *filename),
73689 +
73690 + TP_ARGS(filename),
73691 +
73692 + TP_STRUCT__entry(
73693 + __string( filename, filename )
73694 + ),
73695 +
73696 + TP_fast_assign(
73697 + __assign_str(filename, filename);
73698 + ),
73699 +
73700 + TP_printk("\"%s\"",
73701 + __get_str(filename))
73702 +);
73703 +
73704 +#endif /* _TRACE_FS_H */
73705 +
73706 +/* This part must be outside protection */
73707 +#include <trace/define_trace.h>
73708 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73709 index 1c09820..7f5ec79 100644
73710 --- a/include/trace/events/irq.h
73711 +++ b/include/trace/events/irq.h
73712 @@ -36,7 +36,7 @@ struct softirq_action;
73713 */
73714 TRACE_EVENT(irq_handler_entry,
73715
73716 - TP_PROTO(int irq, struct irqaction *action),
73717 + TP_PROTO(int irq, const struct irqaction *action),
73718
73719 TP_ARGS(irq, action),
73720
73721 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73722 */
73723 TRACE_EVENT(irq_handler_exit,
73724
73725 - TP_PROTO(int irq, struct irqaction *action, int ret),
73726 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73727
73728 TP_ARGS(irq, action, ret),
73729
73730 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73731 index 7caf44c..23c6f27 100644
73732 --- a/include/uapi/linux/a.out.h
73733 +++ b/include/uapi/linux/a.out.h
73734 @@ -39,6 +39,14 @@ enum machine_type {
73735 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73736 };
73737
73738 +/* Constants for the N_FLAGS field */
73739 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73740 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73741 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73742 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73743 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73744 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73745 +
73746 #if !defined (N_MAGIC)
73747 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73748 #endif
73749 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73750 index d876736..ccce5c0 100644
73751 --- a/include/uapi/linux/byteorder/little_endian.h
73752 +++ b/include/uapi/linux/byteorder/little_endian.h
73753 @@ -42,51 +42,51 @@
73754
73755 static inline __le64 __cpu_to_le64p(const __u64 *p)
73756 {
73757 - return (__force __le64)*p;
73758 + return (__force const __le64)*p;
73759 }
73760 -static inline __u64 __le64_to_cpup(const __le64 *p)
73761 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73762 {
73763 - return (__force __u64)*p;
73764 + return (__force const __u64)*p;
73765 }
73766 static inline __le32 __cpu_to_le32p(const __u32 *p)
73767 {
73768 - return (__force __le32)*p;
73769 + return (__force const __le32)*p;
73770 }
73771 static inline __u32 __le32_to_cpup(const __le32 *p)
73772 {
73773 - return (__force __u32)*p;
73774 + return (__force const __u32)*p;
73775 }
73776 static inline __le16 __cpu_to_le16p(const __u16 *p)
73777 {
73778 - return (__force __le16)*p;
73779 + return (__force const __le16)*p;
73780 }
73781 static inline __u16 __le16_to_cpup(const __le16 *p)
73782 {
73783 - return (__force __u16)*p;
73784 + return (__force const __u16)*p;
73785 }
73786 static inline __be64 __cpu_to_be64p(const __u64 *p)
73787 {
73788 - return (__force __be64)__swab64p(p);
73789 + return (__force const __be64)__swab64p(p);
73790 }
73791 static inline __u64 __be64_to_cpup(const __be64 *p)
73792 {
73793 - return __swab64p((__u64 *)p);
73794 + return __swab64p((const __u64 *)p);
73795 }
73796 static inline __be32 __cpu_to_be32p(const __u32 *p)
73797 {
73798 - return (__force __be32)__swab32p(p);
73799 + return (__force const __be32)__swab32p(p);
73800 }
73801 -static inline __u32 __be32_to_cpup(const __be32 *p)
73802 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73803 {
73804 - return __swab32p((__u32 *)p);
73805 + return __swab32p((const __u32 *)p);
73806 }
73807 static inline __be16 __cpu_to_be16p(const __u16 *p)
73808 {
73809 - return (__force __be16)__swab16p(p);
73810 + return (__force const __be16)__swab16p(p);
73811 }
73812 static inline __u16 __be16_to_cpup(const __be16 *p)
73813 {
73814 - return __swab16p((__u16 *)p);
73815 + return __swab16p((const __u16 *)p);
73816 }
73817 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73818 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73819 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73820 index ef6103b..d4e65dd 100644
73821 --- a/include/uapi/linux/elf.h
73822 +++ b/include/uapi/linux/elf.h
73823 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73824 #define PT_GNU_EH_FRAME 0x6474e550
73825
73826 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73827 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73828 +
73829 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73830 +
73831 +/* Constants for the e_flags field */
73832 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73833 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73834 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73835 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73836 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73837 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73838
73839 /*
73840 * Extended Numbering
73841 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73842 #define DT_DEBUG 21
73843 #define DT_TEXTREL 22
73844 #define DT_JMPREL 23
73845 +#define DT_FLAGS 30
73846 + #define DF_TEXTREL 0x00000004
73847 #define DT_ENCODING 32
73848 #define OLD_DT_LOOS 0x60000000
73849 #define DT_LOOS 0x6000000d
73850 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73851 #define PF_W 0x2
73852 #define PF_X 0x1
73853
73854 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73855 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73856 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73857 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73858 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73859 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73860 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73861 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73862 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73863 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73864 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73865 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73866 +
73867 typedef struct elf32_phdr{
73868 Elf32_Word p_type;
73869 Elf32_Off p_offset;
73870 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73871 #define EI_OSABI 7
73872 #define EI_PAD 8
73873
73874 +#define EI_PAX 14
73875 +
73876 #define ELFMAG0 0x7f /* EI_MAG */
73877 #define ELFMAG1 'E'
73878 #define ELFMAG2 'L'
73879 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73880 index aa169c4..6a2771d 100644
73881 --- a/include/uapi/linux/personality.h
73882 +++ b/include/uapi/linux/personality.h
73883 @@ -30,6 +30,7 @@ enum {
73884 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73885 ADDR_NO_RANDOMIZE | \
73886 ADDR_COMPAT_LAYOUT | \
73887 + ADDR_LIMIT_3GB | \
73888 MMAP_PAGE_ZERO)
73889
73890 /*
73891 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73892 index 7530e74..e714828 100644
73893 --- a/include/uapi/linux/screen_info.h
73894 +++ b/include/uapi/linux/screen_info.h
73895 @@ -43,7 +43,8 @@ struct screen_info {
73896 __u16 pages; /* 0x32 */
73897 __u16 vesa_attributes; /* 0x34 */
73898 __u32 capabilities; /* 0x36 */
73899 - __u8 _reserved[6]; /* 0x3a */
73900 + __u16 vesapm_size; /* 0x3a */
73901 + __u8 _reserved[4]; /* 0x3c */
73902 } __attribute__((packed));
73903
73904 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73905 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73906 index 0e011eb..82681b1 100644
73907 --- a/include/uapi/linux/swab.h
73908 +++ b/include/uapi/linux/swab.h
73909 @@ -43,7 +43,7 @@
73910 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73911 */
73912
73913 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73914 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73915 {
73916 #ifdef __HAVE_BUILTIN_BSWAP16__
73917 return __builtin_bswap16(val);
73918 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73919 #endif
73920 }
73921
73922 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73923 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73924 {
73925 #ifdef __HAVE_BUILTIN_BSWAP32__
73926 return __builtin_bswap32(val);
73927 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73928 #endif
73929 }
73930
73931 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73932 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73933 {
73934 #ifdef __HAVE_BUILTIN_BSWAP64__
73935 return __builtin_bswap64(val);
73936 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73937 index 6d67213..8dab561 100644
73938 --- a/include/uapi/linux/sysctl.h
73939 +++ b/include/uapi/linux/sysctl.h
73940 @@ -155,7 +155,11 @@ enum
73941 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73942 };
73943
73944 -
73945 +#ifdef CONFIG_PAX_SOFTMODE
73946 +enum {
73947 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73948 +};
73949 +#endif
73950
73951 /* CTL_VM names: */
73952 enum
73953 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73954 index e4629b9..6958086 100644
73955 --- a/include/uapi/linux/xattr.h
73956 +++ b/include/uapi/linux/xattr.h
73957 @@ -63,5 +63,9 @@
73958 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73959 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73960
73961 +/* User namespace */
73962 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73963 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73964 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73965
73966 #endif /* _UAPI_LINUX_XATTR_H */
73967 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73968 index f9466fa..f4e2b81 100644
73969 --- a/include/video/udlfb.h
73970 +++ b/include/video/udlfb.h
73971 @@ -53,10 +53,10 @@ struct dlfb_data {
73972 u32 pseudo_palette[256];
73973 int blank_mode; /*one of FB_BLANK_ */
73974 /* blit-only rendering path metrics, exposed through sysfs */
73975 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73976 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73977 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73978 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73979 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73980 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73981 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73982 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73983 };
73984
73985 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73986 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73987 index 1a91850..28573f8 100644
73988 --- a/include/video/uvesafb.h
73989 +++ b/include/video/uvesafb.h
73990 @@ -122,6 +122,7 @@ struct uvesafb_par {
73991 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73992 u8 pmi_setpal; /* PMI for palette changes */
73993 u16 *pmi_base; /* protected mode interface location */
73994 + u8 *pmi_code; /* protected mode code location */
73995 void *pmi_start;
73996 void *pmi_pal;
73997 u8 *vbe_state_orig; /*
73998 diff --git a/init/Kconfig b/init/Kconfig
73999 index 2d9b831..ae4c8ac 100644
74000 --- a/init/Kconfig
74001 +++ b/init/Kconfig
74002 @@ -1029,6 +1029,7 @@ endif # CGROUPS
74003
74004 config CHECKPOINT_RESTORE
74005 bool "Checkpoint/restore support" if EXPERT
74006 + depends on !GRKERNSEC
74007 default n
74008 help
74009 Enables additional kernel features in a sake of checkpoint/restore.
74010 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
74011
74012 config COMPAT_BRK
74013 bool "Disable heap randomization"
74014 - default y
74015 + default n
74016 help
74017 Randomizing heap placement makes heap exploits harder, but it
74018 also breaks ancient binaries (including anything libc5 based).
74019 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
74020 config STOP_MACHINE
74021 bool
74022 default y
74023 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
74024 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
74025 help
74026 Need stop_machine() primitive.
74027
74028 diff --git a/init/Makefile b/init/Makefile
74029 index 7bc47ee..6da2dc7 100644
74030 --- a/init/Makefile
74031 +++ b/init/Makefile
74032 @@ -2,6 +2,9 @@
74033 # Makefile for the linux kernel.
74034 #
74035
74036 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
74037 +asflags-y := $(GCC_PLUGINS_AFLAGS)
74038 +
74039 obj-y := main.o version.o mounts.o
74040 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
74041 obj-y += noinitramfs.o
74042 diff --git a/init/do_mounts.c b/init/do_mounts.c
74043 index a2b49f2..03a0e17c 100644
74044 --- a/init/do_mounts.c
74045 +++ b/init/do_mounts.c
74046 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
74047 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
74048 {
74049 struct super_block *s;
74050 - int err = sys_mount(name, "/root", fs, flags, data);
74051 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
74052 if (err)
74053 return err;
74054
74055 - sys_chdir("/root");
74056 + sys_chdir((const char __force_user *)"/root");
74057 s = current->fs->pwd.dentry->d_sb;
74058 ROOT_DEV = s->s_dev;
74059 printk(KERN_INFO
74060 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
74061 va_start(args, fmt);
74062 vsprintf(buf, fmt, args);
74063 va_end(args);
74064 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
74065 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
74066 if (fd >= 0) {
74067 sys_ioctl(fd, FDEJECT, 0);
74068 sys_close(fd);
74069 }
74070 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
74071 - fd = sys_open("/dev/console", O_RDWR, 0);
74072 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
74073 if (fd >= 0) {
74074 sys_ioctl(fd, TCGETS, (long)&termios);
74075 termios.c_lflag &= ~ICANON;
74076 sys_ioctl(fd, TCSETSF, (long)&termios);
74077 - sys_read(fd, &c, 1);
74078 + sys_read(fd, (char __user *)&c, 1);
74079 termios.c_lflag |= ICANON;
74080 sys_ioctl(fd, TCSETSF, (long)&termios);
74081 sys_close(fd);
74082 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
74083 mount_root();
74084 out:
74085 devtmpfs_mount("dev");
74086 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74087 - sys_chroot(".");
74088 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74089 + sys_chroot((const char __force_user *)".");
74090 }
74091 diff --git a/init/do_mounts.h b/init/do_mounts.h
74092 index f5b978a..69dbfe8 100644
74093 --- a/init/do_mounts.h
74094 +++ b/init/do_mounts.h
74095 @@ -15,15 +15,15 @@ extern int root_mountflags;
74096
74097 static inline int create_dev(char *name, dev_t dev)
74098 {
74099 - sys_unlink(name);
74100 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
74101 + sys_unlink((char __force_user *)name);
74102 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
74103 }
74104
74105 #if BITS_PER_LONG == 32
74106 static inline u32 bstat(char *name)
74107 {
74108 struct stat64 stat;
74109 - if (sys_stat64(name, &stat) != 0)
74110 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
74111 return 0;
74112 if (!S_ISBLK(stat.st_mode))
74113 return 0;
74114 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
74115 static inline u32 bstat(char *name)
74116 {
74117 struct stat stat;
74118 - if (sys_newstat(name, &stat) != 0)
74119 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
74120 return 0;
74121 if (!S_ISBLK(stat.st_mode))
74122 return 0;
74123 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74124 index 3e0878e..8a9d7a0 100644
74125 --- a/init/do_mounts_initrd.c
74126 +++ b/init/do_mounts_initrd.c
74127 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
74128 {
74129 sys_unshare(CLONE_FS | CLONE_FILES);
74130 /* stdin/stdout/stderr for /linuxrc */
74131 - sys_open("/dev/console", O_RDWR, 0);
74132 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
74133 sys_dup(0);
74134 sys_dup(0);
74135 /* move initrd over / and chdir/chroot in initrd root */
74136 - sys_chdir("/root");
74137 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74138 - sys_chroot(".");
74139 + sys_chdir((const char __force_user *)"/root");
74140 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74141 + sys_chroot((const char __force_user *)".");
74142 sys_setsid();
74143 return 0;
74144 }
74145 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
74146 create_dev("/dev/root.old", Root_RAM0);
74147 /* mount initrd on rootfs' /root */
74148 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74149 - sys_mkdir("/old", 0700);
74150 - sys_chdir("/old");
74151 + sys_mkdir((const char __force_user *)"/old", 0700);
74152 + sys_chdir((const char __force_user *)"/old");
74153
74154 /* try loading default modules from initrd */
74155 load_default_modules();
74156 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
74157 current->flags &= ~PF_FREEZER_SKIP;
74158
74159 /* move initrd to rootfs' /old */
74160 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74161 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74162 /* switch root and cwd back to / of rootfs */
74163 - sys_chroot("..");
74164 + sys_chroot((const char __force_user *)"..");
74165
74166 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74167 - sys_chdir("/old");
74168 + sys_chdir((const char __force_user *)"/old");
74169 return;
74170 }
74171
74172 - sys_chdir("/");
74173 + sys_chdir((const char __force_user *)"/");
74174 ROOT_DEV = new_decode_dev(real_root_dev);
74175 mount_root();
74176
74177 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74178 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74179 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74180 if (!error)
74181 printk("okay\n");
74182 else {
74183 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74184 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74185 if (error == -ENOENT)
74186 printk("/initrd does not exist. Ignored.\n");
74187 else
74188 printk("failed\n");
74189 printk(KERN_NOTICE "Unmounting old root\n");
74190 - sys_umount("/old", MNT_DETACH);
74191 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74192 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74193 if (fd < 0) {
74194 error = fd;
74195 @@ -127,11 +127,11 @@ int __init initrd_load(void)
74196 * mounted in the normal path.
74197 */
74198 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74199 - sys_unlink("/initrd.image");
74200 + sys_unlink((const char __force_user *)"/initrd.image");
74201 handle_initrd();
74202 return 1;
74203 }
74204 }
74205 - sys_unlink("/initrd.image");
74206 + sys_unlink((const char __force_user *)"/initrd.image");
74207 return 0;
74208 }
74209 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74210 index 8cb6db5..d729f50 100644
74211 --- a/init/do_mounts_md.c
74212 +++ b/init/do_mounts_md.c
74213 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74214 partitioned ? "_d" : "", minor,
74215 md_setup_args[ent].device_names);
74216
74217 - fd = sys_open(name, 0, 0);
74218 + fd = sys_open((char __force_user *)name, 0, 0);
74219 if (fd < 0) {
74220 printk(KERN_ERR "md: open failed - cannot start "
74221 "array %s\n", name);
74222 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
74223 * array without it
74224 */
74225 sys_close(fd);
74226 - fd = sys_open(name, 0, 0);
74227 + fd = sys_open((char __force_user *)name, 0, 0);
74228 sys_ioctl(fd, BLKRRPART, 0);
74229 }
74230 sys_close(fd);
74231 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
74232
74233 wait_for_device_probe();
74234
74235 - fd = sys_open("/dev/md0", 0, 0);
74236 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
74237 if (fd >= 0) {
74238 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
74239 sys_close(fd);
74240 diff --git a/init/init_task.c b/init/init_task.c
74241 index ba0a7f36..2bcf1d5 100644
74242 --- a/init/init_task.c
74243 +++ b/init/init_task.c
74244 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
74245 * Initial thread structure. Alignment of this is handled by a special
74246 * linker map entry.
74247 */
74248 +#ifdef CONFIG_X86
74249 +union thread_union init_thread_union __init_task_data;
74250 +#else
74251 union thread_union init_thread_union __init_task_data =
74252 { INIT_THREAD_INFO(init_task) };
74253 +#endif
74254 diff --git a/init/initramfs.c b/init/initramfs.c
74255 index a67ef9d..2d17ed9 100644
74256 --- a/init/initramfs.c
74257 +++ b/init/initramfs.c
74258 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74259 }
74260 }
74261
74262 -static long __init do_utime(char *filename, time_t mtime)
74263 +static long __init do_utime(char __force_user *filename, time_t mtime)
74264 {
74265 struct timespec t[2];
74266
74267 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74268 struct dir_entry *de, *tmp;
74269 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74270 list_del(&de->list);
74271 - do_utime(de->name, de->mtime);
74272 + do_utime((char __force_user *)de->name, de->mtime);
74273 kfree(de->name);
74274 kfree(de);
74275 }
74276 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74277 if (nlink >= 2) {
74278 char *old = find_link(major, minor, ino, mode, collected);
74279 if (old)
74280 - return (sys_link(old, collected) < 0) ? -1 : 1;
74281 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74282 }
74283 return 0;
74284 }
74285 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74286 {
74287 struct stat st;
74288
74289 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74290 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74291 if (S_ISDIR(st.st_mode))
74292 - sys_rmdir(path);
74293 + sys_rmdir((char __force_user *)path);
74294 else
74295 - sys_unlink(path);
74296 + sys_unlink((char __force_user *)path);
74297 }
74298 }
74299
74300 @@ -315,7 +315,7 @@ static int __init do_name(void)
74301 int openflags = O_WRONLY|O_CREAT;
74302 if (ml != 1)
74303 openflags |= O_TRUNC;
74304 - wfd = sys_open(collected, openflags, mode);
74305 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74306
74307 if (wfd >= 0) {
74308 sys_fchown(wfd, uid, gid);
74309 @@ -327,17 +327,17 @@ static int __init do_name(void)
74310 }
74311 }
74312 } else if (S_ISDIR(mode)) {
74313 - sys_mkdir(collected, mode);
74314 - sys_chown(collected, uid, gid);
74315 - sys_chmod(collected, mode);
74316 + sys_mkdir((char __force_user *)collected, mode);
74317 + sys_chown((char __force_user *)collected, uid, gid);
74318 + sys_chmod((char __force_user *)collected, mode);
74319 dir_add(collected, mtime);
74320 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74321 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74322 if (maybe_link() == 0) {
74323 - sys_mknod(collected, mode, rdev);
74324 - sys_chown(collected, uid, gid);
74325 - sys_chmod(collected, mode);
74326 - do_utime(collected, mtime);
74327 + sys_mknod((char __force_user *)collected, mode, rdev);
74328 + sys_chown((char __force_user *)collected, uid, gid);
74329 + sys_chmod((char __force_user *)collected, mode);
74330 + do_utime((char __force_user *)collected, mtime);
74331 }
74332 }
74333 return 0;
74334 @@ -346,15 +346,15 @@ static int __init do_name(void)
74335 static int __init do_copy(void)
74336 {
74337 if (count >= body_len) {
74338 - sys_write(wfd, victim, body_len);
74339 + sys_write(wfd, (char __force_user *)victim, body_len);
74340 sys_close(wfd);
74341 - do_utime(vcollected, mtime);
74342 + do_utime((char __force_user *)vcollected, mtime);
74343 kfree(vcollected);
74344 eat(body_len);
74345 state = SkipIt;
74346 return 0;
74347 } else {
74348 - sys_write(wfd, victim, count);
74349 + sys_write(wfd, (char __force_user *)victim, count);
74350 body_len -= count;
74351 eat(count);
74352 return 1;
74353 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74354 {
74355 collected[N_ALIGN(name_len) + body_len] = '\0';
74356 clean_path(collected, 0);
74357 - sys_symlink(collected + N_ALIGN(name_len), collected);
74358 - sys_lchown(collected, uid, gid);
74359 - do_utime(collected, mtime);
74360 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74361 + sys_lchown((char __force_user *)collected, uid, gid);
74362 + do_utime((char __force_user *)collected, mtime);
74363 state = SkipIt;
74364 next_state = Reset;
74365 return 0;
74366 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
74367 {
74368 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
74369 if (err)
74370 - panic(err); /* Failed to decompress INTERNAL initramfs */
74371 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
74372 if (initrd_start) {
74373 #ifdef CONFIG_BLK_DEV_RAM
74374 int fd;
74375 diff --git a/init/main.c b/init/main.c
74376 index 9484f4b..4c01430 100644
74377 --- a/init/main.c
74378 +++ b/init/main.c
74379 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
74380 extern void tc_init(void);
74381 #endif
74382
74383 +extern void grsecurity_init(void);
74384 +
74385 /*
74386 * Debug helper: via this flag we know that we are in 'early bootup code'
74387 * where only the boot processor is running with IRQ disabled. This means
74388 @@ -153,6 +155,64 @@ static int __init set_reset_devices(char *str)
74389
74390 __setup("reset_devices", set_reset_devices);
74391
74392 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74393 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74394 +static int __init setup_grsec_proc_gid(char *str)
74395 +{
74396 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74397 + return 1;
74398 +}
74399 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74400 +#endif
74401 +
74402 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74403 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
74404 +EXPORT_SYMBOL(pax_user_shadow_base);
74405 +extern char pax_enter_kernel_user[];
74406 +extern char pax_exit_kernel_user[];
74407 +extern pgdval_t clone_pgd_mask;
74408 +#endif
74409 +
74410 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74411 +static int __init setup_pax_nouderef(char *str)
74412 +{
74413 +#ifdef CONFIG_X86_32
74414 + unsigned int cpu;
74415 + struct desc_struct *gdt;
74416 +
74417 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74418 + gdt = get_cpu_gdt_table(cpu);
74419 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74420 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74421 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74422 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74423 + }
74424 + loadsegment(ds, __KERNEL_DS);
74425 + loadsegment(es, __KERNEL_DS);
74426 + loadsegment(ss, __KERNEL_DS);
74427 +#else
74428 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74429 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74430 + clone_pgd_mask = ~(pgdval_t)0UL;
74431 + pax_user_shadow_base = 0UL;
74432 +#endif
74433 +
74434 + return 0;
74435 +}
74436 +early_param("pax_nouderef", setup_pax_nouderef);
74437 +#endif
74438 +
74439 +#ifdef CONFIG_PAX_SOFTMODE
74440 +int pax_softmode;
74441 +
74442 +static int __init setup_pax_softmode(char *str)
74443 +{
74444 + get_option(&str, &pax_softmode);
74445 + return 1;
74446 +}
74447 +__setup("pax_softmode=", setup_pax_softmode);
74448 +#endif
74449 +
74450 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74451 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74452 static const char *panic_later, *panic_param;
74453 @@ -655,8 +715,6 @@ static void __init do_ctors(void)
74454 bool initcall_debug;
74455 core_param(initcall_debug, initcall_debug, bool, 0644);
74456
74457 -static char msgbuf[64];
74458 -
74459 static int __init_or_module do_one_initcall_debug(initcall_t fn)
74460 {
74461 ktime_t calltime, delta, rettime;
74462 @@ -679,23 +737,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
74463 {
74464 int count = preempt_count();
74465 int ret;
74466 + const char *msg1 = "", *msg2 = "";
74467
74468 if (initcall_debug)
74469 ret = do_one_initcall_debug(fn);
74470 else
74471 ret = fn();
74472
74473 - msgbuf[0] = 0;
74474 -
74475 if (preempt_count() != count) {
74476 - sprintf(msgbuf, "preemption imbalance ");
74477 + msg1 = " preemption imbalance";
74478 preempt_count() = count;
74479 }
74480 if (irqs_disabled()) {
74481 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74482 + msg2 = " disabled interrupts";
74483 local_irq_enable();
74484 }
74485 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
74486 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
74487
74488 return ret;
74489 }
74490 @@ -748,8 +805,14 @@ static void __init do_initcall_level(int level)
74491 level, level,
74492 &repair_env_string);
74493
74494 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74495 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74496 do_one_initcall(*fn);
74497 +
74498 +#ifdef LATENT_ENTROPY_PLUGIN
74499 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74500 +#endif
74501 +
74502 + }
74503 }
74504
74505 static void __init do_initcalls(void)
74506 @@ -783,8 +846,14 @@ static void __init do_pre_smp_initcalls(void)
74507 {
74508 initcall_t *fn;
74509
74510 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74511 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74512 do_one_initcall(*fn);
74513 +
74514 +#ifdef LATENT_ENTROPY_PLUGIN
74515 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74516 +#endif
74517 +
74518 + }
74519 }
74520
74521 /*
74522 @@ -802,8 +871,8 @@ static int run_init_process(const char *init_filename)
74523 {
74524 argv_init[0] = init_filename;
74525 return do_execve(init_filename,
74526 - (const char __user *const __user *)argv_init,
74527 - (const char __user *const __user *)envp_init);
74528 + (const char __user *const __force_user *)argv_init,
74529 + (const char __user *const __force_user *)envp_init);
74530 }
74531
74532 static noinline void __init kernel_init_freeable(void);
74533 @@ -880,7 +949,7 @@ static noinline void __init kernel_init_freeable(void)
74534 do_basic_setup();
74535
74536 /* Open the /dev/console on the rootfs, this should never fail */
74537 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74538 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74539 pr_err("Warning: unable to open an initial console.\n");
74540
74541 (void) sys_dup(0);
74542 @@ -893,11 +962,13 @@ static noinline void __init kernel_init_freeable(void)
74543 if (!ramdisk_execute_command)
74544 ramdisk_execute_command = "/init";
74545
74546 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74547 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74548 ramdisk_execute_command = NULL;
74549 prepare_namespace();
74550 }
74551
74552 + grsecurity_init();
74553 +
74554 /*
74555 * Ok, we have completed the initial bootup, and
74556 * we're essentially up and running. Get rid of the
74557 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74558 index 130dfec..cc88451 100644
74559 --- a/ipc/ipc_sysctl.c
74560 +++ b/ipc/ipc_sysctl.c
74561 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74562 static int proc_ipc_dointvec(ctl_table *table, int write,
74563 void __user *buffer, size_t *lenp, loff_t *ppos)
74564 {
74565 - struct ctl_table ipc_table;
74566 + ctl_table_no_const ipc_table;
74567
74568 memcpy(&ipc_table, table, sizeof(ipc_table));
74569 ipc_table.data = get_ipc(table);
74570 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74571 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74572 void __user *buffer, size_t *lenp, loff_t *ppos)
74573 {
74574 - struct ctl_table ipc_table;
74575 + ctl_table_no_const ipc_table;
74576
74577 memcpy(&ipc_table, table, sizeof(ipc_table));
74578 ipc_table.data = get_ipc(table);
74579 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74580 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74581 void __user *buffer, size_t *lenp, loff_t *ppos)
74582 {
74583 - struct ctl_table ipc_table;
74584 + ctl_table_no_const ipc_table;
74585 size_t lenp_bef = *lenp;
74586 int rc;
74587
74588 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74589 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74590 void __user *buffer, size_t *lenp, loff_t *ppos)
74591 {
74592 - struct ctl_table ipc_table;
74593 + ctl_table_no_const ipc_table;
74594 memcpy(&ipc_table, table, sizeof(ipc_table));
74595 ipc_table.data = get_ipc(table);
74596
74597 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74598 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74599 void __user *buffer, size_t *lenp, loff_t *ppos)
74600 {
74601 - struct ctl_table ipc_table;
74602 + ctl_table_no_const ipc_table;
74603 size_t lenp_bef = *lenp;
74604 int oldval;
74605 int rc;
74606 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74607 index 383d638..943fdbb 100644
74608 --- a/ipc/mq_sysctl.c
74609 +++ b/ipc/mq_sysctl.c
74610 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74611 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74612 void __user *buffer, size_t *lenp, loff_t *ppos)
74613 {
74614 - struct ctl_table mq_table;
74615 + ctl_table_no_const mq_table;
74616 memcpy(&mq_table, table, sizeof(mq_table));
74617 mq_table.data = get_mq(table);
74618
74619 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74620 index e4e47f6..a85e0ad 100644
74621 --- a/ipc/mqueue.c
74622 +++ b/ipc/mqueue.c
74623 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74624 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74625 info->attr.mq_msgsize);
74626
74627 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74628 spin_lock(&mq_lock);
74629 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74630 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74631 diff --git a/ipc/msg.c b/ipc/msg.c
74632 index d0c6d96..69a893c 100644
74633 --- a/ipc/msg.c
74634 +++ b/ipc/msg.c
74635 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74636 return security_msg_queue_associate(msq, msgflg);
74637 }
74638
74639 +static struct ipc_ops msg_ops = {
74640 + .getnew = newque,
74641 + .associate = msg_security,
74642 + .more_checks = NULL
74643 +};
74644 +
74645 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74646 {
74647 struct ipc_namespace *ns;
74648 - struct ipc_ops msg_ops;
74649 struct ipc_params msg_params;
74650
74651 ns = current->nsproxy->ipc_ns;
74652
74653 - msg_ops.getnew = newque;
74654 - msg_ops.associate = msg_security;
74655 - msg_ops.more_checks = NULL;
74656 -
74657 msg_params.key = key;
74658 msg_params.flg = msgflg;
74659
74660 diff --git a/ipc/sem.c b/ipc/sem.c
74661 index 70480a3..f4e8262 100644
74662 --- a/ipc/sem.c
74663 +++ b/ipc/sem.c
74664 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74665 return 0;
74666 }
74667
74668 +static struct ipc_ops sem_ops = {
74669 + .getnew = newary,
74670 + .associate = sem_security,
74671 + .more_checks = sem_more_checks
74672 +};
74673 +
74674 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74675 {
74676 struct ipc_namespace *ns;
74677 - struct ipc_ops sem_ops;
74678 struct ipc_params sem_params;
74679
74680 ns = current->nsproxy->ipc_ns;
74681 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74682 if (nsems < 0 || nsems > ns->sc_semmsl)
74683 return -EINVAL;
74684
74685 - sem_ops.getnew = newary;
74686 - sem_ops.associate = sem_security;
74687 - sem_ops.more_checks = sem_more_checks;
74688 -
74689 sem_params.key = key;
74690 sem_params.flg = semflg;
74691 sem_params.u.nsems = nsems;
74692 diff --git a/ipc/shm.c b/ipc/shm.c
74693 index 7e199fa..180a1ca 100644
74694 --- a/ipc/shm.c
74695 +++ b/ipc/shm.c
74696 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74697 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74698 #endif
74699
74700 +#ifdef CONFIG_GRKERNSEC
74701 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74702 + const time_t shm_createtime, const kuid_t cuid,
74703 + const int shmid);
74704 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74705 + const time_t shm_createtime);
74706 +#endif
74707 +
74708 void shm_init_ns(struct ipc_namespace *ns)
74709 {
74710 ns->shm_ctlmax = SHMMAX;
74711 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74712 shp->shm_lprid = 0;
74713 shp->shm_atim = shp->shm_dtim = 0;
74714 shp->shm_ctim = get_seconds();
74715 +#ifdef CONFIG_GRKERNSEC
74716 + {
74717 + struct timespec timeval;
74718 + do_posix_clock_monotonic_gettime(&timeval);
74719 +
74720 + shp->shm_createtime = timeval.tv_sec;
74721 + }
74722 +#endif
74723 shp->shm_segsz = size;
74724 shp->shm_nattch = 0;
74725 shp->shm_file = file;
74726 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74727 return 0;
74728 }
74729
74730 +static struct ipc_ops shm_ops = {
74731 + .getnew = newseg,
74732 + .associate = shm_security,
74733 + .more_checks = shm_more_checks
74734 +};
74735 +
74736 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74737 {
74738 struct ipc_namespace *ns;
74739 - struct ipc_ops shm_ops;
74740 struct ipc_params shm_params;
74741
74742 ns = current->nsproxy->ipc_ns;
74743
74744 - shm_ops.getnew = newseg;
74745 - shm_ops.associate = shm_security;
74746 - shm_ops.more_checks = shm_more_checks;
74747 -
74748 shm_params.key = key;
74749 shm_params.flg = shmflg;
74750 shm_params.u.size = size;
74751 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74752 f_mode = FMODE_READ | FMODE_WRITE;
74753 }
74754 if (shmflg & SHM_EXEC) {
74755 +
74756 +#ifdef CONFIG_PAX_MPROTECT
74757 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74758 + goto out;
74759 +#endif
74760 +
74761 prot |= PROT_EXEC;
74762 acc_mode |= S_IXUGO;
74763 }
74764 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74765 if (err)
74766 goto out_unlock;
74767
74768 +#ifdef CONFIG_GRKERNSEC
74769 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74770 + shp->shm_perm.cuid, shmid) ||
74771 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74772 + err = -EACCES;
74773 + goto out_unlock;
74774 + }
74775 +#endif
74776 +
74777 path = shp->shm_file->f_path;
74778 path_get(&path);
74779 shp->shm_nattch++;
74780 +#ifdef CONFIG_GRKERNSEC
74781 + shp->shm_lapid = current->pid;
74782 +#endif
74783 size = i_size_read(path.dentry->d_inode);
74784 shm_unlock(shp);
74785
74786 diff --git a/kernel/acct.c b/kernel/acct.c
74787 index 8d6e145..33e0b1e 100644
74788 --- a/kernel/acct.c
74789 +++ b/kernel/acct.c
74790 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74791 */
74792 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74793 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74794 - file->f_op->write(file, (char *)&ac,
74795 + file->f_op->write(file, (char __force_user *)&ac,
74796 sizeof(acct_t), &file->f_pos);
74797 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74798 set_fs(fs);
74799 diff --git a/kernel/audit.c b/kernel/audit.c
74800 index 91e53d0..d9e3ec4 100644
74801 --- a/kernel/audit.c
74802 +++ b/kernel/audit.c
74803 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
74804 3) suppressed due to audit_rate_limit
74805 4) suppressed due to audit_backlog_limit
74806 */
74807 -static atomic_t audit_lost = ATOMIC_INIT(0);
74808 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74809
74810 /* The netlink socket. */
74811 static struct sock *audit_sock;
74812 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
74813 unsigned long now;
74814 int print;
74815
74816 - atomic_inc(&audit_lost);
74817 + atomic_inc_unchecked(&audit_lost);
74818
74819 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74820
74821 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
74822 printk(KERN_WARNING
74823 "audit: audit_lost=%d audit_rate_limit=%d "
74824 "audit_backlog_limit=%d\n",
74825 - atomic_read(&audit_lost),
74826 + atomic_read_unchecked(&audit_lost),
74827 audit_rate_limit,
74828 audit_backlog_limit);
74829 audit_panic(message);
74830 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74831 status_set.pid = audit_pid;
74832 status_set.rate_limit = audit_rate_limit;
74833 status_set.backlog_limit = audit_backlog_limit;
74834 - status_set.lost = atomic_read(&audit_lost);
74835 + status_set.lost = atomic_read_unchecked(&audit_lost);
74836 status_set.backlog = skb_queue_len(&audit_skb_queue);
74837 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74838 &status_set, sizeof(status_set));
74839 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
74840 index 6bd4a90..0ee9eff 100644
74841 --- a/kernel/auditfilter.c
74842 +++ b/kernel/auditfilter.c
74843 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
74844 f->lsm_rule = NULL;
74845
74846 /* Support legacy tests for a valid loginuid */
74847 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
74848 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
74849 f->type = AUDIT_LOGINUID_SET;
74850 f->val = 0;
74851 }
74852 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74853 index 3c8a601..3a416f6 100644
74854 --- a/kernel/auditsc.c
74855 +++ b/kernel/auditsc.c
74856 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74857 }
74858
74859 /* global counter which is incremented every time something logs in */
74860 -static atomic_t session_id = ATOMIC_INIT(0);
74861 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74862
74863 /**
74864 * audit_set_loginuid - set current task's audit_context loginuid
74865 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
74866 return -EPERM;
74867 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74868
74869 - sessionid = atomic_inc_return(&session_id);
74870 + sessionid = atomic_inc_return_unchecked(&session_id);
74871 if (context && context->in_syscall) {
74872 struct audit_buffer *ab;
74873
74874 diff --git a/kernel/capability.c b/kernel/capability.c
74875 index f6c2ce5..982c0f9 100644
74876 --- a/kernel/capability.c
74877 +++ b/kernel/capability.c
74878 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74879 * before modification is attempted and the application
74880 * fails.
74881 */
74882 + if (tocopy > ARRAY_SIZE(kdata))
74883 + return -EFAULT;
74884 +
74885 if (copy_to_user(dataptr, kdata, tocopy
74886 * sizeof(struct __user_cap_data_struct))) {
74887 return -EFAULT;
74888 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74889 int ret;
74890
74891 rcu_read_lock();
74892 - ret = security_capable(__task_cred(t), ns, cap);
74893 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74894 + gr_task_is_capable(t, __task_cred(t), cap);
74895 rcu_read_unlock();
74896
74897 - return (ret == 0);
74898 + return ret;
74899 }
74900
74901 /**
74902 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74903 int ret;
74904
74905 rcu_read_lock();
74906 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74907 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74908 rcu_read_unlock();
74909
74910 - return (ret == 0);
74911 + return ret;
74912 }
74913
74914 /**
74915 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74916 BUG();
74917 }
74918
74919 - if (security_capable(current_cred(), ns, cap) == 0) {
74920 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74921 current->flags |= PF_SUPERPRIV;
74922 return true;
74923 }
74924 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74925 }
74926 EXPORT_SYMBOL(ns_capable);
74927
74928 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74929 +{
74930 + if (unlikely(!cap_valid(cap))) {
74931 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74932 + BUG();
74933 + }
74934 +
74935 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74936 + current->flags |= PF_SUPERPRIV;
74937 + return true;
74938 + }
74939 + return false;
74940 +}
74941 +EXPORT_SYMBOL(ns_capable_nolog);
74942 +
74943 /**
74944 * file_ns_capable - Determine if the file's opener had a capability in effect
74945 * @file: The file we want to check
74946 @@ -432,6 +451,12 @@ bool capable(int cap)
74947 }
74948 EXPORT_SYMBOL(capable);
74949
74950 +bool capable_nolog(int cap)
74951 +{
74952 + return ns_capable_nolog(&init_user_ns, cap);
74953 +}
74954 +EXPORT_SYMBOL(capable_nolog);
74955 +
74956 /**
74957 * nsown_capable - Check superior capability to one's own user_ns
74958 * @cap: The capability in question
74959 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74960
74961 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74962 }
74963 +
74964 +bool inode_capable_nolog(const struct inode *inode, int cap)
74965 +{
74966 + struct user_namespace *ns = current_user_ns();
74967 +
74968 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74969 +}
74970 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74971 index a7c9e6d..a16aa75 100644
74972 --- a/kernel/cgroup.c
74973 +++ b/kernel/cgroup.c
74974 @@ -5378,7 +5378,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74975 struct css_set *cg = link->cg;
74976 struct task_struct *task;
74977 int count = 0;
74978 - seq_printf(seq, "css_set %p\n", cg);
74979 + seq_printf(seq, "css_set %pK\n", cg);
74980 list_for_each_entry(task, &cg->tasks, cg_list) {
74981 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74982 seq_puts(seq, " ...\n");
74983 diff --git a/kernel/compat.c b/kernel/compat.c
74984 index 0a09e48..f44f3f0 100644
74985 --- a/kernel/compat.c
74986 +++ b/kernel/compat.c
74987 @@ -13,6 +13,7 @@
74988
74989 #include <linux/linkage.h>
74990 #include <linux/compat.h>
74991 +#include <linux/module.h>
74992 #include <linux/errno.h>
74993 #include <linux/time.h>
74994 #include <linux/signal.h>
74995 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74996 mm_segment_t oldfs;
74997 long ret;
74998
74999 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
75000 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
75001 oldfs = get_fs();
75002 set_fs(KERNEL_DS);
75003 ret = hrtimer_nanosleep_restart(restart);
75004 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
75005 oldfs = get_fs();
75006 set_fs(KERNEL_DS);
75007 ret = hrtimer_nanosleep(&tu,
75008 - rmtp ? (struct timespec __user *)&rmt : NULL,
75009 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
75010 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
75011 set_fs(oldfs);
75012
75013 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
75014 mm_segment_t old_fs = get_fs();
75015
75016 set_fs(KERNEL_DS);
75017 - ret = sys_sigpending((old_sigset_t __user *) &s);
75018 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
75019 set_fs(old_fs);
75020 if (ret == 0)
75021 ret = put_user(s, set);
75022 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
75023 mm_segment_t old_fs = get_fs();
75024
75025 set_fs(KERNEL_DS);
75026 - ret = sys_old_getrlimit(resource, &r);
75027 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
75028 set_fs(old_fs);
75029
75030 if (!ret) {
75031 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
75032 set_fs (KERNEL_DS);
75033 ret = sys_wait4(pid,
75034 (stat_addr ?
75035 - (unsigned int __user *) &status : NULL),
75036 - options, (struct rusage __user *) &r);
75037 + (unsigned int __force_user *) &status : NULL),
75038 + options, (struct rusage __force_user *) &r);
75039 set_fs (old_fs);
75040
75041 if (ret > 0) {
75042 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
75043 memset(&info, 0, sizeof(info));
75044
75045 set_fs(KERNEL_DS);
75046 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
75047 - uru ? (struct rusage __user *)&ru : NULL);
75048 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
75049 + uru ? (struct rusage __force_user *)&ru : NULL);
75050 set_fs(old_fs);
75051
75052 if ((ret < 0) || (info.si_signo == 0))
75053 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
75054 oldfs = get_fs();
75055 set_fs(KERNEL_DS);
75056 err = sys_timer_settime(timer_id, flags,
75057 - (struct itimerspec __user *) &newts,
75058 - (struct itimerspec __user *) &oldts);
75059 + (struct itimerspec __force_user *) &newts,
75060 + (struct itimerspec __force_user *) &oldts);
75061 set_fs(oldfs);
75062 if (!err && old && put_compat_itimerspec(old, &oldts))
75063 return -EFAULT;
75064 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
75065 oldfs = get_fs();
75066 set_fs(KERNEL_DS);
75067 err = sys_timer_gettime(timer_id,
75068 - (struct itimerspec __user *) &ts);
75069 + (struct itimerspec __force_user *) &ts);
75070 set_fs(oldfs);
75071 if (!err && put_compat_itimerspec(setting, &ts))
75072 return -EFAULT;
75073 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
75074 oldfs = get_fs();
75075 set_fs(KERNEL_DS);
75076 err = sys_clock_settime(which_clock,
75077 - (struct timespec __user *) &ts);
75078 + (struct timespec __force_user *) &ts);
75079 set_fs(oldfs);
75080 return err;
75081 }
75082 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
75083 oldfs = get_fs();
75084 set_fs(KERNEL_DS);
75085 err = sys_clock_gettime(which_clock,
75086 - (struct timespec __user *) &ts);
75087 + (struct timespec __force_user *) &ts);
75088 set_fs(oldfs);
75089 if (!err && put_compat_timespec(&ts, tp))
75090 return -EFAULT;
75091 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
75092
75093 oldfs = get_fs();
75094 set_fs(KERNEL_DS);
75095 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
75096 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
75097 set_fs(oldfs);
75098
75099 err = compat_put_timex(utp, &txc);
75100 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
75101 oldfs = get_fs();
75102 set_fs(KERNEL_DS);
75103 err = sys_clock_getres(which_clock,
75104 - (struct timespec __user *) &ts);
75105 + (struct timespec __force_user *) &ts);
75106 set_fs(oldfs);
75107 if (!err && tp && put_compat_timespec(&ts, tp))
75108 return -EFAULT;
75109 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
75110 long err;
75111 mm_segment_t oldfs;
75112 struct timespec tu;
75113 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
75114 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
75115
75116 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
75117 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
75118 oldfs = get_fs();
75119 set_fs(KERNEL_DS);
75120 err = clock_nanosleep_restart(restart);
75121 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
75122 oldfs = get_fs();
75123 set_fs(KERNEL_DS);
75124 err = sys_clock_nanosleep(which_clock, flags,
75125 - (struct timespec __user *) &in,
75126 - (struct timespec __user *) &out);
75127 + (struct timespec __force_user *) &in,
75128 + (struct timespec __force_user *) &out);
75129 set_fs(oldfs);
75130
75131 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75132 diff --git a/kernel/configs.c b/kernel/configs.c
75133 index c18b1f1..b9a0132 100644
75134 --- a/kernel/configs.c
75135 +++ b/kernel/configs.c
75136 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75137 struct proc_dir_entry *entry;
75138
75139 /* create the current config file */
75140 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75141 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75142 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75143 + &ikconfig_file_ops);
75144 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75145 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75146 + &ikconfig_file_ops);
75147 +#endif
75148 +#else
75149 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75150 &ikconfig_file_ops);
75151 +#endif
75152 +
75153 if (!entry)
75154 return -ENOMEM;
75155
75156 diff --git a/kernel/cred.c b/kernel/cred.c
75157 index e0573a4..3874e41 100644
75158 --- a/kernel/cred.c
75159 +++ b/kernel/cred.c
75160 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75161 validate_creds(cred);
75162 alter_cred_subscribers(cred, -1);
75163 put_cred(cred);
75164 +
75165 +#ifdef CONFIG_GRKERNSEC_SETXID
75166 + cred = (struct cred *) tsk->delayed_cred;
75167 + if (cred != NULL) {
75168 + tsk->delayed_cred = NULL;
75169 + validate_creds(cred);
75170 + alter_cred_subscribers(cred, -1);
75171 + put_cred(cred);
75172 + }
75173 +#endif
75174 }
75175
75176 /**
75177 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75178 * Always returns 0 thus allowing this function to be tail-called at the end
75179 * of, say, sys_setgid().
75180 */
75181 -int commit_creds(struct cred *new)
75182 +static int __commit_creds(struct cred *new)
75183 {
75184 struct task_struct *task = current;
75185 const struct cred *old = task->real_cred;
75186 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75187
75188 get_cred(new); /* we will require a ref for the subj creds too */
75189
75190 + gr_set_role_label(task, new->uid, new->gid);
75191 +
75192 /* dumpability changes */
75193 if (!uid_eq(old->euid, new->euid) ||
75194 !gid_eq(old->egid, new->egid) ||
75195 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75196 put_cred(old);
75197 return 0;
75198 }
75199 +#ifdef CONFIG_GRKERNSEC_SETXID
75200 +extern int set_user(struct cred *new);
75201 +
75202 +void gr_delayed_cred_worker(void)
75203 +{
75204 + const struct cred *new = current->delayed_cred;
75205 + struct cred *ncred;
75206 +
75207 + current->delayed_cred = NULL;
75208 +
75209 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75210 + // from doing get_cred on it when queueing this
75211 + put_cred(new);
75212 + return;
75213 + } else if (new == NULL)
75214 + return;
75215 +
75216 + ncred = prepare_creds();
75217 + if (!ncred)
75218 + goto die;
75219 + // uids
75220 + ncred->uid = new->uid;
75221 + ncred->euid = new->euid;
75222 + ncred->suid = new->suid;
75223 + ncred->fsuid = new->fsuid;
75224 + // gids
75225 + ncred->gid = new->gid;
75226 + ncred->egid = new->egid;
75227 + ncred->sgid = new->sgid;
75228 + ncred->fsgid = new->fsgid;
75229 + // groups
75230 + if (set_groups(ncred, new->group_info) < 0) {
75231 + abort_creds(ncred);
75232 + goto die;
75233 + }
75234 + // caps
75235 + ncred->securebits = new->securebits;
75236 + ncred->cap_inheritable = new->cap_inheritable;
75237 + ncred->cap_permitted = new->cap_permitted;
75238 + ncred->cap_effective = new->cap_effective;
75239 + ncred->cap_bset = new->cap_bset;
75240 +
75241 + if (set_user(ncred)) {
75242 + abort_creds(ncred);
75243 + goto die;
75244 + }
75245 +
75246 + // from doing get_cred on it when queueing this
75247 + put_cred(new);
75248 +
75249 + __commit_creds(ncred);
75250 + return;
75251 +die:
75252 + // from doing get_cred on it when queueing this
75253 + put_cred(new);
75254 + do_group_exit(SIGKILL);
75255 +}
75256 +#endif
75257 +
75258 +int commit_creds(struct cred *new)
75259 +{
75260 +#ifdef CONFIG_GRKERNSEC_SETXID
75261 + int ret;
75262 + int schedule_it = 0;
75263 + struct task_struct *t;
75264 +
75265 + /* we won't get called with tasklist_lock held for writing
75266 + and interrupts disabled as the cred struct in that case is
75267 + init_cred
75268 + */
75269 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75270 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75271 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75272 + schedule_it = 1;
75273 + }
75274 + ret = __commit_creds(new);
75275 + if (schedule_it) {
75276 + rcu_read_lock();
75277 + read_lock(&tasklist_lock);
75278 + for (t = next_thread(current); t != current;
75279 + t = next_thread(t)) {
75280 + if (t->delayed_cred == NULL) {
75281 + t->delayed_cred = get_cred(new);
75282 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75283 + set_tsk_need_resched(t);
75284 + }
75285 + }
75286 + read_unlock(&tasklist_lock);
75287 + rcu_read_unlock();
75288 + }
75289 + return ret;
75290 +#else
75291 + return __commit_creds(new);
75292 +#endif
75293 +}
75294 +
75295 EXPORT_SYMBOL(commit_creds);
75296
75297 /**
75298 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75299 index 0506d44..2c20034 100644
75300 --- a/kernel/debug/debug_core.c
75301 +++ b/kernel/debug/debug_core.c
75302 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75303 */
75304 static atomic_t masters_in_kgdb;
75305 static atomic_t slaves_in_kgdb;
75306 -static atomic_t kgdb_break_tasklet_var;
75307 +static atomic_unchecked_t kgdb_break_tasklet_var;
75308 atomic_t kgdb_setting_breakpoint;
75309
75310 struct task_struct *kgdb_usethread;
75311 @@ -133,7 +133,7 @@ int kgdb_single_step;
75312 static pid_t kgdb_sstep_pid;
75313
75314 /* to keep track of the CPU which is doing the single stepping*/
75315 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75316 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75317
75318 /*
75319 * If you are debugging a problem where roundup (the collection of
75320 @@ -541,7 +541,7 @@ return_normal:
75321 * kernel will only try for the value of sstep_tries before
75322 * giving up and continuing on.
75323 */
75324 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75325 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75326 (kgdb_info[cpu].task &&
75327 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75328 atomic_set(&kgdb_active, -1);
75329 @@ -635,8 +635,8 @@ cpu_master_loop:
75330 }
75331
75332 kgdb_restore:
75333 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75334 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75335 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75336 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75337 if (kgdb_info[sstep_cpu].task)
75338 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75339 else
75340 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
75341 static void kgdb_tasklet_bpt(unsigned long ing)
75342 {
75343 kgdb_breakpoint();
75344 - atomic_set(&kgdb_break_tasklet_var, 0);
75345 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75346 }
75347
75348 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75349
75350 void kgdb_schedule_breakpoint(void)
75351 {
75352 - if (atomic_read(&kgdb_break_tasklet_var) ||
75353 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75354 atomic_read(&kgdb_active) != -1 ||
75355 atomic_read(&kgdb_setting_breakpoint))
75356 return;
75357 - atomic_inc(&kgdb_break_tasklet_var);
75358 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75359 tasklet_schedule(&kgdb_tasklet_breakpoint);
75360 }
75361 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75362 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75363 index 00eb8f7..d7e3244 100644
75364 --- a/kernel/debug/kdb/kdb_main.c
75365 +++ b/kernel/debug/kdb/kdb_main.c
75366 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75367 continue;
75368
75369 kdb_printf("%-20s%8u 0x%p ", mod->name,
75370 - mod->core_size, (void *)mod);
75371 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75372 #ifdef CONFIG_MODULE_UNLOAD
75373 kdb_printf("%4ld ", module_refcount(mod));
75374 #endif
75375 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75376 kdb_printf(" (Loading)");
75377 else
75378 kdb_printf(" (Live)");
75379 - kdb_printf(" 0x%p", mod->module_core);
75380 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75381
75382 #ifdef CONFIG_MODULE_UNLOAD
75383 {
75384 diff --git a/kernel/events/core.c b/kernel/events/core.c
75385 index b391907..a0e2372 100644
75386 --- a/kernel/events/core.c
75387 +++ b/kernel/events/core.c
75388 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
75389 * 0 - disallow raw tracepoint access for unpriv
75390 * 1 - disallow cpu events for unpriv
75391 * 2 - disallow kernel profiling for unpriv
75392 + * 3 - disallow all unpriv perf event use
75393 */
75394 -int sysctl_perf_event_paranoid __read_mostly = 1;
75395 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75396 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
75397 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
75398 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
75399 +#else
75400 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
75401 +#endif
75402
75403 /* Minimum for 512 kiB + 1 user control page */
75404 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
75405 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75406 return 0;
75407 }
75408
75409 -static atomic64_t perf_event_id;
75410 +static atomic64_unchecked_t perf_event_id;
75411
75412 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75413 enum event_type_t event_type);
75414 @@ -2725,7 +2732,7 @@ static void __perf_event_read(void *info)
75415
75416 static inline u64 perf_event_count(struct perf_event *event)
75417 {
75418 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75419 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75420 }
75421
75422 static u64 perf_event_read(struct perf_event *event)
75423 @@ -3071,9 +3078,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75424 mutex_lock(&event->child_mutex);
75425 total += perf_event_read(event);
75426 *enabled += event->total_time_enabled +
75427 - atomic64_read(&event->child_total_time_enabled);
75428 + atomic64_read_unchecked(&event->child_total_time_enabled);
75429 *running += event->total_time_running +
75430 - atomic64_read(&event->child_total_time_running);
75431 + atomic64_read_unchecked(&event->child_total_time_running);
75432
75433 list_for_each_entry(child, &event->child_list, child_list) {
75434 total += perf_event_read(child);
75435 @@ -3459,10 +3466,10 @@ void perf_event_update_userpage(struct perf_event *event)
75436 userpg->offset -= local64_read(&event->hw.prev_count);
75437
75438 userpg->time_enabled = enabled +
75439 - atomic64_read(&event->child_total_time_enabled);
75440 + atomic64_read_unchecked(&event->child_total_time_enabled);
75441
75442 userpg->time_running = running +
75443 - atomic64_read(&event->child_total_time_running);
75444 + atomic64_read_unchecked(&event->child_total_time_running);
75445
75446 arch_perf_update_userpage(userpg, now);
75447
75448 @@ -4012,7 +4019,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
75449
75450 /* Data. */
75451 sp = perf_user_stack_pointer(regs);
75452 - rem = __output_copy_user(handle, (void *) sp, dump_size);
75453 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
75454 dyn_size = dump_size - rem;
75455
75456 perf_output_skip(handle, rem);
75457 @@ -4100,11 +4107,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75458 values[n++] = perf_event_count(event);
75459 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75460 values[n++] = enabled +
75461 - atomic64_read(&event->child_total_time_enabled);
75462 + atomic64_read_unchecked(&event->child_total_time_enabled);
75463 }
75464 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75465 values[n++] = running +
75466 - atomic64_read(&event->child_total_time_running);
75467 + atomic64_read_unchecked(&event->child_total_time_running);
75468 }
75469 if (read_format & PERF_FORMAT_ID)
75470 values[n++] = primary_event_id(event);
75471 @@ -4813,12 +4820,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75472 * need to add enough zero bytes after the string to handle
75473 * the 64bit alignment we do later.
75474 */
75475 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75476 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75477 if (!buf) {
75478 name = strncpy(tmp, "//enomem", sizeof(tmp));
75479 goto got_name;
75480 }
75481 - name = d_path(&file->f_path, buf, PATH_MAX);
75482 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75483 if (IS_ERR(name)) {
75484 name = strncpy(tmp, "//toolong", sizeof(tmp));
75485 goto got_name;
75486 @@ -6240,7 +6247,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75487 event->parent = parent_event;
75488
75489 event->ns = get_pid_ns(task_active_pid_ns(current));
75490 - event->id = atomic64_inc_return(&perf_event_id);
75491 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75492
75493 event->state = PERF_EVENT_STATE_INACTIVE;
75494
75495 @@ -6550,6 +6557,11 @@ SYSCALL_DEFINE5(perf_event_open,
75496 if (flags & ~PERF_FLAG_ALL)
75497 return -EINVAL;
75498
75499 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75500 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75501 + return -EACCES;
75502 +#endif
75503 +
75504 err = perf_copy_attr(attr_uptr, &attr);
75505 if (err)
75506 return err;
75507 @@ -6882,10 +6894,10 @@ static void sync_child_event(struct perf_event *child_event,
75508 /*
75509 * Add back the child's count to the parent's count:
75510 */
75511 - atomic64_add(child_val, &parent_event->child_count);
75512 - atomic64_add(child_event->total_time_enabled,
75513 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75514 + atomic64_add_unchecked(child_event->total_time_enabled,
75515 &parent_event->child_total_time_enabled);
75516 - atomic64_add(child_event->total_time_running,
75517 + atomic64_add_unchecked(child_event->total_time_running,
75518 &parent_event->child_total_time_running);
75519
75520 /*
75521 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75522 index ca65997..cc8cee4 100644
75523 --- a/kernel/events/internal.h
75524 +++ b/kernel/events/internal.h
75525 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75526 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75527 }
75528
75529 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75530 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75531 static inline unsigned int \
75532 func_name(struct perf_output_handle *handle, \
75533 - const void *buf, unsigned int len) \
75534 + const void user *buf, unsigned int len) \
75535 { \
75536 unsigned long size, written; \
75537 \
75538 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75539 return n;
75540 }
75541
75542 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75543 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75544
75545 #define MEMCPY_SKIP(dst, src, n) (n)
75546
75547 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75548 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75549
75550 #ifndef arch_perf_out_copy_user
75551 #define arch_perf_out_copy_user __copy_from_user_inatomic
75552 #endif
75553
75554 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75555 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75556
75557 /* Callchain handling */
75558 extern struct perf_callchain_entry *
75559 diff --git a/kernel/exit.c b/kernel/exit.c
75560 index 7bb73f9..d7978ed 100644
75561 --- a/kernel/exit.c
75562 +++ b/kernel/exit.c
75563 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75564 struct task_struct *leader;
75565 int zap_leader;
75566 repeat:
75567 +#ifdef CONFIG_NET
75568 + gr_del_task_from_ip_table(p);
75569 +#endif
75570 +
75571 /* don't need to get the RCU readlock here - the process is dead and
75572 * can't be modifying its own credentials. But shut RCU-lockdep up */
75573 rcu_read_lock();
75574 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75575 * know it'll be handled, so that they don't get converted to
75576 * SIGKILL or just silently dropped.
75577 */
75578 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75579 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75580 recalc_sigpending();
75581 spin_unlock_irq(&current->sighand->siglock);
75582 return 0;
75583 @@ -709,6 +713,8 @@ void do_exit(long code)
75584 struct task_struct *tsk = current;
75585 int group_dead;
75586
75587 + set_fs(USER_DS);
75588 +
75589 profile_task_exit(tsk);
75590
75591 WARN_ON(blk_needs_flush_plug(tsk));
75592 @@ -725,7 +731,6 @@ void do_exit(long code)
75593 * mm_release()->clear_child_tid() from writing to a user-controlled
75594 * kernel address.
75595 */
75596 - set_fs(USER_DS);
75597
75598 ptrace_event(PTRACE_EVENT_EXIT, code);
75599
75600 @@ -784,6 +789,9 @@ void do_exit(long code)
75601 tsk->exit_code = code;
75602 taskstats_exit(tsk, group_dead);
75603
75604 + gr_acl_handle_psacct(tsk, code);
75605 + gr_acl_handle_exit();
75606 +
75607 exit_mm(tsk);
75608
75609 if (group_dead)
75610 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75611 * Take down every thread in the group. This is called by fatal signals
75612 * as well as by sys_exit_group (below).
75613 */
75614 -void
75615 +__noreturn void
75616 do_group_exit(int exit_code)
75617 {
75618 struct signal_struct *sig = current->signal;
75619 diff --git a/kernel/fork.c b/kernel/fork.c
75620 index 987b28a..4e03c05 100644
75621 --- a/kernel/fork.c
75622 +++ b/kernel/fork.c
75623 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75624 *stackend = STACK_END_MAGIC; /* for overflow detection */
75625
75626 #ifdef CONFIG_CC_STACKPROTECTOR
75627 - tsk->stack_canary = get_random_int();
75628 + tsk->stack_canary = pax_get_random_long();
75629 #endif
75630
75631 /*
75632 @@ -345,13 +345,81 @@ free_tsk:
75633 }
75634
75635 #ifdef CONFIG_MMU
75636 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75637 +{
75638 + struct vm_area_struct *tmp;
75639 + unsigned long charge;
75640 + struct mempolicy *pol;
75641 + struct file *file;
75642 +
75643 + charge = 0;
75644 + if (mpnt->vm_flags & VM_ACCOUNT) {
75645 + unsigned long len = vma_pages(mpnt);
75646 +
75647 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75648 + goto fail_nomem;
75649 + charge = len;
75650 + }
75651 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75652 + if (!tmp)
75653 + goto fail_nomem;
75654 + *tmp = *mpnt;
75655 + tmp->vm_mm = mm;
75656 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75657 + pol = mpol_dup(vma_policy(mpnt));
75658 + if (IS_ERR(pol))
75659 + goto fail_nomem_policy;
75660 + vma_set_policy(tmp, pol);
75661 + if (anon_vma_fork(tmp, mpnt))
75662 + goto fail_nomem_anon_vma_fork;
75663 + tmp->vm_flags &= ~VM_LOCKED;
75664 + tmp->vm_next = tmp->vm_prev = NULL;
75665 + tmp->vm_mirror = NULL;
75666 + file = tmp->vm_file;
75667 + if (file) {
75668 + struct inode *inode = file_inode(file);
75669 + struct address_space *mapping = file->f_mapping;
75670 +
75671 + get_file(file);
75672 + if (tmp->vm_flags & VM_DENYWRITE)
75673 + atomic_dec(&inode->i_writecount);
75674 + mutex_lock(&mapping->i_mmap_mutex);
75675 + if (tmp->vm_flags & VM_SHARED)
75676 + mapping->i_mmap_writable++;
75677 + flush_dcache_mmap_lock(mapping);
75678 + /* insert tmp into the share list, just after mpnt */
75679 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75680 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75681 + else
75682 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75683 + flush_dcache_mmap_unlock(mapping);
75684 + mutex_unlock(&mapping->i_mmap_mutex);
75685 + }
75686 +
75687 + /*
75688 + * Clear hugetlb-related page reserves for children. This only
75689 + * affects MAP_PRIVATE mappings. Faults generated by the child
75690 + * are not guaranteed to succeed, even if read-only
75691 + */
75692 + if (is_vm_hugetlb_page(tmp))
75693 + reset_vma_resv_huge_pages(tmp);
75694 +
75695 + return tmp;
75696 +
75697 +fail_nomem_anon_vma_fork:
75698 + mpol_put(pol);
75699 +fail_nomem_policy:
75700 + kmem_cache_free(vm_area_cachep, tmp);
75701 +fail_nomem:
75702 + vm_unacct_memory(charge);
75703 + return NULL;
75704 +}
75705 +
75706 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75707 {
75708 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75709 struct rb_node **rb_link, *rb_parent;
75710 int retval;
75711 - unsigned long charge;
75712 - struct mempolicy *pol;
75713
75714 uprobe_start_dup_mmap();
75715 down_write(&oldmm->mmap_sem);
75716 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75717 mm->locked_vm = 0;
75718 mm->mmap = NULL;
75719 mm->mmap_cache = NULL;
75720 - mm->free_area_cache = oldmm->mmap_base;
75721 - mm->cached_hole_size = ~0UL;
75722 + mm->free_area_cache = oldmm->free_area_cache;
75723 + mm->cached_hole_size = oldmm->cached_hole_size;
75724 mm->map_count = 0;
75725 cpumask_clear(mm_cpumask(mm));
75726 mm->mm_rb = RB_ROOT;
75727 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75728
75729 prev = NULL;
75730 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75731 - struct file *file;
75732 -
75733 if (mpnt->vm_flags & VM_DONTCOPY) {
75734 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75735 -vma_pages(mpnt));
75736 continue;
75737 }
75738 - charge = 0;
75739 - if (mpnt->vm_flags & VM_ACCOUNT) {
75740 - unsigned long len = vma_pages(mpnt);
75741 -
75742 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75743 - goto fail_nomem;
75744 - charge = len;
75745 - }
75746 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75747 - if (!tmp)
75748 - goto fail_nomem;
75749 - *tmp = *mpnt;
75750 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75751 - pol = mpol_dup(vma_policy(mpnt));
75752 - retval = PTR_ERR(pol);
75753 - if (IS_ERR(pol))
75754 - goto fail_nomem_policy;
75755 - vma_set_policy(tmp, pol);
75756 - tmp->vm_mm = mm;
75757 - if (anon_vma_fork(tmp, mpnt))
75758 - goto fail_nomem_anon_vma_fork;
75759 - tmp->vm_flags &= ~VM_LOCKED;
75760 - tmp->vm_next = tmp->vm_prev = NULL;
75761 - file = tmp->vm_file;
75762 - if (file) {
75763 - struct inode *inode = file_inode(file);
75764 - struct address_space *mapping = file->f_mapping;
75765 -
75766 - get_file(file);
75767 - if (tmp->vm_flags & VM_DENYWRITE)
75768 - atomic_dec(&inode->i_writecount);
75769 - mutex_lock(&mapping->i_mmap_mutex);
75770 - if (tmp->vm_flags & VM_SHARED)
75771 - mapping->i_mmap_writable++;
75772 - flush_dcache_mmap_lock(mapping);
75773 - /* insert tmp into the share list, just after mpnt */
75774 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75775 - vma_nonlinear_insert(tmp,
75776 - &mapping->i_mmap_nonlinear);
75777 - else
75778 - vma_interval_tree_insert_after(tmp, mpnt,
75779 - &mapping->i_mmap);
75780 - flush_dcache_mmap_unlock(mapping);
75781 - mutex_unlock(&mapping->i_mmap_mutex);
75782 + tmp = dup_vma(mm, oldmm, mpnt);
75783 + if (!tmp) {
75784 + retval = -ENOMEM;
75785 + goto out;
75786 }
75787
75788 /*
75789 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75790 if (retval)
75791 goto out;
75792 }
75793 +
75794 +#ifdef CONFIG_PAX_SEGMEXEC
75795 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75796 + struct vm_area_struct *mpnt_m;
75797 +
75798 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75799 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75800 +
75801 + if (!mpnt->vm_mirror)
75802 + continue;
75803 +
75804 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75805 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75806 + mpnt->vm_mirror = mpnt_m;
75807 + } else {
75808 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75809 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75810 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75811 + mpnt->vm_mirror->vm_mirror = mpnt;
75812 + }
75813 + }
75814 + BUG_ON(mpnt_m);
75815 + }
75816 +#endif
75817 +
75818 /* a new mm has just been created */
75819 arch_dup_mmap(oldmm, mm);
75820 retval = 0;
75821 @@ -473,14 +524,6 @@ out:
75822 up_write(&oldmm->mmap_sem);
75823 uprobe_end_dup_mmap();
75824 return retval;
75825 -fail_nomem_anon_vma_fork:
75826 - mpol_put(pol);
75827 -fail_nomem_policy:
75828 - kmem_cache_free(vm_area_cachep, tmp);
75829 -fail_nomem:
75830 - retval = -ENOMEM;
75831 - vm_unacct_memory(charge);
75832 - goto out;
75833 }
75834
75835 static inline int mm_alloc_pgd(struct mm_struct *mm)
75836 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75837 return ERR_PTR(err);
75838
75839 mm = get_task_mm(task);
75840 - if (mm && mm != current->mm &&
75841 - !ptrace_may_access(task, mode)) {
75842 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75843 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75844 mmput(mm);
75845 mm = ERR_PTR(-EACCES);
75846 }
75847 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75848 spin_unlock(&fs->lock);
75849 return -EAGAIN;
75850 }
75851 - fs->users++;
75852 + atomic_inc(&fs->users);
75853 spin_unlock(&fs->lock);
75854 return 0;
75855 }
75856 tsk->fs = copy_fs_struct(fs);
75857 if (!tsk->fs)
75858 return -ENOMEM;
75859 + /* Carry through gr_chroot_dentry and is_chrooted instead
75860 + of recomputing it here. Already copied when the task struct
75861 + is duplicated. This allows pivot_root to not be treated as
75862 + a chroot
75863 + */
75864 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75865 +
75866 return 0;
75867 }
75868
75869 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75870 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75871 #endif
75872 retval = -EAGAIN;
75873 +
75874 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75875 +
75876 if (atomic_read(&p->real_cred->user->processes) >=
75877 task_rlimit(p, RLIMIT_NPROC)) {
75878 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75879 - p->real_cred->user != INIT_USER)
75880 + if (p->real_cred->user != INIT_USER &&
75881 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
75882 goto bad_fork_free;
75883 }
75884 current->flags &= ~PF_NPROC_EXCEEDED;
75885 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75886 goto bad_fork_free_pid;
75887 }
75888
75889 + /* synchronizes with gr_set_acls()
75890 + we need to call this past the point of no return for fork()
75891 + */
75892 + gr_copy_label(p);
75893 +
75894 if (clone_flags & CLONE_THREAD) {
75895 current->signal->nr_threads++;
75896 atomic_inc(&current->signal->live);
75897 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
75898 bad_fork_free:
75899 free_task(p);
75900 fork_out:
75901 + gr_log_forkfail(retval);
75902 +
75903 return ERR_PTR(retval);
75904 }
75905
75906 @@ -1579,6 +1639,23 @@ long do_fork(unsigned long clone_flags,
75907 return -EINVAL;
75908 }
75909
75910 +#ifdef CONFIG_GRKERNSEC
75911 + if (clone_flags & CLONE_NEWUSER) {
75912 + /*
75913 + * This doesn't really inspire confidence:
75914 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75915 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75916 + * Increases kernel attack surface in areas developers
75917 + * previously cared little about ("low importance due
75918 + * to requiring "root" capability")
75919 + * To be removed when this code receives *proper* review
75920 + */
75921 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75922 + !capable(CAP_SETGID))
75923 + return -EPERM;
75924 + }
75925 +#endif
75926 +
75927 /*
75928 * Determine whether and which event to report to ptracer. When
75929 * called from kernel_thread or CLONE_UNTRACED is explicitly
75930 @@ -1613,6 +1690,8 @@ long do_fork(unsigned long clone_flags,
75931 if (clone_flags & CLONE_PARENT_SETTID)
75932 put_user(nr, parent_tidptr);
75933
75934 + gr_handle_brute_check();
75935 +
75936 if (clone_flags & CLONE_VFORK) {
75937 p->vfork_done = &vfork;
75938 init_completion(&vfork);
75939 @@ -1763,7 +1842,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75940 return 0;
75941
75942 /* don't need lock here; in the worst case we'll do useless copy */
75943 - if (fs->users == 1)
75944 + if (atomic_read(&fs->users) == 1)
75945 return 0;
75946
75947 *new_fsp = copy_fs_struct(fs);
75948 @@ -1875,7 +1954,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75949 fs = current->fs;
75950 spin_lock(&fs->lock);
75951 current->fs = new_fs;
75952 - if (--fs->users)
75953 + gr_set_chroot_entries(current, &current->fs->root);
75954 + if (atomic_dec_return(&fs->users))
75955 new_fs = NULL;
75956 else
75957 new_fs = fs;
75958 diff --git a/kernel/futex.c b/kernel/futex.c
75959 index 49dacfb..5c6b450 100644
75960 --- a/kernel/futex.c
75961 +++ b/kernel/futex.c
75962 @@ -54,6 +54,7 @@
75963 #include <linux/mount.h>
75964 #include <linux/pagemap.h>
75965 #include <linux/syscalls.h>
75966 +#include <linux/ptrace.h>
75967 #include <linux/signal.h>
75968 #include <linux/export.h>
75969 #include <linux/magic.h>
75970 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75971 struct page *page, *page_head;
75972 int err, ro = 0;
75973
75974 +#ifdef CONFIG_PAX_SEGMEXEC
75975 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75976 + return -EFAULT;
75977 +#endif
75978 +
75979 /*
75980 * The futex address must be "naturally" aligned.
75981 */
75982 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
75983 {
75984 u32 curval;
75985 int i;
75986 + mm_segment_t oldfs;
75987
75988 /*
75989 * This will fail and we want it. Some arch implementations do
75990 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
75991 * implementation, the non-functional ones will return
75992 * -ENOSYS.
75993 */
75994 + oldfs = get_fs();
75995 + set_fs(USER_DS);
75996 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75997 futex_cmpxchg_enabled = 1;
75998 + set_fs(oldfs);
75999
76000 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
76001 plist_head_init(&futex_queues[i].chain);
76002 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
76003 index f9f44fd..29885e4 100644
76004 --- a/kernel/futex_compat.c
76005 +++ b/kernel/futex_compat.c
76006 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
76007 return 0;
76008 }
76009
76010 -static void __user *futex_uaddr(struct robust_list __user *entry,
76011 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
76012 compat_long_t futex_offset)
76013 {
76014 compat_uptr_t base = ptr_to_compat(entry);
76015 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
76016 index 9b22d03..6295b62 100644
76017 --- a/kernel/gcov/base.c
76018 +++ b/kernel/gcov/base.c
76019 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
76020 }
76021
76022 #ifdef CONFIG_MODULES
76023 -static inline int within(void *addr, void *start, unsigned long size)
76024 -{
76025 - return ((addr >= start) && (addr < start + size));
76026 -}
76027 -
76028 /* Update list and generate events when modules are unloaded. */
76029 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76030 void *data)
76031 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76032 prev = NULL;
76033 /* Remove entries located in module from linked list. */
76034 for (info = gcov_info_head; info; info = info->next) {
76035 - if (within(info, mod->module_core, mod->core_size)) {
76036 + if (within_module_core_rw((unsigned long)info, mod)) {
76037 if (prev)
76038 prev->next = info->next;
76039 else
76040 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
76041 index fd4b13b..09a5ccb 100644
76042 --- a/kernel/hrtimer.c
76043 +++ b/kernel/hrtimer.c
76044 @@ -1430,7 +1430,7 @@ void hrtimer_peek_ahead_timers(void)
76045 local_irq_restore(flags);
76046 }
76047
76048 -static void run_hrtimer_softirq(struct softirq_action *h)
76049 +static void run_hrtimer_softirq(void)
76050 {
76051 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
76052
76053 @@ -1772,7 +1772,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
76054 return NOTIFY_OK;
76055 }
76056
76057 -static struct notifier_block __cpuinitdata hrtimers_nb = {
76058 +static struct notifier_block hrtimers_nb = {
76059 .notifier_call = hrtimer_cpu_notify,
76060 };
76061
76062 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
76063 index 55fcce6..0e4cf34 100644
76064 --- a/kernel/irq_work.c
76065 +++ b/kernel/irq_work.c
76066 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
76067 return NOTIFY_OK;
76068 }
76069
76070 -static struct notifier_block cpu_notify;
76071 +static struct notifier_block cpu_notify = {
76072 + .notifier_call = irq_work_cpu_notify,
76073 + .priority = 0,
76074 +};
76075
76076 static __init int irq_work_init_cpu_notifier(void)
76077 {
76078 - cpu_notify.notifier_call = irq_work_cpu_notify;
76079 - cpu_notify.priority = 0;
76080 register_cpu_notifier(&cpu_notify);
76081 return 0;
76082 }
76083 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
76084 index 60f48fa..7f3a770 100644
76085 --- a/kernel/jump_label.c
76086 +++ b/kernel/jump_label.c
76087 @@ -13,6 +13,7 @@
76088 #include <linux/sort.h>
76089 #include <linux/err.h>
76090 #include <linux/static_key.h>
76091 +#include <linux/mm.h>
76092
76093 #ifdef HAVE_JUMP_LABEL
76094
76095 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
76096
76097 size = (((unsigned long)stop - (unsigned long)start)
76098 / sizeof(struct jump_entry));
76099 + pax_open_kernel();
76100 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
76101 + pax_close_kernel();
76102 }
76103
76104 static void jump_label_update(struct static_key *key, int enable);
76105 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
76106 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
76107 struct jump_entry *iter;
76108
76109 + pax_open_kernel();
76110 for (iter = iter_start; iter < iter_stop; iter++) {
76111 if (within_module_init(iter->code, mod))
76112 iter->code = 0;
76113 }
76114 + pax_close_kernel();
76115 }
76116
76117 static int
76118 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
76119 index 3127ad5..159d880 100644
76120 --- a/kernel/kallsyms.c
76121 +++ b/kernel/kallsyms.c
76122 @@ -11,6 +11,9 @@
76123 * Changed the compression method from stem compression to "table lookup"
76124 * compression (see scripts/kallsyms.c for a more complete description)
76125 */
76126 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76127 +#define __INCLUDED_BY_HIDESYM 1
76128 +#endif
76129 #include <linux/kallsyms.h>
76130 #include <linux/module.h>
76131 #include <linux/init.h>
76132 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76133
76134 static inline int is_kernel_inittext(unsigned long addr)
76135 {
76136 + if (system_state != SYSTEM_BOOTING)
76137 + return 0;
76138 +
76139 if (addr >= (unsigned long)_sinittext
76140 && addr <= (unsigned long)_einittext)
76141 return 1;
76142 return 0;
76143 }
76144
76145 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76146 +#ifdef CONFIG_MODULES
76147 +static inline int is_module_text(unsigned long addr)
76148 +{
76149 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76150 + return 1;
76151 +
76152 + addr = ktla_ktva(addr);
76153 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76154 +}
76155 +#else
76156 +static inline int is_module_text(unsigned long addr)
76157 +{
76158 + return 0;
76159 +}
76160 +#endif
76161 +#endif
76162 +
76163 static inline int is_kernel_text(unsigned long addr)
76164 {
76165 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76166 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76167
76168 static inline int is_kernel(unsigned long addr)
76169 {
76170 +
76171 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76172 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76173 + return 1;
76174 +
76175 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76176 +#else
76177 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76178 +#endif
76179 +
76180 return 1;
76181 return in_gate_area_no_mm(addr);
76182 }
76183
76184 static int is_ksym_addr(unsigned long addr)
76185 {
76186 +
76187 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76188 + if (is_module_text(addr))
76189 + return 0;
76190 +#endif
76191 +
76192 if (all_var)
76193 return is_kernel(addr);
76194
76195 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76196
76197 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76198 {
76199 - iter->name[0] = '\0';
76200 iter->nameoff = get_symbol_offset(new_pos);
76201 iter->pos = new_pos;
76202 }
76203 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
76204 {
76205 struct kallsym_iter *iter = m->private;
76206
76207 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76208 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76209 + return 0;
76210 +#endif
76211 +
76212 /* Some debugging symbols have no name. Ignore them. */
76213 if (!iter->name[0])
76214 return 0;
76215 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
76216 */
76217 type = iter->exported ? toupper(iter->type) :
76218 tolower(iter->type);
76219 +
76220 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
76221 type, iter->name, iter->module_name);
76222 } else
76223 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
76224 struct kallsym_iter *iter;
76225 int ret;
76226
76227 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
76228 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
76229 if (!iter)
76230 return -ENOMEM;
76231 reset_iter(iter, 0);
76232 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
76233 index e30ac0f..3528cac 100644
76234 --- a/kernel/kcmp.c
76235 +++ b/kernel/kcmp.c
76236 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
76237 struct task_struct *task1, *task2;
76238 int ret;
76239
76240 +#ifdef CONFIG_GRKERNSEC
76241 + return -ENOSYS;
76242 +#endif
76243 +
76244 rcu_read_lock();
76245
76246 /*
76247 diff --git a/kernel/kexec.c b/kernel/kexec.c
76248 index 59f7b55..4022f65 100644
76249 --- a/kernel/kexec.c
76250 +++ b/kernel/kexec.c
76251 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
76252 unsigned long flags)
76253 {
76254 struct compat_kexec_segment in;
76255 - struct kexec_segment out, __user *ksegments;
76256 + struct kexec_segment out;
76257 + struct kexec_segment __user *ksegments;
76258 unsigned long i, result;
76259
76260 /* Don't allow clients that don't understand the native
76261 diff --git a/kernel/kmod.c b/kernel/kmod.c
76262 index 8241906..d625f2c 100644
76263 --- a/kernel/kmod.c
76264 +++ b/kernel/kmod.c
76265 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76266 kfree(info->argv);
76267 }
76268
76269 -static int call_modprobe(char *module_name, int wait)
76270 +static int call_modprobe(char *module_name, char *module_param, int wait)
76271 {
76272 struct subprocess_info *info;
76273 static char *envp[] = {
76274 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
76275 NULL
76276 };
76277
76278 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76279 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76280 if (!argv)
76281 goto out;
76282
76283 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
76284 argv[1] = "-q";
76285 argv[2] = "--";
76286 argv[3] = module_name; /* check free_modprobe_argv() */
76287 - argv[4] = NULL;
76288 + argv[4] = module_param;
76289 + argv[5] = NULL;
76290
76291 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
76292 NULL, free_modprobe_argv, NULL);
76293 @@ -129,9 +130,8 @@ out:
76294 * If module auto-loading support is disabled then this function
76295 * becomes a no-operation.
76296 */
76297 -int __request_module(bool wait, const char *fmt, ...)
76298 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76299 {
76300 - va_list args;
76301 char module_name[MODULE_NAME_LEN];
76302 unsigned int max_modprobes;
76303 int ret;
76304 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
76305 */
76306 WARN_ON_ONCE(wait && current_is_async());
76307
76308 - va_start(args, fmt);
76309 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76310 - va_end(args);
76311 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76312 if (ret >= MODULE_NAME_LEN)
76313 return -ENAMETOOLONG;
76314
76315 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
76316 if (ret)
76317 return ret;
76318
76319 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76320 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76321 + /* hack to workaround consolekit/udisks stupidity */
76322 + read_lock(&tasklist_lock);
76323 + if (!strcmp(current->comm, "mount") &&
76324 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76325 + read_unlock(&tasklist_lock);
76326 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76327 + return -EPERM;
76328 + }
76329 + read_unlock(&tasklist_lock);
76330 + }
76331 +#endif
76332 +
76333 /* If modprobe needs a service that is in a module, we get a recursive
76334 * loop. Limit the number of running kmod threads to max_threads/2 or
76335 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76336 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
76337
76338 trace_module_request(module_name, wait, _RET_IP_);
76339
76340 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76341 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76342
76343 atomic_dec(&kmod_concurrent);
76344 return ret;
76345 }
76346 +
76347 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76348 +{
76349 + va_list args;
76350 + int ret;
76351 +
76352 + va_start(args, fmt);
76353 + ret = ____request_module(wait, module_param, fmt, args);
76354 + va_end(args);
76355 +
76356 + return ret;
76357 +}
76358 +
76359 +int __request_module(bool wait, const char *fmt, ...)
76360 +{
76361 + va_list args;
76362 + int ret;
76363 +
76364 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76365 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76366 + char module_param[MODULE_NAME_LEN];
76367 +
76368 + memset(module_param, 0, sizeof(module_param));
76369 +
76370 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76371 +
76372 + va_start(args, fmt);
76373 + ret = ____request_module(wait, module_param, fmt, args);
76374 + va_end(args);
76375 +
76376 + return ret;
76377 + }
76378 +#endif
76379 +
76380 + va_start(args, fmt);
76381 + ret = ____request_module(wait, NULL, fmt, args);
76382 + va_end(args);
76383 +
76384 + return ret;
76385 +}
76386 +
76387 EXPORT_SYMBOL(__request_module);
76388 #endif /* CONFIG_MODULES */
76389
76390 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
76391 *
76392 * Thus the __user pointer cast is valid here.
76393 */
76394 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76395 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76396
76397 /*
76398 * If ret is 0, either ____call_usermodehelper failed and the
76399 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
76400 static int proc_cap_handler(struct ctl_table *table, int write,
76401 void __user *buffer, size_t *lenp, loff_t *ppos)
76402 {
76403 - struct ctl_table t;
76404 + ctl_table_no_const t;
76405 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76406 kernel_cap_t new_cap;
76407 int err, i;
76408 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76409 index bddf3b2..07b90dd 100644
76410 --- a/kernel/kprobes.c
76411 +++ b/kernel/kprobes.c
76412 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76413 * kernel image and loaded module images reside. This is required
76414 * so x86_64 can correctly handle the %rip-relative fixups.
76415 */
76416 - kip->insns = module_alloc(PAGE_SIZE);
76417 + kip->insns = module_alloc_exec(PAGE_SIZE);
76418 if (!kip->insns) {
76419 kfree(kip);
76420 return NULL;
76421 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76422 */
76423 if (!list_is_singular(&kip->list)) {
76424 list_del(&kip->list);
76425 - module_free(NULL, kip->insns);
76426 + module_free_exec(NULL, kip->insns);
76427 kfree(kip);
76428 }
76429 return 1;
76430 @@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
76431 {
76432 int i, err = 0;
76433 unsigned long offset = 0, size = 0;
76434 - char *modname, namebuf[128];
76435 + char *modname, namebuf[KSYM_NAME_LEN];
76436 const char *symbol_name;
76437 void *addr;
76438 struct kprobe_blackpoint *kb;
76439 @@ -2168,11 +2168,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76440 kprobe_type = "k";
76441
76442 if (sym)
76443 - seq_printf(pi, "%p %s %s+0x%x %s ",
76444 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76445 p->addr, kprobe_type, sym, offset,
76446 (modname ? modname : " "));
76447 else
76448 - seq_printf(pi, "%p %s %p ",
76449 + seq_printf(pi, "%pK %s %pK ",
76450 p->addr, kprobe_type, p->addr);
76451
76452 if (!pp)
76453 @@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76454 const char *sym = NULL;
76455 unsigned int i = *(loff_t *) v;
76456 unsigned long offset = 0;
76457 - char *modname, namebuf[128];
76458 + char *modname, namebuf[KSYM_NAME_LEN];
76459
76460 head = &kprobe_table[i];
76461 preempt_disable();
76462 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76463 index 6ada93c..dce7d5d 100644
76464 --- a/kernel/ksysfs.c
76465 +++ b/kernel/ksysfs.c
76466 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76467 {
76468 if (count+1 > UEVENT_HELPER_PATH_LEN)
76469 return -ENOENT;
76470 + if (!capable(CAP_SYS_ADMIN))
76471 + return -EPERM;
76472 memcpy(uevent_helper, buf, count);
76473 uevent_helper[count] = '\0';
76474 if (count && uevent_helper[count-1] == '\n')
76475 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76476 return count;
76477 }
76478
76479 -static struct bin_attribute notes_attr = {
76480 +static bin_attribute_no_const notes_attr __read_only = {
76481 .attr = {
76482 .name = "notes",
76483 .mode = S_IRUGO,
76484 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76485 index 1f3186b..bb7dbc6 100644
76486 --- a/kernel/lockdep.c
76487 +++ b/kernel/lockdep.c
76488 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
76489 end = (unsigned long) &_end,
76490 addr = (unsigned long) obj;
76491
76492 +#ifdef CONFIG_PAX_KERNEXEC
76493 + start = ktla_ktva(start);
76494 +#endif
76495 +
76496 /*
76497 * static variable?
76498 */
76499 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76500 if (!static_obj(lock->key)) {
76501 debug_locks_off();
76502 printk("INFO: trying to register non-static key.\n");
76503 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76504 printk("the code is fine but needs lockdep annotation.\n");
76505 printk("turning off the locking correctness validator.\n");
76506 dump_stack();
76507 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76508 if (!class)
76509 return 0;
76510 }
76511 - atomic_inc((atomic_t *)&class->ops);
76512 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76513 if (very_verbose(class)) {
76514 printk("\nacquire class [%p] %s", class->key, class->name);
76515 if (class->name_version > 1)
76516 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76517 index b2c71c5..7b88d63 100644
76518 --- a/kernel/lockdep_proc.c
76519 +++ b/kernel/lockdep_proc.c
76520 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76521 return 0;
76522 }
76523
76524 - seq_printf(m, "%p", class->key);
76525 + seq_printf(m, "%pK", class->key);
76526 #ifdef CONFIG_DEBUG_LOCKDEP
76527 seq_printf(m, " OPS:%8ld", class->ops);
76528 #endif
76529 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76530
76531 list_for_each_entry(entry, &class->locks_after, entry) {
76532 if (entry->distance == 1) {
76533 - seq_printf(m, " -> [%p] ", entry->class->key);
76534 + seq_printf(m, " -> [%pK] ", entry->class->key);
76535 print_name(m, entry->class);
76536 seq_puts(m, "\n");
76537 }
76538 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76539 if (!class->key)
76540 continue;
76541
76542 - seq_printf(m, "[%p] ", class->key);
76543 + seq_printf(m, "[%pK] ", class->key);
76544 print_name(m, class);
76545 seq_puts(m, "\n");
76546 }
76547 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76548 if (!i)
76549 seq_line(m, '-', 40-namelen, namelen);
76550
76551 - snprintf(ip, sizeof(ip), "[<%p>]",
76552 + snprintf(ip, sizeof(ip), "[<%pK>]",
76553 (void *)class->contention_point[i]);
76554 seq_printf(m, "%40s %14lu %29s %pS\n",
76555 name, stats->contention_point[i],
76556 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76557 if (!i)
76558 seq_line(m, '-', 40-namelen, namelen);
76559
76560 - snprintf(ip, sizeof(ip), "[<%p>]",
76561 + snprintf(ip, sizeof(ip), "[<%pK>]",
76562 (void *)class->contending_point[i]);
76563 seq_printf(m, "%40s %14lu %29s %pS\n",
76564 name, stats->contending_point[i],
76565 diff --git a/kernel/module.c b/kernel/module.c
76566 index fa53db8..6f17200 100644
76567 --- a/kernel/module.c
76568 +++ b/kernel/module.c
76569 @@ -61,6 +61,7 @@
76570 #include <linux/pfn.h>
76571 #include <linux/bsearch.h>
76572 #include <linux/fips.h>
76573 +#include <linux/grsecurity.h>
76574 #include <uapi/linux/module.h>
76575 #include "module-internal.h"
76576
76577 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76578
76579 /* Bounds of module allocation, for speeding __module_address.
76580 * Protected by module_mutex. */
76581 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76582 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76583 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76584
76585 int register_module_notifier(struct notifier_block * nb)
76586 {
76587 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76588 return true;
76589
76590 list_for_each_entry_rcu(mod, &modules, list) {
76591 - struct symsearch arr[] = {
76592 + struct symsearch modarr[] = {
76593 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76594 NOT_GPL_ONLY, false },
76595 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76596 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76597 if (mod->state == MODULE_STATE_UNFORMED)
76598 continue;
76599
76600 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76601 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76602 return true;
76603 }
76604 return false;
76605 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76606 static int percpu_modalloc(struct module *mod,
76607 unsigned long size, unsigned long align)
76608 {
76609 - if (align > PAGE_SIZE) {
76610 + if (align-1 >= PAGE_SIZE) {
76611 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76612 mod->name, align, PAGE_SIZE);
76613 align = PAGE_SIZE;
76614 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76615 static ssize_t show_coresize(struct module_attribute *mattr,
76616 struct module_kobject *mk, char *buffer)
76617 {
76618 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76619 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76620 }
76621
76622 static struct module_attribute modinfo_coresize =
76623 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76624 static ssize_t show_initsize(struct module_attribute *mattr,
76625 struct module_kobject *mk, char *buffer)
76626 {
76627 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76628 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76629 }
76630
76631 static struct module_attribute modinfo_initsize =
76632 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
76633 */
76634 #ifdef CONFIG_SYSFS
76635
76636 -#ifdef CONFIG_KALLSYMS
76637 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76638 static inline bool sect_empty(const Elf_Shdr *sect)
76639 {
76640 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76641 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76642 {
76643 unsigned int notes, loaded, i;
76644 struct module_notes_attrs *notes_attrs;
76645 - struct bin_attribute *nattr;
76646 + bin_attribute_no_const *nattr;
76647
76648 /* failed to create section attributes, so can't create notes */
76649 if (!mod->sect_attrs)
76650 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
76651 static int module_add_modinfo_attrs(struct module *mod)
76652 {
76653 struct module_attribute *attr;
76654 - struct module_attribute *temp_attr;
76655 + module_attribute_no_const *temp_attr;
76656 int error = 0;
76657 int i;
76658
76659 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
76660
76661 static void unset_module_core_ro_nx(struct module *mod)
76662 {
76663 - set_page_attributes(mod->module_core + mod->core_text_size,
76664 - mod->module_core + mod->core_size,
76665 + set_page_attributes(mod->module_core_rw,
76666 + mod->module_core_rw + mod->core_size_rw,
76667 set_memory_x);
76668 - set_page_attributes(mod->module_core,
76669 - mod->module_core + mod->core_ro_size,
76670 + set_page_attributes(mod->module_core_rx,
76671 + mod->module_core_rx + mod->core_size_rx,
76672 set_memory_rw);
76673 }
76674
76675 static void unset_module_init_ro_nx(struct module *mod)
76676 {
76677 - set_page_attributes(mod->module_init + mod->init_text_size,
76678 - mod->module_init + mod->init_size,
76679 + set_page_attributes(mod->module_init_rw,
76680 + mod->module_init_rw + mod->init_size_rw,
76681 set_memory_x);
76682 - set_page_attributes(mod->module_init,
76683 - mod->module_init + mod->init_ro_size,
76684 + set_page_attributes(mod->module_init_rx,
76685 + mod->module_init_rx + mod->init_size_rx,
76686 set_memory_rw);
76687 }
76688
76689 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
76690 list_for_each_entry_rcu(mod, &modules, list) {
76691 if (mod->state == MODULE_STATE_UNFORMED)
76692 continue;
76693 - if ((mod->module_core) && (mod->core_text_size)) {
76694 - set_page_attributes(mod->module_core,
76695 - mod->module_core + mod->core_text_size,
76696 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76697 + set_page_attributes(mod->module_core_rx,
76698 + mod->module_core_rx + mod->core_size_rx,
76699 set_memory_rw);
76700 }
76701 - if ((mod->module_init) && (mod->init_text_size)) {
76702 - set_page_attributes(mod->module_init,
76703 - mod->module_init + mod->init_text_size,
76704 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76705 + set_page_attributes(mod->module_init_rx,
76706 + mod->module_init_rx + mod->init_size_rx,
76707 set_memory_rw);
76708 }
76709 }
76710 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
76711 list_for_each_entry_rcu(mod, &modules, list) {
76712 if (mod->state == MODULE_STATE_UNFORMED)
76713 continue;
76714 - if ((mod->module_core) && (mod->core_text_size)) {
76715 - set_page_attributes(mod->module_core,
76716 - mod->module_core + mod->core_text_size,
76717 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76718 + set_page_attributes(mod->module_core_rx,
76719 + mod->module_core_rx + mod->core_size_rx,
76720 set_memory_ro);
76721 }
76722 - if ((mod->module_init) && (mod->init_text_size)) {
76723 - set_page_attributes(mod->module_init,
76724 - mod->module_init + mod->init_text_size,
76725 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76726 + set_page_attributes(mod->module_init_rx,
76727 + mod->module_init_rx + mod->init_size_rx,
76728 set_memory_ro);
76729 }
76730 }
76731 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
76732
76733 /* This may be NULL, but that's OK */
76734 unset_module_init_ro_nx(mod);
76735 - module_free(mod, mod->module_init);
76736 + module_free(mod, mod->module_init_rw);
76737 + module_free_exec(mod, mod->module_init_rx);
76738 kfree(mod->args);
76739 percpu_modfree(mod);
76740
76741 /* Free lock-classes: */
76742 - lockdep_free_key_range(mod->module_core, mod->core_size);
76743 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76744 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76745
76746 /* Finally, free the core (containing the module structure) */
76747 unset_module_core_ro_nx(mod);
76748 - module_free(mod, mod->module_core);
76749 + module_free_exec(mod, mod->module_core_rx);
76750 + module_free(mod, mod->module_core_rw);
76751
76752 #ifdef CONFIG_MPU
76753 update_protections(current->mm);
76754 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76755 int ret = 0;
76756 const struct kernel_symbol *ksym;
76757
76758 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76759 + int is_fs_load = 0;
76760 + int register_filesystem_found = 0;
76761 + char *p;
76762 +
76763 + p = strstr(mod->args, "grsec_modharden_fs");
76764 + if (p) {
76765 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76766 + /* copy \0 as well */
76767 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76768 + is_fs_load = 1;
76769 + }
76770 +#endif
76771 +
76772 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76773 const char *name = info->strtab + sym[i].st_name;
76774
76775 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76776 + /* it's a real shame this will never get ripped and copied
76777 + upstream! ;(
76778 + */
76779 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76780 + register_filesystem_found = 1;
76781 +#endif
76782 +
76783 switch (sym[i].st_shndx) {
76784 case SHN_COMMON:
76785 /* We compiled with -fno-common. These are not
76786 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76787 ksym = resolve_symbol_wait(mod, info, name);
76788 /* Ok if resolved. */
76789 if (ksym && !IS_ERR(ksym)) {
76790 + pax_open_kernel();
76791 sym[i].st_value = ksym->value;
76792 + pax_close_kernel();
76793 break;
76794 }
76795
76796 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76797 secbase = (unsigned long)mod_percpu(mod);
76798 else
76799 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76800 + pax_open_kernel();
76801 sym[i].st_value += secbase;
76802 + pax_close_kernel();
76803 break;
76804 }
76805 }
76806
76807 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76808 + if (is_fs_load && !register_filesystem_found) {
76809 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76810 + ret = -EPERM;
76811 + }
76812 +#endif
76813 +
76814 return ret;
76815 }
76816
76817 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76818 || s->sh_entsize != ~0UL
76819 || strstarts(sname, ".init"))
76820 continue;
76821 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76822 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76823 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76824 + else
76825 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76826 pr_debug("\t%s\n", sname);
76827 }
76828 - switch (m) {
76829 - case 0: /* executable */
76830 - mod->core_size = debug_align(mod->core_size);
76831 - mod->core_text_size = mod->core_size;
76832 - break;
76833 - case 1: /* RO: text and ro-data */
76834 - mod->core_size = debug_align(mod->core_size);
76835 - mod->core_ro_size = mod->core_size;
76836 - break;
76837 - case 3: /* whole core */
76838 - mod->core_size = debug_align(mod->core_size);
76839 - break;
76840 - }
76841 }
76842
76843 pr_debug("Init section allocation order:\n");
76844 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76845 || s->sh_entsize != ~0UL
76846 || !strstarts(sname, ".init"))
76847 continue;
76848 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76849 - | INIT_OFFSET_MASK);
76850 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76851 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76852 + else
76853 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76854 + s->sh_entsize |= INIT_OFFSET_MASK;
76855 pr_debug("\t%s\n", sname);
76856 }
76857 - switch (m) {
76858 - case 0: /* executable */
76859 - mod->init_size = debug_align(mod->init_size);
76860 - mod->init_text_size = mod->init_size;
76861 - break;
76862 - case 1: /* RO: text and ro-data */
76863 - mod->init_size = debug_align(mod->init_size);
76864 - mod->init_ro_size = mod->init_size;
76865 - break;
76866 - case 3: /* whole init */
76867 - mod->init_size = debug_align(mod->init_size);
76868 - break;
76869 - }
76870 }
76871 }
76872
76873 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76874
76875 /* Put symbol section at end of init part of module. */
76876 symsect->sh_flags |= SHF_ALLOC;
76877 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76878 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76879 info->index.sym) | INIT_OFFSET_MASK;
76880 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76881
76882 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76883 }
76884
76885 /* Append room for core symbols at end of core part. */
76886 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76887 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76888 - mod->core_size += strtab_size;
76889 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76890 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76891 + mod->core_size_rx += strtab_size;
76892
76893 /* Put string table section at end of init part of module. */
76894 strsect->sh_flags |= SHF_ALLOC;
76895 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76896 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76897 info->index.str) | INIT_OFFSET_MASK;
76898 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76899 }
76900 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76901 /* Make sure we get permanent strtab: don't use info->strtab. */
76902 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76903
76904 + pax_open_kernel();
76905 +
76906 /* Set types up while we still have access to sections. */
76907 for (i = 0; i < mod->num_symtab; i++)
76908 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76909
76910 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76911 - mod->core_strtab = s = mod->module_core + info->stroffs;
76912 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76913 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76914 src = mod->symtab;
76915 for (ndst = i = 0; i < mod->num_symtab; i++) {
76916 if (i == 0 ||
76917 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76918 }
76919 }
76920 mod->core_num_syms = ndst;
76921 +
76922 + pax_close_kernel();
76923 }
76924 #else
76925 static inline void layout_symtab(struct module *mod, struct load_info *info)
76926 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
76927 return vmalloc_exec(size);
76928 }
76929
76930 -static void *module_alloc_update_bounds(unsigned long size)
76931 +static void *module_alloc_update_bounds_rw(unsigned long size)
76932 {
76933 void *ret = module_alloc(size);
76934
76935 if (ret) {
76936 mutex_lock(&module_mutex);
76937 /* Update module bounds. */
76938 - if ((unsigned long)ret < module_addr_min)
76939 - module_addr_min = (unsigned long)ret;
76940 - if ((unsigned long)ret + size > module_addr_max)
76941 - module_addr_max = (unsigned long)ret + size;
76942 + if ((unsigned long)ret < module_addr_min_rw)
76943 + module_addr_min_rw = (unsigned long)ret;
76944 + if ((unsigned long)ret + size > module_addr_max_rw)
76945 + module_addr_max_rw = (unsigned long)ret + size;
76946 + mutex_unlock(&module_mutex);
76947 + }
76948 + return ret;
76949 +}
76950 +
76951 +static void *module_alloc_update_bounds_rx(unsigned long size)
76952 +{
76953 + void *ret = module_alloc_exec(size);
76954 +
76955 + if (ret) {
76956 + mutex_lock(&module_mutex);
76957 + /* Update module bounds. */
76958 + if ((unsigned long)ret < module_addr_min_rx)
76959 + module_addr_min_rx = (unsigned long)ret;
76960 + if ((unsigned long)ret + size > module_addr_max_rx)
76961 + module_addr_max_rx = (unsigned long)ret + size;
76962 mutex_unlock(&module_mutex);
76963 }
76964 return ret;
76965 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76966 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76967 {
76968 const char *modmagic = get_modinfo(info, "vermagic");
76969 + const char *license = get_modinfo(info, "license");
76970 int err;
76971
76972 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76973 + if (!license || !license_is_gpl_compatible(license))
76974 + return -ENOEXEC;
76975 +#endif
76976 +
76977 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76978 modmagic = NULL;
76979
76980 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76981 }
76982
76983 /* Set up license info based on the info section */
76984 - set_license(mod, get_modinfo(info, "license"));
76985 + set_license(mod, license);
76986
76987 return 0;
76988 }
76989 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
76990 void *ptr;
76991
76992 /* Do the allocs. */
76993 - ptr = module_alloc_update_bounds(mod->core_size);
76994 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76995 /*
76996 * The pointer to this block is stored in the module structure
76997 * which is inside the block. Just mark it as not being a
76998 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
76999 if (!ptr)
77000 return -ENOMEM;
77001
77002 - memset(ptr, 0, mod->core_size);
77003 - mod->module_core = ptr;
77004 + memset(ptr, 0, mod->core_size_rw);
77005 + mod->module_core_rw = ptr;
77006
77007 - if (mod->init_size) {
77008 - ptr = module_alloc_update_bounds(mod->init_size);
77009 + if (mod->init_size_rw) {
77010 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
77011 /*
77012 * The pointer to this block is stored in the module structure
77013 * which is inside the block. This block doesn't need to be
77014 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
77015 */
77016 kmemleak_ignore(ptr);
77017 if (!ptr) {
77018 - module_free(mod, mod->module_core);
77019 + module_free(mod, mod->module_core_rw);
77020 return -ENOMEM;
77021 }
77022 - memset(ptr, 0, mod->init_size);
77023 - mod->module_init = ptr;
77024 + memset(ptr, 0, mod->init_size_rw);
77025 + mod->module_init_rw = ptr;
77026 } else
77027 - mod->module_init = NULL;
77028 + mod->module_init_rw = NULL;
77029 +
77030 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
77031 + kmemleak_not_leak(ptr);
77032 + if (!ptr) {
77033 + if (mod->module_init_rw)
77034 + module_free(mod, mod->module_init_rw);
77035 + module_free(mod, mod->module_core_rw);
77036 + return -ENOMEM;
77037 + }
77038 +
77039 + pax_open_kernel();
77040 + memset(ptr, 0, mod->core_size_rx);
77041 + pax_close_kernel();
77042 + mod->module_core_rx = ptr;
77043 +
77044 + if (mod->init_size_rx) {
77045 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
77046 + kmemleak_ignore(ptr);
77047 + if (!ptr && mod->init_size_rx) {
77048 + module_free_exec(mod, mod->module_core_rx);
77049 + if (mod->module_init_rw)
77050 + module_free(mod, mod->module_init_rw);
77051 + module_free(mod, mod->module_core_rw);
77052 + return -ENOMEM;
77053 + }
77054 +
77055 + pax_open_kernel();
77056 + memset(ptr, 0, mod->init_size_rx);
77057 + pax_close_kernel();
77058 + mod->module_init_rx = ptr;
77059 + } else
77060 + mod->module_init_rx = NULL;
77061
77062 /* Transfer each section which specifies SHF_ALLOC */
77063 pr_debug("final section addresses:\n");
77064 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
77065 if (!(shdr->sh_flags & SHF_ALLOC))
77066 continue;
77067
77068 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
77069 - dest = mod->module_init
77070 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77071 - else
77072 - dest = mod->module_core + shdr->sh_entsize;
77073 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
77074 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77075 + dest = mod->module_init_rw
77076 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77077 + else
77078 + dest = mod->module_init_rx
77079 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77080 + } else {
77081 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77082 + dest = mod->module_core_rw + shdr->sh_entsize;
77083 + else
77084 + dest = mod->module_core_rx + shdr->sh_entsize;
77085 + }
77086 +
77087 + if (shdr->sh_type != SHT_NOBITS) {
77088 +
77089 +#ifdef CONFIG_PAX_KERNEXEC
77090 +#ifdef CONFIG_X86_64
77091 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
77092 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
77093 +#endif
77094 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
77095 + pax_open_kernel();
77096 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77097 + pax_close_kernel();
77098 + } else
77099 +#endif
77100
77101 - if (shdr->sh_type != SHT_NOBITS)
77102 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77103 + }
77104 /* Update sh_addr to point to copy in image. */
77105 - shdr->sh_addr = (unsigned long)dest;
77106 +
77107 +#ifdef CONFIG_PAX_KERNEXEC
77108 + if (shdr->sh_flags & SHF_EXECINSTR)
77109 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
77110 + else
77111 +#endif
77112 +
77113 + shdr->sh_addr = (unsigned long)dest;
77114 pr_debug("\t0x%lx %s\n",
77115 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
77116 }
77117 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
77118 * Do it before processing of module parameters, so the module
77119 * can provide parameter accessor functions of its own.
77120 */
77121 - if (mod->module_init)
77122 - flush_icache_range((unsigned long)mod->module_init,
77123 - (unsigned long)mod->module_init
77124 - + mod->init_size);
77125 - flush_icache_range((unsigned long)mod->module_core,
77126 - (unsigned long)mod->module_core + mod->core_size);
77127 + if (mod->module_init_rx)
77128 + flush_icache_range((unsigned long)mod->module_init_rx,
77129 + (unsigned long)mod->module_init_rx
77130 + + mod->init_size_rx);
77131 + flush_icache_range((unsigned long)mod->module_core_rx,
77132 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77133
77134 set_fs(old_fs);
77135 }
77136 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
77137 static void module_deallocate(struct module *mod, struct load_info *info)
77138 {
77139 percpu_modfree(mod);
77140 - module_free(mod, mod->module_init);
77141 - module_free(mod, mod->module_core);
77142 + module_free_exec(mod, mod->module_init_rx);
77143 + module_free_exec(mod, mod->module_core_rx);
77144 + module_free(mod, mod->module_init_rw);
77145 + module_free(mod, mod->module_core_rw);
77146 }
77147
77148 int __weak module_finalize(const Elf_Ehdr *hdr,
77149 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77150 static int post_relocation(struct module *mod, const struct load_info *info)
77151 {
77152 /* Sort exception table now relocations are done. */
77153 + pax_open_kernel();
77154 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77155 + pax_close_kernel();
77156
77157 /* Copy relocated percpu area over. */
77158 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77159 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
77160 MODULE_STATE_COMING, mod);
77161
77162 /* Set RO and NX regions for core */
77163 - set_section_ro_nx(mod->module_core,
77164 - mod->core_text_size,
77165 - mod->core_ro_size,
77166 - mod->core_size);
77167 + set_section_ro_nx(mod->module_core_rx,
77168 + mod->core_size_rx,
77169 + mod->core_size_rx,
77170 + mod->core_size_rx);
77171
77172 /* Set RO and NX regions for init */
77173 - set_section_ro_nx(mod->module_init,
77174 - mod->init_text_size,
77175 - mod->init_ro_size,
77176 - mod->init_size);
77177 + set_section_ro_nx(mod->module_init_rx,
77178 + mod->init_size_rx,
77179 + mod->init_size_rx,
77180 + mod->init_size_rx);
77181
77182 do_mod_ctors(mod);
77183 /* Start the module */
77184 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
77185 mod->strtab = mod->core_strtab;
77186 #endif
77187 unset_module_init_ro_nx(mod);
77188 - module_free(mod, mod->module_init);
77189 - mod->module_init = NULL;
77190 - mod->init_size = 0;
77191 - mod->init_ro_size = 0;
77192 - mod->init_text_size = 0;
77193 + module_free(mod, mod->module_init_rw);
77194 + module_free_exec(mod, mod->module_init_rx);
77195 + mod->module_init_rw = NULL;
77196 + mod->module_init_rx = NULL;
77197 + mod->init_size_rw = 0;
77198 + mod->init_size_rx = 0;
77199 mutex_unlock(&module_mutex);
77200 wake_up_all(&module_wq);
77201
77202 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
77203 if (err)
77204 goto free_unload;
77205
77206 + /* Now copy in args */
77207 + mod->args = strndup_user(uargs, ~0UL >> 1);
77208 + if (IS_ERR(mod->args)) {
77209 + err = PTR_ERR(mod->args);
77210 + goto free_unload;
77211 + }
77212 +
77213 /* Set up MODINFO_ATTR fields */
77214 setup_modinfo(mod, info);
77215
77216 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77217 + {
77218 + char *p, *p2;
77219 +
77220 + if (strstr(mod->args, "grsec_modharden_netdev")) {
77221 + 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);
77222 + err = -EPERM;
77223 + goto free_modinfo;
77224 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
77225 + p += sizeof("grsec_modharden_normal") - 1;
77226 + p2 = strstr(p, "_");
77227 + if (p2) {
77228 + *p2 = '\0';
77229 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
77230 + *p2 = '_';
77231 + }
77232 + err = -EPERM;
77233 + goto free_modinfo;
77234 + }
77235 + }
77236 +#endif
77237 +
77238 /* Fix up syms, so that st_value is a pointer to location. */
77239 err = simplify_symbols(mod, info);
77240 if (err < 0)
77241 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
77242
77243 flush_module_icache(mod);
77244
77245 - /* Now copy in args */
77246 - mod->args = strndup_user(uargs, ~0UL >> 1);
77247 - if (IS_ERR(mod->args)) {
77248 - err = PTR_ERR(mod->args);
77249 - goto free_arch_cleanup;
77250 - }
77251 -
77252 dynamic_debug_setup(info->debug, info->num_debug);
77253
77254 /* Finally it's fully formed, ready to start executing. */
77255 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
77256 ddebug_cleanup:
77257 dynamic_debug_remove(info->debug);
77258 synchronize_sched();
77259 - kfree(mod->args);
77260 - free_arch_cleanup:
77261 module_arch_cleanup(mod);
77262 free_modinfo:
77263 free_modinfo(mod);
77264 + kfree(mod->args);
77265 free_unload:
77266 module_unload_free(mod);
77267 unlink_mod:
77268 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
77269 unsigned long nextval;
77270
77271 /* At worse, next value is at end of module */
77272 - if (within_module_init(addr, mod))
77273 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77274 + if (within_module_init_rx(addr, mod))
77275 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77276 + else if (within_module_init_rw(addr, mod))
77277 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77278 + else if (within_module_core_rx(addr, mod))
77279 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77280 + else if (within_module_core_rw(addr, mod))
77281 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77282 else
77283 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77284 + return NULL;
77285
77286 /* Scan for closest preceding symbol, and next symbol. (ELF
77287 starts real symbols at 1). */
77288 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
77289 return 0;
77290
77291 seq_printf(m, "%s %u",
77292 - mod->name, mod->init_size + mod->core_size);
77293 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77294 print_unload_info(m, mod);
77295
77296 /* Informative for users. */
77297 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
77298 mod->state == MODULE_STATE_COMING ? "Loading":
77299 "Live");
77300 /* Used by oprofile and other similar tools. */
77301 - seq_printf(m, " 0x%pK", mod->module_core);
77302 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77303
77304 /* Taints info */
77305 if (mod->taints)
77306 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
77307
77308 static int __init proc_modules_init(void)
77309 {
77310 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77311 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77312 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77313 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77314 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77315 +#else
77316 proc_create("modules", 0, NULL, &proc_modules_operations);
77317 +#endif
77318 +#else
77319 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77320 +#endif
77321 return 0;
77322 }
77323 module_init(proc_modules_init);
77324 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
77325 {
77326 struct module *mod;
77327
77328 - if (addr < module_addr_min || addr > module_addr_max)
77329 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77330 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77331 return NULL;
77332
77333 list_for_each_entry_rcu(mod, &modules, list) {
77334 if (mod->state == MODULE_STATE_UNFORMED)
77335 continue;
77336 - if (within_module_core(addr, mod)
77337 - || within_module_init(addr, mod))
77338 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77339 return mod;
77340 }
77341 return NULL;
77342 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
77343 */
77344 struct module *__module_text_address(unsigned long addr)
77345 {
77346 - struct module *mod = __module_address(addr);
77347 + struct module *mod;
77348 +
77349 +#ifdef CONFIG_X86_32
77350 + addr = ktla_ktva(addr);
77351 +#endif
77352 +
77353 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77354 + return NULL;
77355 +
77356 + mod = __module_address(addr);
77357 +
77358 if (mod) {
77359 /* Make sure it's within the text section. */
77360 - if (!within(addr, mod->module_init, mod->init_text_size)
77361 - && !within(addr, mod->module_core, mod->core_text_size))
77362 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77363 mod = NULL;
77364 }
77365 return mod;
77366 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77367 index 7e3443f..b2a1e6b 100644
77368 --- a/kernel/mutex-debug.c
77369 +++ b/kernel/mutex-debug.c
77370 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77371 }
77372
77373 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77374 - struct thread_info *ti)
77375 + struct task_struct *task)
77376 {
77377 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77378
77379 /* Mark the current thread as blocked on the lock: */
77380 - ti->task->blocked_on = waiter;
77381 + task->blocked_on = waiter;
77382 }
77383
77384 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77385 - struct thread_info *ti)
77386 + struct task_struct *task)
77387 {
77388 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77389 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77390 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77391 - ti->task->blocked_on = NULL;
77392 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77393 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77394 + task->blocked_on = NULL;
77395
77396 list_del_init(&waiter->list);
77397 waiter->task = NULL;
77398 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77399 index 0799fd3..d06ae3b 100644
77400 --- a/kernel/mutex-debug.h
77401 +++ b/kernel/mutex-debug.h
77402 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77403 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77404 extern void debug_mutex_add_waiter(struct mutex *lock,
77405 struct mutex_waiter *waiter,
77406 - struct thread_info *ti);
77407 + struct task_struct *task);
77408 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77409 - struct thread_info *ti);
77410 + struct task_struct *task);
77411 extern void debug_mutex_unlock(struct mutex *lock);
77412 extern void debug_mutex_init(struct mutex *lock, const char *name,
77413 struct lock_class_key *key);
77414 diff --git a/kernel/mutex.c b/kernel/mutex.c
77415 index ad53a66..f1bf8bc 100644
77416 --- a/kernel/mutex.c
77417 +++ b/kernel/mutex.c
77418 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
77419 node->locked = 1;
77420 return;
77421 }
77422 - ACCESS_ONCE(prev->next) = node;
77423 + ACCESS_ONCE_RW(prev->next) = node;
77424 smp_wmb();
77425 /* Wait until the lock holder passes the lock down */
77426 while (!ACCESS_ONCE(node->locked))
77427 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
77428 while (!(next = ACCESS_ONCE(node->next)))
77429 arch_mutex_cpu_relax();
77430 }
77431 - ACCESS_ONCE(next->locked) = 1;
77432 + ACCESS_ONCE_RW(next->locked) = 1;
77433 smp_wmb();
77434 }
77435
77436 @@ -341,7 +341,7 @@ slowpath:
77437 spin_lock_mutex(&lock->wait_lock, flags);
77438
77439 debug_mutex_lock_common(lock, &waiter);
77440 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77441 + debug_mutex_add_waiter(lock, &waiter, task);
77442
77443 /* add waiting tasks to the end of the waitqueue (FIFO): */
77444 list_add_tail(&waiter.list, &lock->wait_list);
77445 @@ -371,8 +371,7 @@ slowpath:
77446 * TASK_UNINTERRUPTIBLE case.)
77447 */
77448 if (unlikely(signal_pending_state(state, task))) {
77449 - mutex_remove_waiter(lock, &waiter,
77450 - task_thread_info(task));
77451 + mutex_remove_waiter(lock, &waiter, task);
77452 mutex_release(&lock->dep_map, 1, ip);
77453 spin_unlock_mutex(&lock->wait_lock, flags);
77454
77455 @@ -391,7 +390,7 @@ slowpath:
77456 done:
77457 lock_acquired(&lock->dep_map, ip);
77458 /* got the lock - rejoice! */
77459 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77460 + mutex_remove_waiter(lock, &waiter, task);
77461 mutex_set_owner(lock);
77462
77463 /* set it to 0 if there are no waiters left: */
77464 diff --git a/kernel/notifier.c b/kernel/notifier.c
77465 index 2d5cc4c..d9ea600 100644
77466 --- a/kernel/notifier.c
77467 +++ b/kernel/notifier.c
77468 @@ -5,6 +5,7 @@
77469 #include <linux/rcupdate.h>
77470 #include <linux/vmalloc.h>
77471 #include <linux/reboot.h>
77472 +#include <linux/mm.h>
77473
77474 /*
77475 * Notifier list for kernel code which wants to be called
77476 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77477 while ((*nl) != NULL) {
77478 if (n->priority > (*nl)->priority)
77479 break;
77480 - nl = &((*nl)->next);
77481 + nl = (struct notifier_block **)&((*nl)->next);
77482 }
77483 - n->next = *nl;
77484 + pax_open_kernel();
77485 + *(const void **)&n->next = *nl;
77486 rcu_assign_pointer(*nl, n);
77487 + pax_close_kernel();
77488 return 0;
77489 }
77490
77491 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77492 return 0;
77493 if (n->priority > (*nl)->priority)
77494 break;
77495 - nl = &((*nl)->next);
77496 + nl = (struct notifier_block **)&((*nl)->next);
77497 }
77498 - n->next = *nl;
77499 + pax_open_kernel();
77500 + *(const void **)&n->next = *nl;
77501 rcu_assign_pointer(*nl, n);
77502 + pax_close_kernel();
77503 return 0;
77504 }
77505
77506 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77507 {
77508 while ((*nl) != NULL) {
77509 if ((*nl) == n) {
77510 + pax_open_kernel();
77511 rcu_assign_pointer(*nl, n->next);
77512 + pax_close_kernel();
77513 return 0;
77514 }
77515 - nl = &((*nl)->next);
77516 + nl = (struct notifier_block **)&((*nl)->next);
77517 }
77518 return -ENOENT;
77519 }
77520 diff --git a/kernel/panic.c b/kernel/panic.c
77521 index 167ec09..0dda5f9 100644
77522 --- a/kernel/panic.c
77523 +++ b/kernel/panic.c
77524 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77525 unsigned taint, struct slowpath_args *args)
77526 {
77527 printk(KERN_WARNING "------------[ cut here ]------------\n");
77528 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77529 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77530
77531 if (args)
77532 vprintk(args->fmt, args->args);
77533 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77534 */
77535 void __stack_chk_fail(void)
77536 {
77537 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77538 + dump_stack();
77539 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77540 __builtin_return_address(0));
77541 }
77542 EXPORT_SYMBOL(__stack_chk_fail);
77543 diff --git a/kernel/pid.c b/kernel/pid.c
77544 index 0db3e79..95b9dc2 100644
77545 --- a/kernel/pid.c
77546 +++ b/kernel/pid.c
77547 @@ -33,6 +33,7 @@
77548 #include <linux/rculist.h>
77549 #include <linux/bootmem.h>
77550 #include <linux/hash.h>
77551 +#include <linux/security.h>
77552 #include <linux/pid_namespace.h>
77553 #include <linux/init_task.h>
77554 #include <linux/syscalls.h>
77555 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77556
77557 int pid_max = PID_MAX_DEFAULT;
77558
77559 -#define RESERVED_PIDS 300
77560 +#define RESERVED_PIDS 500
77561
77562 int pid_max_min = RESERVED_PIDS + 1;
77563 int pid_max_max = PID_MAX_LIMIT;
77564 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
77565 */
77566 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77567 {
77568 + struct task_struct *task;
77569 +
77570 rcu_lockdep_assert(rcu_read_lock_held(),
77571 "find_task_by_pid_ns() needs rcu_read_lock()"
77572 " protection");
77573 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77574 +
77575 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77576 +
77577 + if (gr_pid_is_chrooted(task))
77578 + return NULL;
77579 +
77580 + return task;
77581 }
77582
77583 struct task_struct *find_task_by_vpid(pid_t vnr)
77584 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77585 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77586 }
77587
77588 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77589 +{
77590 + rcu_lockdep_assert(rcu_read_lock_held(),
77591 + "find_task_by_pid_ns() needs rcu_read_lock()"
77592 + " protection");
77593 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77594 +}
77595 +
77596 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77597 {
77598 struct pid *pid;
77599 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77600 index 6917e8e..9909aeb 100644
77601 --- a/kernel/pid_namespace.c
77602 +++ b/kernel/pid_namespace.c
77603 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77604 void __user *buffer, size_t *lenp, loff_t *ppos)
77605 {
77606 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77607 - struct ctl_table tmp = *table;
77608 + ctl_table_no_const tmp = *table;
77609
77610 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77611 return -EPERM;
77612 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77613 index 42670e9..8719c2f 100644
77614 --- a/kernel/posix-cpu-timers.c
77615 +++ b/kernel/posix-cpu-timers.c
77616 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
77617
77618 static __init int init_posix_cpu_timers(void)
77619 {
77620 - struct k_clock process = {
77621 + static struct k_clock process = {
77622 .clock_getres = process_cpu_clock_getres,
77623 .clock_get = process_cpu_clock_get,
77624 .timer_create = process_cpu_timer_create,
77625 .nsleep = process_cpu_nsleep,
77626 .nsleep_restart = process_cpu_nsleep_restart,
77627 };
77628 - struct k_clock thread = {
77629 + static struct k_clock thread = {
77630 .clock_getres = thread_cpu_clock_getres,
77631 .clock_get = thread_cpu_clock_get,
77632 .timer_create = thread_cpu_timer_create,
77633 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77634 index 424c2d4..a9194f7 100644
77635 --- a/kernel/posix-timers.c
77636 +++ b/kernel/posix-timers.c
77637 @@ -43,6 +43,7 @@
77638 #include <linux/hash.h>
77639 #include <linux/posix-clock.h>
77640 #include <linux/posix-timers.h>
77641 +#include <linux/grsecurity.h>
77642 #include <linux/syscalls.h>
77643 #include <linux/wait.h>
77644 #include <linux/workqueue.h>
77645 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
77646 * which we beg off on and pass to do_sys_settimeofday().
77647 */
77648
77649 -static struct k_clock posix_clocks[MAX_CLOCKS];
77650 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77651
77652 /*
77653 * These ones are defined below.
77654 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
77655 */
77656 static __init int init_posix_timers(void)
77657 {
77658 - struct k_clock clock_realtime = {
77659 + static struct k_clock clock_realtime = {
77660 .clock_getres = hrtimer_get_res,
77661 .clock_get = posix_clock_realtime_get,
77662 .clock_set = posix_clock_realtime_set,
77663 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
77664 .timer_get = common_timer_get,
77665 .timer_del = common_timer_del,
77666 };
77667 - struct k_clock clock_monotonic = {
77668 + static struct k_clock clock_monotonic = {
77669 .clock_getres = hrtimer_get_res,
77670 .clock_get = posix_ktime_get_ts,
77671 .nsleep = common_nsleep,
77672 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
77673 .timer_get = common_timer_get,
77674 .timer_del = common_timer_del,
77675 };
77676 - struct k_clock clock_monotonic_raw = {
77677 + static struct k_clock clock_monotonic_raw = {
77678 .clock_getres = hrtimer_get_res,
77679 .clock_get = posix_get_monotonic_raw,
77680 };
77681 - struct k_clock clock_realtime_coarse = {
77682 + static struct k_clock clock_realtime_coarse = {
77683 .clock_getres = posix_get_coarse_res,
77684 .clock_get = posix_get_realtime_coarse,
77685 };
77686 - struct k_clock clock_monotonic_coarse = {
77687 + static struct k_clock clock_monotonic_coarse = {
77688 .clock_getres = posix_get_coarse_res,
77689 .clock_get = posix_get_monotonic_coarse,
77690 };
77691 - struct k_clock clock_tai = {
77692 + static struct k_clock clock_tai = {
77693 .clock_getres = hrtimer_get_res,
77694 .clock_get = posix_get_tai,
77695 .nsleep = common_nsleep,
77696 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
77697 .timer_get = common_timer_get,
77698 .timer_del = common_timer_del,
77699 };
77700 - struct k_clock clock_boottime = {
77701 + static struct k_clock clock_boottime = {
77702 .clock_getres = hrtimer_get_res,
77703 .clock_get = posix_get_boottime,
77704 .nsleep = common_nsleep,
77705 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77706 return;
77707 }
77708
77709 - posix_clocks[clock_id] = *new_clock;
77710 + posix_clocks[clock_id] = new_clock;
77711 }
77712 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77713
77714 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77715 return (id & CLOCKFD_MASK) == CLOCKFD ?
77716 &clock_posix_dynamic : &clock_posix_cpu;
77717
77718 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77719 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77720 return NULL;
77721 - return &posix_clocks[id];
77722 + return posix_clocks[id];
77723 }
77724
77725 static int common_timer_create(struct k_itimer *new_timer)
77726 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77727 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77728 return -EFAULT;
77729
77730 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77731 + have their clock_set fptr set to a nosettime dummy function
77732 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77733 + call common_clock_set, which calls do_sys_settimeofday, which
77734 + we hook
77735 + */
77736 +
77737 return kc->clock_set(which_clock, &new_tp);
77738 }
77739
77740 diff --git a/kernel/power/process.c b/kernel/power/process.c
77741 index 98088e0..aaf95c0 100644
77742 --- a/kernel/power/process.c
77743 +++ b/kernel/power/process.c
77744 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77745 u64 elapsed_csecs64;
77746 unsigned int elapsed_csecs;
77747 bool wakeup = false;
77748 + bool timedout = false;
77749
77750 do_gettimeofday(&start);
77751
77752 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77753
77754 while (true) {
77755 todo = 0;
77756 + if (time_after(jiffies, end_time))
77757 + timedout = true;
77758 read_lock(&tasklist_lock);
77759 do_each_thread(g, p) {
77760 if (p == current || !freeze_task(p))
77761 continue;
77762
77763 - if (!freezer_should_skip(p))
77764 + if (!freezer_should_skip(p)) {
77765 todo++;
77766 + if (timedout) {
77767 + printk(KERN_ERR "Task refusing to freeze:\n");
77768 + sched_show_task(p);
77769 + }
77770 + }
77771 } while_each_thread(g, p);
77772 read_unlock(&tasklist_lock);
77773
77774 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77775 todo += wq_busy;
77776 }
77777
77778 - if (!todo || time_after(jiffies, end_time))
77779 + if (!todo || timedout)
77780 break;
77781
77782 if (pm_wakeup_pending()) {
77783 diff --git a/kernel/printk.c b/kernel/printk.c
77784 index 8212c1a..eb61021 100644
77785 --- a/kernel/printk.c
77786 +++ b/kernel/printk.c
77787 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
77788 if (from_file && type != SYSLOG_ACTION_OPEN)
77789 return 0;
77790
77791 +#ifdef CONFIG_GRKERNSEC_DMESG
77792 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77793 + return -EPERM;
77794 +#endif
77795 +
77796 if (syslog_action_restricted(type)) {
77797 if (capable(CAP_SYSLOG))
77798 return 0;
77799 diff --git a/kernel/profile.c b/kernel/profile.c
77800 index 0bf4007..6234708 100644
77801 --- a/kernel/profile.c
77802 +++ b/kernel/profile.c
77803 @@ -37,7 +37,7 @@ struct profile_hit {
77804 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77805 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77806
77807 -static atomic_t *prof_buffer;
77808 +static atomic_unchecked_t *prof_buffer;
77809 static unsigned long prof_len, prof_shift;
77810
77811 int prof_on __read_mostly;
77812 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77813 hits[i].pc = 0;
77814 continue;
77815 }
77816 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77817 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77818 hits[i].hits = hits[i].pc = 0;
77819 }
77820 }
77821 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77822 * Add the current hit(s) and flush the write-queue out
77823 * to the global buffer:
77824 */
77825 - atomic_add(nr_hits, &prof_buffer[pc]);
77826 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77827 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77828 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77829 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77830 hits[i].pc = hits[i].hits = 0;
77831 }
77832 out:
77833 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77834 {
77835 unsigned long pc;
77836 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77837 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77838 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77839 }
77840 #endif /* !CONFIG_SMP */
77841
77842 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77843 return -EFAULT;
77844 buf++; p++; count--; read++;
77845 }
77846 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77847 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77848 if (copy_to_user(buf, (void *)pnt, count))
77849 return -EFAULT;
77850 read += count;
77851 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77852 }
77853 #endif
77854 profile_discard_flip_buffers();
77855 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77856 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77857 return count;
77858 }
77859
77860 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77861 index 335a7ae..3bbbceb 100644
77862 --- a/kernel/ptrace.c
77863 +++ b/kernel/ptrace.c
77864 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77865 if (seize)
77866 flags |= PT_SEIZED;
77867 rcu_read_lock();
77868 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77869 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77870 flags |= PT_PTRACE_CAP;
77871 rcu_read_unlock();
77872 task->ptrace = flags;
77873 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77874 break;
77875 return -EIO;
77876 }
77877 - if (copy_to_user(dst, buf, retval))
77878 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77879 return -EFAULT;
77880 copied += retval;
77881 src += retval;
77882 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
77883 bool seized = child->ptrace & PT_SEIZED;
77884 int ret = -EIO;
77885 siginfo_t siginfo, *si;
77886 - void __user *datavp = (void __user *) data;
77887 + void __user *datavp = (__force void __user *) data;
77888 unsigned long __user *datalp = datavp;
77889 unsigned long flags;
77890
77891 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77892 goto out;
77893 }
77894
77895 + if (gr_handle_ptrace(child, request)) {
77896 + ret = -EPERM;
77897 + goto out_put_task_struct;
77898 + }
77899 +
77900 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77901 ret = ptrace_attach(child, request, addr, data);
77902 /*
77903 * Some architectures need to do book-keeping after
77904 * a ptrace attach.
77905 */
77906 - if (!ret)
77907 + if (!ret) {
77908 arch_ptrace_attach(child);
77909 + gr_audit_ptrace(child);
77910 + }
77911 goto out_put_task_struct;
77912 }
77913
77914 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77915 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77916 if (copied != sizeof(tmp))
77917 return -EIO;
77918 - return put_user(tmp, (unsigned long __user *)data);
77919 + return put_user(tmp, (__force unsigned long __user *)data);
77920 }
77921
77922 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77923 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77924 }
77925
77926 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77927 - compat_long_t addr, compat_long_t data)
77928 + compat_ulong_t addr, compat_ulong_t data)
77929 {
77930 struct task_struct *child;
77931 long ret;
77932 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77933 goto out;
77934 }
77935
77936 + if (gr_handle_ptrace(child, request)) {
77937 + ret = -EPERM;
77938 + goto out_put_task_struct;
77939 + }
77940 +
77941 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77942 ret = ptrace_attach(child, request, addr, data);
77943 /*
77944 * Some architectures need to do book-keeping after
77945 * a ptrace attach.
77946 */
77947 - if (!ret)
77948 + if (!ret) {
77949 arch_ptrace_attach(child);
77950 + gr_audit_ptrace(child);
77951 + }
77952 goto out_put_task_struct;
77953 }
77954
77955 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77956 index 48ab703..07561d4 100644
77957 --- a/kernel/rcupdate.c
77958 +++ b/kernel/rcupdate.c
77959 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77960 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77961 */
77962 if (till_stall_check < 3) {
77963 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77964 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77965 till_stall_check = 3;
77966 } else if (till_stall_check > 300) {
77967 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77968 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77969 till_stall_check = 300;
77970 }
77971 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77972 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77973 index a0714a5..2ab5e34 100644
77974 --- a/kernel/rcutiny.c
77975 +++ b/kernel/rcutiny.c
77976 @@ -46,7 +46,7 @@
77977 struct rcu_ctrlblk;
77978 static void invoke_rcu_callbacks(void);
77979 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77980 -static void rcu_process_callbacks(struct softirq_action *unused);
77981 +static void rcu_process_callbacks(void);
77982 static void __call_rcu(struct rcu_head *head,
77983 void (*func)(struct rcu_head *rcu),
77984 struct rcu_ctrlblk *rcp);
77985 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77986 rcu_is_callbacks_kthread()));
77987 }
77988
77989 -static void rcu_process_callbacks(struct softirq_action *unused)
77990 +static void rcu_process_callbacks(void)
77991 {
77992 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77993 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77994 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77995 index 8a23300..4255818 100644
77996 --- a/kernel/rcutiny_plugin.h
77997 +++ b/kernel/rcutiny_plugin.h
77998 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77999 have_rcu_kthread_work = morework;
78000 local_irq_restore(flags);
78001 if (work)
78002 - rcu_process_callbacks(NULL);
78003 + rcu_process_callbacks();
78004 schedule_timeout_interruptible(1); /* Leave CPU for others. */
78005 }
78006
78007 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
78008 index e1f3a8c..42c94a2 100644
78009 --- a/kernel/rcutorture.c
78010 +++ b/kernel/rcutorture.c
78011 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
78012 { 0 };
78013 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
78014 { 0 };
78015 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78016 -static atomic_t n_rcu_torture_alloc;
78017 -static atomic_t n_rcu_torture_alloc_fail;
78018 -static atomic_t n_rcu_torture_free;
78019 -static atomic_t n_rcu_torture_mberror;
78020 -static atomic_t n_rcu_torture_error;
78021 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78022 +static atomic_unchecked_t n_rcu_torture_alloc;
78023 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
78024 +static atomic_unchecked_t n_rcu_torture_free;
78025 +static atomic_unchecked_t n_rcu_torture_mberror;
78026 +static atomic_unchecked_t n_rcu_torture_error;
78027 static long n_rcu_torture_barrier_error;
78028 static long n_rcu_torture_boost_ktrerror;
78029 static long n_rcu_torture_boost_rterror;
78030 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
78031
78032 spin_lock_bh(&rcu_torture_lock);
78033 if (list_empty(&rcu_torture_freelist)) {
78034 - atomic_inc(&n_rcu_torture_alloc_fail);
78035 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
78036 spin_unlock_bh(&rcu_torture_lock);
78037 return NULL;
78038 }
78039 - atomic_inc(&n_rcu_torture_alloc);
78040 + atomic_inc_unchecked(&n_rcu_torture_alloc);
78041 p = rcu_torture_freelist.next;
78042 list_del_init(p);
78043 spin_unlock_bh(&rcu_torture_lock);
78044 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
78045 static void
78046 rcu_torture_free(struct rcu_torture *p)
78047 {
78048 - atomic_inc(&n_rcu_torture_free);
78049 + atomic_inc_unchecked(&n_rcu_torture_free);
78050 spin_lock_bh(&rcu_torture_lock);
78051 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
78052 spin_unlock_bh(&rcu_torture_lock);
78053 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
78054 i = rp->rtort_pipe_count;
78055 if (i > RCU_TORTURE_PIPE_LEN)
78056 i = RCU_TORTURE_PIPE_LEN;
78057 - atomic_inc(&rcu_torture_wcount[i]);
78058 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78059 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78060 rp->rtort_mbtest = 0;
78061 rcu_torture_free(rp);
78062 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
78063 i = rp->rtort_pipe_count;
78064 if (i > RCU_TORTURE_PIPE_LEN)
78065 i = RCU_TORTURE_PIPE_LEN;
78066 - atomic_inc(&rcu_torture_wcount[i]);
78067 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78068 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78069 rp->rtort_mbtest = 0;
78070 list_del(&rp->rtort_free);
78071 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
78072 i = old_rp->rtort_pipe_count;
78073 if (i > RCU_TORTURE_PIPE_LEN)
78074 i = RCU_TORTURE_PIPE_LEN;
78075 - atomic_inc(&rcu_torture_wcount[i]);
78076 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78077 old_rp->rtort_pipe_count++;
78078 cur_ops->deferred_free(old_rp);
78079 }
78080 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
78081 return;
78082 }
78083 if (p->rtort_mbtest == 0)
78084 - atomic_inc(&n_rcu_torture_mberror);
78085 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78086 spin_lock(&rand_lock);
78087 cur_ops->read_delay(&rand);
78088 n_rcu_torture_timers++;
78089 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
78090 continue;
78091 }
78092 if (p->rtort_mbtest == 0)
78093 - atomic_inc(&n_rcu_torture_mberror);
78094 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78095 cur_ops->read_delay(&rand);
78096 preempt_disable();
78097 pipe_count = p->rtort_pipe_count;
78098 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
78099 rcu_torture_current,
78100 rcu_torture_current_version,
78101 list_empty(&rcu_torture_freelist),
78102 - atomic_read(&n_rcu_torture_alloc),
78103 - atomic_read(&n_rcu_torture_alloc_fail),
78104 - atomic_read(&n_rcu_torture_free));
78105 + atomic_read_unchecked(&n_rcu_torture_alloc),
78106 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
78107 + atomic_read_unchecked(&n_rcu_torture_free));
78108 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
78109 - atomic_read(&n_rcu_torture_mberror),
78110 + atomic_read_unchecked(&n_rcu_torture_mberror),
78111 n_rcu_torture_boost_ktrerror,
78112 n_rcu_torture_boost_rterror);
78113 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
78114 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
78115 n_barrier_attempts,
78116 n_rcu_torture_barrier_error);
78117 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
78118 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
78119 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
78120 n_rcu_torture_barrier_error != 0 ||
78121 n_rcu_torture_boost_ktrerror != 0 ||
78122 n_rcu_torture_boost_rterror != 0 ||
78123 n_rcu_torture_boost_failure != 0 ||
78124 i > 1) {
78125 cnt += sprintf(&page[cnt], "!!! ");
78126 - atomic_inc(&n_rcu_torture_error);
78127 + atomic_inc_unchecked(&n_rcu_torture_error);
78128 WARN_ON_ONCE(1);
78129 }
78130 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78131 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
78132 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78133 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78134 cnt += sprintf(&page[cnt], " %d",
78135 - atomic_read(&rcu_torture_wcount[i]));
78136 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78137 }
78138 cnt += sprintf(&page[cnt], "\n");
78139 if (cur_ops->stats)
78140 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
78141
78142 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78143
78144 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78145 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78146 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78147 else if (n_online_successes != n_online_attempts ||
78148 n_offline_successes != n_offline_attempts)
78149 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
78150
78151 rcu_torture_current = NULL;
78152 rcu_torture_current_version = 0;
78153 - atomic_set(&n_rcu_torture_alloc, 0);
78154 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78155 - atomic_set(&n_rcu_torture_free, 0);
78156 - atomic_set(&n_rcu_torture_mberror, 0);
78157 - atomic_set(&n_rcu_torture_error, 0);
78158 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78159 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78160 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78161 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78162 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78163 n_rcu_torture_barrier_error = 0;
78164 n_rcu_torture_boost_ktrerror = 0;
78165 n_rcu_torture_boost_rterror = 0;
78166 n_rcu_torture_boost_failure = 0;
78167 n_rcu_torture_boosts = 0;
78168 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78169 - atomic_set(&rcu_torture_wcount[i], 0);
78170 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78171 for_each_possible_cpu(cpu) {
78172 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78173 per_cpu(rcu_torture_count, cpu)[i] = 0;
78174 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78175 index 3538001..e379e0b 100644
78176 --- a/kernel/rcutree.c
78177 +++ b/kernel/rcutree.c
78178 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78179 rcu_prepare_for_idle(smp_processor_id());
78180 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78181 smp_mb__before_atomic_inc(); /* See above. */
78182 - atomic_inc(&rdtp->dynticks);
78183 + atomic_inc_unchecked(&rdtp->dynticks);
78184 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78185 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78186 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78187
78188 /*
78189 * It is illegal to enter an extended quiescent state while
78190 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78191 int user)
78192 {
78193 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78194 - atomic_inc(&rdtp->dynticks);
78195 + atomic_inc_unchecked(&rdtp->dynticks);
78196 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78197 smp_mb__after_atomic_inc(); /* See above. */
78198 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78199 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78200 rcu_cleanup_after_idle(smp_processor_id());
78201 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78202 if (!user && !is_idle_task(current)) {
78203 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
78204 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78205
78206 if (rdtp->dynticks_nmi_nesting == 0 &&
78207 - (atomic_read(&rdtp->dynticks) & 0x1))
78208 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78209 return;
78210 rdtp->dynticks_nmi_nesting++;
78211 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
78212 - atomic_inc(&rdtp->dynticks);
78213 + atomic_inc_unchecked(&rdtp->dynticks);
78214 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78215 smp_mb__after_atomic_inc(); /* See above. */
78216 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78217 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78218 }
78219
78220 /**
78221 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
78222 return;
78223 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78224 smp_mb__before_atomic_inc(); /* See above. */
78225 - atomic_inc(&rdtp->dynticks);
78226 + atomic_inc_unchecked(&rdtp->dynticks);
78227 smp_mb__after_atomic_inc(); /* Force delay to next write. */
78228 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78229 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78230 }
78231
78232 /**
78233 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
78234 int ret;
78235
78236 preempt_disable();
78237 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78238 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78239 preempt_enable();
78240 return ret;
78241 }
78242 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
78243 */
78244 static int dyntick_save_progress_counter(struct rcu_data *rdp)
78245 {
78246 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
78247 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78248 return (rdp->dynticks_snap & 0x1) == 0;
78249 }
78250
78251 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
78252 unsigned int curr;
78253 unsigned int snap;
78254
78255 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
78256 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78257 snap = (unsigned int)rdp->dynticks_snap;
78258
78259 /*
78260 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
78261 rdp = this_cpu_ptr(rsp->rda);
78262 rcu_preempt_check_blocked_tasks(rnp);
78263 rnp->qsmask = rnp->qsmaskinit;
78264 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
78265 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
78266 WARN_ON_ONCE(rnp->completed != rsp->completed);
78267 - ACCESS_ONCE(rnp->completed) = rsp->completed;
78268 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
78269 if (rnp == rdp->mynode)
78270 rcu_start_gp_per_cpu(rsp, rnp, rdp);
78271 rcu_preempt_boost_start_gp(rnp);
78272 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
78273 */
78274 rcu_for_each_node_breadth_first(rsp, rnp) {
78275 raw_spin_lock_irq(&rnp->lock);
78276 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
78277 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
78278 rdp = this_cpu_ptr(rsp->rda);
78279 if (rnp == rdp->mynode)
78280 __rcu_process_gp_end(rsp, rnp, rdp);
78281 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
78282 rsp->qlen += rdp->qlen;
78283 rdp->n_cbs_orphaned += rdp->qlen;
78284 rdp->qlen_lazy = 0;
78285 - ACCESS_ONCE(rdp->qlen) = 0;
78286 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78287 }
78288
78289 /*
78290 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
78291 }
78292 smp_mb(); /* List handling before counting for rcu_barrier(). */
78293 rdp->qlen_lazy -= count_lazy;
78294 - ACCESS_ONCE(rdp->qlen) -= count;
78295 + ACCESS_ONCE_RW(rdp->qlen) -= count;
78296 rdp->n_cbs_invoked += count;
78297
78298 /* Reinstate batch limit if we have worked down the excess. */
78299 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
78300 /*
78301 * Do RCU core processing for the current CPU.
78302 */
78303 -static void rcu_process_callbacks(struct softirq_action *unused)
78304 +static void rcu_process_callbacks(void)
78305 {
78306 struct rcu_state *rsp;
78307
78308 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78309 local_irq_restore(flags);
78310 return;
78311 }
78312 - ACCESS_ONCE(rdp->qlen)++;
78313 + ACCESS_ONCE_RW(rdp->qlen)++;
78314 if (lazy)
78315 rdp->qlen_lazy++;
78316 else
78317 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
78318 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78319 * course be required on a 64-bit system.
78320 */
78321 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78322 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78323 (ulong)atomic_long_read(&rsp->expedited_done) +
78324 ULONG_MAX / 8)) {
78325 synchronize_sched();
78326 - atomic_long_inc(&rsp->expedited_wrap);
78327 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78328 return;
78329 }
78330
78331 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
78332 * Take a ticket. Note that atomic_inc_return() implies a
78333 * full memory barrier.
78334 */
78335 - snap = atomic_long_inc_return(&rsp->expedited_start);
78336 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78337 firstsnap = snap;
78338 get_online_cpus();
78339 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78340 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
78341 synchronize_sched_expedited_cpu_stop,
78342 NULL) == -EAGAIN) {
78343 put_online_cpus();
78344 - atomic_long_inc(&rsp->expedited_tryfail);
78345 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78346
78347 /* Check to see if someone else did our work for us. */
78348 s = atomic_long_read(&rsp->expedited_done);
78349 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78350 /* ensure test happens before caller kfree */
78351 smp_mb__before_atomic_inc(); /* ^^^ */
78352 - atomic_long_inc(&rsp->expedited_workdone1);
78353 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78354 return;
78355 }
78356
78357 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
78358 udelay(trycount * num_online_cpus());
78359 } else {
78360 wait_rcu_gp(call_rcu_sched);
78361 - atomic_long_inc(&rsp->expedited_normal);
78362 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78363 return;
78364 }
78365
78366 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
78367 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78368 /* ensure test happens before caller kfree */
78369 smp_mb__before_atomic_inc(); /* ^^^ */
78370 - atomic_long_inc(&rsp->expedited_workdone2);
78371 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78372 return;
78373 }
78374
78375 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
78376 * period works for us.
78377 */
78378 get_online_cpus();
78379 - snap = atomic_long_read(&rsp->expedited_start);
78380 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78381 smp_mb(); /* ensure read is before try_stop_cpus(). */
78382 }
78383 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78384 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78385
78386 /*
78387 * Everyone up to our most recent fetch is covered by our grace
78388 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
78389 * than we did already did their update.
78390 */
78391 do {
78392 - atomic_long_inc(&rsp->expedited_done_tries);
78393 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78394 s = atomic_long_read(&rsp->expedited_done);
78395 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78396 /* ensure test happens before caller kfree */
78397 smp_mb__before_atomic_inc(); /* ^^^ */
78398 - atomic_long_inc(&rsp->expedited_done_lost);
78399 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78400 break;
78401 }
78402 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78403 - atomic_long_inc(&rsp->expedited_done_exit);
78404 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78405
78406 put_online_cpus();
78407 }
78408 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78409 * ACCESS_ONCE() to prevent the compiler from speculating
78410 * the increment to precede the early-exit check.
78411 */
78412 - ACCESS_ONCE(rsp->n_barrier_done)++;
78413 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78414 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78415 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78416 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78417 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78418
78419 /* Increment ->n_barrier_done to prevent duplicate work. */
78420 smp_mb(); /* Keep increment after above mechanism. */
78421 - ACCESS_ONCE(rsp->n_barrier_done)++;
78422 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78423 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78424 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78425 smp_mb(); /* Keep increment before caller's subsequent code. */
78426 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78427 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78428 init_callback_list(rdp);
78429 rdp->qlen_lazy = 0;
78430 - ACCESS_ONCE(rdp->qlen) = 0;
78431 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78432 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78433 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78434 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78435 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78436 rdp->cpu = cpu;
78437 rdp->rsp = rsp;
78438 rcu_boot_init_nocb_percpu_data(rdp);
78439 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78440 rdp->blimit = blimit;
78441 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78442 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78443 - atomic_set(&rdp->dynticks->dynticks,
78444 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78445 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78446 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78447 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78448
78449 /* Add CPU to rcu_node bitmasks. */
78450 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
78451 struct task_struct *t;
78452
78453 for_each_rcu_flavor(rsp) {
78454 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
78455 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
78456 BUG_ON(IS_ERR(t));
78457 rnp = rcu_get_root(rsp);
78458 raw_spin_lock_irqsave(&rnp->lock, flags);
78459 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78460 index 4df5034..5ee93f2 100644
78461 --- a/kernel/rcutree.h
78462 +++ b/kernel/rcutree.h
78463 @@ -87,7 +87,7 @@ struct rcu_dynticks {
78464 long long dynticks_nesting; /* Track irq/process nesting level. */
78465 /* Process level is worth LLONG_MAX/2. */
78466 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78467 - atomic_t dynticks; /* Even value for idle, else odd. */
78468 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78469 #ifdef CONFIG_RCU_FAST_NO_HZ
78470 bool all_lazy; /* Are all CPU's CBs lazy? */
78471 unsigned long nonlazy_posted;
78472 @@ -414,17 +414,17 @@ struct rcu_state {
78473 /* _rcu_barrier(). */
78474 /* End of fields guarded by barrier_mutex. */
78475
78476 - atomic_long_t expedited_start; /* Starting ticket. */
78477 - atomic_long_t expedited_done; /* Done ticket. */
78478 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78479 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78480 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78481 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78482 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78483 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78484 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78485 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78486 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78487 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78488 + atomic_long_t expedited_done; /* Done ticket. */
78489 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78490 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78491 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78492 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78493 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78494 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78495 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78496 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78497 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78498
78499 unsigned long jiffies_force_qs; /* Time at which to invoke */
78500 /* force_quiescent_state(). */
78501 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78502 index 3db5a37..b395fb35 100644
78503 --- a/kernel/rcutree_plugin.h
78504 +++ b/kernel/rcutree_plugin.h
78505 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
78506
78507 /* Clean up and exit. */
78508 smp_mb(); /* ensure expedited GP seen before counter increment. */
78509 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78510 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78511 unlock_mb_ret:
78512 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78513 mb_ret:
78514 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78515 free_cpumask_var(cm);
78516 }
78517
78518 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78519 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78520 .store = &rcu_cpu_kthread_task,
78521 .thread_should_run = rcu_cpu_kthread_should_run,
78522 .thread_fn = rcu_cpu_kthread,
78523 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78524 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78525 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
78526 cpu, ticks_value, ticks_title,
78527 - atomic_read(&rdtp->dynticks) & 0xfff,
78528 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78529 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78530 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
78531 fast_no_hz);
78532 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78533
78534 /* Enqueue the callback on the nocb list and update counts. */
78535 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78536 - ACCESS_ONCE(*old_rhpp) = rhp;
78537 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78538 atomic_long_add(rhcount, &rdp->nocb_q_count);
78539 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78540
78541 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
78542 * Extract queued callbacks, update counts, and wait
78543 * for a grace period to elapse.
78544 */
78545 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78546 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78547 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78548 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78549 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78550 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78551 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78552 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78553 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78554 rcu_nocb_wait_gp(rdp);
78555
78556 /* Each pass through the following loop invokes a callback. */
78557 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
78558 list = next;
78559 }
78560 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78561 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78562 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78563 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78564 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78565 rdp->n_nocbs_invoked += c;
78566 }
78567 return 0;
78568 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78569 t = kthread_run(rcu_nocb_kthread, rdp,
78570 "rcuo%c/%d", rsp->abbr, cpu);
78571 BUG_ON(IS_ERR(t));
78572 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78573 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78574 }
78575 }
78576
78577 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78578 index cf6c174..a8f4b50 100644
78579 --- a/kernel/rcutree_trace.c
78580 +++ b/kernel/rcutree_trace.c
78581 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78582 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78583 rdp->passed_quiesce, rdp->qs_pending);
78584 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78585 - atomic_read(&rdp->dynticks->dynticks),
78586 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78587 rdp->dynticks->dynticks_nesting,
78588 rdp->dynticks->dynticks_nmi_nesting,
78589 rdp->dynticks_fqs);
78590 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78591 struct rcu_state *rsp = (struct rcu_state *)m->private;
78592
78593 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",
78594 - atomic_long_read(&rsp->expedited_start),
78595 + atomic_long_read_unchecked(&rsp->expedited_start),
78596 atomic_long_read(&rsp->expedited_done),
78597 - atomic_long_read(&rsp->expedited_wrap),
78598 - atomic_long_read(&rsp->expedited_tryfail),
78599 - atomic_long_read(&rsp->expedited_workdone1),
78600 - atomic_long_read(&rsp->expedited_workdone2),
78601 - atomic_long_read(&rsp->expedited_normal),
78602 - atomic_long_read(&rsp->expedited_stoppedcpus),
78603 - atomic_long_read(&rsp->expedited_done_tries),
78604 - atomic_long_read(&rsp->expedited_done_lost),
78605 - atomic_long_read(&rsp->expedited_done_exit));
78606 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78607 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78608 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78609 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78610 + atomic_long_read_unchecked(&rsp->expedited_normal),
78611 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78612 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78613 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78614 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78615 return 0;
78616 }
78617
78618 diff --git a/kernel/resource.c b/kernel/resource.c
78619 index d738698..5f8e60a 100644
78620 --- a/kernel/resource.c
78621 +++ b/kernel/resource.c
78622 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
78623
78624 static int __init ioresources_init(void)
78625 {
78626 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78627 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78628 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78629 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78630 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78631 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78632 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78633 +#endif
78634 +#else
78635 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78636 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78637 +#endif
78638 return 0;
78639 }
78640 __initcall(ioresources_init);
78641 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78642 index 1d96dd0..994ff19 100644
78643 --- a/kernel/rtmutex-tester.c
78644 +++ b/kernel/rtmutex-tester.c
78645 @@ -22,7 +22,7 @@
78646 #define MAX_RT_TEST_MUTEXES 8
78647
78648 static spinlock_t rttest_lock;
78649 -static atomic_t rttest_event;
78650 +static atomic_unchecked_t rttest_event;
78651
78652 struct test_thread_data {
78653 int opcode;
78654 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78655
78656 case RTTEST_LOCKCONT:
78657 td->mutexes[td->opdata] = 1;
78658 - td->event = atomic_add_return(1, &rttest_event);
78659 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78660 return 0;
78661
78662 case RTTEST_RESET:
78663 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78664 return 0;
78665
78666 case RTTEST_RESETEVENT:
78667 - atomic_set(&rttest_event, 0);
78668 + atomic_set_unchecked(&rttest_event, 0);
78669 return 0;
78670
78671 default:
78672 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78673 return ret;
78674
78675 td->mutexes[id] = 1;
78676 - td->event = atomic_add_return(1, &rttest_event);
78677 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78678 rt_mutex_lock(&mutexes[id]);
78679 - td->event = atomic_add_return(1, &rttest_event);
78680 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78681 td->mutexes[id] = 4;
78682 return 0;
78683
78684 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78685 return ret;
78686
78687 td->mutexes[id] = 1;
78688 - td->event = atomic_add_return(1, &rttest_event);
78689 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78690 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78691 - td->event = atomic_add_return(1, &rttest_event);
78692 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78693 td->mutexes[id] = ret ? 0 : 4;
78694 return ret ? -EINTR : 0;
78695
78696 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78697 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78698 return ret;
78699
78700 - td->event = atomic_add_return(1, &rttest_event);
78701 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78702 rt_mutex_unlock(&mutexes[id]);
78703 - td->event = atomic_add_return(1, &rttest_event);
78704 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78705 td->mutexes[id] = 0;
78706 return 0;
78707
78708 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78709 break;
78710
78711 td->mutexes[dat] = 2;
78712 - td->event = atomic_add_return(1, &rttest_event);
78713 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78714 break;
78715
78716 default:
78717 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78718 return;
78719
78720 td->mutexes[dat] = 3;
78721 - td->event = atomic_add_return(1, &rttest_event);
78722 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78723 break;
78724
78725 case RTTEST_LOCKNOWAIT:
78726 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78727 return;
78728
78729 td->mutexes[dat] = 1;
78730 - td->event = atomic_add_return(1, &rttest_event);
78731 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78732 return;
78733
78734 default:
78735 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78736 index 64de5f8..7735e12 100644
78737 --- a/kernel/sched/auto_group.c
78738 +++ b/kernel/sched/auto_group.c
78739 @@ -11,7 +11,7 @@
78740
78741 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78742 static struct autogroup autogroup_default;
78743 -static atomic_t autogroup_seq_nr;
78744 +static atomic_unchecked_t autogroup_seq_nr;
78745
78746 void __init autogroup_init(struct task_struct *init_task)
78747 {
78748 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78749
78750 kref_init(&ag->kref);
78751 init_rwsem(&ag->lock);
78752 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78753 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78754 ag->tg = tg;
78755 #ifdef CONFIG_RT_GROUP_SCHED
78756 /*
78757 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78758 index e8b3350..d83d44e 100644
78759 --- a/kernel/sched/core.c
78760 +++ b/kernel/sched/core.c
78761 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78762 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78763 * positive (at least 1, or number of jiffies left till timeout) if completed.
78764 */
78765 -long __sched
78766 +long __sched __intentional_overflow(-1)
78767 wait_for_completion_interruptible_timeout(struct completion *x,
78768 unsigned long timeout)
78769 {
78770 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78771 *
78772 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78773 */
78774 -int __sched wait_for_completion_killable(struct completion *x)
78775 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78776 {
78777 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78778 if (t == -ERESTARTSYS)
78779 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78780 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78781 * positive (at least 1, or number of jiffies left till timeout) if completed.
78782 */
78783 -long __sched
78784 +long __sched __intentional_overflow(-1)
78785 wait_for_completion_killable_timeout(struct completion *x,
78786 unsigned long timeout)
78787 {
78788 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
78789 /* convert nice value [19,-20] to rlimit style value [1,40] */
78790 int nice_rlim = 20 - nice;
78791
78792 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78793 +
78794 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78795 capable(CAP_SYS_NICE));
78796 }
78797 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78798 if (nice > 19)
78799 nice = 19;
78800
78801 - if (increment < 0 && !can_nice(current, nice))
78802 + if (increment < 0 && (!can_nice(current, nice) ||
78803 + gr_handle_chroot_nice()))
78804 return -EPERM;
78805
78806 retval = security_task_setnice(current, nice);
78807 @@ -3891,6 +3894,7 @@ recheck:
78808 unsigned long rlim_rtprio =
78809 task_rlimit(p, RLIMIT_RTPRIO);
78810
78811 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78812 /* can't set/change the rt policy */
78813 if (policy != p->policy && !rlim_rtprio)
78814 return -EPERM;
78815 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78816
78817 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78818
78819 -static struct ctl_table sd_ctl_dir[] = {
78820 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78821 {
78822 .procname = "sched_domain",
78823 .mode = 0555,
78824 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
78825 {}
78826 };
78827
78828 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78829 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78830 {
78831 - struct ctl_table *entry =
78832 + ctl_table_no_const *entry =
78833 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78834
78835 return entry;
78836 }
78837
78838 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78839 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78840 {
78841 - struct ctl_table *entry;
78842 + ctl_table_no_const *entry;
78843
78844 /*
78845 * In the intermediate directories, both the child directory and
78846 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78847 * will always be set. In the lowest directory the names are
78848 * static strings and all have proc handlers.
78849 */
78850 - for (entry = *tablep; entry->mode; entry++) {
78851 - if (entry->child)
78852 - sd_free_ctl_entry(&entry->child);
78853 + for (entry = tablep; entry->mode; entry++) {
78854 + if (entry->child) {
78855 + sd_free_ctl_entry(entry->child);
78856 + pax_open_kernel();
78857 + entry->child = NULL;
78858 + pax_close_kernel();
78859 + }
78860 if (entry->proc_handler == NULL)
78861 kfree(entry->procname);
78862 }
78863
78864 - kfree(*tablep);
78865 - *tablep = NULL;
78866 + kfree(tablep);
78867 }
78868
78869 static int min_load_idx = 0;
78870 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78871
78872 static void
78873 -set_table_entry(struct ctl_table *entry,
78874 +set_table_entry(ctl_table_no_const *entry,
78875 const char *procname, void *data, int maxlen,
78876 umode_t mode, proc_handler *proc_handler,
78877 bool load_idx)
78878 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
78879 static struct ctl_table *
78880 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78881 {
78882 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78883 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78884
78885 if (table == NULL)
78886 return NULL;
78887 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78888 return table;
78889 }
78890
78891 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78892 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78893 {
78894 - struct ctl_table *entry, *table;
78895 + ctl_table_no_const *entry, *table;
78896 struct sched_domain *sd;
78897 int domain_num = 0, i;
78898 char buf[32];
78899 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
78900 static void register_sched_domain_sysctl(void)
78901 {
78902 int i, cpu_num = num_possible_cpus();
78903 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78904 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78905 char buf[32];
78906
78907 WARN_ON(sd_ctl_dir[0].child);
78908 + pax_open_kernel();
78909 sd_ctl_dir[0].child = entry;
78910 + pax_close_kernel();
78911
78912 if (entry == NULL)
78913 return;
78914 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
78915 if (sd_sysctl_header)
78916 unregister_sysctl_table(sd_sysctl_header);
78917 sd_sysctl_header = NULL;
78918 - if (sd_ctl_dir[0].child)
78919 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78920 + if (sd_ctl_dir[0].child) {
78921 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78922 + pax_open_kernel();
78923 + sd_ctl_dir[0].child = NULL;
78924 + pax_close_kernel();
78925 + }
78926 }
78927 #else
78928 static void register_sched_domain_sysctl(void)
78929 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78930 * happens before everything else. This has to be lower priority than
78931 * the notifier in the perf_event subsystem, though.
78932 */
78933 -static struct notifier_block __cpuinitdata migration_notifier = {
78934 +static struct notifier_block migration_notifier = {
78935 .notifier_call = migration_call,
78936 .priority = CPU_PRI_MIGRATION,
78937 };
78938 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78939 index c61a614..d7f3d7e 100644
78940 --- a/kernel/sched/fair.c
78941 +++ b/kernel/sched/fair.c
78942 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78943
78944 static void reset_ptenuma_scan(struct task_struct *p)
78945 {
78946 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78947 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78948 p->mm->numa_scan_offset = 0;
78949 }
78950
78951 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78952 * run_rebalance_domains is triggered when needed from the scheduler tick.
78953 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78954 */
78955 -static void run_rebalance_domains(struct softirq_action *h)
78956 +static void run_rebalance_domains(void)
78957 {
78958 int this_cpu = smp_processor_id();
78959 struct rq *this_rq = cpu_rq(this_cpu);
78960 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
78961 index ce39224..0e09343 100644
78962 --- a/kernel/sched/sched.h
78963 +++ b/kernel/sched/sched.h
78964 @@ -1009,7 +1009,7 @@ struct sched_class {
78965 #ifdef CONFIG_FAIR_GROUP_SCHED
78966 void (*task_move_group) (struct task_struct *p, int on_rq);
78967 #endif
78968 -};
78969 +} __do_const;
78970
78971 #define sched_class_highest (&stop_sched_class)
78972 #define for_each_class(class) \
78973 diff --git a/kernel/signal.c b/kernel/signal.c
78974 index 113411b..17190e2 100644
78975 --- a/kernel/signal.c
78976 +++ b/kernel/signal.c
78977 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
78978
78979 int print_fatal_signals __read_mostly;
78980
78981 -static void __user *sig_handler(struct task_struct *t, int sig)
78982 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78983 {
78984 return t->sighand->action[sig - 1].sa.sa_handler;
78985 }
78986
78987 -static int sig_handler_ignored(void __user *handler, int sig)
78988 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78989 {
78990 /* Is it explicitly or implicitly ignored? */
78991 return handler == SIG_IGN ||
78992 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78993
78994 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78995 {
78996 - void __user *handler;
78997 + __sighandler_t handler;
78998
78999 handler = sig_handler(t, sig);
79000
79001 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
79002 atomic_inc(&user->sigpending);
79003 rcu_read_unlock();
79004
79005 + if (!override_rlimit)
79006 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
79007 +
79008 if (override_rlimit ||
79009 atomic_read(&user->sigpending) <=
79010 task_rlimit(t, RLIMIT_SIGPENDING)) {
79011 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
79012
79013 int unhandled_signal(struct task_struct *tsk, int sig)
79014 {
79015 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
79016 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
79017 if (is_global_init(tsk))
79018 return 1;
79019 if (handler != SIG_IGN && handler != SIG_DFL)
79020 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
79021 }
79022 }
79023
79024 + /* allow glibc communication via tgkill to other threads in our
79025 + thread group */
79026 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
79027 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
79028 + && gr_handle_signal(t, sig))
79029 + return -EPERM;
79030 +
79031 return security_task_kill(t, info, sig, 0);
79032 }
79033
79034 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79035 return send_signal(sig, info, p, 1);
79036 }
79037
79038 -static int
79039 +int
79040 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79041 {
79042 return send_signal(sig, info, t, 0);
79043 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79044 unsigned long int flags;
79045 int ret, blocked, ignored;
79046 struct k_sigaction *action;
79047 + int is_unhandled = 0;
79048
79049 spin_lock_irqsave(&t->sighand->siglock, flags);
79050 action = &t->sighand->action[sig-1];
79051 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79052 }
79053 if (action->sa.sa_handler == SIG_DFL)
79054 t->signal->flags &= ~SIGNAL_UNKILLABLE;
79055 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
79056 + is_unhandled = 1;
79057 ret = specific_send_sig_info(sig, info, t);
79058 spin_unlock_irqrestore(&t->sighand->siglock, flags);
79059
79060 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
79061 + normal operation */
79062 + if (is_unhandled) {
79063 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
79064 + gr_handle_crash(t, sig);
79065 + }
79066 +
79067 return ret;
79068 }
79069
79070 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79071 ret = check_kill_permission(sig, info, p);
79072 rcu_read_unlock();
79073
79074 - if (!ret && sig)
79075 + if (!ret && sig) {
79076 ret = do_send_sig_info(sig, info, p, true);
79077 + if (!ret)
79078 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
79079 + }
79080
79081 return ret;
79082 }
79083 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
79084 int error = -ESRCH;
79085
79086 rcu_read_lock();
79087 - p = find_task_by_vpid(pid);
79088 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79089 + /* allow glibc communication via tgkill to other threads in our
79090 + thread group */
79091 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
79092 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
79093 + p = find_task_by_vpid_unrestricted(pid);
79094 + else
79095 +#endif
79096 + p = find_task_by_vpid(pid);
79097 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
79098 error = check_kill_permission(sig, info, p);
79099 /*
79100 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
79101 }
79102 seg = get_fs();
79103 set_fs(KERNEL_DS);
79104 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
79105 - (stack_t __force __user *) &uoss,
79106 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
79107 + (stack_t __force_user *) &uoss,
79108 compat_user_stack_pointer());
79109 set_fs(seg);
79110 if (ret >= 0 && uoss_ptr) {
79111 diff --git a/kernel/smp.c b/kernel/smp.c
79112 index 4dba0f7..fe9f773 100644
79113 --- a/kernel/smp.c
79114 +++ b/kernel/smp.c
79115 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
79116 return NOTIFY_OK;
79117 }
79118
79119 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
79120 +static struct notifier_block hotplug_cfd_notifier = {
79121 .notifier_call = hotplug_cfd,
79122 };
79123
79124 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
79125 index 02fc5c9..e54c335 100644
79126 --- a/kernel/smpboot.c
79127 +++ b/kernel/smpboot.c
79128 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
79129 }
79130 smpboot_unpark_thread(plug_thread, cpu);
79131 }
79132 - list_add(&plug_thread->list, &hotplug_threads);
79133 + pax_list_add(&plug_thread->list, &hotplug_threads);
79134 out:
79135 mutex_unlock(&smpboot_threads_lock);
79136 return ret;
79137 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79138 {
79139 get_online_cpus();
79140 mutex_lock(&smpboot_threads_lock);
79141 - list_del(&plug_thread->list);
79142 + pax_list_del(&plug_thread->list);
79143 smpboot_destroy_threads(plug_thread);
79144 mutex_unlock(&smpboot_threads_lock);
79145 put_online_cpus();
79146 diff --git a/kernel/softirq.c b/kernel/softirq.c
79147 index 3d6833f..da6d93d 100644
79148 --- a/kernel/softirq.c
79149 +++ b/kernel/softirq.c
79150 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79151 EXPORT_SYMBOL(irq_stat);
79152 #endif
79153
79154 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79155 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79156
79157 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79158
79159 -char *softirq_to_name[NR_SOFTIRQS] = {
79160 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79161 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79162 "TASKLET", "SCHED", "HRTIMER", "RCU"
79163 };
79164 @@ -250,7 +250,7 @@ restart:
79165 kstat_incr_softirqs_this_cpu(vec_nr);
79166
79167 trace_softirq_entry(vec_nr);
79168 - h->action(h);
79169 + h->action();
79170 trace_softirq_exit(vec_nr);
79171 if (unlikely(prev_count != preempt_count())) {
79172 printk(KERN_ERR "huh, entered softirq %u %s %p"
79173 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79174 or_softirq_pending(1UL << nr);
79175 }
79176
79177 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79178 +void __init open_softirq(int nr, void (*action)(void))
79179 {
79180 softirq_vec[nr].action = action;
79181 }
79182 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79183
79184 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79185
79186 -static void tasklet_action(struct softirq_action *a)
79187 +static void tasklet_action(void)
79188 {
79189 struct tasklet_struct *list;
79190
79191 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
79192 }
79193 }
79194
79195 -static void tasklet_hi_action(struct softirq_action *a)
79196 +static void tasklet_hi_action(void)
79197 {
79198 struct tasklet_struct *list;
79199
79200 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79201 return NOTIFY_OK;
79202 }
79203
79204 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79205 +static struct notifier_block remote_softirq_cpu_notifier = {
79206 .notifier_call = remote_softirq_cpu_notify,
79207 };
79208
79209 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
79210 return NOTIFY_OK;
79211 }
79212
79213 -static struct notifier_block __cpuinitdata cpu_nfb = {
79214 +static struct notifier_block cpu_nfb = {
79215 .notifier_call = cpu_callback
79216 };
79217
79218 -static struct smp_hotplug_thread softirq_threads = {
79219 +static struct smp_hotplug_thread softirq_threads __read_only = {
79220 .store = &ksoftirqd,
79221 .thread_should_run = ksoftirqd_should_run,
79222 .thread_fn = run_ksoftirqd,
79223 diff --git a/kernel/srcu.c b/kernel/srcu.c
79224 index 01d5ccb..cdcbee6 100644
79225 --- a/kernel/srcu.c
79226 +++ b/kernel/srcu.c
79227 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
79228
79229 idx = ACCESS_ONCE(sp->completed) & 0x1;
79230 preempt_disable();
79231 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79232 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79233 smp_mb(); /* B */ /* Avoid leaking the critical section. */
79234 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79235 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79236 preempt_enable();
79237 return idx;
79238 }
79239 diff --git a/kernel/sys.c b/kernel/sys.c
79240 index 2bbd9a7..0875671 100644
79241 --- a/kernel/sys.c
79242 +++ b/kernel/sys.c
79243 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
79244 error = -EACCES;
79245 goto out;
79246 }
79247 +
79248 + if (gr_handle_chroot_setpriority(p, niceval)) {
79249 + error = -EACCES;
79250 + goto out;
79251 + }
79252 +
79253 no_nice = security_task_setnice(p, niceval);
79254 if (no_nice) {
79255 error = no_nice;
79256 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
79257 goto error;
79258 }
79259
79260 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
79261 + goto error;
79262 +
79263 if (rgid != (gid_t) -1 ||
79264 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
79265 new->sgid = new->egid;
79266 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
79267 old = current_cred();
79268
79269 retval = -EPERM;
79270 +
79271 + if (gr_check_group_change(kgid, kgid, kgid))
79272 + goto error;
79273 +
79274 if (nsown_capable(CAP_SETGID))
79275 new->gid = new->egid = new->sgid = new->fsgid = kgid;
79276 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
79277 @@ -678,7 +691,7 @@ error:
79278 /*
79279 * change the user struct in a credentials set to match the new UID
79280 */
79281 -static int set_user(struct cred *new)
79282 +int set_user(struct cred *new)
79283 {
79284 struct user_struct *new_user;
79285
79286 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
79287 goto error;
79288 }
79289
79290 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
79291 + goto error;
79292 +
79293 if (!uid_eq(new->uid, old->uid)) {
79294 retval = set_user(new);
79295 if (retval < 0)
79296 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
79297 old = current_cred();
79298
79299 retval = -EPERM;
79300 +
79301 + if (gr_check_crash_uid(kuid))
79302 + goto error;
79303 + if (gr_check_user_change(kuid, kuid, kuid))
79304 + goto error;
79305 +
79306 if (nsown_capable(CAP_SETUID)) {
79307 new->suid = new->uid = kuid;
79308 if (!uid_eq(kuid, old->uid)) {
79309 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
79310 goto error;
79311 }
79312
79313 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
79314 + goto error;
79315 +
79316 if (ruid != (uid_t) -1) {
79317 new->uid = kruid;
79318 if (!uid_eq(kruid, old->uid)) {
79319 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79320 goto error;
79321 }
79322
79323 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79324 + goto error;
79325 +
79326 if (rgid != (gid_t) -1)
79327 new->gid = krgid;
79328 if (egid != (gid_t) -1)
79329 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79330 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79331 nsown_capable(CAP_SETUID)) {
79332 if (!uid_eq(kuid, old->fsuid)) {
79333 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79334 + goto error;
79335 +
79336 new->fsuid = kuid;
79337 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79338 goto change_okay;
79339 }
79340 }
79341
79342 +error:
79343 abort_creds(new);
79344 return old_fsuid;
79345
79346 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79347 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79348 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79349 nsown_capable(CAP_SETGID)) {
79350 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79351 + goto error;
79352 +
79353 if (!gid_eq(kgid, old->fsgid)) {
79354 new->fsgid = kgid;
79355 goto change_okay;
79356 }
79357 }
79358
79359 +error:
79360 abort_creds(new);
79361 return old_fsgid;
79362
79363 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79364 return -EFAULT;
79365
79366 down_read(&uts_sem);
79367 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79368 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79369 __OLD_UTS_LEN);
79370 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79371 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79372 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79373 __OLD_UTS_LEN);
79374 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79375 - error |= __copy_to_user(&name->release, &utsname()->release,
79376 + error |= __copy_to_user(name->release, &utsname()->release,
79377 __OLD_UTS_LEN);
79378 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79379 - error |= __copy_to_user(&name->version, &utsname()->version,
79380 + error |= __copy_to_user(name->version, &utsname()->version,
79381 __OLD_UTS_LEN);
79382 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79383 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79384 + error |= __copy_to_user(name->machine, &utsname()->machine,
79385 __OLD_UTS_LEN);
79386 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79387 up_read(&uts_sem);
79388 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79389 */
79390 new_rlim->rlim_cur = 1;
79391 }
79392 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79393 + is changed to a lower value. Since tasks can be created by the same
79394 + user in between this limit change and an execve by this task, force
79395 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79396 + */
79397 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
79398 + tsk->flags |= PF_NPROC_EXCEEDED;
79399 }
79400 if (!retval) {
79401 if (old_rlim)
79402 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79403 index 9edcf45..713c960 100644
79404 --- a/kernel/sysctl.c
79405 +++ b/kernel/sysctl.c
79406 @@ -93,7 +93,6 @@
79407
79408
79409 #if defined(CONFIG_SYSCTL)
79410 -
79411 /* External variables not in a header file. */
79412 extern int sysctl_overcommit_memory;
79413 extern int sysctl_overcommit_ratio;
79414 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
79415
79416 /* Constants used for minimum and maximum */
79417 #ifdef CONFIG_LOCKUP_DETECTOR
79418 -static int sixty = 60;
79419 -static int neg_one = -1;
79420 +static int sixty __read_only = 60;
79421 #endif
79422
79423 -static int zero;
79424 -static int __maybe_unused one = 1;
79425 -static int __maybe_unused two = 2;
79426 -static int __maybe_unused three = 3;
79427 -static unsigned long one_ul = 1;
79428 -static int one_hundred = 100;
79429 +static int neg_one __read_only = -1;
79430 +static int zero __read_only = 0;
79431 +static int __maybe_unused one __read_only = 1;
79432 +static int __maybe_unused two __read_only = 2;
79433 +static int __maybe_unused three __read_only = 3;
79434 +static unsigned long one_ul __read_only = 1;
79435 +static int one_hundred __read_only = 100;
79436 #ifdef CONFIG_PRINTK
79437 -static int ten_thousand = 10000;
79438 +static int ten_thousand __read_only = 10000;
79439 #endif
79440
79441 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
79442 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
79443 void __user *buffer, size_t *lenp, loff_t *ppos);
79444 #endif
79445
79446 -#ifdef CONFIG_PRINTK
79447 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79448 void __user *buffer, size_t *lenp, loff_t *ppos);
79449 -#endif
79450
79451 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79452 void __user *buffer, size_t *lenp, loff_t *ppos);
79453 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79454
79455 #endif
79456
79457 +extern struct ctl_table grsecurity_table[];
79458 +
79459 static struct ctl_table kern_table[];
79460 static struct ctl_table vm_table[];
79461 static struct ctl_table fs_table[];
79462 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
79463 int sysctl_legacy_va_layout;
79464 #endif
79465
79466 +#ifdef CONFIG_PAX_SOFTMODE
79467 +static ctl_table pax_table[] = {
79468 + {
79469 + .procname = "softmode",
79470 + .data = &pax_softmode,
79471 + .maxlen = sizeof(unsigned int),
79472 + .mode = 0600,
79473 + .proc_handler = &proc_dointvec,
79474 + },
79475 +
79476 + { }
79477 +};
79478 +#endif
79479 +
79480 /* The default sysctl tables: */
79481
79482 static struct ctl_table sysctl_base_table[] = {
79483 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
79484 #endif
79485
79486 static struct ctl_table kern_table[] = {
79487 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79488 + {
79489 + .procname = "grsecurity",
79490 + .mode = 0500,
79491 + .child = grsecurity_table,
79492 + },
79493 +#endif
79494 +
79495 +#ifdef CONFIG_PAX_SOFTMODE
79496 + {
79497 + .procname = "pax",
79498 + .mode = 0500,
79499 + .child = pax_table,
79500 + },
79501 +#endif
79502 +
79503 {
79504 .procname = "sched_child_runs_first",
79505 .data = &sysctl_sched_child_runs_first,
79506 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
79507 .data = &modprobe_path,
79508 .maxlen = KMOD_PATH_LEN,
79509 .mode = 0644,
79510 - .proc_handler = proc_dostring,
79511 + .proc_handler = proc_dostring_modpriv,
79512 },
79513 {
79514 .procname = "modules_disabled",
79515 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
79516 .extra1 = &zero,
79517 .extra2 = &one,
79518 },
79519 +#endif
79520 {
79521 .procname = "kptr_restrict",
79522 .data = &kptr_restrict,
79523 .maxlen = sizeof(int),
79524 .mode = 0644,
79525 .proc_handler = proc_dointvec_minmax_sysadmin,
79526 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79527 + .extra1 = &two,
79528 +#else
79529 .extra1 = &zero,
79530 +#endif
79531 .extra2 = &two,
79532 },
79533 -#endif
79534 {
79535 .procname = "ngroups_max",
79536 .data = &ngroups_max,
79537 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
79538 */
79539 {
79540 .procname = "perf_event_paranoid",
79541 - .data = &sysctl_perf_event_paranoid,
79542 - .maxlen = sizeof(sysctl_perf_event_paranoid),
79543 + .data = &sysctl_perf_event_legitimately_concerned,
79544 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
79545 .mode = 0644,
79546 - .proc_handler = proc_dointvec,
79547 + /* go ahead, be a hero */
79548 + .proc_handler = proc_dointvec_minmax_sysadmin,
79549 + .extra1 = &neg_one,
79550 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79551 + .extra2 = &three,
79552 +#else
79553 + .extra2 = &two,
79554 +#endif
79555 },
79556 {
79557 .procname = "perf_event_mlock_kb",
79558 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
79559 .proc_handler = proc_dointvec_minmax,
79560 .extra1 = &zero,
79561 },
79562 + {
79563 + .procname = "heap_stack_gap",
79564 + .data = &sysctl_heap_stack_gap,
79565 + .maxlen = sizeof(sysctl_heap_stack_gap),
79566 + .mode = 0644,
79567 + .proc_handler = proc_doulongvec_minmax,
79568 + },
79569 #else
79570 {
79571 .procname = "nr_trim_pages",
79572 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
79573 buffer, lenp, ppos);
79574 }
79575
79576 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79577 + void __user *buffer, size_t *lenp, loff_t *ppos)
79578 +{
79579 + if (write && !capable(CAP_SYS_MODULE))
79580 + return -EPERM;
79581 +
79582 + return _proc_do_string(table->data, table->maxlen, write,
79583 + buffer, lenp, ppos);
79584 +}
79585 +
79586 static size_t proc_skip_spaces(char **buf)
79587 {
79588 size_t ret;
79589 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79590 len = strlen(tmp);
79591 if (len > *size)
79592 len = *size;
79593 + if (len > sizeof(tmp))
79594 + len = sizeof(tmp);
79595 if (copy_to_user(*buf, tmp, len))
79596 return -EFAULT;
79597 *size -= len;
79598 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79599 static int proc_taint(struct ctl_table *table, int write,
79600 void __user *buffer, size_t *lenp, loff_t *ppos)
79601 {
79602 - struct ctl_table t;
79603 + ctl_table_no_const t;
79604 unsigned long tmptaint = get_taint();
79605 int err;
79606
79607 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
79608 return err;
79609 }
79610
79611 -#ifdef CONFIG_PRINTK
79612 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79613 void __user *buffer, size_t *lenp, loff_t *ppos)
79614 {
79615 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79616
79617 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79618 }
79619 -#endif
79620
79621 struct do_proc_dointvec_minmax_conv_param {
79622 int *min;
79623 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79624 *i = val;
79625 } else {
79626 val = convdiv * (*i) / convmul;
79627 - if (!first)
79628 + if (!first) {
79629 err = proc_put_char(&buffer, &left, '\t');
79630 + if (err)
79631 + break;
79632 + }
79633 err = proc_put_long(&buffer, &left, val, false);
79634 if (err)
79635 break;
79636 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
79637 return -ENOSYS;
79638 }
79639
79640 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79641 + void __user *buffer, size_t *lenp, loff_t *ppos)
79642 +{
79643 + return -ENOSYS;
79644 +}
79645 +
79646 int proc_dointvec(struct ctl_table *table, int write,
79647 void __user *buffer, size_t *lenp, loff_t *ppos)
79648 {
79649 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79650 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79651 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79652 EXPORT_SYMBOL(proc_dostring);
79653 +EXPORT_SYMBOL(proc_dostring_modpriv);
79654 EXPORT_SYMBOL(proc_doulongvec_minmax);
79655 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79656 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79657 index 145bb4d..b2aa969 100644
79658 --- a/kernel/taskstats.c
79659 +++ b/kernel/taskstats.c
79660 @@ -28,9 +28,12 @@
79661 #include <linux/fs.h>
79662 #include <linux/file.h>
79663 #include <linux/pid_namespace.h>
79664 +#include <linux/grsecurity.h>
79665 #include <net/genetlink.h>
79666 #include <linux/atomic.h>
79667
79668 +extern int gr_is_taskstats_denied(int pid);
79669 +
79670 /*
79671 * Maximum length of a cpumask that can be specified in
79672 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79673 @@ -570,6 +573,9 @@ err:
79674
79675 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79676 {
79677 + if (gr_is_taskstats_denied(current->pid))
79678 + return -EACCES;
79679 +
79680 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79681 return cmd_attr_register_cpumask(info);
79682 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79683 diff --git a/kernel/time.c b/kernel/time.c
79684 index d3617db..c98bbe9 100644
79685 --- a/kernel/time.c
79686 +++ b/kernel/time.c
79687 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79688 return error;
79689
79690 if (tz) {
79691 + /* we log in do_settimeofday called below, so don't log twice
79692 + */
79693 + if (!tv)
79694 + gr_log_timechange();
79695 +
79696 sys_tz = *tz;
79697 update_vsyscall_tz();
79698 if (firsttime) {
79699 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79700 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79701 * value to a scaled second value.
79702 */
79703 -unsigned long
79704 +unsigned long __intentional_overflow(-1)
79705 timespec_to_jiffies(const struct timespec *value)
79706 {
79707 unsigned long sec = value->tv_sec;
79708 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79709 index f11d83b..d016d91 100644
79710 --- a/kernel/time/alarmtimer.c
79711 +++ b/kernel/time/alarmtimer.c
79712 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79713 struct platform_device *pdev;
79714 int error = 0;
79715 int i;
79716 - struct k_clock alarm_clock = {
79717 + static struct k_clock alarm_clock = {
79718 .clock_getres = alarm_clock_getres,
79719 .clock_get = alarm_clock_get,
79720 .timer_create = alarm_timer_create,
79721 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79722 index 20d6fba..09e103a 100644
79723 --- a/kernel/time/tick-broadcast.c
79724 +++ b/kernel/time/tick-broadcast.c
79725 @@ -147,7 +147,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79726 * then clear the broadcast bit.
79727 */
79728 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79729 - int cpu = smp_processor_id();
79730 + cpu = smp_processor_id();
79731 cpumask_clear_cpu(cpu, tick_broadcast_mask);
79732 tick_broadcast_clear_oneshot(cpu);
79733 } else {
79734 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79735 index baeeb5c..c22704a 100644
79736 --- a/kernel/time/timekeeping.c
79737 +++ b/kernel/time/timekeeping.c
79738 @@ -15,6 +15,7 @@
79739 #include <linux/init.h>
79740 #include <linux/mm.h>
79741 #include <linux/sched.h>
79742 +#include <linux/grsecurity.h>
79743 #include <linux/syscore_ops.h>
79744 #include <linux/clocksource.h>
79745 #include <linux/jiffies.h>
79746 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
79747 if (!timespec_valid_strict(tv))
79748 return -EINVAL;
79749
79750 + gr_log_timechange();
79751 +
79752 raw_spin_lock_irqsave(&timekeeper_lock, flags);
79753 write_seqcount_begin(&timekeeper_seq);
79754
79755 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79756 index 3bdf283..cc68d83 100644
79757 --- a/kernel/time/timer_list.c
79758 +++ b/kernel/time/timer_list.c
79759 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79760
79761 static void print_name_offset(struct seq_file *m, void *sym)
79762 {
79763 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79764 + SEQ_printf(m, "<%p>", NULL);
79765 +#else
79766 char symname[KSYM_NAME_LEN];
79767
79768 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79769 SEQ_printf(m, "<%pK>", sym);
79770 else
79771 SEQ_printf(m, "%s", symname);
79772 +#endif
79773 }
79774
79775 static void
79776 @@ -119,7 +123,11 @@ next_one:
79777 static void
79778 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79779 {
79780 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79781 + SEQ_printf(m, " .base: %p\n", NULL);
79782 +#else
79783 SEQ_printf(m, " .base: %pK\n", base);
79784 +#endif
79785 SEQ_printf(m, " .index: %d\n",
79786 base->index);
79787 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79788 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
79789 {
79790 struct proc_dir_entry *pe;
79791
79792 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79793 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79794 +#else
79795 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79796 +#endif
79797 if (!pe)
79798 return -ENOMEM;
79799 return 0;
79800 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79801 index 0b537f2..40d6c20 100644
79802 --- a/kernel/time/timer_stats.c
79803 +++ b/kernel/time/timer_stats.c
79804 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79805 static unsigned long nr_entries;
79806 static struct entry entries[MAX_ENTRIES];
79807
79808 -static atomic_t overflow_count;
79809 +static atomic_unchecked_t overflow_count;
79810
79811 /*
79812 * The entries are in a hash-table, for fast lookup:
79813 @@ -140,7 +140,7 @@ static void reset_entries(void)
79814 nr_entries = 0;
79815 memset(entries, 0, sizeof(entries));
79816 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79817 - atomic_set(&overflow_count, 0);
79818 + atomic_set_unchecked(&overflow_count, 0);
79819 }
79820
79821 static struct entry *alloc_entry(void)
79822 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79823 if (likely(entry))
79824 entry->count++;
79825 else
79826 - atomic_inc(&overflow_count);
79827 + atomic_inc_unchecked(&overflow_count);
79828
79829 out_unlock:
79830 raw_spin_unlock_irqrestore(lock, flags);
79831 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79832
79833 static void print_name_offset(struct seq_file *m, unsigned long addr)
79834 {
79835 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79836 + seq_printf(m, "<%p>", NULL);
79837 +#else
79838 char symname[KSYM_NAME_LEN];
79839
79840 if (lookup_symbol_name(addr, symname) < 0)
79841 - seq_printf(m, "<%p>", (void *)addr);
79842 + seq_printf(m, "<%pK>", (void *)addr);
79843 else
79844 seq_printf(m, "%s", symname);
79845 +#endif
79846 }
79847
79848 static int tstats_show(struct seq_file *m, void *v)
79849 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79850
79851 seq_puts(m, "Timer Stats Version: v0.2\n");
79852 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79853 - if (atomic_read(&overflow_count))
79854 + if (atomic_read_unchecked(&overflow_count))
79855 seq_printf(m, "Overflow: %d entries\n",
79856 - atomic_read(&overflow_count));
79857 + atomic_read_unchecked(&overflow_count));
79858
79859 for (i = 0; i < nr_entries; i++) {
79860 entry = entries + i;
79861 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79862 {
79863 struct proc_dir_entry *pe;
79864
79865 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79866 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79867 +#else
79868 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79869 +#endif
79870 if (!pe)
79871 return -ENOMEM;
79872 return 0;
79873 diff --git a/kernel/timer.c b/kernel/timer.c
79874 index 15ffdb3..62d885c 100644
79875 --- a/kernel/timer.c
79876 +++ b/kernel/timer.c
79877 @@ -1364,7 +1364,7 @@ void update_process_times(int user_tick)
79878 /*
79879 * This function runs timers and the timer-tq in bottom half context.
79880 */
79881 -static void run_timer_softirq(struct softirq_action *h)
79882 +static void run_timer_softirq(void)
79883 {
79884 struct tvec_base *base = __this_cpu_read(tvec_bases);
79885
79886 @@ -1427,7 +1427,7 @@ static void process_timeout(unsigned long __data)
79887 *
79888 * In all cases the return value is guaranteed to be non-negative.
79889 */
79890 -signed long __sched schedule_timeout(signed long timeout)
79891 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79892 {
79893 struct timer_list timer;
79894 unsigned long expire;
79895 @@ -1633,7 +1633,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79896 return NOTIFY_OK;
79897 }
79898
79899 -static struct notifier_block __cpuinitdata timers_nb = {
79900 +static struct notifier_block timers_nb = {
79901 .notifier_call = timer_cpu_notify,
79902 };
79903
79904 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79905 index b8b8560..75b1a09 100644
79906 --- a/kernel/trace/blktrace.c
79907 +++ b/kernel/trace/blktrace.c
79908 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79909 struct blk_trace *bt = filp->private_data;
79910 char buf[16];
79911
79912 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79913 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79914
79915 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79916 }
79917 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79918 return 1;
79919
79920 bt = buf->chan->private_data;
79921 - atomic_inc(&bt->dropped);
79922 + atomic_inc_unchecked(&bt->dropped);
79923 return 0;
79924 }
79925
79926 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79927
79928 bt->dir = dir;
79929 bt->dev = dev;
79930 - atomic_set(&bt->dropped, 0);
79931 + atomic_set_unchecked(&bt->dropped, 0);
79932
79933 ret = -EIO;
79934 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79935 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79936 index 6c508ff..ee55a13 100644
79937 --- a/kernel/trace/ftrace.c
79938 +++ b/kernel/trace/ftrace.c
79939 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79940 if (unlikely(ftrace_disabled))
79941 return 0;
79942
79943 + ret = ftrace_arch_code_modify_prepare();
79944 + FTRACE_WARN_ON(ret);
79945 + if (ret)
79946 + return 0;
79947 +
79948 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79949 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79950 if (ret) {
79951 ftrace_bug(ret, ip);
79952 - return 0;
79953 }
79954 - return 1;
79955 + return ret ? 0 : 1;
79956 }
79957
79958 /*
79959 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
79960 if (!count)
79961 return 0;
79962
79963 + pax_open_kernel();
79964 sort(start, count, sizeof(*start),
79965 ftrace_cmp_ips, ftrace_swap_ips);
79966 + pax_close_kernel();
79967
79968 start_pg = ftrace_allocate_pages(count);
79969 if (!start_pg)
79970 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79971 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79972
79973 static int ftrace_graph_active;
79974 -static struct notifier_block ftrace_suspend_notifier;
79975 -
79976 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79977 {
79978 return 0;
79979 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79980 return NOTIFY_DONE;
79981 }
79982
79983 +static struct notifier_block ftrace_suspend_notifier = {
79984 + .notifier_call = ftrace_suspend_notifier_call
79985 +};
79986 +
79987 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79988 trace_func_graph_ent_t entryfunc)
79989 {
79990 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79991 goto out;
79992 }
79993
79994 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79995 register_pm_notifier(&ftrace_suspend_notifier);
79996
79997 ftrace_graph_active++;
79998 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79999 index e444ff8..438b8f4 100644
80000 --- a/kernel/trace/ring_buffer.c
80001 +++ b/kernel/trace/ring_buffer.c
80002 @@ -352,9 +352,9 @@ struct buffer_data_page {
80003 */
80004 struct buffer_page {
80005 struct list_head list; /* list of buffer pages */
80006 - local_t write; /* index for next write */
80007 + local_unchecked_t write; /* index for next write */
80008 unsigned read; /* index for next read */
80009 - local_t entries; /* entries on this page */
80010 + local_unchecked_t entries; /* entries on this page */
80011 unsigned long real_end; /* real end of data */
80012 struct buffer_data_page *page; /* Actual data page */
80013 };
80014 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
80015 unsigned long last_overrun;
80016 local_t entries_bytes;
80017 local_t entries;
80018 - local_t overrun;
80019 - local_t commit_overrun;
80020 + local_unchecked_t overrun;
80021 + local_unchecked_t commit_overrun;
80022 local_t dropped_events;
80023 local_t committing;
80024 local_t commits;
80025 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80026 *
80027 * We add a counter to the write field to denote this.
80028 */
80029 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
80030 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
80031 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
80032 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
80033
80034 /*
80035 * Just make sure we have seen our old_write and synchronize
80036 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80037 * cmpxchg to only update if an interrupt did not already
80038 * do it for us. If the cmpxchg fails, we don't care.
80039 */
80040 - (void)local_cmpxchg(&next_page->write, old_write, val);
80041 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
80042 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
80043 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
80044
80045 /*
80046 * No need to worry about races with clearing out the commit.
80047 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
80048
80049 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
80050 {
80051 - return local_read(&bpage->entries) & RB_WRITE_MASK;
80052 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
80053 }
80054
80055 static inline unsigned long rb_page_write(struct buffer_page *bpage)
80056 {
80057 - return local_read(&bpage->write) & RB_WRITE_MASK;
80058 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
80059 }
80060
80061 static int
80062 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
80063 * bytes consumed in ring buffer from here.
80064 * Increment overrun to account for the lost events.
80065 */
80066 - local_add(page_entries, &cpu_buffer->overrun);
80067 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
80068 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80069 }
80070
80071 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
80072 * it is our responsibility to update
80073 * the counters.
80074 */
80075 - local_add(entries, &cpu_buffer->overrun);
80076 + local_add_unchecked(entries, &cpu_buffer->overrun);
80077 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80078
80079 /*
80080 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80081 if (tail == BUF_PAGE_SIZE)
80082 tail_page->real_end = 0;
80083
80084 - local_sub(length, &tail_page->write);
80085 + local_sub_unchecked(length, &tail_page->write);
80086 return;
80087 }
80088
80089 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80090 rb_event_set_padding(event);
80091
80092 /* Set the write back to the previous setting */
80093 - local_sub(length, &tail_page->write);
80094 + local_sub_unchecked(length, &tail_page->write);
80095 return;
80096 }
80097
80098 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80099
80100 /* Set write to end of buffer */
80101 length = (tail + length) - BUF_PAGE_SIZE;
80102 - local_sub(length, &tail_page->write);
80103 + local_sub_unchecked(length, &tail_page->write);
80104 }
80105
80106 /*
80107 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80108 * about it.
80109 */
80110 if (unlikely(next_page == commit_page)) {
80111 - local_inc(&cpu_buffer->commit_overrun);
80112 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80113 goto out_reset;
80114 }
80115
80116 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80117 cpu_buffer->tail_page) &&
80118 (cpu_buffer->commit_page ==
80119 cpu_buffer->reader_page))) {
80120 - local_inc(&cpu_buffer->commit_overrun);
80121 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80122 goto out_reset;
80123 }
80124 }
80125 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80126 length += RB_LEN_TIME_EXTEND;
80127
80128 tail_page = cpu_buffer->tail_page;
80129 - write = local_add_return(length, &tail_page->write);
80130 + write = local_add_return_unchecked(length, &tail_page->write);
80131
80132 /* set write to only the index of the write */
80133 write &= RB_WRITE_MASK;
80134 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80135 kmemcheck_annotate_bitfield(event, bitfield);
80136 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80137
80138 - local_inc(&tail_page->entries);
80139 + local_inc_unchecked(&tail_page->entries);
80140
80141 /*
80142 * If this is the first commit on the page, then update
80143 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80144
80145 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80146 unsigned long write_mask =
80147 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80148 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80149 unsigned long event_length = rb_event_length(event);
80150 /*
80151 * This is on the tail page. It is possible that
80152 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80153 */
80154 old_index += write_mask;
80155 new_index += write_mask;
80156 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80157 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80158 if (index == old_index) {
80159 /* update counters */
80160 local_sub(event_length, &cpu_buffer->entries_bytes);
80161 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80162
80163 /* Do the likely case first */
80164 if (likely(bpage->page == (void *)addr)) {
80165 - local_dec(&bpage->entries);
80166 + local_dec_unchecked(&bpage->entries);
80167 return;
80168 }
80169
80170 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80171 start = bpage;
80172 do {
80173 if (bpage->page == (void *)addr) {
80174 - local_dec(&bpage->entries);
80175 + local_dec_unchecked(&bpage->entries);
80176 return;
80177 }
80178 rb_inc_page(cpu_buffer, &bpage);
80179 @@ -3138,7 +3138,7 @@ static inline unsigned long
80180 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80181 {
80182 return local_read(&cpu_buffer->entries) -
80183 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80184 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80185 }
80186
80187 /**
80188 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80189 return 0;
80190
80191 cpu_buffer = buffer->buffers[cpu];
80192 - ret = local_read(&cpu_buffer->overrun);
80193 + ret = local_read_unchecked(&cpu_buffer->overrun);
80194
80195 return ret;
80196 }
80197 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80198 return 0;
80199
80200 cpu_buffer = buffer->buffers[cpu];
80201 - ret = local_read(&cpu_buffer->commit_overrun);
80202 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80203
80204 return ret;
80205 }
80206 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80207 /* if you care about this being correct, lock the buffer */
80208 for_each_buffer_cpu(buffer, cpu) {
80209 cpu_buffer = buffer->buffers[cpu];
80210 - overruns += local_read(&cpu_buffer->overrun);
80211 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80212 }
80213
80214 return overruns;
80215 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80216 /*
80217 * Reset the reader page to size zero.
80218 */
80219 - local_set(&cpu_buffer->reader_page->write, 0);
80220 - local_set(&cpu_buffer->reader_page->entries, 0);
80221 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80222 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80223 local_set(&cpu_buffer->reader_page->page->commit, 0);
80224 cpu_buffer->reader_page->real_end = 0;
80225
80226 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80227 * want to compare with the last_overrun.
80228 */
80229 smp_mb();
80230 - overwrite = local_read(&(cpu_buffer->overrun));
80231 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
80232
80233 /*
80234 * Here's the tricky part.
80235 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80236
80237 cpu_buffer->head_page
80238 = list_entry(cpu_buffer->pages, struct buffer_page, list);
80239 - local_set(&cpu_buffer->head_page->write, 0);
80240 - local_set(&cpu_buffer->head_page->entries, 0);
80241 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
80242 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
80243 local_set(&cpu_buffer->head_page->page->commit, 0);
80244
80245 cpu_buffer->head_page->read = 0;
80246 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80247
80248 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
80249 INIT_LIST_HEAD(&cpu_buffer->new_pages);
80250 - local_set(&cpu_buffer->reader_page->write, 0);
80251 - local_set(&cpu_buffer->reader_page->entries, 0);
80252 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80253 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80254 local_set(&cpu_buffer->reader_page->page->commit, 0);
80255 cpu_buffer->reader_page->read = 0;
80256
80257 local_set(&cpu_buffer->entries_bytes, 0);
80258 - local_set(&cpu_buffer->overrun, 0);
80259 - local_set(&cpu_buffer->commit_overrun, 0);
80260 + local_set_unchecked(&cpu_buffer->overrun, 0);
80261 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
80262 local_set(&cpu_buffer->dropped_events, 0);
80263 local_set(&cpu_buffer->entries, 0);
80264 local_set(&cpu_buffer->committing, 0);
80265 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
80266 rb_init_page(bpage);
80267 bpage = reader->page;
80268 reader->page = *data_page;
80269 - local_set(&reader->write, 0);
80270 - local_set(&reader->entries, 0);
80271 + local_set_unchecked(&reader->write, 0);
80272 + local_set_unchecked(&reader->entries, 0);
80273 reader->read = 0;
80274 *data_page = bpage;
80275
80276 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
80277 index e71a8be..948710a 100644
80278 --- a/kernel/trace/trace.c
80279 +++ b/kernel/trace/trace.c
80280 @@ -3201,7 +3201,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
80281 return 0;
80282 }
80283
80284 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
80285 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
80286 {
80287 /* do nothing if flag is already set */
80288 if (!!(trace_flags & mask) == !!enabled)
80289 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
80290 index 20572ed..fe55cf3 100644
80291 --- a/kernel/trace/trace.h
80292 +++ b/kernel/trace/trace.h
80293 @@ -1030,7 +1030,7 @@ extern const char *__stop___trace_bprintk_fmt[];
80294 void trace_printk_init_buffers(void);
80295 void trace_printk_start_comm(void);
80296 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
80297 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
80298 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
80299
80300 /*
80301 * Normal trace_printk() and friends allocates special buffers
80302 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80303 index 27963e2..5a6936f 100644
80304 --- a/kernel/trace/trace_events.c
80305 +++ b/kernel/trace/trace_events.c
80306 @@ -1637,10 +1637,6 @@ static LIST_HEAD(ftrace_module_file_list);
80307 struct ftrace_module_file_ops {
80308 struct list_head list;
80309 struct module *mod;
80310 - struct file_operations id;
80311 - struct file_operations enable;
80312 - struct file_operations format;
80313 - struct file_operations filter;
80314 };
80315
80316 static struct ftrace_module_file_ops *
80317 @@ -1681,17 +1677,12 @@ trace_create_file_ops(struct module *mod)
80318
80319 file_ops->mod = mod;
80320
80321 - file_ops->id = ftrace_event_id_fops;
80322 - file_ops->id.owner = mod;
80323 -
80324 - file_ops->enable = ftrace_enable_fops;
80325 - file_ops->enable.owner = mod;
80326 -
80327 - file_ops->filter = ftrace_event_filter_fops;
80328 - file_ops->filter.owner = mod;
80329 -
80330 - file_ops->format = ftrace_event_format_fops;
80331 - file_ops->format.owner = mod;
80332 + pax_open_kernel();
80333 + mod->trace_id.owner = mod;
80334 + mod->trace_enable.owner = mod;
80335 + mod->trace_filter.owner = mod;
80336 + mod->trace_format.owner = mod;
80337 + pax_close_kernel();
80338
80339 list_add(&file_ops->list, &ftrace_module_file_list);
80340
80341 @@ -1782,8 +1773,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
80342 struct ftrace_module_file_ops *file_ops)
80343 {
80344 return __trace_add_new_event(call, tr,
80345 - &file_ops->id, &file_ops->enable,
80346 - &file_ops->filter, &file_ops->format);
80347 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
80348 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
80349 }
80350
80351 #else
80352 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80353 index a5e8f48..a9690d2 100644
80354 --- a/kernel/trace/trace_mmiotrace.c
80355 +++ b/kernel/trace/trace_mmiotrace.c
80356 @@ -24,7 +24,7 @@ struct header_iter {
80357 static struct trace_array *mmio_trace_array;
80358 static bool overrun_detected;
80359 static unsigned long prev_overruns;
80360 -static atomic_t dropped_count;
80361 +static atomic_unchecked_t dropped_count;
80362
80363 static void mmio_reset_data(struct trace_array *tr)
80364 {
80365 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80366
80367 static unsigned long count_overruns(struct trace_iterator *iter)
80368 {
80369 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80370 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80371 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
80372
80373 if (over > prev_overruns)
80374 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80375 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80376 sizeof(*entry), 0, pc);
80377 if (!event) {
80378 - atomic_inc(&dropped_count);
80379 + atomic_inc_unchecked(&dropped_count);
80380 return;
80381 }
80382 entry = ring_buffer_event_data(event);
80383 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80384 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80385 sizeof(*entry), 0, pc);
80386 if (!event) {
80387 - atomic_inc(&dropped_count);
80388 + atomic_inc_unchecked(&dropped_count);
80389 return;
80390 }
80391 entry = ring_buffer_event_data(event);
80392 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80393 index bb922d9..2a54a257 100644
80394 --- a/kernel/trace/trace_output.c
80395 +++ b/kernel/trace/trace_output.c
80396 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80397
80398 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80399 if (!IS_ERR(p)) {
80400 - p = mangle_path(s->buffer + s->len, p, "\n");
80401 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80402 if (p) {
80403 s->len = p - s->buffer;
80404 return 1;
80405 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
80406 goto out;
80407 }
80408
80409 + pax_open_kernel();
80410 if (event->funcs->trace == NULL)
80411 - event->funcs->trace = trace_nop_print;
80412 + *(void **)&event->funcs->trace = trace_nop_print;
80413 if (event->funcs->raw == NULL)
80414 - event->funcs->raw = trace_nop_print;
80415 + *(void **)&event->funcs->raw = trace_nop_print;
80416 if (event->funcs->hex == NULL)
80417 - event->funcs->hex = trace_nop_print;
80418 + *(void **)&event->funcs->hex = trace_nop_print;
80419 if (event->funcs->binary == NULL)
80420 - event->funcs->binary = trace_nop_print;
80421 + *(void **)&event->funcs->binary = trace_nop_print;
80422 + pax_close_kernel();
80423
80424 key = event->type & (EVENT_HASHSIZE - 1);
80425
80426 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80427 index b20428c..4845a10 100644
80428 --- a/kernel/trace/trace_stack.c
80429 +++ b/kernel/trace/trace_stack.c
80430 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80431 return;
80432
80433 /* we do not handle interrupt stacks yet */
80434 - if (!object_is_on_stack(stack))
80435 + if (!object_starts_on_stack(stack))
80436 return;
80437
80438 local_irq_save(flags);
80439 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80440 index d8c30db..e065e89 100644
80441 --- a/kernel/user_namespace.c
80442 +++ b/kernel/user_namespace.c
80443 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80444 if (atomic_read(&current->mm->mm_users) > 1)
80445 return -EINVAL;
80446
80447 - if (current->fs->users != 1)
80448 + if (atomic_read(&current->fs->users) != 1)
80449 return -EINVAL;
80450
80451 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80452 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80453 index 4f69f9a..7c6f8f8 100644
80454 --- a/kernel/utsname_sysctl.c
80455 +++ b/kernel/utsname_sysctl.c
80456 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80457 static int proc_do_uts_string(ctl_table *table, int write,
80458 void __user *buffer, size_t *lenp, loff_t *ppos)
80459 {
80460 - struct ctl_table uts_table;
80461 + ctl_table_no_const uts_table;
80462 int r;
80463 memcpy(&uts_table, table, sizeof(uts_table));
80464 uts_table.data = get_uts(table, write);
80465 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80466 index 05039e3..17490c7 100644
80467 --- a/kernel/watchdog.c
80468 +++ b/kernel/watchdog.c
80469 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80470 }
80471 #endif /* CONFIG_SYSCTL */
80472
80473 -static struct smp_hotplug_thread watchdog_threads = {
80474 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80475 .store = &softlockup_watchdog,
80476 .thread_should_run = watchdog_should_run,
80477 .thread_fn = watchdog,
80478 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
80479 index ee8e29a..410568e 100644
80480 --- a/kernel/workqueue.c
80481 +++ b/kernel/workqueue.c
80482 @@ -4584,7 +4584,7 @@ static void rebind_workers(struct worker_pool *pool)
80483 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
80484 worker_flags |= WORKER_REBOUND;
80485 worker_flags &= ~WORKER_UNBOUND;
80486 - ACCESS_ONCE(worker->flags) = worker_flags;
80487 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
80488 }
80489
80490 spin_unlock_irq(&pool->lock);
80491 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80492 index 566cf2b..fdaa52c 100644
80493 --- a/lib/Kconfig.debug
80494 +++ b/lib/Kconfig.debug
80495 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
80496
80497 config DEBUG_LOCK_ALLOC
80498 bool "Lock debugging: detect incorrect freeing of live locks"
80499 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80500 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80501 select DEBUG_SPINLOCK
80502 select DEBUG_MUTEXES
80503 select LOCKDEP
80504 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
80505
80506 config PROVE_LOCKING
80507 bool "Lock debugging: prove locking correctness"
80508 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80509 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80510 select LOCKDEP
80511 select DEBUG_SPINLOCK
80512 select DEBUG_MUTEXES
80513 @@ -614,7 +614,7 @@ config LOCKDEP
80514
80515 config LOCK_STAT
80516 bool "Lock usage statistics"
80517 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80518 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80519 select LOCKDEP
80520 select DEBUG_SPINLOCK
80521 select DEBUG_MUTEXES
80522 @@ -1282,6 +1282,7 @@ config LATENCYTOP
80523 depends on DEBUG_KERNEL
80524 depends on STACKTRACE_SUPPORT
80525 depends on PROC_FS
80526 + depends on !GRKERNSEC_HIDESYM
80527 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80528 select KALLSYMS
80529 select KALLSYMS_ALL
80530 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80531 config DEBUG_STRICT_USER_COPY_CHECKS
80532 bool "Strict user copy size checks"
80533 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80534 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
80535 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
80536 help
80537 Enabling this option turns a certain set of sanity checks for user
80538 copy operations into compile time failures.
80539 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
80540
80541 config PROVIDE_OHCI1394_DMA_INIT
80542 bool "Remote debugging over FireWire early on boot"
80543 - depends on PCI && X86
80544 + depends on PCI && X86 && !GRKERNSEC
80545 help
80546 If you want to debug problems which hang or crash the kernel early
80547 on boot and the crashing machine has a FireWire port, you can use
80548 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80549
80550 config FIREWIRE_OHCI_REMOTE_DMA
80551 bool "Remote debugging over FireWire with firewire-ohci"
80552 - depends on FIREWIRE_OHCI
80553 + depends on FIREWIRE_OHCI && !GRKERNSEC
80554 help
80555 This option lets you use the FireWire bus for remote debugging
80556 with help of the firewire-ohci driver. It enables unfiltered
80557 diff --git a/lib/Makefile b/lib/Makefile
80558 index c55a037..fb46e3b 100644
80559 --- a/lib/Makefile
80560 +++ b/lib/Makefile
80561 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80562
80563 obj-$(CONFIG_BTREE) += btree.o
80564 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80565 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80566 +obj-y += list_debug.o
80567 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80568
80569 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80570 diff --git a/lib/bitmap.c b/lib/bitmap.c
80571 index 06f7e4f..f3cf2b0 100644
80572 --- a/lib/bitmap.c
80573 +++ b/lib/bitmap.c
80574 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80575 {
80576 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80577 u32 chunk;
80578 - const char __user __force *ubuf = (const char __user __force *)buf;
80579 + const char __user *ubuf = (const char __force_user *)buf;
80580
80581 bitmap_zero(maskp, nmaskbits);
80582
80583 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80584 {
80585 if (!access_ok(VERIFY_READ, ubuf, ulen))
80586 return -EFAULT;
80587 - return __bitmap_parse((const char __force *)ubuf,
80588 + return __bitmap_parse((const char __force_kernel *)ubuf,
80589 ulen, 1, maskp, nmaskbits);
80590
80591 }
80592 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80593 {
80594 unsigned a, b;
80595 int c, old_c, totaldigits;
80596 - const char __user __force *ubuf = (const char __user __force *)buf;
80597 + const char __user *ubuf = (const char __force_user *)buf;
80598 int exp_digit, in_range;
80599
80600 totaldigits = c = 0;
80601 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80602 {
80603 if (!access_ok(VERIFY_READ, ubuf, ulen))
80604 return -EFAULT;
80605 - return __bitmap_parselist((const char __force *)ubuf,
80606 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80607 ulen, 1, maskp, nmaskbits);
80608 }
80609 EXPORT_SYMBOL(bitmap_parselist_user);
80610 diff --git a/lib/bug.c b/lib/bug.c
80611 index 1686034..a9c00c8 100644
80612 --- a/lib/bug.c
80613 +++ b/lib/bug.c
80614 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80615 return BUG_TRAP_TYPE_NONE;
80616
80617 bug = find_bug(bugaddr);
80618 + if (!bug)
80619 + return BUG_TRAP_TYPE_NONE;
80620
80621 file = NULL;
80622 line = 0;
80623 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80624 index 37061ed..da83f48 100644
80625 --- a/lib/debugobjects.c
80626 +++ b/lib/debugobjects.c
80627 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80628 if (limit > 4)
80629 return;
80630
80631 - is_on_stack = object_is_on_stack(addr);
80632 + is_on_stack = object_starts_on_stack(addr);
80633 if (is_on_stack == onstack)
80634 return;
80635
80636 diff --git a/lib/devres.c b/lib/devres.c
80637 index 8235331..5881053 100644
80638 --- a/lib/devres.c
80639 +++ b/lib/devres.c
80640 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80641 void devm_iounmap(struct device *dev, void __iomem *addr)
80642 {
80643 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80644 - (void *)addr));
80645 + (void __force *)addr));
80646 iounmap(addr);
80647 }
80648 EXPORT_SYMBOL(devm_iounmap);
80649 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80650 {
80651 ioport_unmap(addr);
80652 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80653 - devm_ioport_map_match, (void *)addr));
80654 + devm_ioport_map_match, (void __force *)addr));
80655 }
80656 EXPORT_SYMBOL(devm_ioport_unmap);
80657 #endif /* CONFIG_HAS_IOPORT */
80658 diff --git a/lib/div64.c b/lib/div64.c
80659 index a163b6c..9618fa5 100644
80660 --- a/lib/div64.c
80661 +++ b/lib/div64.c
80662 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80663 EXPORT_SYMBOL(__div64_32);
80664
80665 #ifndef div_s64_rem
80666 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80667 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80668 {
80669 u64 quotient;
80670
80671 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80672 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80673 */
80674 #ifndef div64_u64
80675 -u64 div64_u64(u64 dividend, u64 divisor)
80676 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80677 {
80678 u32 high = divisor >> 32;
80679 u64 quot;
80680 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80681 index d87a17a..ac0d79a 100644
80682 --- a/lib/dma-debug.c
80683 +++ b/lib/dma-debug.c
80684 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80685
80686 void dma_debug_add_bus(struct bus_type *bus)
80687 {
80688 - struct notifier_block *nb;
80689 + notifier_block_no_const *nb;
80690
80691 if (global_disable)
80692 return;
80693 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80694
80695 static void check_for_stack(struct device *dev, void *addr)
80696 {
80697 - if (object_is_on_stack(addr))
80698 + if (object_starts_on_stack(addr))
80699 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80700 "stack [addr=%p]\n", addr);
80701 }
80702 diff --git a/lib/inflate.c b/lib/inflate.c
80703 index 013a761..c28f3fc 100644
80704 --- a/lib/inflate.c
80705 +++ b/lib/inflate.c
80706 @@ -269,7 +269,7 @@ static void free(void *where)
80707 malloc_ptr = free_mem_ptr;
80708 }
80709 #else
80710 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80711 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80712 #define free(a) kfree(a)
80713 #endif
80714
80715 diff --git a/lib/ioremap.c b/lib/ioremap.c
80716 index 0c9216c..863bd89 100644
80717 --- a/lib/ioremap.c
80718 +++ b/lib/ioremap.c
80719 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80720 unsigned long next;
80721
80722 phys_addr -= addr;
80723 - pmd = pmd_alloc(&init_mm, pud, addr);
80724 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80725 if (!pmd)
80726 return -ENOMEM;
80727 do {
80728 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80729 unsigned long next;
80730
80731 phys_addr -= addr;
80732 - pud = pud_alloc(&init_mm, pgd, addr);
80733 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80734 if (!pud)
80735 return -ENOMEM;
80736 do {
80737 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80738 index bd2bea9..6b3c95e 100644
80739 --- a/lib/is_single_threaded.c
80740 +++ b/lib/is_single_threaded.c
80741 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80742 struct task_struct *p, *t;
80743 bool ret;
80744
80745 + if (!mm)
80746 + return true;
80747 +
80748 if (atomic_read(&task->signal->live) != 1)
80749 return false;
80750
80751 diff --git a/lib/kobject.c b/lib/kobject.c
80752 index b7e29a6..2f3ca75 100644
80753 --- a/lib/kobject.c
80754 +++ b/lib/kobject.c
80755 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
80756 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
80757 if (!kset)
80758 return NULL;
80759 - retval = kobject_set_name(&kset->kobj, name);
80760 + retval = kobject_set_name(&kset->kobj, "%s", name);
80761 if (retval) {
80762 kfree(kset);
80763 return NULL;
80764 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80765
80766
80767 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80768 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80769 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80770
80771 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80772 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80773 {
80774 enum kobj_ns_type type = ops->type;
80775 int error;
80776 diff --git a/lib/list_debug.c b/lib/list_debug.c
80777 index c24c2f7..06e070b 100644
80778 --- a/lib/list_debug.c
80779 +++ b/lib/list_debug.c
80780 @@ -11,7 +11,9 @@
80781 #include <linux/bug.h>
80782 #include <linux/kernel.h>
80783 #include <linux/rculist.h>
80784 +#include <linux/mm.h>
80785
80786 +#ifdef CONFIG_DEBUG_LIST
80787 /*
80788 * Insert a new entry between two known consecutive entries.
80789 *
80790 @@ -19,21 +21,32 @@
80791 * the prev/next entries already!
80792 */
80793
80794 -void __list_add(struct list_head *new,
80795 - struct list_head *prev,
80796 - struct list_head *next)
80797 +static bool __list_add_debug(struct list_head *new,
80798 + struct list_head *prev,
80799 + struct list_head *next)
80800 {
80801 - WARN(next->prev != prev,
80802 + if (WARN(next->prev != prev,
80803 "list_add corruption. next->prev should be "
80804 "prev (%p), but was %p. (next=%p).\n",
80805 - prev, next->prev, next);
80806 - WARN(prev->next != next,
80807 + prev, next->prev, next) ||
80808 + WARN(prev->next != next,
80809 "list_add corruption. prev->next should be "
80810 "next (%p), but was %p. (prev=%p).\n",
80811 - next, prev->next, prev);
80812 - WARN(new == prev || new == next,
80813 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80814 - new, prev, next);
80815 + next, prev->next, prev) ||
80816 + WARN(new == prev || new == next,
80817 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80818 + new, prev, next))
80819 + return false;
80820 + return true;
80821 +}
80822 +
80823 +void __list_add(struct list_head *new,
80824 + struct list_head *prev,
80825 + struct list_head *next)
80826 +{
80827 + if (!__list_add_debug(new, prev, next))
80828 + return;
80829 +
80830 next->prev = new;
80831 new->next = next;
80832 new->prev = prev;
80833 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80834 }
80835 EXPORT_SYMBOL(__list_add);
80836
80837 -void __list_del_entry(struct list_head *entry)
80838 +static bool __list_del_entry_debug(struct list_head *entry)
80839 {
80840 struct list_head *prev, *next;
80841
80842 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80843 WARN(next->prev != entry,
80844 "list_del corruption. next->prev should be %p, "
80845 "but was %p\n", entry, next->prev))
80846 + return false;
80847 + return true;
80848 +}
80849 +
80850 +void __list_del_entry(struct list_head *entry)
80851 +{
80852 + if (!__list_del_entry_debug(entry))
80853 return;
80854
80855 - __list_del(prev, next);
80856 + __list_del(entry->prev, entry->next);
80857 }
80858 EXPORT_SYMBOL(__list_del_entry);
80859
80860 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80861 void __list_add_rcu(struct list_head *new,
80862 struct list_head *prev, struct list_head *next)
80863 {
80864 - WARN(next->prev != prev,
80865 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80866 - prev, next->prev, next);
80867 - WARN(prev->next != next,
80868 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80869 - next, prev->next, prev);
80870 + if (!__list_add_debug(new, prev, next))
80871 + return;
80872 +
80873 new->next = next;
80874 new->prev = prev;
80875 rcu_assign_pointer(list_next_rcu(prev), new);
80876 next->prev = new;
80877 }
80878 EXPORT_SYMBOL(__list_add_rcu);
80879 +#endif
80880 +
80881 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80882 +{
80883 +#ifdef CONFIG_DEBUG_LIST
80884 + if (!__list_add_debug(new, prev, next))
80885 + return;
80886 +#endif
80887 +
80888 + pax_open_kernel();
80889 + next->prev = new;
80890 + new->next = next;
80891 + new->prev = prev;
80892 + prev->next = new;
80893 + pax_close_kernel();
80894 +}
80895 +EXPORT_SYMBOL(__pax_list_add);
80896 +
80897 +void pax_list_del(struct list_head *entry)
80898 +{
80899 +#ifdef CONFIG_DEBUG_LIST
80900 + if (!__list_del_entry_debug(entry))
80901 + return;
80902 +#endif
80903 +
80904 + pax_open_kernel();
80905 + __list_del(entry->prev, entry->next);
80906 + entry->next = LIST_POISON1;
80907 + entry->prev = LIST_POISON2;
80908 + pax_close_kernel();
80909 +}
80910 +EXPORT_SYMBOL(pax_list_del);
80911 +
80912 +void pax_list_del_init(struct list_head *entry)
80913 +{
80914 + pax_open_kernel();
80915 + __list_del(entry->prev, entry->next);
80916 + INIT_LIST_HEAD(entry);
80917 + pax_close_kernel();
80918 +}
80919 +EXPORT_SYMBOL(pax_list_del_init);
80920 +
80921 +void __pax_list_add_rcu(struct list_head *new,
80922 + struct list_head *prev, struct list_head *next)
80923 +{
80924 +#ifdef CONFIG_DEBUG_LIST
80925 + if (!__list_add_debug(new, prev, next))
80926 + return;
80927 +#endif
80928 +
80929 + pax_open_kernel();
80930 + new->next = next;
80931 + new->prev = prev;
80932 + rcu_assign_pointer(list_next_rcu(prev), new);
80933 + next->prev = new;
80934 + pax_close_kernel();
80935 +}
80936 +EXPORT_SYMBOL(__pax_list_add_rcu);
80937 +
80938 +void pax_list_del_rcu(struct list_head *entry)
80939 +{
80940 +#ifdef CONFIG_DEBUG_LIST
80941 + if (!__list_del_entry_debug(entry))
80942 + return;
80943 +#endif
80944 +
80945 + pax_open_kernel();
80946 + __list_del(entry->prev, entry->next);
80947 + entry->next = LIST_POISON1;
80948 + entry->prev = LIST_POISON2;
80949 + pax_close_kernel();
80950 +}
80951 +EXPORT_SYMBOL(pax_list_del_rcu);
80952 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80953 index e796429..6e38f9f 100644
80954 --- a/lib/radix-tree.c
80955 +++ b/lib/radix-tree.c
80956 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80957 int nr;
80958 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80959 };
80960 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80961 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80962
80963 static inline void *ptr_to_indirect(void *ptr)
80964 {
80965 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80966 index bb2b201..46abaf9 100644
80967 --- a/lib/strncpy_from_user.c
80968 +++ b/lib/strncpy_from_user.c
80969 @@ -21,7 +21,7 @@
80970 */
80971 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80972 {
80973 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80974 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80975 long res = 0;
80976
80977 /*
80978 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80979 index a28df52..3d55877 100644
80980 --- a/lib/strnlen_user.c
80981 +++ b/lib/strnlen_user.c
80982 @@ -26,7 +26,7 @@
80983 */
80984 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80985 {
80986 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80987 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80988 long align, res = 0;
80989 unsigned long c;
80990
80991 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80992 index d23762e..e21eab2 100644
80993 --- a/lib/swiotlb.c
80994 +++ b/lib/swiotlb.c
80995 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80996
80997 void
80998 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80999 - dma_addr_t dev_addr)
81000 + dma_addr_t dev_addr, struct dma_attrs *attrs)
81001 {
81002 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
81003
81004 diff --git a/lib/usercopy.c b/lib/usercopy.c
81005 index 4f5b1dd..7cab418 100644
81006 --- a/lib/usercopy.c
81007 +++ b/lib/usercopy.c
81008 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
81009 WARN(1, "Buffer overflow detected!\n");
81010 }
81011 EXPORT_SYMBOL(copy_from_user_overflow);
81012 +
81013 +void copy_to_user_overflow(void)
81014 +{
81015 + WARN(1, "Buffer overflow detected!\n");
81016 +}
81017 +EXPORT_SYMBOL(copy_to_user_overflow);
81018 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81019 index e149c64..24aa71a 100644
81020 --- a/lib/vsprintf.c
81021 +++ b/lib/vsprintf.c
81022 @@ -16,6 +16,9 @@
81023 * - scnprintf and vscnprintf
81024 */
81025
81026 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81027 +#define __INCLUDED_BY_HIDESYM 1
81028 +#endif
81029 #include <stdarg.h>
81030 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
81031 #include <linux/types.h>
81032 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
81033 return number(buf, end, *(const netdev_features_t *)addr, spec);
81034 }
81035
81036 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81037 +int kptr_restrict __read_mostly = 2;
81038 +#else
81039 int kptr_restrict __read_mostly;
81040 +#endif
81041
81042 /*
81043 * Show a '%p' thing. A kernel extension is that the '%p' is followed
81044 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
81045 * - 'f' For simple symbolic function names without offset
81046 * - 'S' For symbolic direct pointers with offset
81047 * - 's' For symbolic direct pointers without offset
81048 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
81049 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
81050 * - 'B' For backtraced symbolic direct pointers with offset
81051 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
81052 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81053
81054 if (!ptr && *fmt != 'K') {
81055 /*
81056 - * Print (null) with the same width as a pointer so it makes
81057 + * Print (nil) with the same width as a pointer so it makes
81058 * tabular output look nice.
81059 */
81060 if (spec.field_width == -1)
81061 spec.field_width = default_width;
81062 - return string(buf, end, "(null)", spec);
81063 + return string(buf, end, "(nil)", spec);
81064 }
81065
81066 switch (*fmt) {
81067 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81068 /* Fallthrough */
81069 case 'S':
81070 case 's':
81071 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81072 + break;
81073 +#else
81074 + return symbol_string(buf, end, ptr, spec, fmt);
81075 +#endif
81076 + case 'A':
81077 case 'B':
81078 return symbol_string(buf, end, ptr, spec, fmt);
81079 case 'R':
81080 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81081 va_end(va);
81082 return buf;
81083 }
81084 + case 'P':
81085 + break;
81086 case 'K':
81087 /*
81088 * %pK cannot be used in IRQ context because its test
81089 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81090 return number(buf, end,
81091 (unsigned long long) *((phys_addr_t *)ptr), spec);
81092 }
81093 +
81094 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81095 + /* 'P' = approved pointers to copy to userland,
81096 + as in the /proc/kallsyms case, as we make it display nothing
81097 + for non-root users, and the real contents for root users
81098 + Also ignore 'K' pointers, since we force their NULLing for non-root users
81099 + above
81100 + */
81101 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
81102 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
81103 + dump_stack();
81104 + ptr = NULL;
81105 + }
81106 +#endif
81107 +
81108 spec.flags |= SMALL;
81109 if (spec.field_width == -1) {
81110 spec.field_width = default_width;
81111 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81112 typeof(type) value; \
81113 if (sizeof(type) == 8) { \
81114 args = PTR_ALIGN(args, sizeof(u32)); \
81115 - *(u32 *)&value = *(u32 *)args; \
81116 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
81117 + *(u32 *)&value = *(const u32 *)args; \
81118 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
81119 } else { \
81120 args = PTR_ALIGN(args, sizeof(type)); \
81121 - value = *(typeof(type) *)args; \
81122 + value = *(const typeof(type) *)args; \
81123 } \
81124 args += sizeof(type); \
81125 value; \
81126 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81127 case FORMAT_TYPE_STR: {
81128 const char *str_arg = args;
81129 args += strlen(str_arg) + 1;
81130 - str = string(str, end, (char *)str_arg, spec);
81131 + str = string(str, end, str_arg, spec);
81132 break;
81133 }
81134
81135 diff --git a/localversion-grsec b/localversion-grsec
81136 new file mode 100644
81137 index 0000000..7cd6065
81138 --- /dev/null
81139 +++ b/localversion-grsec
81140 @@ -0,0 +1 @@
81141 +-grsec
81142 diff --git a/mm/Kconfig b/mm/Kconfig
81143 index e742d06..c56fdd8 100644
81144 --- a/mm/Kconfig
81145 +++ b/mm/Kconfig
81146 @@ -317,10 +317,10 @@ config KSM
81147 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81148
81149 config DEFAULT_MMAP_MIN_ADDR
81150 - int "Low address space to protect from user allocation"
81151 + int "Low address space to protect from user allocation"
81152 depends on MMU
81153 - default 4096
81154 - help
81155 + default 65536
81156 + help
81157 This is the portion of low virtual memory which should be protected
81158 from userspace allocation. Keeping a user from writing to low pages
81159 can help reduce the impact of kernel NULL pointer bugs.
81160 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
81161
81162 config HWPOISON_INJECT
81163 tristate "HWPoison pages injector"
81164 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81165 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81166 select PROC_PAGE_MONITOR
81167
81168 config NOMMU_INITIAL_TRIM_EXCESS
81169 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
81170 index 5025174..9fc1c5c 100644
81171 --- a/mm/backing-dev.c
81172 +++ b/mm/backing-dev.c
81173 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
81174 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81175 unsigned int cap)
81176 {
81177 - char tmp[32];
81178 int err;
81179
81180 bdi->name = name;
81181 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81182 if (err)
81183 return err;
81184
81185 - sprintf(tmp, "%.28s%s", name, "-%d");
81186 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
81187 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
81188 if (err) {
81189 bdi_destroy(bdi);
81190 return err;
81191 diff --git a/mm/filemap.c b/mm/filemap.c
81192 index 7905fe7..e60faa8 100644
81193 --- a/mm/filemap.c
81194 +++ b/mm/filemap.c
81195 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81196 struct address_space *mapping = file->f_mapping;
81197
81198 if (!mapping->a_ops->readpage)
81199 - return -ENOEXEC;
81200 + return -ENODEV;
81201 file_accessed(file);
81202 vma->vm_ops = &generic_file_vm_ops;
81203 return 0;
81204 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81205 *pos = i_size_read(inode);
81206
81207 if (limit != RLIM_INFINITY) {
81208 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
81209 if (*pos >= limit) {
81210 send_sig(SIGXFSZ, current, 0);
81211 return -EFBIG;
81212 diff --git a/mm/fremap.c b/mm/fremap.c
81213 index 87da359..3f41cb1 100644
81214 --- a/mm/fremap.c
81215 +++ b/mm/fremap.c
81216 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
81217 retry:
81218 vma = find_vma(mm, start);
81219
81220 +#ifdef CONFIG_PAX_SEGMEXEC
81221 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
81222 + goto out;
81223 +#endif
81224 +
81225 /*
81226 * Make sure the vma is shared, that it supports prefaulting,
81227 * and that the remapped range is valid and fully within
81228 diff --git a/mm/highmem.c b/mm/highmem.c
81229 index b32b70c..e512eb0 100644
81230 --- a/mm/highmem.c
81231 +++ b/mm/highmem.c
81232 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
81233 * So no dangers, even with speculative execution.
81234 */
81235 page = pte_page(pkmap_page_table[i]);
81236 + pax_open_kernel();
81237 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
81238 -
81239 + pax_close_kernel();
81240 set_page_address(page, NULL);
81241 need_flush = 1;
81242 }
81243 @@ -198,9 +199,11 @@ start:
81244 }
81245 }
81246 vaddr = PKMAP_ADDR(last_pkmap_nr);
81247 +
81248 + pax_open_kernel();
81249 set_pte_at(&init_mm, vaddr,
81250 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
81251 -
81252 + pax_close_kernel();
81253 pkmap_count[last_pkmap_nr] = 1;
81254 set_page_address(page, (void *)vaddr);
81255
81256 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
81257 index 5cf99bf..28634c8 100644
81258 --- a/mm/hugetlb.c
81259 +++ b/mm/hugetlb.c
81260 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
81261 struct hstate *h = &default_hstate;
81262 unsigned long tmp;
81263 int ret;
81264 + ctl_table_no_const hugetlb_table;
81265
81266 tmp = h->max_huge_pages;
81267
81268 if (write && h->order >= MAX_ORDER)
81269 return -EINVAL;
81270
81271 - table->data = &tmp;
81272 - table->maxlen = sizeof(unsigned long);
81273 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81274 + hugetlb_table = *table;
81275 + hugetlb_table.data = &tmp;
81276 + hugetlb_table.maxlen = sizeof(unsigned long);
81277 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81278 if (ret)
81279 goto out;
81280
81281 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
81282 struct hstate *h = &default_hstate;
81283 unsigned long tmp;
81284 int ret;
81285 + ctl_table_no_const hugetlb_table;
81286
81287 tmp = h->nr_overcommit_huge_pages;
81288
81289 if (write && h->order >= MAX_ORDER)
81290 return -EINVAL;
81291
81292 - table->data = &tmp;
81293 - table->maxlen = sizeof(unsigned long);
81294 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81295 + hugetlb_table = *table;
81296 + hugetlb_table.data = &tmp;
81297 + hugetlb_table.maxlen = sizeof(unsigned long);
81298 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81299 if (ret)
81300 goto out;
81301
81302 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
81303 return 1;
81304 }
81305
81306 +#ifdef CONFIG_PAX_SEGMEXEC
81307 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
81308 +{
81309 + struct mm_struct *mm = vma->vm_mm;
81310 + struct vm_area_struct *vma_m;
81311 + unsigned long address_m;
81312 + pte_t *ptep_m;
81313 +
81314 + vma_m = pax_find_mirror_vma(vma);
81315 + if (!vma_m)
81316 + return;
81317 +
81318 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81319 + address_m = address + SEGMEXEC_TASK_SIZE;
81320 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
81321 + get_page(page_m);
81322 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81323 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81324 +}
81325 +#endif
81326 +
81327 /*
81328 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81329 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81330 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
81331 make_huge_pte(vma, new_page, 1));
81332 page_remove_rmap(old_page);
81333 hugepage_add_new_anon_rmap(new_page, vma, address);
81334 +
81335 +#ifdef CONFIG_PAX_SEGMEXEC
81336 + pax_mirror_huge_pte(vma, address, new_page);
81337 +#endif
81338 +
81339 /* Make the old page be freed below */
81340 new_page = old_page;
81341 }
81342 @@ -2821,6 +2851,10 @@ retry:
81343 && (vma->vm_flags & VM_SHARED)));
81344 set_huge_pte_at(mm, address, ptep, new_pte);
81345
81346 +#ifdef CONFIG_PAX_SEGMEXEC
81347 + pax_mirror_huge_pte(vma, address, page);
81348 +#endif
81349 +
81350 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81351 /* Optimization, do the COW without a second fault */
81352 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81353 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81354 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81355 struct hstate *h = hstate_vma(vma);
81356
81357 +#ifdef CONFIG_PAX_SEGMEXEC
81358 + struct vm_area_struct *vma_m;
81359 +#endif
81360 +
81361 address &= huge_page_mask(h);
81362
81363 ptep = huge_pte_offset(mm, address);
81364 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81365 VM_FAULT_SET_HINDEX(hstate_index(h));
81366 }
81367
81368 +#ifdef CONFIG_PAX_SEGMEXEC
81369 + vma_m = pax_find_mirror_vma(vma);
81370 + if (vma_m) {
81371 + unsigned long address_m;
81372 +
81373 + if (vma->vm_start > vma_m->vm_start) {
81374 + address_m = address;
81375 + address -= SEGMEXEC_TASK_SIZE;
81376 + vma = vma_m;
81377 + h = hstate_vma(vma);
81378 + } else
81379 + address_m = address + SEGMEXEC_TASK_SIZE;
81380 +
81381 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81382 + return VM_FAULT_OOM;
81383 + address_m &= HPAGE_MASK;
81384 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81385 + }
81386 +#endif
81387 +
81388 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81389 if (!ptep)
81390 return VM_FAULT_OOM;
81391 diff --git a/mm/internal.h b/mm/internal.h
81392 index 8562de0..7fdfe92 100644
81393 --- a/mm/internal.h
81394 +++ b/mm/internal.h
81395 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81396 * in mm/page_alloc.c
81397 */
81398 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81399 +extern void free_compound_page(struct page *page);
81400 extern void prep_compound_page(struct page *page, unsigned long order);
81401 #ifdef CONFIG_MEMORY_FAILURE
81402 extern bool is_free_buddy_page(struct page *page);
81403 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81404 index c8d7f31..2dbeffd 100644
81405 --- a/mm/kmemleak.c
81406 +++ b/mm/kmemleak.c
81407 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81408
81409 for (i = 0; i < object->trace_len; i++) {
81410 void *ptr = (void *)object->trace[i];
81411 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81412 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81413 }
81414 }
81415
81416 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
81417 return -ENOMEM;
81418 }
81419
81420 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81421 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81422 &kmemleak_fops);
81423 if (!dentry)
81424 pr_warning("Failed to create the debugfs kmemleak file\n");
81425 diff --git a/mm/maccess.c b/mm/maccess.c
81426 index d53adf9..03a24bf 100644
81427 --- a/mm/maccess.c
81428 +++ b/mm/maccess.c
81429 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81430 set_fs(KERNEL_DS);
81431 pagefault_disable();
81432 ret = __copy_from_user_inatomic(dst,
81433 - (__force const void __user *)src, size);
81434 + (const void __force_user *)src, size);
81435 pagefault_enable();
81436 set_fs(old_fs);
81437
81438 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81439
81440 set_fs(KERNEL_DS);
81441 pagefault_disable();
81442 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81443 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81444 pagefault_enable();
81445 set_fs(old_fs);
81446
81447 diff --git a/mm/madvise.c b/mm/madvise.c
81448 index 7055883..aafb1ed 100644
81449 --- a/mm/madvise.c
81450 +++ b/mm/madvise.c
81451 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81452 pgoff_t pgoff;
81453 unsigned long new_flags = vma->vm_flags;
81454
81455 +#ifdef CONFIG_PAX_SEGMEXEC
81456 + struct vm_area_struct *vma_m;
81457 +#endif
81458 +
81459 switch (behavior) {
81460 case MADV_NORMAL:
81461 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81462 @@ -126,6 +130,13 @@ success:
81463 /*
81464 * vm_flags is protected by the mmap_sem held in write mode.
81465 */
81466 +
81467 +#ifdef CONFIG_PAX_SEGMEXEC
81468 + vma_m = pax_find_mirror_vma(vma);
81469 + if (vma_m)
81470 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81471 +#endif
81472 +
81473 vma->vm_flags = new_flags;
81474
81475 out:
81476 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81477 struct vm_area_struct ** prev,
81478 unsigned long start, unsigned long end)
81479 {
81480 +
81481 +#ifdef CONFIG_PAX_SEGMEXEC
81482 + struct vm_area_struct *vma_m;
81483 +#endif
81484 +
81485 *prev = vma;
81486 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81487 return -EINVAL;
81488 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81489 zap_page_range(vma, start, end - start, &details);
81490 } else
81491 zap_page_range(vma, start, end - start, NULL);
81492 +
81493 +#ifdef CONFIG_PAX_SEGMEXEC
81494 + vma_m = pax_find_mirror_vma(vma);
81495 + if (vma_m) {
81496 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81497 + struct zap_details details = {
81498 + .nonlinear_vma = vma_m,
81499 + .last_index = ULONG_MAX,
81500 + };
81501 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81502 + } else
81503 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81504 + }
81505 +#endif
81506 +
81507 return 0;
81508 }
81509
81510 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81511 if (end < start)
81512 return error;
81513
81514 +#ifdef CONFIG_PAX_SEGMEXEC
81515 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81516 + if (end > SEGMEXEC_TASK_SIZE)
81517 + return error;
81518 + } else
81519 +#endif
81520 +
81521 + if (end > TASK_SIZE)
81522 + return error;
81523 +
81524 error = 0;
81525 if (end == start)
81526 return error;
81527 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
81528 index fd79df5..15b0409 100644
81529 --- a/mm/memcontrol.c
81530 +++ b/mm/memcontrol.c
81531 @@ -6296,14 +6296,6 @@ mem_cgroup_css_online(struct cgroup *cont)
81532
81533 error = memcg_init_kmem(memcg, &mem_cgroup_subsys);
81534 mutex_unlock(&memcg_create_mutex);
81535 - if (error) {
81536 - /*
81537 - * We call put now because our (and parent's) refcnts
81538 - * are already in place. mem_cgroup_put() will internally
81539 - * call __mem_cgroup_free, so return directly
81540 - */
81541 - mem_cgroup_put(memcg);
81542 - }
81543 return error;
81544 }
81545
81546 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81547 index ceb0c7f..b2b8e94 100644
81548 --- a/mm/memory-failure.c
81549 +++ b/mm/memory-failure.c
81550 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81551
81552 int sysctl_memory_failure_recovery __read_mostly = 1;
81553
81554 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81555 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81556
81557 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81558
81559 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81560 pfn, t->comm, t->pid);
81561 si.si_signo = SIGBUS;
81562 si.si_errno = 0;
81563 - si.si_addr = (void *)addr;
81564 + si.si_addr = (void __user *)addr;
81565 #ifdef __ARCH_SI_TRAPNO
81566 si.si_trapno = trapno;
81567 #endif
81568 @@ -760,7 +760,7 @@ static struct page_state {
81569 unsigned long res;
81570 char *msg;
81571 int (*action)(struct page *p, unsigned long pfn);
81572 -} error_states[] = {
81573 +} __do_const error_states[] = {
81574 { reserved, reserved, "reserved kernel", me_kernel },
81575 /*
81576 * free pages are specially detected outside this table:
81577 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81578 nr_pages = 1 << compound_order(hpage);
81579 else /* normal page or thp */
81580 nr_pages = 1;
81581 - atomic_long_add(nr_pages, &num_poisoned_pages);
81582 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
81583
81584 /*
81585 * We need/can do nothing about count=0 pages.
81586 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81587 if (!PageHWPoison(hpage)
81588 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81589 || (p != hpage && TestSetPageHWPoison(hpage))) {
81590 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81591 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81592 return 0;
81593 }
81594 set_page_hwpoison_huge_page(hpage);
81595 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81596 }
81597 if (hwpoison_filter(p)) {
81598 if (TestClearPageHWPoison(p))
81599 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81600 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81601 unlock_page(hpage);
81602 put_page(hpage);
81603 return 0;
81604 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
81605 return 0;
81606 }
81607 if (TestClearPageHWPoison(p))
81608 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81609 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81610 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81611 return 0;
81612 }
81613 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81614 */
81615 if (TestClearPageHWPoison(page)) {
81616 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81617 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81618 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81619 freeit = 1;
81620 if (PageHuge(page))
81621 clear_page_hwpoison_huge_page(page);
81622 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81623 } else {
81624 set_page_hwpoison_huge_page(hpage);
81625 dequeue_hwpoisoned_huge_page(hpage);
81626 - atomic_long_add(1 << compound_trans_order(hpage),
81627 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81628 &num_poisoned_pages);
81629 }
81630 /* keep elevated page count for bad page */
81631 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81632 if (PageHuge(page)) {
81633 set_page_hwpoison_huge_page(hpage);
81634 dequeue_hwpoisoned_huge_page(hpage);
81635 - atomic_long_add(1 << compound_trans_order(hpage),
81636 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81637 &num_poisoned_pages);
81638 } else {
81639 SetPageHWPoison(page);
81640 - atomic_long_inc(&num_poisoned_pages);
81641 + atomic_long_inc_unchecked(&num_poisoned_pages);
81642 }
81643 }
81644 /* keep elevated page count for bad page */
81645 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81646 put_page(page);
81647 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81648 SetPageHWPoison(page);
81649 - atomic_long_inc(&num_poisoned_pages);
81650 + atomic_long_inc_unchecked(&num_poisoned_pages);
81651 return 0;
81652 }
81653
81654 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81655 ret = -EIO;
81656 } else {
81657 SetPageHWPoison(page);
81658 - atomic_long_inc(&num_poisoned_pages);
81659 + atomic_long_inc_unchecked(&num_poisoned_pages);
81660 }
81661 } else {
81662 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81663 diff --git a/mm/memory.c b/mm/memory.c
81664 index 61a262b..77a94d1 100644
81665 --- a/mm/memory.c
81666 +++ b/mm/memory.c
81667 @@ -429,6 +429,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81668 free_pte_range(tlb, pmd, addr);
81669 } while (pmd++, addr = next, addr != end);
81670
81671 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81672 start &= PUD_MASK;
81673 if (start < floor)
81674 return;
81675 @@ -443,6 +444,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81676 pmd = pmd_offset(pud, start);
81677 pud_clear(pud);
81678 pmd_free_tlb(tlb, pmd, start);
81679 +#endif
81680 +
81681 }
81682
81683 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81684 @@ -462,6 +465,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81685 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81686 } while (pud++, addr = next, addr != end);
81687
81688 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81689 start &= PGDIR_MASK;
81690 if (start < floor)
81691 return;
81692 @@ -476,6 +480,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81693 pud = pud_offset(pgd, start);
81694 pgd_clear(pgd);
81695 pud_free_tlb(tlb, pud, start);
81696 +#endif
81697 +
81698 }
81699
81700 /*
81701 @@ -1635,12 +1641,6 @@ no_page_table:
81702 return page;
81703 }
81704
81705 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81706 -{
81707 - return stack_guard_page_start(vma, addr) ||
81708 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81709 -}
81710 -
81711 /**
81712 * __get_user_pages() - pin user pages in memory
81713 * @tsk: task_struct of target task
81714 @@ -1727,10 +1727,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81715
81716 i = 0;
81717
81718 - do {
81719 + while (nr_pages) {
81720 struct vm_area_struct *vma;
81721
81722 - vma = find_extend_vma(mm, start);
81723 + vma = find_vma(mm, start);
81724 if (!vma && in_gate_area(mm, start)) {
81725 unsigned long pg = start & PAGE_MASK;
81726 pgd_t *pgd;
81727 @@ -1779,7 +1779,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81728 goto next_page;
81729 }
81730
81731 - if (!vma ||
81732 + if (!vma || start < vma->vm_start ||
81733 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81734 !(vm_flags & vma->vm_flags))
81735 return i ? : -EFAULT;
81736 @@ -1808,11 +1808,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81737 int ret;
81738 unsigned int fault_flags = 0;
81739
81740 - /* For mlock, just skip the stack guard page. */
81741 - if (foll_flags & FOLL_MLOCK) {
81742 - if (stack_guard_page(vma, start))
81743 - goto next_page;
81744 - }
81745 if (foll_flags & FOLL_WRITE)
81746 fault_flags |= FAULT_FLAG_WRITE;
81747 if (nonblocking)
81748 @@ -1892,7 +1887,7 @@ next_page:
81749 start += page_increm * PAGE_SIZE;
81750 nr_pages -= page_increm;
81751 } while (nr_pages && start < vma->vm_end);
81752 - } while (nr_pages);
81753 + }
81754 return i;
81755 }
81756 EXPORT_SYMBOL(__get_user_pages);
81757 @@ -2099,6 +2094,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81758 page_add_file_rmap(page);
81759 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81760
81761 +#ifdef CONFIG_PAX_SEGMEXEC
81762 + pax_mirror_file_pte(vma, addr, page, ptl);
81763 +#endif
81764 +
81765 retval = 0;
81766 pte_unmap_unlock(pte, ptl);
81767 return retval;
81768 @@ -2143,9 +2142,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81769 if (!page_count(page))
81770 return -EINVAL;
81771 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81772 +
81773 +#ifdef CONFIG_PAX_SEGMEXEC
81774 + struct vm_area_struct *vma_m;
81775 +#endif
81776 +
81777 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81778 BUG_ON(vma->vm_flags & VM_PFNMAP);
81779 vma->vm_flags |= VM_MIXEDMAP;
81780 +
81781 +#ifdef CONFIG_PAX_SEGMEXEC
81782 + vma_m = pax_find_mirror_vma(vma);
81783 + if (vma_m)
81784 + vma_m->vm_flags |= VM_MIXEDMAP;
81785 +#endif
81786 +
81787 }
81788 return insert_page(vma, addr, page, vma->vm_page_prot);
81789 }
81790 @@ -2228,6 +2239,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81791 unsigned long pfn)
81792 {
81793 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81794 + BUG_ON(vma->vm_mirror);
81795
81796 if (addr < vma->vm_start || addr >= vma->vm_end)
81797 return -EFAULT;
81798 @@ -2475,7 +2487,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81799
81800 BUG_ON(pud_huge(*pud));
81801
81802 - pmd = pmd_alloc(mm, pud, addr);
81803 + pmd = (mm == &init_mm) ?
81804 + pmd_alloc_kernel(mm, pud, addr) :
81805 + pmd_alloc(mm, pud, addr);
81806 if (!pmd)
81807 return -ENOMEM;
81808 do {
81809 @@ -2495,7 +2509,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81810 unsigned long next;
81811 int err;
81812
81813 - pud = pud_alloc(mm, pgd, addr);
81814 + pud = (mm == &init_mm) ?
81815 + pud_alloc_kernel(mm, pgd, addr) :
81816 + pud_alloc(mm, pgd, addr);
81817 if (!pud)
81818 return -ENOMEM;
81819 do {
81820 @@ -2583,6 +2599,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81821 copy_user_highpage(dst, src, va, vma);
81822 }
81823
81824 +#ifdef CONFIG_PAX_SEGMEXEC
81825 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81826 +{
81827 + struct mm_struct *mm = vma->vm_mm;
81828 + spinlock_t *ptl;
81829 + pte_t *pte, entry;
81830 +
81831 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81832 + entry = *pte;
81833 + if (!pte_present(entry)) {
81834 + if (!pte_none(entry)) {
81835 + BUG_ON(pte_file(entry));
81836 + free_swap_and_cache(pte_to_swp_entry(entry));
81837 + pte_clear_not_present_full(mm, address, pte, 0);
81838 + }
81839 + } else {
81840 + struct page *page;
81841 +
81842 + flush_cache_page(vma, address, pte_pfn(entry));
81843 + entry = ptep_clear_flush(vma, address, pte);
81844 + BUG_ON(pte_dirty(entry));
81845 + page = vm_normal_page(vma, address, entry);
81846 + if (page) {
81847 + update_hiwater_rss(mm);
81848 + if (PageAnon(page))
81849 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81850 + else
81851 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81852 + page_remove_rmap(page);
81853 + page_cache_release(page);
81854 + }
81855 + }
81856 + pte_unmap_unlock(pte, ptl);
81857 +}
81858 +
81859 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81860 + *
81861 + * the ptl of the lower mapped page is held on entry and is not released on exit
81862 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81863 + */
81864 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81865 +{
81866 + struct mm_struct *mm = vma->vm_mm;
81867 + unsigned long address_m;
81868 + spinlock_t *ptl_m;
81869 + struct vm_area_struct *vma_m;
81870 + pmd_t *pmd_m;
81871 + pte_t *pte_m, entry_m;
81872 +
81873 + BUG_ON(!page_m || !PageAnon(page_m));
81874 +
81875 + vma_m = pax_find_mirror_vma(vma);
81876 + if (!vma_m)
81877 + return;
81878 +
81879 + BUG_ON(!PageLocked(page_m));
81880 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81881 + address_m = address + SEGMEXEC_TASK_SIZE;
81882 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81883 + pte_m = pte_offset_map(pmd_m, address_m);
81884 + ptl_m = pte_lockptr(mm, pmd_m);
81885 + if (ptl != ptl_m) {
81886 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81887 + if (!pte_none(*pte_m))
81888 + goto out;
81889 + }
81890 +
81891 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81892 + page_cache_get(page_m);
81893 + page_add_anon_rmap(page_m, vma_m, address_m);
81894 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81895 + set_pte_at(mm, address_m, pte_m, entry_m);
81896 + update_mmu_cache(vma_m, address_m, pte_m);
81897 +out:
81898 + if (ptl != ptl_m)
81899 + spin_unlock(ptl_m);
81900 + pte_unmap(pte_m);
81901 + unlock_page(page_m);
81902 +}
81903 +
81904 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81905 +{
81906 + struct mm_struct *mm = vma->vm_mm;
81907 + unsigned long address_m;
81908 + spinlock_t *ptl_m;
81909 + struct vm_area_struct *vma_m;
81910 + pmd_t *pmd_m;
81911 + pte_t *pte_m, entry_m;
81912 +
81913 + BUG_ON(!page_m || PageAnon(page_m));
81914 +
81915 + vma_m = pax_find_mirror_vma(vma);
81916 + if (!vma_m)
81917 + return;
81918 +
81919 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81920 + address_m = address + SEGMEXEC_TASK_SIZE;
81921 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81922 + pte_m = pte_offset_map(pmd_m, address_m);
81923 + ptl_m = pte_lockptr(mm, pmd_m);
81924 + if (ptl != ptl_m) {
81925 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81926 + if (!pte_none(*pte_m))
81927 + goto out;
81928 + }
81929 +
81930 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81931 + page_cache_get(page_m);
81932 + page_add_file_rmap(page_m);
81933 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81934 + set_pte_at(mm, address_m, pte_m, entry_m);
81935 + update_mmu_cache(vma_m, address_m, pte_m);
81936 +out:
81937 + if (ptl != ptl_m)
81938 + spin_unlock(ptl_m);
81939 + pte_unmap(pte_m);
81940 +}
81941 +
81942 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81943 +{
81944 + struct mm_struct *mm = vma->vm_mm;
81945 + unsigned long address_m;
81946 + spinlock_t *ptl_m;
81947 + struct vm_area_struct *vma_m;
81948 + pmd_t *pmd_m;
81949 + pte_t *pte_m, entry_m;
81950 +
81951 + vma_m = pax_find_mirror_vma(vma);
81952 + if (!vma_m)
81953 + return;
81954 +
81955 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81956 + address_m = address + SEGMEXEC_TASK_SIZE;
81957 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81958 + pte_m = pte_offset_map(pmd_m, address_m);
81959 + ptl_m = pte_lockptr(mm, pmd_m);
81960 + if (ptl != ptl_m) {
81961 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81962 + if (!pte_none(*pte_m))
81963 + goto out;
81964 + }
81965 +
81966 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81967 + set_pte_at(mm, address_m, pte_m, entry_m);
81968 +out:
81969 + if (ptl != ptl_m)
81970 + spin_unlock(ptl_m);
81971 + pte_unmap(pte_m);
81972 +}
81973 +
81974 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81975 +{
81976 + struct page *page_m;
81977 + pte_t entry;
81978 +
81979 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81980 + goto out;
81981 +
81982 + entry = *pte;
81983 + page_m = vm_normal_page(vma, address, entry);
81984 + if (!page_m)
81985 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81986 + else if (PageAnon(page_m)) {
81987 + if (pax_find_mirror_vma(vma)) {
81988 + pte_unmap_unlock(pte, ptl);
81989 + lock_page(page_m);
81990 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81991 + if (pte_same(entry, *pte))
81992 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81993 + else
81994 + unlock_page(page_m);
81995 + }
81996 + } else
81997 + pax_mirror_file_pte(vma, address, page_m, ptl);
81998 +
81999 +out:
82000 + pte_unmap_unlock(pte, ptl);
82001 +}
82002 +#endif
82003 +
82004 /*
82005 * This routine handles present pages, when users try to write
82006 * to a shared page. It is done by copying the page to a new address
82007 @@ -2799,6 +2995,12 @@ gotten:
82008 */
82009 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82010 if (likely(pte_same(*page_table, orig_pte))) {
82011 +
82012 +#ifdef CONFIG_PAX_SEGMEXEC
82013 + if (pax_find_mirror_vma(vma))
82014 + BUG_ON(!trylock_page(new_page));
82015 +#endif
82016 +
82017 if (old_page) {
82018 if (!PageAnon(old_page)) {
82019 dec_mm_counter_fast(mm, MM_FILEPAGES);
82020 @@ -2850,6 +3052,10 @@ gotten:
82021 page_remove_rmap(old_page);
82022 }
82023
82024 +#ifdef CONFIG_PAX_SEGMEXEC
82025 + pax_mirror_anon_pte(vma, address, new_page, ptl);
82026 +#endif
82027 +
82028 /* Free the old page.. */
82029 new_page = old_page;
82030 ret |= VM_FAULT_WRITE;
82031 @@ -3125,6 +3331,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82032 swap_free(entry);
82033 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
82034 try_to_free_swap(page);
82035 +
82036 +#ifdef CONFIG_PAX_SEGMEXEC
82037 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
82038 +#endif
82039 +
82040 unlock_page(page);
82041 if (page != swapcache) {
82042 /*
82043 @@ -3148,6 +3359,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82044
82045 /* No need to invalidate - it was non-present before */
82046 update_mmu_cache(vma, address, page_table);
82047 +
82048 +#ifdef CONFIG_PAX_SEGMEXEC
82049 + pax_mirror_anon_pte(vma, address, page, ptl);
82050 +#endif
82051 +
82052 unlock:
82053 pte_unmap_unlock(page_table, ptl);
82054 out:
82055 @@ -3167,40 +3383,6 @@ out_release:
82056 }
82057
82058 /*
82059 - * This is like a special single-page "expand_{down|up}wards()",
82060 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
82061 - * doesn't hit another vma.
82062 - */
82063 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
82064 -{
82065 - address &= PAGE_MASK;
82066 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
82067 - struct vm_area_struct *prev = vma->vm_prev;
82068 -
82069 - /*
82070 - * Is there a mapping abutting this one below?
82071 - *
82072 - * That's only ok if it's the same stack mapping
82073 - * that has gotten split..
82074 - */
82075 - if (prev && prev->vm_end == address)
82076 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
82077 -
82078 - expand_downwards(vma, address - PAGE_SIZE);
82079 - }
82080 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
82081 - struct vm_area_struct *next = vma->vm_next;
82082 -
82083 - /* As VM_GROWSDOWN but s/below/above/ */
82084 - if (next && next->vm_start == address + PAGE_SIZE)
82085 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
82086 -
82087 - expand_upwards(vma, address + PAGE_SIZE);
82088 - }
82089 - return 0;
82090 -}
82091 -
82092 -/*
82093 * We enter with non-exclusive mmap_sem (to exclude vma changes,
82094 * but allow concurrent faults), and pte mapped but not yet locked.
82095 * We return with mmap_sem still held, but pte unmapped and unlocked.
82096 @@ -3209,27 +3391,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82097 unsigned long address, pte_t *page_table, pmd_t *pmd,
82098 unsigned int flags)
82099 {
82100 - struct page *page;
82101 + struct page *page = NULL;
82102 spinlock_t *ptl;
82103 pte_t entry;
82104
82105 - pte_unmap(page_table);
82106 -
82107 - /* Check if we need to add a guard page to the stack */
82108 - if (check_stack_guard_page(vma, address) < 0)
82109 - return VM_FAULT_SIGBUS;
82110 -
82111 - /* Use the zero-page for reads */
82112 if (!(flags & FAULT_FLAG_WRITE)) {
82113 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
82114 vma->vm_page_prot));
82115 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82116 + ptl = pte_lockptr(mm, pmd);
82117 + spin_lock(ptl);
82118 if (!pte_none(*page_table))
82119 goto unlock;
82120 goto setpte;
82121 }
82122
82123 /* Allocate our own private page. */
82124 + pte_unmap(page_table);
82125 +
82126 if (unlikely(anon_vma_prepare(vma)))
82127 goto oom;
82128 page = alloc_zeroed_user_highpage_movable(vma, address);
82129 @@ -3253,6 +3431,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82130 if (!pte_none(*page_table))
82131 goto release;
82132
82133 +#ifdef CONFIG_PAX_SEGMEXEC
82134 + if (pax_find_mirror_vma(vma))
82135 + BUG_ON(!trylock_page(page));
82136 +#endif
82137 +
82138 inc_mm_counter_fast(mm, MM_ANONPAGES);
82139 page_add_new_anon_rmap(page, vma, address);
82140 setpte:
82141 @@ -3260,6 +3443,12 @@ setpte:
82142
82143 /* No need to invalidate - it was non-present before */
82144 update_mmu_cache(vma, address, page_table);
82145 +
82146 +#ifdef CONFIG_PAX_SEGMEXEC
82147 + if (page)
82148 + pax_mirror_anon_pte(vma, address, page, ptl);
82149 +#endif
82150 +
82151 unlock:
82152 pte_unmap_unlock(page_table, ptl);
82153 return 0;
82154 @@ -3403,6 +3592,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82155 */
82156 /* Only go through if we didn't race with anybody else... */
82157 if (likely(pte_same(*page_table, orig_pte))) {
82158 +
82159 +#ifdef CONFIG_PAX_SEGMEXEC
82160 + if (anon && pax_find_mirror_vma(vma))
82161 + BUG_ON(!trylock_page(page));
82162 +#endif
82163 +
82164 flush_icache_page(vma, page);
82165 entry = mk_pte(page, vma->vm_page_prot);
82166 if (flags & FAULT_FLAG_WRITE)
82167 @@ -3422,6 +3617,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82168
82169 /* no need to invalidate: a not-present page won't be cached */
82170 update_mmu_cache(vma, address, page_table);
82171 +
82172 +#ifdef CONFIG_PAX_SEGMEXEC
82173 + if (anon)
82174 + pax_mirror_anon_pte(vma, address, page, ptl);
82175 + else
82176 + pax_mirror_file_pte(vma, address, page, ptl);
82177 +#endif
82178 +
82179 } else {
82180 if (cow_page)
82181 mem_cgroup_uncharge_page(cow_page);
82182 @@ -3743,6 +3946,12 @@ int handle_pte_fault(struct mm_struct *mm,
82183 if (flags & FAULT_FLAG_WRITE)
82184 flush_tlb_fix_spurious_fault(vma, address);
82185 }
82186 +
82187 +#ifdef CONFIG_PAX_SEGMEXEC
82188 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82189 + return 0;
82190 +#endif
82191 +
82192 unlock:
82193 pte_unmap_unlock(pte, ptl);
82194 return 0;
82195 @@ -3759,6 +3968,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82196 pmd_t *pmd;
82197 pte_t *pte;
82198
82199 +#ifdef CONFIG_PAX_SEGMEXEC
82200 + struct vm_area_struct *vma_m;
82201 +#endif
82202 +
82203 __set_current_state(TASK_RUNNING);
82204
82205 count_vm_event(PGFAULT);
82206 @@ -3770,6 +3983,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82207 if (unlikely(is_vm_hugetlb_page(vma)))
82208 return hugetlb_fault(mm, vma, address, flags);
82209
82210 +#ifdef CONFIG_PAX_SEGMEXEC
82211 + vma_m = pax_find_mirror_vma(vma);
82212 + if (vma_m) {
82213 + unsigned long address_m;
82214 + pgd_t *pgd_m;
82215 + pud_t *pud_m;
82216 + pmd_t *pmd_m;
82217 +
82218 + if (vma->vm_start > vma_m->vm_start) {
82219 + address_m = address;
82220 + address -= SEGMEXEC_TASK_SIZE;
82221 + vma = vma_m;
82222 + } else
82223 + address_m = address + SEGMEXEC_TASK_SIZE;
82224 +
82225 + pgd_m = pgd_offset(mm, address_m);
82226 + pud_m = pud_alloc(mm, pgd_m, address_m);
82227 + if (!pud_m)
82228 + return VM_FAULT_OOM;
82229 + pmd_m = pmd_alloc(mm, pud_m, address_m);
82230 + if (!pmd_m)
82231 + return VM_FAULT_OOM;
82232 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
82233 + return VM_FAULT_OOM;
82234 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
82235 + }
82236 +#endif
82237 +
82238 retry:
82239 pgd = pgd_offset(mm, address);
82240 pud = pud_alloc(mm, pgd, address);
82241 @@ -3868,6 +4109,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82242 spin_unlock(&mm->page_table_lock);
82243 return 0;
82244 }
82245 +
82246 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82247 +{
82248 + pud_t *new = pud_alloc_one(mm, address);
82249 + if (!new)
82250 + return -ENOMEM;
82251 +
82252 + smp_wmb(); /* See comment in __pte_alloc */
82253 +
82254 + spin_lock(&mm->page_table_lock);
82255 + if (pgd_present(*pgd)) /* Another has populated it */
82256 + pud_free(mm, new);
82257 + else
82258 + pgd_populate_kernel(mm, pgd, new);
82259 + spin_unlock(&mm->page_table_lock);
82260 + return 0;
82261 +}
82262 #endif /* __PAGETABLE_PUD_FOLDED */
82263
82264 #ifndef __PAGETABLE_PMD_FOLDED
82265 @@ -3898,6 +4156,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
82266 spin_unlock(&mm->page_table_lock);
82267 return 0;
82268 }
82269 +
82270 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
82271 +{
82272 + pmd_t *new = pmd_alloc_one(mm, address);
82273 + if (!new)
82274 + return -ENOMEM;
82275 +
82276 + smp_wmb(); /* See comment in __pte_alloc */
82277 +
82278 + spin_lock(&mm->page_table_lock);
82279 +#ifndef __ARCH_HAS_4LEVEL_HACK
82280 + if (pud_present(*pud)) /* Another has populated it */
82281 + pmd_free(mm, new);
82282 + else
82283 + pud_populate_kernel(mm, pud, new);
82284 +#else
82285 + if (pgd_present(*pud)) /* Another has populated it */
82286 + pmd_free(mm, new);
82287 + else
82288 + pgd_populate_kernel(mm, pud, new);
82289 +#endif /* __ARCH_HAS_4LEVEL_HACK */
82290 + spin_unlock(&mm->page_table_lock);
82291 + return 0;
82292 +}
82293 #endif /* __PAGETABLE_PMD_FOLDED */
82294
82295 #if !defined(__HAVE_ARCH_GATE_AREA)
82296 @@ -3911,7 +4193,7 @@ static int __init gate_vma_init(void)
82297 gate_vma.vm_start = FIXADDR_USER_START;
82298 gate_vma.vm_end = FIXADDR_USER_END;
82299 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
82300 - gate_vma.vm_page_prot = __P101;
82301 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
82302
82303 return 0;
82304 }
82305 @@ -4045,8 +4327,8 @@ out:
82306 return ret;
82307 }
82308
82309 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82310 - void *buf, int len, int write)
82311 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82312 + void *buf, size_t len, int write)
82313 {
82314 resource_size_t phys_addr;
82315 unsigned long prot = 0;
82316 @@ -4071,8 +4353,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82317 * Access another process' address space as given in mm. If non-NULL, use the
82318 * given task for page fault accounting.
82319 */
82320 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82321 - unsigned long addr, void *buf, int len, int write)
82322 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82323 + unsigned long addr, void *buf, size_t len, int write)
82324 {
82325 struct vm_area_struct *vma;
82326 void *old_buf = buf;
82327 @@ -4080,7 +4362,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82328 down_read(&mm->mmap_sem);
82329 /* ignore errors, just check how much was successfully transferred */
82330 while (len) {
82331 - int bytes, ret, offset;
82332 + ssize_t bytes, ret, offset;
82333 void *maddr;
82334 struct page *page = NULL;
82335
82336 @@ -4139,8 +4421,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82337 *
82338 * The caller must hold a reference on @mm.
82339 */
82340 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82341 - void *buf, int len, int write)
82342 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82343 + void *buf, size_t len, int write)
82344 {
82345 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82346 }
82347 @@ -4150,11 +4432,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82348 * Source/target buffer must be kernel space,
82349 * Do not walk the page table directly, use get_user_pages
82350 */
82351 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82352 - void *buf, int len, int write)
82353 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82354 + void *buf, size_t len, int write)
82355 {
82356 struct mm_struct *mm;
82357 - int ret;
82358 + ssize_t ret;
82359
82360 mm = get_task_mm(tsk);
82361 if (!mm)
82362 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82363 index 7431001..0f8344e 100644
82364 --- a/mm/mempolicy.c
82365 +++ b/mm/mempolicy.c
82366 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82367 unsigned long vmstart;
82368 unsigned long vmend;
82369
82370 +#ifdef CONFIG_PAX_SEGMEXEC
82371 + struct vm_area_struct *vma_m;
82372 +#endif
82373 +
82374 vma = find_vma(mm, start);
82375 if (!vma || vma->vm_start > start)
82376 return -EFAULT;
82377 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82378 if (err)
82379 goto out;
82380 }
82381 +
82382 err = vma_replace_policy(vma, new_pol);
82383 if (err)
82384 goto out;
82385 +
82386 +#ifdef CONFIG_PAX_SEGMEXEC
82387 + vma_m = pax_find_mirror_vma(vma);
82388 + if (vma_m) {
82389 + err = vma_replace_policy(vma_m, new_pol);
82390 + if (err)
82391 + goto out;
82392 + }
82393 +#endif
82394 +
82395 }
82396
82397 out:
82398 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82399
82400 if (end < start)
82401 return -EINVAL;
82402 +
82403 +#ifdef CONFIG_PAX_SEGMEXEC
82404 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82405 + if (end > SEGMEXEC_TASK_SIZE)
82406 + return -EINVAL;
82407 + } else
82408 +#endif
82409 +
82410 + if (end > TASK_SIZE)
82411 + return -EINVAL;
82412 +
82413 if (end == start)
82414 return 0;
82415
82416 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82417 */
82418 tcred = __task_cred(task);
82419 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82420 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82421 - !capable(CAP_SYS_NICE)) {
82422 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82423 rcu_read_unlock();
82424 err = -EPERM;
82425 goto out_put;
82426 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82427 goto out;
82428 }
82429
82430 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82431 + if (mm != current->mm &&
82432 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82433 + mmput(mm);
82434 + err = -EPERM;
82435 + goto out;
82436 + }
82437 +#endif
82438 +
82439 err = do_migrate_pages(mm, old, new,
82440 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82441
82442 diff --git a/mm/migrate.c b/mm/migrate.c
82443 index 6f0c244..6d1ae32 100644
82444 --- a/mm/migrate.c
82445 +++ b/mm/migrate.c
82446 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82447 */
82448 tcred = __task_cred(task);
82449 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82450 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82451 - !capable(CAP_SYS_NICE)) {
82452 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82453 rcu_read_unlock();
82454 err = -EPERM;
82455 goto out;
82456 diff --git a/mm/mlock.c b/mm/mlock.c
82457 index 79b7cf7..9944291 100644
82458 --- a/mm/mlock.c
82459 +++ b/mm/mlock.c
82460 @@ -13,6 +13,7 @@
82461 #include <linux/pagemap.h>
82462 #include <linux/mempolicy.h>
82463 #include <linux/syscalls.h>
82464 +#include <linux/security.h>
82465 #include <linux/sched.h>
82466 #include <linux/export.h>
82467 #include <linux/rmap.h>
82468 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82469 {
82470 unsigned long nstart, end, tmp;
82471 struct vm_area_struct * vma, * prev;
82472 - int error;
82473 + int error = 0;
82474
82475 VM_BUG_ON(start & ~PAGE_MASK);
82476 VM_BUG_ON(len != PAGE_ALIGN(len));
82477 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82478 return -EINVAL;
82479 if (end == start)
82480 return 0;
82481 + if (end > TASK_SIZE)
82482 + return -EINVAL;
82483 +
82484 vma = find_vma(current->mm, start);
82485 if (!vma || vma->vm_start > start)
82486 return -ENOMEM;
82487 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82488 for (nstart = start ; ; ) {
82489 vm_flags_t newflags;
82490
82491 +#ifdef CONFIG_PAX_SEGMEXEC
82492 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82493 + break;
82494 +#endif
82495 +
82496 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82497
82498 newflags = vma->vm_flags & ~VM_LOCKED;
82499 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82500 lock_limit >>= PAGE_SHIFT;
82501
82502 /* check against resource limits */
82503 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82504 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82505 error = do_mlock(start, len, 1);
82506 up_write(&current->mm->mmap_sem);
82507 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
82508 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82509 vm_flags_t newflags;
82510
82511 +#ifdef CONFIG_PAX_SEGMEXEC
82512 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82513 + break;
82514 +#endif
82515 +
82516 newflags = vma->vm_flags & ~VM_LOCKED;
82517 if (flags & MCL_CURRENT)
82518 newflags |= VM_LOCKED;
82519 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82520 lock_limit >>= PAGE_SHIFT;
82521
82522 ret = -ENOMEM;
82523 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82524 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82525 capable(CAP_IPC_LOCK))
82526 ret = do_mlockall(flags);
82527 diff --git a/mm/mmap.c b/mm/mmap.c
82528 index f681e18..4c2577f 100644
82529 --- a/mm/mmap.c
82530 +++ b/mm/mmap.c
82531 @@ -36,6 +36,7 @@
82532 #include <linux/sched/sysctl.h>
82533 #include <linux/notifier.h>
82534 #include <linux/memory.h>
82535 +#include <linux/random.h>
82536
82537 #include <asm/uaccess.h>
82538 #include <asm/cacheflush.h>
82539 @@ -52,6 +53,16 @@
82540 #define arch_rebalance_pgtables(addr, len) (addr)
82541 #endif
82542
82543 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82544 +{
82545 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82546 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82547 + up_read(&mm->mmap_sem);
82548 + BUG();
82549 + }
82550 +#endif
82551 +}
82552 +
82553 static void unmap_region(struct mm_struct *mm,
82554 struct vm_area_struct *vma, struct vm_area_struct *prev,
82555 unsigned long start, unsigned long end);
82556 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
82557 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82558 *
82559 */
82560 -pgprot_t protection_map[16] = {
82561 +pgprot_t protection_map[16] __read_only = {
82562 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82563 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82564 };
82565
82566 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82567 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82568 {
82569 - return __pgprot(pgprot_val(protection_map[vm_flags &
82570 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82571 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82572 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82573 +
82574 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82575 + if (!(__supported_pte_mask & _PAGE_NX) &&
82576 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82577 + (vm_flags & (VM_READ | VM_WRITE)))
82578 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82579 +#endif
82580 +
82581 + return prot;
82582 }
82583 EXPORT_SYMBOL(vm_get_page_prot);
82584
82585 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82586 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82587 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
82588 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
82589 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82590 /*
82591 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82592 * other variables. It can be updated by several CPUs frequently.
82593 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82594 struct vm_area_struct *next = vma->vm_next;
82595
82596 might_sleep();
82597 + BUG_ON(vma->vm_mirror);
82598 if (vma->vm_ops && vma->vm_ops->close)
82599 vma->vm_ops->close(vma);
82600 if (vma->vm_file)
82601 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82602 * not page aligned -Ram Gupta
82603 */
82604 rlim = rlimit(RLIMIT_DATA);
82605 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82606 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82607 (mm->end_data - mm->start_data) > rlim)
82608 goto out;
82609 @@ -933,6 +956,12 @@ static int
82610 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82611 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82612 {
82613 +
82614 +#ifdef CONFIG_PAX_SEGMEXEC
82615 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82616 + return 0;
82617 +#endif
82618 +
82619 if (is_mergeable_vma(vma, file, vm_flags) &&
82620 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82621 if (vma->vm_pgoff == vm_pgoff)
82622 @@ -952,6 +981,12 @@ static int
82623 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82624 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82625 {
82626 +
82627 +#ifdef CONFIG_PAX_SEGMEXEC
82628 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82629 + return 0;
82630 +#endif
82631 +
82632 if (is_mergeable_vma(vma, file, vm_flags) &&
82633 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82634 pgoff_t vm_pglen;
82635 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82636 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82637 struct vm_area_struct *prev, unsigned long addr,
82638 unsigned long end, unsigned long vm_flags,
82639 - struct anon_vma *anon_vma, struct file *file,
82640 + struct anon_vma *anon_vma, struct file *file,
82641 pgoff_t pgoff, struct mempolicy *policy)
82642 {
82643 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82644 struct vm_area_struct *area, *next;
82645 int err;
82646
82647 +#ifdef CONFIG_PAX_SEGMEXEC
82648 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82649 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82650 +
82651 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82652 +#endif
82653 +
82654 /*
82655 * We later require that vma->vm_flags == vm_flags,
82656 * so this tests vma->vm_flags & VM_SPECIAL, too.
82657 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82658 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82659 next = next->vm_next;
82660
82661 +#ifdef CONFIG_PAX_SEGMEXEC
82662 + if (prev)
82663 + prev_m = pax_find_mirror_vma(prev);
82664 + if (area)
82665 + area_m = pax_find_mirror_vma(area);
82666 + if (next)
82667 + next_m = pax_find_mirror_vma(next);
82668 +#endif
82669 +
82670 /*
82671 * Can it merge with the predecessor?
82672 */
82673 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82674 /* cases 1, 6 */
82675 err = vma_adjust(prev, prev->vm_start,
82676 next->vm_end, prev->vm_pgoff, NULL);
82677 - } else /* cases 2, 5, 7 */
82678 +
82679 +#ifdef CONFIG_PAX_SEGMEXEC
82680 + if (!err && prev_m)
82681 + err = vma_adjust(prev_m, prev_m->vm_start,
82682 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82683 +#endif
82684 +
82685 + } else { /* cases 2, 5, 7 */
82686 err = vma_adjust(prev, prev->vm_start,
82687 end, prev->vm_pgoff, NULL);
82688 +
82689 +#ifdef CONFIG_PAX_SEGMEXEC
82690 + if (!err && prev_m)
82691 + err = vma_adjust(prev_m, prev_m->vm_start,
82692 + end_m, prev_m->vm_pgoff, NULL);
82693 +#endif
82694 +
82695 + }
82696 if (err)
82697 return NULL;
82698 khugepaged_enter_vma_merge(prev);
82699 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82700 mpol_equal(policy, vma_policy(next)) &&
82701 can_vma_merge_before(next, vm_flags,
82702 anon_vma, file, pgoff+pglen)) {
82703 - if (prev && addr < prev->vm_end) /* case 4 */
82704 + if (prev && addr < prev->vm_end) { /* case 4 */
82705 err = vma_adjust(prev, prev->vm_start,
82706 addr, prev->vm_pgoff, NULL);
82707 - else /* cases 3, 8 */
82708 +
82709 +#ifdef CONFIG_PAX_SEGMEXEC
82710 + if (!err && prev_m)
82711 + err = vma_adjust(prev_m, prev_m->vm_start,
82712 + addr_m, prev_m->vm_pgoff, NULL);
82713 +#endif
82714 +
82715 + } else { /* cases 3, 8 */
82716 err = vma_adjust(area, addr, next->vm_end,
82717 next->vm_pgoff - pglen, NULL);
82718 +
82719 +#ifdef CONFIG_PAX_SEGMEXEC
82720 + if (!err && area_m)
82721 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82722 + next_m->vm_pgoff - pglen, NULL);
82723 +#endif
82724 +
82725 + }
82726 if (err)
82727 return NULL;
82728 khugepaged_enter_vma_merge(area);
82729 @@ -1165,8 +1246,10 @@ none:
82730 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82731 struct file *file, long pages)
82732 {
82733 - const unsigned long stack_flags
82734 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82735 +
82736 +#ifdef CONFIG_PAX_RANDMMAP
82737 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82738 +#endif
82739
82740 mm->total_vm += pages;
82741
82742 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82743 mm->shared_vm += pages;
82744 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82745 mm->exec_vm += pages;
82746 - } else if (flags & stack_flags)
82747 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82748 mm->stack_vm += pages;
82749 }
82750 #endif /* CONFIG_PROC_FS */
82751 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82752 * (the exception is when the underlying filesystem is noexec
82753 * mounted, in which case we dont add PROT_EXEC.)
82754 */
82755 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82756 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82757 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82758 prot |= PROT_EXEC;
82759
82760 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82761 /* Obtain the address to map to. we verify (or select) it and ensure
82762 * that it represents a valid section of the address space.
82763 */
82764 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82765 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82766 if (addr & ~PAGE_MASK)
82767 return addr;
82768
82769 @@ -1250,6 +1333,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82770 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82771 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82772
82773 +#ifdef CONFIG_PAX_MPROTECT
82774 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82775 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82776 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82777 + gr_log_rwxmmap(file);
82778 +
82779 +#ifdef CONFIG_PAX_EMUPLT
82780 + vm_flags &= ~VM_EXEC;
82781 +#else
82782 + return -EPERM;
82783 +#endif
82784 +
82785 + }
82786 +
82787 + if (!(vm_flags & VM_EXEC))
82788 + vm_flags &= ~VM_MAYEXEC;
82789 +#else
82790 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82791 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82792 +#endif
82793 + else
82794 + vm_flags &= ~VM_MAYWRITE;
82795 + }
82796 +#endif
82797 +
82798 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82799 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82800 + vm_flags &= ~VM_PAGEEXEC;
82801 +#endif
82802 +
82803 if (flags & MAP_LOCKED)
82804 if (!can_do_mlock())
82805 return -EPERM;
82806 @@ -1261,6 +1374,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82807 locked += mm->locked_vm;
82808 lock_limit = rlimit(RLIMIT_MEMLOCK);
82809 lock_limit >>= PAGE_SHIFT;
82810 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82811 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82812 return -EAGAIN;
82813 }
82814 @@ -1341,6 +1455,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82815 vm_flags |= VM_NORESERVE;
82816 }
82817
82818 + if (!gr_acl_handle_mmap(file, prot))
82819 + return -EACCES;
82820 +
82821 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82822 if (!IS_ERR_VALUE(addr) &&
82823 ((vm_flags & VM_LOCKED) ||
82824 @@ -1432,7 +1549,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82825 vm_flags_t vm_flags = vma->vm_flags;
82826
82827 /* If it was private or non-writable, the write bit is already clear */
82828 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82829 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82830 return 0;
82831
82832 /* The backer wishes to know when pages are first written to? */
82833 @@ -1480,7 +1597,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82834 unsigned long charged = 0;
82835 struct inode *inode = file ? file_inode(file) : NULL;
82836
82837 +#ifdef CONFIG_PAX_SEGMEXEC
82838 + struct vm_area_struct *vma_m = NULL;
82839 +#endif
82840 +
82841 + /*
82842 + * mm->mmap_sem is required to protect against another thread
82843 + * changing the mappings in case we sleep.
82844 + */
82845 + verify_mm_writelocked(mm);
82846 +
82847 /* Check against address space limit. */
82848 +
82849 +#ifdef CONFIG_PAX_RANDMMAP
82850 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82851 +#endif
82852 +
82853 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
82854 unsigned long nr_pages;
82855
82856 @@ -1499,11 +1631,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82857
82858 /* Clear old maps */
82859 error = -ENOMEM;
82860 -munmap_back:
82861 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82862 if (do_munmap(mm, addr, len))
82863 return -ENOMEM;
82864 - goto munmap_back;
82865 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82866 }
82867
82868 /*
82869 @@ -1534,6 +1665,16 @@ munmap_back:
82870 goto unacct_error;
82871 }
82872
82873 +#ifdef CONFIG_PAX_SEGMEXEC
82874 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82875 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82876 + if (!vma_m) {
82877 + error = -ENOMEM;
82878 + goto free_vma;
82879 + }
82880 + }
82881 +#endif
82882 +
82883 vma->vm_mm = mm;
82884 vma->vm_start = addr;
82885 vma->vm_end = addr + len;
82886 @@ -1558,6 +1699,13 @@ munmap_back:
82887 if (error)
82888 goto unmap_and_free_vma;
82889
82890 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82891 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82892 + vma->vm_flags |= VM_PAGEEXEC;
82893 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82894 + }
82895 +#endif
82896 +
82897 /* Can addr have changed??
82898 *
82899 * Answer: Yes, several device drivers can do it in their
82900 @@ -1596,6 +1744,11 @@ munmap_back:
82901 vma_link(mm, vma, prev, rb_link, rb_parent);
82902 file = vma->vm_file;
82903
82904 +#ifdef CONFIG_PAX_SEGMEXEC
82905 + if (vma_m)
82906 + BUG_ON(pax_mirror_vma(vma_m, vma));
82907 +#endif
82908 +
82909 /* Once vma denies write, undo our temporary denial count */
82910 if (correct_wcount)
82911 atomic_inc(&inode->i_writecount);
82912 @@ -1603,6 +1756,7 @@ out:
82913 perf_event_mmap(vma);
82914
82915 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82916 + track_exec_limit(mm, addr, addr + len, vm_flags);
82917 if (vm_flags & VM_LOCKED) {
82918 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82919 vma == get_gate_vma(current->mm)))
82920 @@ -1626,6 +1780,12 @@ unmap_and_free_vma:
82921 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82922 charged = 0;
82923 free_vma:
82924 +
82925 +#ifdef CONFIG_PAX_SEGMEXEC
82926 + if (vma_m)
82927 + kmem_cache_free(vm_area_cachep, vma_m);
82928 +#endif
82929 +
82930 kmem_cache_free(vm_area_cachep, vma);
82931 unacct_error:
82932 if (charged)
82933 @@ -1633,7 +1793,63 @@ unacct_error:
82934 return error;
82935 }
82936
82937 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82938 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82939 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82940 +{
82941 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82942 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
82943 +
82944 + return 0;
82945 +}
82946 +#endif
82947 +
82948 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82949 +{
82950 + if (!vma) {
82951 +#ifdef CONFIG_STACK_GROWSUP
82952 + if (addr > sysctl_heap_stack_gap)
82953 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82954 + else
82955 + vma = find_vma(current->mm, 0);
82956 + if (vma && (vma->vm_flags & VM_GROWSUP))
82957 + return false;
82958 +#endif
82959 + return true;
82960 + }
82961 +
82962 + if (addr + len > vma->vm_start)
82963 + return false;
82964 +
82965 + if (vma->vm_flags & VM_GROWSDOWN)
82966 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82967 +#ifdef CONFIG_STACK_GROWSUP
82968 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82969 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
82970 +#endif
82971 + else if (offset)
82972 + return offset <= vma->vm_start - addr - len;
82973 +
82974 + return true;
82975 +}
82976 +
82977 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82978 +{
82979 + if (vma->vm_start < len)
82980 + return -ENOMEM;
82981 +
82982 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82983 + if (offset <= vma->vm_start - len)
82984 + return vma->vm_start - len - offset;
82985 + else
82986 + return -ENOMEM;
82987 + }
82988 +
82989 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82990 + return vma->vm_start - len - sysctl_heap_stack_gap;
82991 + return -ENOMEM;
82992 +}
82993 +
82994 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
82995 {
82996 /*
82997 * We implement the search by looking for an rbtree node that
82998 @@ -1681,11 +1897,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82999 }
83000 }
83001
83002 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
83003 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
83004 check_current:
83005 /* Check if current node has a suitable gap */
83006 if (gap_start > high_limit)
83007 return -ENOMEM;
83008 +
83009 + if (gap_end - gap_start > info->threadstack_offset)
83010 + gap_start += info->threadstack_offset;
83011 + else
83012 + gap_start = gap_end;
83013 +
83014 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83015 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83016 + gap_start += sysctl_heap_stack_gap;
83017 + else
83018 + gap_start = gap_end;
83019 + }
83020 + if (vma->vm_flags & VM_GROWSDOWN) {
83021 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83022 + gap_end -= sysctl_heap_stack_gap;
83023 + else
83024 + gap_end = gap_start;
83025 + }
83026 if (gap_end >= low_limit && gap_end - gap_start >= length)
83027 goto found;
83028
83029 @@ -1735,7 +1969,7 @@ found:
83030 return gap_start;
83031 }
83032
83033 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
83034 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
83035 {
83036 struct mm_struct *mm = current->mm;
83037 struct vm_area_struct *vma;
83038 @@ -1789,6 +2023,24 @@ check_current:
83039 gap_end = vma->vm_start;
83040 if (gap_end < low_limit)
83041 return -ENOMEM;
83042 +
83043 + if (gap_end - gap_start > info->threadstack_offset)
83044 + gap_end -= info->threadstack_offset;
83045 + else
83046 + gap_end = gap_start;
83047 +
83048 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83049 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83050 + gap_start += sysctl_heap_stack_gap;
83051 + else
83052 + gap_start = gap_end;
83053 + }
83054 + if (vma->vm_flags & VM_GROWSDOWN) {
83055 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83056 + gap_end -= sysctl_heap_stack_gap;
83057 + else
83058 + gap_end = gap_start;
83059 + }
83060 if (gap_start <= high_limit && gap_end - gap_start >= length)
83061 goto found;
83062
83063 @@ -1852,6 +2104,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83064 struct mm_struct *mm = current->mm;
83065 struct vm_area_struct *vma;
83066 struct vm_unmapped_area_info info;
83067 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83068
83069 if (len > TASK_SIZE)
83070 return -ENOMEM;
83071 @@ -1859,29 +2112,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83072 if (flags & MAP_FIXED)
83073 return addr;
83074
83075 +#ifdef CONFIG_PAX_RANDMMAP
83076 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83077 +#endif
83078 +
83079 if (addr) {
83080 addr = PAGE_ALIGN(addr);
83081 vma = find_vma(mm, addr);
83082 - if (TASK_SIZE - len >= addr &&
83083 - (!vma || addr + len <= vma->vm_start))
83084 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83085 return addr;
83086 }
83087
83088 info.flags = 0;
83089 info.length = len;
83090 info.low_limit = TASK_UNMAPPED_BASE;
83091 +
83092 +#ifdef CONFIG_PAX_RANDMMAP
83093 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83094 + info.low_limit += mm->delta_mmap;
83095 +#endif
83096 +
83097 info.high_limit = TASK_SIZE;
83098 info.align_mask = 0;
83099 + info.threadstack_offset = offset;
83100 return vm_unmapped_area(&info);
83101 }
83102 #endif
83103
83104 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
83105 {
83106 +
83107 +#ifdef CONFIG_PAX_SEGMEXEC
83108 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83109 + return;
83110 +#endif
83111 +
83112 /*
83113 * Is this a new hole at the lowest possible address?
83114 */
83115 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
83116 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
83117 mm->free_area_cache = addr;
83118 }
83119
83120 @@ -1899,6 +2168,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83121 struct mm_struct *mm = current->mm;
83122 unsigned long addr = addr0;
83123 struct vm_unmapped_area_info info;
83124 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83125
83126 /* requested length too big for entire address space */
83127 if (len > TASK_SIZE)
83128 @@ -1907,12 +2177,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83129 if (flags & MAP_FIXED)
83130 return addr;
83131
83132 +#ifdef CONFIG_PAX_RANDMMAP
83133 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83134 +#endif
83135 +
83136 /* requesting a specific address */
83137 if (addr) {
83138 addr = PAGE_ALIGN(addr);
83139 vma = find_vma(mm, addr);
83140 - if (TASK_SIZE - len >= addr &&
83141 - (!vma || addr + len <= vma->vm_start))
83142 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83143 return addr;
83144 }
83145
83146 @@ -1921,6 +2194,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83147 info.low_limit = PAGE_SIZE;
83148 info.high_limit = mm->mmap_base;
83149 info.align_mask = 0;
83150 + info.threadstack_offset = offset;
83151 addr = vm_unmapped_area(&info);
83152
83153 /*
83154 @@ -1933,6 +2207,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83155 VM_BUG_ON(addr != -ENOMEM);
83156 info.flags = 0;
83157 info.low_limit = TASK_UNMAPPED_BASE;
83158 +
83159 +#ifdef CONFIG_PAX_RANDMMAP
83160 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83161 + info.low_limit += mm->delta_mmap;
83162 +#endif
83163 +
83164 info.high_limit = TASK_SIZE;
83165 addr = vm_unmapped_area(&info);
83166 }
83167 @@ -1943,6 +2223,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83168
83169 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83170 {
83171 +
83172 +#ifdef CONFIG_PAX_SEGMEXEC
83173 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83174 + return;
83175 +#endif
83176 +
83177 /*
83178 * Is this a new hole at the highest possible address?
83179 */
83180 @@ -1950,8 +2236,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83181 mm->free_area_cache = addr;
83182
83183 /* dont allow allocations above current base */
83184 - if (mm->free_area_cache > mm->mmap_base)
83185 + if (mm->free_area_cache > mm->mmap_base) {
83186 mm->free_area_cache = mm->mmap_base;
83187 + mm->cached_hole_size = ~0UL;
83188 + }
83189 }
83190
83191 unsigned long
83192 @@ -2047,6 +2335,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83193 return vma;
83194 }
83195
83196 +#ifdef CONFIG_PAX_SEGMEXEC
83197 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83198 +{
83199 + struct vm_area_struct *vma_m;
83200 +
83201 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83202 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83203 + BUG_ON(vma->vm_mirror);
83204 + return NULL;
83205 + }
83206 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83207 + vma_m = vma->vm_mirror;
83208 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83209 + BUG_ON(vma->vm_file != vma_m->vm_file);
83210 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83211 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83212 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83213 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83214 + return vma_m;
83215 +}
83216 +#endif
83217 +
83218 /*
83219 * Verify that the stack growth is acceptable and
83220 * update accounting. This is shared with both the
83221 @@ -2063,6 +2373,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83222 return -ENOMEM;
83223
83224 /* Stack limit test */
83225 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
83226 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
83227 return -ENOMEM;
83228
83229 @@ -2073,6 +2384,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83230 locked = mm->locked_vm + grow;
83231 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
83232 limit >>= PAGE_SHIFT;
83233 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83234 if (locked > limit && !capable(CAP_IPC_LOCK))
83235 return -ENOMEM;
83236 }
83237 @@ -2102,37 +2414,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83238 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
83239 * vma is the last one with address > vma->vm_end. Have to extend vma.
83240 */
83241 +#ifndef CONFIG_IA64
83242 +static
83243 +#endif
83244 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83245 {
83246 int error;
83247 + bool locknext;
83248
83249 if (!(vma->vm_flags & VM_GROWSUP))
83250 return -EFAULT;
83251
83252 + /* Also guard against wrapping around to address 0. */
83253 + if (address < PAGE_ALIGN(address+1))
83254 + address = PAGE_ALIGN(address+1);
83255 + else
83256 + return -ENOMEM;
83257 +
83258 /*
83259 * We must make sure the anon_vma is allocated
83260 * so that the anon_vma locking is not a noop.
83261 */
83262 if (unlikely(anon_vma_prepare(vma)))
83263 return -ENOMEM;
83264 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
83265 + if (locknext && anon_vma_prepare(vma->vm_next))
83266 + return -ENOMEM;
83267 vma_lock_anon_vma(vma);
83268 + if (locknext)
83269 + vma_lock_anon_vma(vma->vm_next);
83270
83271 /*
83272 * vma->vm_start/vm_end cannot change under us because the caller
83273 * is required to hold the mmap_sem in read mode. We need the
83274 - * anon_vma lock to serialize against concurrent expand_stacks.
83275 - * Also guard against wrapping around to address 0.
83276 + * anon_vma locks to serialize against concurrent expand_stacks
83277 + * and expand_upwards.
83278 */
83279 - if (address < PAGE_ALIGN(address+4))
83280 - address = PAGE_ALIGN(address+4);
83281 - else {
83282 - vma_unlock_anon_vma(vma);
83283 - return -ENOMEM;
83284 - }
83285 error = 0;
83286
83287 /* Somebody else might have raced and expanded it already */
83288 - if (address > vma->vm_end) {
83289 + 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)
83290 + error = -ENOMEM;
83291 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
83292 unsigned long size, grow;
83293
83294 size = address - vma->vm_start;
83295 @@ -2167,6 +2490,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83296 }
83297 }
83298 }
83299 + if (locknext)
83300 + vma_unlock_anon_vma(vma->vm_next);
83301 vma_unlock_anon_vma(vma);
83302 khugepaged_enter_vma_merge(vma);
83303 validate_mm(vma->vm_mm);
83304 @@ -2181,6 +2506,8 @@ int expand_downwards(struct vm_area_struct *vma,
83305 unsigned long address)
83306 {
83307 int error;
83308 + bool lockprev = false;
83309 + struct vm_area_struct *prev;
83310
83311 /*
83312 * We must make sure the anon_vma is allocated
83313 @@ -2194,6 +2521,15 @@ int expand_downwards(struct vm_area_struct *vma,
83314 if (error)
83315 return error;
83316
83317 + prev = vma->vm_prev;
83318 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
83319 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
83320 +#endif
83321 + if (lockprev && anon_vma_prepare(prev))
83322 + return -ENOMEM;
83323 + if (lockprev)
83324 + vma_lock_anon_vma(prev);
83325 +
83326 vma_lock_anon_vma(vma);
83327
83328 /*
83329 @@ -2203,9 +2539,17 @@ int expand_downwards(struct vm_area_struct *vma,
83330 */
83331
83332 /* Somebody else might have raced and expanded it already */
83333 - if (address < vma->vm_start) {
83334 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
83335 + error = -ENOMEM;
83336 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
83337 unsigned long size, grow;
83338
83339 +#ifdef CONFIG_PAX_SEGMEXEC
83340 + struct vm_area_struct *vma_m;
83341 +
83342 + vma_m = pax_find_mirror_vma(vma);
83343 +#endif
83344 +
83345 size = vma->vm_end - address;
83346 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83347
83348 @@ -2230,13 +2574,27 @@ int expand_downwards(struct vm_area_struct *vma,
83349 vma->vm_pgoff -= grow;
83350 anon_vma_interval_tree_post_update_vma(vma);
83351 vma_gap_update(vma);
83352 +
83353 +#ifdef CONFIG_PAX_SEGMEXEC
83354 + if (vma_m) {
83355 + anon_vma_interval_tree_pre_update_vma(vma_m);
83356 + vma_m->vm_start -= grow << PAGE_SHIFT;
83357 + vma_m->vm_pgoff -= grow;
83358 + anon_vma_interval_tree_post_update_vma(vma_m);
83359 + vma_gap_update(vma_m);
83360 + }
83361 +#endif
83362 +
83363 spin_unlock(&vma->vm_mm->page_table_lock);
83364
83365 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83366 perf_event_mmap(vma);
83367 }
83368 }
83369 }
83370 vma_unlock_anon_vma(vma);
83371 + if (lockprev)
83372 + vma_unlock_anon_vma(prev);
83373 khugepaged_enter_vma_merge(vma);
83374 validate_mm(vma->vm_mm);
83375 return error;
83376 @@ -2334,6 +2692,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83377 do {
83378 long nrpages = vma_pages(vma);
83379
83380 +#ifdef CONFIG_PAX_SEGMEXEC
83381 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83382 + vma = remove_vma(vma);
83383 + continue;
83384 + }
83385 +#endif
83386 +
83387 if (vma->vm_flags & VM_ACCOUNT)
83388 nr_accounted += nrpages;
83389 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83390 @@ -2379,6 +2744,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83391 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83392 vma->vm_prev = NULL;
83393 do {
83394 +
83395 +#ifdef CONFIG_PAX_SEGMEXEC
83396 + if (vma->vm_mirror) {
83397 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83398 + vma->vm_mirror->vm_mirror = NULL;
83399 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83400 + vma->vm_mirror = NULL;
83401 + }
83402 +#endif
83403 +
83404 vma_rb_erase(vma, &mm->mm_rb);
83405 mm->map_count--;
83406 tail_vma = vma;
83407 @@ -2410,14 +2785,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83408 struct vm_area_struct *new;
83409 int err = -ENOMEM;
83410
83411 +#ifdef CONFIG_PAX_SEGMEXEC
83412 + struct vm_area_struct *vma_m, *new_m = NULL;
83413 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83414 +#endif
83415 +
83416 if (is_vm_hugetlb_page(vma) && (addr &
83417 ~(huge_page_mask(hstate_vma(vma)))))
83418 return -EINVAL;
83419
83420 +#ifdef CONFIG_PAX_SEGMEXEC
83421 + vma_m = pax_find_mirror_vma(vma);
83422 +#endif
83423 +
83424 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83425 if (!new)
83426 goto out_err;
83427
83428 +#ifdef CONFIG_PAX_SEGMEXEC
83429 + if (vma_m) {
83430 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83431 + if (!new_m) {
83432 + kmem_cache_free(vm_area_cachep, new);
83433 + goto out_err;
83434 + }
83435 + }
83436 +#endif
83437 +
83438 /* most fields are the same, copy all, and then fixup */
83439 *new = *vma;
83440
83441 @@ -2430,6 +2824,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83442 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83443 }
83444
83445 +#ifdef CONFIG_PAX_SEGMEXEC
83446 + if (vma_m) {
83447 + *new_m = *vma_m;
83448 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83449 + new_m->vm_mirror = new;
83450 + new->vm_mirror = new_m;
83451 +
83452 + if (new_below)
83453 + new_m->vm_end = addr_m;
83454 + else {
83455 + new_m->vm_start = addr_m;
83456 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83457 + }
83458 + }
83459 +#endif
83460 +
83461 pol = mpol_dup(vma_policy(vma));
83462 if (IS_ERR(pol)) {
83463 err = PTR_ERR(pol);
83464 @@ -2452,6 +2862,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83465 else
83466 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83467
83468 +#ifdef CONFIG_PAX_SEGMEXEC
83469 + if (!err && vma_m) {
83470 + if (anon_vma_clone(new_m, vma_m))
83471 + goto out_free_mpol;
83472 +
83473 + mpol_get(pol);
83474 + vma_set_policy(new_m, pol);
83475 +
83476 + if (new_m->vm_file)
83477 + get_file(new_m->vm_file);
83478 +
83479 + if (new_m->vm_ops && new_m->vm_ops->open)
83480 + new_m->vm_ops->open(new_m);
83481 +
83482 + if (new_below)
83483 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83484 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83485 + else
83486 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83487 +
83488 + if (err) {
83489 + if (new_m->vm_ops && new_m->vm_ops->close)
83490 + new_m->vm_ops->close(new_m);
83491 + if (new_m->vm_file)
83492 + fput(new_m->vm_file);
83493 + mpol_put(pol);
83494 + }
83495 + }
83496 +#endif
83497 +
83498 /* Success. */
83499 if (!err)
83500 return 0;
83501 @@ -2461,10 +2901,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83502 new->vm_ops->close(new);
83503 if (new->vm_file)
83504 fput(new->vm_file);
83505 - unlink_anon_vmas(new);
83506 out_free_mpol:
83507 mpol_put(pol);
83508 out_free_vma:
83509 +
83510 +#ifdef CONFIG_PAX_SEGMEXEC
83511 + if (new_m) {
83512 + unlink_anon_vmas(new_m);
83513 + kmem_cache_free(vm_area_cachep, new_m);
83514 + }
83515 +#endif
83516 +
83517 + unlink_anon_vmas(new);
83518 kmem_cache_free(vm_area_cachep, new);
83519 out_err:
83520 return err;
83521 @@ -2477,6 +2925,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83522 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83523 unsigned long addr, int new_below)
83524 {
83525 +
83526 +#ifdef CONFIG_PAX_SEGMEXEC
83527 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83528 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83529 + if (mm->map_count >= sysctl_max_map_count-1)
83530 + return -ENOMEM;
83531 + } else
83532 +#endif
83533 +
83534 if (mm->map_count >= sysctl_max_map_count)
83535 return -ENOMEM;
83536
83537 @@ -2488,11 +2945,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83538 * work. This now handles partial unmappings.
83539 * Jeremy Fitzhardinge <jeremy@goop.org>
83540 */
83541 +#ifdef CONFIG_PAX_SEGMEXEC
83542 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83543 {
83544 + int ret = __do_munmap(mm, start, len);
83545 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83546 + return ret;
83547 +
83548 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83549 +}
83550 +
83551 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83552 +#else
83553 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83554 +#endif
83555 +{
83556 unsigned long end;
83557 struct vm_area_struct *vma, *prev, *last;
83558
83559 + /*
83560 + * mm->mmap_sem is required to protect against another thread
83561 + * changing the mappings in case we sleep.
83562 + */
83563 + verify_mm_writelocked(mm);
83564 +
83565 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83566 return -EINVAL;
83567
83568 @@ -2567,6 +3043,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83569 /* Fix up all other VM information */
83570 remove_vma_list(mm, vma);
83571
83572 + track_exec_limit(mm, start, end, 0UL);
83573 +
83574 return 0;
83575 }
83576
83577 @@ -2575,6 +3053,13 @@ int vm_munmap(unsigned long start, size_t len)
83578 int ret;
83579 struct mm_struct *mm = current->mm;
83580
83581 +
83582 +#ifdef CONFIG_PAX_SEGMEXEC
83583 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83584 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83585 + return -EINVAL;
83586 +#endif
83587 +
83588 down_write(&mm->mmap_sem);
83589 ret = do_munmap(mm, start, len);
83590 up_write(&mm->mmap_sem);
83591 @@ -2588,16 +3073,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83592 return vm_munmap(addr, len);
83593 }
83594
83595 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83596 -{
83597 -#ifdef CONFIG_DEBUG_VM
83598 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83599 - WARN_ON(1);
83600 - up_read(&mm->mmap_sem);
83601 - }
83602 -#endif
83603 -}
83604 -
83605 /*
83606 * this is really a simplified "do_mmap". it only handles
83607 * anonymous maps. eventually we may be able to do some
83608 @@ -2611,6 +3086,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83609 struct rb_node ** rb_link, * rb_parent;
83610 pgoff_t pgoff = addr >> PAGE_SHIFT;
83611 int error;
83612 + unsigned long charged;
83613
83614 len = PAGE_ALIGN(len);
83615 if (!len)
83616 @@ -2618,16 +3094,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83617
83618 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83619
83620 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83621 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83622 + flags &= ~VM_EXEC;
83623 +
83624 +#ifdef CONFIG_PAX_MPROTECT
83625 + if (mm->pax_flags & MF_PAX_MPROTECT)
83626 + flags &= ~VM_MAYEXEC;
83627 +#endif
83628 +
83629 + }
83630 +#endif
83631 +
83632 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83633 if (error & ~PAGE_MASK)
83634 return error;
83635
83636 + charged = len >> PAGE_SHIFT;
83637 +
83638 /*
83639 * mlock MCL_FUTURE?
83640 */
83641 if (mm->def_flags & VM_LOCKED) {
83642 unsigned long locked, lock_limit;
83643 - locked = len >> PAGE_SHIFT;
83644 + locked = charged;
83645 locked += mm->locked_vm;
83646 lock_limit = rlimit(RLIMIT_MEMLOCK);
83647 lock_limit >>= PAGE_SHIFT;
83648 @@ -2644,21 +3134,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83649 /*
83650 * Clear old maps. this also does some error checking for us
83651 */
83652 - munmap_back:
83653 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83654 if (do_munmap(mm, addr, len))
83655 return -ENOMEM;
83656 - goto munmap_back;
83657 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83658 }
83659
83660 /* Check against address space limits *after* clearing old maps... */
83661 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83662 + if (!may_expand_vm(mm, charged))
83663 return -ENOMEM;
83664
83665 if (mm->map_count > sysctl_max_map_count)
83666 return -ENOMEM;
83667
83668 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83669 + if (security_vm_enough_memory_mm(mm, charged))
83670 return -ENOMEM;
83671
83672 /* Can we just expand an old private anonymous mapping? */
83673 @@ -2672,7 +3161,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83674 */
83675 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83676 if (!vma) {
83677 - vm_unacct_memory(len >> PAGE_SHIFT);
83678 + vm_unacct_memory(charged);
83679 return -ENOMEM;
83680 }
83681
83682 @@ -2686,9 +3175,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83683 vma_link(mm, vma, prev, rb_link, rb_parent);
83684 out:
83685 perf_event_mmap(vma);
83686 - mm->total_vm += len >> PAGE_SHIFT;
83687 + mm->total_vm += charged;
83688 if (flags & VM_LOCKED)
83689 - mm->locked_vm += (len >> PAGE_SHIFT);
83690 + mm->locked_vm += charged;
83691 + track_exec_limit(mm, addr, addr + len, flags);
83692 return addr;
83693 }
83694
83695 @@ -2750,6 +3240,7 @@ void exit_mmap(struct mm_struct *mm)
83696 while (vma) {
83697 if (vma->vm_flags & VM_ACCOUNT)
83698 nr_accounted += vma_pages(vma);
83699 + vma->vm_mirror = NULL;
83700 vma = remove_vma(vma);
83701 }
83702 vm_unacct_memory(nr_accounted);
83703 @@ -2766,6 +3257,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83704 struct vm_area_struct *prev;
83705 struct rb_node **rb_link, *rb_parent;
83706
83707 +#ifdef CONFIG_PAX_SEGMEXEC
83708 + struct vm_area_struct *vma_m = NULL;
83709 +#endif
83710 +
83711 + if (security_mmap_addr(vma->vm_start))
83712 + return -EPERM;
83713 +
83714 /*
83715 * The vm_pgoff of a purely anonymous vma should be irrelevant
83716 * until its first write fault, when page's anon_vma and index
83717 @@ -2789,7 +3287,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83718 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83719 return -ENOMEM;
83720
83721 +#ifdef CONFIG_PAX_SEGMEXEC
83722 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83723 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83724 + if (!vma_m)
83725 + return -ENOMEM;
83726 + }
83727 +#endif
83728 +
83729 vma_link(mm, vma, prev, rb_link, rb_parent);
83730 +
83731 +#ifdef CONFIG_PAX_SEGMEXEC
83732 + if (vma_m)
83733 + BUG_ON(pax_mirror_vma(vma_m, vma));
83734 +#endif
83735 +
83736 return 0;
83737 }
83738
83739 @@ -2809,6 +3321,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83740 struct mempolicy *pol;
83741 bool faulted_in_anon_vma = true;
83742
83743 + BUG_ON(vma->vm_mirror);
83744 +
83745 /*
83746 * If anonymous vma has not yet been faulted, update new pgoff
83747 * to match new location, to increase its chance of merging.
83748 @@ -2875,6 +3389,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83749 return NULL;
83750 }
83751
83752 +#ifdef CONFIG_PAX_SEGMEXEC
83753 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83754 +{
83755 + struct vm_area_struct *prev_m;
83756 + struct rb_node **rb_link_m, *rb_parent_m;
83757 + struct mempolicy *pol_m;
83758 +
83759 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83760 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83761 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83762 + *vma_m = *vma;
83763 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83764 + if (anon_vma_clone(vma_m, vma))
83765 + return -ENOMEM;
83766 + pol_m = vma_policy(vma_m);
83767 + mpol_get(pol_m);
83768 + vma_set_policy(vma_m, pol_m);
83769 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83770 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83771 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83772 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83773 + if (vma_m->vm_file)
83774 + get_file(vma_m->vm_file);
83775 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83776 + vma_m->vm_ops->open(vma_m);
83777 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83778 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83779 + vma_m->vm_mirror = vma;
83780 + vma->vm_mirror = vma_m;
83781 + return 0;
83782 +}
83783 +#endif
83784 +
83785 /*
83786 * Return true if the calling process may expand its vm space by the passed
83787 * number of pages
83788 @@ -2886,6 +3433,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83789
83790 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83791
83792 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83793 if (cur + npages > lim)
83794 return 0;
83795 return 1;
83796 @@ -2956,6 +3504,22 @@ int install_special_mapping(struct mm_struct *mm,
83797 vma->vm_start = addr;
83798 vma->vm_end = addr + len;
83799
83800 +#ifdef CONFIG_PAX_MPROTECT
83801 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83802 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83803 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83804 + return -EPERM;
83805 + if (!(vm_flags & VM_EXEC))
83806 + vm_flags &= ~VM_MAYEXEC;
83807 +#else
83808 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83809 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83810 +#endif
83811 + else
83812 + vm_flags &= ~VM_MAYWRITE;
83813 + }
83814 +#endif
83815 +
83816 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83817 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83818
83819 diff --git a/mm/mprotect.c b/mm/mprotect.c
83820 index 94722a4..07d9926 100644
83821 --- a/mm/mprotect.c
83822 +++ b/mm/mprotect.c
83823 @@ -23,10 +23,18 @@
83824 #include <linux/mmu_notifier.h>
83825 #include <linux/migrate.h>
83826 #include <linux/perf_event.h>
83827 +#include <linux/sched/sysctl.h>
83828 +
83829 +#ifdef CONFIG_PAX_MPROTECT
83830 +#include <linux/elf.h>
83831 +#include <linux/binfmts.h>
83832 +#endif
83833 +
83834 #include <asm/uaccess.h>
83835 #include <asm/pgtable.h>
83836 #include <asm/cacheflush.h>
83837 #include <asm/tlbflush.h>
83838 +#include <asm/mmu_context.h>
83839
83840 #ifndef pgprot_modify
83841 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83842 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83843 return pages;
83844 }
83845
83846 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83847 +/* called while holding the mmap semaphor for writing except stack expansion */
83848 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83849 +{
83850 + unsigned long oldlimit, newlimit = 0UL;
83851 +
83852 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83853 + return;
83854 +
83855 + spin_lock(&mm->page_table_lock);
83856 + oldlimit = mm->context.user_cs_limit;
83857 + if ((prot & VM_EXEC) && oldlimit < end)
83858 + /* USER_CS limit moved up */
83859 + newlimit = end;
83860 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83861 + /* USER_CS limit moved down */
83862 + newlimit = start;
83863 +
83864 + if (newlimit) {
83865 + mm->context.user_cs_limit = newlimit;
83866 +
83867 +#ifdef CONFIG_SMP
83868 + wmb();
83869 + cpus_clear(mm->context.cpu_user_cs_mask);
83870 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83871 +#endif
83872 +
83873 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83874 + }
83875 + spin_unlock(&mm->page_table_lock);
83876 + if (newlimit == end) {
83877 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83878 +
83879 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83880 + if (is_vm_hugetlb_page(vma))
83881 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83882 + else
83883 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83884 + }
83885 +}
83886 +#endif
83887 +
83888 int
83889 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83890 unsigned long start, unsigned long end, unsigned long newflags)
83891 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83892 int error;
83893 int dirty_accountable = 0;
83894
83895 +#ifdef CONFIG_PAX_SEGMEXEC
83896 + struct vm_area_struct *vma_m = NULL;
83897 + unsigned long start_m, end_m;
83898 +
83899 + start_m = start + SEGMEXEC_TASK_SIZE;
83900 + end_m = end + SEGMEXEC_TASK_SIZE;
83901 +#endif
83902 +
83903 if (newflags == oldflags) {
83904 *pprev = vma;
83905 return 0;
83906 }
83907
83908 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83909 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83910 +
83911 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83912 + return -ENOMEM;
83913 +
83914 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83915 + return -ENOMEM;
83916 + }
83917 +
83918 /*
83919 * If we make a private mapping writable we increase our commit;
83920 * but (without finer accounting) cannot reduce our commit if we
83921 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83922 }
83923 }
83924
83925 +#ifdef CONFIG_PAX_SEGMEXEC
83926 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83927 + if (start != vma->vm_start) {
83928 + error = split_vma(mm, vma, start, 1);
83929 + if (error)
83930 + goto fail;
83931 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83932 + *pprev = (*pprev)->vm_next;
83933 + }
83934 +
83935 + if (end != vma->vm_end) {
83936 + error = split_vma(mm, vma, end, 0);
83937 + if (error)
83938 + goto fail;
83939 + }
83940 +
83941 + if (pax_find_mirror_vma(vma)) {
83942 + error = __do_munmap(mm, start_m, end_m - start_m);
83943 + if (error)
83944 + goto fail;
83945 + } else {
83946 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83947 + if (!vma_m) {
83948 + error = -ENOMEM;
83949 + goto fail;
83950 + }
83951 + vma->vm_flags = newflags;
83952 + error = pax_mirror_vma(vma_m, vma);
83953 + if (error) {
83954 + vma->vm_flags = oldflags;
83955 + goto fail;
83956 + }
83957 + }
83958 + }
83959 +#endif
83960 +
83961 /*
83962 * First try to merge with previous and/or next vma.
83963 */
83964 @@ -296,9 +400,21 @@ success:
83965 * vm_flags and vm_page_prot are protected by the mmap_sem
83966 * held in write mode.
83967 */
83968 +
83969 +#ifdef CONFIG_PAX_SEGMEXEC
83970 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83971 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83972 +#endif
83973 +
83974 vma->vm_flags = newflags;
83975 +
83976 +#ifdef CONFIG_PAX_MPROTECT
83977 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83978 + mm->binfmt->handle_mprotect(vma, newflags);
83979 +#endif
83980 +
83981 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83982 - vm_get_page_prot(newflags));
83983 + vm_get_page_prot(vma->vm_flags));
83984
83985 if (vma_wants_writenotify(vma)) {
83986 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83987 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83988 end = start + len;
83989 if (end <= start)
83990 return -ENOMEM;
83991 +
83992 +#ifdef CONFIG_PAX_SEGMEXEC
83993 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83994 + if (end > SEGMEXEC_TASK_SIZE)
83995 + return -EINVAL;
83996 + } else
83997 +#endif
83998 +
83999 + if (end > TASK_SIZE)
84000 + return -EINVAL;
84001 +
84002 if (!arch_validate_prot(prot))
84003 return -EINVAL;
84004
84005 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84006 /*
84007 * Does the application expect PROT_READ to imply PROT_EXEC:
84008 */
84009 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
84010 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
84011 prot |= PROT_EXEC;
84012
84013 vm_flags = calc_vm_prot_bits(prot);
84014 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84015 if (start > vma->vm_start)
84016 prev = vma;
84017
84018 +#ifdef CONFIG_PAX_MPROTECT
84019 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
84020 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
84021 +#endif
84022 +
84023 for (nstart = start ; ; ) {
84024 unsigned long newflags;
84025
84026 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84027
84028 /* newflags >> 4 shift VM_MAY% in place of VM_% */
84029 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
84030 + if (prot & (PROT_WRITE | PROT_EXEC))
84031 + gr_log_rwxmprotect(vma->vm_file);
84032 +
84033 + error = -EACCES;
84034 + goto out;
84035 + }
84036 +
84037 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
84038 error = -EACCES;
84039 goto out;
84040 }
84041 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84042 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
84043 if (error)
84044 goto out;
84045 +
84046 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
84047 +
84048 nstart = tmp;
84049
84050 if (nstart < prev->vm_end)
84051 diff --git a/mm/mremap.c b/mm/mremap.c
84052 index 463a257..c0c7a92 100644
84053 --- a/mm/mremap.c
84054 +++ b/mm/mremap.c
84055 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
84056 continue;
84057 pte = ptep_get_and_clear(mm, old_addr, old_pte);
84058 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
84059 +
84060 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84061 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
84062 + pte = pte_exprotect(pte);
84063 +#endif
84064 +
84065 set_pte_at(mm, new_addr, new_pte, pte);
84066 }
84067
84068 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
84069 if (is_vm_hugetlb_page(vma))
84070 goto Einval;
84071
84072 +#ifdef CONFIG_PAX_SEGMEXEC
84073 + if (pax_find_mirror_vma(vma))
84074 + goto Einval;
84075 +#endif
84076 +
84077 /* We can't remap across vm area boundaries */
84078 if (old_len > vma->vm_end - addr)
84079 goto Efault;
84080 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
84081 unsigned long ret = -EINVAL;
84082 unsigned long charged = 0;
84083 unsigned long map_flags;
84084 + unsigned long pax_task_size = TASK_SIZE;
84085
84086 if (new_addr & ~PAGE_MASK)
84087 goto out;
84088
84089 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
84090 +#ifdef CONFIG_PAX_SEGMEXEC
84091 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84092 + pax_task_size = SEGMEXEC_TASK_SIZE;
84093 +#endif
84094 +
84095 + pax_task_size -= PAGE_SIZE;
84096 +
84097 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
84098 goto out;
84099
84100 /* Check if the location we're moving into overlaps the
84101 * old location at all, and fail if it does.
84102 */
84103 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
84104 - goto out;
84105 -
84106 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
84107 + if (addr + old_len > new_addr && new_addr + new_len > addr)
84108 goto out;
84109
84110 ret = do_munmap(mm, new_addr, new_len);
84111 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84112 unsigned long ret = -EINVAL;
84113 unsigned long charged = 0;
84114 bool locked = false;
84115 + unsigned long pax_task_size = TASK_SIZE;
84116
84117 down_write(&current->mm->mmap_sem);
84118
84119 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84120 if (!new_len)
84121 goto out;
84122
84123 +#ifdef CONFIG_PAX_SEGMEXEC
84124 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84125 + pax_task_size = SEGMEXEC_TASK_SIZE;
84126 +#endif
84127 +
84128 + pax_task_size -= PAGE_SIZE;
84129 +
84130 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
84131 + old_len > pax_task_size || addr > pax_task_size-old_len)
84132 + goto out;
84133 +
84134 if (flags & MREMAP_FIXED) {
84135 if (flags & MREMAP_MAYMOVE)
84136 ret = mremap_to(addr, old_len, new_addr, new_len,
84137 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84138 new_addr = addr;
84139 }
84140 ret = addr;
84141 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
84142 goto out;
84143 }
84144 }
84145 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84146 goto out;
84147 }
84148
84149 + map_flags = vma->vm_flags;
84150 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
84151 + if (!(ret & ~PAGE_MASK)) {
84152 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84153 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84154 + }
84155 }
84156 out:
84157 if (ret & ~PAGE_MASK)
84158 diff --git a/mm/nommu.c b/mm/nommu.c
84159 index 298884d..5f74980 100644
84160 --- a/mm/nommu.c
84161 +++ b/mm/nommu.c
84162 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84163 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84164 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
84165 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
84166 -int heap_stack_gap = 0;
84167
84168 atomic_long_t mmap_pages_allocated;
84169
84170 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84171 EXPORT_SYMBOL(find_vma);
84172
84173 /*
84174 - * find a VMA
84175 - * - we don't extend stack VMAs under NOMMU conditions
84176 - */
84177 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84178 -{
84179 - return find_vma(mm, addr);
84180 -}
84181 -
84182 -/*
84183 * expand a stack to a given address
84184 * - not supported under NOMMU conditions
84185 */
84186 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84187
84188 /* most fields are the same, copy all, and then fixup */
84189 *new = *vma;
84190 + INIT_LIST_HEAD(&new->anon_vma_chain);
84191 *region = *vma->vm_region;
84192 new->vm_region = region;
84193
84194 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84195 }
84196 EXPORT_SYMBOL(generic_file_remap_pages);
84197
84198 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84199 - unsigned long addr, void *buf, int len, int write)
84200 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84201 + unsigned long addr, void *buf, size_t len, int write)
84202 {
84203 struct vm_area_struct *vma;
84204
84205 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84206 *
84207 * The caller must hold a reference on @mm.
84208 */
84209 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84210 - void *buf, int len, int write)
84211 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84212 + void *buf, size_t len, int write)
84213 {
84214 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84215 }
84216 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84217 * Access another process' address space.
84218 * - source/target buffer must be kernel space
84219 */
84220 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84221 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84222 {
84223 struct mm_struct *mm;
84224
84225 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
84226 index 4514ad7..92eaa1c 100644
84227 --- a/mm/page-writeback.c
84228 +++ b/mm/page-writeback.c
84229 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
84230 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
84231 * - the bdi dirty thresh drops quickly due to change of JBOD workload
84232 */
84233 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
84234 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
84235 unsigned long thresh,
84236 unsigned long bg_thresh,
84237 unsigned long dirty,
84238 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
84239 }
84240 }
84241
84242 -static struct notifier_block __cpuinitdata ratelimit_nb = {
84243 +static struct notifier_block ratelimit_nb = {
84244 .notifier_call = ratelimit_handler,
84245 .next = NULL,
84246 };
84247 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
84248 index c3edb62..2d60097 100644
84249 --- a/mm/page_alloc.c
84250 +++ b/mm/page_alloc.c
84251 @@ -60,6 +60,7 @@
84252 #include <linux/page-debug-flags.h>
84253 #include <linux/hugetlb.h>
84254 #include <linux/sched/rt.h>
84255 +#include <linux/random.h>
84256
84257 #include <asm/tlbflush.h>
84258 #include <asm/div64.h>
84259 @@ -345,7 +346,7 @@ out:
84260 * This usage means that zero-order pages may not be compound.
84261 */
84262
84263 -static void free_compound_page(struct page *page)
84264 +void free_compound_page(struct page *page)
84265 {
84266 __free_pages_ok(page, compound_order(page));
84267 }
84268 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84269 int i;
84270 int bad = 0;
84271
84272 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84273 + unsigned long index = 1UL << order;
84274 +#endif
84275 +
84276 trace_mm_page_free(page, order);
84277 kmemcheck_free_shadow(page, order);
84278
84279 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84280 debug_check_no_obj_freed(page_address(page),
84281 PAGE_SIZE << order);
84282 }
84283 +
84284 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84285 + for (; index; --index)
84286 + sanitize_highpage(page + index - 1);
84287 +#endif
84288 +
84289 arch_free_page(page, order);
84290 kernel_map_pages(page, 1 << order, 0);
84291
84292 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
84293 local_irq_restore(flags);
84294 }
84295
84296 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84297 +bool __meminitdata extra_latent_entropy;
84298 +
84299 +static int __init setup_pax_extra_latent_entropy(char *str)
84300 +{
84301 + extra_latent_entropy = true;
84302 + return 0;
84303 +}
84304 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
84305 +
84306 +volatile u64 latent_entropy;
84307 +#endif
84308 +
84309 /*
84310 * Read access to zone->managed_pages is safe because it's unsigned long,
84311 * but we still need to serialize writers. Currently all callers of
84312 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
84313 set_page_count(p, 0);
84314 }
84315
84316 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84317 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
84318 + u64 hash = 0;
84319 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
84320 + const u64 *data = lowmem_page_address(page);
84321 +
84322 + for (index = 0; index < end; index++)
84323 + hash ^= hash + data[index];
84324 + latent_entropy ^= hash;
84325 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
84326 + }
84327 +#endif
84328 +
84329 page_zone(page)->managed_pages += 1 << order;
84330 set_page_refcounted(page);
84331 __free_pages(page, order);
84332 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
84333 arch_alloc_page(page, order);
84334 kernel_map_pages(page, 1 << order, 1);
84335
84336 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
84337 if (gfp_flags & __GFP_ZERO)
84338 prep_zero_page(page, order, gfp_flags);
84339 +#endif
84340
84341 if (order && (gfp_flags & __GFP_COMP))
84342 prep_compound_page(page, order);
84343 diff --git a/mm/page_io.c b/mm/page_io.c
84344 index a8a3ef4..7260a60 100644
84345 --- a/mm/page_io.c
84346 +++ b/mm/page_io.c
84347 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
84348 struct file *swap_file = sis->swap_file;
84349 struct address_space *mapping = swap_file->f_mapping;
84350 struct iovec iov = {
84351 - .iov_base = kmap(page),
84352 + .iov_base = (void __force_user *)kmap(page),
84353 .iov_len = PAGE_SIZE,
84354 };
84355
84356 diff --git a/mm/percpu.c b/mm/percpu.c
84357 index 8c8e08f..73a5cda 100644
84358 --- a/mm/percpu.c
84359 +++ b/mm/percpu.c
84360 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84361 static unsigned int pcpu_high_unit_cpu __read_mostly;
84362
84363 /* the address of the first chunk which starts with the kernel static area */
84364 -void *pcpu_base_addr __read_mostly;
84365 +void *pcpu_base_addr __read_only;
84366 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84367
84368 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84369 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84370 index fd26d04..0cea1b0 100644
84371 --- a/mm/process_vm_access.c
84372 +++ b/mm/process_vm_access.c
84373 @@ -13,6 +13,7 @@
84374 #include <linux/uio.h>
84375 #include <linux/sched.h>
84376 #include <linux/highmem.h>
84377 +#include <linux/security.h>
84378 #include <linux/ptrace.h>
84379 #include <linux/slab.h>
84380 #include <linux/syscalls.h>
84381 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84382 size_t iov_l_curr_offset = 0;
84383 ssize_t iov_len;
84384
84385 + return -ENOSYS; // PaX: until properly audited
84386 +
84387 /*
84388 * Work out how many pages of struct pages we're going to need
84389 * when eventually calling get_user_pages
84390 */
84391 for (i = 0; i < riovcnt; i++) {
84392 iov_len = rvec[i].iov_len;
84393 - if (iov_len > 0) {
84394 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84395 - + iov_len)
84396 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84397 - / PAGE_SIZE + 1;
84398 - nr_pages = max(nr_pages, nr_pages_iov);
84399 - }
84400 + if (iov_len <= 0)
84401 + continue;
84402 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84403 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84404 + nr_pages = max(nr_pages, nr_pages_iov);
84405 }
84406
84407 if (nr_pages == 0)
84408 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84409 goto free_proc_pages;
84410 }
84411
84412 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84413 + rc = -EPERM;
84414 + goto put_task_struct;
84415 + }
84416 +
84417 mm = mm_access(task, PTRACE_MODE_ATTACH);
84418 if (!mm || IS_ERR(mm)) {
84419 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84420 diff --git a/mm/rmap.c b/mm/rmap.c
84421 index 6280da8..ecce194 100644
84422 --- a/mm/rmap.c
84423 +++ b/mm/rmap.c
84424 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84425 struct anon_vma *anon_vma = vma->anon_vma;
84426 struct anon_vma_chain *avc;
84427
84428 +#ifdef CONFIG_PAX_SEGMEXEC
84429 + struct anon_vma_chain *avc_m = NULL;
84430 +#endif
84431 +
84432 might_sleep();
84433 if (unlikely(!anon_vma)) {
84434 struct mm_struct *mm = vma->vm_mm;
84435 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84436 if (!avc)
84437 goto out_enomem;
84438
84439 +#ifdef CONFIG_PAX_SEGMEXEC
84440 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84441 + if (!avc_m)
84442 + goto out_enomem_free_avc;
84443 +#endif
84444 +
84445 anon_vma = find_mergeable_anon_vma(vma);
84446 allocated = NULL;
84447 if (!anon_vma) {
84448 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84449 /* page_table_lock to protect against threads */
84450 spin_lock(&mm->page_table_lock);
84451 if (likely(!vma->anon_vma)) {
84452 +
84453 +#ifdef CONFIG_PAX_SEGMEXEC
84454 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84455 +
84456 + if (vma_m) {
84457 + BUG_ON(vma_m->anon_vma);
84458 + vma_m->anon_vma = anon_vma;
84459 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84460 + avc_m = NULL;
84461 + }
84462 +#endif
84463 +
84464 vma->anon_vma = anon_vma;
84465 anon_vma_chain_link(vma, avc, anon_vma);
84466 allocated = NULL;
84467 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84468
84469 if (unlikely(allocated))
84470 put_anon_vma(allocated);
84471 +
84472 +#ifdef CONFIG_PAX_SEGMEXEC
84473 + if (unlikely(avc_m))
84474 + anon_vma_chain_free(avc_m);
84475 +#endif
84476 +
84477 if (unlikely(avc))
84478 anon_vma_chain_free(avc);
84479 }
84480 return 0;
84481
84482 out_enomem_free_avc:
84483 +
84484 +#ifdef CONFIG_PAX_SEGMEXEC
84485 + if (avc_m)
84486 + anon_vma_chain_free(avc_m);
84487 +#endif
84488 +
84489 anon_vma_chain_free(avc);
84490 out_enomem:
84491 return -ENOMEM;
84492 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84493 * Attach the anon_vmas from src to dst.
84494 * Returns 0 on success, -ENOMEM on failure.
84495 */
84496 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84497 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84498 {
84499 struct anon_vma_chain *avc, *pavc;
84500 struct anon_vma *root = NULL;
84501 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84502 * the corresponding VMA in the parent process is attached to.
84503 * Returns 0 on success, non-zero on failure.
84504 */
84505 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84506 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84507 {
84508 struct anon_vma_chain *avc;
84509 struct anon_vma *anon_vma;
84510 diff --git a/mm/shmem.c b/mm/shmem.c
84511 index 5e6a842..b41916e 100644
84512 --- a/mm/shmem.c
84513 +++ b/mm/shmem.c
84514 @@ -33,7 +33,7 @@
84515 #include <linux/swap.h>
84516 #include <linux/aio.h>
84517
84518 -static struct vfsmount *shm_mnt;
84519 +struct vfsmount *shm_mnt;
84520
84521 #ifdef CONFIG_SHMEM
84522 /*
84523 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
84524 #define BOGO_DIRENT_SIZE 20
84525
84526 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84527 -#define SHORT_SYMLINK_LEN 128
84528 +#define SHORT_SYMLINK_LEN 64
84529
84530 /*
84531 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84532 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84533 static int shmem_xattr_validate(const char *name)
84534 {
84535 struct { const char *prefix; size_t len; } arr[] = {
84536 +
84537 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84538 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84539 +#endif
84540 +
84541 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84542 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84543 };
84544 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84545 if (err)
84546 return err;
84547
84548 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84549 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84550 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84551 + return -EOPNOTSUPP;
84552 + if (size > 8)
84553 + return -EINVAL;
84554 + }
84555 +#endif
84556 +
84557 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84558 }
84559
84560 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84561 int err = -ENOMEM;
84562
84563 /* Round up to L1_CACHE_BYTES to resist false sharing */
84564 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84565 - L1_CACHE_BYTES), GFP_KERNEL);
84566 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84567 if (!sbinfo)
84568 return -ENOMEM;
84569
84570 diff --git a/mm/slab.c b/mm/slab.c
84571 index 8ccd296..012fe4e 100644
84572 --- a/mm/slab.c
84573 +++ b/mm/slab.c
84574 @@ -366,10 +366,10 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
84575 if ((x)->max_freeable < i) \
84576 (x)->max_freeable = i; \
84577 } while (0)
84578 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84579 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84580 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84581 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84582 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84583 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84584 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84585 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84586 #else
84587 #define STATS_INC_ACTIVE(x) do { } while (0)
84588 #define STATS_DEC_ACTIVE(x) do { } while (0)
84589 @@ -477,7 +477,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84590 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84591 */
84592 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84593 - const struct slab *slab, void *obj)
84594 + const struct slab *slab, const void *obj)
84595 {
84596 u32 offset = (obj - slab->s_mem);
84597 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84598 @@ -1384,7 +1384,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84599 return notifier_from_errno(err);
84600 }
84601
84602 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84603 +static struct notifier_block cpucache_notifier = {
84604 &cpuup_callback, NULL, 0
84605 };
84606
84607 @@ -1565,12 +1565,12 @@ void __init kmem_cache_init(void)
84608 */
84609
84610 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
84611 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
84612 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
84613
84614 if (INDEX_AC != INDEX_NODE)
84615 kmalloc_caches[INDEX_NODE] =
84616 create_kmalloc_cache("kmalloc-node",
84617 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
84618 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
84619
84620 slab_early_init = 0;
84621
84622 @@ -3800,6 +3800,7 @@ void kfree(const void *objp)
84623
84624 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84625 return;
84626 + VM_BUG_ON(!virt_addr_valid(objp));
84627 local_irq_save(flags);
84628 kfree_debugcheck(objp);
84629 c = virt_to_cache(objp);
84630 @@ -4241,10 +4242,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84631 }
84632 /* cpu stats */
84633 {
84634 - unsigned long allochit = atomic_read(&cachep->allochit);
84635 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84636 - unsigned long freehit = atomic_read(&cachep->freehit);
84637 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84638 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84639 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84640 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84641 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84642
84643 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84644 allochit, allocmiss, freehit, freemiss);
84645 @@ -4476,13 +4477,71 @@ static const struct file_operations proc_slabstats_operations = {
84646 static int __init slab_proc_init(void)
84647 {
84648 #ifdef CONFIG_DEBUG_SLAB_LEAK
84649 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84650 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84651 #endif
84652 return 0;
84653 }
84654 module_init(slab_proc_init);
84655 #endif
84656
84657 +bool is_usercopy_object(const void *ptr)
84658 +{
84659 + struct page *page;
84660 + struct kmem_cache *cachep;
84661 +
84662 + if (ZERO_OR_NULL_PTR(ptr))
84663 + return false;
84664 +
84665 + if (!slab_is_available())
84666 + return false;
84667 +
84668 + if (!virt_addr_valid(ptr))
84669 + return false;
84670 +
84671 + page = virt_to_head_page(ptr);
84672 +
84673 + if (!PageSlab(page))
84674 + return false;
84675 +
84676 + cachep = page->slab_cache;
84677 + return cachep->flags & SLAB_USERCOPY;
84678 +}
84679 +
84680 +#ifdef CONFIG_PAX_USERCOPY
84681 +const char *check_heap_object(const void *ptr, unsigned long n)
84682 +{
84683 + struct page *page;
84684 + struct kmem_cache *cachep;
84685 + struct slab *slabp;
84686 + unsigned int objnr;
84687 + unsigned long offset;
84688 +
84689 + if (ZERO_OR_NULL_PTR(ptr))
84690 + return "<null>";
84691 +
84692 + if (!virt_addr_valid(ptr))
84693 + return NULL;
84694 +
84695 + page = virt_to_head_page(ptr);
84696 +
84697 + if (!PageSlab(page))
84698 + return NULL;
84699 +
84700 + cachep = page->slab_cache;
84701 + if (!(cachep->flags & SLAB_USERCOPY))
84702 + return cachep->name;
84703 +
84704 + slabp = page->slab_page;
84705 + objnr = obj_to_index(cachep, slabp, ptr);
84706 + BUG_ON(objnr >= cachep->num);
84707 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84708 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84709 + return NULL;
84710 +
84711 + return cachep->name;
84712 +}
84713 +#endif
84714 +
84715 /**
84716 * ksize - get the actual amount of memory allocated for a given object
84717 * @objp: Pointer to the object
84718 diff --git a/mm/slab.h b/mm/slab.h
84719 index f96b49e..5634e90 100644
84720 --- a/mm/slab.h
84721 +++ b/mm/slab.h
84722 @@ -67,7 +67,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84723
84724 /* Legal flag mask for kmem_cache_create(), for various configurations */
84725 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84726 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84727 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84728
84729 #if defined(CONFIG_DEBUG_SLAB)
84730 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84731 @@ -229,6 +229,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84732 return s;
84733
84734 page = virt_to_head_page(x);
84735 +
84736 + BUG_ON(!PageSlab(page));
84737 +
84738 cachep = page->slab_cache;
84739 if (slab_equal_or_root(cachep, s))
84740 return cachep;
84741 diff --git a/mm/slab_common.c b/mm/slab_common.c
84742 index 2d41450..e22088e 100644
84743 --- a/mm/slab_common.c
84744 +++ b/mm/slab_common.c
84745 @@ -22,7 +22,7 @@
84746
84747 #include "slab.h"
84748
84749 -enum slab_state slab_state;
84750 +enum slab_state slab_state __read_only;
84751 LIST_HEAD(slab_caches);
84752 DEFINE_MUTEX(slab_mutex);
84753 struct kmem_cache *kmem_cache;
84754 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84755
84756 err = __kmem_cache_create(s, flags);
84757 if (!err) {
84758 - s->refcount = 1;
84759 + atomic_set(&s->refcount, 1);
84760 list_add(&s->list, &slab_caches);
84761 memcg_cache_list_add(memcg, s);
84762 } else {
84763 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84764
84765 get_online_cpus();
84766 mutex_lock(&slab_mutex);
84767 - s->refcount--;
84768 - if (!s->refcount) {
84769 + if (atomic_dec_and_test(&s->refcount)) {
84770 list_del(&s->list);
84771
84772 if (!__kmem_cache_shutdown(s)) {
84773 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84774 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
84775 name, size, err);
84776
84777 - s->refcount = -1; /* Exempt from merging for now */
84778 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84779 }
84780
84781 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84782 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84783
84784 create_boot_cache(s, name, size, flags);
84785 list_add(&s->list, &slab_caches);
84786 - s->refcount = 1;
84787 + atomic_set(&s->refcount, 1);
84788 return s;
84789 }
84790
84791 @@ -327,6 +326,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
84792 EXPORT_SYMBOL(kmalloc_dma_caches);
84793 #endif
84794
84795 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84796 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
84797 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
84798 +#endif
84799 +
84800 /*
84801 * Conversion table for small slabs sizes / 8 to the index in the
84802 * kmalloc array. This is necessary for slabs < 192 since we have non power
84803 @@ -391,6 +395,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
84804 return kmalloc_dma_caches[index];
84805
84806 #endif
84807 +
84808 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84809 + if (unlikely((flags & GFP_USERCOPY)))
84810 + return kmalloc_usercopy_caches[index];
84811 +
84812 +#endif
84813 +
84814 return kmalloc_caches[index];
84815 }
84816
84817 @@ -447,7 +458,7 @@ void __init create_kmalloc_caches(unsigned long flags)
84818 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
84819 if (!kmalloc_caches[i]) {
84820 kmalloc_caches[i] = create_kmalloc_cache(NULL,
84821 - 1 << i, flags);
84822 + 1 << i, SLAB_USERCOPY | flags);
84823 }
84824
84825 /*
84826 @@ -456,10 +467,10 @@ void __init create_kmalloc_caches(unsigned long flags)
84827 * earlier power of two caches
84828 */
84829 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
84830 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
84831 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
84832
84833 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
84834 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
84835 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
84836 }
84837
84838 /* Kmalloc array is now usable */
84839 @@ -492,6 +503,23 @@ void __init create_kmalloc_caches(unsigned long flags)
84840 }
84841 }
84842 #endif
84843 +
84844 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84845 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
84846 + struct kmem_cache *s = kmalloc_caches[i];
84847 +
84848 + if (s) {
84849 + int size = kmalloc_size(i);
84850 + char *n = kasprintf(GFP_NOWAIT,
84851 + "usercopy-kmalloc-%d", size);
84852 +
84853 + BUG_ON(!n);
84854 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
84855 + size, SLAB_USERCOPY | flags);
84856 + }
84857 + }
84858 +#endif
84859 +
84860 }
84861 #endif /* !CONFIG_SLOB */
84862
84863 diff --git a/mm/slob.c b/mm/slob.c
84864 index eeed4a0..c414c12 100644
84865 --- a/mm/slob.c
84866 +++ b/mm/slob.c
84867 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84868 /*
84869 * Return the size of a slob block.
84870 */
84871 -static slobidx_t slob_units(slob_t *s)
84872 +static slobidx_t slob_units(const slob_t *s)
84873 {
84874 if (s->units > 0)
84875 return s->units;
84876 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84877 /*
84878 * Return the next free slob block pointer after this one.
84879 */
84880 -static slob_t *slob_next(slob_t *s)
84881 +static slob_t *slob_next(const slob_t *s)
84882 {
84883 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84884 slobidx_t next;
84885 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84886 /*
84887 * Returns true if s is the last free block in its page.
84888 */
84889 -static int slob_last(slob_t *s)
84890 +static int slob_last(const slob_t *s)
84891 {
84892 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84893 }
84894
84895 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84896 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84897 {
84898 - void *page;
84899 + struct page *page;
84900
84901 #ifdef CONFIG_NUMA
84902 if (node != NUMA_NO_NODE)
84903 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84904 if (!page)
84905 return NULL;
84906
84907 - return page_address(page);
84908 + __SetPageSlab(page);
84909 + return page;
84910 }
84911
84912 -static void slob_free_pages(void *b, int order)
84913 +static void slob_free_pages(struct page *sp, int order)
84914 {
84915 if (current->reclaim_state)
84916 current->reclaim_state->reclaimed_slab += 1 << order;
84917 - free_pages((unsigned long)b, order);
84918 + __ClearPageSlab(sp);
84919 + page_mapcount_reset(sp);
84920 + sp->private = 0;
84921 + __free_pages(sp, order);
84922 }
84923
84924 /*
84925 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84926
84927 /* Not enough space: must allocate a new page */
84928 if (!b) {
84929 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84930 - if (!b)
84931 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84932 + if (!sp)
84933 return NULL;
84934 - sp = virt_to_page(b);
84935 - __SetPageSlab(sp);
84936 + b = page_address(sp);
84937
84938 spin_lock_irqsave(&slob_lock, flags);
84939 sp->units = SLOB_UNITS(PAGE_SIZE);
84940 sp->freelist = b;
84941 + sp->private = 0;
84942 INIT_LIST_HEAD(&sp->list);
84943 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84944 set_slob_page_free(sp, slob_list);
84945 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84946 if (slob_page_free(sp))
84947 clear_slob_page_free(sp);
84948 spin_unlock_irqrestore(&slob_lock, flags);
84949 - __ClearPageSlab(sp);
84950 - page_mapcount_reset(sp);
84951 - slob_free_pages(b, 0);
84952 + slob_free_pages(sp, 0);
84953 return;
84954 }
84955
84956 @@ -424,11 +426,10 @@ out:
84957 */
84958
84959 static __always_inline void *
84960 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84961 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84962 {
84963 - unsigned int *m;
84964 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84965 - void *ret;
84966 + slob_t *m;
84967 + void *ret = NULL;
84968
84969 gfp &= gfp_allowed_mask;
84970
84971 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84972
84973 if (!m)
84974 return NULL;
84975 - *m = size;
84976 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84977 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84978 + m[0].units = size;
84979 + m[1].units = align;
84980 ret = (void *)m + align;
84981
84982 trace_kmalloc_node(caller, ret,
84983 size, size + align, gfp, node);
84984 } else {
84985 unsigned int order = get_order(size);
84986 + struct page *page;
84987
84988 if (likely(order))
84989 gfp |= __GFP_COMP;
84990 - ret = slob_new_pages(gfp, order, node);
84991 + page = slob_new_pages(gfp, order, node);
84992 + if (page) {
84993 + ret = page_address(page);
84994 + page->private = size;
84995 + }
84996
84997 trace_kmalloc_node(caller, ret,
84998 size, PAGE_SIZE << order, gfp, node);
84999 }
85000
85001 - kmemleak_alloc(ret, size, 1, gfp);
85002 + return ret;
85003 +}
85004 +
85005 +static __always_inline void *
85006 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85007 +{
85008 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85009 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
85010 +
85011 + if (!ZERO_OR_NULL_PTR(ret))
85012 + kmemleak_alloc(ret, size, 1, gfp);
85013 return ret;
85014 }
85015
85016 @@ -493,34 +512,112 @@ void kfree(const void *block)
85017 return;
85018 kmemleak_free(block);
85019
85020 + VM_BUG_ON(!virt_addr_valid(block));
85021 sp = virt_to_page(block);
85022 - if (PageSlab(sp)) {
85023 + VM_BUG_ON(!PageSlab(sp));
85024 + if (!sp->private) {
85025 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85026 - unsigned int *m = (unsigned int *)(block - align);
85027 - slob_free(m, *m + align);
85028 - } else
85029 + slob_t *m = (slob_t *)(block - align);
85030 + slob_free(m, m[0].units + align);
85031 + } else {
85032 + __ClearPageSlab(sp);
85033 + page_mapcount_reset(sp);
85034 + sp->private = 0;
85035 __free_pages(sp, compound_order(sp));
85036 + }
85037 }
85038 EXPORT_SYMBOL(kfree);
85039
85040 +bool is_usercopy_object(const void *ptr)
85041 +{
85042 + if (!slab_is_available())
85043 + return false;
85044 +
85045 + // PAX: TODO
85046 +
85047 + return false;
85048 +}
85049 +
85050 +#ifdef CONFIG_PAX_USERCOPY
85051 +const char *check_heap_object(const void *ptr, unsigned long n)
85052 +{
85053 + struct page *page;
85054 + const slob_t *free;
85055 + const void *base;
85056 + unsigned long flags;
85057 +
85058 + if (ZERO_OR_NULL_PTR(ptr))
85059 + return "<null>";
85060 +
85061 + if (!virt_addr_valid(ptr))
85062 + return NULL;
85063 +
85064 + page = virt_to_head_page(ptr);
85065 + if (!PageSlab(page))
85066 + return NULL;
85067 +
85068 + if (page->private) {
85069 + base = page;
85070 + if (base <= ptr && n <= page->private - (ptr - base))
85071 + return NULL;
85072 + return "<slob>";
85073 + }
85074 +
85075 + /* some tricky double walking to find the chunk */
85076 + spin_lock_irqsave(&slob_lock, flags);
85077 + base = (void *)((unsigned long)ptr & PAGE_MASK);
85078 + free = page->freelist;
85079 +
85080 + while (!slob_last(free) && (void *)free <= ptr) {
85081 + base = free + slob_units(free);
85082 + free = slob_next(free);
85083 + }
85084 +
85085 + while (base < (void *)free) {
85086 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
85087 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
85088 + int offset;
85089 +
85090 + if (ptr < base + align)
85091 + break;
85092 +
85093 + offset = ptr - base - align;
85094 + if (offset >= m) {
85095 + base += size;
85096 + continue;
85097 + }
85098 +
85099 + if (n > m - offset)
85100 + break;
85101 +
85102 + spin_unlock_irqrestore(&slob_lock, flags);
85103 + return NULL;
85104 + }
85105 +
85106 + spin_unlock_irqrestore(&slob_lock, flags);
85107 + return "<slob>";
85108 +}
85109 +#endif
85110 +
85111 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
85112 size_t ksize(const void *block)
85113 {
85114 struct page *sp;
85115 int align;
85116 - unsigned int *m;
85117 + slob_t *m;
85118
85119 BUG_ON(!block);
85120 if (unlikely(block == ZERO_SIZE_PTR))
85121 return 0;
85122
85123 sp = virt_to_page(block);
85124 - if (unlikely(!PageSlab(sp)))
85125 - return PAGE_SIZE << compound_order(sp);
85126 + VM_BUG_ON(!PageSlab(sp));
85127 + if (sp->private)
85128 + return sp->private;
85129
85130 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85131 - m = (unsigned int *)(block - align);
85132 - return SLOB_UNITS(*m) * SLOB_UNIT;
85133 + m = (slob_t *)(block - align);
85134 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
85135 }
85136 EXPORT_SYMBOL(ksize);
85137
85138 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
85139
85140 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
85141 {
85142 - void *b;
85143 + void *b = NULL;
85144
85145 flags &= gfp_allowed_mask;
85146
85147 lockdep_trace_alloc(flags);
85148
85149 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85150 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
85151 +#else
85152 if (c->size < PAGE_SIZE) {
85153 b = slob_alloc(c->size, flags, c->align, node);
85154 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85155 SLOB_UNITS(c->size) * SLOB_UNIT,
85156 flags, node);
85157 } else {
85158 - b = slob_new_pages(flags, get_order(c->size), node);
85159 + struct page *sp;
85160 +
85161 + sp = slob_new_pages(flags, get_order(c->size), node);
85162 + if (sp) {
85163 + b = page_address(sp);
85164 + sp->private = c->size;
85165 + }
85166 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85167 PAGE_SIZE << get_order(c->size),
85168 flags, node);
85169 }
85170 +#endif
85171
85172 if (c->ctor)
85173 c->ctor(b);
85174 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
85175
85176 static void __kmem_cache_free(void *b, int size)
85177 {
85178 - if (size < PAGE_SIZE)
85179 + struct page *sp;
85180 +
85181 + sp = virt_to_page(b);
85182 + BUG_ON(!PageSlab(sp));
85183 + if (!sp->private)
85184 slob_free(b, size);
85185 else
85186 - slob_free_pages(b, get_order(size));
85187 + slob_free_pages(sp, get_order(size));
85188 }
85189
85190 static void kmem_rcu_free(struct rcu_head *head)
85191 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
85192
85193 void kmem_cache_free(struct kmem_cache *c, void *b)
85194 {
85195 + int size = c->size;
85196 +
85197 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85198 + if (size + c->align < PAGE_SIZE) {
85199 + size += c->align;
85200 + b -= c->align;
85201 + }
85202 +#endif
85203 +
85204 kmemleak_free_recursive(b, c->flags);
85205 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
85206 struct slob_rcu *slob_rcu;
85207 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
85208 - slob_rcu->size = c->size;
85209 + slob_rcu = b + (size - sizeof(struct slob_rcu));
85210 + slob_rcu->size = size;
85211 call_rcu(&slob_rcu->head, kmem_rcu_free);
85212 } else {
85213 - __kmem_cache_free(b, c->size);
85214 + __kmem_cache_free(b, size);
85215 }
85216
85217 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85218 + trace_kfree(_RET_IP_, b);
85219 +#else
85220 trace_kmem_cache_free(_RET_IP_, b);
85221 +#endif
85222 +
85223 }
85224 EXPORT_SYMBOL(kmem_cache_free);
85225
85226 diff --git a/mm/slub.c b/mm/slub.c
85227 index 57707f0..c28619b 100644
85228 --- a/mm/slub.c
85229 +++ b/mm/slub.c
85230 @@ -198,7 +198,7 @@ struct track {
85231
85232 enum track_item { TRACK_ALLOC, TRACK_FREE };
85233
85234 -#ifdef CONFIG_SYSFS
85235 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85236 static int sysfs_slab_add(struct kmem_cache *);
85237 static int sysfs_slab_alias(struct kmem_cache *, const char *);
85238 static void sysfs_slab_remove(struct kmem_cache *);
85239 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
85240 if (!t->addr)
85241 return;
85242
85243 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
85244 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
85245 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
85246 #ifdef CONFIG_STACKTRACE
85247 {
85248 @@ -2661,7 +2661,7 @@ static int slub_min_objects;
85249 * Merge control. If this is set then no merging of slab caches will occur.
85250 * (Could be removed. This was introduced to pacify the merge skeptics.)
85251 */
85252 -static int slub_nomerge;
85253 +static int slub_nomerge = 1;
85254
85255 /*
85256 * Calculate the order of allocation given an slab object size.
85257 @@ -3283,6 +3283,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
85258 EXPORT_SYMBOL(__kmalloc_node);
85259 #endif
85260
85261 +bool is_usercopy_object(const void *ptr)
85262 +{
85263 + struct page *page;
85264 + struct kmem_cache *s;
85265 +
85266 + if (ZERO_OR_NULL_PTR(ptr))
85267 + return false;
85268 +
85269 + if (!slab_is_available())
85270 + return false;
85271 +
85272 + if (!virt_addr_valid(ptr))
85273 + return false;
85274 +
85275 + page = virt_to_head_page(ptr);
85276 +
85277 + if (!PageSlab(page))
85278 + return false;
85279 +
85280 + s = page->slab_cache;
85281 + return s->flags & SLAB_USERCOPY;
85282 +}
85283 +
85284 +#ifdef CONFIG_PAX_USERCOPY
85285 +const char *check_heap_object(const void *ptr, unsigned long n)
85286 +{
85287 + struct page *page;
85288 + struct kmem_cache *s;
85289 + unsigned long offset;
85290 +
85291 + if (ZERO_OR_NULL_PTR(ptr))
85292 + return "<null>";
85293 +
85294 + if (!virt_addr_valid(ptr))
85295 + return NULL;
85296 +
85297 + page = virt_to_head_page(ptr);
85298 +
85299 + if (!PageSlab(page))
85300 + return NULL;
85301 +
85302 + s = page->slab_cache;
85303 + if (!(s->flags & SLAB_USERCOPY))
85304 + return s->name;
85305 +
85306 + offset = (ptr - page_address(page)) % s->size;
85307 + if (offset <= s->object_size && n <= s->object_size - offset)
85308 + return NULL;
85309 +
85310 + return s->name;
85311 +}
85312 +#endif
85313 +
85314 size_t ksize(const void *object)
85315 {
85316 struct page *page;
85317 @@ -3347,6 +3400,7 @@ void kfree(const void *x)
85318 if (unlikely(ZERO_OR_NULL_PTR(x)))
85319 return;
85320
85321 + VM_BUG_ON(!virt_addr_valid(x));
85322 page = virt_to_head_page(x);
85323 if (unlikely(!PageSlab(page))) {
85324 BUG_ON(!PageCompound(page));
85325 @@ -3652,7 +3706,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85326 /*
85327 * We may have set a slab to be unmergeable during bootstrap.
85328 */
85329 - if (s->refcount < 0)
85330 + if (atomic_read(&s->refcount) < 0)
85331 return 1;
85332
85333 return 0;
85334 @@ -3710,7 +3764,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85335
85336 s = find_mergeable(memcg, size, align, flags, name, ctor);
85337 if (s) {
85338 - s->refcount++;
85339 + atomic_inc(&s->refcount);
85340 /*
85341 * Adjust the object sizes so that we clear
85342 * the complete object on kzalloc.
85343 @@ -3719,7 +3773,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85344 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85345
85346 if (sysfs_slab_alias(s, name)) {
85347 - s->refcount--;
85348 + atomic_dec(&s->refcount);
85349 s = NULL;
85350 }
85351 }
85352 @@ -3781,7 +3835,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85353 return NOTIFY_OK;
85354 }
85355
85356 -static struct notifier_block __cpuinitdata slab_notifier = {
85357 +static struct notifier_block slab_notifier = {
85358 .notifier_call = slab_cpuup_callback
85359 };
85360
85361 @@ -3839,7 +3893,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85362 }
85363 #endif
85364
85365 -#ifdef CONFIG_SYSFS
85366 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85367 static int count_inuse(struct page *page)
85368 {
85369 return page->inuse;
85370 @@ -4226,12 +4280,12 @@ static void resiliency_test(void)
85371 validate_slab_cache(kmalloc_caches[9]);
85372 }
85373 #else
85374 -#ifdef CONFIG_SYSFS
85375 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85376 static void resiliency_test(void) {};
85377 #endif
85378 #endif
85379
85380 -#ifdef CONFIG_SYSFS
85381 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85382 enum slab_stat_type {
85383 SL_ALL, /* All slabs */
85384 SL_PARTIAL, /* Only partially allocated slabs */
85385 @@ -4475,7 +4529,7 @@ SLAB_ATTR_RO(ctor);
85386
85387 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85388 {
85389 - return sprintf(buf, "%d\n", s->refcount - 1);
85390 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85391 }
85392 SLAB_ATTR_RO(aliases);
85393
85394 @@ -4563,6 +4617,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
85395 SLAB_ATTR_RO(cache_dma);
85396 #endif
85397
85398 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85399 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
85400 +{
85401 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
85402 +}
85403 +SLAB_ATTR_RO(usercopy);
85404 +#endif
85405 +
85406 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
85407 {
85408 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
85409 @@ -4897,6 +4959,9 @@ static struct attribute *slab_attrs[] = {
85410 #ifdef CONFIG_ZONE_DMA
85411 &cache_dma_attr.attr,
85412 #endif
85413 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85414 + &usercopy_attr.attr,
85415 +#endif
85416 #ifdef CONFIG_NUMA
85417 &remote_node_defrag_ratio_attr.attr,
85418 #endif
85419 @@ -5128,6 +5193,7 @@ static char *create_unique_id(struct kmem_cache *s)
85420 return name;
85421 }
85422
85423 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85424 static int sysfs_slab_add(struct kmem_cache *s)
85425 {
85426 int err;
85427 @@ -5151,7 +5217,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
85428 }
85429
85430 s->kobj.kset = slab_kset;
85431 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
85432 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
85433 if (err) {
85434 kobject_put(&s->kobj);
85435 return err;
85436 @@ -5185,6 +5251,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85437 kobject_del(&s->kobj);
85438 kobject_put(&s->kobj);
85439 }
85440 +#endif
85441
85442 /*
85443 * Need to buffer aliases during bootup until sysfs becomes
85444 @@ -5198,6 +5265,7 @@ struct saved_alias {
85445
85446 static struct saved_alias *alias_list;
85447
85448 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85449 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85450 {
85451 struct saved_alias *al;
85452 @@ -5220,6 +5288,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85453 alias_list = al;
85454 return 0;
85455 }
85456 +#endif
85457
85458 static int __init slab_sysfs_init(void)
85459 {
85460 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85461 index 27eeab3..7c3f7f2 100644
85462 --- a/mm/sparse-vmemmap.c
85463 +++ b/mm/sparse-vmemmap.c
85464 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85465 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85466 if (!p)
85467 return NULL;
85468 - pud_populate(&init_mm, pud, p);
85469 + pud_populate_kernel(&init_mm, pud, p);
85470 }
85471 return pud;
85472 }
85473 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85474 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85475 if (!p)
85476 return NULL;
85477 - pgd_populate(&init_mm, pgd, p);
85478 + pgd_populate_kernel(&init_mm, pgd, p);
85479 }
85480 return pgd;
85481 }
85482 diff --git a/mm/sparse.c b/mm/sparse.c
85483 index 1c91f0d3..485470a 100644
85484 --- a/mm/sparse.c
85485 +++ b/mm/sparse.c
85486 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85487
85488 for (i = 0; i < PAGES_PER_SECTION; i++) {
85489 if (PageHWPoison(&memmap[i])) {
85490 - atomic_long_sub(1, &num_poisoned_pages);
85491 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
85492 ClearPageHWPoison(&memmap[i]);
85493 }
85494 }
85495 diff --git a/mm/swap.c b/mm/swap.c
85496 index dfd7d71..ccdf688 100644
85497 --- a/mm/swap.c
85498 +++ b/mm/swap.c
85499 @@ -31,6 +31,7 @@
85500 #include <linux/memcontrol.h>
85501 #include <linux/gfp.h>
85502 #include <linux/uio.h>
85503 +#include <linux/hugetlb.h>
85504
85505 #include "internal.h"
85506
85507 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
85508
85509 __page_cache_release(page);
85510 dtor = get_compound_page_dtor(page);
85511 + if (!PageHuge(page))
85512 + BUG_ON(dtor != free_compound_page);
85513 (*dtor)(page);
85514 }
85515
85516 diff --git a/mm/swapfile.c b/mm/swapfile.c
85517 index 746af55b..7ac94ae 100644
85518 --- a/mm/swapfile.c
85519 +++ b/mm/swapfile.c
85520 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
85521
85522 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85523 /* Activity counter to indicate that a swapon or swapoff has occurred */
85524 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85525 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85526
85527 static inline unsigned char swap_count(unsigned char ent)
85528 {
85529 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85530 }
85531 filp_close(swap_file, NULL);
85532 err = 0;
85533 - atomic_inc(&proc_poll_event);
85534 + atomic_inc_unchecked(&proc_poll_event);
85535 wake_up_interruptible(&proc_poll_wait);
85536
85537 out_dput:
85538 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85539
85540 poll_wait(file, &proc_poll_wait, wait);
85541
85542 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85543 - seq->poll_event = atomic_read(&proc_poll_event);
85544 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85545 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85546 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85547 }
85548
85549 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85550 return ret;
85551
85552 seq = file->private_data;
85553 - seq->poll_event = atomic_read(&proc_poll_event);
85554 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85555 return 0;
85556 }
85557
85558 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85559 (frontswap_map) ? "FS" : "");
85560
85561 mutex_unlock(&swapon_mutex);
85562 - atomic_inc(&proc_poll_event);
85563 + atomic_inc_unchecked(&proc_poll_event);
85564 wake_up_interruptible(&proc_poll_wait);
85565
85566 if (S_ISREG(inode->i_mode))
85567 diff --git a/mm/util.c b/mm/util.c
85568 index ab1424d..7c5bd5a 100644
85569 --- a/mm/util.c
85570 +++ b/mm/util.c
85571 @@ -294,6 +294,12 @@ done:
85572 void arch_pick_mmap_layout(struct mm_struct *mm)
85573 {
85574 mm->mmap_base = TASK_UNMAPPED_BASE;
85575 +
85576 +#ifdef CONFIG_PAX_RANDMMAP
85577 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85578 + mm->mmap_base += mm->delta_mmap;
85579 +#endif
85580 +
85581 mm->get_unmapped_area = arch_get_unmapped_area;
85582 mm->unmap_area = arch_unmap_area;
85583 }
85584 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85585 index d365724..6cae7c2 100644
85586 --- a/mm/vmalloc.c
85587 +++ b/mm/vmalloc.c
85588 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85589
85590 pte = pte_offset_kernel(pmd, addr);
85591 do {
85592 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85593 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85594 +
85595 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85596 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85597 + BUG_ON(!pte_exec(*pte));
85598 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85599 + continue;
85600 + }
85601 +#endif
85602 +
85603 + {
85604 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85605 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85606 + }
85607 } while (pte++, addr += PAGE_SIZE, addr != end);
85608 }
85609
85610 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85611 pte = pte_alloc_kernel(pmd, addr);
85612 if (!pte)
85613 return -ENOMEM;
85614 +
85615 + pax_open_kernel();
85616 do {
85617 struct page *page = pages[*nr];
85618
85619 - if (WARN_ON(!pte_none(*pte)))
85620 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85621 + if (pgprot_val(prot) & _PAGE_NX)
85622 +#endif
85623 +
85624 + if (!pte_none(*pte)) {
85625 + pax_close_kernel();
85626 + WARN_ON(1);
85627 return -EBUSY;
85628 - if (WARN_ON(!page))
85629 + }
85630 + if (!page) {
85631 + pax_close_kernel();
85632 + WARN_ON(1);
85633 return -ENOMEM;
85634 + }
85635 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85636 (*nr)++;
85637 } while (pte++, addr += PAGE_SIZE, addr != end);
85638 + pax_close_kernel();
85639 return 0;
85640 }
85641
85642 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85643 pmd_t *pmd;
85644 unsigned long next;
85645
85646 - pmd = pmd_alloc(&init_mm, pud, addr);
85647 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85648 if (!pmd)
85649 return -ENOMEM;
85650 do {
85651 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85652 pud_t *pud;
85653 unsigned long next;
85654
85655 - pud = pud_alloc(&init_mm, pgd, addr);
85656 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85657 if (!pud)
85658 return -ENOMEM;
85659 do {
85660 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
85661 if (addr >= MODULES_VADDR && addr < MODULES_END)
85662 return 1;
85663 #endif
85664 +
85665 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85666 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85667 + return 1;
85668 +#endif
85669 +
85670 return is_vmalloc_addr(x);
85671 }
85672
85673 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85674
85675 if (!pgd_none(*pgd)) {
85676 pud_t *pud = pud_offset(pgd, addr);
85677 +#ifdef CONFIG_X86
85678 + if (!pud_large(*pud))
85679 +#endif
85680 if (!pud_none(*pud)) {
85681 pmd_t *pmd = pmd_offset(pud, addr);
85682 +#ifdef CONFIG_X86
85683 + if (!pmd_large(*pmd))
85684 +#endif
85685 if (!pmd_none(*pmd)) {
85686 pte_t *ptep, pte;
85687
85688 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
85689 * Allocate a region of KVA of the specified size and alignment, within the
85690 * vstart and vend.
85691 */
85692 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85693 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85694 unsigned long align,
85695 unsigned long vstart, unsigned long vend,
85696 int node, gfp_t gfp_mask)
85697 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85698 struct vm_struct *area;
85699
85700 BUG_ON(in_interrupt());
85701 +
85702 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85703 + if (flags & VM_KERNEXEC) {
85704 + if (start != VMALLOC_START || end != VMALLOC_END)
85705 + return NULL;
85706 + start = (unsigned long)MODULES_EXEC_VADDR;
85707 + end = (unsigned long)MODULES_EXEC_END;
85708 + }
85709 +#endif
85710 +
85711 if (flags & VM_IOREMAP) {
85712 int bit = fls(size);
85713
85714 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
85715 if (count > totalram_pages)
85716 return NULL;
85717
85718 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85719 + if (!(pgprot_val(prot) & _PAGE_NX))
85720 + flags |= VM_KERNEXEC;
85721 +#endif
85722 +
85723 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85724 __builtin_return_address(0));
85725 if (!area)
85726 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85727 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85728 goto fail;
85729
85730 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85731 + if (!(pgprot_val(prot) & _PAGE_NX))
85732 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85733 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85734 + else
85735 +#endif
85736 +
85737 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85738 start, end, node, gfp_mask, caller);
85739 if (!area)
85740 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
85741 * For tight control over page level allocator and protection flags
85742 * use __vmalloc() instead.
85743 */
85744 -
85745 void *vmalloc_exec(unsigned long size)
85746 {
85747 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85748 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85749 NUMA_NO_NODE, __builtin_return_address(0));
85750 }
85751
85752 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85753 unsigned long uaddr = vma->vm_start;
85754 unsigned long usize = vma->vm_end - vma->vm_start;
85755
85756 + BUG_ON(vma->vm_mirror);
85757 +
85758 if ((PAGE_SIZE-1) & (unsigned long)addr)
85759 return -EINVAL;
85760
85761 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
85762 v->addr, v->addr + v->size, v->size);
85763
85764 if (v->caller)
85765 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85766 + seq_printf(m, " %pK", v->caller);
85767 +#else
85768 seq_printf(m, " %pS", v->caller);
85769 +#endif
85770
85771 if (v->nr_pages)
85772 seq_printf(m, " pages=%d", v->nr_pages);
85773 diff --git a/mm/vmstat.c b/mm/vmstat.c
85774 index f42745e..62f8346 100644
85775 --- a/mm/vmstat.c
85776 +++ b/mm/vmstat.c
85777 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
85778 *
85779 * vm_stat contains the global counters
85780 */
85781 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85782 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85783 EXPORT_SYMBOL(vm_stat);
85784
85785 #ifdef CONFIG_SMP
85786 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
85787 v = p->vm_stat_diff[i];
85788 p->vm_stat_diff[i] = 0;
85789 local_irq_restore(flags);
85790 - atomic_long_add(v, &zone->vm_stat[i]);
85791 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85792 global_diff[i] += v;
85793 #ifdef CONFIG_NUMA
85794 /* 3 seconds idle till flush */
85795 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
85796
85797 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85798 if (global_diff[i])
85799 - atomic_long_add(global_diff[i], &vm_stat[i]);
85800 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85801 }
85802
85803 /*
85804 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85805 if (pset->vm_stat_diff[i]) {
85806 int v = pset->vm_stat_diff[i];
85807 pset->vm_stat_diff[i] = 0;
85808 - atomic_long_add(v, &zone->vm_stat[i]);
85809 - atomic_long_add(v, &vm_stat[i]);
85810 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85811 + atomic_long_add_unchecked(v, &vm_stat[i]);
85812 }
85813 }
85814 #endif
85815 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85816 return NOTIFY_OK;
85817 }
85818
85819 -static struct notifier_block __cpuinitdata vmstat_notifier =
85820 +static struct notifier_block vmstat_notifier =
85821 { &vmstat_cpuup_callback, NULL, 0 };
85822 #endif
85823
85824 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
85825 start_cpu_timer(cpu);
85826 #endif
85827 #ifdef CONFIG_PROC_FS
85828 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85829 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85830 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85831 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85832 + {
85833 + mode_t gr_mode = S_IRUGO;
85834 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85835 + gr_mode = S_IRUSR;
85836 +#endif
85837 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85838 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85839 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85840 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85841 +#else
85842 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85843 +#endif
85844 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85845 + }
85846 #endif
85847 return 0;
85848 }
85849 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85850 index 9424f37..6aabf19 100644
85851 --- a/net/8021q/vlan.c
85852 +++ b/net/8021q/vlan.c
85853 @@ -469,7 +469,7 @@ out:
85854 return NOTIFY_DONE;
85855 }
85856
85857 -static struct notifier_block vlan_notifier_block __read_mostly = {
85858 +static struct notifier_block vlan_notifier_block = {
85859 .notifier_call = vlan_device_event,
85860 };
85861
85862 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85863 err = -EPERM;
85864 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85865 break;
85866 - if ((args.u.name_type >= 0) &&
85867 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85868 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85869 struct vlan_net *vn;
85870
85871 vn = net_generic(net, vlan_net_id);
85872 diff --git a/net/9p/mod.c b/net/9p/mod.c
85873 index 6ab36ae..6f1841b 100644
85874 --- a/net/9p/mod.c
85875 +++ b/net/9p/mod.c
85876 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85877 void v9fs_register_trans(struct p9_trans_module *m)
85878 {
85879 spin_lock(&v9fs_trans_lock);
85880 - list_add_tail(&m->list, &v9fs_trans_list);
85881 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85882 spin_unlock(&v9fs_trans_lock);
85883 }
85884 EXPORT_SYMBOL(v9fs_register_trans);
85885 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85886 void v9fs_unregister_trans(struct p9_trans_module *m)
85887 {
85888 spin_lock(&v9fs_trans_lock);
85889 - list_del_init(&m->list);
85890 + pax_list_del_init((struct list_head *)&m->list);
85891 spin_unlock(&v9fs_trans_lock);
85892 }
85893 EXPORT_SYMBOL(v9fs_unregister_trans);
85894 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85895 index 02efb25..41541a9 100644
85896 --- a/net/9p/trans_fd.c
85897 +++ b/net/9p/trans_fd.c
85898 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85899 oldfs = get_fs();
85900 set_fs(get_ds());
85901 /* The cast to a user pointer is valid due to the set_fs() */
85902 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85903 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85904 set_fs(oldfs);
85905
85906 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85907 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85908 index 876fbe8..8bbea9f 100644
85909 --- a/net/atm/atm_misc.c
85910 +++ b/net/atm/atm_misc.c
85911 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85912 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85913 return 1;
85914 atm_return(vcc, truesize);
85915 - atomic_inc(&vcc->stats->rx_drop);
85916 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85917 return 0;
85918 }
85919 EXPORT_SYMBOL(atm_charge);
85920 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85921 }
85922 }
85923 atm_return(vcc, guess);
85924 - atomic_inc(&vcc->stats->rx_drop);
85925 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85926 return NULL;
85927 }
85928 EXPORT_SYMBOL(atm_alloc_charge);
85929 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85930
85931 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85932 {
85933 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85934 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85935 __SONET_ITEMS
85936 #undef __HANDLE_ITEM
85937 }
85938 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85939
85940 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85941 {
85942 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85943 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85944 __SONET_ITEMS
85945 #undef __HANDLE_ITEM
85946 }
85947 diff --git a/net/atm/lec.h b/net/atm/lec.h
85948 index 4149db1..f2ab682 100644
85949 --- a/net/atm/lec.h
85950 +++ b/net/atm/lec.h
85951 @@ -48,7 +48,7 @@ struct lane2_ops {
85952 const u8 *tlvs, u32 sizeoftlvs);
85953 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85954 const u8 *tlvs, u32 sizeoftlvs);
85955 -};
85956 +} __no_const;
85957
85958 /*
85959 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85960 diff --git a/net/atm/proc.c b/net/atm/proc.c
85961 index bbb6461..cf04016 100644
85962 --- a/net/atm/proc.c
85963 +++ b/net/atm/proc.c
85964 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85965 const struct k_atm_aal_stats *stats)
85966 {
85967 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85968 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85969 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85970 - atomic_read(&stats->rx_drop));
85971 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85972 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85973 + atomic_read_unchecked(&stats->rx_drop));
85974 }
85975
85976 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85977 diff --git a/net/atm/resources.c b/net/atm/resources.c
85978 index 0447d5d..3cf4728 100644
85979 --- a/net/atm/resources.c
85980 +++ b/net/atm/resources.c
85981 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85982 static void copy_aal_stats(struct k_atm_aal_stats *from,
85983 struct atm_aal_stats *to)
85984 {
85985 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85986 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85987 __AAL_STAT_ITEMS
85988 #undef __HANDLE_ITEM
85989 }
85990 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85991 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85992 struct atm_aal_stats *to)
85993 {
85994 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85995 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85996 __AAL_STAT_ITEMS
85997 #undef __HANDLE_ITEM
85998 }
85999 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
86000 index d5744b7..506bae3 100644
86001 --- a/net/ax25/sysctl_net_ax25.c
86002 +++ b/net/ax25/sysctl_net_ax25.c
86003 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
86004 {
86005 char path[sizeof("net/ax25/") + IFNAMSIZ];
86006 int k;
86007 - struct ctl_table *table;
86008 + ctl_table_no_const *table;
86009
86010 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
86011 if (!table)
86012 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
86013 index f680ee1..97e3542 100644
86014 --- a/net/batman-adv/bat_iv_ogm.c
86015 +++ b/net/batman-adv/bat_iv_ogm.c
86016 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
86017
86018 /* randomize initial seqno to avoid collision */
86019 get_random_bytes(&random_seqno, sizeof(random_seqno));
86020 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86021 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86022
86023 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
86024 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
86025 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
86026 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
86027
86028 /* change sequence number to network order */
86029 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
86030 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
86031 batadv_ogm_packet->seqno = htonl(seqno);
86032 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
86033 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
86034
86035 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
86036 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
86037 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
86038 return;
86039
86040 /* could be changed by schedule_own_packet() */
86041 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
86042 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
86043
86044 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
86045 has_directlink_flag = 1;
86046 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
86047 index 522243a..b48c0ef 100644
86048 --- a/net/batman-adv/hard-interface.c
86049 +++ b/net/batman-adv/hard-interface.c
86050 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
86051 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
86052 dev_add_pack(&hard_iface->batman_adv_ptype);
86053
86054 - atomic_set(&hard_iface->frag_seqno, 1);
86055 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
86056 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
86057 hard_iface->net_dev->name);
86058
86059 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
86060 /* This can't be called via a bat_priv callback because
86061 * we have no bat_priv yet.
86062 */
86063 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
86064 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
86065 hard_iface->bat_iv.ogm_buff = NULL;
86066
86067 return hard_iface;
86068 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
86069 index 819dfb0..9a672d1 100644
86070 --- a/net/batman-adv/soft-interface.c
86071 +++ b/net/batman-adv/soft-interface.c
86072 @@ -253,7 +253,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
86073 primary_if->net_dev->dev_addr, ETH_ALEN);
86074
86075 /* set broadcast sequence number */
86076 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
86077 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
86078 bcast_packet->seqno = htonl(seqno);
86079
86080 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
86081 @@ -472,7 +472,7 @@ static int batadv_softif_init_late(struct net_device *dev)
86082 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
86083
86084 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
86085 - atomic_set(&bat_priv->bcast_seqno, 1);
86086 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
86087 atomic_set(&bat_priv->tt.vn, 0);
86088 atomic_set(&bat_priv->tt.local_changes, 0);
86089 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
86090 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
86091 index aba8364..50fcbb8 100644
86092 --- a/net/batman-adv/types.h
86093 +++ b/net/batman-adv/types.h
86094 @@ -51,7 +51,7 @@
86095 struct batadv_hard_iface_bat_iv {
86096 unsigned char *ogm_buff;
86097 int ogm_buff_len;
86098 - atomic_t ogm_seqno;
86099 + atomic_unchecked_t ogm_seqno;
86100 };
86101
86102 /**
86103 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
86104 int16_t if_num;
86105 char if_status;
86106 struct net_device *net_dev;
86107 - atomic_t frag_seqno;
86108 + atomic_unchecked_t frag_seqno;
86109 struct kobject *hardif_obj;
86110 atomic_t refcount;
86111 struct packet_type batman_adv_ptype;
86112 @@ -558,7 +558,7 @@ struct batadv_priv {
86113 #ifdef CONFIG_BATMAN_ADV_DEBUG
86114 atomic_t log_level;
86115 #endif
86116 - atomic_t bcast_seqno;
86117 + atomic_unchecked_t bcast_seqno;
86118 atomic_t bcast_queue_left;
86119 atomic_t batman_queue_left;
86120 char num_ifaces;
86121 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
86122 index 0bb3b59..ffcbf2f 100644
86123 --- a/net/batman-adv/unicast.c
86124 +++ b/net/batman-adv/unicast.c
86125 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
86126 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
86127 frag2->flags = large_tail;
86128
86129 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
86130 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
86131 frag1->seqno = htons(seqno - 1);
86132 frag2->seqno = htons(seqno);
86133
86134 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
86135 index ace5e55..a65a1c0 100644
86136 --- a/net/bluetooth/hci_core.c
86137 +++ b/net/bluetooth/hci_core.c
86138 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
86139 list_add(&hdev->list, &hci_dev_list);
86140 write_unlock(&hci_dev_list_lock);
86141
86142 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
86143 - WQ_MEM_RECLAIM, 1);
86144 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
86145 + WQ_MEM_RECLAIM, 1, hdev->name);
86146 if (!hdev->workqueue) {
86147 error = -ENOMEM;
86148 goto err;
86149 }
86150
86151 - hdev->req_workqueue = alloc_workqueue(hdev->name,
86152 + hdev->req_workqueue = alloc_workqueue("%s",
86153 WQ_HIGHPRI | WQ_UNBOUND |
86154 - WQ_MEM_RECLAIM, 1);
86155 + WQ_MEM_RECLAIM, 1, hdev->name);
86156 if (!hdev->req_workqueue) {
86157 destroy_workqueue(hdev->workqueue);
86158 error = -ENOMEM;
86159 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
86160 index 9bd7d95..6c4884f 100644
86161 --- a/net/bluetooth/hci_sock.c
86162 +++ b/net/bluetooth/hci_sock.c
86163 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
86164 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
86165 }
86166
86167 - len = min_t(unsigned int, len, sizeof(uf));
86168 + len = min((size_t)len, sizeof(uf));
86169 if (copy_from_user(&uf, optval, len)) {
86170 err = -EFAULT;
86171 break;
86172 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
86173 index 68843a2..30e9342 100644
86174 --- a/net/bluetooth/l2cap_core.c
86175 +++ b/net/bluetooth/l2cap_core.c
86176 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
86177 break;
86178
86179 case L2CAP_CONF_RFC:
86180 - if (olen == sizeof(rfc))
86181 - memcpy(&rfc, (void *)val, olen);
86182 + if (olen != sizeof(rfc))
86183 + break;
86184 +
86185 + memcpy(&rfc, (void *)val, olen);
86186
86187 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
86188 rfc.mode != chan->mode)
86189 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
86190 index 36fed40..be2eeb2 100644
86191 --- a/net/bluetooth/l2cap_sock.c
86192 +++ b/net/bluetooth/l2cap_sock.c
86193 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86194 struct sock *sk = sock->sk;
86195 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
86196 struct l2cap_options opts;
86197 - int len, err = 0;
86198 + int err = 0;
86199 + size_t len = optlen;
86200 u32 opt;
86201
86202 BT_DBG("sk %p", sk);
86203 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86204 opts.max_tx = chan->max_tx;
86205 opts.txwin_size = chan->tx_win;
86206
86207 - len = min_t(unsigned int, sizeof(opts), optlen);
86208 + len = min(sizeof(opts), len);
86209 if (copy_from_user((char *) &opts, optval, len)) {
86210 err = -EFAULT;
86211 break;
86212 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86213 struct bt_security sec;
86214 struct bt_power pwr;
86215 struct l2cap_conn *conn;
86216 - int len, err = 0;
86217 + int err = 0;
86218 + size_t len = optlen;
86219 u32 opt;
86220
86221 BT_DBG("sk %p", sk);
86222 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86223
86224 sec.level = BT_SECURITY_LOW;
86225
86226 - len = min_t(unsigned int, sizeof(sec), optlen);
86227 + len = min(sizeof(sec), len);
86228 if (copy_from_user((char *) &sec, optval, len)) {
86229 err = -EFAULT;
86230 break;
86231 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86232
86233 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
86234
86235 - len = min_t(unsigned int, sizeof(pwr), optlen);
86236 + len = min(sizeof(pwr), len);
86237 if (copy_from_user((char *) &pwr, optval, len)) {
86238 err = -EFAULT;
86239 break;
86240 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
86241 index 30b3721..c1bd0a0 100644
86242 --- a/net/bluetooth/rfcomm/sock.c
86243 +++ b/net/bluetooth/rfcomm/sock.c
86244 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86245 struct sock *sk = sock->sk;
86246 struct bt_security sec;
86247 int err = 0;
86248 - size_t len;
86249 + size_t len = optlen;
86250 u32 opt;
86251
86252 BT_DBG("sk %p", sk);
86253 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86254
86255 sec.level = BT_SECURITY_LOW;
86256
86257 - len = min_t(unsigned int, sizeof(sec), optlen);
86258 + len = min(sizeof(sec), len);
86259 if (copy_from_user((char *) &sec, optval, len)) {
86260 err = -EFAULT;
86261 break;
86262 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
86263 index b6e44ad..5b0d514 100644
86264 --- a/net/bluetooth/rfcomm/tty.c
86265 +++ b/net/bluetooth/rfcomm/tty.c
86266 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
86267 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
86268
86269 spin_lock_irqsave(&dev->port.lock, flags);
86270 - if (dev->port.count > 0) {
86271 + if (atomic_read(&dev->port.count) > 0) {
86272 spin_unlock_irqrestore(&dev->port.lock, flags);
86273 return;
86274 }
86275 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
86276 return -ENODEV;
86277
86278 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
86279 - dev->channel, dev->port.count);
86280 + dev->channel, atomic_read(&dev->port.count));
86281
86282 spin_lock_irqsave(&dev->port.lock, flags);
86283 - if (++dev->port.count > 1) {
86284 + if (atomic_inc_return(&dev->port.count) > 1) {
86285 spin_unlock_irqrestore(&dev->port.lock, flags);
86286 return 0;
86287 }
86288 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
86289 return;
86290
86291 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
86292 - dev->port.count);
86293 + atomic_read(&dev->port.count));
86294
86295 spin_lock_irqsave(&dev->port.lock, flags);
86296 - if (!--dev->port.count) {
86297 + if (!atomic_dec_return(&dev->port.count)) {
86298 spin_unlock_irqrestore(&dev->port.lock, flags);
86299 if (dev->tty_dev->parent)
86300 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86301 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86302 index 3d110c4..4e1b2eb 100644
86303 --- a/net/bridge/netfilter/ebtables.c
86304 +++ b/net/bridge/netfilter/ebtables.c
86305 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86306 tmp.valid_hooks = t->table->valid_hooks;
86307 }
86308 mutex_unlock(&ebt_mutex);
86309 - if (copy_to_user(user, &tmp, *len) != 0){
86310 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86311 BUGPRINT("c2u Didn't work\n");
86312 ret = -EFAULT;
86313 break;
86314 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86315 goto out;
86316 tmp.valid_hooks = t->valid_hooks;
86317
86318 - if (copy_to_user(user, &tmp, *len) != 0) {
86319 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86320 ret = -EFAULT;
86321 break;
86322 }
86323 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86324 tmp.entries_size = t->table->entries_size;
86325 tmp.valid_hooks = t->table->valid_hooks;
86326
86327 - if (copy_to_user(user, &tmp, *len) != 0) {
86328 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86329 ret = -EFAULT;
86330 break;
86331 }
86332 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86333 index 2bd4b58..0dc30a1 100644
86334 --- a/net/caif/cfctrl.c
86335 +++ b/net/caif/cfctrl.c
86336 @@ -10,6 +10,7 @@
86337 #include <linux/spinlock.h>
86338 #include <linux/slab.h>
86339 #include <linux/pkt_sched.h>
86340 +#include <linux/sched.h>
86341 #include <net/caif/caif_layer.h>
86342 #include <net/caif/cfpkt.h>
86343 #include <net/caif/cfctrl.h>
86344 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86345 memset(&dev_info, 0, sizeof(dev_info));
86346 dev_info.id = 0xff;
86347 cfsrvl_init(&this->serv, 0, &dev_info, false);
86348 - atomic_set(&this->req_seq_no, 1);
86349 - atomic_set(&this->rsp_seq_no, 1);
86350 + atomic_set_unchecked(&this->req_seq_no, 1);
86351 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86352 this->serv.layer.receive = cfctrl_recv;
86353 sprintf(this->serv.layer.name, "ctrl");
86354 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86355 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86356 struct cfctrl_request_info *req)
86357 {
86358 spin_lock_bh(&ctrl->info_list_lock);
86359 - atomic_inc(&ctrl->req_seq_no);
86360 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86361 + atomic_inc_unchecked(&ctrl->req_seq_no);
86362 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86363 list_add_tail(&req->list, &ctrl->list);
86364 spin_unlock_bh(&ctrl->info_list_lock);
86365 }
86366 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86367 if (p != first)
86368 pr_warn("Requests are not received in order\n");
86369
86370 - atomic_set(&ctrl->rsp_seq_no,
86371 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86372 p->sequence_no);
86373 list_del(&p->list);
86374 goto out;
86375 diff --git a/net/can/af_can.c b/net/can/af_can.c
86376 index c4e5085..aa9efdf 100644
86377 --- a/net/can/af_can.c
86378 +++ b/net/can/af_can.c
86379 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
86380 };
86381
86382 /* notifier block for netdevice event */
86383 -static struct notifier_block can_netdev_notifier __read_mostly = {
86384 +static struct notifier_block can_netdev_notifier = {
86385 .notifier_call = can_notifier,
86386 };
86387
86388 diff --git a/net/can/gw.c b/net/can/gw.c
86389 index 3ee690e..00d581b 100644
86390 --- a/net/can/gw.c
86391 +++ b/net/can/gw.c
86392 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
86393 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
86394
86395 static HLIST_HEAD(cgw_list);
86396 -static struct notifier_block notifier;
86397
86398 static struct kmem_cache *cgw_cache __read_mostly;
86399
86400 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
86401 return err;
86402 }
86403
86404 +static struct notifier_block notifier = {
86405 + .notifier_call = cgw_notifier
86406 +};
86407 +
86408 static __init int cgw_module_init(void)
86409 {
86410 /* sanitize given module parameter */
86411 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
86412 return -ENOMEM;
86413
86414 /* set notifier */
86415 - notifier.notifier_call = cgw_notifier;
86416 register_netdevice_notifier(&notifier);
86417
86418 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86419 diff --git a/net/compat.c b/net/compat.c
86420 index f0a1ba6..0541331 100644
86421 --- a/net/compat.c
86422 +++ b/net/compat.c
86423 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86424 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86425 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86426 return -EFAULT;
86427 - kmsg->msg_name = compat_ptr(tmp1);
86428 - kmsg->msg_iov = compat_ptr(tmp2);
86429 - kmsg->msg_control = compat_ptr(tmp3);
86430 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86431 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86432 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86433 return 0;
86434 }
86435
86436 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86437
86438 if (kern_msg->msg_namelen) {
86439 if (mode == VERIFY_READ) {
86440 - int err = move_addr_to_kernel(kern_msg->msg_name,
86441 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86442 kern_msg->msg_namelen,
86443 kern_address);
86444 if (err < 0)
86445 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86446 kern_msg->msg_name = NULL;
86447
86448 tot_len = iov_from_user_compat_to_kern(kern_iov,
86449 - (struct compat_iovec __user *)kern_msg->msg_iov,
86450 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86451 kern_msg->msg_iovlen);
86452 if (tot_len >= 0)
86453 kern_msg->msg_iov = kern_iov;
86454 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86455
86456 #define CMSG_COMPAT_FIRSTHDR(msg) \
86457 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86458 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86459 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86460 (struct compat_cmsghdr __user *)NULL)
86461
86462 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86463 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86464 (ucmlen) <= (unsigned long) \
86465 ((mhdr)->msg_controllen - \
86466 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86467 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86468
86469 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86470 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86471 {
86472 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86473 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86474 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86475 msg->msg_controllen)
86476 return NULL;
86477 return (struct compat_cmsghdr __user *)ptr;
86478 @@ -219,7 +219,7 @@ Efault:
86479
86480 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86481 {
86482 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86483 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86484 struct compat_cmsghdr cmhdr;
86485 struct compat_timeval ctv;
86486 struct compat_timespec cts[3];
86487 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86488
86489 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86490 {
86491 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86492 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86493 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86494 int fdnum = scm->fp->count;
86495 struct file **fp = scm->fp->fp;
86496 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86497 return -EFAULT;
86498 old_fs = get_fs();
86499 set_fs(KERNEL_DS);
86500 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86501 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86502 set_fs(old_fs);
86503
86504 return err;
86505 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86506 len = sizeof(ktime);
86507 old_fs = get_fs();
86508 set_fs(KERNEL_DS);
86509 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86510 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86511 set_fs(old_fs);
86512
86513 if (!err) {
86514 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86515 case MCAST_JOIN_GROUP:
86516 case MCAST_LEAVE_GROUP:
86517 {
86518 - struct compat_group_req __user *gr32 = (void *)optval;
86519 + struct compat_group_req __user *gr32 = (void __user *)optval;
86520 struct group_req __user *kgr =
86521 compat_alloc_user_space(sizeof(struct group_req));
86522 u32 interface;
86523 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86524 case MCAST_BLOCK_SOURCE:
86525 case MCAST_UNBLOCK_SOURCE:
86526 {
86527 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86528 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86529 struct group_source_req __user *kgsr = compat_alloc_user_space(
86530 sizeof(struct group_source_req));
86531 u32 interface;
86532 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86533 }
86534 case MCAST_MSFILTER:
86535 {
86536 - struct compat_group_filter __user *gf32 = (void *)optval;
86537 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86538 struct group_filter __user *kgf;
86539 u32 interface, fmode, numsrc;
86540
86541 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86542 char __user *optval, int __user *optlen,
86543 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86544 {
86545 - struct compat_group_filter __user *gf32 = (void *)optval;
86546 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86547 struct group_filter __user *kgf;
86548 int __user *koptlen;
86549 u32 interface, fmode, numsrc;
86550 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86551
86552 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86553 return -EINVAL;
86554 - if (copy_from_user(a, args, nas[call]))
86555 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86556 return -EFAULT;
86557 a0 = a[0];
86558 a1 = a[1];
86559 diff --git a/net/core/datagram.c b/net/core/datagram.c
86560 index b71423d..0360434 100644
86561 --- a/net/core/datagram.c
86562 +++ b/net/core/datagram.c
86563 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86564 }
86565
86566 kfree_skb(skb);
86567 - atomic_inc(&sk->sk_drops);
86568 + atomic_inc_unchecked(&sk->sk_drops);
86569 sk_mem_reclaim_partial(sk);
86570
86571 return err;
86572 diff --git a/net/core/dev.c b/net/core/dev.c
86573 index faebb39..a38fb42 100644
86574 --- a/net/core/dev.c
86575 +++ b/net/core/dev.c
86576 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86577 {
86578 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86579 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86580 - atomic_long_inc(&dev->rx_dropped);
86581 + atomic_long_inc_unchecked(&dev->rx_dropped);
86582 kfree_skb(skb);
86583 return NET_RX_DROP;
86584 }
86585 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86586 skb_orphan(skb);
86587
86588 if (unlikely(!is_skb_forwardable(dev, skb))) {
86589 - atomic_long_inc(&dev->rx_dropped);
86590 + atomic_long_inc_unchecked(&dev->rx_dropped);
86591 kfree_skb(skb);
86592 return NET_RX_DROP;
86593 }
86594 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86595
86596 struct dev_gso_cb {
86597 void (*destructor)(struct sk_buff *skb);
86598 -};
86599 +} __no_const;
86600
86601 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86602
86603 @@ -3139,7 +3139,7 @@ enqueue:
86604
86605 local_irq_restore(flags);
86606
86607 - atomic_long_inc(&skb->dev->rx_dropped);
86608 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86609 kfree_skb(skb);
86610 return NET_RX_DROP;
86611 }
86612 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
86613 }
86614 EXPORT_SYMBOL(netif_rx_ni);
86615
86616 -static void net_tx_action(struct softirq_action *h)
86617 +static void net_tx_action(void)
86618 {
86619 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86620
86621 @@ -3538,7 +3538,7 @@ ncls:
86622 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86623 } else {
86624 drop:
86625 - atomic_long_inc(&skb->dev->rx_dropped);
86626 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86627 kfree_skb(skb);
86628 /* Jamal, now you will not able to escape explaining
86629 * me how you were going to use this. :-)
86630 @@ -4146,7 +4146,7 @@ void netif_napi_del(struct napi_struct *napi)
86631 }
86632 EXPORT_SYMBOL(netif_napi_del);
86633
86634 -static void net_rx_action(struct softirq_action *h)
86635 +static void net_rx_action(void)
86636 {
86637 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86638 unsigned long time_limit = jiffies + 2;
86639 @@ -5583,7 +5583,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86640 } else {
86641 netdev_stats_to_stats64(storage, &dev->stats);
86642 }
86643 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86644 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86645 return storage;
86646 }
86647 EXPORT_SYMBOL(dev_get_stats);
86648 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86649 index 5b7d0e1..cb960fc 100644
86650 --- a/net/core/dev_ioctl.c
86651 +++ b/net/core/dev_ioctl.c
86652 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
86653 if (no_module && capable(CAP_NET_ADMIN))
86654 no_module = request_module("netdev-%s", name);
86655 if (no_module && capable(CAP_SYS_MODULE)) {
86656 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86657 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86658 +#else
86659 if (!request_module("%s", name))
86660 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86661 name);
86662 +#endif
86663 }
86664 }
86665 EXPORT_SYMBOL(dev_load);
86666 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
86667 index ce91766..3b71cdb 100644
86668 --- a/net/core/ethtool.c
86669 +++ b/net/core/ethtool.c
86670 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
86671 if (ret)
86672 return ret;
86673
86674 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
86675 + len = min(tmp.len, dump.len);
86676 if (!len)
86677 return -EFAULT;
86678
86679 + /* Don't ever let the driver think there's more space available
86680 + * than it requested with .get_dump_flag().
86681 + */
86682 + dump.len = len;
86683 +
86684 + /* Always allocate enough space to hold the whole thing so that the
86685 + * driver does not need to check the length and bother with partial
86686 + * dumping.
86687 + */
86688 data = vzalloc(tmp.len);
86689 if (!data)
86690 return -ENOMEM;
86691 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
86692 if (ret)
86693 goto out;
86694
86695 + /* There are two sane possibilities:
86696 + * 1. The driver's .get_dump_data() does not touch dump.len.
86697 + * 2. Or it may set dump.len to how much it really writes, which
86698 + * should be tmp.len (or len if it can do a partial dump).
86699 + * In any case respond to userspace with the actual length of data
86700 + * it's receiving.
86701 + */
86702 + WARN_ON(dump.len != len && dump.len != tmp.len);
86703 + dump.len = len;
86704 +
86705 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
86706 ret = -EFAULT;
86707 goto out;
86708 diff --git a/net/core/flow.c b/net/core/flow.c
86709 index 7102f16..146b4bd 100644
86710 --- a/net/core/flow.c
86711 +++ b/net/core/flow.c
86712 @@ -61,7 +61,7 @@ struct flow_cache {
86713 struct timer_list rnd_timer;
86714 };
86715
86716 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86717 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86718 EXPORT_SYMBOL(flow_cache_genid);
86719 static struct flow_cache flow_cache_global;
86720 static struct kmem_cache *flow_cachep __read_mostly;
86721 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86722
86723 static int flow_entry_valid(struct flow_cache_entry *fle)
86724 {
86725 - if (atomic_read(&flow_cache_genid) != fle->genid)
86726 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86727 return 0;
86728 if (fle->object && !fle->object->ops->check(fle->object))
86729 return 0;
86730 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86731 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86732 fcp->hash_count++;
86733 }
86734 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86735 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86736 flo = fle->object;
86737 if (!flo)
86738 goto ret_object;
86739 @@ -279,7 +279,7 @@ nocache:
86740 }
86741 flo = resolver(net, key, family, dir, flo, ctx);
86742 if (fle) {
86743 - fle->genid = atomic_read(&flow_cache_genid);
86744 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86745 if (!IS_ERR(flo))
86746 fle->object = flo;
86747 else
86748 diff --git a/net/core/iovec.c b/net/core/iovec.c
86749 index de178e4..1dabd8b 100644
86750 --- a/net/core/iovec.c
86751 +++ b/net/core/iovec.c
86752 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86753 if (m->msg_namelen) {
86754 if (mode == VERIFY_READ) {
86755 void __user *namep;
86756 - namep = (void __user __force *) m->msg_name;
86757 + namep = (void __force_user *) m->msg_name;
86758 err = move_addr_to_kernel(namep, m->msg_namelen,
86759 address);
86760 if (err < 0)
86761 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86762 }
86763
86764 size = m->msg_iovlen * sizeof(struct iovec);
86765 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86766 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86767 return -EFAULT;
86768
86769 m->msg_iov = iov;
86770 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86771 index 5c56b21..8766fbf 100644
86772 --- a/net/core/neighbour.c
86773 +++ b/net/core/neighbour.c
86774 @@ -2769,7 +2769,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86775 size_t *lenp, loff_t *ppos)
86776 {
86777 int size, ret;
86778 - ctl_table tmp = *ctl;
86779 + ctl_table_no_const tmp = *ctl;
86780
86781 tmp.extra1 = &zero;
86782 tmp.extra2 = &unres_qlen_max;
86783 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86784 index 569d355..79cf2d0 100644
86785 --- a/net/core/net-procfs.c
86786 +++ b/net/core/net-procfs.c
86787 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86788 else
86789 seq_printf(seq, "%04x", ntohs(pt->type));
86790
86791 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86792 + seq_printf(seq, " %-8s %pf\n",
86793 + pt->dev ? pt->dev->name : "", NULL);
86794 +#else
86795 seq_printf(seq, " %-8s %pf\n",
86796 pt->dev ? pt->dev->name : "", pt->func);
86797 +#endif
86798 }
86799
86800 return 0;
86801 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86802 index 981fed3..536af34 100644
86803 --- a/net/core/net-sysfs.c
86804 +++ b/net/core/net-sysfs.c
86805 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86806 }
86807 EXPORT_SYMBOL(netdev_class_remove_file);
86808
86809 -int netdev_kobject_init(void)
86810 +int __init netdev_kobject_init(void)
86811 {
86812 kobj_ns_type_register(&net_ns_type_operations);
86813 return class_register(&net_class);
86814 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86815 index f9765203..9feaef8 100644
86816 --- a/net/core/net_namespace.c
86817 +++ b/net/core/net_namespace.c
86818 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
86819 int error;
86820 LIST_HEAD(net_exit_list);
86821
86822 - list_add_tail(&ops->list, list);
86823 + pax_list_add_tail((struct list_head *)&ops->list, list);
86824 if (ops->init || (ops->id && ops->size)) {
86825 for_each_net(net) {
86826 error = ops_init(ops, net);
86827 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
86828
86829 out_undo:
86830 /* If I have an error cleanup all namespaces I initialized */
86831 - list_del(&ops->list);
86832 + pax_list_del((struct list_head *)&ops->list);
86833 ops_exit_list(ops, &net_exit_list);
86834 ops_free_list(ops, &net_exit_list);
86835 return error;
86836 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86837 struct net *net;
86838 LIST_HEAD(net_exit_list);
86839
86840 - list_del(&ops->list);
86841 + pax_list_del((struct list_head *)&ops->list);
86842 for_each_net(net)
86843 list_add_tail(&net->exit_list, &net_exit_list);
86844 ops_exit_list(ops, &net_exit_list);
86845 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
86846 mutex_lock(&net_mutex);
86847 error = register_pernet_operations(&pernet_list, ops);
86848 if (!error && (first_device == &pernet_list))
86849 - first_device = &ops->list;
86850 + first_device = (struct list_head *)&ops->list;
86851 mutex_unlock(&net_mutex);
86852 return error;
86853 }
86854 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86855 index a08bd2b..4e8f43c 100644
86856 --- a/net/core/rtnetlink.c
86857 +++ b/net/core/rtnetlink.c
86858 @@ -58,7 +58,7 @@ struct rtnl_link {
86859 rtnl_doit_func doit;
86860 rtnl_dumpit_func dumpit;
86861 rtnl_calcit_func calcit;
86862 -};
86863 +} __no_const;
86864
86865 static DEFINE_MUTEX(rtnl_mutex);
86866
86867 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86868 if (rtnl_link_ops_get(ops->kind))
86869 return -EEXIST;
86870
86871 - if (!ops->dellink)
86872 - ops->dellink = unregister_netdevice_queue;
86873 + if (!ops->dellink) {
86874 + pax_open_kernel();
86875 + *(void **)&ops->dellink = unregister_netdevice_queue;
86876 + pax_close_kernel();
86877 + }
86878
86879 - list_add_tail(&ops->list, &link_ops);
86880 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86881 return 0;
86882 }
86883 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86884 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86885 for_each_net(net) {
86886 __rtnl_kill_links(net, ops);
86887 }
86888 - list_del(&ops->list);
86889 + pax_list_del((struct list_head *)&ops->list);
86890 }
86891 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86892
86893 diff --git a/net/core/scm.c b/net/core/scm.c
86894 index 03795d0..eaf7368 100644
86895 --- a/net/core/scm.c
86896 +++ b/net/core/scm.c
86897 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
86898 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86899 {
86900 struct cmsghdr __user *cm
86901 - = (__force struct cmsghdr __user *)msg->msg_control;
86902 + = (struct cmsghdr __force_user *)msg->msg_control;
86903 struct cmsghdr cmhdr;
86904 int cmlen = CMSG_LEN(len);
86905 int err;
86906 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86907 err = -EFAULT;
86908 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86909 goto out;
86910 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86911 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86912 goto out;
86913 cmlen = CMSG_SPACE(len);
86914 if (msg->msg_controllen < cmlen)
86915 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
86916 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86917 {
86918 struct cmsghdr __user *cm
86919 - = (__force struct cmsghdr __user*)msg->msg_control;
86920 + = (struct cmsghdr __force_user *)msg->msg_control;
86921
86922 int fdmax = 0;
86923 int fdnum = scm->fp->count;
86924 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86925 if (fdnum < fdmax)
86926 fdmax = fdnum;
86927
86928 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86929 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86930 i++, cmfptr++)
86931 {
86932 struct socket *sock;
86933 diff --git a/net/core/sock.c b/net/core/sock.c
86934 index d6d024c..6ea7ab4 100644
86935 --- a/net/core/sock.c
86936 +++ b/net/core/sock.c
86937 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86938 struct sk_buff_head *list = &sk->sk_receive_queue;
86939
86940 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86941 - atomic_inc(&sk->sk_drops);
86942 + atomic_inc_unchecked(&sk->sk_drops);
86943 trace_sock_rcvqueue_full(sk, skb);
86944 return -ENOMEM;
86945 }
86946 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86947 return err;
86948
86949 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86950 - atomic_inc(&sk->sk_drops);
86951 + atomic_inc_unchecked(&sk->sk_drops);
86952 return -ENOBUFS;
86953 }
86954
86955 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86956 skb_dst_force(skb);
86957
86958 spin_lock_irqsave(&list->lock, flags);
86959 - skb->dropcount = atomic_read(&sk->sk_drops);
86960 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86961 __skb_queue_tail(list, skb);
86962 spin_unlock_irqrestore(&list->lock, flags);
86963
86964 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86965 skb->dev = NULL;
86966
86967 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86968 - atomic_inc(&sk->sk_drops);
86969 + atomic_inc_unchecked(&sk->sk_drops);
86970 goto discard_and_relse;
86971 }
86972 if (nested)
86973 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86974 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86975 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86976 bh_unlock_sock(sk);
86977 - atomic_inc(&sk->sk_drops);
86978 + atomic_inc_unchecked(&sk->sk_drops);
86979 goto discard_and_relse;
86980 }
86981
86982 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86983 struct timeval tm;
86984 } v;
86985
86986 - int lv = sizeof(int);
86987 - int len;
86988 + unsigned int lv = sizeof(int);
86989 + unsigned int len;
86990
86991 if (get_user(len, optlen))
86992 return -EFAULT;
86993 - if (len < 0)
86994 + if (len > INT_MAX)
86995 return -EINVAL;
86996
86997 memset(&v, 0, sizeof(v));
86998 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86999
87000 case SO_PEERNAME:
87001 {
87002 - char address[128];
87003 + char address[_K_SS_MAXSIZE];
87004
87005 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
87006 return -ENOTCONN;
87007 - if (lv < len)
87008 + if (lv < len || sizeof address < len)
87009 return -EINVAL;
87010 if (copy_to_user(optval, address, len))
87011 return -EFAULT;
87012 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87013
87014 if (len > lv)
87015 len = lv;
87016 - if (copy_to_user(optval, &v, len))
87017 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
87018 return -EFAULT;
87019 lenout:
87020 if (put_user(len, optlen))
87021 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
87022 */
87023 smp_wmb();
87024 atomic_set(&sk->sk_refcnt, 1);
87025 - atomic_set(&sk->sk_drops, 0);
87026 + atomic_set_unchecked(&sk->sk_drops, 0);
87027 }
87028 EXPORT_SYMBOL(sock_init_data);
87029
87030 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
87031 index a0e9cf6..ef7f9ed 100644
87032 --- a/net/core/sock_diag.c
87033 +++ b/net/core/sock_diag.c
87034 @@ -9,26 +9,33 @@
87035 #include <linux/inet_diag.h>
87036 #include <linux/sock_diag.h>
87037
87038 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
87039 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
87040 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
87041 static DEFINE_MUTEX(sock_diag_table_mutex);
87042
87043 int sock_diag_check_cookie(void *sk, __u32 *cookie)
87044 {
87045 +#ifndef CONFIG_GRKERNSEC_HIDESYM
87046 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
87047 cookie[1] != INET_DIAG_NOCOOKIE) &&
87048 ((u32)(unsigned long)sk != cookie[0] ||
87049 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
87050 return -ESTALE;
87051 else
87052 +#endif
87053 return 0;
87054 }
87055 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
87056
87057 void sock_diag_save_cookie(void *sk, __u32 *cookie)
87058 {
87059 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87060 + cookie[0] = 0;
87061 + cookie[1] = 0;
87062 +#else
87063 cookie[0] = (u32)(unsigned long)sk;
87064 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
87065 +#endif
87066 }
87067 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
87068
87069 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
87070 mutex_lock(&sock_diag_table_mutex);
87071 if (sock_diag_handlers[hndl->family])
87072 err = -EBUSY;
87073 - else
87074 + else {
87075 + pax_open_kernel();
87076 sock_diag_handlers[hndl->family] = hndl;
87077 + pax_close_kernel();
87078 + }
87079 mutex_unlock(&sock_diag_table_mutex);
87080
87081 return err;
87082 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
87083
87084 mutex_lock(&sock_diag_table_mutex);
87085 BUG_ON(sock_diag_handlers[family] != hnld);
87086 + pax_open_kernel();
87087 sock_diag_handlers[family] = NULL;
87088 + pax_close_kernel();
87089 mutex_unlock(&sock_diag_table_mutex);
87090 }
87091 EXPORT_SYMBOL_GPL(sock_diag_unregister);
87092 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
87093 index cfdb46a..cef55e1 100644
87094 --- a/net/core/sysctl_net_core.c
87095 +++ b/net/core/sysctl_net_core.c
87096 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
87097 {
87098 unsigned int orig_size, size;
87099 int ret, i;
87100 - ctl_table tmp = {
87101 + ctl_table_no_const tmp = {
87102 .data = &size,
87103 .maxlen = sizeof(size),
87104 .mode = table->mode
87105 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
87106
87107 static __net_init int sysctl_core_net_init(struct net *net)
87108 {
87109 - struct ctl_table *tbl;
87110 + ctl_table_no_const *tbl = NULL;
87111
87112 net->core.sysctl_somaxconn = SOMAXCONN;
87113
87114 - tbl = netns_core_table;
87115 if (!net_eq(net, &init_net)) {
87116 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
87117 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
87118 if (tbl == NULL)
87119 goto err_dup;
87120
87121 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
87122 if (net->user_ns != &init_user_ns) {
87123 tbl[0].procname = NULL;
87124 }
87125 - }
87126 -
87127 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87128 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87129 + } else
87130 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
87131 if (net->core.sysctl_hdr == NULL)
87132 goto err_reg;
87133
87134 return 0;
87135
87136 err_reg:
87137 - if (tbl != netns_core_table)
87138 - kfree(tbl);
87139 + kfree(tbl);
87140 err_dup:
87141 return -ENOMEM;
87142 }
87143 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
87144 kfree(tbl);
87145 }
87146
87147 -static __net_initdata struct pernet_operations sysctl_core_ops = {
87148 +static __net_initconst struct pernet_operations sysctl_core_ops = {
87149 .init = sysctl_core_net_init,
87150 .exit = sysctl_core_net_exit,
87151 };
87152 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
87153 index c21f200..bc4565b 100644
87154 --- a/net/decnet/af_decnet.c
87155 +++ b/net/decnet/af_decnet.c
87156 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
87157 .sysctl_rmem = sysctl_decnet_rmem,
87158 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
87159 .obj_size = sizeof(struct dn_sock),
87160 + .slab_flags = SLAB_USERCOPY,
87161 };
87162
87163 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
87164 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
87165 index a55eecc..dd8428c 100644
87166 --- a/net/decnet/sysctl_net_decnet.c
87167 +++ b/net/decnet/sysctl_net_decnet.c
87168 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
87169
87170 if (len > *lenp) len = *lenp;
87171
87172 - if (copy_to_user(buffer, addr, len))
87173 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
87174 return -EFAULT;
87175
87176 *lenp = len;
87177 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
87178
87179 if (len > *lenp) len = *lenp;
87180
87181 - if (copy_to_user(buffer, devname, len))
87182 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
87183 return -EFAULT;
87184
87185 *lenp = len;
87186 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
87187 index d01be2a..8976537 100644
87188 --- a/net/ipv4/af_inet.c
87189 +++ b/net/ipv4/af_inet.c
87190 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
87191
87192 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
87193
87194 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
87195 - if (!sysctl_local_reserved_ports)
87196 - goto out;
87197 -
87198 rc = proto_register(&tcp_prot, 1);
87199 if (rc)
87200 - goto out_free_reserved_ports;
87201 + goto out;
87202
87203 rc = proto_register(&udp_prot, 1);
87204 if (rc)
87205 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
87206 proto_unregister(&udp_prot);
87207 out_unregister_tcp_proto:
87208 proto_unregister(&tcp_prot);
87209 -out_free_reserved_ports:
87210 - kfree(sysctl_local_reserved_ports);
87211 goto out;
87212 }
87213
87214 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
87215 index 2e7f194..0fa4d6d 100644
87216 --- a/net/ipv4/ah4.c
87217 +++ b/net/ipv4/ah4.c
87218 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
87219 return;
87220
87221 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87222 - atomic_inc(&flow_cache_genid);
87223 + atomic_inc_unchecked(&flow_cache_genid);
87224 rt_genid_bump(net);
87225
87226 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
87227 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
87228 index dfc39d4..0b82c4d 100644
87229 --- a/net/ipv4/devinet.c
87230 +++ b/net/ipv4/devinet.c
87231 @@ -1529,7 +1529,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
87232 idx = 0;
87233 head = &net->dev_index_head[h];
87234 rcu_read_lock();
87235 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87236 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87237 net->dev_base_seq;
87238 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87239 if (idx < s_idx)
87240 @@ -1840,7 +1840,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
87241 idx = 0;
87242 head = &net->dev_index_head[h];
87243 rcu_read_lock();
87244 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87245 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87246 net->dev_base_seq;
87247 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87248 if (idx < s_idx)
87249 @@ -2065,7 +2065,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
87250 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
87251 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
87252
87253 -static struct devinet_sysctl_table {
87254 +static const struct devinet_sysctl_table {
87255 struct ctl_table_header *sysctl_header;
87256 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
87257 } devinet_sysctl = {
87258 @@ -2183,7 +2183,7 @@ static __net_init int devinet_init_net(struct net *net)
87259 int err;
87260 struct ipv4_devconf *all, *dflt;
87261 #ifdef CONFIG_SYSCTL
87262 - struct ctl_table *tbl = ctl_forward_entry;
87263 + ctl_table_no_const *tbl = NULL;
87264 struct ctl_table_header *forw_hdr;
87265 #endif
87266
87267 @@ -2201,7 +2201,7 @@ static __net_init int devinet_init_net(struct net *net)
87268 goto err_alloc_dflt;
87269
87270 #ifdef CONFIG_SYSCTL
87271 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
87272 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
87273 if (tbl == NULL)
87274 goto err_alloc_ctl;
87275
87276 @@ -2221,7 +2221,10 @@ static __net_init int devinet_init_net(struct net *net)
87277 goto err_reg_dflt;
87278
87279 err = -ENOMEM;
87280 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87281 + if (!net_eq(net, &init_net))
87282 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87283 + else
87284 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
87285 if (forw_hdr == NULL)
87286 goto err_reg_ctl;
87287 net->ipv4.forw_hdr = forw_hdr;
87288 @@ -2237,8 +2240,7 @@ err_reg_ctl:
87289 err_reg_dflt:
87290 __devinet_sysctl_unregister(all);
87291 err_reg_all:
87292 - if (tbl != ctl_forward_entry)
87293 - kfree(tbl);
87294 + kfree(tbl);
87295 err_alloc_ctl:
87296 #endif
87297 if (dflt != &ipv4_devconf_dflt)
87298 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87299 index 4cfe34d..a6ba66e 100644
87300 --- a/net/ipv4/esp4.c
87301 +++ b/net/ipv4/esp4.c
87302 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87303 return;
87304
87305 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87306 - atomic_inc(&flow_cache_genid);
87307 + atomic_inc_unchecked(&flow_cache_genid);
87308 rt_genid_bump(net);
87309
87310 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87311 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87312 index c7629a2..b62d139 100644
87313 --- a/net/ipv4/fib_frontend.c
87314 +++ b/net/ipv4/fib_frontend.c
87315 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87316 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87317 fib_sync_up(dev);
87318 #endif
87319 - atomic_inc(&net->ipv4.dev_addr_genid);
87320 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87321 rt_cache_flush(dev_net(dev));
87322 break;
87323 case NETDEV_DOWN:
87324 fib_del_ifaddr(ifa, NULL);
87325 - atomic_inc(&net->ipv4.dev_addr_genid);
87326 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87327 if (ifa->ifa_dev->ifa_list == NULL) {
87328 /* Last address was deleted from this interface.
87329 * Disable IP.
87330 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87331 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87332 fib_sync_up(dev);
87333 #endif
87334 - atomic_inc(&net->ipv4.dev_addr_genid);
87335 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87336 rt_cache_flush(net);
87337 break;
87338 case NETDEV_DOWN:
87339 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87340 index 8f6cb7a..34507f9 100644
87341 --- a/net/ipv4/fib_semantics.c
87342 +++ b/net/ipv4/fib_semantics.c
87343 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87344 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87345 nh->nh_gw,
87346 nh->nh_parent->fib_scope);
87347 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87348 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87349
87350 return nh->nh_saddr;
87351 }
87352 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87353 index 6acb541..9ea617d 100644
87354 --- a/net/ipv4/inet_connection_sock.c
87355 +++ b/net/ipv4/inet_connection_sock.c
87356 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87357 .range = { 32768, 61000 },
87358 };
87359
87360 -unsigned long *sysctl_local_reserved_ports;
87361 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87362 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87363
87364 void inet_get_local_port_range(int *low, int *high)
87365 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87366 index 6af375a..c493c74 100644
87367 --- a/net/ipv4/inet_hashtables.c
87368 +++ b/net/ipv4/inet_hashtables.c
87369 @@ -18,12 +18,15 @@
87370 #include <linux/sched.h>
87371 #include <linux/slab.h>
87372 #include <linux/wait.h>
87373 +#include <linux/security.h>
87374
87375 #include <net/inet_connection_sock.h>
87376 #include <net/inet_hashtables.h>
87377 #include <net/secure_seq.h>
87378 #include <net/ip.h>
87379
87380 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87381 +
87382 /*
87383 * Allocate and initialize a new local port bind bucket.
87384 * The bindhash mutex for snum's hash chain must be held here.
87385 @@ -554,6 +557,8 @@ ok:
87386 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87387 spin_unlock(&head->lock);
87388
87389 + gr_update_task_in_ip_table(current, inet_sk(sk));
87390 +
87391 if (tw) {
87392 inet_twsk_deschedule(tw, death_row);
87393 while (twrefcnt) {
87394 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87395 index 000e3d2..5472da3 100644
87396 --- a/net/ipv4/inetpeer.c
87397 +++ b/net/ipv4/inetpeer.c
87398 @@ -503,8 +503,8 @@ relookup:
87399 if (p) {
87400 p->daddr = *daddr;
87401 atomic_set(&p->refcnt, 1);
87402 - atomic_set(&p->rid, 0);
87403 - atomic_set(&p->ip_id_count,
87404 + atomic_set_unchecked(&p->rid, 0);
87405 + atomic_set_unchecked(&p->ip_id_count,
87406 (daddr->family == AF_INET) ?
87407 secure_ip_id(daddr->addr.a4) :
87408 secure_ipv6_id(daddr->addr.a6));
87409 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87410 index b66910a..cfe416e 100644
87411 --- a/net/ipv4/ip_fragment.c
87412 +++ b/net/ipv4/ip_fragment.c
87413 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87414 return 0;
87415
87416 start = qp->rid;
87417 - end = atomic_inc_return(&peer->rid);
87418 + end = atomic_inc_return_unchecked(&peer->rid);
87419 qp->rid = end;
87420
87421 rc = qp->q.fragments && (end - start) > max;
87422 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87423
87424 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87425 {
87426 - struct ctl_table *table;
87427 + ctl_table_no_const *table = NULL;
87428 struct ctl_table_header *hdr;
87429
87430 - table = ip4_frags_ns_ctl_table;
87431 if (!net_eq(net, &init_net)) {
87432 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87433 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87434 if (table == NULL)
87435 goto err_alloc;
87436
87437 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87438 /* Don't export sysctls to unprivileged users */
87439 if (net->user_ns != &init_user_ns)
87440 table[0].procname = NULL;
87441 - }
87442 + hdr = register_net_sysctl(net, "net/ipv4", table);
87443 + } else
87444 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87445
87446 - hdr = register_net_sysctl(net, "net/ipv4", table);
87447 if (hdr == NULL)
87448 goto err_reg;
87449
87450 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87451 return 0;
87452
87453 err_reg:
87454 - if (!net_eq(net, &init_net))
87455 - kfree(table);
87456 + kfree(table);
87457 err_alloc:
87458 return -ENOMEM;
87459 }
87460 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87461 index 2a83591..68e7458 100644
87462 --- a/net/ipv4/ip_gre.c
87463 +++ b/net/ipv4/ip_gre.c
87464 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
87465 module_param(log_ecn_error, bool, 0644);
87466 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87467
87468 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87469 +static struct rtnl_link_ops ipgre_link_ops;
87470 static int ipgre_tunnel_init(struct net_device *dev);
87471
87472 static int ipgre_net_id __read_mostly;
87473 @@ -503,10 +503,11 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
87474
87475 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
87476 return -EFAULT;
87477 - if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
87478 - p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
87479 - ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING))) {
87480 - return -EINVAL;
87481 + if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
87482 + if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
87483 + p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
87484 + ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING)))
87485 + return -EINVAL;
87486 }
87487 p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
87488 p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
87489 @@ -918,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87490 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87491 };
87492
87493 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87494 +static struct rtnl_link_ops ipgre_link_ops = {
87495 .kind = "gre",
87496 .maxtype = IFLA_GRE_MAX,
87497 .policy = ipgre_policy,
87498 @@ -932,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87499 .fill_info = ipgre_fill_info,
87500 };
87501
87502 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87503 +static struct rtnl_link_ops ipgre_tap_ops = {
87504 .kind = "gretap",
87505 .maxtype = IFLA_GRE_MAX,
87506 .policy = ipgre_policy,
87507 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87508 index d9c4f11..02b82dbc 100644
87509 --- a/net/ipv4/ip_sockglue.c
87510 +++ b/net/ipv4/ip_sockglue.c
87511 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87512 len = min_t(unsigned int, len, opt->optlen);
87513 if (put_user(len, optlen))
87514 return -EFAULT;
87515 - if (copy_to_user(optval, opt->__data, len))
87516 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87517 + copy_to_user(optval, opt->__data, len))
87518 return -EFAULT;
87519 return 0;
87520 }
87521 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87522 if (sk->sk_type != SOCK_STREAM)
87523 return -ENOPROTOOPT;
87524
87525 - msg.msg_control = optval;
87526 + msg.msg_control = (void __force_kernel *)optval;
87527 msg.msg_controllen = len;
87528 msg.msg_flags = flags;
87529
87530 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87531 index c118f6b..63856c4 100644
87532 --- a/net/ipv4/ip_vti.c
87533 +++ b/net/ipv4/ip_vti.c
87534 @@ -47,7 +47,7 @@
87535 #define HASH_SIZE 16
87536 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87537
87538 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87539 +static struct rtnl_link_ops vti_link_ops;
87540
87541 static int vti_net_id __read_mostly;
87542 struct vti_net {
87543 @@ -606,17 +606,10 @@ static int __net_init vti_fb_tunnel_init(struct net_device *dev)
87544 struct iphdr *iph = &tunnel->parms.iph;
87545 struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);
87546
87547 - tunnel->dev = dev;
87548 - strcpy(tunnel->parms.name, dev->name);
87549 -
87550 iph->version = 4;
87551 iph->protocol = IPPROTO_IPIP;
87552 iph->ihl = 5;
87553
87554 - dev->tstats = alloc_percpu(struct pcpu_tstats);
87555 - if (!dev->tstats)
87556 - return -ENOMEM;
87557 -
87558 dev_hold(dev);
87559 rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
87560 return 0;
87561 @@ -847,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87562 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87563 };
87564
87565 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87566 +static struct rtnl_link_ops vti_link_ops = {
87567 .kind = "vti",
87568 .maxtype = IFLA_VTI_MAX,
87569 .policy = vti_policy,
87570 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87571 index 59cb8c7..a72160c 100644
87572 --- a/net/ipv4/ipcomp.c
87573 +++ b/net/ipv4/ipcomp.c
87574 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87575 return;
87576
87577 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87578 - atomic_inc(&flow_cache_genid);
87579 + atomic_inc_unchecked(&flow_cache_genid);
87580 rt_genid_bump(net);
87581
87582 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87583 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87584 index efa1138..20dbba0 100644
87585 --- a/net/ipv4/ipconfig.c
87586 +++ b/net/ipv4/ipconfig.c
87587 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87588
87589 mm_segment_t oldfs = get_fs();
87590 set_fs(get_ds());
87591 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87592 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87593 set_fs(oldfs);
87594 return res;
87595 }
87596 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87597
87598 mm_segment_t oldfs = get_fs();
87599 set_fs(get_ds());
87600 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87601 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87602 set_fs(oldfs);
87603 return res;
87604 }
87605 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87606
87607 mm_segment_t oldfs = get_fs();
87608 set_fs(get_ds());
87609 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87610 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87611 set_fs(oldfs);
87612 return res;
87613 }
87614 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87615 index 77bfcce..64a55d4 100644
87616 --- a/net/ipv4/ipip.c
87617 +++ b/net/ipv4/ipip.c
87618 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87619 static int ipip_net_id __read_mostly;
87620
87621 static int ipip_tunnel_init(struct net_device *dev);
87622 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87623 +static struct rtnl_link_ops ipip_link_ops;
87624
87625 static int ipip_err(struct sk_buff *skb, u32 info)
87626 {
87627 @@ -404,7 +404,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87628 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87629 };
87630
87631 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87632 +static struct rtnl_link_ops ipip_link_ops = {
87633 .kind = "ipip",
87634 .maxtype = IFLA_IPTUN_MAX,
87635 .policy = ipip_policy,
87636 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87637 index 85a4f21..1beb1f5 100644
87638 --- a/net/ipv4/netfilter/arp_tables.c
87639 +++ b/net/ipv4/netfilter/arp_tables.c
87640 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
87641 #endif
87642
87643 static int get_info(struct net *net, void __user *user,
87644 - const int *len, int compat)
87645 + int len, int compat)
87646 {
87647 char name[XT_TABLE_MAXNAMELEN];
87648 struct xt_table *t;
87649 int ret;
87650
87651 - if (*len != sizeof(struct arpt_getinfo)) {
87652 - duprintf("length %u != %Zu\n", *len,
87653 + if (len != sizeof(struct arpt_getinfo)) {
87654 + duprintf("length %u != %Zu\n", len,
87655 sizeof(struct arpt_getinfo));
87656 return -EINVAL;
87657 }
87658 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
87659 info.size = private->size;
87660 strcpy(info.name, name);
87661
87662 - if (copy_to_user(user, &info, *len) != 0)
87663 + if (copy_to_user(user, &info, len) != 0)
87664 ret = -EFAULT;
87665 else
87666 ret = 0;
87667 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87668
87669 switch (cmd) {
87670 case ARPT_SO_GET_INFO:
87671 - ret = get_info(sock_net(sk), user, len, 1);
87672 + ret = get_info(sock_net(sk), user, *len, 1);
87673 break;
87674 case ARPT_SO_GET_ENTRIES:
87675 ret = compat_get_entries(sock_net(sk), user, len);
87676 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87677
87678 switch (cmd) {
87679 case ARPT_SO_GET_INFO:
87680 - ret = get_info(sock_net(sk), user, len, 0);
87681 + ret = get_info(sock_net(sk), user, *len, 0);
87682 break;
87683
87684 case ARPT_SO_GET_ENTRIES:
87685 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87686 index d23118d..6ad7277 100644
87687 --- a/net/ipv4/netfilter/ip_tables.c
87688 +++ b/net/ipv4/netfilter/ip_tables.c
87689 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87690 #endif
87691
87692 static int get_info(struct net *net, void __user *user,
87693 - const int *len, int compat)
87694 + int len, int compat)
87695 {
87696 char name[XT_TABLE_MAXNAMELEN];
87697 struct xt_table *t;
87698 int ret;
87699
87700 - if (*len != sizeof(struct ipt_getinfo)) {
87701 - duprintf("length %u != %zu\n", *len,
87702 + if (len != sizeof(struct ipt_getinfo)) {
87703 + duprintf("length %u != %zu\n", len,
87704 sizeof(struct ipt_getinfo));
87705 return -EINVAL;
87706 }
87707 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87708 info.size = private->size;
87709 strcpy(info.name, name);
87710
87711 - if (copy_to_user(user, &info, *len) != 0)
87712 + if (copy_to_user(user, &info, len) != 0)
87713 ret = -EFAULT;
87714 else
87715 ret = 0;
87716 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87717
87718 switch (cmd) {
87719 case IPT_SO_GET_INFO:
87720 - ret = get_info(sock_net(sk), user, len, 1);
87721 + ret = get_info(sock_net(sk), user, *len, 1);
87722 break;
87723 case IPT_SO_GET_ENTRIES:
87724 ret = compat_get_entries(sock_net(sk), user, len);
87725 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87726
87727 switch (cmd) {
87728 case IPT_SO_GET_INFO:
87729 - ret = get_info(sock_net(sk), user, len, 0);
87730 + ret = get_info(sock_net(sk), user, *len, 0);
87731 break;
87732
87733 case IPT_SO_GET_ENTRIES:
87734 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87735 index 7d93d62..cbbf2a3 100644
87736 --- a/net/ipv4/ping.c
87737 +++ b/net/ipv4/ping.c
87738 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87739 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87740 0, sock_i_ino(sp),
87741 atomic_read(&sp->sk_refcnt), sp,
87742 - atomic_read(&sp->sk_drops), len);
87743 + atomic_read_unchecked(&sp->sk_drops), len);
87744 }
87745
87746 static int ping_seq_show(struct seq_file *seq, void *v)
87747 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87748 index dd44e0a..06dcca4 100644
87749 --- a/net/ipv4/raw.c
87750 +++ b/net/ipv4/raw.c
87751 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87752 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87753 {
87754 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87755 - atomic_inc(&sk->sk_drops);
87756 + atomic_inc_unchecked(&sk->sk_drops);
87757 kfree_skb(skb);
87758 return NET_RX_DROP;
87759 }
87760 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87761
87762 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87763 {
87764 + struct icmp_filter filter;
87765 +
87766 if (optlen > sizeof(struct icmp_filter))
87767 optlen = sizeof(struct icmp_filter);
87768 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87769 + if (copy_from_user(&filter, optval, optlen))
87770 return -EFAULT;
87771 + raw_sk(sk)->filter = filter;
87772 return 0;
87773 }
87774
87775 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87776 {
87777 int len, ret = -EFAULT;
87778 + struct icmp_filter filter;
87779
87780 if (get_user(len, optlen))
87781 goto out;
87782 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87783 if (len > sizeof(struct icmp_filter))
87784 len = sizeof(struct icmp_filter);
87785 ret = -EFAULT;
87786 - if (put_user(len, optlen) ||
87787 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87788 + filter = raw_sk(sk)->filter;
87789 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87790 goto out;
87791 ret = 0;
87792 out: return ret;
87793 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87794 0, 0L, 0,
87795 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87796 0, sock_i_ino(sp),
87797 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87798 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87799 }
87800
87801 static int raw_seq_show(struct seq_file *seq, void *v)
87802 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87803 index d35bbf0..faa3ab8 100644
87804 --- a/net/ipv4/route.c
87805 +++ b/net/ipv4/route.c
87806 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87807 .maxlen = sizeof(int),
87808 .mode = 0200,
87809 .proc_handler = ipv4_sysctl_rtcache_flush,
87810 + .extra1 = &init_net,
87811 },
87812 { },
87813 };
87814
87815 static __net_init int sysctl_route_net_init(struct net *net)
87816 {
87817 - struct ctl_table *tbl;
87818 + ctl_table_no_const *tbl = NULL;
87819
87820 - tbl = ipv4_route_flush_table;
87821 if (!net_eq(net, &init_net)) {
87822 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87823 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87824 if (tbl == NULL)
87825 goto err_dup;
87826
87827 /* Don't export sysctls to unprivileged users */
87828 if (net->user_ns != &init_user_ns)
87829 tbl[0].procname = NULL;
87830 - }
87831 - tbl[0].extra1 = net;
87832 + tbl[0].extra1 = net;
87833 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87834 + } else
87835 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87836
87837 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87838 if (net->ipv4.route_hdr == NULL)
87839 goto err_reg;
87840 return 0;
87841
87842 err_reg:
87843 - if (tbl != ipv4_route_flush_table)
87844 - kfree(tbl);
87845 + kfree(tbl);
87846 err_dup:
87847 return -ENOMEM;
87848 }
87849 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87850
87851 static __net_init int rt_genid_init(struct net *net)
87852 {
87853 - atomic_set(&net->rt_genid, 0);
87854 + atomic_set_unchecked(&net->rt_genid, 0);
87855 get_random_bytes(&net->ipv4.dev_addr_genid,
87856 sizeof(net->ipv4.dev_addr_genid));
87857 return 0;
87858 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87859 index fa2f63f..6554815 100644
87860 --- a/net/ipv4/sysctl_net_ipv4.c
87861 +++ b/net/ipv4/sysctl_net_ipv4.c
87862 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87863 {
87864 int ret;
87865 int range[2];
87866 - ctl_table tmp = {
87867 + ctl_table_no_const tmp = {
87868 .data = &range,
87869 .maxlen = sizeof(range),
87870 .mode = table->mode,
87871 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87872 int ret;
87873 gid_t urange[2];
87874 kgid_t low, high;
87875 - ctl_table tmp = {
87876 + ctl_table_no_const tmp = {
87877 .data = &urange,
87878 .maxlen = sizeof(urange),
87879 .mode = table->mode,
87880 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87881 void __user *buffer, size_t *lenp, loff_t *ppos)
87882 {
87883 char val[TCP_CA_NAME_MAX];
87884 - ctl_table tbl = {
87885 + ctl_table_no_const tbl = {
87886 .data = val,
87887 .maxlen = TCP_CA_NAME_MAX,
87888 };
87889 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87890 void __user *buffer, size_t *lenp,
87891 loff_t *ppos)
87892 {
87893 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87894 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87895 int ret;
87896
87897 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87898 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87899 void __user *buffer, size_t *lenp,
87900 loff_t *ppos)
87901 {
87902 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87903 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87904 int ret;
87905
87906 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87907 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87908 struct mem_cgroup *memcg;
87909 #endif
87910
87911 - ctl_table tmp = {
87912 + ctl_table_no_const tmp = {
87913 .data = &vec,
87914 .maxlen = sizeof(vec),
87915 .mode = ctl->mode,
87916 };
87917
87918 if (!write) {
87919 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87920 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87921 + ctl_table_no_const tcp_mem = *ctl;
87922 +
87923 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87924 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87925 }
87926
87927 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87928 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87929 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87930 size_t *lenp, loff_t *ppos)
87931 {
87932 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87933 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87934 struct tcp_fastopen_context *ctxt;
87935 int ret;
87936 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87937 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87938 },
87939 {
87940 .procname = "ip_local_reserved_ports",
87941 - .data = NULL, /* initialized in sysctl_ipv4_init */
87942 + .data = sysctl_local_reserved_ports,
87943 .maxlen = 65536,
87944 .mode = 0644,
87945 .proc_handler = proc_do_large_bitmap,
87946 @@ -842,11 +844,10 @@ static struct ctl_table ipv4_net_table[] = {
87947
87948 static __net_init int ipv4_sysctl_init_net(struct net *net)
87949 {
87950 - struct ctl_table *table;
87951 + ctl_table_no_const *table = NULL;
87952
87953 - table = ipv4_net_table;
87954 if (!net_eq(net, &init_net)) {
87955 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87956 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87957 if (table == NULL)
87958 goto err_alloc;
87959
87960 @@ -881,15 +882,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87961
87962 tcp_init_mem(net);
87963
87964 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87965 + if (!net_eq(net, &init_net))
87966 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87967 + else
87968 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87969 if (net->ipv4.ipv4_hdr == NULL)
87970 goto err_reg;
87971
87972 return 0;
87973
87974 err_reg:
87975 - if (!net_eq(net, &init_net))
87976 - kfree(table);
87977 + kfree(table);
87978 err_alloc:
87979 return -ENOMEM;
87980 }
87981 @@ -911,16 +914,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87982 static __init int sysctl_ipv4_init(void)
87983 {
87984 struct ctl_table_header *hdr;
87985 - struct ctl_table *i;
87986 -
87987 - for (i = ipv4_table; i->procname; i++) {
87988 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87989 - i->data = sysctl_local_reserved_ports;
87990 - break;
87991 - }
87992 - }
87993 - if (!i->procname)
87994 - return -EINVAL;
87995
87996 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87997 if (hdr == NULL)
87998 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87999 index 9c62257..651cc27 100644
88000 --- a/net/ipv4/tcp_input.c
88001 +++ b/net/ipv4/tcp_input.c
88002 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
88003 * simplifies code)
88004 */
88005 static void
88006 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88007 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88008 struct sk_buff *head, struct sk_buff *tail,
88009 u32 start, u32 end)
88010 {
88011 @@ -5522,6 +5522,7 @@ discard:
88012 tcp_paws_reject(&tp->rx_opt, 0))
88013 goto discard_and_undo;
88014
88015 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
88016 if (th->syn) {
88017 /* We see SYN without ACK. It is attempt of
88018 * simultaneous connect with crossed SYNs.
88019 @@ -5572,6 +5573,7 @@ discard:
88020 goto discard;
88021 #endif
88022 }
88023 +#endif
88024 /* "fifth, if neither of the SYN or RST bits is set then
88025 * drop the segment and return."
88026 */
88027 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
88028 goto discard;
88029
88030 if (th->syn) {
88031 - if (th->fin)
88032 + if (th->fin || th->urg || th->psh)
88033 goto discard;
88034 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
88035 return 1;
88036 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
88037 index 7999fc5..c812f42 100644
88038 --- a/net/ipv4/tcp_ipv4.c
88039 +++ b/net/ipv4/tcp_ipv4.c
88040 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
88041 EXPORT_SYMBOL(sysctl_tcp_low_latency);
88042
88043
88044 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88045 +extern int grsec_enable_blackhole;
88046 +#endif
88047 +
88048 #ifdef CONFIG_TCP_MD5SIG
88049 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
88050 __be32 daddr, __be32 saddr, const struct tcphdr *th);
88051 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
88052 return 0;
88053
88054 reset:
88055 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88056 + if (!grsec_enable_blackhole)
88057 +#endif
88058 tcp_v4_send_reset(rsk, skb);
88059 discard:
88060 kfree_skb(skb);
88061 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
88062 TCP_SKB_CB(skb)->sacked = 0;
88063
88064 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88065 - if (!sk)
88066 + if (!sk) {
88067 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88068 + ret = 1;
88069 +#endif
88070 goto no_tcp_socket;
88071 -
88072 + }
88073 process:
88074 - if (sk->sk_state == TCP_TIME_WAIT)
88075 + if (sk->sk_state == TCP_TIME_WAIT) {
88076 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88077 + ret = 2;
88078 +#endif
88079 goto do_time_wait;
88080 + }
88081
88082 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
88083 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88084 @@ -2058,6 +2072,10 @@ csum_error:
88085 bad_packet:
88086 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88087 } else {
88088 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88089 + if (!grsec_enable_blackhole || (ret == 1 &&
88090 + (skb->dev->flags & IFF_LOOPBACK)))
88091 +#endif
88092 tcp_v4_send_reset(NULL, skb);
88093 }
88094
88095 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
88096 index 0f01788..d52a859 100644
88097 --- a/net/ipv4/tcp_minisocks.c
88098 +++ b/net/ipv4/tcp_minisocks.c
88099 @@ -27,6 +27,10 @@
88100 #include <net/inet_common.h>
88101 #include <net/xfrm.h>
88102
88103 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88104 +extern int grsec_enable_blackhole;
88105 +#endif
88106 +
88107 int sysctl_tcp_syncookies __read_mostly = 1;
88108 EXPORT_SYMBOL(sysctl_tcp_syncookies);
88109
88110 @@ -717,7 +721,10 @@ embryonic_reset:
88111 * avoid becoming vulnerable to outside attack aiming at
88112 * resetting legit local connections.
88113 */
88114 - req->rsk_ops->send_reset(sk, skb);
88115 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88116 + if (!grsec_enable_blackhole)
88117 +#endif
88118 + req->rsk_ops->send_reset(sk, skb);
88119 } else if (fastopen) { /* received a valid RST pkt */
88120 reqsk_fastopen_remove(sk, req, true);
88121 tcp_reset(sk);
88122 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
88123 index d4943f6..e7a74a5 100644
88124 --- a/net/ipv4/tcp_probe.c
88125 +++ b/net/ipv4/tcp_probe.c
88126 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
88127 if (cnt + width >= len)
88128 break;
88129
88130 - if (copy_to_user(buf + cnt, tbuf, width))
88131 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
88132 return -EFAULT;
88133 cnt += width;
88134 }
88135 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
88136 index 4b85e6f..22f9ac9 100644
88137 --- a/net/ipv4/tcp_timer.c
88138 +++ b/net/ipv4/tcp_timer.c
88139 @@ -22,6 +22,10 @@
88140 #include <linux/gfp.h>
88141 #include <net/tcp.h>
88142
88143 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88144 +extern int grsec_lastack_retries;
88145 +#endif
88146 +
88147 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
88148 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
88149 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
88150 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
88151 }
88152 }
88153
88154 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88155 + if ((sk->sk_state == TCP_LAST_ACK) &&
88156 + (grsec_lastack_retries > 0) &&
88157 + (grsec_lastack_retries < retry_until))
88158 + retry_until = grsec_lastack_retries;
88159 +#endif
88160 +
88161 if (retransmits_timed_out(sk, retry_until,
88162 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
88163 /* Has it gone just too far? */
88164 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
88165 index 0bf5d399..5a2dd92 100644
88166 --- a/net/ipv4/udp.c
88167 +++ b/net/ipv4/udp.c
88168 @@ -87,6 +87,7 @@
88169 #include <linux/types.h>
88170 #include <linux/fcntl.h>
88171 #include <linux/module.h>
88172 +#include <linux/security.h>
88173 #include <linux/socket.h>
88174 #include <linux/sockios.h>
88175 #include <linux/igmp.h>
88176 @@ -111,6 +112,10 @@
88177 #include <trace/events/skb.h>
88178 #include "udp_impl.h"
88179
88180 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88181 +extern int grsec_enable_blackhole;
88182 +#endif
88183 +
88184 struct udp_table udp_table __read_mostly;
88185 EXPORT_SYMBOL(udp_table);
88186
88187 @@ -594,6 +599,9 @@ found:
88188 return s;
88189 }
88190
88191 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
88192 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
88193 +
88194 /*
88195 * This routine is called by the ICMP module when it gets some
88196 * sort of error condition. If err < 0 then the socket should
88197 @@ -799,7 +807,7 @@ send:
88198 /*
88199 * Push out all pending data as one UDP datagram. Socket is locked.
88200 */
88201 -static int udp_push_pending_frames(struct sock *sk)
88202 +int udp_push_pending_frames(struct sock *sk)
88203 {
88204 struct udp_sock *up = udp_sk(sk);
88205 struct inet_sock *inet = inet_sk(sk);
88206 @@ -818,6 +826,7 @@ out:
88207 up->pending = 0;
88208 return err;
88209 }
88210 +EXPORT_SYMBOL(udp_push_pending_frames);
88211
88212 int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
88213 size_t len)
88214 @@ -889,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
88215 dport = usin->sin_port;
88216 if (dport == 0)
88217 return -EINVAL;
88218 +
88219 + err = gr_search_udp_sendmsg(sk, usin);
88220 + if (err)
88221 + return err;
88222 } else {
88223 if (sk->sk_state != TCP_ESTABLISHED)
88224 return -EDESTADDRREQ;
88225 +
88226 + err = gr_search_udp_sendmsg(sk, NULL);
88227 + if (err)
88228 + return err;
88229 +
88230 daddr = inet->inet_daddr;
88231 dport = inet->inet_dport;
88232 /* Open fast path for connected socket.
88233 @@ -1135,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
88234 IS_UDPLITE(sk));
88235 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88236 IS_UDPLITE(sk));
88237 - atomic_inc(&sk->sk_drops);
88238 + atomic_inc_unchecked(&sk->sk_drops);
88239 __skb_unlink(skb, rcvq);
88240 __skb_queue_tail(&list_kill, skb);
88241 }
88242 @@ -1221,6 +1239,10 @@ try_again:
88243 if (!skb)
88244 goto out;
88245
88246 + err = gr_search_udp_recvmsg(sk, skb);
88247 + if (err)
88248 + goto out_free;
88249 +
88250 ulen = skb->len - sizeof(struct udphdr);
88251 copied = len;
88252 if (copied > ulen)
88253 @@ -1254,7 +1276,7 @@ try_again:
88254 if (unlikely(err)) {
88255 trace_kfree_skb(skb, udp_recvmsg);
88256 if (!peeked) {
88257 - atomic_inc(&sk->sk_drops);
88258 + atomic_inc_unchecked(&sk->sk_drops);
88259 UDP_INC_STATS_USER(sock_net(sk),
88260 UDP_MIB_INERRORS, is_udplite);
88261 }
88262 @@ -1541,7 +1563,7 @@ csum_error:
88263 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88264 drop:
88265 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88266 - atomic_inc(&sk->sk_drops);
88267 + atomic_inc_unchecked(&sk->sk_drops);
88268 kfree_skb(skb);
88269 return -1;
88270 }
88271 @@ -1560,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88272 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88273
88274 if (!skb1) {
88275 - atomic_inc(&sk->sk_drops);
88276 + atomic_inc_unchecked(&sk->sk_drops);
88277 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88278 IS_UDPLITE(sk));
88279 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88280 @@ -1729,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88281 goto csum_error;
88282
88283 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88284 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88285 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88286 +#endif
88287 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
88288
88289 /*
88290 @@ -2159,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
88291 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88292 0, sock_i_ino(sp),
88293 atomic_read(&sp->sk_refcnt), sp,
88294 - atomic_read(&sp->sk_drops), len);
88295 + atomic_read_unchecked(&sp->sk_drops), len);
88296 }
88297
88298 int udp4_seq_show(struct seq_file *seq, void *v)
88299 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
88300 index 9a459be..086b866 100644
88301 --- a/net/ipv4/xfrm4_policy.c
88302 +++ b/net/ipv4/xfrm4_policy.c
88303 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
88304
88305 static int __net_init xfrm4_net_init(struct net *net)
88306 {
88307 - struct ctl_table *table;
88308 + ctl_table_no_const *table = NULL;
88309 struct ctl_table_header *hdr;
88310
88311 - table = xfrm4_policy_table;
88312 if (!net_eq(net, &init_net)) {
88313 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88314 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88315 if (!table)
88316 goto err_alloc;
88317
88318 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
88319 - }
88320 -
88321 - hdr = register_net_sysctl(net, "net/ipv4", table);
88322 + hdr = register_net_sysctl(net, "net/ipv4", table);
88323 + } else
88324 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
88325 if (!hdr)
88326 goto err_reg;
88327
88328 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
88329 return 0;
88330
88331 err_reg:
88332 - if (!net_eq(net, &init_net))
88333 - kfree(table);
88334 + kfree(table);
88335 err_alloc:
88336 return -ENOMEM;
88337 }
88338 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88339 index 4ab4c38..1533b2d 100644
88340 --- a/net/ipv6/addrconf.c
88341 +++ b/net/ipv6/addrconf.c
88342 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
88343 idx = 0;
88344 head = &net->dev_index_head[h];
88345 rcu_read_lock();
88346 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
88347 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
88348 net->dev_base_seq;
88349 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88350 if (idx < s_idx)
88351 @@ -2372,7 +2372,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88352 p.iph.ihl = 5;
88353 p.iph.protocol = IPPROTO_IPV6;
88354 p.iph.ttl = 64;
88355 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88356 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88357
88358 if (ops->ndo_do_ioctl) {
88359 mm_segment_t oldfs = get_fs();
88360 @@ -3994,7 +3994,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
88361 s_ip_idx = ip_idx = cb->args[2];
88362
88363 rcu_read_lock();
88364 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88365 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88366 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
88367 idx = 0;
88368 head = &net->dev_index_head[h];
88369 @@ -4579,7 +4579,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88370 dst_free(&ifp->rt->dst);
88371 break;
88372 }
88373 - atomic_inc(&net->ipv6.dev_addr_genid);
88374 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
88375 }
88376
88377 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88378 @@ -4599,7 +4599,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88379 int *valp = ctl->data;
88380 int val = *valp;
88381 loff_t pos = *ppos;
88382 - ctl_table lctl;
88383 + ctl_table_no_const lctl;
88384 int ret;
88385
88386 /*
88387 @@ -4681,7 +4681,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88388 int *valp = ctl->data;
88389 int val = *valp;
88390 loff_t pos = *ppos;
88391 - ctl_table lctl;
88392 + ctl_table_no_const lctl;
88393 int ret;
88394
88395 /*
88396 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88397 index b4ff0a4..db9b764 100644
88398 --- a/net/ipv6/icmp.c
88399 +++ b/net/ipv6/icmp.c
88400 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
88401
88402 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88403 {
88404 - struct ctl_table *table;
88405 + ctl_table_no_const *table;
88406
88407 table = kmemdup(ipv6_icmp_table_template,
88408 sizeof(ipv6_icmp_table_template),
88409 diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
88410 index 192dd1a..5fc9c7a 100644
88411 --- a/net/ipv6/ip6_fib.c
88412 +++ b/net/ipv6/ip6_fib.c
88413 @@ -632,6 +632,12 @@ insert_above:
88414 return ln;
88415 }
88416
88417 +static inline bool rt6_qualify_for_ecmp(struct rt6_info *rt)
88418 +{
88419 + return (rt->rt6i_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
88420 + RTF_GATEWAY;
88421 +}
88422 +
88423 /*
88424 * Insert routing information in a node.
88425 */
88426 @@ -646,6 +652,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
88427 int add = (!info->nlh ||
88428 (info->nlh->nlmsg_flags & NLM_F_CREATE));
88429 int found = 0;
88430 + bool rt_can_ecmp = rt6_qualify_for_ecmp(rt);
88431
88432 ins = &fn->leaf;
88433
88434 @@ -691,9 +698,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
88435 * To avoid long list, we only had siblings if the
88436 * route have a gateway.
88437 */
88438 - if (rt->rt6i_flags & RTF_GATEWAY &&
88439 - !(rt->rt6i_flags & RTF_EXPIRES) &&
88440 - !(iter->rt6i_flags & RTF_EXPIRES))
88441 + if (rt_can_ecmp &&
88442 + rt6_qualify_for_ecmp(iter))
88443 rt->rt6i_nsiblings++;
88444 }
88445
88446 @@ -715,7 +721,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
88447 /* Find the first route that have the same metric */
88448 sibling = fn->leaf;
88449 while (sibling) {
88450 - if (sibling->rt6i_metric == rt->rt6i_metric) {
88451 + if (sibling->rt6i_metric == rt->rt6i_metric &&
88452 + rt6_qualify_for_ecmp(sibling)) {
88453 list_add_tail(&rt->rt6i_siblings,
88454 &sibling->rt6i_siblings);
88455 break;
88456 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88457 index ecd6073..58162ae 100644
88458 --- a/net/ipv6/ip6_gre.c
88459 +++ b/net/ipv6/ip6_gre.c
88460 @@ -74,7 +74,7 @@ struct ip6gre_net {
88461 struct net_device *fb_tunnel_dev;
88462 };
88463
88464 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88465 +static struct rtnl_link_ops ip6gre_link_ops;
88466 static int ip6gre_tunnel_init(struct net_device *dev);
88467 static void ip6gre_tunnel_setup(struct net_device *dev);
88468 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88469 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88470 }
88471
88472
88473 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88474 +static struct inet6_protocol ip6gre_protocol = {
88475 .handler = ip6gre_rcv,
88476 .err_handler = ip6gre_err,
88477 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88478 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88479 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88480 };
88481
88482 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88483 +static struct rtnl_link_ops ip6gre_link_ops = {
88484 .kind = "ip6gre",
88485 .maxtype = IFLA_GRE_MAX,
88486 .policy = ip6gre_policy,
88487 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88488 .fill_info = ip6gre_fill_info,
88489 };
88490
88491 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88492 +static struct rtnl_link_ops ip6gre_tap_ops = {
88493 .kind = "ip6gretap",
88494 .maxtype = IFLA_GRE_MAX,
88495 .policy = ip6gre_policy,
88496 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
88497 index d5d20cd..6e3ddf8 100644
88498 --- a/net/ipv6/ip6_output.c
88499 +++ b/net/ipv6/ip6_output.c
88500 @@ -1098,11 +1098,12 @@ static inline struct ipv6_rt_hdr *ip6_rthdr_dup(struct ipv6_rt_hdr *src,
88501 return src ? kmemdup(src, (src->hdrlen + 1) * 8, gfp) : NULL;
88502 }
88503
88504 -static void ip6_append_data_mtu(int *mtu,
88505 +static void ip6_append_data_mtu(unsigned int *mtu,
88506 int *maxfraglen,
88507 unsigned int fragheaderlen,
88508 struct sk_buff *skb,
88509 - struct rt6_info *rt)
88510 + struct rt6_info *rt,
88511 + bool pmtuprobe)
88512 {
88513 if (!(rt->dst.flags & DST_XFRM_TUNNEL)) {
88514 if (skb == NULL) {
88515 @@ -1114,7 +1115,9 @@ static void ip6_append_data_mtu(int *mtu,
88516 * this fragment is not first, the headers
88517 * space is regarded as data space.
88518 */
88519 - *mtu = dst_mtu(rt->dst.path);
88520 + *mtu = min(*mtu, pmtuprobe ?
88521 + rt->dst.dev->mtu :
88522 + dst_mtu(rt->dst.path));
88523 }
88524 *maxfraglen = ((*mtu - fragheaderlen) & ~7)
88525 + fragheaderlen - sizeof(struct frag_hdr);
88526 @@ -1131,11 +1134,10 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
88527 struct ipv6_pinfo *np = inet6_sk(sk);
88528 struct inet_cork *cork;
88529 struct sk_buff *skb, *skb_prev = NULL;
88530 - unsigned int maxfraglen, fragheaderlen;
88531 + unsigned int maxfraglen, fragheaderlen, mtu;
88532 int exthdrlen;
88533 int dst_exthdrlen;
88534 int hh_len;
88535 - int mtu;
88536 int copy;
88537 int err;
88538 int offset = 0;
88539 @@ -1292,7 +1294,9 @@ alloc_new_skb:
88540 /* update mtu and maxfraglen if necessary */
88541 if (skb == NULL || skb_prev == NULL)
88542 ip6_append_data_mtu(&mtu, &maxfraglen,
88543 - fragheaderlen, skb, rt);
88544 + fragheaderlen, skb, rt,
88545 + np->pmtudisc ==
88546 + IPV6_PMTUDISC_PROBE);
88547
88548 skb_prev = skb;
88549
88550 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88551 index 1e55866..b398dab 100644
88552 --- a/net/ipv6/ip6_tunnel.c
88553 +++ b/net/ipv6/ip6_tunnel.c
88554 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88555
88556 static int ip6_tnl_dev_init(struct net_device *dev);
88557 static void ip6_tnl_dev_setup(struct net_device *dev);
88558 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88559 +static struct rtnl_link_ops ip6_link_ops;
88560
88561 static int ip6_tnl_net_id __read_mostly;
88562 struct ip6_tnl_net {
88563 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88564 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88565 };
88566
88567 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88568 +static struct rtnl_link_ops ip6_link_ops = {
88569 .kind = "ip6tnl",
88570 .maxtype = IFLA_IPTUN_MAX,
88571 .policy = ip6_tnl_policy,
88572 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88573 index d1e2e8e..51c19ae 100644
88574 --- a/net/ipv6/ipv6_sockglue.c
88575 +++ b/net/ipv6/ipv6_sockglue.c
88576 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88577 if (sk->sk_type != SOCK_STREAM)
88578 return -ENOPROTOOPT;
88579
88580 - msg.msg_control = optval;
88581 + msg.msg_control = (void __force_kernel *)optval;
88582 msg.msg_controllen = len;
88583 msg.msg_flags = flags;
88584
88585 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88586 index 44400c2..8e11f52 100644
88587 --- a/net/ipv6/netfilter/ip6_tables.c
88588 +++ b/net/ipv6/netfilter/ip6_tables.c
88589 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
88590 #endif
88591
88592 static int get_info(struct net *net, void __user *user,
88593 - const int *len, int compat)
88594 + int len, int compat)
88595 {
88596 char name[XT_TABLE_MAXNAMELEN];
88597 struct xt_table *t;
88598 int ret;
88599
88600 - if (*len != sizeof(struct ip6t_getinfo)) {
88601 - duprintf("length %u != %zu\n", *len,
88602 + if (len != sizeof(struct ip6t_getinfo)) {
88603 + duprintf("length %u != %zu\n", len,
88604 sizeof(struct ip6t_getinfo));
88605 return -EINVAL;
88606 }
88607 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
88608 info.size = private->size;
88609 strcpy(info.name, name);
88610
88611 - if (copy_to_user(user, &info, *len) != 0)
88612 + if (copy_to_user(user, &info, len) != 0)
88613 ret = -EFAULT;
88614 else
88615 ret = 0;
88616 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88617
88618 switch (cmd) {
88619 case IP6T_SO_GET_INFO:
88620 - ret = get_info(sock_net(sk), user, len, 1);
88621 + ret = get_info(sock_net(sk), user, *len, 1);
88622 break;
88623 case IP6T_SO_GET_ENTRIES:
88624 ret = compat_get_entries(sock_net(sk), user, len);
88625 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88626
88627 switch (cmd) {
88628 case IP6T_SO_GET_INFO:
88629 - ret = get_info(sock_net(sk), user, len, 0);
88630 + ret = get_info(sock_net(sk), user, *len, 0);
88631 break;
88632
88633 case IP6T_SO_GET_ENTRIES:
88634 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88635 index dffdc1a..ccc6678 100644
88636 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88637 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88638 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88639
88640 static int nf_ct_frag6_sysctl_register(struct net *net)
88641 {
88642 - struct ctl_table *table;
88643 + ctl_table_no_const *table = NULL;
88644 struct ctl_table_header *hdr;
88645
88646 - table = nf_ct_frag6_sysctl_table;
88647 if (!net_eq(net, &init_net)) {
88648 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88649 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88650 GFP_KERNEL);
88651 if (table == NULL)
88652 goto err_alloc;
88653 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88654 table[0].data = &net->nf_frag.frags.timeout;
88655 table[1].data = &net->nf_frag.frags.low_thresh;
88656 table[2].data = &net->nf_frag.frags.high_thresh;
88657 - }
88658 -
88659 - hdr = register_net_sysctl(net, "net/netfilter", table);
88660 + hdr = register_net_sysctl(net, "net/netfilter", table);
88661 + } else
88662 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88663 if (hdr == NULL)
88664 goto err_reg;
88665
88666 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88667 return 0;
88668
88669 err_reg:
88670 - if (!net_eq(net, &init_net))
88671 - kfree(table);
88672 + kfree(table);
88673 err_alloc:
88674 return -ENOMEM;
88675 }
88676 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88677 index eedff8c..6e13a47 100644
88678 --- a/net/ipv6/raw.c
88679 +++ b/net/ipv6/raw.c
88680 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88681 {
88682 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88683 skb_checksum_complete(skb)) {
88684 - atomic_inc(&sk->sk_drops);
88685 + atomic_inc_unchecked(&sk->sk_drops);
88686 kfree_skb(skb);
88687 return NET_RX_DROP;
88688 }
88689 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88690 struct raw6_sock *rp = raw6_sk(sk);
88691
88692 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88693 - atomic_inc(&sk->sk_drops);
88694 + atomic_inc_unchecked(&sk->sk_drops);
88695 kfree_skb(skb);
88696 return NET_RX_DROP;
88697 }
88698 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88699
88700 if (inet->hdrincl) {
88701 if (skb_checksum_complete(skb)) {
88702 - atomic_inc(&sk->sk_drops);
88703 + atomic_inc_unchecked(&sk->sk_drops);
88704 kfree_skb(skb);
88705 return NET_RX_DROP;
88706 }
88707 @@ -602,7 +602,7 @@ out:
88708 return err;
88709 }
88710
88711 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88712 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88713 struct flowi6 *fl6, struct dst_entry **dstp,
88714 unsigned int flags)
88715 {
88716 @@ -914,12 +914,15 @@ do_confirm:
88717 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88718 char __user *optval, int optlen)
88719 {
88720 + struct icmp6_filter filter;
88721 +
88722 switch (optname) {
88723 case ICMPV6_FILTER:
88724 if (optlen > sizeof(struct icmp6_filter))
88725 optlen = sizeof(struct icmp6_filter);
88726 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88727 + if (copy_from_user(&filter, optval, optlen))
88728 return -EFAULT;
88729 + raw6_sk(sk)->filter = filter;
88730 return 0;
88731 default:
88732 return -ENOPROTOOPT;
88733 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88734 char __user *optval, int __user *optlen)
88735 {
88736 int len;
88737 + struct icmp6_filter filter;
88738
88739 switch (optname) {
88740 case ICMPV6_FILTER:
88741 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88742 len = sizeof(struct icmp6_filter);
88743 if (put_user(len, optlen))
88744 return -EFAULT;
88745 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88746 + filter = raw6_sk(sk)->filter;
88747 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88748 return -EFAULT;
88749 return 0;
88750 default:
88751 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88752 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88753 0,
88754 sock_i_ino(sp),
88755 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88756 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88757 }
88758
88759 static int raw6_seq_show(struct seq_file *seq, void *v)
88760 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88761 index 790d9f4..68ae078 100644
88762 --- a/net/ipv6/reassembly.c
88763 +++ b/net/ipv6/reassembly.c
88764 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88765
88766 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88767 {
88768 - struct ctl_table *table;
88769 + ctl_table_no_const *table = NULL;
88770 struct ctl_table_header *hdr;
88771
88772 - table = ip6_frags_ns_ctl_table;
88773 if (!net_eq(net, &init_net)) {
88774 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88775 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88776 if (table == NULL)
88777 goto err_alloc;
88778
88779 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88780 /* Don't export sysctls to unprivileged users */
88781 if (net->user_ns != &init_user_ns)
88782 table[0].procname = NULL;
88783 - }
88784 + hdr = register_net_sysctl(net, "net/ipv6", table);
88785 + } else
88786 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88787
88788 - hdr = register_net_sysctl(net, "net/ipv6", table);
88789 if (hdr == NULL)
88790 goto err_reg;
88791
88792 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88793 return 0;
88794
88795 err_reg:
88796 - if (!net_eq(net, &init_net))
88797 - kfree(table);
88798 + kfree(table);
88799 err_alloc:
88800 return -ENOMEM;
88801 }
88802 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88803 index ad0aa6b..beaef03 100644
88804 --- a/net/ipv6/route.c
88805 +++ b/net/ipv6/route.c
88806 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88807
88808 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88809 {
88810 - struct ctl_table *table;
88811 + ctl_table_no_const *table;
88812
88813 table = kmemdup(ipv6_route_table_template,
88814 sizeof(ipv6_route_table_template),
88815 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88816 index 3353634..3d5084a 100644
88817 --- a/net/ipv6/sit.c
88818 +++ b/net/ipv6/sit.c
88819 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88820 static void ipip6_dev_free(struct net_device *dev);
88821 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88822 __be32 *v4dst);
88823 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88824 +static struct rtnl_link_ops sit_link_ops;
88825
88826 static int sit_net_id __read_mostly;
88827 struct sit_net {
88828 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88829 #endif
88830 };
88831
88832 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88833 +static struct rtnl_link_ops sit_link_ops = {
88834 .kind = "sit",
88835 .maxtype = IFLA_IPTUN_MAX,
88836 .policy = ipip6_policy,
88837 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88838 index e85c48b..b8268d3 100644
88839 --- a/net/ipv6/sysctl_net_ipv6.c
88840 +++ b/net/ipv6/sysctl_net_ipv6.c
88841 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88842
88843 static int __net_init ipv6_sysctl_net_init(struct net *net)
88844 {
88845 - struct ctl_table *ipv6_table;
88846 + ctl_table_no_const *ipv6_table;
88847 struct ctl_table *ipv6_route_table;
88848 struct ctl_table *ipv6_icmp_table;
88849 int err;
88850 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88851 index 0a17ed9..2526cc3 100644
88852 --- a/net/ipv6/tcp_ipv6.c
88853 +++ b/net/ipv6/tcp_ipv6.c
88854 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88855 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88856 }
88857
88858 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88859 +extern int grsec_enable_blackhole;
88860 +#endif
88861 +
88862 static void tcp_v6_hash(struct sock *sk)
88863 {
88864 if (sk->sk_state != TCP_CLOSE) {
88865 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88866 return 0;
88867
88868 reset:
88869 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88870 + if (!grsec_enable_blackhole)
88871 +#endif
88872 tcp_v6_send_reset(sk, skb);
88873 discard:
88874 if (opt_skb)
88875 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88876 TCP_SKB_CB(skb)->sacked = 0;
88877
88878 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88879 - if (!sk)
88880 + if (!sk) {
88881 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88882 + ret = 1;
88883 +#endif
88884 goto no_tcp_socket;
88885 + }
88886
88887 process:
88888 - if (sk->sk_state == TCP_TIME_WAIT)
88889 + if (sk->sk_state == TCP_TIME_WAIT) {
88890 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88891 + ret = 2;
88892 +#endif
88893 goto do_time_wait;
88894 + }
88895
88896 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88897 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88898 @@ -1536,6 +1551,10 @@ csum_error:
88899 bad_packet:
88900 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88901 } else {
88902 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88903 + if (!grsec_enable_blackhole || (ret == 1 &&
88904 + (skb->dev->flags & IFF_LOOPBACK)))
88905 +#endif
88906 tcp_v6_send_reset(NULL, skb);
88907 }
88908
88909 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88910 index 42923b1..d09c290 100644
88911 --- a/net/ipv6/udp.c
88912 +++ b/net/ipv6/udp.c
88913 @@ -52,6 +52,10 @@
88914 #include <trace/events/skb.h>
88915 #include "udp_impl.h"
88916
88917 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88918 +extern int grsec_enable_blackhole;
88919 +#endif
88920 +
88921 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88922 {
88923 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88924 @@ -419,7 +423,7 @@ try_again:
88925 if (unlikely(err)) {
88926 trace_kfree_skb(skb, udpv6_recvmsg);
88927 if (!peeked) {
88928 - atomic_inc(&sk->sk_drops);
88929 + atomic_inc_unchecked(&sk->sk_drops);
88930 if (is_udp4)
88931 UDP_INC_STATS_USER(sock_net(sk),
88932 UDP_MIB_INERRORS,
88933 @@ -665,7 +669,7 @@ csum_error:
88934 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88935 drop:
88936 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88937 - atomic_inc(&sk->sk_drops);
88938 + atomic_inc_unchecked(&sk->sk_drops);
88939 kfree_skb(skb);
88940 return -1;
88941 }
88942 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88943 if (likely(skb1 == NULL))
88944 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88945 if (!skb1) {
88946 - atomic_inc(&sk->sk_drops);
88947 + atomic_inc_unchecked(&sk->sk_drops);
88948 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88949 IS_UDPLITE(sk));
88950 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88951 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88952 goto csum_error;
88953
88954 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88955 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88956 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88957 +#endif
88958 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88959
88960 kfree_skb(skb);
88961 @@ -955,11 +962,16 @@ static int udp_v6_push_pending_frames(struct sock *sk)
88962 struct udphdr *uh;
88963 struct udp_sock *up = udp_sk(sk);
88964 struct inet_sock *inet = inet_sk(sk);
88965 - struct flowi6 *fl6 = &inet->cork.fl.u.ip6;
88966 + struct flowi6 *fl6;
88967 int err = 0;
88968 int is_udplite = IS_UDPLITE(sk);
88969 __wsum csum = 0;
88970
88971 + if (up->pending == AF_INET)
88972 + return udp_push_pending_frames(sk);
88973 +
88974 + fl6 = &inet->cork.fl.u.ip6;
88975 +
88976 /* Grab the skbuff where UDP header space exists. */
88977 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
88978 goto out;
88979 @@ -1387,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88980 0,
88981 sock_i_ino(sp),
88982 atomic_read(&sp->sk_refcnt), sp,
88983 - atomic_read(&sp->sk_drops));
88984 + atomic_read_unchecked(&sp->sk_drops));
88985 }
88986
88987 int udp6_seq_show(struct seq_file *seq, void *v)
88988 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88989 index 23ed03d..465a71d 100644
88990 --- a/net/ipv6/xfrm6_policy.c
88991 +++ b/net/ipv6/xfrm6_policy.c
88992 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88993
88994 static int __net_init xfrm6_net_init(struct net *net)
88995 {
88996 - struct ctl_table *table;
88997 + ctl_table_no_const *table = NULL;
88998 struct ctl_table_header *hdr;
88999
89000 - table = xfrm6_policy_table;
89001 if (!net_eq(net, &init_net)) {
89002 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89003 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89004 if (!table)
89005 goto err_alloc;
89006
89007 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
89008 - }
89009 + hdr = register_net_sysctl(net, "net/ipv6", table);
89010 + } else
89011 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
89012
89013 - hdr = register_net_sysctl(net, "net/ipv6", table);
89014 if (!hdr)
89015 goto err_reg;
89016
89017 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
89018 return 0;
89019
89020 err_reg:
89021 - if (!net_eq(net, &init_net))
89022 - kfree(table);
89023 + kfree(table);
89024 err_alloc:
89025 return -ENOMEM;
89026 }
89027 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
89028 index 41ac7938..75e3bb1 100644
89029 --- a/net/irda/ircomm/ircomm_tty.c
89030 +++ b/net/irda/ircomm/ircomm_tty.c
89031 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89032 add_wait_queue(&port->open_wait, &wait);
89033
89034 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
89035 - __FILE__, __LINE__, tty->driver->name, port->count);
89036 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89037
89038 spin_lock_irqsave(&port->lock, flags);
89039 if (!tty_hung_up_p(filp))
89040 - port->count--;
89041 + atomic_dec(&port->count);
89042 port->blocked_open++;
89043 spin_unlock_irqrestore(&port->lock, flags);
89044
89045 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89046 }
89047
89048 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
89049 - __FILE__, __LINE__, tty->driver->name, port->count);
89050 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89051
89052 schedule();
89053 }
89054 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89055
89056 spin_lock_irqsave(&port->lock, flags);
89057 if (!tty_hung_up_p(filp))
89058 - port->count++;
89059 + atomic_inc(&port->count);
89060 port->blocked_open--;
89061 spin_unlock_irqrestore(&port->lock, flags);
89062
89063 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
89064 - __FILE__, __LINE__, tty->driver->name, port->count);
89065 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89066
89067 if (!retval)
89068 port->flags |= ASYNC_NORMAL_ACTIVE;
89069 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
89070
89071 /* ++ is not atomic, so this should be protected - Jean II */
89072 spin_lock_irqsave(&self->port.lock, flags);
89073 - self->port.count++;
89074 + atomic_inc(&self->port.count);
89075 spin_unlock_irqrestore(&self->port.lock, flags);
89076 tty_port_tty_set(&self->port, tty);
89077
89078 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
89079 - self->line, self->port.count);
89080 + self->line, atomic_read(&self->port.count));
89081
89082 /* Not really used by us, but lets do it anyway */
89083 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
89084 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
89085 tty_kref_put(port->tty);
89086 }
89087 port->tty = NULL;
89088 - port->count = 0;
89089 + atomic_set(&port->count, 0);
89090 spin_unlock_irqrestore(&port->lock, flags);
89091
89092 wake_up_interruptible(&port->open_wait);
89093 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
89094 seq_putc(m, '\n');
89095
89096 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
89097 - seq_printf(m, "Open count: %d\n", self->port.count);
89098 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
89099 seq_printf(m, "Max data size: %d\n", self->max_data_size);
89100 seq_printf(m, "Max header size: %d\n", self->max_header_size);
89101
89102 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
89103 index ae69165..c8b82d8 100644
89104 --- a/net/iucv/af_iucv.c
89105 +++ b/net/iucv/af_iucv.c
89106 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
89107
89108 write_lock_bh(&iucv_sk_list.lock);
89109
89110 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
89111 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89112 while (__iucv_get_sock_by_name(name)) {
89113 sprintf(name, "%08x",
89114 - atomic_inc_return(&iucv_sk_list.autobind_name));
89115 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89116 }
89117
89118 write_unlock_bh(&iucv_sk_list.lock);
89119 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
89120 index 4fe76ff..426a904 100644
89121 --- a/net/iucv/iucv.c
89122 +++ b/net/iucv/iucv.c
89123 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
89124 return NOTIFY_OK;
89125 }
89126
89127 -static struct notifier_block __refdata iucv_cpu_notifier = {
89128 +static struct notifier_block iucv_cpu_notifier = {
89129 .notifier_call = iucv_cpu_notify,
89130 };
89131
89132 diff --git a/net/key/af_key.c b/net/key/af_key.c
89133 index 9da8620..97070ad 100644
89134 --- a/net/key/af_key.c
89135 +++ b/net/key/af_key.c
89136 @@ -3047,10 +3047,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
89137 static u32 get_acqseq(void)
89138 {
89139 u32 res;
89140 - static atomic_t acqseq;
89141 + static atomic_unchecked_t acqseq;
89142
89143 do {
89144 - res = atomic_inc_return(&acqseq);
89145 + res = atomic_inc_return_unchecked(&acqseq);
89146 } while (!res);
89147 return res;
89148 }
89149 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
89150 index 8dec687..5ebee2d 100644
89151 --- a/net/l2tp/l2tp_ppp.c
89152 +++ b/net/l2tp/l2tp_ppp.c
89153 @@ -1793,7 +1793,8 @@ static const struct proto_ops pppol2tp_ops = {
89154
89155 static const struct pppox_proto pppol2tp_proto = {
89156 .create = pppol2tp_create,
89157 - .ioctl = pppol2tp_ioctl
89158 + .ioctl = pppol2tp_ioctl,
89159 + .owner = THIS_MODULE,
89160 };
89161
89162 #ifdef CONFIG_L2TP_V3
89163 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
89164 index 4fdb306e..920086a 100644
89165 --- a/net/mac80211/cfg.c
89166 +++ b/net/mac80211/cfg.c
89167 @@ -804,7 +804,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
89168 ret = ieee80211_vif_use_channel(sdata, chandef,
89169 IEEE80211_CHANCTX_EXCLUSIVE);
89170 }
89171 - } else if (local->open_count == local->monitors) {
89172 + } else if (local_read(&local->open_count) == local->monitors) {
89173 local->_oper_chandef = *chandef;
89174 ieee80211_hw_config(local, 0);
89175 }
89176 @@ -2920,7 +2920,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
89177 else
89178 local->probe_req_reg--;
89179
89180 - if (!local->open_count)
89181 + if (!local_read(&local->open_count))
89182 break;
89183
89184 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
89185 @@ -3383,8 +3383,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
89186 if (chanctx_conf) {
89187 *chandef = chanctx_conf->def;
89188 ret = 0;
89189 - } else if (local->open_count > 0 &&
89190 - local->open_count == local->monitors &&
89191 + } else if (local_read(&local->open_count) > 0 &&
89192 + local_read(&local->open_count) == local->monitors &&
89193 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
89194 if (local->use_chanctx)
89195 *chandef = local->monitor_chandef;
89196 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
89197 index 9ca8e32..48e4a9b 100644
89198 --- a/net/mac80211/ieee80211_i.h
89199 +++ b/net/mac80211/ieee80211_i.h
89200 @@ -28,6 +28,7 @@
89201 #include <net/ieee80211_radiotap.h>
89202 #include <net/cfg80211.h>
89203 #include <net/mac80211.h>
89204 +#include <asm/local.h>
89205 #include "key.h"
89206 #include "sta_info.h"
89207 #include "debug.h"
89208 @@ -891,7 +892,7 @@ struct ieee80211_local {
89209 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
89210 spinlock_t queue_stop_reason_lock;
89211
89212 - int open_count;
89213 + local_t open_count;
89214 int monitors, cooked_mntrs;
89215 /* number of interfaces with corresponding FIF_ flags */
89216 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
89217 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
89218 index 98d20c0..586675b 100644
89219 --- a/net/mac80211/iface.c
89220 +++ b/net/mac80211/iface.c
89221 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89222 break;
89223 }
89224
89225 - if (local->open_count == 0) {
89226 + if (local_read(&local->open_count) == 0) {
89227 res = drv_start(local);
89228 if (res)
89229 goto err_del_bss;
89230 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89231 break;
89232 }
89233
89234 - if (local->monitors == 0 && local->open_count == 0) {
89235 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
89236 res = ieee80211_add_virtual_monitor(local);
89237 if (res)
89238 goto err_stop;
89239 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89240 atomic_inc(&local->iff_promiscs);
89241
89242 if (coming_up)
89243 - local->open_count++;
89244 + local_inc(&local->open_count);
89245
89246 if (hw_reconf_flags)
89247 ieee80211_hw_config(local, hw_reconf_flags);
89248 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89249 err_del_interface:
89250 drv_remove_interface(local, sdata);
89251 err_stop:
89252 - if (!local->open_count)
89253 + if (!local_read(&local->open_count))
89254 drv_stop(local);
89255 err_del_bss:
89256 sdata->bss = NULL;
89257 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89258 }
89259
89260 if (going_down)
89261 - local->open_count--;
89262 + local_dec(&local->open_count);
89263
89264 switch (sdata->vif.type) {
89265 case NL80211_IFTYPE_AP_VLAN:
89266 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89267 }
89268 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
89269
89270 - if (local->open_count == 0)
89271 + if (local_read(&local->open_count) == 0)
89272 ieee80211_clear_tx_pending(local);
89273
89274 /*
89275 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89276
89277 ieee80211_recalc_ps(local, -1);
89278
89279 - if (local->open_count == 0) {
89280 + if (local_read(&local->open_count) == 0) {
89281 ieee80211_stop_device(local);
89282
89283 /* no reconfiguring after stop! */
89284 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89285 ieee80211_configure_filter(local);
89286 ieee80211_hw_config(local, hw_reconf_flags);
89287
89288 - if (local->monitors == local->open_count)
89289 + if (local->monitors == local_read(&local->open_count))
89290 ieee80211_add_virtual_monitor(local);
89291 }
89292
89293 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
89294 index 8a7bfc4..4407cd0 100644
89295 --- a/net/mac80211/main.c
89296 +++ b/net/mac80211/main.c
89297 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
89298 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
89299 IEEE80211_CONF_CHANGE_POWER);
89300
89301 - if (changed && local->open_count) {
89302 + if (changed && local_read(&local->open_count)) {
89303 ret = drv_config(local, changed);
89304 /*
89305 * Goal:
89306 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
89307 index 7fc5d0d..07ea536 100644
89308 --- a/net/mac80211/pm.c
89309 +++ b/net/mac80211/pm.c
89310 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89311 struct ieee80211_sub_if_data *sdata;
89312 struct sta_info *sta;
89313
89314 - if (!local->open_count)
89315 + if (!local_read(&local->open_count))
89316 goto suspend;
89317
89318 ieee80211_scan_cancel(local);
89319 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89320 cancel_work_sync(&local->dynamic_ps_enable_work);
89321 del_timer_sync(&local->dynamic_ps_timer);
89322
89323 - local->wowlan = wowlan && local->open_count;
89324 + local->wowlan = wowlan && local_read(&local->open_count);
89325 if (local->wowlan) {
89326 int err = drv_suspend(local, wowlan);
89327 if (err < 0) {
89328 @@ -113,7 +113,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89329 WARN_ON(!list_empty(&local->chanctx_list));
89330
89331 /* stop hardware - this must stop RX */
89332 - if (local->open_count)
89333 + if (local_read(&local->open_count))
89334 ieee80211_stop_device(local);
89335
89336 suspend:
89337 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
89338 index a02bef3..f2f38dd 100644
89339 --- a/net/mac80211/rate.c
89340 +++ b/net/mac80211/rate.c
89341 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
89342
89343 ASSERT_RTNL();
89344
89345 - if (local->open_count)
89346 + if (local_read(&local->open_count))
89347 return -EBUSY;
89348
89349 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
89350 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
89351 index c97a065..ff61928 100644
89352 --- a/net/mac80211/rc80211_pid_debugfs.c
89353 +++ b/net/mac80211/rc80211_pid_debugfs.c
89354 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
89355
89356 spin_unlock_irqrestore(&events->lock, status);
89357
89358 - if (copy_to_user(buf, pb, p))
89359 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
89360 return -EFAULT;
89361
89362 return p;
89363 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
89364 index 72e6292..e6319eb 100644
89365 --- a/net/mac80211/util.c
89366 +++ b/net/mac80211/util.c
89367 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
89368 }
89369 #endif
89370 /* everything else happens only if HW was up & running */
89371 - if (!local->open_count)
89372 + if (!local_read(&local->open_count))
89373 goto wake_up;
89374
89375 /*
89376 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
89377 local->in_reconfig = false;
89378 barrier();
89379
89380 - if (local->monitors == local->open_count && local->monitors > 0)
89381 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
89382 ieee80211_add_virtual_monitor(local);
89383
89384 /*
89385 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
89386 index 56d22ca..87c778f 100644
89387 --- a/net/netfilter/Kconfig
89388 +++ b/net/netfilter/Kconfig
89389 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
89390
89391 To compile it as a module, choose M here. If unsure, say N.
89392
89393 +config NETFILTER_XT_MATCH_GRADM
89394 + tristate '"gradm" match support'
89395 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
89396 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
89397 + ---help---
89398 + The gradm match allows to match on grsecurity RBAC being enabled.
89399 + It is useful when iptables rules are applied early on bootup to
89400 + prevent connections to the machine (except from a trusted host)
89401 + while the RBAC system is disabled.
89402 +
89403 config NETFILTER_XT_MATCH_HASHLIMIT
89404 tristate '"hashlimit" match support'
89405 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
89406 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
89407 index a1abf87..dbcb7ee 100644
89408 --- a/net/netfilter/Makefile
89409 +++ b/net/netfilter/Makefile
89410 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
89411 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
89412 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
89413 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
89414 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
89415 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
89416 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
89417 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
89418 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
89419 index f771390..145b765 100644
89420 --- a/net/netfilter/ipset/ip_set_core.c
89421 +++ b/net/netfilter/ipset/ip_set_core.c
89422 @@ -1820,7 +1820,7 @@ done:
89423 return ret;
89424 }
89425
89426 -static struct nf_sockopt_ops so_set __read_mostly = {
89427 +static struct nf_sockopt_ops so_set = {
89428 .pf = PF_INET,
89429 .get_optmin = SO_IP_SET,
89430 .get_optmax = SO_IP_SET + 1,
89431 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
89432 index a083bda..da661c3 100644
89433 --- a/net/netfilter/ipvs/ip_vs_conn.c
89434 +++ b/net/netfilter/ipvs/ip_vs_conn.c
89435 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
89436 /* Increase the refcnt counter of the dest */
89437 ip_vs_dest_hold(dest);
89438
89439 - conn_flags = atomic_read(&dest->conn_flags);
89440 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
89441 if (cp->protocol != IPPROTO_UDP)
89442 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
89443 flags = cp->flags;
89444 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
89445
89446 cp->control = NULL;
89447 atomic_set(&cp->n_control, 0);
89448 - atomic_set(&cp->in_pkts, 0);
89449 + atomic_set_unchecked(&cp->in_pkts, 0);
89450
89451 cp->packet_xmit = NULL;
89452 cp->app = NULL;
89453 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89454
89455 /* Don't drop the entry if its number of incoming packets is not
89456 located in [0, 8] */
89457 - i = atomic_read(&cp->in_pkts);
89458 + i = atomic_read_unchecked(&cp->in_pkts);
89459 if (i > 8 || i < 0) return 0;
89460
89461 if (!todrop_rate[i]) return 0;
89462 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89463 index 23b8eb5..48a8959 100644
89464 --- a/net/netfilter/ipvs/ip_vs_core.c
89465 +++ b/net/netfilter/ipvs/ip_vs_core.c
89466 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89467 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89468 /* do not touch skb anymore */
89469
89470 - atomic_inc(&cp->in_pkts);
89471 + atomic_inc_unchecked(&cp->in_pkts);
89472 ip_vs_conn_put(cp);
89473 return ret;
89474 }
89475 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89476 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89477 pkts = sysctl_sync_threshold(ipvs);
89478 else
89479 - pkts = atomic_add_return(1, &cp->in_pkts);
89480 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89481
89482 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89483 ip_vs_sync_conn(net, cp, pkts);
89484 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89485 index 9e6c2a0..28552e2 100644
89486 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89487 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89488 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89489 */
89490 ip_vs_rs_hash(ipvs, dest);
89491 }
89492 - atomic_set(&dest->conn_flags, conn_flags);
89493 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89494
89495 /* bind the service */
89496 if (!dest->svc) {
89497 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89498 * align with netns init in ip_vs_control_net_init()
89499 */
89500
89501 -static struct ctl_table vs_vars[] = {
89502 +static ctl_table_no_const vs_vars[] __read_only = {
89503 {
89504 .procname = "amemthresh",
89505 .maxlen = sizeof(int),
89506 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89507 " %-7s %-6d %-10d %-10d\n",
89508 &dest->addr.in6,
89509 ntohs(dest->port),
89510 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89511 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89512 atomic_read(&dest->weight),
89513 atomic_read(&dest->activeconns),
89514 atomic_read(&dest->inactconns));
89515 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89516 "%-7s %-6d %-10d %-10d\n",
89517 ntohl(dest->addr.ip),
89518 ntohs(dest->port),
89519 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89520 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89521 atomic_read(&dest->weight),
89522 atomic_read(&dest->activeconns),
89523 atomic_read(&dest->inactconns));
89524 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89525
89526 entry.addr = dest->addr.ip;
89527 entry.port = dest->port;
89528 - entry.conn_flags = atomic_read(&dest->conn_flags);
89529 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89530 entry.weight = atomic_read(&dest->weight);
89531 entry.u_threshold = dest->u_threshold;
89532 entry.l_threshold = dest->l_threshold;
89533 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89534 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89535 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89536 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89537 - (atomic_read(&dest->conn_flags) &
89538 + (atomic_read_unchecked(&dest->conn_flags) &
89539 IP_VS_CONN_F_FWD_MASK)) ||
89540 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89541 atomic_read(&dest->weight)) ||
89542 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89543 {
89544 int idx;
89545 struct netns_ipvs *ipvs = net_ipvs(net);
89546 - struct ctl_table *tbl;
89547 + ctl_table_no_const *tbl;
89548
89549 atomic_set(&ipvs->dropentry, 0);
89550 spin_lock_init(&ipvs->dropentry_lock);
89551 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89552 index 5ea26bd..c9bc65f 100644
89553 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89554 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89555 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
89556 * IPVS LBLC sysctl table
89557 */
89558 #ifdef CONFIG_SYSCTL
89559 -static ctl_table vs_vars_table[] = {
89560 +static ctl_table_no_const vs_vars_table[] __read_only = {
89561 {
89562 .procname = "lblc_expiration",
89563 .data = NULL,
89564 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89565 index 50123c2..067c773 100644
89566 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89567 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89568 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
89569 * IPVS LBLCR sysctl table
89570 */
89571
89572 -static ctl_table vs_vars_table[] = {
89573 +static ctl_table_no_const vs_vars_table[] __read_only = {
89574 {
89575 .procname = "lblcr_expiration",
89576 .data = NULL,
89577 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89578 index f6046d9..4f10cfd 100644
89579 --- a/net/netfilter/ipvs/ip_vs_sync.c
89580 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89581 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89582 cp = cp->control;
89583 if (cp) {
89584 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89585 - pkts = atomic_add_return(1, &cp->in_pkts);
89586 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89587 else
89588 pkts = sysctl_sync_threshold(ipvs);
89589 ip_vs_sync_conn(net, cp->control, pkts);
89590 @@ -758,7 +758,7 @@ control:
89591 if (!cp)
89592 return;
89593 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89594 - pkts = atomic_add_return(1, &cp->in_pkts);
89595 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89596 else
89597 pkts = sysctl_sync_threshold(ipvs);
89598 goto sloop;
89599 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89600
89601 if (opt)
89602 memcpy(&cp->in_seq, opt, sizeof(*opt));
89603 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89604 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89605 cp->state = state;
89606 cp->old_state = cp->state;
89607 /*
89608 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89609 index b75ff64..0c51bbe 100644
89610 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89611 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89612 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89613 else
89614 rc = NF_ACCEPT;
89615 /* do not touch skb anymore */
89616 - atomic_inc(&cp->in_pkts);
89617 + atomic_inc_unchecked(&cp->in_pkts);
89618 goto out;
89619 }
89620
89621 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89622 else
89623 rc = NF_ACCEPT;
89624 /* do not touch skb anymore */
89625 - atomic_inc(&cp->in_pkts);
89626 + atomic_inc_unchecked(&cp->in_pkts);
89627 goto out;
89628 }
89629
89630 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89631 index 2d3030a..7ba1c0a 100644
89632 --- a/net/netfilter/nf_conntrack_acct.c
89633 +++ b/net/netfilter/nf_conntrack_acct.c
89634 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89635 #ifdef CONFIG_SYSCTL
89636 static int nf_conntrack_acct_init_sysctl(struct net *net)
89637 {
89638 - struct ctl_table *table;
89639 + ctl_table_no_const *table;
89640
89641 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89642 GFP_KERNEL);
89643 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89644 index 0283bae..5febcb0 100644
89645 --- a/net/netfilter/nf_conntrack_core.c
89646 +++ b/net/netfilter/nf_conntrack_core.c
89647 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
89648 #define DYING_NULLS_VAL ((1<<30)+1)
89649 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89650
89651 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89652 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89653 +#endif
89654 +
89655 int nf_conntrack_init_net(struct net *net)
89656 {
89657 int ret;
89658 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
89659 goto err_stat;
89660 }
89661
89662 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89663 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89664 +#else
89665 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89666 +#endif
89667 if (!net->ct.slabname) {
89668 ret = -ENOMEM;
89669 goto err_slabname;
89670 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89671 index 1df1761..ce8b88a 100644
89672 --- a/net/netfilter/nf_conntrack_ecache.c
89673 +++ b/net/netfilter/nf_conntrack_ecache.c
89674 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89675 #ifdef CONFIG_SYSCTL
89676 static int nf_conntrack_event_init_sysctl(struct net *net)
89677 {
89678 - struct ctl_table *table;
89679 + ctl_table_no_const *table;
89680
89681 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89682 GFP_KERNEL);
89683 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89684 index 974a2a4..52cc6ff 100644
89685 --- a/net/netfilter/nf_conntrack_helper.c
89686 +++ b/net/netfilter/nf_conntrack_helper.c
89687 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
89688
89689 static int nf_conntrack_helper_init_sysctl(struct net *net)
89690 {
89691 - struct ctl_table *table;
89692 + ctl_table_no_const *table;
89693
89694 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89695 GFP_KERNEL);
89696 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89697 index 0ab9636..cea3c6a 100644
89698 --- a/net/netfilter/nf_conntrack_proto.c
89699 +++ b/net/netfilter/nf_conntrack_proto.c
89700 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
89701
89702 static void
89703 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89704 - struct ctl_table **table,
89705 + ctl_table_no_const **table,
89706 unsigned int users)
89707 {
89708 if (users > 0)
89709 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
89710 index a99b6c3..3841268 100644
89711 --- a/net/netfilter/nf_conntrack_proto_dccp.c
89712 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
89713 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
89714 out_invalid:
89715 if (LOG_INVALID(net, IPPROTO_DCCP))
89716 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
89717 - NULL, msg);
89718 + NULL, "%s", msg);
89719 return false;
89720 }
89721
89722 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
89723
89724 out_invalid:
89725 if (LOG_INVALID(net, IPPROTO_DCCP))
89726 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
89727 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
89728 return -NF_ACCEPT;
89729 }
89730
89731 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89732 index bd700b4..4a3dc61 100644
89733 --- a/net/netfilter/nf_conntrack_standalone.c
89734 +++ b/net/netfilter/nf_conntrack_standalone.c
89735 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89736
89737 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89738 {
89739 - struct ctl_table *table;
89740 + ctl_table_no_const *table;
89741
89742 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
89743 GFP_KERNEL);
89744 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89745 index 902fb0a..87f7fdb 100644
89746 --- a/net/netfilter/nf_conntrack_timestamp.c
89747 +++ b/net/netfilter/nf_conntrack_timestamp.c
89748 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89749 #ifdef CONFIG_SYSCTL
89750 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89751 {
89752 - struct ctl_table *table;
89753 + ctl_table_no_const *table;
89754
89755 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89756 GFP_KERNEL);
89757 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89758 index 3b18dd1..f79e0ca 100644
89759 --- a/net/netfilter/nf_log.c
89760 +++ b/net/netfilter/nf_log.c
89761 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
89762
89763 #ifdef CONFIG_SYSCTL
89764 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89765 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89766 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89767
89768 static int nf_log_proc_dostring(ctl_table *table, int write,
89769 void __user *buffer, size_t *lenp, loff_t *ppos)
89770 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89771 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
89772 mutex_unlock(&nf_log_mutex);
89773 } else {
89774 + ctl_table_no_const nf_log_table = *table;
89775 +
89776 mutex_lock(&nf_log_mutex);
89777 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
89778 lockdep_is_held(&nf_log_mutex));
89779 if (!logger)
89780 - table->data = "NONE";
89781 + nf_log_table.data = "NONE";
89782 else
89783 - table->data = logger->name;
89784 - r = proc_dostring(table, write, buffer, lenp, ppos);
89785 + nf_log_table.data = logger->name;
89786 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89787 mutex_unlock(&nf_log_mutex);
89788 }
89789
89790 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89791 index f042ae5..30ea486 100644
89792 --- a/net/netfilter/nf_sockopt.c
89793 +++ b/net/netfilter/nf_sockopt.c
89794 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89795 }
89796 }
89797
89798 - list_add(&reg->list, &nf_sockopts);
89799 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89800 out:
89801 mutex_unlock(&nf_sockopt_mutex);
89802 return ret;
89803 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89804 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89805 {
89806 mutex_lock(&nf_sockopt_mutex);
89807 - list_del(&reg->list);
89808 + pax_list_del((struct list_head *)&reg->list);
89809 mutex_unlock(&nf_sockopt_mutex);
89810 }
89811 EXPORT_SYMBOL(nf_unregister_sockopt);
89812 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89813 index 962e979..d4ae2e9 100644
89814 --- a/net/netfilter/nfnetlink_log.c
89815 +++ b/net/netfilter/nfnetlink_log.c
89816 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
89817 struct nfnl_log_net {
89818 spinlock_t instances_lock;
89819 struct hlist_head instance_table[INSTANCE_BUCKETS];
89820 - atomic_t global_seq;
89821 + atomic_unchecked_t global_seq;
89822 };
89823
89824 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
89825 @@ -559,7 +559,7 @@ __build_packet_message(struct nfnl_log_net *log,
89826 /* global sequence number */
89827 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89828 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89829 - htonl(atomic_inc_return(&log->global_seq))))
89830 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
89831 goto nla_put_failure;
89832
89833 if (data_len) {
89834 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89835 new file mode 100644
89836 index 0000000..c566332
89837 --- /dev/null
89838 +++ b/net/netfilter/xt_gradm.c
89839 @@ -0,0 +1,51 @@
89840 +/*
89841 + * gradm match for netfilter
89842 + * Copyright © Zbigniew Krzystolik, 2010
89843 + *
89844 + * This program is free software; you can redistribute it and/or modify
89845 + * it under the terms of the GNU General Public License; either version
89846 + * 2 or 3 as published by the Free Software Foundation.
89847 + */
89848 +#include <linux/module.h>
89849 +#include <linux/moduleparam.h>
89850 +#include <linux/skbuff.h>
89851 +#include <linux/netfilter/x_tables.h>
89852 +#include <linux/grsecurity.h>
89853 +#include <linux/netfilter/xt_gradm.h>
89854 +
89855 +static bool
89856 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89857 +{
89858 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89859 + bool retval = false;
89860 + if (gr_acl_is_enabled())
89861 + retval = true;
89862 + return retval ^ info->invflags;
89863 +}
89864 +
89865 +static struct xt_match gradm_mt_reg __read_mostly = {
89866 + .name = "gradm",
89867 + .revision = 0,
89868 + .family = NFPROTO_UNSPEC,
89869 + .match = gradm_mt,
89870 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89871 + .me = THIS_MODULE,
89872 +};
89873 +
89874 +static int __init gradm_mt_init(void)
89875 +{
89876 + return xt_register_match(&gradm_mt_reg);
89877 +}
89878 +
89879 +static void __exit gradm_mt_exit(void)
89880 +{
89881 + xt_unregister_match(&gradm_mt_reg);
89882 +}
89883 +
89884 +module_init(gradm_mt_init);
89885 +module_exit(gradm_mt_exit);
89886 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89887 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89888 +MODULE_LICENSE("GPL");
89889 +MODULE_ALIAS("ipt_gradm");
89890 +MODULE_ALIAS("ip6t_gradm");
89891 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89892 index 4fe4fb4..87a89e5 100644
89893 --- a/net/netfilter/xt_statistic.c
89894 +++ b/net/netfilter/xt_statistic.c
89895 @@ -19,7 +19,7 @@
89896 #include <linux/module.h>
89897
89898 struct xt_statistic_priv {
89899 - atomic_t count;
89900 + atomic_unchecked_t count;
89901 } ____cacheline_aligned_in_smp;
89902
89903 MODULE_LICENSE("GPL");
89904 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89905 break;
89906 case XT_STATISTIC_MODE_NTH:
89907 do {
89908 - oval = atomic_read(&info->master->count);
89909 + oval = atomic_read_unchecked(&info->master->count);
89910 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89911 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89912 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89913 if (nval == 0)
89914 ret = !ret;
89915 break;
89916 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89917 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89918 if (info->master == NULL)
89919 return -ENOMEM;
89920 - atomic_set(&info->master->count, info->u.nth.count);
89921 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89922
89923 return 0;
89924 }
89925 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89926 index 57ee84d..8b99cf5 100644
89927 --- a/net/netlink/af_netlink.c
89928 +++ b/net/netlink/af_netlink.c
89929 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
89930 sk->sk_error_report(sk);
89931 }
89932 }
89933 - atomic_inc(&sk->sk_drops);
89934 + atomic_inc_unchecked(&sk->sk_drops);
89935 }
89936
89937 static void netlink_rcv_wake(struct sock *sk)
89938 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89939 sk_wmem_alloc_get(s),
89940 nlk->cb,
89941 atomic_read(&s->sk_refcnt),
89942 - atomic_read(&s->sk_drops),
89943 + atomic_read_unchecked(&s->sk_drops),
89944 sock_i_ino(s)
89945 );
89946
89947 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89948 index 2fd6dbe..1032269 100644
89949 --- a/net/netlink/genetlink.c
89950 +++ b/net/netlink/genetlink.c
89951 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89952 goto errout;
89953 }
89954
89955 + pax_open_kernel();
89956 if (ops->dumpit)
89957 - ops->flags |= GENL_CMD_CAP_DUMP;
89958 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89959 if (ops->doit)
89960 - ops->flags |= GENL_CMD_CAP_DO;
89961 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89962 if (ops->policy)
89963 - ops->flags |= GENL_CMD_CAP_HASPOL;
89964 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89965 + pax_close_kernel();
89966
89967 genl_lock_all();
89968 - list_add_tail(&ops->ops_list, &family->ops_list);
89969 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89970 genl_unlock_all();
89971
89972 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89973 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89974 err = 0;
89975 errout:
89976 return err;
89977 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89978 genl_lock_all();
89979 list_for_each_entry(rc, &family->ops_list, ops_list) {
89980 if (rc == ops) {
89981 - list_del(&ops->ops_list);
89982 + pax_list_del((struct list_head *)&ops->ops_list);
89983 genl_unlock_all();
89984 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89985 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89986 return 0;
89987 }
89988 }
89989 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89990 index ec0c80f..41e1830 100644
89991 --- a/net/netrom/af_netrom.c
89992 +++ b/net/netrom/af_netrom.c
89993 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89994 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89995 } else {
89996 sax->fsa_ax25.sax25_family = AF_NETROM;
89997 - sax->fsa_ax25.sax25_ndigis = 0;
89998 sax->fsa_ax25.sax25_call = nr->source_addr;
89999 *uaddr_len = sizeof(struct sockaddr_ax25);
90000 }
90001 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
90002 index 20a1bd0..bb8f1c1 100644
90003 --- a/net/packet/af_packet.c
90004 +++ b/net/packet/af_packet.c
90005 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90006
90007 spin_lock(&sk->sk_receive_queue.lock);
90008 po->stats.stats1.tp_packets++;
90009 - skb->dropcount = atomic_read(&sk->sk_drops);
90010 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
90011 __skb_queue_tail(&sk->sk_receive_queue, skb);
90012 spin_unlock(&sk->sk_receive_queue.lock);
90013 sk->sk_data_ready(sk, skb->len);
90014 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90015 drop_n_acct:
90016 spin_lock(&sk->sk_receive_queue.lock);
90017 po->stats.stats1.tp_drops++;
90018 - atomic_inc(&sk->sk_drops);
90019 + atomic_inc_unchecked(&sk->sk_drops);
90020 spin_unlock(&sk->sk_receive_queue.lock);
90021
90022 drop_n_restore:
90023 @@ -2640,6 +2640,7 @@ out:
90024
90025 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90026 {
90027 + struct sock_extended_err ee;
90028 struct sock_exterr_skb *serr;
90029 struct sk_buff *skb, *skb2;
90030 int copied, err;
90031 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90032 sock_recv_timestamp(msg, sk, skb);
90033
90034 serr = SKB_EXT_ERR(skb);
90035 + ee = serr->ee;
90036 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
90037 - sizeof(serr->ee), &serr->ee);
90038 + sizeof ee, &ee);
90039
90040 msg->msg_flags |= MSG_ERRQUEUE;
90041 err = copied;
90042 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90043 case PACKET_HDRLEN:
90044 if (len > sizeof(int))
90045 len = sizeof(int);
90046 - if (copy_from_user(&val, optval, len))
90047 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
90048 return -EFAULT;
90049 switch (val) {
90050 case TPACKET_V1:
90051 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90052 len = lv;
90053 if (put_user(len, optlen))
90054 return -EFAULT;
90055 - if (copy_to_user(optval, data, len))
90056 + if (len > sizeof(st) || copy_to_user(optval, data, len))
90057 return -EFAULT;
90058 return 0;
90059 }
90060 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
90061 index 5a940db..d6a502d 100644
90062 --- a/net/phonet/af_phonet.c
90063 +++ b/net/phonet/af_phonet.c
90064 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
90065 {
90066 int err = 0;
90067
90068 - if (protocol >= PHONET_NPROTO)
90069 + if (protocol < 0 || protocol >= PHONET_NPROTO)
90070 return -EINVAL;
90071
90072 err = proto_register(pp->prot, 1);
90073 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
90074 index e774117..900b8b7 100644
90075 --- a/net/phonet/pep.c
90076 +++ b/net/phonet/pep.c
90077 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90078
90079 case PNS_PEP_CTRL_REQ:
90080 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
90081 - atomic_inc(&sk->sk_drops);
90082 + atomic_inc_unchecked(&sk->sk_drops);
90083 break;
90084 }
90085 __skb_pull(skb, 4);
90086 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90087 }
90088
90089 if (pn->rx_credits == 0) {
90090 - atomic_inc(&sk->sk_drops);
90091 + atomic_inc_unchecked(&sk->sk_drops);
90092 err = -ENOBUFS;
90093 break;
90094 }
90095 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
90096 }
90097
90098 if (pn->rx_credits == 0) {
90099 - atomic_inc(&sk->sk_drops);
90100 + atomic_inc_unchecked(&sk->sk_drops);
90101 err = NET_RX_DROP;
90102 break;
90103 }
90104 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
90105 index 1afd138..0b42453 100644
90106 --- a/net/phonet/socket.c
90107 +++ b/net/phonet/socket.c
90108 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
90109 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
90110 sock_i_ino(sk),
90111 atomic_read(&sk->sk_refcnt), sk,
90112 - atomic_read(&sk->sk_drops), &len);
90113 + atomic_read_unchecked(&sk->sk_drops), &len);
90114 }
90115 seq_printf(seq, "%*s\n", 127 - len, "");
90116 return 0;
90117 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
90118 index d6bbbbd..61561e4 100644
90119 --- a/net/phonet/sysctl.c
90120 +++ b/net/phonet/sysctl.c
90121 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
90122 {
90123 int ret;
90124 int range[2] = {local_port_range[0], local_port_range[1]};
90125 - ctl_table tmp = {
90126 + ctl_table_no_const tmp = {
90127 .data = &range,
90128 .maxlen = sizeof(range),
90129 .mode = table->mode,
90130 diff --git a/net/rds/cong.c b/net/rds/cong.c
90131 index e5b65ac..f3b6fb7 100644
90132 --- a/net/rds/cong.c
90133 +++ b/net/rds/cong.c
90134 @@ -78,7 +78,7 @@
90135 * finds that the saved generation number is smaller than the global generation
90136 * number, it wakes up the process.
90137 */
90138 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
90139 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
90140
90141 /*
90142 * Congestion monitoring
90143 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
90144 rdsdebug("waking map %p for %pI4\n",
90145 map, &map->m_addr);
90146 rds_stats_inc(s_cong_update_received);
90147 - atomic_inc(&rds_cong_generation);
90148 + atomic_inc_unchecked(&rds_cong_generation);
90149 if (waitqueue_active(&map->m_waitq))
90150 wake_up(&map->m_waitq);
90151 if (waitqueue_active(&rds_poll_waitq))
90152 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
90153
90154 int rds_cong_updated_since(unsigned long *recent)
90155 {
90156 - unsigned long gen = atomic_read(&rds_cong_generation);
90157 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
90158
90159 if (likely(*recent == gen))
90160 return 0;
90161 diff --git a/net/rds/ib.h b/net/rds/ib.h
90162 index 7280ab8..e04f4ea 100644
90163 --- a/net/rds/ib.h
90164 +++ b/net/rds/ib.h
90165 @@ -128,7 +128,7 @@ struct rds_ib_connection {
90166 /* sending acks */
90167 unsigned long i_ack_flags;
90168 #ifdef KERNEL_HAS_ATOMIC64
90169 - atomic64_t i_ack_next; /* next ACK to send */
90170 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90171 #else
90172 spinlock_t i_ack_lock; /* protect i_ack_next */
90173 u64 i_ack_next; /* next ACK to send */
90174 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
90175 index 31b74f5..dc1fbfa 100644
90176 --- a/net/rds/ib_cm.c
90177 +++ b/net/rds/ib_cm.c
90178 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
90179 /* Clear the ACK state */
90180 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90181 #ifdef KERNEL_HAS_ATOMIC64
90182 - atomic64_set(&ic->i_ack_next, 0);
90183 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90184 #else
90185 ic->i_ack_next = 0;
90186 #endif
90187 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
90188 index 8eb9501..0c386ff 100644
90189 --- a/net/rds/ib_recv.c
90190 +++ b/net/rds/ib_recv.c
90191 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90192 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
90193 int ack_required)
90194 {
90195 - atomic64_set(&ic->i_ack_next, seq);
90196 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90197 if (ack_required) {
90198 smp_mb__before_clear_bit();
90199 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90200 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90201 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90202 smp_mb__after_clear_bit();
90203
90204 - return atomic64_read(&ic->i_ack_next);
90205 + return atomic64_read_unchecked(&ic->i_ack_next);
90206 }
90207 #endif
90208
90209 diff --git a/net/rds/iw.h b/net/rds/iw.h
90210 index 04ce3b1..48119a6 100644
90211 --- a/net/rds/iw.h
90212 +++ b/net/rds/iw.h
90213 @@ -134,7 +134,7 @@ struct rds_iw_connection {
90214 /* sending acks */
90215 unsigned long i_ack_flags;
90216 #ifdef KERNEL_HAS_ATOMIC64
90217 - atomic64_t i_ack_next; /* next ACK to send */
90218 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90219 #else
90220 spinlock_t i_ack_lock; /* protect i_ack_next */
90221 u64 i_ack_next; /* next ACK to send */
90222 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
90223 index a91e1db..cf3053f 100644
90224 --- a/net/rds/iw_cm.c
90225 +++ b/net/rds/iw_cm.c
90226 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
90227 /* Clear the ACK state */
90228 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90229 #ifdef KERNEL_HAS_ATOMIC64
90230 - atomic64_set(&ic->i_ack_next, 0);
90231 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90232 #else
90233 ic->i_ack_next = 0;
90234 #endif
90235 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
90236 index 4503335..db566b4 100644
90237 --- a/net/rds/iw_recv.c
90238 +++ b/net/rds/iw_recv.c
90239 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90240 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
90241 int ack_required)
90242 {
90243 - atomic64_set(&ic->i_ack_next, seq);
90244 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90245 if (ack_required) {
90246 smp_mb__before_clear_bit();
90247 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90248 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90249 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90250 smp_mb__after_clear_bit();
90251
90252 - return atomic64_read(&ic->i_ack_next);
90253 + return atomic64_read_unchecked(&ic->i_ack_next);
90254 }
90255 #endif
90256
90257 diff --git a/net/rds/rds.h b/net/rds/rds.h
90258 index ec1d731..90a3a8d 100644
90259 --- a/net/rds/rds.h
90260 +++ b/net/rds/rds.h
90261 @@ -449,7 +449,7 @@ struct rds_transport {
90262 void (*sync_mr)(void *trans_private, int direction);
90263 void (*free_mr)(void *trans_private, int invalidate);
90264 void (*flush_mrs)(void);
90265 -};
90266 +} __do_const;
90267
90268 struct rds_sock {
90269 struct sock rs_sk;
90270 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
90271 index edac9ef..16bcb98 100644
90272 --- a/net/rds/tcp.c
90273 +++ b/net/rds/tcp.c
90274 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
90275 int val = 1;
90276
90277 set_fs(KERNEL_DS);
90278 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
90279 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
90280 sizeof(val));
90281 set_fs(oldfs);
90282 }
90283 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
90284 index 81cf5a4..b5826ff 100644
90285 --- a/net/rds/tcp_send.c
90286 +++ b/net/rds/tcp_send.c
90287 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
90288
90289 oldfs = get_fs();
90290 set_fs(KERNEL_DS);
90291 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
90292 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
90293 sizeof(val));
90294 set_fs(oldfs);
90295 }
90296 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
90297 index e61aa60..f07cc89 100644
90298 --- a/net/rxrpc/af_rxrpc.c
90299 +++ b/net/rxrpc/af_rxrpc.c
90300 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
90301 __be32 rxrpc_epoch;
90302
90303 /* current debugging ID */
90304 -atomic_t rxrpc_debug_id;
90305 +atomic_unchecked_t rxrpc_debug_id;
90306
90307 /* count of skbs currently in use */
90308 atomic_t rxrpc_n_skbs;
90309 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
90310 index e4d9cbc..b229649 100644
90311 --- a/net/rxrpc/ar-ack.c
90312 +++ b/net/rxrpc/ar-ack.c
90313 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90314
90315 _enter("{%d,%d,%d,%d},",
90316 call->acks_hard, call->acks_unacked,
90317 - atomic_read(&call->sequence),
90318 + atomic_read_unchecked(&call->sequence),
90319 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
90320
90321 stop = 0;
90322 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90323
90324 /* each Tx packet has a new serial number */
90325 sp->hdr.serial =
90326 - htonl(atomic_inc_return(&call->conn->serial));
90327 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
90328
90329 hdr = (struct rxrpc_header *) txb->head;
90330 hdr->serial = sp->hdr.serial;
90331 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
90332 */
90333 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
90334 {
90335 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
90336 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
90337 }
90338
90339 /*
90340 @@ -629,7 +629,7 @@ process_further:
90341
90342 latest = ntohl(sp->hdr.serial);
90343 hard = ntohl(ack.firstPacket);
90344 - tx = atomic_read(&call->sequence);
90345 + tx = atomic_read_unchecked(&call->sequence);
90346
90347 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90348 latest,
90349 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
90350 goto maybe_reschedule;
90351
90352 send_ACK_with_skew:
90353 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
90354 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
90355 ntohl(ack.serial));
90356 send_ACK:
90357 mtu = call->conn->trans->peer->if_mtu;
90358 @@ -1173,7 +1173,7 @@ send_ACK:
90359 ackinfo.rxMTU = htonl(5692);
90360 ackinfo.jumbo_max = htonl(4);
90361
90362 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90363 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90364 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90365 ntohl(hdr.serial),
90366 ntohs(ack.maxSkew),
90367 @@ -1191,7 +1191,7 @@ send_ACK:
90368 send_message:
90369 _debug("send message");
90370
90371 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90372 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90373 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
90374 send_message_2:
90375
90376 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
90377 index a3bbb36..3341fb9 100644
90378 --- a/net/rxrpc/ar-call.c
90379 +++ b/net/rxrpc/ar-call.c
90380 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
90381 spin_lock_init(&call->lock);
90382 rwlock_init(&call->state_lock);
90383 atomic_set(&call->usage, 1);
90384 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
90385 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90386 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
90387
90388 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
90389 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
90390 index 4106ca9..a338d7a 100644
90391 --- a/net/rxrpc/ar-connection.c
90392 +++ b/net/rxrpc/ar-connection.c
90393 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
90394 rwlock_init(&conn->lock);
90395 spin_lock_init(&conn->state_lock);
90396 atomic_set(&conn->usage, 1);
90397 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
90398 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90399 conn->avail_calls = RXRPC_MAXCALLS;
90400 conn->size_align = 4;
90401 conn->header_size = sizeof(struct rxrpc_header);
90402 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
90403 index e7ed43a..6afa140 100644
90404 --- a/net/rxrpc/ar-connevent.c
90405 +++ b/net/rxrpc/ar-connevent.c
90406 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
90407
90408 len = iov[0].iov_len + iov[1].iov_len;
90409
90410 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90411 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90412 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
90413
90414 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90415 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
90416 index 529572f..c758ca7 100644
90417 --- a/net/rxrpc/ar-input.c
90418 +++ b/net/rxrpc/ar-input.c
90419 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
90420 /* track the latest serial number on this connection for ACK packet
90421 * information */
90422 serial = ntohl(sp->hdr.serial);
90423 - hi_serial = atomic_read(&call->conn->hi_serial);
90424 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90425 while (serial > hi_serial)
90426 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90427 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90428 serial);
90429
90430 /* request ACK generation for any ACK or DATA packet that requests
90431 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90432 index a693aca..81e7293 100644
90433 --- a/net/rxrpc/ar-internal.h
90434 +++ b/net/rxrpc/ar-internal.h
90435 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90436 int error; /* error code for local abort */
90437 int debug_id; /* debug ID for printks */
90438 unsigned int call_counter; /* call ID counter */
90439 - atomic_t serial; /* packet serial number counter */
90440 - atomic_t hi_serial; /* highest serial number received */
90441 + atomic_unchecked_t serial; /* packet serial number counter */
90442 + atomic_unchecked_t hi_serial; /* highest serial number received */
90443 u8 avail_calls; /* number of calls available */
90444 u8 size_align; /* data size alignment (for security) */
90445 u8 header_size; /* rxrpc + security header size */
90446 @@ -346,7 +346,7 @@ struct rxrpc_call {
90447 spinlock_t lock;
90448 rwlock_t state_lock; /* lock for state transition */
90449 atomic_t usage;
90450 - atomic_t sequence; /* Tx data packet sequence counter */
90451 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90452 u32 abort_code; /* local/remote abort code */
90453 enum { /* current state of call */
90454 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90455 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90456 */
90457 extern atomic_t rxrpc_n_skbs;
90458 extern __be32 rxrpc_epoch;
90459 -extern atomic_t rxrpc_debug_id;
90460 +extern atomic_unchecked_t rxrpc_debug_id;
90461 extern struct workqueue_struct *rxrpc_workqueue;
90462
90463 /*
90464 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90465 index 87f7135..74d3703 100644
90466 --- a/net/rxrpc/ar-local.c
90467 +++ b/net/rxrpc/ar-local.c
90468 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90469 spin_lock_init(&local->lock);
90470 rwlock_init(&local->services_lock);
90471 atomic_set(&local->usage, 1);
90472 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90473 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90474 memcpy(&local->srx, srx, sizeof(*srx));
90475 }
90476
90477 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90478 index e1ac183..b43e10e 100644
90479 --- a/net/rxrpc/ar-output.c
90480 +++ b/net/rxrpc/ar-output.c
90481 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90482 sp->hdr.cid = call->cid;
90483 sp->hdr.callNumber = call->call_id;
90484 sp->hdr.seq =
90485 - htonl(atomic_inc_return(&call->sequence));
90486 + htonl(atomic_inc_return_unchecked(&call->sequence));
90487 sp->hdr.serial =
90488 - htonl(atomic_inc_return(&conn->serial));
90489 + htonl(atomic_inc_return_unchecked(&conn->serial));
90490 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90491 sp->hdr.userStatus = 0;
90492 sp->hdr.securityIndex = conn->security_ix;
90493 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90494 index bebaa43..2644591 100644
90495 --- a/net/rxrpc/ar-peer.c
90496 +++ b/net/rxrpc/ar-peer.c
90497 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90498 INIT_LIST_HEAD(&peer->error_targets);
90499 spin_lock_init(&peer->lock);
90500 atomic_set(&peer->usage, 1);
90501 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90502 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90503 memcpy(&peer->srx, srx, sizeof(*srx));
90504
90505 rxrpc_assess_MTU_size(peer);
90506 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90507 index 38047f7..9f48511 100644
90508 --- a/net/rxrpc/ar-proc.c
90509 +++ b/net/rxrpc/ar-proc.c
90510 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90511 atomic_read(&conn->usage),
90512 rxrpc_conn_states[conn->state],
90513 key_serial(conn->key),
90514 - atomic_read(&conn->serial),
90515 - atomic_read(&conn->hi_serial));
90516 + atomic_read_unchecked(&conn->serial),
90517 + atomic_read_unchecked(&conn->hi_serial));
90518
90519 return 0;
90520 }
90521 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90522 index 92df566..87ec1bf 100644
90523 --- a/net/rxrpc/ar-transport.c
90524 +++ b/net/rxrpc/ar-transport.c
90525 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90526 spin_lock_init(&trans->client_lock);
90527 rwlock_init(&trans->conn_lock);
90528 atomic_set(&trans->usage, 1);
90529 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90530 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90531
90532 if (peer->srx.transport.family == AF_INET) {
90533 switch (peer->srx.transport_type) {
90534 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90535 index f226709..0e735a8 100644
90536 --- a/net/rxrpc/rxkad.c
90537 +++ b/net/rxrpc/rxkad.c
90538 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90539
90540 len = iov[0].iov_len + iov[1].iov_len;
90541
90542 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90543 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90544 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90545
90546 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90547 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90548
90549 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90550
90551 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90552 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90553 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90554
90555 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90556 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90557 index 391a245..296b3d7 100644
90558 --- a/net/sctp/ipv6.c
90559 +++ b/net/sctp/ipv6.c
90560 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90561 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90562 };
90563
90564 -static struct sctp_af sctp_af_inet6 = {
90565 +static struct sctp_af sctp_af_inet6 __read_only = {
90566 .sa_family = AF_INET6,
90567 .sctp_xmit = sctp_v6_xmit,
90568 .setsockopt = ipv6_setsockopt,
90569 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90570 #endif
90571 };
90572
90573 -static struct sctp_pf sctp_pf_inet6 = {
90574 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90575 .event_msgname = sctp_inet6_event_msgname,
90576 .skb_msgname = sctp_inet6_skb_msgname,
90577 .af_supported = sctp_inet6_af_supported,
90578 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90579
90580 void sctp_v6_pf_exit(void)
90581 {
90582 - list_del(&sctp_af_inet6.list);
90583 + pax_list_del(&sctp_af_inet6.list);
90584 }
90585
90586 /* Initialize IPv6 support and register with socket layer. */
90587 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90588 index 4e45ee3..e66a031 100644
90589 --- a/net/sctp/proc.c
90590 +++ b/net/sctp/proc.c
90591 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90592 seq_printf(seq,
90593 "%8pK %8pK %-3d %-3d %-2d %-4d "
90594 "%4d %8d %8d %7d %5lu %-5d %5d ",
90595 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90596 + assoc, sk,
90597 + sctp_sk(sk)->type, sk->sk_state,
90598 assoc->state, hash,
90599 assoc->assoc_id,
90600 assoc->sndbuf_used,
90601 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90602 index eaee00c..97c0afd 100644
90603 --- a/net/sctp/protocol.c
90604 +++ b/net/sctp/protocol.c
90605 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90606 return 0;
90607 }
90608
90609 + pax_open_kernel();
90610 INIT_LIST_HEAD(&af->list);
90611 - list_add_tail(&af->list, &sctp_address_families);
90612 + pax_close_kernel();
90613 + pax_list_add_tail(&af->list, &sctp_address_families);
90614 return 1;
90615 }
90616
90617 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90618
90619 static struct sctp_af sctp_af_inet;
90620
90621 -static struct sctp_pf sctp_pf_inet = {
90622 +static struct sctp_pf sctp_pf_inet __read_only = {
90623 .event_msgname = sctp_inet_event_msgname,
90624 .skb_msgname = sctp_inet_skb_msgname,
90625 .af_supported = sctp_inet_af_supported,
90626 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90627 };
90628
90629 /* IPv4 address related functions. */
90630 -static struct sctp_af sctp_af_inet = {
90631 +static struct sctp_af sctp_af_inet __read_only = {
90632 .sa_family = AF_INET,
90633 .sctp_xmit = sctp_v4_xmit,
90634 .setsockopt = ip_setsockopt,
90635 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90636
90637 static void sctp_v4_pf_exit(void)
90638 {
90639 - list_del(&sctp_af_inet.list);
90640 + pax_list_del(&sctp_af_inet.list);
90641 }
90642
90643 static int sctp_v4_protosw_init(void)
90644 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90645 index 8aab894..f6b7e7d 100644
90646 --- a/net/sctp/sm_sideeffect.c
90647 +++ b/net/sctp/sm_sideeffect.c
90648 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90649 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90650 }
90651
90652 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90653 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90654 NULL,
90655 sctp_generate_t1_cookie_event,
90656 sctp_generate_t1_init_event,
90657 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90658 index 6abb1ca..1678f8b 100644
90659 --- a/net/sctp/socket.c
90660 +++ b/net/sctp/socket.c
90661 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90662 {
90663 struct sctp_association *asoc;
90664 struct sctp_ulpevent *event;
90665 + struct sctp_event_subscribe subscribe;
90666
90667 if (optlen > sizeof(struct sctp_event_subscribe))
90668 return -EINVAL;
90669 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90670 + if (copy_from_user(&subscribe, optval, optlen))
90671 return -EFAULT;
90672 + sctp_sk(sk)->subscribe = subscribe;
90673
90674 /*
90675 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90676 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90677 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90678 int __user *optlen)
90679 {
90680 + struct sctp_event_subscribe subscribe;
90681 +
90682 if (len <= 0)
90683 return -EINVAL;
90684 if (len > sizeof(struct sctp_event_subscribe))
90685 len = sizeof(struct sctp_event_subscribe);
90686 if (put_user(len, optlen))
90687 return -EFAULT;
90688 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90689 + subscribe = sctp_sk(sk)->subscribe;
90690 + if (copy_to_user(optval, &subscribe, len))
90691 return -EFAULT;
90692 return 0;
90693 }
90694 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90695 */
90696 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90697 {
90698 + __u32 autoclose;
90699 +
90700 /* Applicable to UDP-style socket only */
90701 if (sctp_style(sk, TCP))
90702 return -EOPNOTSUPP;
90703 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90704 len = sizeof(int);
90705 if (put_user(len, optlen))
90706 return -EFAULT;
90707 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90708 + autoclose = sctp_sk(sk)->autoclose;
90709 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90710 return -EFAULT;
90711 return 0;
90712 }
90713 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90714 */
90715 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90716 {
90717 + struct sctp_initmsg initmsg;
90718 +
90719 if (len < sizeof(struct sctp_initmsg))
90720 return -EINVAL;
90721 len = sizeof(struct sctp_initmsg);
90722 if (put_user(len, optlen))
90723 return -EFAULT;
90724 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90725 + initmsg = sctp_sk(sk)->initmsg;
90726 + if (copy_to_user(optval, &initmsg, len))
90727 return -EFAULT;
90728 return 0;
90729 }
90730 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90731 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90732 if (space_left < addrlen)
90733 return -ENOMEM;
90734 + if (addrlen > sizeof(temp) || addrlen < 0)
90735 + return -EFAULT;
90736 if (copy_to_user(to, &temp, addrlen))
90737 return -EFAULT;
90738 to += addrlen;
90739 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90740 index bf3c6e8..376d8d0 100644
90741 --- a/net/sctp/sysctl.c
90742 +++ b/net/sctp/sysctl.c
90743 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90744 {
90745 struct net *net = current->nsproxy->net_ns;
90746 char tmp[8];
90747 - ctl_table tbl;
90748 + ctl_table_no_const tbl;
90749 int ret;
90750 int changed = 0;
90751 char *none = "none";
90752 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90753
90754 int sctp_sysctl_net_register(struct net *net)
90755 {
90756 - struct ctl_table *table;
90757 + ctl_table_no_const *table;
90758 int i;
90759
90760 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90761 diff --git a/net/socket.c b/net/socket.c
90762 index 4ca1526..df83e47 100644
90763 --- a/net/socket.c
90764 +++ b/net/socket.c
90765 @@ -88,6 +88,7 @@
90766 #include <linux/magic.h>
90767 #include <linux/slab.h>
90768 #include <linux/xattr.h>
90769 +#include <linux/in.h>
90770
90771 #include <asm/uaccess.h>
90772 #include <asm/unistd.h>
90773 @@ -105,6 +106,8 @@
90774 #include <linux/sockios.h>
90775 #include <linux/atalk.h>
90776
90777 +#include <linux/grsock.h>
90778 +
90779 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90780 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90781 unsigned long nr_segs, loff_t pos);
90782 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90783 &sockfs_dentry_operations, SOCKFS_MAGIC);
90784 }
90785
90786 -static struct vfsmount *sock_mnt __read_mostly;
90787 +struct vfsmount *sock_mnt __read_mostly;
90788
90789 static struct file_system_type sock_fs_type = {
90790 .name = "sockfs",
90791 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90792 return -EAFNOSUPPORT;
90793 if (type < 0 || type >= SOCK_MAX)
90794 return -EINVAL;
90795 + if (protocol < 0)
90796 + return -EINVAL;
90797
90798 /* Compatibility.
90799
90800 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90801 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90802 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90803
90804 + if(!gr_search_socket(family, type, protocol)) {
90805 + retval = -EACCES;
90806 + goto out;
90807 + }
90808 +
90809 + if (gr_handle_sock_all(family, type, protocol)) {
90810 + retval = -EACCES;
90811 + goto out;
90812 + }
90813 +
90814 retval = sock_create(family, type, protocol, &sock);
90815 if (retval < 0)
90816 goto out;
90817 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90818 if (sock) {
90819 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90820 if (err >= 0) {
90821 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90822 + err = -EACCES;
90823 + goto error;
90824 + }
90825 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90826 + if (err)
90827 + goto error;
90828 +
90829 err = security_socket_bind(sock,
90830 (struct sockaddr *)&address,
90831 addrlen);
90832 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90833 (struct sockaddr *)
90834 &address, addrlen);
90835 }
90836 +error:
90837 fput_light(sock->file, fput_needed);
90838 }
90839 return err;
90840 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90841 if ((unsigned int)backlog > somaxconn)
90842 backlog = somaxconn;
90843
90844 + if (gr_handle_sock_server_other(sock->sk)) {
90845 + err = -EPERM;
90846 + goto error;
90847 + }
90848 +
90849 + err = gr_search_listen(sock);
90850 + if (err)
90851 + goto error;
90852 +
90853 err = security_socket_listen(sock, backlog);
90854 if (!err)
90855 err = sock->ops->listen(sock, backlog);
90856
90857 +error:
90858 fput_light(sock->file, fput_needed);
90859 }
90860 return err;
90861 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90862 newsock->type = sock->type;
90863 newsock->ops = sock->ops;
90864
90865 + if (gr_handle_sock_server_other(sock->sk)) {
90866 + err = -EPERM;
90867 + sock_release(newsock);
90868 + goto out_put;
90869 + }
90870 +
90871 + err = gr_search_accept(sock);
90872 + if (err) {
90873 + sock_release(newsock);
90874 + goto out_put;
90875 + }
90876 +
90877 /*
90878 * We don't need try_module_get here, as the listening socket (sock)
90879 * has the protocol module (sock->ops->owner) held.
90880 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90881 fd_install(newfd, newfile);
90882 err = newfd;
90883
90884 + gr_attach_curr_ip(newsock->sk);
90885 +
90886 out_put:
90887 fput_light(sock->file, fput_needed);
90888 out:
90889 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90890 int, addrlen)
90891 {
90892 struct socket *sock;
90893 + struct sockaddr *sck;
90894 struct sockaddr_storage address;
90895 int err, fput_needed;
90896
90897 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90898 if (err < 0)
90899 goto out_put;
90900
90901 + sck = (struct sockaddr *)&address;
90902 +
90903 + if (gr_handle_sock_client(sck)) {
90904 + err = -EACCES;
90905 + goto out_put;
90906 + }
90907 +
90908 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90909 + if (err)
90910 + goto out_put;
90911 +
90912 err =
90913 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90914 if (err)
90915 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90916 * the protocol.
90917 */
90918
90919 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90920 +
90921 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90922 unsigned int, flags, struct sockaddr __user *, addr,
90923 int, addr_len)
90924 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90925 struct socket *sock;
90926 struct iovec iov;
90927 struct msghdr msg;
90928 - struct sockaddr_storage address;
90929 + struct sockaddr_storage address = { };
90930 int err, err2;
90931 int fput_needed;
90932
90933 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90934 * checking falls down on this.
90935 */
90936 if (copy_from_user(ctl_buf,
90937 - (void __user __force *)msg_sys->msg_control,
90938 + (void __force_user *)msg_sys->msg_control,
90939 ctl_len))
90940 goto out_freectl;
90941 msg_sys->msg_control = ctl_buf;
90942 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90943 int err, total_len, len;
90944
90945 /* kernel mode address */
90946 - struct sockaddr_storage addr;
90947 + struct sockaddr_storage addr = { };
90948
90949 /* user mode address pointers */
90950 struct sockaddr __user *uaddr;
90951 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90952 * kernel msghdr to use the kernel address space)
90953 */
90954
90955 - uaddr = (__force void __user *)msg_sys->msg_name;
90956 + uaddr = (void __force_user *)msg_sys->msg_name;
90957 uaddr_len = COMPAT_NAMELEN(msg);
90958 if (MSG_CMSG_COMPAT & flags) {
90959 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90960 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90961 old_fs = get_fs();
90962 set_fs(KERNEL_DS);
90963 err = dev_ioctl(net, cmd,
90964 - (struct ifreq __user __force *) &kifr);
90965 + (struct ifreq __force_user *) &kifr);
90966 set_fs(old_fs);
90967
90968 return err;
90969 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90970
90971 old_fs = get_fs();
90972 set_fs(KERNEL_DS);
90973 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90974 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90975 set_fs(old_fs);
90976
90977 if (cmd == SIOCGIFMAP && !err) {
90978 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90979 ret |= __get_user(rtdev, &(ur4->rt_dev));
90980 if (rtdev) {
90981 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90982 - r4.rt_dev = (char __user __force *)devname;
90983 + r4.rt_dev = (char __force_user *)devname;
90984 devname[15] = 0;
90985 } else
90986 r4.rt_dev = NULL;
90987 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90988 int __user *uoptlen;
90989 int err;
90990
90991 - uoptval = (char __user __force *) optval;
90992 - uoptlen = (int __user __force *) optlen;
90993 + uoptval = (char __force_user *) optval;
90994 + uoptlen = (int __force_user *) optlen;
90995
90996 set_fs(KERNEL_DS);
90997 if (level == SOL_SOCKET)
90998 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90999 char __user *uoptval;
91000 int err;
91001
91002 - uoptval = (char __user __force *) optval;
91003 + uoptval = (char __force_user *) optval;
91004
91005 set_fs(KERNEL_DS);
91006 if (level == SOL_SOCKET)
91007 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
91008 index 5a750b9..ca5d7af 100644
91009 --- a/net/sunrpc/clnt.c
91010 +++ b/net/sunrpc/clnt.c
91011 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
91012 (RPC_IS_ASYNC(task) ? "async" : "sync"));
91013
91014 /* Increment call count */
91015 - task->tk_msg.rpc_proc->p_count++;
91016 + pax_open_kernel();
91017 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
91018 + pax_close_kernel();
91019 clnt->cl_stats->rpccnt++;
91020 task->tk_action = call_reserve;
91021 }
91022 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
91023 index 5356b12..c0f4c29 100644
91024 --- a/net/sunrpc/sched.c
91025 +++ b/net/sunrpc/sched.c
91026 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
91027 #ifdef RPC_DEBUG
91028 static void rpc_task_set_debuginfo(struct rpc_task *task)
91029 {
91030 - static atomic_t rpc_pid;
91031 + static atomic_unchecked_t rpc_pid;
91032
91033 - task->tk_pid = atomic_inc_return(&rpc_pid);
91034 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
91035 }
91036 #else
91037 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
91038 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
91039 index 89a588b..678ed90 100644
91040 --- a/net/sunrpc/svc.c
91041 +++ b/net/sunrpc/svc.c
91042 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
91043
91044 __module_get(serv->sv_module);
91045 task = kthread_create_on_node(serv->sv_function, rqstp,
91046 - node, serv->sv_name);
91047 + node, "%s", serv->sv_name);
91048 if (IS_ERR(task)) {
91049 error = PTR_ERR(task);
91050 module_put(serv->sv_module);
91051 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
91052 svc_putnl(resv, RPC_SUCCESS);
91053
91054 /* Bump per-procedure stats counter */
91055 - procp->pc_count++;
91056 + pax_open_kernel();
91057 + (*(unsigned int *)&procp->pc_count)++;
91058 + pax_close_kernel();
91059
91060 /* Initialize storage for argp and resp */
91061 memset(rqstp->rq_argp, 0, procp->pc_argsize);
91062 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
91063 index 8343737..677025e 100644
91064 --- a/net/sunrpc/xprtrdma/svc_rdma.c
91065 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
91066 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
91067 static unsigned int min_max_inline = 4096;
91068 static unsigned int max_max_inline = 65536;
91069
91070 -atomic_t rdma_stat_recv;
91071 -atomic_t rdma_stat_read;
91072 -atomic_t rdma_stat_write;
91073 -atomic_t rdma_stat_sq_starve;
91074 -atomic_t rdma_stat_rq_starve;
91075 -atomic_t rdma_stat_rq_poll;
91076 -atomic_t rdma_stat_rq_prod;
91077 -atomic_t rdma_stat_sq_poll;
91078 -atomic_t rdma_stat_sq_prod;
91079 +atomic_unchecked_t rdma_stat_recv;
91080 +atomic_unchecked_t rdma_stat_read;
91081 +atomic_unchecked_t rdma_stat_write;
91082 +atomic_unchecked_t rdma_stat_sq_starve;
91083 +atomic_unchecked_t rdma_stat_rq_starve;
91084 +atomic_unchecked_t rdma_stat_rq_poll;
91085 +atomic_unchecked_t rdma_stat_rq_prod;
91086 +atomic_unchecked_t rdma_stat_sq_poll;
91087 +atomic_unchecked_t rdma_stat_sq_prod;
91088
91089 /* Temporary NFS request map and context caches */
91090 struct kmem_cache *svc_rdma_map_cachep;
91091 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
91092 len -= *ppos;
91093 if (len > *lenp)
91094 len = *lenp;
91095 - if (len && copy_to_user(buffer, str_buf, len))
91096 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
91097 return -EFAULT;
91098 *lenp = len;
91099 *ppos += len;
91100 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
91101 {
91102 .procname = "rdma_stat_read",
91103 .data = &rdma_stat_read,
91104 - .maxlen = sizeof(atomic_t),
91105 + .maxlen = sizeof(atomic_unchecked_t),
91106 .mode = 0644,
91107 .proc_handler = read_reset_stat,
91108 },
91109 {
91110 .procname = "rdma_stat_recv",
91111 .data = &rdma_stat_recv,
91112 - .maxlen = sizeof(atomic_t),
91113 + .maxlen = sizeof(atomic_unchecked_t),
91114 .mode = 0644,
91115 .proc_handler = read_reset_stat,
91116 },
91117 {
91118 .procname = "rdma_stat_write",
91119 .data = &rdma_stat_write,
91120 - .maxlen = sizeof(atomic_t),
91121 + .maxlen = sizeof(atomic_unchecked_t),
91122 .mode = 0644,
91123 .proc_handler = read_reset_stat,
91124 },
91125 {
91126 .procname = "rdma_stat_sq_starve",
91127 .data = &rdma_stat_sq_starve,
91128 - .maxlen = sizeof(atomic_t),
91129 + .maxlen = sizeof(atomic_unchecked_t),
91130 .mode = 0644,
91131 .proc_handler = read_reset_stat,
91132 },
91133 {
91134 .procname = "rdma_stat_rq_starve",
91135 .data = &rdma_stat_rq_starve,
91136 - .maxlen = sizeof(atomic_t),
91137 + .maxlen = sizeof(atomic_unchecked_t),
91138 .mode = 0644,
91139 .proc_handler = read_reset_stat,
91140 },
91141 {
91142 .procname = "rdma_stat_rq_poll",
91143 .data = &rdma_stat_rq_poll,
91144 - .maxlen = sizeof(atomic_t),
91145 + .maxlen = sizeof(atomic_unchecked_t),
91146 .mode = 0644,
91147 .proc_handler = read_reset_stat,
91148 },
91149 {
91150 .procname = "rdma_stat_rq_prod",
91151 .data = &rdma_stat_rq_prod,
91152 - .maxlen = sizeof(atomic_t),
91153 + .maxlen = sizeof(atomic_unchecked_t),
91154 .mode = 0644,
91155 .proc_handler = read_reset_stat,
91156 },
91157 {
91158 .procname = "rdma_stat_sq_poll",
91159 .data = &rdma_stat_sq_poll,
91160 - .maxlen = sizeof(atomic_t),
91161 + .maxlen = sizeof(atomic_unchecked_t),
91162 .mode = 0644,
91163 .proc_handler = read_reset_stat,
91164 },
91165 {
91166 .procname = "rdma_stat_sq_prod",
91167 .data = &rdma_stat_sq_prod,
91168 - .maxlen = sizeof(atomic_t),
91169 + .maxlen = sizeof(atomic_unchecked_t),
91170 .mode = 0644,
91171 .proc_handler = read_reset_stat,
91172 },
91173 diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91174 index 8d2eddd..65b1462 100644
91175 --- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91176 +++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91177 @@ -98,6 +98,7 @@ void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch,
91178 */
91179 static u32 *decode_write_list(u32 *va, u32 *vaend)
91180 {
91181 + unsigned long start, end;
91182 int nchunks;
91183
91184 struct rpcrdma_write_array *ary =
91185 @@ -113,9 +114,12 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
91186 return NULL;
91187 }
91188 nchunks = ntohl(ary->wc_nchunks);
91189 - if (((unsigned long)&ary->wc_array[0] +
91190 - (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
91191 - (unsigned long)vaend) {
91192 +
91193 + start = (unsigned long)&ary->wc_array[0];
91194 + end = (unsigned long)vaend;
91195 + if (nchunks < 0 ||
91196 + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
91197 + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
91198 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
91199 ary, nchunks, vaend);
91200 return NULL;
91201 @@ -129,6 +133,7 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
91202
91203 static u32 *decode_reply_array(u32 *va, u32 *vaend)
91204 {
91205 + unsigned long start, end;
91206 int nchunks;
91207 struct rpcrdma_write_array *ary =
91208 (struct rpcrdma_write_array *)va;
91209 @@ -143,9 +148,12 @@ static u32 *decode_reply_array(u32 *va, u32 *vaend)
91210 return NULL;
91211 }
91212 nchunks = ntohl(ary->wc_nchunks);
91213 - if (((unsigned long)&ary->wc_array[0] +
91214 - (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
91215 - (unsigned long)vaend) {
91216 +
91217 + start = (unsigned long)&ary->wc_array[0];
91218 + end = (unsigned long)vaend;
91219 + if (nchunks < 0 ||
91220 + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
91221 + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
91222 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
91223 ary, nchunks, vaend);
91224 return NULL;
91225 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91226 index 0ce7552..d074459 100644
91227 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91228 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91229 @@ -501,7 +501,7 @@ next_sge:
91230 svc_rdma_put_context(ctxt, 0);
91231 goto out;
91232 }
91233 - atomic_inc(&rdma_stat_read);
91234 + atomic_inc_unchecked(&rdma_stat_read);
91235
91236 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91237 chl_map->ch[ch_no].count -= read_wr.num_sge;
91238 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91239 dto_q);
91240 list_del_init(&ctxt->dto_q);
91241 } else {
91242 - atomic_inc(&rdma_stat_rq_starve);
91243 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91244 clear_bit(XPT_DATA, &xprt->xpt_flags);
91245 ctxt = NULL;
91246 }
91247 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91248 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91249 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91250 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91251 - atomic_inc(&rdma_stat_recv);
91252 + atomic_inc_unchecked(&rdma_stat_recv);
91253
91254 /* Build up the XDR from the receive buffers. */
91255 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91256 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91257 index c1d124d..acfc59e 100644
91258 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91259 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91260 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91261 write_wr.wr.rdma.remote_addr = to;
91262
91263 /* Post It */
91264 - atomic_inc(&rdma_stat_write);
91265 + atomic_inc_unchecked(&rdma_stat_write);
91266 if (svc_rdma_send(xprt, &write_wr))
91267 goto err;
91268 return 0;
91269 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91270 index 62e4f9b..dd3f2d7 100644
91271 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
91272 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91273 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91274 return;
91275
91276 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
91277 - atomic_inc(&rdma_stat_rq_poll);
91278 + atomic_inc_unchecked(&rdma_stat_rq_poll);
91279
91280 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
91281 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
91282 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91283 }
91284
91285 if (ctxt)
91286 - atomic_inc(&rdma_stat_rq_prod);
91287 + atomic_inc_unchecked(&rdma_stat_rq_prod);
91288
91289 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
91290 /*
91291 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91292 return;
91293
91294 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
91295 - atomic_inc(&rdma_stat_sq_poll);
91296 + atomic_inc_unchecked(&rdma_stat_sq_poll);
91297 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
91298 if (wc.status != IB_WC_SUCCESS)
91299 /* Close the transport */
91300 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91301 }
91302
91303 if (ctxt)
91304 - atomic_inc(&rdma_stat_sq_prod);
91305 + atomic_inc_unchecked(&rdma_stat_sq_prod);
91306 }
91307
91308 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
91309 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
91310 spin_lock_bh(&xprt->sc_lock);
91311 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
91312 spin_unlock_bh(&xprt->sc_lock);
91313 - atomic_inc(&rdma_stat_sq_starve);
91314 + atomic_inc_unchecked(&rdma_stat_sq_starve);
91315
91316 /* See if we can opportunistically reap SQ WR to make room */
91317 sq_cq_reap(xprt);
91318 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
91319 index 9bc6db0..47ac8c0 100644
91320 --- a/net/sysctl_net.c
91321 +++ b/net/sysctl_net.c
91322 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
91323 kgid_t root_gid = make_kgid(net->user_ns, 0);
91324
91325 /* Allow network administrator to have same access as root. */
91326 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
91327 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
91328 uid_eq(root_uid, current_uid())) {
91329 int mode = (table->mode >> 6) & 7;
91330 return (mode << 6) | (mode << 3) | mode;
91331 diff --git a/net/tipc/link.c b/net/tipc/link.c
91332 index a80feee..2bbbe70 100644
91333 --- a/net/tipc/link.c
91334 +++ b/net/tipc/link.c
91335 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
91336 struct tipc_msg fragm_hdr;
91337 struct sk_buff *buf, *buf_chain, *prev;
91338 u32 fragm_crs, fragm_rest, hsz, sect_rest;
91339 - const unchar *sect_crs;
91340 + const unchar __user *sect_crs;
91341 int curr_sect;
91342 u32 fragm_no;
91343
91344 @@ -1242,7 +1242,7 @@ again:
91345
91346 if (!sect_rest) {
91347 sect_rest = msg_sect[++curr_sect].iov_len;
91348 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
91349 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
91350 }
91351
91352 if (sect_rest < fragm_rest)
91353 @@ -1261,7 +1261,7 @@ error:
91354 }
91355 } else
91356 skb_copy_to_linear_data_offset(buf, fragm_crs,
91357 - sect_crs, sz);
91358 + (const void __force_kernel *)sect_crs, sz);
91359 sect_crs += sz;
91360 sect_rest -= sz;
91361 fragm_crs += sz;
91362 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
91363 index f2db8a8..9245aa4 100644
91364 --- a/net/tipc/msg.c
91365 +++ b/net/tipc/msg.c
91366 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
91367 msg_sect[cnt].iov_len);
91368 else
91369 skb_copy_to_linear_data_offset(*buf, pos,
91370 - msg_sect[cnt].iov_base,
91371 + (const void __force_kernel *)msg_sect[cnt].iov_base,
91372 msg_sect[cnt].iov_len);
91373 pos += msg_sect[cnt].iov_len;
91374 }
91375 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
91376 index 6b42d47..2ac24d5 100644
91377 --- a/net/tipc/subscr.c
91378 +++ b/net/tipc/subscr.c
91379 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
91380 {
91381 struct iovec msg_sect;
91382
91383 - msg_sect.iov_base = (void *)&sub->evt;
91384 + msg_sect.iov_base = (void __force_user *)&sub->evt;
91385 msg_sect.iov_len = sizeof(struct tipc_event);
91386
91387 sub->evt.event = htohl(event, sub->swap);
91388 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
91389 index 826e099..4fa8c93 100644
91390 --- a/net/unix/af_unix.c
91391 +++ b/net/unix/af_unix.c
91392 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
91393 err = -ECONNREFUSED;
91394 if (!S_ISSOCK(inode->i_mode))
91395 goto put_fail;
91396 +
91397 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
91398 + err = -EACCES;
91399 + goto put_fail;
91400 + }
91401 +
91402 u = unix_find_socket_byinode(inode);
91403 if (!u)
91404 goto put_fail;
91405 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
91406 if (u) {
91407 struct dentry *dentry;
91408 dentry = unix_sk(u)->path.dentry;
91409 +
91410 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
91411 + err = -EPERM;
91412 + sock_put(u);
91413 + goto fail;
91414 + }
91415 +
91416 if (dentry)
91417 touch_atime(&unix_sk(u)->path);
91418 } else
91419 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
91420 */
91421 err = security_path_mknod(&path, dentry, mode, 0);
91422 if (!err) {
91423 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
91424 + err = -EACCES;
91425 + goto out;
91426 + }
91427 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
91428 if (!err) {
91429 res->mnt = mntget(path.mnt);
91430 res->dentry = dget(dentry);
91431 + gr_handle_create(dentry, path.mnt);
91432 }
91433 }
91434 +out:
91435 done_path_create(&path, dentry);
91436 return err;
91437 }
91438 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91439 seq_puts(seq, "Num RefCount Protocol Flags Type St "
91440 "Inode Path\n");
91441 else {
91442 - struct sock *s = v;
91443 + struct sock *s = v, *peer;
91444 struct unix_sock *u = unix_sk(s);
91445 unix_state_lock(s);
91446 + peer = unix_peer(s);
91447 + unix_state_unlock(s);
91448 +
91449 + unix_state_double_lock(s, peer);
91450
91451 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91452 s,
91453 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91454 }
91455 for ( ; i < len; i++)
91456 seq_putc(seq, u->addr->name->sun_path[i]);
91457 - }
91458 - unix_state_unlock(s);
91459 + } else if (peer)
91460 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91461 +
91462 + unix_state_double_unlock(s, peer);
91463 seq_putc(seq, '\n');
91464 }
91465
91466 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91467 index 8800604..0526440 100644
91468 --- a/net/unix/sysctl_net_unix.c
91469 +++ b/net/unix/sysctl_net_unix.c
91470 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91471
91472 int __net_init unix_sysctl_register(struct net *net)
91473 {
91474 - struct ctl_table *table;
91475 + ctl_table_no_const *table;
91476
91477 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91478 if (table == NULL)
91479 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91480 index c8717c1..08539f5 100644
91481 --- a/net/wireless/wext-core.c
91482 +++ b/net/wireless/wext-core.c
91483 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91484 */
91485
91486 /* Support for very large requests */
91487 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91488 - (user_length > descr->max_tokens)) {
91489 + if (user_length > descr->max_tokens) {
91490 /* Allow userspace to GET more than max so
91491 * we can support any size GET requests.
91492 * There is still a limit : -ENOMEM.
91493 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91494 }
91495 }
91496
91497 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91498 - /*
91499 - * If this is a GET, but not NOMAX, it means that the extra
91500 - * data is not bounded by userspace, but by max_tokens. Thus
91501 - * set the length to max_tokens. This matches the extra data
91502 - * allocation.
91503 - * The driver should fill it with the number of tokens it
91504 - * provided, and it may check iwp->length rather than having
91505 - * knowledge of max_tokens. If the driver doesn't change the
91506 - * iwp->length, this ioctl just copies back max_token tokens
91507 - * filled with zeroes. Hopefully the driver isn't claiming
91508 - * them to be valid data.
91509 - */
91510 - iwp->length = descr->max_tokens;
91511 - }
91512 -
91513 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91514
91515 iwp->length += essid_compat;
91516 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91517 index ea970b8..c68edb9f 100644
91518 --- a/net/xfrm/xfrm_policy.c
91519 +++ b/net/xfrm/xfrm_policy.c
91520 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91521 {
91522 policy->walk.dead = 1;
91523
91524 - atomic_inc(&policy->genid);
91525 + atomic_inc_unchecked(&policy->genid);
91526
91527 del_timer(&policy->polq.hold_timer);
91528 xfrm_queue_purge(&policy->polq.hold_queue);
91529 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91530 hlist_add_head(&policy->bydst, chain);
91531 xfrm_pol_hold(policy);
91532 net->xfrm.policy_count[dir]++;
91533 - atomic_inc(&flow_cache_genid);
91534 + atomic_inc_unchecked(&flow_cache_genid);
91535 rt_genid_bump(net);
91536 if (delpol) {
91537 xfrm_policy_requeue(delpol, policy);
91538 @@ -1629,7 +1629,7 @@ free_dst:
91539 goto out;
91540 }
91541
91542 -static int inline
91543 +static inline int
91544 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91545 {
91546 if (!*target) {
91547 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91548 return 0;
91549 }
91550
91551 -static int inline
91552 +static inline int
91553 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91554 {
91555 #ifdef CONFIG_XFRM_SUB_POLICY
91556 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91557 #endif
91558 }
91559
91560 -static int inline
91561 +static inline int
91562 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91563 {
91564 #ifdef CONFIG_XFRM_SUB_POLICY
91565 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91566
91567 xdst->num_pols = num_pols;
91568 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91569 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91570 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91571
91572 return xdst;
91573 }
91574 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91575 if (xdst->xfrm_genid != dst->xfrm->genid)
91576 return 0;
91577 if (xdst->num_pols > 0 &&
91578 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91579 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91580 return 0;
91581
91582 mtu = dst_mtu(dst->child);
91583 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91584 dst_ops->link_failure = xfrm_link_failure;
91585 if (likely(dst_ops->neigh_lookup == NULL))
91586 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91587 - if (likely(afinfo->garbage_collect == NULL))
91588 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91589 + if (likely(afinfo->garbage_collect == NULL)) {
91590 + pax_open_kernel();
91591 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91592 + pax_close_kernel();
91593 + }
91594 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91595 }
91596 spin_unlock(&xfrm_policy_afinfo_lock);
91597 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91598 dst_ops->check = NULL;
91599 dst_ops->negative_advice = NULL;
91600 dst_ops->link_failure = NULL;
91601 - afinfo->garbage_collect = NULL;
91602 + pax_open_kernel();
91603 + *(void **)&afinfo->garbage_collect = NULL;
91604 + pax_close_kernel();
91605 }
91606 return err;
91607 }
91608 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91609 sizeof(pol->xfrm_vec[i].saddr));
91610 pol->xfrm_vec[i].encap_family = mp->new_family;
91611 /* flush bundles */
91612 - atomic_inc(&pol->genid);
91613 + atomic_inc_unchecked(&pol->genid);
91614 }
91615 }
91616
91617 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91618 index 78f66fa..9286768 100644
91619 --- a/net/xfrm/xfrm_state.c
91620 +++ b/net/xfrm/xfrm_state.c
91621 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91622
91623 if (unlikely(afinfo == NULL))
91624 return -EAFNOSUPPORT;
91625 - typemap = afinfo->type_map;
91626 + typemap = (const struct xfrm_type **)afinfo->type_map;
91627 spin_lock_bh(&xfrm_type_lock);
91628
91629 - if (likely(typemap[type->proto] == NULL))
91630 + if (likely(typemap[type->proto] == NULL)) {
91631 + pax_open_kernel();
91632 typemap[type->proto] = type;
91633 - else
91634 + pax_close_kernel();
91635 + } else
91636 err = -EEXIST;
91637 spin_unlock_bh(&xfrm_type_lock);
91638 xfrm_state_put_afinfo(afinfo);
91639 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91640
91641 if (unlikely(afinfo == NULL))
91642 return -EAFNOSUPPORT;
91643 - typemap = afinfo->type_map;
91644 + typemap = (const struct xfrm_type **)afinfo->type_map;
91645 spin_lock_bh(&xfrm_type_lock);
91646
91647 if (unlikely(typemap[type->proto] != type))
91648 err = -ENOENT;
91649 - else
91650 + else {
91651 + pax_open_kernel();
91652 typemap[type->proto] = NULL;
91653 + pax_close_kernel();
91654 + }
91655 spin_unlock_bh(&xfrm_type_lock);
91656 xfrm_state_put_afinfo(afinfo);
91657 return err;
91658 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91659 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91660 {
91661 struct xfrm_state_afinfo *afinfo;
91662 - const struct xfrm_type **typemap;
91663 const struct xfrm_type *type;
91664 int modload_attempted = 0;
91665
91666 @@ -222,9 +226,8 @@ retry:
91667 afinfo = xfrm_state_get_afinfo(family);
91668 if (unlikely(afinfo == NULL))
91669 return NULL;
91670 - typemap = afinfo->type_map;
91671
91672 - type = typemap[proto];
91673 + type = afinfo->type_map[proto];
91674 if (unlikely(type && !try_module_get(type->owner)))
91675 type = NULL;
91676 if (!type && !modload_attempted) {
91677 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91678 return -EAFNOSUPPORT;
91679
91680 err = -EEXIST;
91681 - modemap = afinfo->mode_map;
91682 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91683 spin_lock_bh(&xfrm_mode_lock);
91684 if (modemap[mode->encap])
91685 goto out;
91686 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91687 if (!try_module_get(afinfo->owner))
91688 goto out;
91689
91690 - mode->afinfo = afinfo;
91691 + pax_open_kernel();
91692 + *(const void **)&mode->afinfo = afinfo;
91693 modemap[mode->encap] = mode;
91694 + pax_close_kernel();
91695 err = 0;
91696
91697 out:
91698 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91699 return -EAFNOSUPPORT;
91700
91701 err = -ENOENT;
91702 - modemap = afinfo->mode_map;
91703 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91704 spin_lock_bh(&xfrm_mode_lock);
91705 if (likely(modemap[mode->encap] == mode)) {
91706 + pax_open_kernel();
91707 modemap[mode->encap] = NULL;
91708 + pax_close_kernel();
91709 module_put(mode->afinfo->owner);
91710 err = 0;
91711 }
91712 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91713 index 05a6e3d..6716ec9 100644
91714 --- a/net/xfrm/xfrm_sysctl.c
91715 +++ b/net/xfrm/xfrm_sysctl.c
91716 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91717
91718 int __net_init xfrm_sysctl_init(struct net *net)
91719 {
91720 - struct ctl_table *table;
91721 + ctl_table_no_const *table;
91722
91723 __xfrm_sysctl_init(net);
91724
91725 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91726 index d5d859c..781cbcb 100644
91727 --- a/scripts/Makefile.build
91728 +++ b/scripts/Makefile.build
91729 @@ -111,7 +111,7 @@ endif
91730 endif
91731
91732 # Do not include host rules unless needed
91733 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91734 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91735 include scripts/Makefile.host
91736 endif
91737
91738 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91739 index 686cb0d..9d653bf 100644
91740 --- a/scripts/Makefile.clean
91741 +++ b/scripts/Makefile.clean
91742 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91743 __clean-files := $(extra-y) $(always) \
91744 $(targets) $(clean-files) \
91745 $(host-progs) \
91746 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91747 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91748 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91749
91750 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91751
91752 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91753 index 1ac414f..38575f7 100644
91754 --- a/scripts/Makefile.host
91755 +++ b/scripts/Makefile.host
91756 @@ -31,6 +31,8 @@
91757 # Note: Shared libraries consisting of C++ files are not supported
91758
91759 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91760 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91761 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91762
91763 # C code
91764 # Executables compiled from a single .c file
91765 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91766 # Shared libaries (only .c supported)
91767 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91768 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91769 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91770 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91771 # Remove .so files from "xxx-objs"
91772 host-cobjs := $(filter-out %.so,$(host-cobjs))
91773 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91774
91775 -#Object (.o) files used by the shared libaries
91776 +# Object (.o) files used by the shared libaries
91777 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91778 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91779
91780 # output directory for programs/.o files
91781 # hostprogs-y := tools/build may have been specified. Retrieve directory
91782 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91783 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91784 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91785 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91786 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91787 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91788 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91789 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91790
91791 obj-dirs += $(host-objdirs)
91792 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91793 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91794 $(call if_changed_dep,host-cshobjs)
91795
91796 +# Compile .c file, create position independent .o file
91797 +# host-cxxshobjs -> .o
91798 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91799 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91800 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91801 + $(call if_changed_dep,host-cxxshobjs)
91802 +
91803 # Link a shared library, based on position independent .o files
91804 # *.o -> .so shared library (host-cshlib)
91805 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91806 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91807 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91808 $(call if_changed,host-cshlib)
91809
91810 +# Link a shared library, based on position independent .o files
91811 +# *.o -> .so shared library (host-cxxshlib)
91812 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91813 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91814 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91815 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91816 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91817 + $(call if_changed,host-cxxshlib)
91818 +
91819 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91820 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91821 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91822
91823 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91824 index 078fe1d..fbdb363 100644
91825 --- a/scripts/basic/fixdep.c
91826 +++ b/scripts/basic/fixdep.c
91827 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91828 /*
91829 * Lookup a value in the configuration string.
91830 */
91831 -static int is_defined_config(const char *name, int len, unsigned int hash)
91832 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91833 {
91834 struct item *aux;
91835
91836 @@ -211,10 +211,10 @@ static void clear_config(void)
91837 /*
91838 * Record the use of a CONFIG_* word.
91839 */
91840 -static void use_config(const char *m, int slen)
91841 +static void use_config(const char *m, unsigned int slen)
91842 {
91843 unsigned int hash = strhash(m, slen);
91844 - int c, i;
91845 + unsigned int c, i;
91846
91847 if (is_defined_config(m, slen, hash))
91848 return;
91849 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91850
91851 static void parse_config_file(const char *map, size_t len)
91852 {
91853 - const int *end = (const int *) (map + len);
91854 + const unsigned int *end = (const unsigned int *) (map + len);
91855 /* start at +1, so that p can never be < map */
91856 - const int *m = (const int *) map + 1;
91857 + const unsigned int *m = (const unsigned int *) map + 1;
91858 const char *p, *q;
91859
91860 for (; m < end; m++) {
91861 @@ -435,7 +435,7 @@ static void print_deps(void)
91862 static void traps(void)
91863 {
91864 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91865 - int *p = (int *)test;
91866 + unsigned int *p = (unsigned int *)test;
91867
91868 if (*p != INT_CONF) {
91869 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91870 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91871 new file mode 100644
91872 index 0000000..5e0222d
91873 --- /dev/null
91874 +++ b/scripts/gcc-plugin.sh
91875 @@ -0,0 +1,17 @@
91876 +#!/bin/bash
91877 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91878 +#include "gcc-plugin.h"
91879 +#include "tree.h"
91880 +#include "tm.h"
91881 +#include "rtl.h"
91882 +#ifdef ENABLE_BUILD_WITH_CXX
91883 +#warning $2
91884 +#else
91885 +#warning $1
91886 +#endif
91887 +EOF`
91888 +if [ $? -eq 0 ]
91889 +then
91890 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91891 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91892 +fi
91893 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
91894 index 643764f..6cc0137 100644
91895 --- a/scripts/headers_install.sh
91896 +++ b/scripts/headers_install.sh
91897 @@ -29,6 +29,7 @@ do
91898 FILE="$(basename "$i")"
91899 sed -r \
91900 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
91901 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
91902 -e 's/__attribute_const__([ \t]|$)/\1/g' \
91903 -e 's@^#include <linux/compiler.h>@@' \
91904 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
91905 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91906 index 0149949..d482a0d 100644
91907 --- a/scripts/link-vmlinux.sh
91908 +++ b/scripts/link-vmlinux.sh
91909 @@ -158,7 +158,7 @@ else
91910 fi;
91911
91912 # final build of init/
91913 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91914 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91915
91916 kallsymso=""
91917 kallsyms_vmlinux=""
91918 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91919 index 45f9a33..e4194b3 100644
91920 --- a/scripts/mod/file2alias.c
91921 +++ b/scripts/mod/file2alias.c
91922 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91923 unsigned long size, unsigned long id_size,
91924 void *symval)
91925 {
91926 - int i;
91927 + unsigned int i;
91928
91929 if (size % id_size || size < id_size) {
91930 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91931 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91932 /* USB is special because the bcdDevice can be matched against a numeric range */
91933 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91934 static void do_usb_entry(void *symval,
91935 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91936 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91937 unsigned char range_lo, unsigned char range_hi,
91938 unsigned char max, struct module *mod)
91939 {
91940 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91941 {
91942 unsigned int devlo, devhi;
91943 unsigned char chi, clo, max;
91944 - int ndigits;
91945 + unsigned int ndigits;
91946
91947 DEF_FIELD(symval, usb_device_id, match_flags);
91948 DEF_FIELD(symval, usb_device_id, idVendor);
91949 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91950 for (i = 0; i < count; i++) {
91951 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91952 char acpi_id[sizeof(*id)];
91953 - int j;
91954 + unsigned int j;
91955
91956 buf_printf(&mod->dev_table_buf,
91957 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91958 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91959
91960 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91961 const char *id = (char *)(*devs)[j].id;
91962 - int i2, j2;
91963 + unsigned int i2, j2;
91964 int dup = 0;
91965
91966 if (!id[0])
91967 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91968 /* add an individual alias for every device entry */
91969 if (!dup) {
91970 char acpi_id[PNP_ID_LEN];
91971 - int k;
91972 + unsigned int k;
91973
91974 buf_printf(&mod->dev_table_buf,
91975 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91976 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91977 static int do_dmi_entry(const char *filename, void *symval,
91978 char *alias)
91979 {
91980 - int i, j;
91981 + unsigned int i, j;
91982 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91983 sprintf(alias, "dmi*");
91984
91985 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91986 index a4be8e1..6e8a5fb 100644
91987 --- a/scripts/mod/modpost.c
91988 +++ b/scripts/mod/modpost.c
91989 @@ -933,6 +933,7 @@ enum mismatch {
91990 ANY_INIT_TO_ANY_EXIT,
91991 ANY_EXIT_TO_ANY_INIT,
91992 EXPORT_TO_INIT_EXIT,
91993 + DATA_TO_TEXT
91994 };
91995
91996 struct sectioncheck {
91997 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
91998 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91999 .mismatch = EXPORT_TO_INIT_EXIT,
92000 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
92001 +},
92002 +/* Do not reference code from writable data */
92003 +{
92004 + .fromsec = { DATA_SECTIONS, NULL },
92005 + .tosec = { TEXT_SECTIONS, NULL },
92006 + .mismatch = DATA_TO_TEXT
92007 }
92008 };
92009
92010 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
92011 continue;
92012 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
92013 continue;
92014 - if (sym->st_value == addr)
92015 - return sym;
92016 /* Find a symbol nearby - addr are maybe negative */
92017 d = sym->st_value - addr;
92018 + if (d == 0)
92019 + return sym;
92020 if (d < 0)
92021 d = addr - sym->st_value;
92022 if (d < distance) {
92023 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
92024 tosym, prl_to, prl_to, tosym);
92025 free(prl_to);
92026 break;
92027 + case DATA_TO_TEXT:
92028 +#if 0
92029 + fprintf(stderr,
92030 + "The %s %s:%s references\n"
92031 + "the %s %s:%s%s\n",
92032 + from, fromsec, fromsym, to, tosec, tosym, to_p);
92033 +#endif
92034 + break;
92035 }
92036 fprintf(stderr, "\n");
92037 }
92038 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
92039 static void check_sec_ref(struct module *mod, const char *modname,
92040 struct elf_info *elf)
92041 {
92042 - int i;
92043 + unsigned int i;
92044 Elf_Shdr *sechdrs = elf->sechdrs;
92045
92046 /* Walk through all sections */
92047 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
92048 va_end(ap);
92049 }
92050
92051 -void buf_write(struct buffer *buf, const char *s, int len)
92052 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
92053 {
92054 if (buf->size - buf->pos < len) {
92055 buf->size += len + SZ;
92056 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
92057 if (fstat(fileno(file), &st) < 0)
92058 goto close_write;
92059
92060 - if (st.st_size != b->pos)
92061 + if (st.st_size != (off_t)b->pos)
92062 goto close_write;
92063
92064 tmp = NOFAIL(malloc(b->pos));
92065 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
92066 index 51207e4..f7d603d 100644
92067 --- a/scripts/mod/modpost.h
92068 +++ b/scripts/mod/modpost.h
92069 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
92070
92071 struct buffer {
92072 char *p;
92073 - int pos;
92074 - int size;
92075 + unsigned int pos;
92076 + unsigned int size;
92077 };
92078
92079 void __attribute__((format(printf, 2, 3)))
92080 buf_printf(struct buffer *buf, const char *fmt, ...);
92081
92082 void
92083 -buf_write(struct buffer *buf, const char *s, int len);
92084 +buf_write(struct buffer *buf, const char *s, unsigned int len);
92085
92086 struct module {
92087 struct module *next;
92088 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
92089 index 9dfcd6d..099068e 100644
92090 --- a/scripts/mod/sumversion.c
92091 +++ b/scripts/mod/sumversion.c
92092 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
92093 goto out;
92094 }
92095
92096 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
92097 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
92098 warn("writing sum in %s failed: %s\n",
92099 filename, strerror(errno));
92100 goto out;
92101 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
92102 index acb8650..b8c5f02 100644
92103 --- a/scripts/package/builddeb
92104 +++ b/scripts/package/builddeb
92105 @@ -246,6 +246,7 @@ fi
92106 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
92107 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
92108 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
92109 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
92110 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
92111 mkdir -p "$destdir"
92112 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
92113 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
92114 index 68bb4ef..2f419e1 100644
92115 --- a/scripts/pnmtologo.c
92116 +++ b/scripts/pnmtologo.c
92117 @@ -244,14 +244,14 @@ static void write_header(void)
92118 fprintf(out, " * Linux logo %s\n", logoname);
92119 fputs(" */\n\n", out);
92120 fputs("#include <linux/linux_logo.h>\n\n", out);
92121 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
92122 + fprintf(out, "static unsigned char %s_data[] = {\n",
92123 logoname);
92124 }
92125
92126 static void write_footer(void)
92127 {
92128 fputs("\n};\n\n", out);
92129 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
92130 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
92131 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
92132 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
92133 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
92134 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
92135 fputs("\n};\n\n", out);
92136
92137 /* write logo clut */
92138 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
92139 + fprintf(out, "static unsigned char %s_clut[] = {\n",
92140 logoname);
92141 write_hex_cnt = 0;
92142 for (i = 0; i < logo_clutsize; i++) {
92143 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
92144 index f5eb43d..1814de8 100644
92145 --- a/scripts/sortextable.h
92146 +++ b/scripts/sortextable.h
92147 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
92148 const char *secstrtab;
92149 const char *strtab;
92150 char *extab_image;
92151 - int extab_index = 0;
92152 - int i;
92153 - int idx;
92154 + unsigned int extab_index = 0;
92155 + unsigned int i;
92156 + unsigned int idx;
92157
92158 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
92159 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
92160 diff --git a/security/Kconfig b/security/Kconfig
92161 index e9c6ac7..66bf8e9 100644
92162 --- a/security/Kconfig
92163 +++ b/security/Kconfig
92164 @@ -4,6 +4,945 @@
92165
92166 menu "Security options"
92167
92168 +menu "Grsecurity"
92169 +
92170 + config ARCH_TRACK_EXEC_LIMIT
92171 + bool
92172 +
92173 + config PAX_KERNEXEC_PLUGIN
92174 + bool
92175 +
92176 + config PAX_PER_CPU_PGD
92177 + bool
92178 +
92179 + config TASK_SIZE_MAX_SHIFT
92180 + int
92181 + depends on X86_64
92182 + default 47 if !PAX_PER_CPU_PGD
92183 + default 42 if PAX_PER_CPU_PGD
92184 +
92185 + config PAX_ENABLE_PAE
92186 + bool
92187 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92188 +
92189 + config PAX_USERCOPY_SLABS
92190 + bool
92191 +
92192 +config GRKERNSEC
92193 + bool "Grsecurity"
92194 + select CRYPTO
92195 + select CRYPTO_SHA256
92196 + select PROC_FS
92197 + select STOP_MACHINE
92198 + select TTY
92199 + help
92200 + If you say Y here, you will be able to configure many features
92201 + that will enhance the security of your system. It is highly
92202 + recommended that you say Y here and read through the help
92203 + for each option so that you fully understand the features and
92204 + can evaluate their usefulness for your machine.
92205 +
92206 +choice
92207 + prompt "Configuration Method"
92208 + depends on GRKERNSEC
92209 + default GRKERNSEC_CONFIG_CUSTOM
92210 + help
92211 +
92212 +config GRKERNSEC_CONFIG_AUTO
92213 + bool "Automatic"
92214 + help
92215 + If you choose this configuration method, you'll be able to answer a small
92216 + number of simple questions about how you plan to use this kernel.
92217 + The settings of grsecurity and PaX will be automatically configured for
92218 + the highest commonly-used settings within the provided constraints.
92219 +
92220 + If you require additional configuration, custom changes can still be made
92221 + from the "custom configuration" menu.
92222 +
92223 +config GRKERNSEC_CONFIG_CUSTOM
92224 + bool "Custom"
92225 + help
92226 + If you choose this configuration method, you'll be able to configure all
92227 + grsecurity and PaX settings manually. Via this method, no options are
92228 + automatically enabled.
92229 +
92230 +endchoice
92231 +
92232 +choice
92233 + prompt "Usage Type"
92234 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92235 + default GRKERNSEC_CONFIG_SERVER
92236 + help
92237 +
92238 +config GRKERNSEC_CONFIG_SERVER
92239 + bool "Server"
92240 + help
92241 + Choose this option if you plan to use this kernel on a server.
92242 +
92243 +config GRKERNSEC_CONFIG_DESKTOP
92244 + bool "Desktop"
92245 + help
92246 + Choose this option if you plan to use this kernel on a desktop.
92247 +
92248 +endchoice
92249 +
92250 +choice
92251 + prompt "Virtualization Type"
92252 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92253 + default GRKERNSEC_CONFIG_VIRT_NONE
92254 + help
92255 +
92256 +config GRKERNSEC_CONFIG_VIRT_NONE
92257 + bool "None"
92258 + help
92259 + Choose this option if this kernel will be run on bare metal.
92260 +
92261 +config GRKERNSEC_CONFIG_VIRT_GUEST
92262 + bool "Guest"
92263 + help
92264 + Choose this option if this kernel will be run as a VM guest.
92265 +
92266 +config GRKERNSEC_CONFIG_VIRT_HOST
92267 + bool "Host"
92268 + help
92269 + Choose this option if this kernel will be run as a VM host.
92270 +
92271 +endchoice
92272 +
92273 +choice
92274 + prompt "Virtualization Hardware"
92275 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92276 + help
92277 +
92278 +config GRKERNSEC_CONFIG_VIRT_EPT
92279 + bool "EPT/RVI Processor Support"
92280 + depends on X86
92281 + help
92282 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
92283 + hardware virtualization. This allows for additional kernel hardening protections
92284 + to operate without additional performance impact.
92285 +
92286 + To see if your Intel processor supports EPT, see:
92287 + http://ark.intel.com/Products/VirtualizationTechnology
92288 + (Most Core i3/5/7 support EPT)
92289 +
92290 + To see if your AMD processor supports RVI, see:
92291 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
92292 +
92293 +config GRKERNSEC_CONFIG_VIRT_SOFT
92294 + bool "First-gen/No Hardware Virtualization"
92295 + help
92296 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
92297 + support hardware virtualization or doesn't support the EPT/RVI extensions.
92298 +
92299 +endchoice
92300 +
92301 +choice
92302 + prompt "Virtualization Software"
92303 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92304 + help
92305 +
92306 +config GRKERNSEC_CONFIG_VIRT_XEN
92307 + bool "Xen"
92308 + help
92309 + Choose this option if this kernel is running as a Xen guest or host.
92310 +
92311 +config GRKERNSEC_CONFIG_VIRT_VMWARE
92312 + bool "VMWare"
92313 + help
92314 + Choose this option if this kernel is running as a VMWare guest or host.
92315 +
92316 +config GRKERNSEC_CONFIG_VIRT_KVM
92317 + bool "KVM"
92318 + help
92319 + Choose this option if this kernel is running as a KVM guest or host.
92320 +
92321 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
92322 + bool "VirtualBox"
92323 + help
92324 + Choose this option if this kernel is running as a VirtualBox guest or host.
92325 +
92326 +endchoice
92327 +
92328 +choice
92329 + prompt "Required Priorities"
92330 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92331 + default GRKERNSEC_CONFIG_PRIORITY_PERF
92332 + help
92333 +
92334 +config GRKERNSEC_CONFIG_PRIORITY_PERF
92335 + bool "Performance"
92336 + help
92337 + Choose this option if performance is of highest priority for this deployment
92338 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
92339 + clearing of structures intended for userland, and freed memory sanitizing will
92340 + be disabled.
92341 +
92342 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
92343 + bool "Security"
92344 + help
92345 + Choose this option if security is of highest priority for this deployment of
92346 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
92347 + for userland, and freed memory sanitizing will be enabled for this kernel.
92348 + In a worst-case scenario, these features can introduce a 20% performance hit
92349 + (UDEREF on x64 contributing half of this hit).
92350 +
92351 +endchoice
92352 +
92353 +menu "Default Special Groups"
92354 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92355 +
92356 +config GRKERNSEC_PROC_GID
92357 + int "GID exempted from /proc restrictions"
92358 + default 1001
92359 + help
92360 + Setting this GID determines which group will be exempted from
92361 + grsecurity's /proc restrictions, allowing users of the specified
92362 + group to view network statistics and the existence of other users'
92363 + processes on the system. This GID may also be chosen at boot time
92364 + via "grsec_proc_gid=" on the kernel commandline.
92365 +
92366 +config GRKERNSEC_TPE_UNTRUSTED_GID
92367 + int "GID for TPE-untrusted users"
92368 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
92369 + default 1005
92370 + help
92371 + Setting this GID determines which group untrusted users should
92372 + be added to. These users will be placed under grsecurity's Trusted Path
92373 + Execution mechanism, preventing them from executing their own binaries.
92374 + The users will only be able to execute binaries in directories owned and
92375 + writable only by the root user. If the sysctl option is enabled, a sysctl
92376 + option with name "tpe_gid" is created.
92377 +
92378 +config GRKERNSEC_TPE_TRUSTED_GID
92379 + int "GID for TPE-trusted users"
92380 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
92381 + default 1005
92382 + help
92383 + Setting this GID determines what group TPE restrictions will be
92384 + *disabled* for. If the sysctl option is enabled, a sysctl option
92385 + with name "tpe_gid" is created.
92386 +
92387 +config GRKERNSEC_SYMLINKOWN_GID
92388 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
92389 + depends on GRKERNSEC_CONFIG_SERVER
92390 + default 1006
92391 + help
92392 + Setting this GID determines what group kernel-enforced
92393 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
92394 + is enabled, a sysctl option with name "symlinkown_gid" is created.
92395 +
92396 +
92397 +endmenu
92398 +
92399 +menu "Customize Configuration"
92400 +depends on GRKERNSEC
92401 +
92402 +menu "PaX"
92403 +
92404 +config PAX
92405 + bool "Enable various PaX features"
92406 + default y if GRKERNSEC_CONFIG_AUTO
92407 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
92408 + help
92409 + This allows you to enable various PaX features. PaX adds
92410 + intrusion prevention mechanisms to the kernel that reduce
92411 + the risks posed by exploitable memory corruption bugs.
92412 +
92413 +menu "PaX Control"
92414 + depends on PAX
92415 +
92416 +config PAX_SOFTMODE
92417 + bool 'Support soft mode'
92418 + help
92419 + Enabling this option will allow you to run PaX in soft mode, that
92420 + is, PaX features will not be enforced by default, only on executables
92421 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
92422 + support as they are the only way to mark executables for soft mode use.
92423 +
92424 + Soft mode can be activated by using the "pax_softmode=1" kernel command
92425 + line option on boot. Furthermore you can control various PaX features
92426 + at runtime via the entries in /proc/sys/kernel/pax.
92427 +
92428 +config PAX_EI_PAX
92429 + bool 'Use legacy ELF header marking'
92430 + default y if GRKERNSEC_CONFIG_AUTO
92431 + help
92432 + Enabling this option will allow you to control PaX features on
92433 + a per executable basis via the 'chpax' utility available at
92434 + http://pax.grsecurity.net/. The control flags will be read from
92435 + an otherwise reserved part of the ELF header. This marking has
92436 + numerous drawbacks (no support for soft-mode, toolchain does not
92437 + know about the non-standard use of the ELF header) therefore it
92438 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
92439 + support.
92440 +
92441 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92442 + support as well, they will override the legacy EI_PAX marks.
92443 +
92444 + If you enable none of the marking options then all applications
92445 + will run with PaX enabled on them by default.
92446 +
92447 +config PAX_PT_PAX_FLAGS
92448 + bool 'Use ELF program header marking'
92449 + default y if GRKERNSEC_CONFIG_AUTO
92450 + help
92451 + Enabling this option will allow you to control PaX features on
92452 + a per executable basis via the 'paxctl' utility available at
92453 + http://pax.grsecurity.net/. The control flags will be read from
92454 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92455 + has the benefits of supporting both soft mode and being fully
92456 + integrated into the toolchain (the binutils patch is available
92457 + from http://pax.grsecurity.net).
92458 +
92459 + Note that if you enable the legacy EI_PAX marking support as well,
92460 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92461 +
92462 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92463 + must make sure that the marks are the same if a binary has both marks.
92464 +
92465 + If you enable none of the marking options then all applications
92466 + will run with PaX enabled on them by default.
92467 +
92468 +config PAX_XATTR_PAX_FLAGS
92469 + bool 'Use filesystem extended attributes marking'
92470 + default y if GRKERNSEC_CONFIG_AUTO
92471 + select CIFS_XATTR if CIFS
92472 + select EXT2_FS_XATTR if EXT2_FS
92473 + select EXT3_FS_XATTR if EXT3_FS
92474 + select EXT4_FS_XATTR if EXT4_FS
92475 + select JFFS2_FS_XATTR if JFFS2_FS
92476 + select REISERFS_FS_XATTR if REISERFS_FS
92477 + select SQUASHFS_XATTR if SQUASHFS
92478 + select TMPFS_XATTR if TMPFS
92479 + select UBIFS_FS_XATTR if UBIFS_FS
92480 + help
92481 + Enabling this option will allow you to control PaX features on
92482 + a per executable basis via the 'setfattr' utility. The control
92483 + flags will be read from the user.pax.flags extended attribute of
92484 + the file. This marking has the benefit of supporting binary-only
92485 + applications that self-check themselves (e.g., skype) and would
92486 + not tolerate chpax/paxctl changes. The main drawback is that
92487 + extended attributes are not supported by some filesystems (e.g.,
92488 + isofs, udf, vfat) so copying files through such filesystems will
92489 + lose the extended attributes and these PaX markings.
92490 +
92491 + Note that if you enable the legacy EI_PAX marking support as well,
92492 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92493 +
92494 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92495 + must make sure that the marks are the same if a binary has both marks.
92496 +
92497 + If you enable none of the marking options then all applications
92498 + will run with PaX enabled on them by default.
92499 +
92500 +choice
92501 + prompt 'MAC system integration'
92502 + default PAX_HAVE_ACL_FLAGS
92503 + help
92504 + Mandatory Access Control systems have the option of controlling
92505 + PaX flags on a per executable basis, choose the method supported
92506 + by your particular system.
92507 +
92508 + - "none": if your MAC system does not interact with PaX,
92509 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92510 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92511 +
92512 + NOTE: this option is for developers/integrators only.
92513 +
92514 + config PAX_NO_ACL_FLAGS
92515 + bool 'none'
92516 +
92517 + config PAX_HAVE_ACL_FLAGS
92518 + bool 'direct'
92519 +
92520 + config PAX_HOOK_ACL_FLAGS
92521 + bool 'hook'
92522 +endchoice
92523 +
92524 +endmenu
92525 +
92526 +menu "Non-executable pages"
92527 + depends on PAX
92528 +
92529 +config PAX_NOEXEC
92530 + bool "Enforce non-executable pages"
92531 + default y if GRKERNSEC_CONFIG_AUTO
92532 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92533 + help
92534 + By design some architectures do not allow for protecting memory
92535 + pages against execution or even if they do, Linux does not make
92536 + use of this feature. In practice this means that if a page is
92537 + readable (such as the stack or heap) it is also executable.
92538 +
92539 + There is a well known exploit technique that makes use of this
92540 + fact and a common programming mistake where an attacker can
92541 + introduce code of his choice somewhere in the attacked program's
92542 + memory (typically the stack or the heap) and then execute it.
92543 +
92544 + If the attacked program was running with different (typically
92545 + higher) privileges than that of the attacker, then he can elevate
92546 + his own privilege level (e.g. get a root shell, write to files for
92547 + which he does not have write access to, etc).
92548 +
92549 + Enabling this option will let you choose from various features
92550 + that prevent the injection and execution of 'foreign' code in
92551 + a program.
92552 +
92553 + This will also break programs that rely on the old behaviour and
92554 + expect that dynamically allocated memory via the malloc() family
92555 + of functions is executable (which it is not). Notable examples
92556 + are the XFree86 4.x server, the java runtime and wine.
92557 +
92558 +config PAX_PAGEEXEC
92559 + bool "Paging based non-executable pages"
92560 + default y if GRKERNSEC_CONFIG_AUTO
92561 + 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)
92562 + select S390_SWITCH_AMODE if S390
92563 + select S390_EXEC_PROTECT if S390
92564 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92565 + help
92566 + This implementation is based on the paging feature of the CPU.
92567 + On i386 without hardware non-executable bit support there is a
92568 + variable but usually low performance impact, however on Intel's
92569 + P4 core based CPUs it is very high so you should not enable this
92570 + for kernels meant to be used on such CPUs.
92571 +
92572 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92573 + with hardware non-executable bit support there is no performance
92574 + impact, on ppc the impact is negligible.
92575 +
92576 + Note that several architectures require various emulations due to
92577 + badly designed userland ABIs, this will cause a performance impact
92578 + but will disappear as soon as userland is fixed. For example, ppc
92579 + userland MUST have been built with secure-plt by a recent toolchain.
92580 +
92581 +config PAX_SEGMEXEC
92582 + bool "Segmentation based non-executable pages"
92583 + default y if GRKERNSEC_CONFIG_AUTO
92584 + depends on PAX_NOEXEC && X86_32
92585 + help
92586 + This implementation is based on the segmentation feature of the
92587 + CPU and has a very small performance impact, however applications
92588 + will be limited to a 1.5 GB address space instead of the normal
92589 + 3 GB.
92590 +
92591 +config PAX_EMUTRAMP
92592 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92593 + default y if PARISC
92594 + help
92595 + There are some programs and libraries that for one reason or
92596 + another attempt to execute special small code snippets from
92597 + non-executable memory pages. Most notable examples are the
92598 + signal handler return code generated by the kernel itself and
92599 + the GCC trampolines.
92600 +
92601 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92602 + such programs will no longer work under your kernel.
92603 +
92604 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92605 + utilities to enable trampoline emulation for the affected programs
92606 + yet still have the protection provided by the non-executable pages.
92607 +
92608 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92609 + your system will not even boot.
92610 +
92611 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92612 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92613 + for the affected files.
92614 +
92615 + NOTE: enabling this feature *may* open up a loophole in the
92616 + protection provided by non-executable pages that an attacker
92617 + could abuse. Therefore the best solution is to not have any
92618 + files on your system that would require this option. This can
92619 + be achieved by not using libc5 (which relies on the kernel
92620 + signal handler return code) and not using or rewriting programs
92621 + that make use of the nested function implementation of GCC.
92622 + Skilled users can just fix GCC itself so that it implements
92623 + nested function calls in a way that does not interfere with PaX.
92624 +
92625 +config PAX_EMUSIGRT
92626 + bool "Automatically emulate sigreturn trampolines"
92627 + depends on PAX_EMUTRAMP && PARISC
92628 + default y
92629 + help
92630 + Enabling this option will have the kernel automatically detect
92631 + and emulate signal return trampolines executing on the stack
92632 + that would otherwise lead to task termination.
92633 +
92634 + This solution is intended as a temporary one for users with
92635 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92636 + Modula-3 runtime, etc) or executables linked to such, basically
92637 + everything that does not specify its own SA_RESTORER function in
92638 + normal executable memory like glibc 2.1+ does.
92639 +
92640 + On parisc you MUST enable this option, otherwise your system will
92641 + not even boot.
92642 +
92643 + NOTE: this feature cannot be disabled on a per executable basis
92644 + and since it *does* open up a loophole in the protection provided
92645 + by non-executable pages, the best solution is to not have any
92646 + files on your system that would require this option.
92647 +
92648 +config PAX_MPROTECT
92649 + bool "Restrict mprotect()"
92650 + default y if GRKERNSEC_CONFIG_AUTO
92651 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92652 + help
92653 + Enabling this option will prevent programs from
92654 + - changing the executable status of memory pages that were
92655 + not originally created as executable,
92656 + - making read-only executable pages writable again,
92657 + - creating executable pages from anonymous memory,
92658 + - making read-only-after-relocations (RELRO) data pages writable again.
92659 +
92660 + You should say Y here to complete the protection provided by
92661 + the enforcement of non-executable pages.
92662 +
92663 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92664 + this feature on a per file basis.
92665 +
92666 +config PAX_MPROTECT_COMPAT
92667 + bool "Use legacy/compat protection demoting (read help)"
92668 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92669 + depends on PAX_MPROTECT
92670 + help
92671 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92672 + by sending the proper error code to the application. For some broken
92673 + userland, this can cause problems with Python or other applications. The
92674 + current implementation however allows for applications like clamav to
92675 + detect if JIT compilation/execution is allowed and to fall back gracefully
92676 + to an interpreter-based mode if it does not. While we encourage everyone
92677 + to use the current implementation as-is and push upstream to fix broken
92678 + userland (note that the RWX logging option can assist with this), in some
92679 + environments this may not be possible. Having to disable MPROTECT
92680 + completely on certain binaries reduces the security benefit of PaX,
92681 + so this option is provided for those environments to revert to the old
92682 + behavior.
92683 +
92684 +config PAX_ELFRELOCS
92685 + bool "Allow ELF text relocations (read help)"
92686 + depends on PAX_MPROTECT
92687 + default n
92688 + help
92689 + Non-executable pages and mprotect() restrictions are effective
92690 + in preventing the introduction of new executable code into an
92691 + attacked task's address space. There remain only two venues
92692 + for this kind of attack: if the attacker can execute already
92693 + existing code in the attacked task then he can either have it
92694 + create and mmap() a file containing his code or have it mmap()
92695 + an already existing ELF library that does not have position
92696 + independent code in it and use mprotect() on it to make it
92697 + writable and copy his code there. While protecting against
92698 + the former approach is beyond PaX, the latter can be prevented
92699 + by having only PIC ELF libraries on one's system (which do not
92700 + need to relocate their code). If you are sure this is your case,
92701 + as is the case with all modern Linux distributions, then leave
92702 + this option disabled. You should say 'n' here.
92703 +
92704 +config PAX_ETEXECRELOCS
92705 + bool "Allow ELF ET_EXEC text relocations"
92706 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92707 + select PAX_ELFRELOCS
92708 + default y
92709 + help
92710 + On some architectures there are incorrectly created applications
92711 + that require text relocations and would not work without enabling
92712 + this option. If you are an alpha, ia64 or parisc user, you should
92713 + enable this option and disable it once you have made sure that
92714 + none of your applications need it.
92715 +
92716 +config PAX_EMUPLT
92717 + bool "Automatically emulate ELF PLT"
92718 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92719 + default y
92720 + help
92721 + Enabling this option will have the kernel automatically detect
92722 + and emulate the Procedure Linkage Table entries in ELF files.
92723 + On some architectures such entries are in writable memory, and
92724 + become non-executable leading to task termination. Therefore
92725 + it is mandatory that you enable this option on alpha, parisc,
92726 + sparc and sparc64, otherwise your system would not even boot.
92727 +
92728 + NOTE: this feature *does* open up a loophole in the protection
92729 + provided by the non-executable pages, therefore the proper
92730 + solution is to modify the toolchain to produce a PLT that does
92731 + not need to be writable.
92732 +
92733 +config PAX_DLRESOLVE
92734 + bool 'Emulate old glibc resolver stub'
92735 + depends on PAX_EMUPLT && SPARC
92736 + default n
92737 + help
92738 + This option is needed if userland has an old glibc (before 2.4)
92739 + that puts a 'save' instruction into the runtime generated resolver
92740 + stub that needs special emulation.
92741 +
92742 +config PAX_KERNEXEC
92743 + bool "Enforce non-executable kernel pages"
92744 + 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))
92745 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92746 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92747 + select PAX_KERNEXEC_PLUGIN if X86_64
92748 + help
92749 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92750 + that is, enabling this option will make it harder to inject
92751 + and execute 'foreign' code in kernel memory itself.
92752 +
92753 +choice
92754 + prompt "Return Address Instrumentation Method"
92755 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92756 + depends on PAX_KERNEXEC_PLUGIN
92757 + help
92758 + Select the method used to instrument function pointer dereferences.
92759 + Note that binary modules cannot be instrumented by this approach.
92760 +
92761 + Note that the implementation requires a gcc with plugin support,
92762 + i.e., gcc 4.5 or newer. You may need to install the supporting
92763 + headers explicitly in addition to the normal gcc package.
92764 +
92765 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92766 + bool "bts"
92767 + help
92768 + This method is compatible with binary only modules but has
92769 + a higher runtime overhead.
92770 +
92771 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92772 + bool "or"
92773 + depends on !PARAVIRT
92774 + help
92775 + This method is incompatible with binary only modules but has
92776 + a lower runtime overhead.
92777 +endchoice
92778 +
92779 +config PAX_KERNEXEC_PLUGIN_METHOD
92780 + string
92781 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92782 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92783 + default ""
92784 +
92785 +config PAX_KERNEXEC_MODULE_TEXT
92786 + int "Minimum amount of memory reserved for module code"
92787 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92788 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92789 + depends on PAX_KERNEXEC && X86_32
92790 + help
92791 + Due to implementation details the kernel must reserve a fixed
92792 + amount of memory for runtime allocated code (such as modules)
92793 + at compile time that cannot be changed at runtime. Here you
92794 + can specify the minimum amount in MB that will be reserved.
92795 + Due to the same implementation details this size will always
92796 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
92797 + the actually available memory for runtime allocated code will
92798 + usually be more than this minimum.
92799 +
92800 + The default 4 MB should be enough for most users but if you have
92801 + an excessive number of modules (e.g., most distribution configs
92802 + compile many drivers as modules) or use huge modules such as
92803 + nvidia's kernel driver, you will need to adjust this amount.
92804 + A good rule of thumb is to look at your currently loaded kernel
92805 + modules and add up their sizes.
92806 +
92807 +endmenu
92808 +
92809 +menu "Address Space Layout Randomization"
92810 + depends on PAX
92811 +
92812 +config PAX_ASLR
92813 + bool "Address Space Layout Randomization"
92814 + default y if GRKERNSEC_CONFIG_AUTO
92815 + help
92816 + Many if not most exploit techniques rely on the knowledge of
92817 + certain addresses in the attacked program. The following options
92818 + will allow the kernel to apply a certain amount of randomization
92819 + to specific parts of the program thereby forcing an attacker to
92820 + guess them in most cases. Any failed guess will most likely crash
92821 + the attacked program which allows the kernel to detect such attempts
92822 + and react on them. PaX itself provides no reaction mechanisms,
92823 + instead it is strongly encouraged that you make use of Nergal's
92824 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92825 + (http://www.grsecurity.net/) built-in crash detection features or
92826 + develop one yourself.
92827 +
92828 + By saying Y here you can choose to randomize the following areas:
92829 + - top of the task's kernel stack
92830 + - top of the task's userland stack
92831 + - base address for mmap() requests that do not specify one
92832 + (this includes all libraries)
92833 + - base address of the main executable
92834 +
92835 + It is strongly recommended to say Y here as address space layout
92836 + randomization has negligible impact on performance yet it provides
92837 + a very effective protection.
92838 +
92839 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92840 + this feature on a per file basis.
92841 +
92842 +config PAX_RANDKSTACK
92843 + bool "Randomize kernel stack base"
92844 + default y if GRKERNSEC_CONFIG_AUTO
92845 + depends on X86_TSC && X86
92846 + help
92847 + By saying Y here the kernel will randomize every task's kernel
92848 + stack on every system call. This will not only force an attacker
92849 + to guess it but also prevent him from making use of possible
92850 + leaked information about it.
92851 +
92852 + Since the kernel stack is a rather scarce resource, randomization
92853 + may cause unexpected stack overflows, therefore you should very
92854 + carefully test your system. Note that once enabled in the kernel
92855 + configuration, this feature cannot be disabled on a per file basis.
92856 +
92857 +config PAX_RANDUSTACK
92858 + bool "Randomize user stack base"
92859 + default y if GRKERNSEC_CONFIG_AUTO
92860 + depends on PAX_ASLR
92861 + help
92862 + By saying Y here the kernel will randomize every task's userland
92863 + stack. The randomization is done in two steps where the second
92864 + one may apply a big amount of shift to the top of the stack and
92865 + cause problems for programs that want to use lots of memory (more
92866 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92867 + For this reason the second step can be controlled by 'chpax' or
92868 + 'paxctl' on a per file basis.
92869 +
92870 +config PAX_RANDMMAP
92871 + bool "Randomize mmap() base"
92872 + default y if GRKERNSEC_CONFIG_AUTO
92873 + depends on PAX_ASLR
92874 + help
92875 + By saying Y here the kernel will use a randomized base address for
92876 + mmap() requests that do not specify one themselves. As a result
92877 + all dynamically loaded libraries will appear at random addresses
92878 + and therefore be harder to exploit by a technique where an attacker
92879 + attempts to execute library code for his purposes (e.g. spawn a
92880 + shell from an exploited program that is running at an elevated
92881 + privilege level).
92882 +
92883 + Furthermore, if a program is relinked as a dynamic ELF file, its
92884 + base address will be randomized as well, completing the full
92885 + randomization of the address space layout. Attacking such programs
92886 + becomes a guess game. You can find an example of doing this at
92887 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92888 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92889 +
92890 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92891 + feature on a per file basis.
92892 +
92893 +endmenu
92894 +
92895 +menu "Miscellaneous hardening features"
92896 +
92897 +config PAX_MEMORY_SANITIZE
92898 + bool "Sanitize all freed memory"
92899 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92900 + depends on !HIBERNATION
92901 + help
92902 + By saying Y here the kernel will erase memory pages as soon as they
92903 + are freed. This in turn reduces the lifetime of data stored in the
92904 + pages, making it less likely that sensitive information such as
92905 + passwords, cryptographic secrets, etc stay in memory for too long.
92906 +
92907 + This is especially useful for programs whose runtime is short, long
92908 + lived processes and the kernel itself benefit from this as long as
92909 + they operate on whole memory pages and ensure timely freeing of pages
92910 + that may hold sensitive information.
92911 +
92912 + The tradeoff is performance impact, on a single CPU system kernel
92913 + compilation sees a 3% slowdown, other systems and workloads may vary
92914 + and you are advised to test this feature on your expected workload
92915 + before deploying it.
92916 +
92917 + Note that this feature does not protect data stored in live pages,
92918 + e.g., process memory swapped to disk may stay there for a long time.
92919 +
92920 +config PAX_MEMORY_STACKLEAK
92921 + bool "Sanitize kernel stack"
92922 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92923 + depends on X86
92924 + help
92925 + By saying Y here the kernel will erase the kernel stack before it
92926 + returns from a system call. This in turn reduces the information
92927 + that a kernel stack leak bug can reveal.
92928 +
92929 + Note that such a bug can still leak information that was put on
92930 + the stack by the current system call (the one eventually triggering
92931 + the bug) but traces of earlier system calls on the kernel stack
92932 + cannot leak anymore.
92933 +
92934 + The tradeoff is performance impact: on a single CPU system kernel
92935 + compilation sees a 1% slowdown, other systems and workloads may vary
92936 + and you are advised to test this feature on your expected workload
92937 + before deploying it.
92938 +
92939 + Note that the full feature requires a gcc with plugin support,
92940 + i.e., gcc 4.5 or newer. You may need to install the supporting
92941 + headers explicitly in addition to the normal gcc package. Using
92942 + older gcc versions means that functions with large enough stack
92943 + frames may leave uninitialized memory behind that may be exposed
92944 + to a later syscall leaking the stack.
92945 +
92946 +config PAX_MEMORY_STRUCTLEAK
92947 + bool "Forcibly initialize local variables copied to userland"
92948 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92949 + help
92950 + By saying Y here the kernel will zero initialize some local
92951 + variables that are going to be copied to userland. This in
92952 + turn prevents unintended information leakage from the kernel
92953 + stack should later code forget to explicitly set all parts of
92954 + the copied variable.
92955 +
92956 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92957 + at a much smaller coverage.
92958 +
92959 + Note that the implementation requires a gcc with plugin support,
92960 + i.e., gcc 4.5 or newer. You may need to install the supporting
92961 + headers explicitly in addition to the normal gcc package.
92962 +
92963 +config PAX_MEMORY_UDEREF
92964 + bool "Prevent invalid userland pointer dereference"
92965 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92966 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92967 + select PAX_PER_CPU_PGD if X86_64
92968 + help
92969 + By saying Y here the kernel will be prevented from dereferencing
92970 + userland pointers in contexts where the kernel expects only kernel
92971 + pointers. This is both a useful runtime debugging feature and a
92972 + security measure that prevents exploiting a class of kernel bugs.
92973 +
92974 + The tradeoff is that some virtualization solutions may experience
92975 + a huge slowdown and therefore you should not enable this feature
92976 + for kernels meant to run in such environments. Whether a given VM
92977 + solution is affected or not is best determined by simply trying it
92978 + out, the performance impact will be obvious right on boot as this
92979 + mechanism engages from very early on. A good rule of thumb is that
92980 + VMs running on CPUs without hardware virtualization support (i.e.,
92981 + the majority of IA-32 CPUs) will likely experience the slowdown.
92982 +
92983 +config PAX_REFCOUNT
92984 + bool "Prevent various kernel object reference counter overflows"
92985 + default y if GRKERNSEC_CONFIG_AUTO
92986 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92987 + help
92988 + By saying Y here the kernel will detect and prevent overflowing
92989 + various (but not all) kinds of object reference counters. Such
92990 + overflows can normally occur due to bugs only and are often, if
92991 + not always, exploitable.
92992 +
92993 + The tradeoff is that data structures protected by an overflowed
92994 + refcount will never be freed and therefore will leak memory. Note
92995 + that this leak also happens even without this protection but in
92996 + that case the overflow can eventually trigger the freeing of the
92997 + data structure while it is still being used elsewhere, resulting
92998 + in the exploitable situation that this feature prevents.
92999 +
93000 + Since this has a negligible performance impact, you should enable
93001 + this feature.
93002 +
93003 +config PAX_CONSTIFY_PLUGIN
93004 + bool "Automatically constify eligible structures"
93005 + default y
93006 + depends on !UML && PAX_KERNEXEC
93007 + help
93008 + By saying Y here the compiler will automatically constify a class
93009 + of types that contain only function pointers. This reduces the
93010 + kernel's attack surface and also produces a better memory layout.
93011 +
93012 + Note that the implementation requires a gcc with plugin support,
93013 + i.e., gcc 4.5 or newer. You may need to install the supporting
93014 + headers explicitly in addition to the normal gcc package.
93015 +
93016 + Note that if some code really has to modify constified variables
93017 + then the source code will have to be patched to allow it. Examples
93018 + can be found in PaX itself (the no_const attribute) and for some
93019 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
93020 +
93021 +config PAX_USERCOPY
93022 + bool "Harden heap object copies between kernel and userland"
93023 + default y if GRKERNSEC_CONFIG_AUTO
93024 + depends on ARM || IA64 || PPC || SPARC || X86
93025 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
93026 + select PAX_USERCOPY_SLABS
93027 + help
93028 + By saying Y here the kernel will enforce the size of heap objects
93029 + when they are copied in either direction between the kernel and
93030 + userland, even if only a part of the heap object is copied.
93031 +
93032 + Specifically, this checking prevents information leaking from the
93033 + kernel heap during kernel to userland copies (if the kernel heap
93034 + object is otherwise fully initialized) and prevents kernel heap
93035 + overflows during userland to kernel copies.
93036 +
93037 + Note that the current implementation provides the strictest bounds
93038 + checks for the SLUB allocator.
93039 +
93040 + Enabling this option also enables per-slab cache protection against
93041 + data in a given cache being copied into/out of via userland
93042 + accessors. Though the whitelist of regions will be reduced over
93043 + time, it notably protects important data structures like task structs.
93044 +
93045 + If frame pointers are enabled on x86, this option will also restrict
93046 + copies into and out of the kernel stack to local variables within a
93047 + single frame.
93048 +
93049 + Since this has a negligible performance impact, you should enable
93050 + this feature.
93051 +
93052 +config PAX_USERCOPY_DEBUG
93053 + bool
93054 + depends on X86 && PAX_USERCOPY
93055 + default n
93056 +
93057 +config PAX_SIZE_OVERFLOW
93058 + bool "Prevent various integer overflows in function size parameters"
93059 + default y if GRKERNSEC_CONFIG_AUTO
93060 + depends on X86
93061 + help
93062 + By saying Y here the kernel recomputes expressions of function
93063 + arguments marked by a size_overflow attribute with double integer
93064 + precision (DImode/TImode for 32/64 bit integer types).
93065 +
93066 + The recomputed argument is checked against TYPE_MAX and an event
93067 + is logged on overflow and the triggering process is killed.
93068 +
93069 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
93070 +
93071 + Note that the implementation requires a gcc with plugin support,
93072 + i.e., gcc 4.5 or newer. You may need to install the supporting
93073 + headers explicitly in addition to the normal gcc package.
93074 +
93075 +config PAX_LATENT_ENTROPY
93076 + bool "Generate some entropy during boot"
93077 + default y if GRKERNSEC_CONFIG_AUTO
93078 + help
93079 + By saying Y here the kernel will instrument early boot code to
93080 + extract some entropy from both original and artificially created
93081 + program state. This will help especially embedded systems where
93082 + there is little 'natural' source of entropy normally. The cost
93083 + is some slowdown of the boot process.
93084 +
93085 + When pax_extra_latent_entropy is passed on the kernel command line,
93086 + entropy will be extracted from up to the first 4GB of RAM while the
93087 + runtime memory allocator is being initialized. This costs even more
93088 + slowdown of the boot process.
93089 +
93090 + Note that the implementation requires a gcc with plugin support,
93091 + i.e., gcc 4.5 or newer. You may need to install the supporting
93092 + headers explicitly in addition to the normal gcc package.
93093 +
93094 + Note that entropy extracted this way is not cryptographically
93095 + secure!
93096 +
93097 +endmenu
93098 +
93099 +endmenu
93100 +
93101 +source grsecurity/Kconfig
93102 +
93103 +endmenu
93104 +
93105 +endmenu
93106 +
93107 source security/keys/Kconfig
93108
93109 config SECURITY_DMESG_RESTRICT
93110 @@ -103,7 +1042,7 @@ config INTEL_TXT
93111 config LSM_MMAP_MIN_ADDR
93112 int "Low address space for LSM to protect from user allocation"
93113 depends on SECURITY && SECURITY_SELINUX
93114 - default 32768 if ARM
93115 + default 32768 if ALPHA || ARM || PARISC || SPARC32
93116 default 65536
93117 help
93118 This is the portion of low virtual memory which should be protected
93119 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
93120 index 9b9013b..51ebf96 100644
93121 --- a/security/apparmor/Kconfig
93122 +++ b/security/apparmor/Kconfig
93123 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
93124 boot.
93125
93126 If you are unsure how to answer this question, answer 1.
93127 +
93128 +config SECURITY_APPARMOR_COMPAT_24
93129 + bool "Enable AppArmor 2.4 compatability"
93130 + depends on SECURITY_APPARMOR
93131 + default y
93132 + help
93133 + This option enables compatability with AppArmor 2.4. It is
93134 + recommended if compatability with older versions of AppArmor
93135 + is desired.
93136 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
93137 index 16c15ec..42b7c9f 100644
93138 --- a/security/apparmor/apparmorfs.c
93139 +++ b/security/apparmor/apparmorfs.c
93140 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
93141 .release = single_release,
93142 };
93143
93144 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93145 +/**
93146 + * __next_namespace - find the next namespace to list
93147 + * @root: root namespace to stop search at (NOT NULL)
93148 + * @ns: current ns position (NOT NULL)
93149 + *
93150 + * Find the next namespace from @ns under @root and handle all locking needed
93151 + * while switching current namespace.
93152 + *
93153 + * Returns: next namespace or NULL if at last namespace under @root
93154 + * NOTE: will not unlock root->lock
93155 + */
93156 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
93157 + struct aa_namespace *ns)
93158 +{
93159 + struct aa_namespace *parent;
93160 +
93161 + /* is next namespace a child */
93162 + if (!list_empty(&ns->sub_ns)) {
93163 + struct aa_namespace *next;
93164 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
93165 + read_lock(&next->lock);
93166 + return next;
93167 + }
93168 +
93169 + /* check if the next ns is a sibling, parent, gp, .. */
93170 + parent = ns->parent;
93171 + while (parent) {
93172 + read_unlock(&ns->lock);
93173 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
93174 + read_lock(&ns->lock);
93175 + return ns;
93176 + }
93177 + if (parent == root)
93178 + return NULL;
93179 + ns = parent;
93180 + parent = parent->parent;
93181 + }
93182 +
93183 + return NULL;
93184 +}
93185 +
93186 +/**
93187 + * __first_profile - find the first profile in a namespace
93188 + * @root: namespace that is root of profiles being displayed (NOT NULL)
93189 + * @ns: namespace to start in (NOT NULL)
93190 + *
93191 + * Returns: unrefcounted profile or NULL if no profile
93192 + */
93193 +static struct aa_profile *__first_profile(struct aa_namespace *root,
93194 + struct aa_namespace *ns)
93195 +{
93196 + for ( ; ns; ns = __next_namespace(root, ns)) {
93197 + if (!list_empty(&ns->base.profiles))
93198 + return list_first_entry(&ns->base.profiles,
93199 + struct aa_profile, base.list);
93200 + }
93201 + return NULL;
93202 +}
93203 +
93204 +/**
93205 + * __next_profile - step to the next profile in a profile tree
93206 + * @profile: current profile in tree (NOT NULL)
93207 + *
93208 + * Perform a depth first taversal on the profile tree in a namespace
93209 + *
93210 + * Returns: next profile or NULL if done
93211 + * Requires: profile->ns.lock to be held
93212 + */
93213 +static struct aa_profile *__next_profile(struct aa_profile *p)
93214 +{
93215 + struct aa_profile *parent;
93216 + struct aa_namespace *ns = p->ns;
93217 +
93218 + /* is next profile a child */
93219 + if (!list_empty(&p->base.profiles))
93220 + return list_first_entry(&p->base.profiles, typeof(*p),
93221 + base.list);
93222 +
93223 + /* is next profile a sibling, parent sibling, gp, subling, .. */
93224 + parent = p->parent;
93225 + while (parent) {
93226 + list_for_each_entry_continue(p, &parent->base.profiles,
93227 + base.list)
93228 + return p;
93229 + p = parent;
93230 + parent = parent->parent;
93231 + }
93232 +
93233 + /* is next another profile in the namespace */
93234 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
93235 + return p;
93236 +
93237 + return NULL;
93238 +}
93239 +
93240 +/**
93241 + * next_profile - step to the next profile in where ever it may be
93242 + * @root: root namespace (NOT NULL)
93243 + * @profile: current profile (NOT NULL)
93244 + *
93245 + * Returns: next profile or NULL if there isn't one
93246 + */
93247 +static struct aa_profile *next_profile(struct aa_namespace *root,
93248 + struct aa_profile *profile)
93249 +{
93250 + struct aa_profile *next = __next_profile(profile);
93251 + if (next)
93252 + return next;
93253 +
93254 + /* finished all profiles in namespace move to next namespace */
93255 + return __first_profile(root, __next_namespace(root, profile->ns));
93256 +}
93257 +
93258 +/**
93259 + * p_start - start a depth first traversal of profile tree
93260 + * @f: seq_file to fill
93261 + * @pos: current position
93262 + *
93263 + * Returns: first profile under current namespace or NULL if none found
93264 + *
93265 + * acquires first ns->lock
93266 + */
93267 +static void *p_start(struct seq_file *f, loff_t *pos)
93268 + __acquires(root->lock)
93269 +{
93270 + struct aa_profile *profile = NULL;
93271 + struct aa_namespace *root = aa_current_profile()->ns;
93272 + loff_t l = *pos;
93273 + f->private = aa_get_namespace(root);
93274 +
93275 +
93276 + /* find the first profile */
93277 + read_lock(&root->lock);
93278 + profile = __first_profile(root, root);
93279 +
93280 + /* skip to position */
93281 + for (; profile && l > 0; l--)
93282 + profile = next_profile(root, profile);
93283 +
93284 + return profile;
93285 +}
93286 +
93287 +/**
93288 + * p_next - read the next profile entry
93289 + * @f: seq_file to fill
93290 + * @p: profile previously returned
93291 + * @pos: current position
93292 + *
93293 + * Returns: next profile after @p or NULL if none
93294 + *
93295 + * may acquire/release locks in namespace tree as necessary
93296 + */
93297 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
93298 +{
93299 + struct aa_profile *profile = p;
93300 + struct aa_namespace *root = f->private;
93301 + (*pos)++;
93302 +
93303 + return next_profile(root, profile);
93304 +}
93305 +
93306 +/**
93307 + * p_stop - stop depth first traversal
93308 + * @f: seq_file we are filling
93309 + * @p: the last profile writen
93310 + *
93311 + * Release all locking done by p_start/p_next on namespace tree
93312 + */
93313 +static void p_stop(struct seq_file *f, void *p)
93314 + __releases(root->lock)
93315 +{
93316 + struct aa_profile *profile = p;
93317 + struct aa_namespace *root = f->private, *ns;
93318 +
93319 + if (profile) {
93320 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
93321 + read_unlock(&ns->lock);
93322 + }
93323 + read_unlock(&root->lock);
93324 + aa_put_namespace(root);
93325 +}
93326 +
93327 +/**
93328 + * seq_show_profile - show a profile entry
93329 + * @f: seq_file to file
93330 + * @p: current position (profile) (NOT NULL)
93331 + *
93332 + * Returns: error on failure
93333 + */
93334 +static int seq_show_profile(struct seq_file *f, void *p)
93335 +{
93336 + struct aa_profile *profile = (struct aa_profile *)p;
93337 + struct aa_namespace *root = f->private;
93338 +
93339 + if (profile->ns != root)
93340 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
93341 + seq_printf(f, "%s (%s)\n", profile->base.hname,
93342 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
93343 +
93344 + return 0;
93345 +}
93346 +
93347 +static const struct seq_operations aa_fs_profiles_op = {
93348 + .start = p_start,
93349 + .next = p_next,
93350 + .stop = p_stop,
93351 + .show = seq_show_profile,
93352 +};
93353 +
93354 +static int profiles_open(struct inode *inode, struct file *file)
93355 +{
93356 + return seq_open(file, &aa_fs_profiles_op);
93357 +}
93358 +
93359 +static int profiles_release(struct inode *inode, struct file *file)
93360 +{
93361 + return seq_release(inode, file);
93362 +}
93363 +
93364 +const struct file_operations aa_fs_profiles_fops = {
93365 + .open = profiles_open,
93366 + .read = seq_read,
93367 + .llseek = seq_lseek,
93368 + .release = profiles_release,
93369 +};
93370 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
93371 +
93372 /** Base file system setup **/
93373
93374 static struct aa_fs_entry aa_fs_entry_file[] = {
93375 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
93376 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
93377 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
93378 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
93379 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93380 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
93381 +#endif
93382 AA_FS_DIR("features", aa_fs_entry_features),
93383 { }
93384 };
93385 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
93386 index b21830e..a7d1a17 100644
93387 --- a/security/apparmor/lsm.c
93388 +++ b/security/apparmor/lsm.c
93389 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
93390 return error;
93391 }
93392
93393 -static struct security_operations apparmor_ops = {
93394 +static struct security_operations apparmor_ops __read_only = {
93395 .name = "apparmor",
93396
93397 .ptrace_access_check = apparmor_ptrace_access_check,
93398 diff --git a/security/commoncap.c b/security/commoncap.c
93399 index c44b6fe..932df30 100644
93400 --- a/security/commoncap.c
93401 +++ b/security/commoncap.c
93402 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
93403 return 0;
93404 }
93405
93406 +/* returns:
93407 + 1 for suid privilege
93408 + 2 for sgid privilege
93409 + 3 for fscap privilege
93410 +*/
93411 +int is_privileged_binary(const struct dentry *dentry)
93412 +{
93413 + struct cpu_vfs_cap_data capdata;
93414 + struct inode *inode = dentry->d_inode;
93415 +
93416 + if (!inode || S_ISDIR(inode->i_mode))
93417 + return 0;
93418 +
93419 + if (inode->i_mode & S_ISUID)
93420 + return 1;
93421 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
93422 + return 2;
93423 +
93424 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
93425 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
93426 + return 3;
93427 + }
93428 +
93429 + return 0;
93430 +}
93431 +
93432 /*
93433 * Attempt to get the on-exec apply capability sets for an executable file from
93434 * its xattrs and, if present, apply them to the proposed credentials being
93435 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
93436 const struct cred *cred = current_cred();
93437 kuid_t root_uid = make_kuid(cred->user_ns, 0);
93438
93439 + if (gr_acl_enable_at_secure())
93440 + return 1;
93441 +
93442 if (!uid_eq(cred->uid, root_uid)) {
93443 if (bprm->cap_effective)
93444 return 1;
93445 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93446 index a41c9c1..83da6dd 100644
93447 --- a/security/integrity/ima/ima.h
93448 +++ b/security/integrity/ima/ima.h
93449 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
93450 extern spinlock_t ima_queue_lock;
93451
93452 struct ima_h_table {
93453 - atomic_long_t len; /* number of stored measurements in the list */
93454 - atomic_long_t violations;
93455 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93456 + atomic_long_unchecked_t violations;
93457 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93458 };
93459 extern struct ima_h_table ima_htable;
93460 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93461 index 1c03e8f1..398a941 100644
93462 --- a/security/integrity/ima/ima_api.c
93463 +++ b/security/integrity/ima/ima_api.c
93464 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93465 int result;
93466
93467 /* can overflow, only indicator */
93468 - atomic_long_inc(&ima_htable.violations);
93469 + atomic_long_inc_unchecked(&ima_htable.violations);
93470
93471 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93472 if (!entry) {
93473 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93474 index 38477c9..87a60c7 100644
93475 --- a/security/integrity/ima/ima_fs.c
93476 +++ b/security/integrity/ima/ima_fs.c
93477 @@ -28,12 +28,12 @@
93478 static int valid_policy = 1;
93479 #define TMPBUFLEN 12
93480 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93481 - loff_t *ppos, atomic_long_t *val)
93482 + loff_t *ppos, atomic_long_unchecked_t *val)
93483 {
93484 char tmpbuf[TMPBUFLEN];
93485 ssize_t len;
93486
93487 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93488 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93489 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93490 }
93491
93492 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93493 index ff63fe0..809cd96 100644
93494 --- a/security/integrity/ima/ima_queue.c
93495 +++ b/security/integrity/ima/ima_queue.c
93496 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93497 INIT_LIST_HEAD(&qe->later);
93498 list_add_tail_rcu(&qe->later, &ima_measurements);
93499
93500 - atomic_long_inc(&ima_htable.len);
93501 + atomic_long_inc_unchecked(&ima_htable.len);
93502 key = ima_hash_key(entry->digest);
93503 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93504 return 0;
93505 diff --git a/security/keys/compat.c b/security/keys/compat.c
93506 index d65fa7f..cbfe366 100644
93507 --- a/security/keys/compat.c
93508 +++ b/security/keys/compat.c
93509 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93510 if (ret == 0)
93511 goto no_payload_free;
93512
93513 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93514 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93515 err:
93516 if (iov != iovstack)
93517 kfree(iov);
93518 diff --git a/security/keys/internal.h b/security/keys/internal.h
93519 index d4f1468..cc52f92 100644
93520 --- a/security/keys/internal.h
93521 +++ b/security/keys/internal.h
93522 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
93523 extern long keyctl_invalidate_key(key_serial_t);
93524
93525 extern long keyctl_instantiate_key_common(key_serial_t,
93526 - const struct iovec *,
93527 + const struct iovec __user *,
93528 unsigned, size_t, key_serial_t);
93529
93530 /*
93531 diff --git a/security/keys/key.c b/security/keys/key.c
93532 index 8fb7c7b..ba3610d 100644
93533 --- a/security/keys/key.c
93534 +++ b/security/keys/key.c
93535 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93536
93537 atomic_set(&key->usage, 1);
93538 init_rwsem(&key->sem);
93539 - lockdep_set_class(&key->sem, &type->lock_class);
93540 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93541 key->type = type;
93542 key->user = user;
93543 key->quotalen = quotalen;
93544 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93545 struct key_type *p;
93546 int ret;
93547
93548 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93549 + pax_open_kernel();
93550 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93551 + pax_close_kernel();
93552
93553 ret = -EEXIST;
93554 down_write(&key_types_sem);
93555 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93556 }
93557
93558 /* store the type */
93559 - list_add(&ktype->link, &key_types_list);
93560 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93561
93562 pr_notice("Key type %s registered\n", ktype->name);
93563 ret = 0;
93564 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93565 void unregister_key_type(struct key_type *ktype)
93566 {
93567 down_write(&key_types_sem);
93568 - list_del_init(&ktype->link);
93569 + pax_list_del_init((struct list_head *)&ktype->link);
93570 downgrade_write(&key_types_sem);
93571 key_gc_keytype(ktype);
93572 pr_notice("Key type %s unregistered\n", ktype->name);
93573 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93574 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93575
93576 /* add the special key types */
93577 - list_add_tail(&key_type_keyring.link, &key_types_list);
93578 - list_add_tail(&key_type_dead.link, &key_types_list);
93579 - list_add_tail(&key_type_user.link, &key_types_list);
93580 - list_add_tail(&key_type_logon.link, &key_types_list);
93581 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93582 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93583 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93584 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93585
93586 /* record the root user tracking */
93587 rb_link_node(&root_key_user.node,
93588 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93589 index 33cfd27..842fc5a 100644
93590 --- a/security/keys/keyctl.c
93591 +++ b/security/keys/keyctl.c
93592 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93593 /*
93594 * Copy the iovec data from userspace
93595 */
93596 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93597 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93598 unsigned ioc)
93599 {
93600 for (; ioc > 0; ioc--) {
93601 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93602 * If successful, 0 will be returned.
93603 */
93604 long keyctl_instantiate_key_common(key_serial_t id,
93605 - const struct iovec *payload_iov,
93606 + const struct iovec __user *payload_iov,
93607 unsigned ioc,
93608 size_t plen,
93609 key_serial_t ringid)
93610 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
93611 [0].iov_len = plen
93612 };
93613
93614 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93615 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93616 }
93617
93618 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93619 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93620 if (ret == 0)
93621 goto no_payload_free;
93622
93623 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93624 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93625 err:
93626 if (iov != iovstack)
93627 kfree(iov);
93628 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93629 index 6ece7f2..ecdb55c 100644
93630 --- a/security/keys/keyring.c
93631 +++ b/security/keys/keyring.c
93632 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93633 ret = -EFAULT;
93634
93635 for (loop = 0; loop < klist->nkeys; loop++) {
93636 + key_serial_t serial;
93637 key = rcu_deref_link_locked(klist, loop,
93638 keyring);
93639 + serial = key->serial;
93640
93641 tmp = sizeof(key_serial_t);
93642 if (tmp > buflen)
93643 tmp = buflen;
93644
93645 - if (copy_to_user(buffer,
93646 - &key->serial,
93647 - tmp) != 0)
93648 + if (copy_to_user(buffer, &serial, tmp))
93649 goto error;
93650
93651 buflen -= tmp;
93652 diff --git a/security/min_addr.c b/security/min_addr.c
93653 index f728728..6457a0c 100644
93654 --- a/security/min_addr.c
93655 +++ b/security/min_addr.c
93656 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93657 */
93658 static void update_mmap_min_addr(void)
93659 {
93660 +#ifndef SPARC
93661 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93662 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93663 mmap_min_addr = dac_mmap_min_addr;
93664 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93665 #else
93666 mmap_min_addr = dac_mmap_min_addr;
93667 #endif
93668 +#endif
93669 }
93670
93671 /*
93672 diff --git a/security/security.c b/security/security.c
93673 index a3dce87..9ca1435 100644
93674 --- a/security/security.c
93675 +++ b/security/security.c
93676 @@ -20,6 +20,7 @@
93677 #include <linux/ima.h>
93678 #include <linux/evm.h>
93679 #include <linux/fsnotify.h>
93680 +#include <linux/mm.h>
93681 #include <linux/mman.h>
93682 #include <linux/mount.h>
93683 #include <linux/personality.h>
93684 @@ -32,8 +33,8 @@
93685 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93686 CONFIG_DEFAULT_SECURITY;
93687
93688 -static struct security_operations *security_ops;
93689 -static struct security_operations default_security_ops = {
93690 +static struct security_operations *security_ops __read_only;
93691 +static struct security_operations default_security_ops __read_only = {
93692 .name = "default",
93693 };
93694
93695 @@ -74,7 +75,9 @@ int __init security_init(void)
93696
93697 void reset_security_ops(void)
93698 {
93699 + pax_open_kernel();
93700 security_ops = &default_security_ops;
93701 + pax_close_kernel();
93702 }
93703
93704 /* Save user chosen LSM */
93705 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93706 index 5c6f2cd..b4f945c 100644
93707 --- a/security/selinux/hooks.c
93708 +++ b/security/selinux/hooks.c
93709 @@ -96,8 +96,6 @@
93710
93711 #define NUM_SEL_MNT_OPTS 5
93712
93713 -extern struct security_operations *security_ops;
93714 -
93715 /* SECMARK reference count */
93716 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93717
93718 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93719
93720 #endif
93721
93722 -static struct security_operations selinux_ops = {
93723 +static struct security_operations selinux_ops __read_only = {
93724 .name = "selinux",
93725
93726 .ptrace_access_check = selinux_ptrace_access_check,
93727 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93728 index 65f67cb..3f141ef 100644
93729 --- a/security/selinux/include/xfrm.h
93730 +++ b/security/selinux/include/xfrm.h
93731 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93732
93733 static inline void selinux_xfrm_notify_policyload(void)
93734 {
93735 - atomic_inc(&flow_cache_genid);
93736 + atomic_inc_unchecked(&flow_cache_genid);
93737 rt_genid_bump(&init_net);
93738 }
93739 #else
93740 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93741 index d52c780..6431349 100644
93742 --- a/security/smack/smack_lsm.c
93743 +++ b/security/smack/smack_lsm.c
93744 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93745 return 0;
93746 }
93747
93748 -struct security_operations smack_ops = {
93749 +struct security_operations smack_ops __read_only = {
93750 .name = "smack",
93751
93752 .ptrace_access_check = smack_ptrace_access_check,
93753 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93754 index 390c646..f2f8db3 100644
93755 --- a/security/tomoyo/mount.c
93756 +++ b/security/tomoyo/mount.c
93757 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93758 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93759 need_dev = -1; /* dev_name is a directory */
93760 } else {
93761 + if (!capable(CAP_SYS_ADMIN)) {
93762 + error = -EPERM;
93763 + goto out;
93764 + }
93765 fstype = get_fs_type(type);
93766 if (!fstype) {
93767 error = -ENODEV;
93768 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93769 index f0b756e..b129202 100644
93770 --- a/security/tomoyo/tomoyo.c
93771 +++ b/security/tomoyo/tomoyo.c
93772 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93773 * tomoyo_security_ops is a "struct security_operations" which is used for
93774 * registering TOMOYO.
93775 */
93776 -static struct security_operations tomoyo_security_ops = {
93777 +static struct security_operations tomoyo_security_ops __read_only = {
93778 .name = "tomoyo",
93779 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93780 .cred_prepare = tomoyo_cred_prepare,
93781 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93782 index 20ef514..4182bed 100644
93783 --- a/security/yama/Kconfig
93784 +++ b/security/yama/Kconfig
93785 @@ -1,6 +1,6 @@
93786 config SECURITY_YAMA
93787 bool "Yama support"
93788 - depends on SECURITY
93789 + depends on SECURITY && !GRKERNSEC
93790 select SECURITYFS
93791 select SECURITY_PATH
93792 default n
93793 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93794 index 13c88fbc..f8c115e 100644
93795 --- a/security/yama/yama_lsm.c
93796 +++ b/security/yama/yama_lsm.c
93797 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93798 }
93799
93800 #ifndef CONFIG_SECURITY_YAMA_STACKED
93801 -static struct security_operations yama_ops = {
93802 +static struct security_operations yama_ops __read_only = {
93803 .name = "yama",
93804
93805 .ptrace_access_check = yama_ptrace_access_check,
93806 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
93807 #endif
93808
93809 #ifdef CONFIG_SYSCTL
93810 +static int zero __read_only;
93811 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93812 +
93813 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93814 void __user *buffer, size_t *lenp, loff_t *ppos)
93815 {
93816 - int rc;
93817 + ctl_table_no_const yama_table;
93818
93819 if (write && !capable(CAP_SYS_PTRACE))
93820 return -EPERM;
93821
93822 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93823 - if (rc)
93824 - return rc;
93825 -
93826 + yama_table = *table;
93827 /* Lock the max value if it ever gets set. */
93828 - if (write && *(int *)table->data == *(int *)table->extra2)
93829 - table->extra1 = table->extra2;
93830 -
93831 - return rc;
93832 + if (ptrace_scope == max_scope)
93833 + yama_table.extra1 = &max_scope;
93834 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93835 }
93836
93837 -static int zero;
93838 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93839 -
93840 struct ctl_path yama_sysctl_path[] = {
93841 { .procname = "kernel", },
93842 { .procname = "yama", },
93843 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93844 index 4cedc69..e59d8a3 100644
93845 --- a/sound/aoa/codecs/onyx.c
93846 +++ b/sound/aoa/codecs/onyx.c
93847 @@ -54,7 +54,7 @@ struct onyx {
93848 spdif_locked:1,
93849 analog_locked:1,
93850 original_mute:2;
93851 - int open_count;
93852 + local_t open_count;
93853 struct codec_info *codec_info;
93854
93855 /* mutex serializes concurrent access to the device
93856 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93857 struct onyx *onyx = cii->codec_data;
93858
93859 mutex_lock(&onyx->mutex);
93860 - onyx->open_count++;
93861 + local_inc(&onyx->open_count);
93862 mutex_unlock(&onyx->mutex);
93863
93864 return 0;
93865 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93866 struct onyx *onyx = cii->codec_data;
93867
93868 mutex_lock(&onyx->mutex);
93869 - onyx->open_count--;
93870 - if (!onyx->open_count)
93871 + if (local_dec_and_test(&onyx->open_count))
93872 onyx->spdif_locked = onyx->analog_locked = 0;
93873 mutex_unlock(&onyx->mutex);
93874
93875 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93876 index ffd2025..df062c9 100644
93877 --- a/sound/aoa/codecs/onyx.h
93878 +++ b/sound/aoa/codecs/onyx.h
93879 @@ -11,6 +11,7 @@
93880 #include <linux/i2c.h>
93881 #include <asm/pmac_low_i2c.h>
93882 #include <asm/prom.h>
93883 +#include <asm/local.h>
93884
93885 /* PCM3052 register definitions */
93886
93887 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93888 index 4c1cc51..16040040 100644
93889 --- a/sound/core/oss/pcm_oss.c
93890 +++ b/sound/core/oss/pcm_oss.c
93891 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93892 if (in_kernel) {
93893 mm_segment_t fs;
93894 fs = snd_enter_user();
93895 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93896 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93897 snd_leave_user(fs);
93898 } else {
93899 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93900 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93901 }
93902 if (ret != -EPIPE && ret != -ESTRPIPE)
93903 break;
93904 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93905 if (in_kernel) {
93906 mm_segment_t fs;
93907 fs = snd_enter_user();
93908 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93909 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93910 snd_leave_user(fs);
93911 } else {
93912 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93913 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93914 }
93915 if (ret == -EPIPE) {
93916 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93917 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93918 struct snd_pcm_plugin_channel *channels;
93919 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93920 if (!in_kernel) {
93921 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93922 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93923 return -EFAULT;
93924 buf = runtime->oss.buffer;
93925 }
93926 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93927 }
93928 } else {
93929 tmp = snd_pcm_oss_write2(substream,
93930 - (const char __force *)buf,
93931 + (const char __force_kernel *)buf,
93932 runtime->oss.period_bytes, 0);
93933 if (tmp <= 0)
93934 goto err;
93935 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93936 struct snd_pcm_runtime *runtime = substream->runtime;
93937 snd_pcm_sframes_t frames, frames1;
93938 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93939 - char __user *final_dst = (char __force __user *)buf;
93940 + char __user *final_dst = (char __force_user *)buf;
93941 if (runtime->oss.plugin_first) {
93942 struct snd_pcm_plugin_channel *channels;
93943 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93944 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93945 xfer += tmp;
93946 runtime->oss.buffer_used -= tmp;
93947 } else {
93948 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93949 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93950 runtime->oss.period_bytes, 0);
93951 if (tmp <= 0)
93952 goto err;
93953 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93954 size1);
93955 size1 /= runtime->channels; /* frames */
93956 fs = snd_enter_user();
93957 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93958 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93959 snd_leave_user(fs);
93960 }
93961 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93962 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93963 index af49721..e85058e 100644
93964 --- a/sound/core/pcm_compat.c
93965 +++ b/sound/core/pcm_compat.c
93966 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93967 int err;
93968
93969 fs = snd_enter_user();
93970 - err = snd_pcm_delay(substream, &delay);
93971 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93972 snd_leave_user(fs);
93973 if (err < 0)
93974 return err;
93975 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93976 index f928181..33fb83d 100644
93977 --- a/sound/core/pcm_native.c
93978 +++ b/sound/core/pcm_native.c
93979 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93980 switch (substream->stream) {
93981 case SNDRV_PCM_STREAM_PLAYBACK:
93982 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93983 - (void __user *)arg);
93984 + (void __force_user *)arg);
93985 break;
93986 case SNDRV_PCM_STREAM_CAPTURE:
93987 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93988 - (void __user *)arg);
93989 + (void __force_user *)arg);
93990 break;
93991 default:
93992 result = -EINVAL;
93993 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93994 index 040c60e..989a19a 100644
93995 --- a/sound/core/seq/seq_device.c
93996 +++ b/sound/core/seq/seq_device.c
93997 @@ -64,7 +64,7 @@ struct ops_list {
93998 int argsize; /* argument size */
93999
94000 /* operators */
94001 - struct snd_seq_dev_ops ops;
94002 + struct snd_seq_dev_ops *ops;
94003
94004 /* registered devices */
94005 struct list_head dev_list; /* list of devices */
94006 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
94007
94008 mutex_lock(&ops->reg_mutex);
94009 /* copy driver operators */
94010 - ops->ops = *entry;
94011 + ops->ops = entry;
94012 ops->driver |= DRIVER_LOADED;
94013 ops->argsize = argsize;
94014
94015 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
94016 dev->name, ops->id, ops->argsize, dev->argsize);
94017 return -EINVAL;
94018 }
94019 - if (ops->ops.init_device(dev) >= 0) {
94020 + if (ops->ops->init_device(dev) >= 0) {
94021 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
94022 ops->num_init_devices++;
94023 } else {
94024 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
94025 dev->name, ops->id, ops->argsize, dev->argsize);
94026 return -EINVAL;
94027 }
94028 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
94029 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
94030 dev->status = SNDRV_SEQ_DEVICE_FREE;
94031 dev->driver_data = NULL;
94032 ops->num_init_devices--;
94033 diff --git a/sound/core/sound.c b/sound/core/sound.c
94034 index f002bd9..c462985 100644
94035 --- a/sound/core/sound.c
94036 +++ b/sound/core/sound.c
94037 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
94038 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
94039 default: return;
94040 }
94041 - request_module(str);
94042 + request_module("%s", str);
94043 }
94044
94045 #endif /* modular kernel */
94046 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
94047 index 4e0dd22..7a1f32c 100644
94048 --- a/sound/drivers/mts64.c
94049 +++ b/sound/drivers/mts64.c
94050 @@ -29,6 +29,7 @@
94051 #include <sound/initval.h>
94052 #include <sound/rawmidi.h>
94053 #include <sound/control.h>
94054 +#include <asm/local.h>
94055
94056 #define CARD_NAME "Miditerminal 4140"
94057 #define DRIVER_NAME "MTS64"
94058 @@ -67,7 +68,7 @@ struct mts64 {
94059 struct pardevice *pardev;
94060 int pardev_claimed;
94061
94062 - int open_count;
94063 + local_t open_count;
94064 int current_midi_output_port;
94065 int current_midi_input_port;
94066 u8 mode[MTS64_NUM_INPUT_PORTS];
94067 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94068 {
94069 struct mts64 *mts = substream->rmidi->private_data;
94070
94071 - if (mts->open_count == 0) {
94072 + if (local_read(&mts->open_count) == 0) {
94073 /* We don't need a spinlock here, because this is just called
94074 if the device has not been opened before.
94075 So there aren't any IRQs from the device */
94076 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94077
94078 msleep(50);
94079 }
94080 - ++(mts->open_count);
94081 + local_inc(&mts->open_count);
94082
94083 return 0;
94084 }
94085 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94086 struct mts64 *mts = substream->rmidi->private_data;
94087 unsigned long flags;
94088
94089 - --(mts->open_count);
94090 - if (mts->open_count == 0) {
94091 + if (local_dec_return(&mts->open_count) == 0) {
94092 /* We need the spinlock_irqsave here because we can still
94093 have IRQs at this point */
94094 spin_lock_irqsave(&mts->lock, flags);
94095 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94096
94097 msleep(500);
94098
94099 - } else if (mts->open_count < 0)
94100 - mts->open_count = 0;
94101 + } else if (local_read(&mts->open_count) < 0)
94102 + local_set(&mts->open_count, 0);
94103
94104 return 0;
94105 }
94106 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
94107 index b953fb4..1999c01 100644
94108 --- a/sound/drivers/opl4/opl4_lib.c
94109 +++ b/sound/drivers/opl4/opl4_lib.c
94110 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
94111 MODULE_DESCRIPTION("OPL4 driver");
94112 MODULE_LICENSE("GPL");
94113
94114 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
94115 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
94116 {
94117 int timeout = 10;
94118 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
94119 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
94120 index 991018d..8984740 100644
94121 --- a/sound/drivers/portman2x4.c
94122 +++ b/sound/drivers/portman2x4.c
94123 @@ -48,6 +48,7 @@
94124 #include <sound/initval.h>
94125 #include <sound/rawmidi.h>
94126 #include <sound/control.h>
94127 +#include <asm/local.h>
94128
94129 #define CARD_NAME "Portman 2x4"
94130 #define DRIVER_NAME "portman"
94131 @@ -85,7 +86,7 @@ struct portman {
94132 struct pardevice *pardev;
94133 int pardev_claimed;
94134
94135 - int open_count;
94136 + local_t open_count;
94137 int mode[PORTMAN_NUM_INPUT_PORTS];
94138 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
94139 };
94140 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
94141 index ea995af..f1bfa37 100644
94142 --- a/sound/firewire/amdtp.c
94143 +++ b/sound/firewire/amdtp.c
94144 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
94145 ptr = s->pcm_buffer_pointer + data_blocks;
94146 if (ptr >= pcm->runtime->buffer_size)
94147 ptr -= pcm->runtime->buffer_size;
94148 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
94149 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
94150
94151 s->pcm_period_pointer += data_blocks;
94152 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
94153 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
94154 */
94155 void amdtp_out_stream_update(struct amdtp_out_stream *s)
94156 {
94157 - ACCESS_ONCE(s->source_node_id_field) =
94158 + ACCESS_ONCE_RW(s->source_node_id_field) =
94159 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
94160 }
94161 EXPORT_SYMBOL(amdtp_out_stream_update);
94162 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
94163 index b680c5e..061b7a0 100644
94164 --- a/sound/firewire/amdtp.h
94165 +++ b/sound/firewire/amdtp.h
94166 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
94167 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
94168 struct snd_pcm_substream *pcm)
94169 {
94170 - ACCESS_ONCE(s->pcm) = pcm;
94171 + ACCESS_ONCE_RW(s->pcm) = pcm;
94172 }
94173
94174 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
94175 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
94176 index d428ffe..751ef78 100644
94177 --- a/sound/firewire/isight.c
94178 +++ b/sound/firewire/isight.c
94179 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
94180 ptr += count;
94181 if (ptr >= runtime->buffer_size)
94182 ptr -= runtime->buffer_size;
94183 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
94184 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
94185
94186 isight->period_counter += count;
94187 if (isight->period_counter >= runtime->period_size) {
94188 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
94189 if (err < 0)
94190 return err;
94191
94192 - ACCESS_ONCE(isight->pcm_active) = true;
94193 + ACCESS_ONCE_RW(isight->pcm_active) = true;
94194
94195 return 0;
94196 }
94197 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
94198 {
94199 struct isight *isight = substream->private_data;
94200
94201 - ACCESS_ONCE(isight->pcm_active) = false;
94202 + ACCESS_ONCE_RW(isight->pcm_active) = false;
94203
94204 mutex_lock(&isight->mutex);
94205 isight_stop_streaming(isight);
94206 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
94207
94208 switch (cmd) {
94209 case SNDRV_PCM_TRIGGER_START:
94210 - ACCESS_ONCE(isight->pcm_running) = true;
94211 + ACCESS_ONCE_RW(isight->pcm_running) = true;
94212 break;
94213 case SNDRV_PCM_TRIGGER_STOP:
94214 - ACCESS_ONCE(isight->pcm_running) = false;
94215 + ACCESS_ONCE_RW(isight->pcm_running) = false;
94216 break;
94217 default:
94218 return -EINVAL;
94219 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
94220 index 844a555..985ab83 100644
94221 --- a/sound/firewire/scs1x.c
94222 +++ b/sound/firewire/scs1x.c
94223 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
94224 {
94225 struct scs *scs = stream->rmidi->private_data;
94226
94227 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
94228 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
94229 if (up) {
94230 scs->output_idle = false;
94231 tasklet_schedule(&scs->tasklet);
94232 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
94233 {
94234 struct scs *scs = stream->rmidi->private_data;
94235
94236 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
94237 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
94238 }
94239
94240 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
94241 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
94242
94243 snd_card_disconnect(scs->card);
94244
94245 - ACCESS_ONCE(scs->output) = NULL;
94246 - ACCESS_ONCE(scs->input) = NULL;
94247 + ACCESS_ONCE_RW(scs->output) = NULL;
94248 + ACCESS_ONCE_RW(scs->input) = NULL;
94249
94250 wait_event(scs->idle_wait, scs->output_idle);
94251
94252 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
94253 index 048439a..3be9f6f 100644
94254 --- a/sound/oss/sb_audio.c
94255 +++ b/sound/oss/sb_audio.c
94256 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
94257 buf16 = (signed short *)(localbuf + localoffs);
94258 while (c)
94259 {
94260 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94261 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94262 if (copy_from_user(lbuf8,
94263 userbuf+useroffs + p,
94264 locallen))
94265 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
94266 index 7d8803a..559f8d0 100644
94267 --- a/sound/oss/swarm_cs4297a.c
94268 +++ b/sound/oss/swarm_cs4297a.c
94269 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
94270 {
94271 struct cs4297a_state *s;
94272 u32 pwr, id;
94273 - mm_segment_t fs;
94274 int rval;
94275 #ifndef CONFIG_BCM_CS4297A_CSWARM
94276 u64 cfg;
94277 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
94278 if (!rval) {
94279 char *sb1250_duart_present;
94280
94281 +#if 0
94282 + mm_segment_t fs;
94283 fs = get_fs();
94284 set_fs(KERNEL_DS);
94285 -#if 0
94286 val = SOUND_MASK_LINE;
94287 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
94288 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
94289 val = initvol[i].vol;
94290 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
94291 }
94292 + set_fs(fs);
94293 // cs4297a_write_ac97(s, 0x18, 0x0808);
94294 #else
94295 // cs4297a_write_ac97(s, 0x5e, 0x180);
94296 cs4297a_write_ac97(s, 0x02, 0x0808);
94297 cs4297a_write_ac97(s, 0x18, 0x0808);
94298 #endif
94299 - set_fs(fs);
94300
94301 list_add(&s->list, &cs4297a_devs);
94302
94303 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
94304 index 4631a23..001ae57 100644
94305 --- a/sound/pci/ymfpci/ymfpci.h
94306 +++ b/sound/pci/ymfpci/ymfpci.h
94307 @@ -358,7 +358,7 @@ struct snd_ymfpci {
94308 spinlock_t reg_lock;
94309 spinlock_t voice_lock;
94310 wait_queue_head_t interrupt_sleep;
94311 - atomic_t interrupt_sleep_count;
94312 + atomic_unchecked_t interrupt_sleep_count;
94313 struct snd_info_entry *proc_entry;
94314 const struct firmware *dsp_microcode;
94315 const struct firmware *controller_microcode;
94316 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
94317 index 22056c5..25d3244 100644
94318 --- a/sound/pci/ymfpci/ymfpci_main.c
94319 +++ b/sound/pci/ymfpci/ymfpci_main.c
94320 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
94321 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
94322 break;
94323 }
94324 - if (atomic_read(&chip->interrupt_sleep_count)) {
94325 - atomic_set(&chip->interrupt_sleep_count, 0);
94326 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94327 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94328 wake_up(&chip->interrupt_sleep);
94329 }
94330 __end:
94331 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
94332 continue;
94333 init_waitqueue_entry(&wait, current);
94334 add_wait_queue(&chip->interrupt_sleep, &wait);
94335 - atomic_inc(&chip->interrupt_sleep_count);
94336 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
94337 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
94338 remove_wait_queue(&chip->interrupt_sleep, &wait);
94339 }
94340 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
94341 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
94342 spin_unlock(&chip->reg_lock);
94343
94344 - if (atomic_read(&chip->interrupt_sleep_count)) {
94345 - atomic_set(&chip->interrupt_sleep_count, 0);
94346 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94347 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94348 wake_up(&chip->interrupt_sleep);
94349 }
94350 }
94351 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
94352 spin_lock_init(&chip->reg_lock);
94353 spin_lock_init(&chip->voice_lock);
94354 init_waitqueue_head(&chip->interrupt_sleep);
94355 - atomic_set(&chip->interrupt_sleep_count, 0);
94356 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94357 chip->card = card;
94358 chip->pci = pci;
94359 chip->irq = -1;
94360 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
94361 index 0f0bed6..c161e28 100644
94362 --- a/sound/soc/fsl/fsl_ssi.c
94363 +++ b/sound/soc/fsl/fsl_ssi.c
94364 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
94365 {
94366 struct fsl_ssi_private *ssi_private;
94367 int ret = 0;
94368 - struct device_attribute *dev_attr = NULL;
94369 + device_attribute_no_const *dev_attr = NULL;
94370 struct device_node *np = pdev->dev.of_node;
94371 const char *p, *sprop;
94372 const uint32_t *iprop;
94373 diff --git a/sound/sound_core.c b/sound/sound_core.c
94374 index 359753f..45759f4 100644
94375 --- a/sound/sound_core.c
94376 +++ b/sound/sound_core.c
94377 @@ -292,7 +292,7 @@ retry:
94378 }
94379
94380 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
94381 - NULL, s->name+6);
94382 + NULL, "%s", s->name+6);
94383 return s->unit_minor;
94384
94385 fail:
94386 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
94387 new file mode 100644
94388 index 0000000..50f2f2f
94389 --- /dev/null
94390 +++ b/tools/gcc/.gitignore
94391 @@ -0,0 +1 @@
94392 +size_overflow_hash.h
94393 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
94394 new file mode 100644
94395 index 0000000..144dbee
94396 --- /dev/null
94397 +++ b/tools/gcc/Makefile
94398 @@ -0,0 +1,45 @@
94399 +#CC := gcc
94400 +#PLUGIN_SOURCE_FILES := pax_plugin.c
94401 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
94402 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
94403 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
94404 +
94405 +ifeq ($(PLUGINCC),$(HOSTCC))
94406 +HOSTLIBS := hostlibs
94407 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
94408 +else
94409 +HOSTLIBS := hostcxxlibs
94410 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
94411 +endif
94412 +
94413 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
94414 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
94415 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
94416 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
94417 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
94418 +$(HOSTLIBS)-y += colorize_plugin.so
94419 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
94420 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
94421 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
94422 +
94423 +always := $($(HOSTLIBS)-y)
94424 +
94425 +constify_plugin-objs := constify_plugin.o
94426 +stackleak_plugin-objs := stackleak_plugin.o
94427 +kallocstat_plugin-objs := kallocstat_plugin.o
94428 +kernexec_plugin-objs := kernexec_plugin.o
94429 +checker_plugin-objs := checker_plugin.o
94430 +colorize_plugin-objs := colorize_plugin.o
94431 +size_overflow_plugin-objs := size_overflow_plugin.o
94432 +latent_entropy_plugin-objs := latent_entropy_plugin.o
94433 +structleak_plugin-objs := structleak_plugin.o
94434 +
94435 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
94436 +
94437 +quiet_cmd_build_size_overflow_hash = GENHASH $@
94438 + cmd_build_size_overflow_hash = \
94439 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
94440 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
94441 + $(call if_changed,build_size_overflow_hash)
94442 +
94443 +targets += size_overflow_hash.h
94444 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94445 new file mode 100644
94446 index 0000000..22f03c0
94447 --- /dev/null
94448 +++ b/tools/gcc/checker_plugin.c
94449 @@ -0,0 +1,172 @@
94450 +/*
94451 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94452 + * Licensed under the GPL v2
94453 + *
94454 + * Note: the choice of the license means that the compilation process is
94455 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94456 + * but for the kernel it doesn't matter since it doesn't link against
94457 + * any of the gcc libraries
94458 + *
94459 + * gcc plugin to implement various sparse (source code checker) features
94460 + *
94461 + * TODO:
94462 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94463 + *
94464 + * BUGS:
94465 + * - none known
94466 + */
94467 +#include "gcc-plugin.h"
94468 +#include "config.h"
94469 +#include "system.h"
94470 +#include "coretypes.h"
94471 +#include "tree.h"
94472 +#include "tree-pass.h"
94473 +#include "flags.h"
94474 +#include "intl.h"
94475 +#include "toplev.h"
94476 +#include "plugin.h"
94477 +//#include "expr.h" where are you...
94478 +#include "diagnostic.h"
94479 +#include "plugin-version.h"
94480 +#include "tm.h"
94481 +#include "function.h"
94482 +#include "basic-block.h"
94483 +#include "gimple.h"
94484 +#include "rtl.h"
94485 +#include "emit-rtl.h"
94486 +#include "tree-flow.h"
94487 +#include "target.h"
94488 +
94489 +extern void c_register_addr_space (const char *str, addr_space_t as);
94490 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94491 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94492 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94493 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94494 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94495 +
94496 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94497 +extern rtx emit_move_insn(rtx x, rtx y);
94498 +
94499 +int plugin_is_GPL_compatible;
94500 +
94501 +static struct plugin_info checker_plugin_info = {
94502 + .version = "201111150100",
94503 + .help = NULL,
94504 +};
94505 +
94506 +#define ADDR_SPACE_KERNEL 0
94507 +#define ADDR_SPACE_FORCE_KERNEL 1
94508 +#define ADDR_SPACE_USER 2
94509 +#define ADDR_SPACE_FORCE_USER 3
94510 +#define ADDR_SPACE_IOMEM 0
94511 +#define ADDR_SPACE_FORCE_IOMEM 0
94512 +#define ADDR_SPACE_PERCPU 0
94513 +#define ADDR_SPACE_FORCE_PERCPU 0
94514 +#define ADDR_SPACE_RCU 0
94515 +#define ADDR_SPACE_FORCE_RCU 0
94516 +
94517 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94518 +{
94519 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94520 +}
94521 +
94522 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94523 +{
94524 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94525 +}
94526 +
94527 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94528 +{
94529 + return default_addr_space_valid_pointer_mode(mode, as);
94530 +}
94531 +
94532 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94533 +{
94534 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94535 +}
94536 +
94537 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94538 +{
94539 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94540 +}
94541 +
94542 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94543 +{
94544 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94545 + return true;
94546 +
94547 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94548 + return true;
94549 +
94550 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94551 + return true;
94552 +
94553 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94554 + return true;
94555 +
94556 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94557 + return true;
94558 +
94559 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94560 + return true;
94561 +
94562 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94563 + return true;
94564 +
94565 + return subset == superset;
94566 +}
94567 +
94568 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94569 +{
94570 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94571 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94572 +
94573 + return op;
94574 +}
94575 +
94576 +static void register_checker_address_spaces(void *event_data, void *data)
94577 +{
94578 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94579 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94580 + c_register_addr_space("__user", ADDR_SPACE_USER);
94581 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94582 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94583 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94584 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94585 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94586 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94587 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94588 +
94589 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94590 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94591 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94592 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94593 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94594 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94595 + targetm.addr_space.convert = checker_addr_space_convert;
94596 +}
94597 +
94598 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94599 +{
94600 + const char * const plugin_name = plugin_info->base_name;
94601 + const int argc = plugin_info->argc;
94602 + const struct plugin_argument * const argv = plugin_info->argv;
94603 + int i;
94604 +
94605 + if (!plugin_default_version_check(version, &gcc_version)) {
94606 + error(G_("incompatible gcc/plugin versions"));
94607 + return 1;
94608 + }
94609 +
94610 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94611 +
94612 + for (i = 0; i < argc; ++i)
94613 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94614 +
94615 + if (TARGET_64BIT == 0)
94616 + return 0;
94617 +
94618 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94619 +
94620 + return 0;
94621 +}
94622 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94623 new file mode 100644
94624 index 0000000..414fe5e
94625 --- /dev/null
94626 +++ b/tools/gcc/colorize_plugin.c
94627 @@ -0,0 +1,151 @@
94628 +/*
94629 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94630 + * Licensed under the GPL v2
94631 + *
94632 + * Note: the choice of the license means that the compilation process is
94633 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94634 + * but for the kernel it doesn't matter since it doesn't link against
94635 + * any of the gcc libraries
94636 + *
94637 + * gcc plugin to colorize diagnostic output
94638 + *
94639 + */
94640 +
94641 +#include "gcc-plugin.h"
94642 +#include "config.h"
94643 +#include "system.h"
94644 +#include "coretypes.h"
94645 +#include "tree.h"
94646 +#include "tree-pass.h"
94647 +#include "flags.h"
94648 +#include "intl.h"
94649 +#include "toplev.h"
94650 +#include "plugin.h"
94651 +#include "diagnostic.h"
94652 +#include "plugin-version.h"
94653 +#include "tm.h"
94654 +
94655 +int plugin_is_GPL_compatible;
94656 +
94657 +static struct plugin_info colorize_plugin_info = {
94658 + .version = "201302112000",
94659 + .help = NULL,
94660 +};
94661 +
94662 +#define GREEN "\033[32m\033[2m"
94663 +#define LIGHTGREEN "\033[32m\033[1m"
94664 +#define YELLOW "\033[33m\033[2m"
94665 +#define LIGHTYELLOW "\033[33m\033[1m"
94666 +#define RED "\033[31m\033[2m"
94667 +#define LIGHTRED "\033[31m\033[1m"
94668 +#define BLUE "\033[34m\033[2m"
94669 +#define LIGHTBLUE "\033[34m\033[1m"
94670 +#define BRIGHT "\033[m\033[1m"
94671 +#define NORMAL "\033[m"
94672 +
94673 +static diagnostic_starter_fn old_starter;
94674 +static diagnostic_finalizer_fn old_finalizer;
94675 +
94676 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94677 +{
94678 + const char *color;
94679 + char *newprefix;
94680 +
94681 + switch (diagnostic->kind) {
94682 + case DK_NOTE:
94683 + color = LIGHTBLUE;
94684 + break;
94685 +
94686 + case DK_PEDWARN:
94687 + case DK_WARNING:
94688 + color = LIGHTYELLOW;
94689 + break;
94690 +
94691 + case DK_ERROR:
94692 + case DK_FATAL:
94693 + case DK_ICE:
94694 + case DK_PERMERROR:
94695 + case DK_SORRY:
94696 + color = LIGHTRED;
94697 + break;
94698 +
94699 + default:
94700 + color = NORMAL;
94701 + }
94702 +
94703 + old_starter(context, diagnostic);
94704 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94705 + return;
94706 + pp_destroy_prefix(context->printer);
94707 + pp_set_prefix(context->printer, newprefix);
94708 +}
94709 +
94710 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94711 +{
94712 + old_finalizer(context, diagnostic);
94713 +}
94714 +
94715 +static void colorize_arm(void)
94716 +{
94717 + old_starter = diagnostic_starter(global_dc);
94718 + old_finalizer = diagnostic_finalizer(global_dc);
94719 +
94720 + diagnostic_starter(global_dc) = start_colorize;
94721 + diagnostic_finalizer(global_dc) = finalize_colorize;
94722 +}
94723 +
94724 +static unsigned int execute_colorize_rearm(void)
94725 +{
94726 + if (diagnostic_starter(global_dc) == start_colorize)
94727 + return 0;
94728 +
94729 + colorize_arm();
94730 + return 0;
94731 +}
94732 +
94733 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94734 + .pass = {
94735 + .type = SIMPLE_IPA_PASS,
94736 + .name = "colorize_rearm",
94737 +#if BUILDING_GCC_VERSION >= 4008
94738 + .optinfo_flags = OPTGROUP_NONE,
94739 +#endif
94740 + .gate = NULL,
94741 + .execute = execute_colorize_rearm,
94742 + .sub = NULL,
94743 + .next = NULL,
94744 + .static_pass_number = 0,
94745 + .tv_id = TV_NONE,
94746 + .properties_required = 0,
94747 + .properties_provided = 0,
94748 + .properties_destroyed = 0,
94749 + .todo_flags_start = 0,
94750 + .todo_flags_finish = 0
94751 + }
94752 +};
94753 +
94754 +static void colorize_start_unit(void *gcc_data, void *user_data)
94755 +{
94756 + colorize_arm();
94757 +}
94758 +
94759 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94760 +{
94761 + const char * const plugin_name = plugin_info->base_name;
94762 + struct register_pass_info colorize_rearm_pass_info = {
94763 + .pass = &pass_ipa_colorize_rearm.pass,
94764 + .reference_pass_name = "*free_lang_data",
94765 + .ref_pass_instance_number = 1,
94766 + .pos_op = PASS_POS_INSERT_AFTER
94767 + };
94768 +
94769 + if (!plugin_default_version_check(version, &gcc_version)) {
94770 + error(G_("incompatible gcc/plugin versions"));
94771 + return 1;
94772 + }
94773 +
94774 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94775 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94776 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94777 + return 0;
94778 +}
94779 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94780 new file mode 100644
94781 index 0000000..c17312d
94782 --- /dev/null
94783 +++ b/tools/gcc/constify_plugin.c
94784 @@ -0,0 +1,560 @@
94785 +/*
94786 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94787 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94788 + * Licensed under the GPL v2, or (at your option) v3
94789 + *
94790 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94791 + *
94792 + * Homepage:
94793 + * http://www.grsecurity.net/~ephox/const_plugin/
94794 + *
94795 + * Usage:
94796 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94797 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94798 + */
94799 +
94800 +#include "gcc-plugin.h"
94801 +#include "config.h"
94802 +#include "system.h"
94803 +#include "coretypes.h"
94804 +#include "tree.h"
94805 +#include "tree-pass.h"
94806 +#include "flags.h"
94807 +#include "intl.h"
94808 +#include "toplev.h"
94809 +#include "plugin.h"
94810 +#include "diagnostic.h"
94811 +#include "plugin-version.h"
94812 +#include "tm.h"
94813 +#include "function.h"
94814 +#include "basic-block.h"
94815 +#include "gimple.h"
94816 +#include "rtl.h"
94817 +#include "emit-rtl.h"
94818 +#include "tree-flow.h"
94819 +#include "target.h"
94820 +#include "langhooks.h"
94821 +
94822 +// should come from c-tree.h if only it were installed for gcc 4.5...
94823 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94824 +
94825 +// unused type flag in all versions 4.5-4.8
94826 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94827 +
94828 +int plugin_is_GPL_compatible;
94829 +
94830 +static struct plugin_info const_plugin_info = {
94831 + .version = "201305231310",
94832 + .help = "no-constify\tturn off constification\n",
94833 +};
94834 +
94835 +typedef struct {
94836 + bool has_fptr_field;
94837 + bool has_writable_field;
94838 + bool has_do_const_field;
94839 + bool has_no_const_field;
94840 +} constify_info;
94841 +
94842 +static const_tree get_field_type(const_tree field)
94843 +{
94844 + return strip_array_types(TREE_TYPE(field));
94845 +}
94846 +
94847 +static bool is_fptr(const_tree field)
94848 +{
94849 + const_tree ptr = get_field_type(field);
94850 +
94851 + if (TREE_CODE(ptr) != POINTER_TYPE)
94852 + return false;
94853 +
94854 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94855 +}
94856 +
94857 +/*
94858 + * determine whether the given structure type meets the requirements for automatic constification,
94859 + * including the constification attributes on nested structure types
94860 + */
94861 +static void constifiable(const_tree node, constify_info *cinfo)
94862 +{
94863 + const_tree field;
94864 +
94865 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94866 +
94867 + // e.g., pointer to structure fields while still constructing the structure type
94868 + if (TYPE_FIELDS(node) == NULL_TREE)
94869 + return;
94870 +
94871 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94872 + const_tree type = get_field_type(field);
94873 + enum tree_code code = TREE_CODE(type);
94874 +
94875 + if (node == type)
94876 + continue;
94877 +
94878 + if (is_fptr(field))
94879 + cinfo->has_fptr_field = true;
94880 + else if (!TREE_READONLY(field))
94881 + cinfo->has_writable_field = true;
94882 +
94883 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94884 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94885 + cinfo->has_do_const_field = true;
94886 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94887 + cinfo->has_no_const_field = true;
94888 + else
94889 + constifiable(type, cinfo);
94890 + }
94891 + }
94892 +}
94893 +
94894 +static bool constified(const_tree node)
94895 +{
94896 + constify_info cinfo = {
94897 + .has_fptr_field = false,
94898 + .has_writable_field = false,
94899 + .has_do_const_field = false,
94900 + .has_no_const_field = false
94901 + };
94902 +
94903 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94904 +
94905 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94906 + gcc_assert(!TYPE_READONLY(node));
94907 + return false;
94908 + }
94909 +
94910 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94911 + gcc_assert(TYPE_READONLY(node));
94912 + return true;
94913 + }
94914 +
94915 + constifiable(node, &cinfo);
94916 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94917 + return false;
94918 +
94919 + return TYPE_READONLY(node);
94920 +}
94921 +
94922 +static void deconstify_tree(tree node);
94923 +
94924 +static void deconstify_type(tree type)
94925 +{
94926 + tree field;
94927 +
94928 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94929 +
94930 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94931 + const_tree fieldtype = get_field_type(field);
94932 +
94933 + // special case handling of simple ptr-to-same-array-type members
94934 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94935 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94936 +
94937 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94938 + continue;
94939 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94940 + continue;
94941 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94942 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94943 + TREE_TYPE(TREE_TYPE(field)) = type;
94944 + }
94945 + continue;
94946 + }
94947 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94948 + continue;
94949 + if (!constified(fieldtype))
94950 + continue;
94951 +
94952 + deconstify_tree(field);
94953 + TREE_READONLY(field) = 0;
94954 + }
94955 + TYPE_READONLY(type) = 0;
94956 + C_TYPE_FIELDS_READONLY(type) = 0;
94957 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94958 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94959 +}
94960 +
94961 +static void deconstify_tree(tree node)
94962 +{
94963 + tree old_type, new_type, field;
94964 +
94965 + old_type = TREE_TYPE(node);
94966 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94967 + node = TREE_TYPE(node) = copy_node(old_type);
94968 + old_type = TREE_TYPE(old_type);
94969 + }
94970 +
94971 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94972 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94973 +
94974 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94975 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94976 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94977 + DECL_FIELD_CONTEXT(field) = new_type;
94978 +
94979 + deconstify_type(new_type);
94980 +
94981 + TREE_TYPE(node) = new_type;
94982 +}
94983 +
94984 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94985 +{
94986 + tree type;
94987 + constify_info cinfo = {
94988 + .has_fptr_field = false,
94989 + .has_writable_field = false,
94990 + .has_do_const_field = false,
94991 + .has_no_const_field = false
94992 + };
94993 +
94994 + *no_add_attrs = true;
94995 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94996 + error("%qE attribute does not apply to functions", name);
94997 + return NULL_TREE;
94998 + }
94999 +
95000 + if (TREE_CODE(*node) == PARM_DECL) {
95001 + error("%qE attribute does not apply to function parameters", name);
95002 + return NULL_TREE;
95003 + }
95004 +
95005 + if (TREE_CODE(*node) == VAR_DECL) {
95006 + error("%qE attribute does not apply to variables", name);
95007 + return NULL_TREE;
95008 + }
95009 +
95010 + if (TYPE_P(*node)) {
95011 + *no_add_attrs = false;
95012 + type = *node;
95013 + } else {
95014 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
95015 + type = TREE_TYPE(*node);
95016 + }
95017 +
95018 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
95019 + error("%qE attribute applies to struct and union types only", name);
95020 + return NULL_TREE;
95021 + }
95022 +
95023 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
95024 + error("%qE attribute is already applied to the type", name);
95025 + return NULL_TREE;
95026 + }
95027 +
95028 + if (TYPE_P(*node)) {
95029 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95030 + error("%qE attribute is incompatible with 'do_const'", name);
95031 + return NULL_TREE;
95032 + }
95033 +
95034 + constifiable(type, &cinfo);
95035 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95036 + deconstify_tree(*node);
95037 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
95038 + return NULL_TREE;
95039 + }
95040 +
95041 + error("%qE attribute used on type that is not constified", name);
95042 + return NULL_TREE;
95043 +}
95044 +
95045 +static void constify_type(tree type)
95046 +{
95047 + TYPE_READONLY(type) = 1;
95048 + C_TYPE_FIELDS_READONLY(type) = 1;
95049 + TYPE_CONSTIFY_VISITED(type) = 1;
95050 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
95051 +}
95052 +
95053 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95054 +{
95055 + *no_add_attrs = true;
95056 + if (!TYPE_P(*node)) {
95057 + error("%qE attribute applies to types only", name);
95058 + return NULL_TREE;
95059 + }
95060 +
95061 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
95062 + error("%qE attribute applies to struct and union types only", name);
95063 + return NULL_TREE;
95064 + }
95065 +
95066 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
95067 + error("%qE attribute is already applied to the type", name);
95068 + return NULL_TREE;
95069 + }
95070 +
95071 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
95072 + error("%qE attribute is incompatible with 'no_const'", name);
95073 + return NULL_TREE;
95074 + }
95075 +
95076 + *no_add_attrs = false;
95077 + return NULL_TREE;
95078 +}
95079 +
95080 +static struct attribute_spec no_const_attr = {
95081 + .name = "no_const",
95082 + .min_length = 0,
95083 + .max_length = 0,
95084 + .decl_required = false,
95085 + .type_required = false,
95086 + .function_type_required = false,
95087 + .handler = handle_no_const_attribute,
95088 +#if BUILDING_GCC_VERSION >= 4007
95089 + .affects_type_identity = true
95090 +#endif
95091 +};
95092 +
95093 +static struct attribute_spec do_const_attr = {
95094 + .name = "do_const",
95095 + .min_length = 0,
95096 + .max_length = 0,
95097 + .decl_required = false,
95098 + .type_required = false,
95099 + .function_type_required = false,
95100 + .handler = handle_do_const_attribute,
95101 +#if BUILDING_GCC_VERSION >= 4007
95102 + .affects_type_identity = true
95103 +#endif
95104 +};
95105 +
95106 +static void register_attributes(void *event_data, void *data)
95107 +{
95108 + register_attribute(&no_const_attr);
95109 + register_attribute(&do_const_attr);
95110 +}
95111 +
95112 +static void finish_type(void *event_data, void *data)
95113 +{
95114 + tree type = (tree)event_data;
95115 + constify_info cinfo = {
95116 + .has_fptr_field = false,
95117 + .has_writable_field = false,
95118 + .has_do_const_field = false,
95119 + .has_no_const_field = false
95120 + };
95121 +
95122 + if (type == NULL_TREE || type == error_mark_node)
95123 + return;
95124 +
95125 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
95126 + return;
95127 +
95128 + constifiable(type, &cinfo);
95129 +
95130 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
95131 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95132 + return;
95133 + if (cinfo.has_writable_field)
95134 + return;
95135 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
95136 + return;
95137 + }
95138 +
95139 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
95140 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
95141 + deconstify_type(type);
95142 + TYPE_CONSTIFY_VISITED(type) = 1;
95143 + } else
95144 + error("'no_const' attribute used on type that is not constified");
95145 + return;
95146 + }
95147 +
95148 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95149 + constify_type(type);
95150 + return;
95151 + }
95152 +
95153 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
95154 + constify_type(type);
95155 + return;
95156 + }
95157 +
95158 + deconstify_type(type);
95159 + TYPE_CONSTIFY_VISITED(type) = 1;
95160 +}
95161 +
95162 +static void check_global_variables(void)
95163 +{
95164 + struct varpool_node *node;
95165 +
95166 +#if BUILDING_GCC_VERSION <= 4007
95167 + for (node = varpool_nodes; node; node = node->next) {
95168 + tree var = node->decl;
95169 +#else
95170 + FOR_EACH_VARIABLE(node) {
95171 + tree var = node->symbol.decl;
95172 +#endif
95173 + tree type = TREE_TYPE(var);
95174 +
95175 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95176 + continue;
95177 +
95178 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95179 + continue;
95180 +
95181 + if (!TYPE_CONSTIFY_VISITED(type))
95182 + continue;
95183 +
95184 + if (DECL_EXTERNAL(var))
95185 + continue;
95186 +
95187 + if (DECL_INITIAL(var))
95188 + continue;
95189 +
95190 + // this works around a gcc bug/feature where uninitialized globals
95191 + // are moved into the .bss section regardless of any constification
95192 + DECL_INITIAL(var) = build_constructor(type, NULL);
95193 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
95194 + }
95195 +}
95196 +
95197 +static unsigned int check_local_variables(void)
95198 +{
95199 + unsigned int ret = 0;
95200 + tree var;
95201 +
95202 +#if BUILDING_GCC_VERSION == 4005
95203 + tree vars;
95204 +#else
95205 + unsigned int i;
95206 +#endif
95207 +
95208 +#if BUILDING_GCC_VERSION == 4005
95209 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
95210 + var = TREE_VALUE(vars);
95211 +#else
95212 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
95213 +#endif
95214 + tree type = TREE_TYPE(var);
95215 +
95216 + gcc_assert(DECL_P(var));
95217 + if (is_global_var(var))
95218 + continue;
95219 +
95220 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95221 + continue;
95222 +
95223 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95224 + continue;
95225 +
95226 + if (!TYPE_CONSTIFY_VISITED(type))
95227 + continue;
95228 +
95229 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
95230 + ret = 1;
95231 + }
95232 + return ret;
95233 +}
95234 +
95235 +static unsigned int check_variables(void)
95236 +{
95237 + check_global_variables();
95238 + return check_local_variables();
95239 +}
95240 +
95241 + unsigned int ret = 0;
95242 +static struct gimple_opt_pass pass_local_variable = {
95243 + {
95244 + .type = GIMPLE_PASS,
95245 + .name = "check_variables",
95246 +#if BUILDING_GCC_VERSION >= 4008
95247 + .optinfo_flags = OPTGROUP_NONE,
95248 +#endif
95249 + .gate = NULL,
95250 + .execute = check_variables,
95251 + .sub = NULL,
95252 + .next = NULL,
95253 + .static_pass_number = 0,
95254 + .tv_id = TV_NONE,
95255 + .properties_required = 0,
95256 + .properties_provided = 0,
95257 + .properties_destroyed = 0,
95258 + .todo_flags_start = 0,
95259 + .todo_flags_finish = 0
95260 + }
95261 +};
95262 +
95263 +static struct {
95264 + const char *name;
95265 + const char *asm_op;
95266 +} sections[] = {
95267 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
95268 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
95269 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
95270 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
95271 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
95272 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
95273 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
95274 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
95275 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
95276 +};
95277 +
95278 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
95279 +
95280 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
95281 +{
95282 + size_t i;
95283 +
95284 + for (i = 0; i < ARRAY_SIZE(sections); i++)
95285 + if (!strcmp(sections[i].name, name))
95286 + return 0;
95287 + return old_section_type_flags(decl, name, reloc);
95288 +}
95289 +
95290 +static void constify_start_unit(void *gcc_data, void *user_data)
95291 +{
95292 +// size_t i;
95293 +
95294 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
95295 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
95296 +// sections[i].section = get_section(sections[i].name, 0, NULL);
95297 +
95298 + old_section_type_flags = targetm.section_type_flags;
95299 + targetm.section_type_flags = constify_section_type_flags;
95300 +}
95301 +
95302 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95303 +{
95304 + const char * const plugin_name = plugin_info->base_name;
95305 + const int argc = plugin_info->argc;
95306 + const struct plugin_argument * const argv = plugin_info->argv;
95307 + int i;
95308 + bool constify = true;
95309 +
95310 + struct register_pass_info local_variable_pass_info = {
95311 + .pass = &pass_local_variable.pass,
95312 + .reference_pass_name = "ssa",
95313 + .ref_pass_instance_number = 1,
95314 + .pos_op = PASS_POS_INSERT_BEFORE
95315 + };
95316 +
95317 + if (!plugin_default_version_check(version, &gcc_version)) {
95318 + error(G_("incompatible gcc/plugin versions"));
95319 + return 1;
95320 + }
95321 +
95322 + for (i = 0; i < argc; ++i) {
95323 + if (!(strcmp(argv[i].key, "no-constify"))) {
95324 + constify = false;
95325 + continue;
95326 + }
95327 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95328 + }
95329 +
95330 + if (strcmp(lang_hooks.name, "GNU C")) {
95331 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
95332 + constify = false;
95333 + }
95334 +
95335 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
95336 + if (constify) {
95337 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
95338 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
95339 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
95340 + }
95341 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95342 +
95343 + return 0;
95344 +}
95345 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
95346 new file mode 100644
95347 index 0000000..e518932
95348 --- /dev/null
95349 +++ b/tools/gcc/generate_size_overflow_hash.sh
95350 @@ -0,0 +1,94 @@
95351 +#!/bin/bash
95352 +
95353 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
95354 +
95355 +header1="size_overflow_hash.h"
95356 +database="size_overflow_hash.data"
95357 +n=65536
95358 +
95359 +usage() {
95360 +cat <<EOF
95361 +usage: $0 options
95362 +OPTIONS:
95363 + -h|--help help
95364 + -o header file
95365 + -d database file
95366 + -n hash array size
95367 +EOF
95368 + return 0
95369 +}
95370 +
95371 +while true
95372 +do
95373 + case "$1" in
95374 + -h|--help) usage && exit 0;;
95375 + -n) n=$2; shift 2;;
95376 + -o) header1="$2"; shift 2;;
95377 + -d) database="$2"; shift 2;;
95378 + --) shift 1; break ;;
95379 + *) break ;;
95380 + esac
95381 +done
95382 +
95383 +create_defines() {
95384 + for i in `seq 0 31`
95385 + do
95386 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
95387 + done
95388 + echo >> "$header1"
95389 +}
95390 +
95391 +create_structs() {
95392 + rm -f "$header1"
95393 +
95394 + create_defines
95395 +
95396 + cat "$database" | while read data
95397 + do
95398 + data_array=($data)
95399 + struct_hash_name="${data_array[0]}"
95400 + funcn="${data_array[1]}"
95401 + params="${data_array[2]}"
95402 + next="${data_array[4]}"
95403 +
95404 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
95405 +
95406 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
95407 + echo -en "\t.param\t= " >> "$header1"
95408 + line=
95409 + for param_num in ${params//-/ };
95410 + do
95411 + line="${line}PARAM"$param_num"|"
95412 + done
95413 +
95414 + echo -e "${line%?},\n};\n" >> "$header1"
95415 + done
95416 +}
95417 +
95418 +create_headers() {
95419 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
95420 +}
95421 +
95422 +create_array_elements() {
95423 + index=0
95424 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
95425 + do
95426 + data_array=($data)
95427 + i="${data_array[3]}"
95428 + hash="${data_array[0]}"
95429 + while [[ $index -lt $i ]]
95430 + do
95431 + echo -e "\t["$index"]\t= NULL," >> "$header1"
95432 + index=$(($index + 1))
95433 + done
95434 + index=$(($index + 1))
95435 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
95436 + done
95437 + echo '};' >> $header1
95438 +}
95439 +
95440 +create_structs
95441 +create_headers
95442 +create_array_elements
95443 +
95444 +exit 0
95445 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95446 new file mode 100644
95447 index 0000000..568b360
95448 --- /dev/null
95449 +++ b/tools/gcc/kallocstat_plugin.c
95450 @@ -0,0 +1,170 @@
95451 +/*
95452 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95453 + * Licensed under the GPL v2
95454 + *
95455 + * Note: the choice of the license means that the compilation process is
95456 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95457 + * but for the kernel it doesn't matter since it doesn't link against
95458 + * any of the gcc libraries
95459 + *
95460 + * gcc plugin to find the distribution of k*alloc sizes
95461 + *
95462 + * TODO:
95463 + *
95464 + * BUGS:
95465 + * - none known
95466 + */
95467 +#include "gcc-plugin.h"
95468 +#include "config.h"
95469 +#include "system.h"
95470 +#include "coretypes.h"
95471 +#include "tree.h"
95472 +#include "tree-pass.h"
95473 +#include "flags.h"
95474 +#include "intl.h"
95475 +#include "toplev.h"
95476 +#include "plugin.h"
95477 +//#include "expr.h" where are you...
95478 +#include "diagnostic.h"
95479 +#include "plugin-version.h"
95480 +#include "tm.h"
95481 +#include "function.h"
95482 +#include "basic-block.h"
95483 +#include "gimple.h"
95484 +#include "rtl.h"
95485 +#include "emit-rtl.h"
95486 +
95487 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95488 +
95489 +int plugin_is_GPL_compatible;
95490 +
95491 +static const char * const kalloc_functions[] = {
95492 + "__kmalloc",
95493 + "kmalloc",
95494 + "kmalloc_large",
95495 + "kmalloc_node",
95496 + "kmalloc_order",
95497 + "kmalloc_order_trace",
95498 + "kmalloc_slab",
95499 + "kzalloc",
95500 + "kzalloc_node",
95501 +};
95502 +
95503 +static struct plugin_info kallocstat_plugin_info = {
95504 + .version = "201302112000",
95505 +};
95506 +
95507 +static unsigned int execute_kallocstat(void);
95508 +
95509 +static struct gimple_opt_pass kallocstat_pass = {
95510 + .pass = {
95511 + .type = GIMPLE_PASS,
95512 + .name = "kallocstat",
95513 +#if BUILDING_GCC_VERSION >= 4008
95514 + .optinfo_flags = OPTGROUP_NONE,
95515 +#endif
95516 + .gate = NULL,
95517 + .execute = execute_kallocstat,
95518 + .sub = NULL,
95519 + .next = NULL,
95520 + .static_pass_number = 0,
95521 + .tv_id = TV_NONE,
95522 + .properties_required = 0,
95523 + .properties_provided = 0,
95524 + .properties_destroyed = 0,
95525 + .todo_flags_start = 0,
95526 + .todo_flags_finish = 0
95527 + }
95528 +};
95529 +
95530 +static bool is_kalloc(const char *fnname)
95531 +{
95532 + size_t i;
95533 +
95534 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95535 + if (!strcmp(fnname, kalloc_functions[i]))
95536 + return true;
95537 + return false;
95538 +}
95539 +
95540 +static unsigned int execute_kallocstat(void)
95541 +{
95542 + basic_block bb;
95543 +
95544 + // 1. loop through BBs and GIMPLE statements
95545 + FOR_EACH_BB(bb) {
95546 + gimple_stmt_iterator gsi;
95547 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95548 + // gimple match:
95549 + tree fndecl, size;
95550 + gimple call_stmt;
95551 + const char *fnname;
95552 +
95553 + // is it a call
95554 + call_stmt = gsi_stmt(gsi);
95555 + if (!is_gimple_call(call_stmt))
95556 + continue;
95557 + fndecl = gimple_call_fndecl(call_stmt);
95558 + if (fndecl == NULL_TREE)
95559 + continue;
95560 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95561 + continue;
95562 +
95563 + // is it a call to k*alloc
95564 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95565 + if (!is_kalloc(fnname))
95566 + continue;
95567 +
95568 + // is the size arg the result of a simple const assignment
95569 + size = gimple_call_arg(call_stmt, 0);
95570 + while (true) {
95571 + gimple def_stmt;
95572 + expanded_location xloc;
95573 + size_t size_val;
95574 +
95575 + if (TREE_CODE(size) != SSA_NAME)
95576 + break;
95577 + def_stmt = SSA_NAME_DEF_STMT(size);
95578 + if (!def_stmt || !is_gimple_assign(def_stmt))
95579 + break;
95580 + if (gimple_num_ops(def_stmt) != 2)
95581 + break;
95582 + size = gimple_assign_rhs1(def_stmt);
95583 + if (!TREE_CONSTANT(size))
95584 + continue;
95585 + xloc = expand_location(gimple_location(def_stmt));
95586 + if (!xloc.file)
95587 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95588 + size_val = TREE_INT_CST_LOW(size);
95589 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95590 + break;
95591 + }
95592 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95593 +//debug_tree(gimple_call_fn(call_stmt));
95594 +//print_node(stderr, "pax", fndecl, 4);
95595 + }
95596 + }
95597 +
95598 + return 0;
95599 +}
95600 +
95601 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95602 +{
95603 + const char * const plugin_name = plugin_info->base_name;
95604 + struct register_pass_info kallocstat_pass_info = {
95605 + .pass = &kallocstat_pass.pass,
95606 + .reference_pass_name = "ssa",
95607 + .ref_pass_instance_number = 1,
95608 + .pos_op = PASS_POS_INSERT_AFTER
95609 + };
95610 +
95611 + if (!plugin_default_version_check(version, &gcc_version)) {
95612 + error(G_("incompatible gcc/plugin versions"));
95613 + return 1;
95614 + }
95615 +
95616 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95617 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95618 +
95619 + return 0;
95620 +}
95621 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95622 new file mode 100644
95623 index 0000000..0408e06
95624 --- /dev/null
95625 +++ b/tools/gcc/kernexec_plugin.c
95626 @@ -0,0 +1,465 @@
95627 +/*
95628 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95629 + * Licensed under the GPL v2
95630 + *
95631 + * Note: the choice of the license means that the compilation process is
95632 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95633 + * but for the kernel it doesn't matter since it doesn't link against
95634 + * any of the gcc libraries
95635 + *
95636 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95637 + *
95638 + * TODO:
95639 + *
95640 + * BUGS:
95641 + * - none known
95642 + */
95643 +#include "gcc-plugin.h"
95644 +#include "config.h"
95645 +#include "system.h"
95646 +#include "coretypes.h"
95647 +#include "tree.h"
95648 +#include "tree-pass.h"
95649 +#include "flags.h"
95650 +#include "intl.h"
95651 +#include "toplev.h"
95652 +#include "plugin.h"
95653 +//#include "expr.h" where are you...
95654 +#include "diagnostic.h"
95655 +#include "plugin-version.h"
95656 +#include "tm.h"
95657 +#include "function.h"
95658 +#include "basic-block.h"
95659 +#include "gimple.h"
95660 +#include "rtl.h"
95661 +#include "emit-rtl.h"
95662 +#include "tree-flow.h"
95663 +
95664 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95665 +extern rtx emit_move_insn(rtx x, rtx y);
95666 +
95667 +#if BUILDING_GCC_VERSION <= 4006
95668 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95669 +#endif
95670 +
95671 +#if BUILDING_GCC_VERSION >= 4008
95672 +#define TODO_dump_func 0
95673 +#endif
95674 +
95675 +int plugin_is_GPL_compatible;
95676 +
95677 +static struct plugin_info kernexec_plugin_info = {
95678 + .version = "201302112000",
95679 + .help = "method=[bts|or]\tinstrumentation method\n"
95680 +};
95681 +
95682 +static unsigned int execute_kernexec_reload(void);
95683 +static unsigned int execute_kernexec_fptr(void);
95684 +static unsigned int execute_kernexec_retaddr(void);
95685 +static bool kernexec_cmodel_check(void);
95686 +
95687 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95688 +static void (*kernexec_instrument_retaddr)(rtx);
95689 +
95690 +static struct gimple_opt_pass kernexec_reload_pass = {
95691 + .pass = {
95692 + .type = GIMPLE_PASS,
95693 + .name = "kernexec_reload",
95694 +#if BUILDING_GCC_VERSION >= 4008
95695 + .optinfo_flags = OPTGROUP_NONE,
95696 +#endif
95697 + .gate = kernexec_cmodel_check,
95698 + .execute = execute_kernexec_reload,
95699 + .sub = NULL,
95700 + .next = NULL,
95701 + .static_pass_number = 0,
95702 + .tv_id = TV_NONE,
95703 + .properties_required = 0,
95704 + .properties_provided = 0,
95705 + .properties_destroyed = 0,
95706 + .todo_flags_start = 0,
95707 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95708 + }
95709 +};
95710 +
95711 +static struct gimple_opt_pass kernexec_fptr_pass = {
95712 + .pass = {
95713 + .type = GIMPLE_PASS,
95714 + .name = "kernexec_fptr",
95715 +#if BUILDING_GCC_VERSION >= 4008
95716 + .optinfo_flags = OPTGROUP_NONE,
95717 +#endif
95718 + .gate = kernexec_cmodel_check,
95719 + .execute = execute_kernexec_fptr,
95720 + .sub = NULL,
95721 + .next = NULL,
95722 + .static_pass_number = 0,
95723 + .tv_id = TV_NONE,
95724 + .properties_required = 0,
95725 + .properties_provided = 0,
95726 + .properties_destroyed = 0,
95727 + .todo_flags_start = 0,
95728 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95729 + }
95730 +};
95731 +
95732 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95733 + .pass = {
95734 + .type = RTL_PASS,
95735 + .name = "kernexec_retaddr",
95736 +#if BUILDING_GCC_VERSION >= 4008
95737 + .optinfo_flags = OPTGROUP_NONE,
95738 +#endif
95739 + .gate = kernexec_cmodel_check,
95740 + .execute = execute_kernexec_retaddr,
95741 + .sub = NULL,
95742 + .next = NULL,
95743 + .static_pass_number = 0,
95744 + .tv_id = TV_NONE,
95745 + .properties_required = 0,
95746 + .properties_provided = 0,
95747 + .properties_destroyed = 0,
95748 + .todo_flags_start = 0,
95749 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95750 + }
95751 +};
95752 +
95753 +static bool kernexec_cmodel_check(void)
95754 +{
95755 + tree section;
95756 +
95757 + if (ix86_cmodel != CM_KERNEL)
95758 + return false;
95759 +
95760 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95761 + if (!section || !TREE_VALUE(section))
95762 + return true;
95763 +
95764 + section = TREE_VALUE(TREE_VALUE(section));
95765 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95766 + return true;
95767 +
95768 + return false;
95769 +}
95770 +
95771 +/*
95772 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95773 + */
95774 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95775 +{
95776 + gimple asm_movabs_stmt;
95777 +
95778 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95779 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95780 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95781 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95782 + update_stmt(asm_movabs_stmt);
95783 +}
95784 +
95785 +/*
95786 + * find all asm() stmts that clobber r10 and add a reload of r10
95787 + */
95788 +static unsigned int execute_kernexec_reload(void)
95789 +{
95790 + basic_block bb;
95791 +
95792 + // 1. loop through BBs and GIMPLE statements
95793 + FOR_EACH_BB(bb) {
95794 + gimple_stmt_iterator gsi;
95795 +
95796 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95797 + // gimple match: __asm__ ("" : : : "r10");
95798 + gimple asm_stmt;
95799 + size_t nclobbers;
95800 +
95801 + // is it an asm ...
95802 + asm_stmt = gsi_stmt(gsi);
95803 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95804 + continue;
95805 +
95806 + // ... clobbering r10
95807 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95808 + while (nclobbers--) {
95809 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95810 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95811 + continue;
95812 + kernexec_reload_fptr_mask(&gsi);
95813 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95814 + break;
95815 + }
95816 + }
95817 + }
95818 +
95819 + return 0;
95820 +}
95821 +
95822 +/*
95823 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95824 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95825 + */
95826 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95827 +{
95828 + gimple assign_intptr, assign_new_fptr, call_stmt;
95829 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95830 +
95831 + call_stmt = gsi_stmt(*gsi);
95832 + old_fptr = gimple_call_fn(call_stmt);
95833 +
95834 + // create temporary unsigned long variable used for bitops and cast fptr to it
95835 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95836 +#if BUILDING_GCC_VERSION <= 4007
95837 + add_referenced_var(intptr);
95838 + mark_sym_for_renaming(intptr);
95839 +#endif
95840 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95841 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95842 + update_stmt(assign_intptr);
95843 +
95844 + // apply logical or to temporary unsigned long and bitmask
95845 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95846 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95847 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95848 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95849 + update_stmt(assign_intptr);
95850 +
95851 + // cast temporary unsigned long back to a temporary fptr variable
95852 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95853 +#if BUILDING_GCC_VERSION <= 4007
95854 + add_referenced_var(new_fptr);
95855 + mark_sym_for_renaming(new_fptr);
95856 +#endif
95857 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95858 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95859 + update_stmt(assign_new_fptr);
95860 +
95861 + // replace call stmt fn with the new fptr
95862 + gimple_call_set_fn(call_stmt, new_fptr);
95863 + update_stmt(call_stmt);
95864 +}
95865 +
95866 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95867 +{
95868 + gimple asm_or_stmt, call_stmt;
95869 + tree old_fptr, new_fptr, input, output;
95870 +#if BUILDING_GCC_VERSION <= 4007
95871 + VEC(tree, gc) *inputs = NULL;
95872 + VEC(tree, gc) *outputs = NULL;
95873 +#else
95874 + vec<tree, va_gc> *inputs = NULL;
95875 + vec<tree, va_gc> *outputs = NULL;
95876 +#endif
95877 +
95878 + call_stmt = gsi_stmt(*gsi);
95879 + old_fptr = gimple_call_fn(call_stmt);
95880 +
95881 + // create temporary fptr variable
95882 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95883 +#if BUILDING_GCC_VERSION <= 4007
95884 + add_referenced_var(new_fptr);
95885 + mark_sym_for_renaming(new_fptr);
95886 +#endif
95887 +
95888 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95889 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95890 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95891 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95892 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95893 +#if BUILDING_GCC_VERSION <= 4007
95894 + VEC_safe_push(tree, gc, inputs, input);
95895 + VEC_safe_push(tree, gc, outputs, output);
95896 +#else
95897 + vec_safe_push(inputs, input);
95898 + vec_safe_push(outputs, output);
95899 +#endif
95900 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95901 + gimple_asm_set_volatile(asm_or_stmt, true);
95902 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95903 + update_stmt(asm_or_stmt);
95904 +
95905 + // replace call stmt fn with the new fptr
95906 + gimple_call_set_fn(call_stmt, new_fptr);
95907 + update_stmt(call_stmt);
95908 +}
95909 +
95910 +/*
95911 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95912 + */
95913 +static unsigned int execute_kernexec_fptr(void)
95914 +{
95915 + basic_block bb;
95916 +
95917 + // 1. loop through BBs and GIMPLE statements
95918 + FOR_EACH_BB(bb) {
95919 + gimple_stmt_iterator gsi;
95920 +
95921 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95922 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95923 + tree fn;
95924 + gimple call_stmt;
95925 +
95926 + // is it a call ...
95927 + call_stmt = gsi_stmt(gsi);
95928 + if (!is_gimple_call(call_stmt))
95929 + continue;
95930 + fn = gimple_call_fn(call_stmt);
95931 + if (TREE_CODE(fn) == ADDR_EXPR)
95932 + continue;
95933 + if (TREE_CODE(fn) != SSA_NAME)
95934 + gcc_unreachable();
95935 +
95936 + // ... through a function pointer
95937 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95938 + fn = SSA_NAME_VAR(fn);
95939 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95940 + debug_tree(fn);
95941 + gcc_unreachable();
95942 + }
95943 + }
95944 + fn = TREE_TYPE(fn);
95945 + if (TREE_CODE(fn) != POINTER_TYPE)
95946 + continue;
95947 + fn = TREE_TYPE(fn);
95948 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95949 + continue;
95950 +
95951 + kernexec_instrument_fptr(&gsi);
95952 +
95953 +//debug_tree(gimple_call_fn(call_stmt));
95954 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95955 + }
95956 + }
95957 +
95958 + return 0;
95959 +}
95960 +
95961 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95962 +static void kernexec_instrument_retaddr_bts(rtx insn)
95963 +{
95964 + rtx btsq;
95965 + rtvec argvec, constraintvec, labelvec;
95966 + int line;
95967 +
95968 + // create asm volatile("btsq $63,(%%rsp)":::)
95969 + argvec = rtvec_alloc(0);
95970 + constraintvec = rtvec_alloc(0);
95971 + labelvec = rtvec_alloc(0);
95972 + line = expand_location(RTL_LOCATION(insn)).line;
95973 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95974 + MEM_VOLATILE_P(btsq) = 1;
95975 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95976 + emit_insn_before(btsq, insn);
95977 +}
95978 +
95979 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95980 +static void kernexec_instrument_retaddr_or(rtx insn)
95981 +{
95982 + rtx orq;
95983 + rtvec argvec, constraintvec, labelvec;
95984 + int line;
95985 +
95986 + // create asm volatile("orq %%r10,(%%rsp)":::)
95987 + argvec = rtvec_alloc(0);
95988 + constraintvec = rtvec_alloc(0);
95989 + labelvec = rtvec_alloc(0);
95990 + line = expand_location(RTL_LOCATION(insn)).line;
95991 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95992 + MEM_VOLATILE_P(orq) = 1;
95993 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95994 + emit_insn_before(orq, insn);
95995 +}
95996 +
95997 +/*
95998 + * find all asm level function returns and forcibly set the highest bit of the return address
95999 + */
96000 +static unsigned int execute_kernexec_retaddr(void)
96001 +{
96002 + rtx insn;
96003 +
96004 + // 1. find function returns
96005 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
96006 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
96007 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
96008 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
96009 + rtx body;
96010 +
96011 + // is it a retn
96012 + if (!JUMP_P(insn))
96013 + continue;
96014 + body = PATTERN(insn);
96015 + if (GET_CODE(body) == PARALLEL)
96016 + body = XVECEXP(body, 0, 0);
96017 + if (!ANY_RETURN_P(body))
96018 + continue;
96019 + kernexec_instrument_retaddr(insn);
96020 + }
96021 +
96022 +// print_simple_rtl(stderr, get_insns());
96023 +// print_rtl(stderr, get_insns());
96024 +
96025 + return 0;
96026 +}
96027 +
96028 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96029 +{
96030 + const char * const plugin_name = plugin_info->base_name;
96031 + const int argc = plugin_info->argc;
96032 + const struct plugin_argument * const argv = plugin_info->argv;
96033 + int i;
96034 + struct register_pass_info kernexec_reload_pass_info = {
96035 + .pass = &kernexec_reload_pass.pass,
96036 + .reference_pass_name = "ssa",
96037 + .ref_pass_instance_number = 1,
96038 + .pos_op = PASS_POS_INSERT_AFTER
96039 + };
96040 + struct register_pass_info kernexec_fptr_pass_info = {
96041 + .pass = &kernexec_fptr_pass.pass,
96042 + .reference_pass_name = "ssa",
96043 + .ref_pass_instance_number = 1,
96044 + .pos_op = PASS_POS_INSERT_AFTER
96045 + };
96046 + struct register_pass_info kernexec_retaddr_pass_info = {
96047 + .pass = &kernexec_retaddr_pass.pass,
96048 + .reference_pass_name = "pro_and_epilogue",
96049 + .ref_pass_instance_number = 1,
96050 + .pos_op = PASS_POS_INSERT_AFTER
96051 + };
96052 +
96053 + if (!plugin_default_version_check(version, &gcc_version)) {
96054 + error(G_("incompatible gcc/plugin versions"));
96055 + return 1;
96056 + }
96057 +
96058 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
96059 +
96060 + if (TARGET_64BIT == 0)
96061 + return 0;
96062 +
96063 + for (i = 0; i < argc; ++i) {
96064 + if (!strcmp(argv[i].key, "method")) {
96065 + if (!argv[i].value) {
96066 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96067 + continue;
96068 + }
96069 + if (!strcmp(argv[i].value, "bts")) {
96070 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
96071 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
96072 + } else if (!strcmp(argv[i].value, "or")) {
96073 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
96074 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
96075 + fix_register("r10", 1, 1);
96076 + } else
96077 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96078 + continue;
96079 + }
96080 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96081 + }
96082 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
96083 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
96084 +
96085 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
96086 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
96087 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
96088 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
96089 +
96090 + return 0;
96091 +}
96092 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
96093 new file mode 100644
96094 index 0000000..b5395ba
96095 --- /dev/null
96096 +++ b/tools/gcc/latent_entropy_plugin.c
96097 @@ -0,0 +1,327 @@
96098 +/*
96099 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
96100 + * Licensed under the GPL v2
96101 + *
96102 + * Note: the choice of the license means that the compilation process is
96103 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96104 + * but for the kernel it doesn't matter since it doesn't link against
96105 + * any of the gcc libraries
96106 + *
96107 + * gcc plugin to help generate a little bit of entropy from program state,
96108 + * used during boot in the kernel
96109 + *
96110 + * TODO:
96111 + * - add ipa pass to identify not explicitly marked candidate functions
96112 + * - mix in more program state (function arguments/return values, loop variables, etc)
96113 + * - more instrumentation control via attribute parameters
96114 + *
96115 + * BUGS:
96116 + * - LTO needs -flto-partition=none for now
96117 + */
96118 +#include "gcc-plugin.h"
96119 +#include "config.h"
96120 +#include "system.h"
96121 +#include "coretypes.h"
96122 +#include "tree.h"
96123 +#include "tree-pass.h"
96124 +#include "flags.h"
96125 +#include "intl.h"
96126 +#include "toplev.h"
96127 +#include "plugin.h"
96128 +//#include "expr.h" where are you...
96129 +#include "diagnostic.h"
96130 +#include "plugin-version.h"
96131 +#include "tm.h"
96132 +#include "function.h"
96133 +#include "basic-block.h"
96134 +#include "gimple.h"
96135 +#include "rtl.h"
96136 +#include "emit-rtl.h"
96137 +#include "tree-flow.h"
96138 +#include "langhooks.h"
96139 +
96140 +#if BUILDING_GCC_VERSION >= 4008
96141 +#define TODO_dump_func 0
96142 +#endif
96143 +
96144 +int plugin_is_GPL_compatible;
96145 +
96146 +static tree latent_entropy_decl;
96147 +
96148 +static struct plugin_info latent_entropy_plugin_info = {
96149 + .version = "201303102320",
96150 + .help = NULL
96151 +};
96152 +
96153 +static unsigned int execute_latent_entropy(void);
96154 +static bool gate_latent_entropy(void);
96155 +
96156 +static struct gimple_opt_pass latent_entropy_pass = {
96157 + .pass = {
96158 + .type = GIMPLE_PASS,
96159 + .name = "latent_entropy",
96160 +#if BUILDING_GCC_VERSION >= 4008
96161 + .optinfo_flags = OPTGROUP_NONE,
96162 +#endif
96163 + .gate = gate_latent_entropy,
96164 + .execute = execute_latent_entropy,
96165 + .sub = NULL,
96166 + .next = NULL,
96167 + .static_pass_number = 0,
96168 + .tv_id = TV_NONE,
96169 + .properties_required = PROP_gimple_leh | PROP_cfg,
96170 + .properties_provided = 0,
96171 + .properties_destroyed = 0,
96172 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96173 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96174 + }
96175 +};
96176 +
96177 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
96178 +{
96179 + if (TREE_CODE(*node) != FUNCTION_DECL) {
96180 + *no_add_attrs = true;
96181 + error("%qE attribute only applies to functions", name);
96182 + }
96183 + return NULL_TREE;
96184 +}
96185 +
96186 +static struct attribute_spec latent_entropy_attr = {
96187 + .name = "latent_entropy",
96188 + .min_length = 0,
96189 + .max_length = 0,
96190 + .decl_required = true,
96191 + .type_required = false,
96192 + .function_type_required = false,
96193 + .handler = handle_latent_entropy_attribute,
96194 +#if BUILDING_GCC_VERSION >= 4007
96195 + .affects_type_identity = false
96196 +#endif
96197 +};
96198 +
96199 +static void register_attributes(void *event_data, void *data)
96200 +{
96201 + register_attribute(&latent_entropy_attr);
96202 +}
96203 +
96204 +static bool gate_latent_entropy(void)
96205 +{
96206 + tree latent_entropy_attr;
96207 +
96208 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
96209 + return latent_entropy_attr != NULL_TREE;
96210 +}
96211 +
96212 +static unsigned HOST_WIDE_INT seed;
96213 +static unsigned HOST_WIDE_INT get_random_const(void)
96214 +{
96215 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
96216 + return seed;
96217 +}
96218 +
96219 +static enum tree_code get_op(tree *rhs)
96220 +{
96221 + static enum tree_code op;
96222 + unsigned HOST_WIDE_INT random_const;
96223 +
96224 + random_const = get_random_const();
96225 +
96226 + switch (op) {
96227 + case BIT_XOR_EXPR:
96228 + op = PLUS_EXPR;
96229 + break;
96230 +
96231 + case PLUS_EXPR:
96232 + if (rhs) {
96233 + op = LROTATE_EXPR;
96234 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
96235 + break;
96236 + }
96237 +
96238 + case LROTATE_EXPR:
96239 + default:
96240 + op = BIT_XOR_EXPR;
96241 + break;
96242 + }
96243 + if (rhs)
96244 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
96245 + return op;
96246 +}
96247 +
96248 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
96249 +{
96250 + gimple_stmt_iterator gsi;
96251 + gimple assign;
96252 + tree addxorrol, rhs;
96253 + enum tree_code op;
96254 +
96255 + op = get_op(&rhs);
96256 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
96257 + assign = gimple_build_assign(local_entropy, addxorrol);
96258 +#if BUILDING_GCC_VERSION <= 4007
96259 + find_referenced_vars_in(assign);
96260 +#endif
96261 +//debug_bb(bb);
96262 + gsi = gsi_after_labels(bb);
96263 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
96264 + update_stmt(assign);
96265 +}
96266 +
96267 +static void perturb_latent_entropy(basic_block bb, tree rhs)
96268 +{
96269 + gimple_stmt_iterator gsi;
96270 + gimple assign;
96271 + tree addxorrol, temp;
96272 +
96273 + // 1. create temporary copy of latent_entropy
96274 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
96275 +#if BUILDING_GCC_VERSION <= 4007
96276 + add_referenced_var(temp);
96277 + mark_sym_for_renaming(temp);
96278 +#endif
96279 +
96280 + // 2. read...
96281 + assign = gimple_build_assign(temp, latent_entropy_decl);
96282 +#if BUILDING_GCC_VERSION <= 4007
96283 + find_referenced_vars_in(assign);
96284 +#endif
96285 + gsi = gsi_after_labels(bb);
96286 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96287 + update_stmt(assign);
96288 +
96289 + // 3. ...modify...
96290 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
96291 + assign = gimple_build_assign(temp, addxorrol);
96292 +#if BUILDING_GCC_VERSION <= 4007
96293 + find_referenced_vars_in(assign);
96294 +#endif
96295 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96296 + update_stmt(assign);
96297 +
96298 + // 4. ...write latent_entropy
96299 + assign = gimple_build_assign(latent_entropy_decl, temp);
96300 +#if BUILDING_GCC_VERSION <= 4007
96301 + find_referenced_vars_in(assign);
96302 +#endif
96303 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96304 + update_stmt(assign);
96305 +}
96306 +
96307 +static unsigned int execute_latent_entropy(void)
96308 +{
96309 + basic_block bb;
96310 + gimple assign;
96311 + gimple_stmt_iterator gsi;
96312 + tree local_entropy;
96313 +
96314 + if (!latent_entropy_decl) {
96315 + struct varpool_node *node;
96316 +
96317 +#if BUILDING_GCC_VERSION <= 4007
96318 + for (node = varpool_nodes; node; node = node->next) {
96319 + tree var = node->decl;
96320 +#else
96321 + FOR_EACH_VARIABLE(node) {
96322 + tree var = node->symbol.decl;
96323 +#endif
96324 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
96325 + continue;
96326 + latent_entropy_decl = var;
96327 +// debug_tree(var);
96328 + break;
96329 + }
96330 + if (!latent_entropy_decl) {
96331 +// debug_tree(current_function_decl);
96332 + return 0;
96333 + }
96334 + }
96335 +
96336 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
96337 +
96338 + // 1. create local entropy variable
96339 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
96340 +#if BUILDING_GCC_VERSION <= 4007
96341 + add_referenced_var(local_entropy);
96342 + mark_sym_for_renaming(local_entropy);
96343 +#endif
96344 +
96345 + // 2. initialize local entropy variable
96346 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
96347 + if (dom_info_available_p(CDI_DOMINATORS))
96348 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
96349 + gsi = gsi_start_bb(bb);
96350 +
96351 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
96352 +// gimple_set_location(assign, loc);
96353 +#if BUILDING_GCC_VERSION <= 4007
96354 + find_referenced_vars_in(assign);
96355 +#endif
96356 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96357 + update_stmt(assign);
96358 + bb = bb->next_bb;
96359 +
96360 + // 3. instrument each BB with an operation on the local entropy variable
96361 + while (bb != EXIT_BLOCK_PTR) {
96362 + perturb_local_entropy(bb, local_entropy);
96363 + bb = bb->next_bb;
96364 + };
96365 +
96366 + // 4. mix local entropy into the global entropy variable
96367 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
96368 + return 0;
96369 +}
96370 +
96371 +static void start_unit_callback(void *gcc_data, void *user_data)
96372 +{
96373 + tree latent_entropy_type;
96374 +
96375 +#if BUILDING_GCC_VERSION >= 4007
96376 + seed = get_random_seed(false);
96377 +#else
96378 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
96379 + seed *= seed;
96380 +#endif
96381 +
96382 + if (in_lto_p)
96383 + return;
96384 +
96385 + // extern volatile u64 latent_entropy
96386 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
96387 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
96388 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
96389 +
96390 + TREE_STATIC(latent_entropy_decl) = 1;
96391 + TREE_PUBLIC(latent_entropy_decl) = 1;
96392 + TREE_USED(latent_entropy_decl) = 1;
96393 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
96394 + DECL_EXTERNAL(latent_entropy_decl) = 1;
96395 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
96396 + DECL_INITIAL(latent_entropy_decl) = NULL;
96397 + lang_hooks.decls.pushdecl(latent_entropy_decl);
96398 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
96399 +// varpool_finalize_decl(latent_entropy_decl);
96400 +// varpool_mark_needed_node(latent_entropy_decl);
96401 +}
96402 +
96403 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96404 +{
96405 + const char * const plugin_name = plugin_info->base_name;
96406 + struct register_pass_info latent_entropy_pass_info = {
96407 + .pass = &latent_entropy_pass.pass,
96408 + .reference_pass_name = "optimized",
96409 + .ref_pass_instance_number = 1,
96410 + .pos_op = PASS_POS_INSERT_BEFORE
96411 + };
96412 +
96413 + if (!plugin_default_version_check(version, &gcc_version)) {
96414 + error(G_("incompatible gcc/plugin versions"));
96415 + return 1;
96416 + }
96417 +
96418 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
96419 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
96420 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
96421 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96422 +
96423 + return 0;
96424 +}
96425 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
96426 new file mode 100644
96427 index 0000000..7982a0c
96428 --- /dev/null
96429 +++ b/tools/gcc/size_overflow_hash.data
96430 @@ -0,0 +1,5893 @@
96431 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
96432 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
96433 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
96434 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
96435 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
96436 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
96437 +padzero_55 padzero 1 55 &sel_read_policyvers_55
96438 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
96439 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
96440 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
96441 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96442 +load_msg_95 load_msg 2 95 NULL
96443 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96444 +init_q_132 init_q 4 132 NULL
96445 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96446 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96447 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96448 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96449 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96450 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96451 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96452 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96453 +br_port_info_size_268 br_port_info_size 0 268 NULL
96454 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96455 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96456 +syslog_print_307 syslog_print 2 307 NULL
96457 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96458 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96459 +next_node_allowed_318 next_node_allowed 1 318 NULL
96460 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96461 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96462 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96463 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96464 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96465 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96466 +pidlist_resize_496 pidlist_resize 2 496 NULL
96467 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96468 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96469 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96470 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
96471 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96472 +dle_count_543 dle_count 0 543 NULL
96473 +devres_alloc_551 devres_alloc 2 551 NULL
96474 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96475 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96476 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96477 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96478 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96479 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96480 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
96481 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96482 +isp1760_register_628 isp1760_register 1-2 628 NULL
96483 +clone_split_bio_633 clone_split_bio 6 633 NULL
96484 +remap_to_cache_640 remap_to_cache 3 640 NULL
96485 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96486 +unlink_queued_645 unlink_queued 3-4 645 NULL
96487 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96488 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96489 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96490 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96491 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96492 +disk_max_parts_719 disk_max_parts 0 719 NULL
96493 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96494 +dvb_video_write_754 dvb_video_write 3 754 NULL
96495 +if_writecmd_815 if_writecmd 2 815 NULL
96496 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96497 +read_fifo_826 read_fifo 3 826 NULL
96498 +um_idi_read_850 um_idi_read 3 850 NULL
96499 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96500 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96501 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96502 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96503 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96504 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96505 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
96506 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
96507 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96508 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
96509 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
96510 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
96511 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96512 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96513 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96514 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96515 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96516 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96517 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96518 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96519 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96520 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
96521 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96522 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96523 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96524 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96525 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96526 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96527 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96528 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96529 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96530 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96531 +nested_get_page_1252 nested_get_page 2 1252 NULL
96532 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96533 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96534 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96535 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96536 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96537 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
96538 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96539 +ffs_1322 ffs 0 1322 NULL
96540 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96541 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96542 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96543 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96544 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96545 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96546 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
96547 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96548 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96549 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96550 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96551 +zone_page_state_1393 zone_page_state 0 1393 NULL
96552 +file_read_actor_1401 file_read_actor 4 1401 NULL
96553 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
96554 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96555 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96556 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96557 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96558 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96559 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96560 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
96561 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96562 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96563 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96564 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96565 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96566 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96567 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96568 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96569 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96570 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96571 +rmap_add_1677 rmap_add 3 1677 NULL
96572 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96573 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96574 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96575 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96576 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96577 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96578 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96579 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96580 +cosa_write_1774 cosa_write 3 1774 NULL
96581 +update_macheader_1775 update_macheader 7 1775 NULL
96582 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96583 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96584 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
96585 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96586 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96587 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96588 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
96589 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96590 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96591 +read_swap_header_1957 read_swap_header 0 1957 NULL
96592 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96593 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96594 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
96595 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96596 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96597 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96598 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96599 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96600 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96601 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96602 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96603 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96604 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96605 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96606 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96607 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96608 +audit_expand_2098 audit_expand 2 2098 NULL
96609 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96610 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96611 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96612 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96613 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96614 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
96615 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96616 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
96617 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
96618 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96619 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96620 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96621 +u32_array_read_2219 u32_array_read 3 2219 NULL
96622 +vhci_write_2224 vhci_write 3 2224 NULL
96623 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96624 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96625 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96626 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96627 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96628 +do_update_counters_2259 do_update_counters 4 2259 NULL
96629 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96630 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96631 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
96632 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96633 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96634 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96635 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96636 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96637 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96638 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96639 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96640 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96641 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96642 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96643 +raid1_size_2419 raid1_size 0-2 2419 NULL
96644 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96645 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96646 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96647 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96648 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
96649 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96650 +update_pmkid_2481 update_pmkid 4 2481 NULL
96651 +wiphy_new_2482 wiphy_new 2 2482 NULL
96652 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96653 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
96654 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96655 +dm_write_2513 dm_write 3 2513 NULL
96656 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96657 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96658 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96659 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
96660 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96661 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96662 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
96663 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96664 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96665 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96666 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96667 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96668 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96669 +__next_cpu_2782 __next_cpu 1 2782 NULL
96670 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
96671 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96672 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
96673 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96674 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96675 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96676 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96677 +mq_map_2871 mq_map 2 2871 NULL
96678 +nla_padlen_2883 nla_padlen 1 2883 NULL
96679 +cmm_write_2896 cmm_write 3 2896 NULL
96680 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96681 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96682 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96683 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96684 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96685 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96686 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96687 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96688 +depth_write_3021 depth_write 3 3021 NULL
96689 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96690 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96691 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96692 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96693 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96694 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
96695 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96696 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96697 +free_coherent_3082 free_coherent 4-2 3082 NULL
96698 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
96699 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
96700 +rb_alloc_3102 rb_alloc 1 3102 NULL
96701 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96702 +print_time_3132 print_time 0 3132 NULL
96703 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96704 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96705 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96706 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96707 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96708 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96709 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96710 +alloc_context_3194 alloc_context 1 3194 NULL
96711 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96712 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96713 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96714 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96715 +key_key_read_3241 key_key_read 3 3241 NULL
96716 +number_3243 number 0 3243 NULL
96717 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96718 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96719 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96720 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96721 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96722 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96723 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96724 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96725 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96726 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96727 +scnprintf_3360 scnprintf 0-2 3360 NULL
96728 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
96729 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96730 +send_stream_3397 send_stream 4 3397 NULL
96731 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96732 +msix_map_region_3411 msix_map_region 3 3411 NULL
96733 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96734 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96735 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96736 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96737 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96738 +map_single_3449 map_single 0-2 3449 NULL
96739 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96740 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96741 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96742 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96743 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96744 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
96745 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96746 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96747 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96748 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96749 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96750 +evtchn_read_3569 evtchn_read 3 3569 NULL
96751 +vc_resize_3585 vc_resize 2-3 3585 NULL
96752 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96753 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96754 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96755 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96756 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96757 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
96758 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96759 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96760 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96761 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96762 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96763 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96764 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96765 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96766 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96767 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96768 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96769 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96770 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96771 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96772 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96773 +get_fd_set_3866 get_fd_set 1 3866 NULL
96774 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96775 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96776 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96777 +nvram_write_3894 nvram_write 3 3894 NULL
96778 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96779 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96780 +vcs_write_3910 vcs_write 3 3910 NULL
96781 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96782 +do_add_counters_3992 do_add_counters 3 3992 NULL
96783 +userspace_status_4004 userspace_status 4 4004 NULL
96784 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96785 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96786 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96787 +mm_populate_4016 mm_populate 1 4016 NULL
96788 +blk_end_request_4024 blk_end_request 3 4024 NULL
96789 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96790 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96791 +read_file_queues_4078 read_file_queues 3 4078 NULL
96792 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96793 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96794 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
96795 +tm6000_read_4151 tm6000_read 3 4151 NULL
96796 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96797 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96798 +get_alua_req_4166 get_alua_req 3 4166 NULL
96799 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96800 +read_file_bool_4180 read_file_bool 3 4180 NULL
96801 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96802 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96803 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96804 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
96805 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
96806 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96807 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96808 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
96809 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96810 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96811 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96812 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96813 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96814 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96815 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96816 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96817 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96818 +memparse_4444 memparse 0 4444 NULL
96819 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96820 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96821 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96822 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96823 +set_link_security_4502 set_link_security 4 4502 NULL
96824 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
96825 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
96826 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96827 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96828 +tty_register_device_4544 tty_register_device 2 4544 NULL
96829 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96830 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96831 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96832 +bch_alloc_4593 bch_alloc 1 4593 NULL
96833 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
96834 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96835 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96836 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96837 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96838 +kone_receive_4690 kone_receive 4 4690 NULL
96839 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96840 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96841 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96842 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96843 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96844 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
96845 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
96846 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96847 +create_subvol_4791 create_subvol 4 4791 NULL
96848 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96849 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96850 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96851 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96852 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96853 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96854 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96855 +sys_ipc_4889 sys_ipc 3 4889 NULL
96856 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96857 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96858 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96859 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96860 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96861 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96862 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96863 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96864 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96865 +do_mincore_5018 do_mincore 0-1 5018 NULL
96866 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96867 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96868 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96869 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96870 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96871 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96872 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96873 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96874 +sound_write_5102 sound_write 3 5102 NULL
96875 +clear_dirty_5105 clear_dirty 3 5105 NULL
96876 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96877 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96878 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96879 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96880 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96881 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96882 +skb_network_header_5203 skb_network_header 0 5203 NULL
96883 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96884 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96885 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96886 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96887 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96888 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96889 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
96890 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
96891 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
96892 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
96893 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96894 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96895 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96896 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96897 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
96898 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96899 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96900 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96901 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96902 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96903 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96904 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96905 +tty_write_5494 tty_write 3 5494 NULL
96906 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96907 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96908 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96909 +spidev_message_5518 spidev_message 3 5518 NULL
96910 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96911 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96912 +le_readq_5557 le_readq 0 5557 NULL
96913 +inw_5558 inw 0 5558 NULL
96914 +fir16_create_5574 fir16_create 3 5574 NULL
96915 +bioset_create_5580 bioset_create 1 5580 NULL
96916 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96917 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96918 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96919 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96920 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96921 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96922 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96923 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96924 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
96925 +get_arg_5694 get_arg 3 5694 NULL
96926 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96927 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
96928 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96929 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96930 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96931 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96932 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96933 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96934 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96935 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96936 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96937 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96938 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96939 +setup_req_5848 setup_req 3 5848 NULL
96940 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96941 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96942 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96943 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
96944 +port_show_regs_5904 port_show_regs 3 5904 NULL
96945 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96946 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96947 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96948 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96949 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96950 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96951 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96952 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96953 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96954 +native_pte_val_5978 native_pte_val 0 5978 NULL
96955 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96956 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96957 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96958 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96959 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96960 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96961 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96962 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96963 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96964 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96965 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96966 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
96967 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
96968 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96969 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96970 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96971 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96972 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96973 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96974 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96975 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
96976 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96977 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96978 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
96979 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96980 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96981 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96982 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
96983 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96984 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96985 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96986 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96987 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
96988 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
96989 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
96990 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
96991 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96992 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
96993 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96994 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96995 +mei_read_6507 mei_read 3 6507 NULL
96996 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96997 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96998 +wdm_read_6549 wdm_read 3 6549 NULL
96999 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
97000 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
97001 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
97002 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
97003 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
97004 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
97005 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
97006 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
97007 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
97008 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
97009 +mpeg_read_6708 mpeg_read 3 6708 NULL
97010 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
97011 +video_proc_write_6724 video_proc_write 3 6724 NULL
97012 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
97013 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
97014 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
97015 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
97016 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
97017 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
97018 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
97019 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
97020 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
97021 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
97022 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
97023 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
97024 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
97025 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
97026 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
97027 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
97028 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
97029 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
97030 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
97031 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
97032 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
97033 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
97034 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
97035 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
97036 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
97037 +request_key_async_6990 request_key_async 4 6990 NULL
97038 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
97039 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
97040 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
97041 +wimax_msg_7030 wimax_msg 4 7030 NULL
97042 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
97043 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
97044 +event_enable_read_7074 event_enable_read 3 7074 NULL
97045 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
97046 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
97047 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
97048 +check_header_7108 check_header 0 7108 NULL
97049 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
97050 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
97051 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
97052 +get_param_h_7247 get_param_h 0 7247 NULL
97053 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
97054 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
97055 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
97056 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
97057 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
97058 +mgmt_control_7349 mgmt_control 3 7349 NULL
97059 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
97060 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
97061 +hweight_long_7388 hweight_long 0-1 7388 NULL
97062 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
97063 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
97064 +readb_7401 readb 0 7401 NULL
97065 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
97066 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
97067 +numa_emulation_7466 numa_emulation 2 7466 NULL
97068 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
97069 +garp_request_join_7471 garp_request_join 4 7471 NULL
97070 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
97071 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
97072 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
97073 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
97074 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
97075 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
97076 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
97077 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
97078 +groups_alloc_7614 groups_alloc 1 7614 NULL
97079 +sg_virt_7616 sg_virt 0 7616 NULL
97080 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
97081 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
97082 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
97083 +dev_write_7708 dev_write 3 7708 NULL
97084 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
97085 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
97086 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
97087 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
97088 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
97089 +ioread32be_7773 ioread32be 0 7773 NULL
97090 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
97091 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
97092 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
97093 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
97094 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
97095 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
97096 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
97097 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
97098 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
97099 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
97100 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
97101 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
97102 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
97103 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
97104 +sys_mbind_7990 sys_mbind 5 7990 NULL
97105 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
97106 +vcs_read_8017 vcs_read 3 8017 NULL
97107 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
97108 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
97109 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
97110 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
97111 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
97112 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
97113 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
97114 +venus_lookup_8121 venus_lookup 4 8121 NULL
97115 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
97116 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
97117 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
97118 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
97119 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
97120 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
97121 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
97122 +play_iframe_8219 play_iframe 3 8219 NULL
97123 +create_log_8225 create_log 2 8225 NULL nohasharray
97124 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
97125 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
97126 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
97127 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
97128 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
97129 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
97130 +init_cdev_8274 init_cdev 1 8274 NULL
97131 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
97132 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
97133 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
97134 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
97135 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
97136 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
97137 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
97138 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
97139 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
97140 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
97141 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
97142 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
97143 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
97144 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
97145 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
97146 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
97147 +dev_config_8506 dev_config 3 8506 NULL
97148 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
97149 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
97150 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
97151 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
97152 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
97153 +profile_remove_8556 profile_remove 3 8556 NULL
97154 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
97155 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
97156 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
97157 +tower_write_8580 tower_write 3 8580 NULL
97158 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
97159 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
97160 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
97161 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
97162 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
97163 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
97164 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
97165 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
97166 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
97167 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
97168 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
97169 +arcfb_write_8702 arcfb_write 3 8702 NULL
97170 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
97171 +init_header_8703 init_header 0 8703 &i_size_read_8703
97172 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
97173 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
97174 +f_dupfd_8730 f_dupfd 1 8730 NULL
97175 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
97176 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
97177 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
97178 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
97179 +sys_prctl_8766 sys_prctl 4 8766 NULL
97180 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
97181 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
97182 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
97183 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
97184 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
97185 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
97186 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
97187 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
97188 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
97189 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
97190 +clear_bitset_8840 clear_bitset 2 8840 NULL
97191 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
97192 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
97193 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
97194 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
97195 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
97196 +layout_commit_8926 layout_commit 3 8926 NULL
97197 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
97198 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
97199 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
97200 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
97201 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
97202 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
97203 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
97204 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
97205 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
97206 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
97207 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
97208 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
97209 +nla_put_9042 nla_put 3 9042 NULL
97210 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
97211 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
97212 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
97213 +string_9080 string 0 9080 NULL
97214 +create_queues_9088 create_queues 2-3 9088 NULL
97215 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
97216 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
97217 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
97218 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
97219 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
97220 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
97221 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
97222 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
97223 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
97224 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
97225 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
97226 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
97227 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
97228 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
97229 +get_pfn_9207 get_pfn 1 9207 NULL
97230 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
97231 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
97232 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
97233 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
97234 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
97235 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
97236 +flakey_status_9274 flakey_status 5 9274 NULL
97237 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
97238 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
97239 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
97240 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
97241 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
97242 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
97243 +read_9397 read 3 9397 NULL
97244 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
97245 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
97246 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
97247 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
97248 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
97249 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
97250 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
97251 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
97252 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
97253 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
97254 +lp_write_9511 lp_write 3 9511 NULL
97255 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
97256 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
97257 +read_file_dma_9530 read_file_dma 3 9530 NULL
97258 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
97259 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
97260 +fw_node_create_9559 fw_node_create 2 9559 NULL
97261 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
97262 +kobj_map_9566 kobj_map 2-3 9566 NULL
97263 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
97264 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
97265 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
97266 +do_sync_9604 do_sync 1 9604 NULL
97267 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
97268 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
97269 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
97270 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
97271 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
97272 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
97273 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
97274 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
97275 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
97276 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
97277 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
97278 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
97279 +is_hole_9694 is_hole 2 9694 NULL nohasharray
97280 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
97281 +fnb_9703 fnb 2-3 9703 NULL
97282 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
97283 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
97284 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
97285 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
97286 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
97287 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
97288 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
97289 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
97290 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
97291 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
97292 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
97293 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
97294 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
97295 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
97296 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
97297 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
97298 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
97299 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
97300 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
97301 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
97302 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
97303 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
97304 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
97305 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
97306 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
97307 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
97308 +read_file_misc_9948 read_file_misc 3 9948 NULL
97309 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
97310 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
97311 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
97312 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
97313 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
97314 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
97315 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
97316 +handle_request_10024 handle_request 9 10024 NULL
97317 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
97318 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
97319 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
97320 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
97321 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
97322 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
97323 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
97324 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
97325 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
97326 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
97327 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
97328 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
97329 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
97330 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
97331 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
97332 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
97333 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
97334 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
97335 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
97336 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
97337 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
97338 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
97339 +read_emulate_10310 read_emulate 2-4 10310 NULL
97340 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
97341 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
97342 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
97343 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
97344 +get_dump_page_10338 get_dump_page 1 10338 NULL
97345 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
97346 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
97347 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
97348 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
97349 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
97350 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
97351 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
97352 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
97353 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
97354 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
97355 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
97356 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
97357 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
97358 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
97359 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
97360 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
97361 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
97362 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
97363 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
97364 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
97365 +otp_read_10594 otp_read 2-4-5 10594 NULL
97366 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
97367 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
97368 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
97369 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
97370 +parport_write_10669 parport_write 0 10669 NULL
97371 +inl_10708 inl 0 10708 NULL nohasharray
97372 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
97373 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
97374 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
97375 +spi_sync_10731 spi_sync 0 10731 NULL
97376 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
97377 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
97378 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
97379 +sys_syslog_10746 sys_syslog 3 10746 NULL
97380 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
97381 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
97382 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
97383 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
97384 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
97385 +sys_bind_10799 sys_bind 3 10799 NULL
97386 +compat_put_int_10828 compat_put_int 1 10828 NULL
97387 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
97388 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
97389 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
97390 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
97391 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
97392 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
97393 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
97394 +get_scq_10897 get_scq 2 10897 NULL
97395 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
97396 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
97397 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
97398 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
97399 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
97400 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
97401 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
97402 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
97403 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
97404 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
97405 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
97406 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
97407 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
97408 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
97409 +count_argc_11083 count_argc 0 11083 NULL
97410 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
97411 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
97412 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
97413 +page_offset_11120 page_offset 0 11120 NULL
97414 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
97415 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
97416 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
97417 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
97418 +__swab16p_11220 __swab16p 0 11220 NULL
97419 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
97420 +mmap_region_11247 mmap_region 0-2 11247 NULL
97421 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
97422 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
97423 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
97424 +cru_detect_11272 cru_detect 1 11272 NULL
97425 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
97426 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
97427 +construct_key_11329 construct_key 3 11329 NULL nohasharray
97428 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
97429 +next_segment_11330 next_segment 0-2-1 11330 NULL
97430 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
97431 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
97432 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
97433 +sel_write_create_11353 sel_write_create 3 11353 NULL
97434 +handle_unit_11355 handle_unit 0-1 11355 NULL
97435 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
97436 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
97437 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
97438 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
97439 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
97440 +str_to_user_11411 str_to_user 2 11411 NULL
97441 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
97442 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
97443 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
97444 +trace_options_read_11419 trace_options_read 3 11419 NULL
97445 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
97446 +prepare_image_11424 prepare_image 0 11424 NULL
97447 +vring_size_11426 vring_size 0-1-2 11426 NULL
97448 +bttv_read_11432 bttv_read 3 11432 NULL
97449 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97450 +swp_offset_11475 swp_offset 0 11475 NULL
97451 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97452 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97453 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97454 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97455 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97456 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97457 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97458 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97459 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97460 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97461 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97462 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97463 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97464 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97465 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97466 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97467 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97468 +split_11691 split 2 11691 NULL
97469 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97470 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97471 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97472 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97473 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97474 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97475 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97476 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97477 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97478 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
97479 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97480 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97481 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97482 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97483 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97484 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97485 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
97486 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97487 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97488 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97489 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97490 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97491 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97492 +atmel_read16_11981 atmel_read16 0 11981 NULL
97493 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97494 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97495 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97496 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97497 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97498 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97499 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
97500 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97501 +set_powered_12129 set_powered 4 12129 NULL
97502 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97503 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97504 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97505 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97506 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97507 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97508 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97509 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97510 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97511 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97512 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97513 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97514 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97515 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97516 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97517 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
97518 +receive_copy_12216 receive_copy 3 12216 NULL
97519 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97520 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
97521 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
97522 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
97523 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97524 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97525 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97526 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97527 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97528 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97529 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97530 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97531 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97532 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97533 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97534 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
97535 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97536 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97537 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97538 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97539 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97540 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97541 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97542 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97543 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
97544 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97545 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97546 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
97547 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
97548 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97549 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97550 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97551 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97552 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97553 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97554 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97555 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97556 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97557 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97558 +wb_create_12651 wb_create 1 12651 NULL
97559 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97560 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97561 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97562 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97563 +ivtv_write_12721 ivtv_write 3 12721 NULL
97564 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97565 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97566 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97567 +listxattr_12769 listxattr 3 12769 NULL
97568 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97569 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
97570 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97571 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97572 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97573 +readq_12825 readq 0 12825 NULL
97574 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97575 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
97576 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
97577 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97578 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97579 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97580 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97581 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97582 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97583 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97584 +bm_status_write_12964 bm_status_write 3 12964 NULL
97585 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97586 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
97587 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97588 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97589 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97590 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97591 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97592 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97593 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97594 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97595 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97596 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97597 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97598 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97599 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97600 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97601 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97602 +blk_update_request_13146 blk_update_request 3 13146 NULL
97603 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97604 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97605 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
97606 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97607 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97608 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97609 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
97610 +comedi_read_13199 comedi_read 3 13199 NULL
97611 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97612 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97613 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97614 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
97615 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97616 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
97617 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
97618 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97619 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97620 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97621 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
97622 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97623 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97624 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97625 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97626 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97627 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
97628 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97629 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
97630 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
97631 +cache_ctr_13364 cache_ctr 2 13364 NULL
97632 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97633 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97634 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97635 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97636 +sky2_receive_13407 sky2_receive 2 13407 NULL
97637 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97638 +keyring_read_13438 keyring_read 3 13438 NULL
97639 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97640 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97641 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
97642 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97643 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97644 +core_status_13515 core_status 4 13515 NULL
97645 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97646 +bm_init_13529 bm_init 2 13529 NULL
97647 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
97648 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97649 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97650 +sys_madvise_13569 sys_madvise 1 13569 NULL
97651 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97652 +cache_write_13589 cache_write 3 13589 NULL
97653 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97654 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97655 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97656 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97657 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97658 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
97659 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97660 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97661 +packet_snd_13634 packet_snd 3 13634 NULL
97662 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97663 +cache_downcall_13666 cache_downcall 3 13666 NULL
97664 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97665 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97666 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97667 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97668 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97669 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97670 +random_read_13815 random_read 3 13815 NULL
97671 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97672 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97673 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97674 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97675 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
97676 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97677 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97678 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97679 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97680 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97681 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97682 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97683 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97684 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97685 +com90xx_found_13974 com90xx_found 3 13974 NULL
97686 +qcam_read_13977 qcam_read 3 13977 NULL
97687 +dsp_read_13980 dsp_read 2 13980 NULL
97688 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97689 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97690 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97691 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97692 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97693 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97694 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97695 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97696 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
97697 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97698 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97699 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97700 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97701 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97702 +em_canid_change_14150 em_canid_change 3 14150 NULL
97703 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97704 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97705 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97706 +alloc_async_14208 alloc_async 1 14208 NULL
97707 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97708 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97709 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97710 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
97711 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97712 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
97713 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97714 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97715 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97716 +rr_status_14293 rr_status 5 14293 NULL
97717 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97718 +oo_objects_14319 oo_objects 0 14319 NULL
97719 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97720 +scsi2int_14358 scsi2int 0 14358 NULL
97721 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97722 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97723 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97724 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97725 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97726 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97727 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97728 +block_size_14443 block_size 0 14443 NULL
97729 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97730 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97731 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97732 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97733 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97734 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97735 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97736 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97737 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97738 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97739 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
97740 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
97741 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97742 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
97743 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97744 +dbJoin_14644 dbJoin 0 14644 NULL
97745 +profile_replace_14652 profile_replace 3 14652 NULL
97746 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97747 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97748 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97749 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97750 +get_bio_block_14714 get_bio_block 0 14714 NULL
97751 +vfd_write_14717 vfd_write 3 14717 NULL
97752 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97753 +raid1_resize_14740 raid1_resize 2 14740 NULL
97754 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97755 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97756 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97757 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97758 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97759 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97760 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97761 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97762 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97763 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97764 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
97765 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97766 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97767 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97768 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97769 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97770 +unifi_read_14899 unifi_read 3 14899 NULL
97771 +krealloc_14908 krealloc 2 14908 NULL
97772 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97773 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
97774 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
97775 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97776 +queue_cnt_14951 queue_cnt 0 14951 NULL
97777 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97778 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97779 +setkey_14987 setkey 3 14987 NULL nohasharray
97780 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97781 +vmap_15025 vmap 2 15025 NULL
97782 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97783 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97784 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97785 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97786 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97787 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97788 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97789 +start_port_15124 start_port 0 15124 NULL
97790 +memchr_15126 memchr 0 15126 NULL
97791 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97792 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97793 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97794 +reserve_resources_15194 reserve_resources 3 15194 NULL
97795 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97796 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97797 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97798 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97799 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97800 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97801 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97802 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97803 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97804 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97805 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97806 +ioread16_15342 ioread16 0 15342 NULL
97807 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97808 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97809 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
97810 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97811 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97812 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97813 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97814 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97815 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97816 +get_modalias_15406 get_modalias 2 15406 NULL
97817 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
97818 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97819 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
97820 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97821 +memweight_15450 memweight 2 15450 NULL
97822 +vmalloc_15464 vmalloc 1 15464 NULL
97823 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97824 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97825 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97826 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97827 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97828 +persistent_status_15574 persistent_status 4 15574 NULL
97829 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97830 +vme_user_write_15587 vme_user_write 3 15587 NULL
97831 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97832 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97833 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97834 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97835 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97836 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97837 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97838 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97839 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97840 +fs_path_add_15648 fs_path_add 3 15648 NULL
97841 +xsd_read_15653 xsd_read 3 15653 NULL
97842 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97843 +unix_bind_15668 unix_bind 3 15668 NULL
97844 +dm_read_15674 dm_read 3 15674 NULL
97845 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97846 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97847 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97848 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97849 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97850 +do_test_15766 do_test 1 15766 NULL
97851 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97852 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97853 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97854 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97855 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97856 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97857 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97858 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97859 +table_size_15851 table_size 0-1-2 15851 NULL
97860 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97861 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97862 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97863 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97864 +native_read_msr_15905 native_read_msr 0 15905 NULL
97865 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97866 +power_read_15939 power_read 3 15939 NULL
97867 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97868 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97869 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97870 +frame_alloc_15981 frame_alloc 4 15981 NULL
97871 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97872 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97873 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97874 +got_frame_16028 got_frame 2 16028 NULL
97875 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
97876 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97877 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97878 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97879 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97880 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97881 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97882 +fsm_init_16134 fsm_init 2 16134 NULL
97883 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97884 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97885 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97886 +mapping_level_16188 mapping_level 2 16188 NULL
97887 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97888 +create_table_16213 create_table 2 16213 NULL
97889 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97890 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97891 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
97892 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
97893 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97894 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97895 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97896 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
97897 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97898 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97899 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97900 +account_16283 account 0-2-4 16283 NULL nohasharray
97901 +mirror_status_16283 mirror_status 5 16283 &account_16283
97902 +retry_instruction_16285 retry_instruction 2 16285 NULL
97903 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97904 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97905 +wb_map_16301 wb_map 2 16301 NULL
97906 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97907 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97908 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97909 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97910 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97911 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97912 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97913 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97914 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97915 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97916 +raid10_resize_16537 raid10_resize 2 16537 NULL
97917 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97918 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97919 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97920 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
97921 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
97922 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97923 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97924 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
97925 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97926 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97927 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97928 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97929 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97930 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97931 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97932 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97933 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97934 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97935 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97936 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97937 +st_write_16874 st_write 3 16874 NULL
97938 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97939 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
97940 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97941 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97942 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97943 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97944 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97945 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97946 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97947 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97948 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97949 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97950 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97951 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97952 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97953 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97954 +mac_address_string_17091 mac_address_string 0 17091 NULL
97955 +entry_length_17093 entry_length 0 17093 NULL
97956 +sys_preadv_17100 sys_preadv 3 17100 NULL
97957 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97958 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97959 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97960 +sep_read_17161 sep_read 3 17161 NULL
97961 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97962 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97963 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97964 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97965 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97966 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97967 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97968 +to_oblock_17254 to_oblock 0-1 17254 NULL
97969 +unpack_value_17259 unpack_value 1 17259 NULL
97970 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97971 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97972 +alloc_ep_17269 alloc_ep 1 17269 NULL
97973 +pg_read_17276 pg_read 3 17276 NULL
97974 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97975 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97976 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97977 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97978 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
97979 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97980 +skb_pad_17302 skb_pad 2 17302 NULL
97981 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97982 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97983 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97984 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97985 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97986 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
97987 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97988 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97989 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97990 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97991 +compat_cmd_17465 compat_cmd 2 17465 NULL
97992 +probe_bios_17467 probe_bios 1 17467 NULL
97993 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97994 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97995 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97996 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97997 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97998 +copy_from_user_17559 copy_from_user 3 17559 NULL
97999 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
98000 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
98001 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
98002 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
98003 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
98004 +osst_execute_17607 osst_execute 7-6 17607 NULL
98005 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
98006 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
98007 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
98008 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
98009 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
98010 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
98011 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
98012 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
98013 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
98014 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
98015 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
98016 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
98017 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
98018 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
98019 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
98020 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
98021 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
98022 +count_leafs_17842 count_leafs 0 17842 NULL
98023 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
98024 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
98025 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
98026 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
98027 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
98028 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
98029 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
98030 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
98031 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
98032 +recover_head_17904 recover_head 3 17904 NULL
98033 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
98034 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
98035 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
98036 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
98037 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
98038 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
98039 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
98040 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
98041 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
98042 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
98043 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
98044 +fill_read_18019 fill_read 0 18019 NULL
98045 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
98046 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
98047 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
98048 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
98049 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
98050 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
98051 +packet_came_18072 packet_came 3 18072 NULL
98052 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
98053 +get_vm_area_18080 get_vm_area 1 18080 NULL
98054 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
98055 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
98056 +svc_getnl_18120 svc_getnl 0 18120 NULL
98057 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
98058 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
98059 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
98060 +_has_tag_18169 _has_tag 2 18169 NULL
98061 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
98062 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
98063 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
98064 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
98065 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
98066 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
98067 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
98068 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
98069 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
98070 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
98071 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
98072 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
98073 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
98074 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
98075 +um_idi_write_18293 um_idi_write 3 18293 NULL
98076 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
98077 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
98078 +vga_r_18310 vga_r 0 18310 NULL
98079 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
98080 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
98081 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
98082 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
98083 +ep_io_18367 ep_io 0 18367 NULL
98084 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
98085 +__video_register_device_18399 __video_register_device 3 18399 NULL
98086 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
98087 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
98088 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
98089 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
98090 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
98091 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
98092 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
98093 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
98094 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
98095 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
98096 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
98097 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
98098 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
98099 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
98100 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
98101 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
98102 +debug_output_18575 debug_output 3 18575 NULL
98103 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
98104 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
98105 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
98106 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
98107 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
98108 +from_buffer_18625 from_buffer 3 18625 NULL
98109 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
98110 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
98111 +unmap_page_18665 unmap_page 2-3 18665 NULL
98112 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
98113 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
98114 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
98115 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
98116 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
98117 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
98118 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
98119 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
98120 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
98121 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
98122 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
98123 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
98124 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
98125 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
98126 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
98127 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
98128 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
98129 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
98130 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
98131 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
98132 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
98133 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
98134 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
98135 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
98136 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
98137 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
98138 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
98139 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
98140 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
98141 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
98142 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
98143 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
98144 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
98145 +huge_page_size_19008 huge_page_size 0 19008 NULL
98146 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
98147 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
98148 +revalidate_19043 revalidate 2 19043 NULL
98149 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
98150 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
98151 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
98152 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
98153 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
98154 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
98155 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
98156 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
98157 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
98158 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
98159 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
98160 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
98161 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
98162 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
98163 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
98164 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
98165 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
98166 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
98167 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
98168 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
98169 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
98170 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
98171 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
98172 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
98173 +qc_capture_19298 qc_capture 3 19298 NULL
98174 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
98175 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
98176 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
98177 +debug_read_19322 debug_read 3 19322 NULL
98178 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
98179 +read_zero_19366 read_zero 3 19366 NULL
98180 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
98181 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
98182 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
98183 +__phys_addr_19434 __phys_addr 0 19434 NULL
98184 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
98185 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
98186 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
98187 +sky2_read16_19475 sky2_read16 0 19475 NULL
98188 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
98189 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
98190 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
98191 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
98192 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
98193 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
98194 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
98195 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
98196 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
98197 +nfsd_read_19568 nfsd_read 5 19568 NULL
98198 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
98199 +bm_status_read_19583 bm_status_read 3 19583 NULL
98200 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
98201 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
98202 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
98203 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
98204 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
98205 +bio_detain_19690 bio_detain 2 19690 NULL
98206 +read_reg_19723 read_reg 0 19723 NULL
98207 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
98208 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
98209 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
98210 +p9_client_read_19750 p9_client_read 5 19750 NULL
98211 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
98212 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
98213 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
98214 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
98215 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
98216 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
98217 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
98218 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
98219 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
98220 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
98221 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
98222 +__nla_put_19857 __nla_put 3 19857 NULL
98223 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
98224 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
98225 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
98226 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
98227 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
98228 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
98229 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
98230 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
98231 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
98232 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
98233 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
98234 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
98235 +team_options_register_20091 team_options_register 3 20091 NULL
98236 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
98237 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
98238 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
98239 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
98240 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
98241 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
98242 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
98243 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
98244 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
98245 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
98246 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
98247 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
98248 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
98249 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
98250 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
98251 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
98252 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
98253 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
98254 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
98255 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
98256 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
98257 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
98258 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
98259 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
98260 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
98261 +read_buf_20469 read_buf 2 20469 NULL
98262 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
98263 +fast_user_write_20494 fast_user_write 5 20494 NULL
98264 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
98265 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
98266 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
98267 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
98268 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
98269 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
98270 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
98271 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
98272 +venus_create_20555 venus_create 4 20555 NULL
98273 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
98274 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
98275 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
98276 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
98277 +lirc_write_20604 lirc_write 3 20604 NULL
98278 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
98279 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
98280 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
98281 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
98282 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
98283 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
98284 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
98285 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
98286 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
98287 +cpumask_size_20683 cpumask_size 0 20683 NULL
98288 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
98289 +gru_vtop_20689 gru_vtop 2 20689 NULL
98290 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
98291 +__maestro_read_20700 __maestro_read 0 20700 NULL
98292 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
98293 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
98294 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
98295 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
98296 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
98297 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
98298 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
98299 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
98300 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
98301 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
98302 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
98303 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
98304 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
98305 +sys_sendto_20809 sys_sendto 6 20809 NULL
98306 +strndup_user_20819 strndup_user 2 20819 NULL
98307 +calc_layout_20829 calc_layout 3 20829 NULL
98308 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
98309 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
98310 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
98311 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
98312 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
98313 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
98314 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
98315 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
98316 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
98317 +htable_bits_20933 htable_bits 0 20933 NULL
98318 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
98319 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
98320 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
98321 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
98322 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
98323 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
98324 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
98325 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
98326 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
98327 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
98328 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
98329 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
98330 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
98331 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
98332 +multipath_status_21094 multipath_status 5 21094 NULL
98333 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
98334 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
98335 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
98336 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
98337 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
98338 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
98339 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
98340 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
98341 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
98342 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
98343 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
98344 +input_ff_create_21240 input_ff_create 2 21240 NULL
98345 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
98346 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
98347 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
98348 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
98349 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
98350 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
98351 +add_res_range_21310 add_res_range 4 21310 NULL
98352 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
98353 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
98354 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
98355 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
98356 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
98357 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
98358 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
98359 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
98360 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
98361 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
98362 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
98363 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
98364 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
98365 +concat_writev_21451 concat_writev 3 21451 NULL
98366 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
98367 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
98368 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
98369 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
98370 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
98371 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
98372 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
98373 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
98374 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
98375 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
98376 +validate_nnode_21638 validate_nnode 0 21638 NULL
98377 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
98378 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
98379 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
98380 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
98381 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
98382 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
98383 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
98384 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
98385 +vm_brk_21739 vm_brk 1 21739 NULL
98386 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
98387 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
98388 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
98389 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
98390 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
98391 +min_odd_21802 min_odd 0 21802 NULL
98392 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
98393 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
98394 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
98395 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
98396 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
98397 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
98398 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
98399 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
98400 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
98401 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
98402 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
98403 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
98404 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
98405 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
98406 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
98407 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
98408 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
98409 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
98410 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
98411 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
98412 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
98413 +write_opcode_22082 write_opcode 2 22082 NULL
98414 +mem_rw_22085 mem_rw 3 22085 NULL
98415 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
98416 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
98417 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
98418 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
98419 +compat_insn_22142 compat_insn 2 22142 NULL
98420 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
98421 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
98422 +fls_22210 fls 0 22210 NULL
98423 +mem_write_22232 mem_write 3 22232 NULL
98424 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
98425 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
98426 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
98427 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
98428 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
98429 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
98430 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
98431 +extend_brk_22301 extend_brk 0 22301 NULL
98432 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
98433 +get_segment_base_22324 get_segment_base 0 22324 NULL
98434 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
98435 +atomic_read_22342 atomic_read 0 22342 NULL
98436 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
98437 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
98438 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
98439 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
98440 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
98441 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98442 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98443 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98444 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
98445 +zoran_write_22404 zoran_write 3 22404 NULL
98446 +queue_reply_22416 queue_reply 3 22416 NULL
98447 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98448 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98449 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98450 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98451 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
98452 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98453 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98454 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98455 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98456 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
98457 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
98458 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98459 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98460 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98461 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98462 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98463 +snapshot_read_22601 snapshot_read 3 22601 NULL
98464 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
98465 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98466 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98467 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98468 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98469 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98470 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98471 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98472 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98473 +map_22700 map 2 22700 NULL
98474 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98475 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98476 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98477 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98478 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98479 +print_frame_22769 print_frame 0 22769 NULL
98480 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98481 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98482 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
98483 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
98484 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98485 +create_attr_set_22861 create_attr_set 1 22861 NULL
98486 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98487 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98488 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98489 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
98490 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98491 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98492 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98493 +vme_get_size_22964 vme_get_size 0 22964 NULL
98494 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98495 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
98496 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98497 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
98498 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98499 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98500 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98501 +st_status_23032 st_status 5 23032 NULL
98502 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98503 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98504 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
98505 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98506 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98507 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98508 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98509 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98510 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98511 +fls_long_23096 fls_long 0 23096 NULL
98512 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98513 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98514 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98515 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98516 +__clear_user_23118 __clear_user 0 23118 NULL
98517 +dm_write_async_23120 dm_write_async 3 23120 NULL
98518 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98519 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98520 +read_file_ani_23161 read_file_ani 3 23161 NULL
98521 +ioremap_23172 ioremap 1-2 23172 NULL
98522 +usblp_write_23178 usblp_write 3 23178 NULL
98523 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98524 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98525 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98526 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98527 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98528 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98529 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98530 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98531 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98532 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98533 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98534 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98535 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98536 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98537 +doc_probe_23285 doc_probe 1 23285 NULL
98538 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98539 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
98540 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98541 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98542 +page_readlink_23346 page_readlink 3 23346 NULL
98543 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98544 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
98545 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98546 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98547 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98548 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
98549 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98550 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98551 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98552 +event_filter_read_23494 event_filter_read 3 23494 NULL
98553 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
98554 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98555 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98556 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98557 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98558 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98559 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98560 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98561 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
98562 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98563 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98564 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98565 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98566 +sInW_23663 sInW 0 23663 NULL
98567 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98568 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98569 +cx18_read_23699 cx18_read 3 23699 NULL
98570 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98571 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98572 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98573 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98574 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98575 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98576 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98577 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
98578 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
98579 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98580 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
98581 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98582 +p54_init_common_23850 p54_init_common 1 23850 NULL
98583 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98584 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98585 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98586 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98587 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98588 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98589 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98590 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98591 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98592 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98593 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98594 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98595 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98596 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98597 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98598 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98599 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98600 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98601 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98602 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
98603 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98604 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98605 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98606 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98607 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98608 +mpu401_read_24126 mpu401_read 3 24126 NULL
98609 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98610 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98611 +set_discard_24162 set_discard 2 24162 NULL
98612 +adu_read_24177 adu_read 3 24177 NULL
98613 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98614 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98615 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98616 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98617 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98618 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98619 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98620 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98621 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
98622 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
98623 +thin_status_24278 thin_status 5 24278 NULL
98624 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98625 +msg_size_24288 msg_size 0 24288 NULL
98626 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98627 +map_page_24298 map_page 3-4 24298 NULL
98628 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98629 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98630 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98631 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98632 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98633 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98634 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98635 +igetword_24373 igetword 0 24373 NULL
98636 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98637 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98638 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98639 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98640 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
98641 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98642 +smk_user_access_24440 smk_user_access 3 24440 NULL
98643 +page_address_24444 page_address 0 24444 NULL
98644 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98645 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98646 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
98647 +pd_video_read_24510 pd_video_read 3 24510 NULL
98648 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98649 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98650 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98651 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98652 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98653 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98654 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98655 +count_preds_24600 count_preds 0 24600 NULL
98656 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98657 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
98658 +context_alloc_24645 context_alloc 3 24645 NULL
98659 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98660 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98661 +read_fs_24717 read_fs 0 24717 NULL
98662 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98663 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98664 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98665 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98666 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98667 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98668 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98669 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98670 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98671 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98672 +cache_read_24790 cache_read 3 24790 NULL
98673 +unpack_str_24798 unpack_str 0 24798 NULL
98674 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98675 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98676 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98677 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98678 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98679 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98680 +setup_buffering_24872 setup_buffering 3 24872 NULL
98681 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98682 +queues_read_24877 queues_read 3 24877 NULL
98683 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98684 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98685 +next_token_24929 next_token 0 24929 NULL
98686 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98687 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98688 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98689 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98690 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98691 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98692 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98693 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98694 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98695 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98696 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98697 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98698 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98699 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
98700 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98701 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98702 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98703 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98704 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98705 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98706 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
98707 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98708 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98709 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98710 +stripe_status_25259 stripe_status 5 25259 NULL
98711 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98712 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98713 +vfs_writev_25278 vfs_writev 3 25278 NULL
98714 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98715 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98716 +help_25316 help 5 25316 NULL nohasharray
98717 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98718 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98719 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98720 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98721 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98722 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98723 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98724 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98725 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98726 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98727 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98728 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98729 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98730 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98731 +sb_permission_25523 sb_permission 0 25523 NULL
98732 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98733 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98734 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98735 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98736 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98737 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
98738 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98739 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98740 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98741 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
98742 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98743 +__direct_map_25647 __direct_map 5-6 25647 NULL
98744 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98745 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98746 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98747 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98748 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98749 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98750 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98751 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
98752 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98753 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98754 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
98755 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98756 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98757 +sg_read_25799 sg_read 3 25799 NULL
98758 +system_enable_read_25815 system_enable_read 3 25815 NULL
98759 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98760 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
98761 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98762 +parport_read_25855 parport_read 0 25855 NULL
98763 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98764 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98765 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98766 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98767 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98768 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98769 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98770 +rcname_read_25919 rcname_read 3 25919 NULL
98771 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98772 +key_flags_read_25931 key_flags_read 3 25931 NULL
98773 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98774 +flush_25957 flush 2 25957 NULL
98775 +video_register_device_25971 video_register_device 3 25971 NULL
98776 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98777 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98778 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98779 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98780 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98781 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98782 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98783 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98784 +tun_do_read_26047 tun_do_read 5 26047 NULL
98785 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
98786 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98787 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98788 +skb_cow_26138 skb_cow 2 26138 NULL
98789 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98790 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98791 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98792 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98793 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98794 +disk_devt_26180 disk_devt 0 26180 NULL
98795 +get_registers_26187 get_registers 3 26187 NULL
98796 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98797 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98798 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98799 +mce_write_26201 mce_write 3 26201 NULL
98800 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98801 +bio_split_26235 bio_split 2 26235 NULL
98802 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98803 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98804 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98805 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98806 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98807 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98808 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98809 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98810 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98811 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98812 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
98813 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98814 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98815 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98816 +read_vmcore_26501 read_vmcore 3 26501 NULL
98817 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98818 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98819 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98820 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98821 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
98822 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98823 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98824 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98825 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98826 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98827 +pack_value_26625 pack_value 1 26625 NULL
98828 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98829 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98830 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98831 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98832 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98833 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98834 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98835 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98836 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98837 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98838 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98839 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98840 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98841 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
98842 +smk_write_load_26829 smk_write_load 3 26829 NULL
98843 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
98844 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98845 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98846 +scnprint_id_26842 scnprint_id 3 26842 NULL
98847 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98848 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98849 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98850 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98851 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98852 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98853 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98854 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98855 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98856 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98857 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98858 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98859 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98860 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98861 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98862 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98863 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
98864 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98865 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98866 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98867 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98868 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98869 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98870 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98871 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
98872 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98873 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98874 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98875 +pms_capture_27142 pms_capture 4 27142 NULL
98876 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98877 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98878 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98879 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98880 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98881 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98882 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98883 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98884 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98885 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98886 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98887 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98888 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98889 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98890 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98891 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98892 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98893 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98894 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98895 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98896 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98897 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98898 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98899 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98900 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98901 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98902 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98903 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98904 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98905 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98906 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98907 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98908 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98909 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98910 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98911 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98912 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98913 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98914 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98915 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98916 +qword_get_27670 qword_get 0 27670 NULL
98917 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98918 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98919 +evm_write_key_27715 evm_write_key 3 27715 NULL
98920 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98921 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98922 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98923 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98924 +kcalloc_27770 kcalloc 1-2 27770 NULL
98925 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98926 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98927 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98928 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98929 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98930 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98931 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98932 +read_profile_27859 read_profile 3 27859 NULL
98933 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98934 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98935 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98936 +gluebi_write_27905 gluebi_write 3 27905 NULL
98937 +bm_find_next_27929 bm_find_next 2 27929 NULL
98938 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98939 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98940 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98941 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98942 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98943 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98944 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98945 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98946 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98947 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98948 +pool_status_28055 pool_status 5 28055 NULL
98949 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98950 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98951 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98952 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98953 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98954 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98955 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98956 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98957 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98958 +video_read_28148 video_read 3 28148 NULL
98959 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98960 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98961 +vread_28173 vread 0 28173 NULL
98962 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98963 +d_path_28198 d_path 0 28198 NULL
98964 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98965 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
98966 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98967 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98968 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98969 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98970 +usemap_size_28281 usemap_size 0 28281 NULL
98971 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98972 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98973 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98974 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
98975 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98976 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98977 +snapshot_write_28351 snapshot_write 3 28351 NULL
98978 +sys_writev_28384 sys_writev 3 28384 NULL
98979 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98980 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98981 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98982 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98983 +__split_large_page_28429 __split_large_page 2 28429 NULL
98984 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98985 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
98986 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98987 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98988 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98989 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98990 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98991 +max_response_pages_28492 max_response_pages 0 28492 NULL
98992 +clear_discard_28494 clear_discard 2 28494 NULL
98993 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98994 +__next_node_28521 __next_node 1 28521 NULL
98995 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98996 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98997 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98998 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98999 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
99000 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
99001 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
99002 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
99003 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
99004 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
99005 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
99006 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
99007 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
99008 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
99009 +_set_range_28627 _set_range 3 28627 NULL
99010 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
99011 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
99012 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
99013 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
99014 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
99015 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
99016 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
99017 +spi_execute_28736 spi_execute 5 28736 NULL
99018 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
99019 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
99020 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
99021 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
99022 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
99023 +sel_write_member_28800 sel_write_member 3 28800 NULL
99024 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
99025 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
99026 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
99027 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
99028 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
99029 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
99030 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
99031 +to_cblock_28899 to_cblock 0-1 28899 NULL
99032 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
99033 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
99034 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
99035 +push_rx_28939 push_rx 3 28939 NULL
99036 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
99037 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
99038 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
99039 +bin_uuid_28999 bin_uuid 3 28999 NULL
99040 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
99041 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
99042 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
99043 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
99044 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
99045 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
99046 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
99047 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
99048 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
99049 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
99050 +snprintf_29125 snprintf 0 29125 NULL
99051 +iov_shorten_29130 iov_shorten 0 29130 NULL
99052 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
99053 +reshape_ring_29147 reshape_ring 2 29147 NULL
99054 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
99055 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
99056 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
99057 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
99058 +__mm_populate_29204 __mm_populate 1 29204 NULL
99059 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
99060 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
99061 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
99062 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
99063 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
99064 +recover_peb_29238 recover_peb 6-7 29238 NULL
99065 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
99066 +block_div_29268 block_div 0-1-2 29268 NULL
99067 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
99068 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
99069 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
99070 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
99071 +tun_put_user_29337 tun_put_user 5 29337 NULL
99072 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
99073 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
99074 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
99075 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
99076 +mempool_create_29437 mempool_create 1 29437 NULL
99077 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
99078 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
99079 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
99080 +do_register_entry_29478 do_register_entry 4 29478 NULL
99081 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
99082 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
99083 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
99084 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
99085 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
99086 +set_brk_29551 set_brk 1 29551 NULL nohasharray
99087 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
99088 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
99089 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
99090 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
99091 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
99092 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
99093 +slots_per_page_29601 slots_per_page 0 29601 NULL
99094 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
99095 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
99096 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
99097 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
99098 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
99099 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
99100 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
99101 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
99102 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
99103 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
99104 +probes_write_29711 probes_write 3 29711 NULL
99105 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
99106 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
99107 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
99108 +dbAlloc_29794 dbAlloc 0 29794 NULL
99109 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
99110 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
99111 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
99112 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
99113 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
99114 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
99115 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
99116 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
99117 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
99118 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
99119 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
99120 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
99121 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
99122 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
99123 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
99124 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
99125 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
99126 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
99127 +drp_wmove_30043 drp_wmove 4 30043 NULL
99128 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
99129 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
99130 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
99131 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
99132 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
99133 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
99134 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
99135 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
99136 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
99137 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
99138 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
99139 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
99140 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
99141 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
99142 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
99143 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
99144 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
99145 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
99146 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
99147 +compat_readv_30273 compat_readv 3 30273 NULL
99148 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
99149 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
99150 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
99151 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
99152 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
99153 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
99154 +resource_from_user_30341 resource_from_user 3 30341 NULL
99155 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
99156 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
99157 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
99158 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
99159 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
99160 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
99161 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
99162 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
99163 +mq_create_30425 mq_create 1 30425 NULL
99164 +enable_write_30456 enable_write 3 30456 NULL
99165 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
99166 +urandom_read_30462 urandom_read 3 30462 NULL
99167 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
99168 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
99169 +write_head_30481 write_head 4 30481 NULL
99170 +adu_write_30487 adu_write 3 30487 NULL
99171 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
99172 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
99173 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
99174 +set_le_30581 set_le 4 30581 NULL
99175 +from_cblock_30582 from_cblock 0-1 30582 NULL
99176 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
99177 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
99178 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
99179 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
99180 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
99181 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
99182 +agp_remap_30665 agp_remap 2 30665 NULL
99183 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
99184 +il_free_pages_30692 il_free_pages 2 30692 NULL
99185 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
99186 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
99187 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
99188 +snapshot_status_30744 snapshot_status 5 30744 NULL
99189 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
99190 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
99191 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
99192 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
99193 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
99194 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
99195 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
99196 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
99197 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
99198 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
99199 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
99200 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
99201 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
99202 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
99203 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
99204 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
99205 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
99206 +sys_mincore_31079 sys_mincore 1 31079 NULL
99207 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
99208 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
99209 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
99210 +depth_read_31112 depth_read 3 31112 NULL
99211 +ssb_read16_31139 ssb_read16 0 31139 NULL
99212 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
99213 +size_inside_page_31141 size_inside_page 0 31141 NULL
99214 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
99215 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
99216 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
99217 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
99218 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
99219 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
99220 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
99221 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
99222 +__read_reg_31216 __read_reg 0 31216 NULL
99223 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
99224 +cyy_readb_31240 cyy_readb 0 31240 NULL
99225 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
99226 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
99227 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
99228 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
99229 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
99230 +command_file_write_31318 command_file_write 3 31318 NULL
99231 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
99232 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
99233 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
99234 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
99235 +inb_31388 inb 0 31388 NULL
99236 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
99237 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
99238 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
99239 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
99240 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
99241 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
99242 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
99243 +do_fcntl_31468 do_fcntl 3 31468 NULL
99244 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
99245 +alg_setkey_31485 alg_setkey 3 31485 NULL
99246 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
99247 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
99248 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
99249 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
99250 +hidraw_write_31536 hidraw_write 3 31536 NULL
99251 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
99252 +usbvision_read_31555 usbvision_read 3 31555 NULL
99253 +normalize_31566 normalize 0-1-2 31566 NULL
99254 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
99255 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
99256 +osst_write_31581 osst_write 3 31581 NULL
99257 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
99258 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
99259 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
99260 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
99261 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
99262 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
99263 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
99264 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
99265 +__lgread_31668 __lgread 4 31668 NULL
99266 +symbol_string_31670 symbol_string 0 31670 NULL
99267 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
99268 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
99269 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
99270 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
99271 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
99272 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
99273 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
99274 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
99275 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
99276 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
99277 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
99278 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
99279 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
99280 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
99281 +get_count_order_31800 get_count_order 0 31800 NULL
99282 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
99283 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
99284 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
99285 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
99286 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
99287 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
99288 +xattr_permission_31907 xattr_permission 0 31907 NULL
99289 +new_dir_31919 new_dir 3 31919 NULL
99290 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
99291 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
99292 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
99293 +vb2_write_31948 vb2_write 3 31948 NULL
99294 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
99295 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
99296 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
99297 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
99298 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
99299 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
99300 +calc_hmac_32010 calc_hmac 3 32010 NULL
99301 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
99302 +aead_len_32021 aead_len 0 32021 NULL
99303 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
99304 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
99305 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
99306 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
99307 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
99308 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
99309 +bio_alloc_32095 bio_alloc 2 32095 NULL
99310 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
99311 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
99312 +disk_status_32120 disk_status 4 32120 NULL
99313 +venus_link_32165 venus_link 5 32165 NULL
99314 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
99315 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
99316 +load_header_32183 load_header 0 32183 NULL
99317 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
99318 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
99319 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
99320 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
99321 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
99322 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
99323 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
99324 +hex_string_32310 hex_string 0 32310 NULL
99325 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
99326 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
99327 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
99328 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
99329 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
99330 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
99331 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
99332 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
99333 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
99334 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
99335 +log_text_32428 log_text 0 32428 NULL
99336 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
99337 +hid_input_report_32458 hid_input_report 4 32458 NULL
99338 +cache_status_32462 cache_status 5 32462 NULL
99339 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
99340 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
99341 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
99342 +disconnect_32521 disconnect 4 32521 NULL
99343 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
99344 +ilo_read_32531 ilo_read 3 32531 NULL
99345 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
99346 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
99347 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
99348 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
99349 +__first_node_32558 __first_node 0 32558 NULL
99350 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
99351 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
99352 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
99353 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
99354 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
99355 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
99356 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
99357 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
99358 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
99359 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
99360 +kvmalloc_32646 kvmalloc 1 32646 NULL
99361 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
99362 +generic_readlink_32654 generic_readlink 3 32654 NULL
99363 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
99364 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
99365 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
99366 +get_arg_page_32746 get_arg_page 2 32746 NULL
99367 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
99368 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
99369 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
99370 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
99371 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
99372 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
99373 +vga_rseq_32848 vga_rseq 0 32848 NULL
99374 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
99375 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
99376 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
99377 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
99378 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
99379 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
99380 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
99381 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
99382 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
99383 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
99384 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
99385 +compat_filldir_32999 compat_filldir 3 32999 NULL
99386 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
99387 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
99388 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
99389 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
99390 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
99391 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
99392 +alloc_tio_33077 alloc_tio 3 33077 NULL
99393 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
99394 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
99395 +write_node_33121 write_node 4 33121 NULL
99396 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
99397 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
99398 +__len_within_target_33132 __len_within_target 0 33132 NULL
99399 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
99400 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
99401 +pp_read_33210 pp_read 3 33210 NULL
99402 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
99403 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
99404 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
99405 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
99406 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
99407 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
99408 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
99409 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
99410 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
99411 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
99412 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
99413 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
99414 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
99415 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
99416 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
99417 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
99418 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
99419 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
99420 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
99421 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
99422 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
99423 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
99424 +create_entry_33479 create_entry 2 33479 NULL
99425 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
99426 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
99427 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
99428 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
99429 +res_counter_read_33499 res_counter_read 4 33499 NULL
99430 +fb_read_33506 fb_read 3 33506 NULL
99431 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
99432 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
99433 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
99434 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
99435 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
99436 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
99437 +dup_array_33551 dup_array 3 33551 NULL
99438 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
99439 +count_subheaders_33591 count_subheaders 0 33591 NULL
99440 +scsi_execute_33596 scsi_execute 5 33596 NULL
99441 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99442 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99443 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99444 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
99445 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
99446 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99447 +inw_p_33668 inw_p 0 33668 NULL
99448 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99449 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99450 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99451 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99452 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99453 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99454 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99455 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99456 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99457 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99458 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99459 +Read_hfc_33755 Read_hfc 0 33755 NULL
99460 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99461 +hashtab_create_33769 hashtab_create 3 33769 NULL
99462 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99463 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99464 +find_next_offset_33804 find_next_offset 3 33804 NULL
99465 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99466 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99467 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99468 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99469 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99470 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99471 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99472 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99473 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
99474 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99475 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99476 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99477 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99478 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99479 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99480 +ppp_write_34034 ppp_write 3 34034 NULL
99481 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99482 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99483 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99484 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99485 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99486 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99487 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99488 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
99489 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99490 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99491 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99492 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99493 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99494 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99495 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99496 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99497 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99498 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99499 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99500 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99501 +__insert_34349 __insert 2-3 34349 NULL
99502 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99503 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99504 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99505 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99506 +ea_read_34378 ea_read 0 34378 NULL
99507 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99508 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99509 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99510 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
99511 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
99512 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99513 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99514 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99515 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99516 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99517 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99518 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99519 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99520 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99521 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99522 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99523 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99524 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99525 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99526 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
99527 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99528 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99529 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99530 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
99531 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99532 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99533 +port_print_34704 port_print 3 34704 NULL
99534 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99535 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99536 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99537 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99538 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99539 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99540 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99541 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99542 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99543 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99544 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99545 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99546 +msg_print_text_34889 msg_print_text 0 34889 NULL
99547 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99548 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99549 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99550 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99551 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99552 +Realloc_34961 Realloc 2 34961 NULL
99553 +mq_lookup_34990 mq_lookup 2 34990 NULL
99554 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99555 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99556 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
99557 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99558 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
99559 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99560 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99561 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99562 +store_ifalias_35088 store_ifalias 4 35088 NULL
99563 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99564 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99565 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99566 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99567 +pointer_35138 pointer 0 35138 NULL
99568 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99569 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99570 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99571 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
99572 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
99573 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
99574 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99575 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99576 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99577 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99578 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
99579 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
99580 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
99581 +set_fd_set_35249 set_fd_set 1 35249 NULL
99582 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99583 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99584 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99585 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99586 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99587 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99588 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99589 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99590 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99591 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99592 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99593 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99594 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99595 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99596 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99597 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99598 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99599 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99600 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99601 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99602 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
99603 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99604 +async_setkey_35521 async_setkey 3 35521 NULL
99605 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99606 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99607 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99608 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99609 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99610 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99611 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
99612 +ReadZReg_35604 ReadZReg 0 35604 NULL
99613 +kernel_readv_35617 kernel_readv 3 35617 NULL
99614 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
99615 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99616 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99617 +store_debug_level_35652 store_debug_level 3 35652 NULL
99618 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99619 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99620 +dm_table_create_35687 dm_table_create 3 35687 NULL
99621 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99622 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99623 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99624 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99625 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99626 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99627 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99628 +fls64_35862 fls64 0 35862 NULL
99629 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99630 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99631 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99632 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99633 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
99634 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99635 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99636 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99637 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99638 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99639 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99640 +acl_alloc_35979 acl_alloc 1 35979 NULL
99641 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99642 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99643 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99644 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99645 +account_shadowed_36048 account_shadowed 2 36048 NULL
99646 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99647 +write_emulate_36065 write_emulate 2-4 36065 NULL
99648 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99649 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99650 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99651 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99652 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99653 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99654 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99655 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99656 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99657 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
99658 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99659 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99660 +twl_set_36154 twl_set 2 36154 NULL
99661 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99662 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99663 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99664 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99665 +is_dirty_36223 is_dirty 2 36223 NULL
99666 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
99667 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99668 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99669 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99670 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99671 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99672 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99673 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99674 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99675 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99676 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99677 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99678 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99679 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
99680 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99681 +lc_create_36332 lc_create 4 36332 NULL
99682 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99683 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99684 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99685 +to_sector_36361 to_sector 0-1 36361 NULL
99686 +tunables_read_36385 tunables_read 3 36385 NULL
99687 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99688 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99689 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99690 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99691 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99692 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99693 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99694 +get_param_l_36518 get_param_l 0 36518 NULL
99695 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99696 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99697 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99698 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99699 +get_entry_len_36549 get_entry_len 0 36549 NULL
99700 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99701 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99702 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99703 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99704 +__erst_read_36579 __erst_read 0 36579 NULL
99705 +put_cmsg_36589 put_cmsg 4 36589 NULL
99706 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99707 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99708 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99709 +format_decode_36638 format_decode 0 36638 NULL
99710 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99711 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99712 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99713 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99714 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99715 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99716 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99717 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99718 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99719 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99720 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99721 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99722 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99723 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99724 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99725 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
99726 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99727 +cm_write_36858 cm_write 3 36858 NULL
99728 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99729 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99730 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
99731 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
99732 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99733 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99734 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99735 +build_key_36931 build_key 1 36931 NULL
99736 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99737 +write_leb_36957 write_leb 5 36957 NULL
99738 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99739 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99740 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99741 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99742 +setxattr_37006 setxattr 4 37006 NULL
99743 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
99744 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
99745 +parse_command_37079 parse_command 2 37079 NULL
99746 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99747 +tun_get_user_37094 tun_get_user 5 37094 NULL
99748 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99749 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
99750 +msg_word_37164 msg_word 0 37164 NULL
99751 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99752 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99753 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99754 +__do_replace_37227 __do_replace 5 37227 NULL
99755 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99756 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99757 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99758 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99759 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
99760 +c101_run_37279 c101_run 2 37279 NULL
99761 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99762 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
99763 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99764 +send_msg_37323 send_msg 4 37323 NULL
99765 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99766 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99767 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99768 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99769 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99770 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99771 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99772 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99773 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99774 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99775 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99776 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99777 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99778 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99779 +__remove_37457 __remove 2 37457 NULL
99780 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99781 +get_est_timing_37484 get_est_timing 0 37484 NULL
99782 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99783 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99784 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99785 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99786 +hdr_size_37536 hdr_size 0 37536 NULL
99787 +a2p_37544 a2p 0-1 37544 NULL
99788 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99789 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99790 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99791 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99792 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
99793 +policy_residency_37629 policy_residency 0 37629 NULL
99794 +check_pt_base_37635 check_pt_base 3 37635 NULL
99795 +alloc_fd_37637 alloc_fd 1 37637 NULL
99796 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99797 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99798 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99799 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99800 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99801 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99802 +nametbl_header_37698 nametbl_header 2 37698 NULL
99803 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99804 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
99805 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
99806 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99807 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99808 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99809 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99810 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99811 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
99812 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99813 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99814 +deny_write_access_37813 deny_write_access 0 37813 NULL
99815 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99816 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99817 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99818 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99819 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99820 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99821 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99822 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
99823 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99824 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99825 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99826 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99827 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99828 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99829 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99830 +vfs_readv_38011 vfs_readv 3 38011 NULL
99831 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99832 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99833 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99834 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
99835 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
99836 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99837 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99838 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99839 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99840 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99841 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99842 +ep0_read_38095 ep0_read 3 38095 NULL
99843 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99844 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
99845 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99846 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99847 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99848 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99849 +cdev_add_38176 cdev_add 2-3 38176 NULL
99850 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99851 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99852 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99853 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99854 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99855 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99856 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
99857 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99858 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99859 +from_dblock_38256 from_dblock 0-1 38256 NULL
99860 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
99861 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99862 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99863 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99864 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99865 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
99866 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
99867 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
99868 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99869 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99870 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99871 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99872 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99873 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99874 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99875 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99876 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99877 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99878 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99879 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99880 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99881 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99882 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99883 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
99884 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99885 +dev_names_read_38509 dev_names_read 3 38509 NULL
99886 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99887 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99888 +set_queue_count_38519 set_queue_count 0 38519 NULL
99889 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
99890 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99891 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99892 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99893 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99894 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99895 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99896 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99897 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99898 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99899 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99900 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99901 +cma_create_area_38642 cma_create_area 2 38642 NULL
99902 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99903 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
99904 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99905 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99906 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99907 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99908 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99909 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
99910 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99911 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99912 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
99913 +udf_readpages_38761 udf_readpages 4 38761 NULL
99914 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99915 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99916 +err_decode_38804 err_decode 2 38804 NULL
99917 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99918 +sys_select_38827 sys_select 1 38827 NULL
99919 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99920 +direct_entry_38836 direct_entry 3 38836 NULL
99921 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99922 +interfaces_38859 interfaces 2 38859 NULL
99923 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99924 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99925 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99926 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99927 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99928 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99929 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99930 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99931 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99932 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99933 +udf_new_block_38999 udf_new_block 4 38999 NULL
99934 +get_nodes_39012 get_nodes 3 39012 NULL
99935 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99936 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99937 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99938 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99939 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99940 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99941 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99942 +ea_foreach_39133 ea_foreach 0 39133 NULL
99943 +generic_permission_39150 generic_permission 0 39150 NULL
99944 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99945 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99946 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99947 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99948 +init_list_set_39188 init_list_set 2-3 39188 NULL
99949 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99950 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99951 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99952 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99953 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99954 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99955 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99956 +drm_order_39244 drm_order 0 39244 NULL
99957 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99958 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99959 +__skb_cow_39254 __skb_cow 2 39254 NULL
99960 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99961 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99962 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99963 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99964 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99965 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99966 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99967 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99968 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99969 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99970 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99971 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
99972 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99973 +__send_to_port_39386 __send_to_port 3 39386 NULL
99974 +user_power_read_39414 user_power_read 3 39414 NULL
99975 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99976 +sys_semop_39457 sys_semop 3 39457 NULL
99977 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99978 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
99979 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99980 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99981 +int_proc_write_39542 int_proc_write 3 39542 NULL
99982 +pp_write_39554 pp_write 3 39554 NULL
99983 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99984 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99985 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99986 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99987 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99988 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99989 +ext_depth_39607 ext_depth 0 39607 NULL
99990 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99991 +sdio_readb_39618 sdio_readb 0 39618 NULL
99992 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99993 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99994 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99995 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99996 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99997 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99998 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99999 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
100000 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
100001 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
100002 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
100003 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
100004 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
100005 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
100006 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
100007 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
100008 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
100009 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
100010 +pkt_add_39897 pkt_add 3 39897 NULL
100011 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
100012 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
100013 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
100014 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
100015 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
100016 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
100017 +__spi_async_39932 __spi_async 0 39932 NULL
100018 +__get_order_39935 __get_order 0 39935 NULL
100019 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
100020 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
100021 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
100022 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
100023 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
100024 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
100025 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
100026 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
100027 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
100028 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
100029 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
100030 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
100031 +add_tty_40055 add_tty 1 40055 NULL nohasharray
100032 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
100033 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
100034 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
100035 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
100036 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
100037 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
100038 +pt_write_40159 pt_write 3 40159 NULL
100039 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
100040 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
100041 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
100042 +allocate_probes_40204 allocate_probes 1 40204 NULL
100043 +compat_put_long_40214 compat_put_long 1 40214 NULL
100044 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
100045 +osst_read_40237 osst_read 3 40237 NULL
100046 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
100047 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
100048 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
100049 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
100050 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
100051 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
100052 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
100053 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
100054 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
100055 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
100056 +mmio_read_40348 mmio_read 4 40348 NULL
100057 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
100058 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
100059 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
100060 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
100061 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
100062 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
100063 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
100064 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
100065 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
100066 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
100067 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
100068 +tty_write_room_40495 tty_write_room 0 40495 NULL
100069 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
100070 +sg_phys_40507 sg_phys 0 40507 NULL
100071 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
100072 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
100073 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
100074 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
100075 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
100076 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
100077 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
100078 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
100079 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
100080 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
100081 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
100082 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
100083 +fops_read_40672 fops_read 3 40672 NULL
100084 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
100085 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
100086 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
100087 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
100088 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
100089 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
100090 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
100091 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
100092 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
100093 +card_send_command_40757 card_send_command 3 40757 NULL
100094 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
100095 +pg_write_40766 pg_write 3 40766 NULL
100096 +show_list_40775 show_list 3 40775 NULL
100097 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
100098 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
100099 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
100100 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
100101 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
100102 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
100103 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
100104 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
100105 +read_file_queue_40895 read_file_queue 3 40895 NULL
100106 +waiters_read_40902 waiters_read 3 40902 NULL
100107 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
100108 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
100109 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
100110 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
100111 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
100112 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
100113 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
100114 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
100115 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
100116 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
100117 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
100118 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
100119 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
100120 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
100121 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
100122 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
100123 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
100124 +dma_attach_41094 dma_attach 5-6 41094 NULL
100125 +provide_user_output_41105 provide_user_output 3 41105 NULL
100126 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
100127 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
100128 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
100129 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
100130 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
100131 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
100132 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
100133 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
100134 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
100135 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
100136 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
100137 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
100138 +erst_read_41260 erst_read 0 41260 NULL
100139 +__fprog_create_41263 __fprog_create 2 41263 NULL
100140 +alloc_context_41283 alloc_context 1 41283 NULL
100141 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
100142 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
100143 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
100144 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
100145 +kmp_init_41373 kmp_init 2 41373 NULL
100146 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
100147 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
100148 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
100149 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
100150 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
100151 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
100152 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
100153 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
100154 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
100155 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
100156 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
100157 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
100158 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
100159 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
100160 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
100161 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
100162 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
100163 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
100164 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
100165 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
100166 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
100167 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
100168 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
100169 +vga_io_r_41609 vga_io_r 0 41609 NULL
100170 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
100171 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
100172 +a2mp_send_41615 a2mp_send 4 41615 NULL
100173 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
100174 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
100175 +get_std_timing_41654 get_std_timing 0 41654 NULL
100176 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
100177 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
100178 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
100179 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
100180 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
100181 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
100182 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
100183 +fillonedir_41746 fillonedir 3 41746 NULL
100184 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
100185 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
100186 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
100187 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
100188 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
100189 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
100190 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
100191 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
100192 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
100193 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
100194 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
100195 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
100196 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
100197 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
100198 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
100199 +portnames_read_41958 portnames_read 3 41958 NULL
100200 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
100201 +dst_mtu_41969 dst_mtu 0 41969 NULL
100202 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
100203 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
100204 +lguest_map_42008 lguest_map 1-2 42008 NULL
100205 +pool_allocate_42012 pool_allocate 3 42012 NULL
100206 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
100207 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
100208 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
100209 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
100210 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
100211 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
100212 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
100213 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
100214 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
100215 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
100216 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
100217 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
100218 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
100219 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
100220 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
100221 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
100222 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
100223 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
100224 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
100225 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
100226 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
100227 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
100228 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
100229 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
100230 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
100231 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
100232 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
100233 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
100234 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
100235 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
100236 +free_cblock_42318 free_cblock 2 42318 NULL
100237 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
100238 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
100239 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
100240 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
100241 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
100242 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
100243 +krng_get_random_42420 krng_get_random 3 42420 NULL
100244 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
100245 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
100246 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
100247 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
100248 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
100249 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
100250 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
100251 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
100252 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
100253 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
100254 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
100255 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
100256 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
100257 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
100258 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
100259 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
100260 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
100261 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
100262 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
100263 +map_state_42602 map_state 1 42602 NULL nohasharray
100264 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
100265 +nd_get_link_42603 nd_get_link 0 42603 NULL
100266 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
100267 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
100268 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
100269 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
100270 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
100271 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
100272 +vb2_read_42703 vb2_read 3 42703 NULL
100273 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
100274 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
100275 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
100276 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
100277 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
100278 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
100279 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
100280 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
100281 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
100282 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
100283 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
100284 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
100285 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
100286 +set_arg_42824 set_arg 3 42824 NULL
100287 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
100288 +prandom_u32_42853 prandom_u32 0 42853 NULL
100289 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
100290 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
100291 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
100292 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
100293 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
100294 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
100295 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
100296 +hd_end_request_42904 hd_end_request 2 42904 NULL
100297 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
100298 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
100299 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
100300 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
100301 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
100302 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
100303 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
100304 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
100305 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
100306 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
100307 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
100308 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
100309 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
100310 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
100311 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
100312 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
100313 +uuid_string_43154 uuid_string 0 43154 NULL
100314 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
100315 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
100316 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
100317 +process_measurement_43190 process_measurement 0 43190 NULL
100318 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
100319 +uio_write_43202 uio_write 3 43202 NULL
100320 +iso_callback_43208 iso_callback 3 43208 NULL
100321 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
100322 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
100323 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
100324 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
100325 +fixup_leb_43256 fixup_leb 3 43256 NULL
100326 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
100327 +evtchn_write_43278 evtchn_write 3 43278 NULL
100328 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
100329 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
100330 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
100331 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
100332 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
100333 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
100334 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
100335 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
100336 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
100337 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
100338 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
100339 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
100340 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
100341 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
100342 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
100343 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
100344 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
100345 +do_readlink_43518 do_readlink 2 43518 NULL
100346 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
100347 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
100348 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
100349 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
100350 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
100351 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
100352 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
100353 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
100354 +proc_read_43614 proc_read 3 43614 NULL
100355 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
100356 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
100357 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
100358 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
100359 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
100360 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
100361 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
100362 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
100363 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
100364 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
100365 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
100366 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
100367 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
100368 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
100369 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
100370 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
100371 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
100372 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
100373 +read_flush_43851 read_flush 3 43851 NULL
100374 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
100375 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
100376 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
100377 +SendString_43928 SendString 3 43928 NULL
100378 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
100379 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
100380 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
100381 +nla_reserve_43984 nla_reserve 3 43984 NULL
100382 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
100383 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
100384 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
100385 +emit_flags_44006 emit_flags 4-3 44006 NULL
100386 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
100387 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
100388 +load_discard_44083 load_discard 3 44083 NULL
100389 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
100390 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
100391 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
100392 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
100393 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
100394 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
100395 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
100396 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
100397 +__set_free_44211 __set_free 2 44211 NULL
100398 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
100399 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
100400 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
100401 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
100402 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
100403 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
100404 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
100405 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
100406 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
100407 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
100408 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
100409 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
100410 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
100411 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
100412 +__is_discarded_44359 __is_discarded 2 44359 NULL
100413 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
100414 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
100415 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
100416 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
100417 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
100418 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
100419 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
100420 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
100421 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
100422 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
100423 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
100424 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
100425 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
100426 +spidev_write_44510 spidev_write 3 44510 NULL
100427 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
100428 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
100429 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
100430 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
100431 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
100432 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
100433 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
100434 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
100435 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
100436 +mpi_resize_44674 mpi_resize 2 44674 NULL
100437 +ts_read_44687 ts_read 3 44687 NULL
100438 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
100439 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
100440 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
100441 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
100442 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
100443 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
100444 +set_brk_44749 set_brk 1 44749 NULL
100445 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
100446 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
100447 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
100448 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
100449 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
100450 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
100451 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
100452 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
100453 +sisusb_write_44834 sisusb_write 3 44834 NULL
100454 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100455 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100456 +skb_availroom_44883 skb_availroom 0 44883 NULL
100457 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100458 +do_tty_write_44896 do_tty_write 5 44896 NULL
100459 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100460 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100461 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100462 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100463 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100464 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100465 +sel_write_user_45060 sel_write_user 3 45060 NULL
100466 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100467 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100468 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100469 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100470 +usbdev_read_45114 usbdev_read 3 45114 NULL
100471 +send_to_tty_45141 send_to_tty 3 45141 NULL
100472 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100473 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100474 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100475 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100476 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100477 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100478 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100479 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100480 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100481 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100482 +add_child_45201 add_child 4 45201 NULL
100483 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100484 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100485 +__dirty_45228 __dirty 2 45228 NULL
100486 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100487 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100488 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100489 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100490 +pte_val_45313 pte_val 0 45313 NULL
100491 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100492 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100493 +keymap_store_45406 keymap_store 4 45406 NULL
100494 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
100495 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
100496 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100497 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100498 +__node_remap_45458 __node_remap 4 45458 NULL
100499 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100500 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100501 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100502 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
100503 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100504 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100505 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100506 +copy_macs_45534 copy_macs 4 45534 NULL
100507 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100508 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100509 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100510 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100511 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100512 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100513 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
100514 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100515 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100516 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100517 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100518 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100519 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100520 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100521 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100522 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100523 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100524 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100525 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100526 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100527 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100528 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100529 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100530 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100531 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100532 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100533 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100534 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100535 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100536 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100537 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100538 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100539 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100540 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100541 +isdn_write_45863 isdn_write 3 45863 NULL
100542 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100543 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100544 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100545 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
100546 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100547 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100548 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
100549 +alloc_mr_45935 alloc_mr 1 45935 NULL
100550 +split_large_page_45941 split_large_page 2 45941 NULL
100551 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100552 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100553 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100554 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100555 +get_free_entries_46030 get_free_entries 1 46030 NULL
100556 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100557 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100558 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100559 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100560 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100561 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100562 +slhc_toss_46066 slhc_toss 0 46066 NULL
100563 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100564 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100565 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100566 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100567 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100568 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100569 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100570 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100571 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
100572 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100573 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100574 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100575 +add_conn_list_46197 add_conn_list 3 46197 NULL
100576 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100577 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100578 +dsp_write_46218 dsp_write 2 46218 NULL
100579 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100580 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100581 +ReadReg_46277 ReadReg 0 46277 NULL
100582 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100583 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100584 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100585 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100586 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100587 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100588 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100589 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100590 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100591 +filldir64_46469 filldir64 3 46469 NULL
100592 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100593 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100594 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100595 +kmsg_read_46514 kmsg_read 3 46514 NULL
100596 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100597 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100598 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100599 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100600 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100601 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100602 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100603 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100604 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100605 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100606 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100607 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100608 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100609 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
100610 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100611 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100612 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100613 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100614 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100615 +prepare_copy_46725 prepare_copy 2 46725 NULL
100616 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100617 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
100618 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
100619 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
100620 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100621 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100622 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100623 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100624 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100625 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100626 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100627 +spi_async_46857 spi_async 0 46857 NULL
100628 +vsnprintf_46863 vsnprintf 0 46863 NULL
100629 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100630 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100631 +rvmalloc_46873 rvmalloc 1 46873 NULL
100632 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
100633 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100634 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100635 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100636 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100637 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100638 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
100639 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
100640 +fb_write_46924 fb_write 3 46924 NULL
100641 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100642 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
100643 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100644 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100645 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100646 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100647 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100648 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100649 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100650 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100651 +__map_single_47020 __map_single 3-4-7 47020 NULL
100652 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100653 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
100654 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100655 +fs_path_len_47060 fs_path_len 0 47060 NULL
100656 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100657 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100658 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100659 +mousedev_read_47123 mousedev_read 3 47123 NULL
100660 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100661 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100662 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100663 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100664 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100665 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100666 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100667 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100668 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100669 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
100670 +l2headersize_47238 l2headersize 0 47238 NULL
100671 +options_write_47243 options_write 3 47243 NULL
100672 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100673 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100674 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100675 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100676 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100677 +vsnprintf_47291 vsnprintf 0 47291 NULL
100678 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100679 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100680 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100681 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100682 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100683 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
100684 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
100685 +nametbl_list_47391 nametbl_list 2 47391 NULL
100686 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100687 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100688 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
100689 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100690 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100691 +vzalloc_47421 vzalloc 1 47421 NULL
100692 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100693 +__load_mapping_47460 __load_mapping 2 47460 NULL
100694 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
100695 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
100696 +core_sys_select_47494 core_sys_select 1 47494 NULL
100697 +unlink_simple_47506 unlink_simple 3 47506 NULL
100698 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100699 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100700 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100701 +oz_events_read_47535 oz_events_read 3 47535 NULL
100702 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100703 +read_ldt_47570 read_ldt 2 47570 NULL
100704 +pci_iomap_47575 pci_iomap 3 47575 NULL
100705 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100706 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100707 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100708 +uea_request_47613 uea_request 4 47613 NULL
100709 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100710 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100711 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100712 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100713 +save_microcode_47717 save_microcode 3 47717 NULL
100714 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100715 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100716 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100717 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100718 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100719 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100720 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100721 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100722 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100723 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100724 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100725 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100726 +vhci_read_47878 vhci_read 3 47878 NULL
100727 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100728 +load_mapping_47904 load_mapping 3 47904 NULL
100729 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100730 +comedi_write_47926 comedi_write 3 47926 NULL
100731 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100732 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100733 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100734 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100735 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100736 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100737 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100738 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100739 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100740 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100741 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
100742 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100743 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100744 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100745 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100746 +set_discoverable_48141 set_discoverable 4 48141 NULL
100747 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100748 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100749 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100750 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100751 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100752 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100753 +init_ipath_48187 init_ipath 1 48187 NULL
100754 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100755 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100756 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100757 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100758 +read_file_recv_48232 read_file_recv 3 48232 NULL
100759 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
100760 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100761 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100762 +send_set_info_48288 send_set_info 7 48288 NULL
100763 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100764 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100765 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100766 +hash_setkey_48310 hash_setkey 3 48310 NULL
100767 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100768 +skb_add_data_48363 skb_add_data 3 48363 NULL
100769 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100770 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
100771 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100772 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100773 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100774 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100775 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100776 +send_control_msg_48498 send_control_msg 6 48498 NULL
100777 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100778 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100779 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100780 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100781 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100782 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100783 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100784 +named_distribute_48544 named_distribute 4 48544 NULL
100785 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100786 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100787 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100788 +mtd_read_48655 mtd_read 0 48655 NULL
100789 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100790 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100791 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100792 +altera_drscan_48698 altera_drscan 2 48698 NULL
100793 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100794 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100795 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100796 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100797 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100798 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100799 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100800 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100801 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
100802 +azx_get_position_48841 azx_get_position 0 48841 NULL
100803 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100804 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100805 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100806 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100807 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100808 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100809 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100810 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100811 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
100812 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100813 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100814 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100815 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
100816 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100817 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100818 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100819 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100820 +transient_status_49027 transient_status 4 49027 NULL
100821 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
100822 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
100823 +ubi_read_49061 ubi_read 0 49061 NULL
100824 +scsi_register_49094 scsi_register 2 49094 NULL
100825 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
100826 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100827 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100828 +pt_read_49136 pt_read 3 49136 NULL
100829 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100830 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100831 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100832 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100833 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100834 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100835 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100836 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100837 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100838 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100839 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
100840 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
100841 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100842 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100843 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100844 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100845 +uio_read_49300 uio_read 3 49300 NULL
100846 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100847 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100848 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100849 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100850 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100851 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100852 +px_raw_event_49371 px_raw_event 4 49371 NULL
100853 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100854 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100855 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100856 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100857 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100858 +md_domain_init_49432 md_domain_init 2 49432 NULL
100859 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100860 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100861 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100862 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100863 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100864 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100865 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100866 +smk_write_access_49561 smk_write_access 3 49561 NULL
100867 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100868 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100869 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100870 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100871 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
100872 +heap_init_49617 heap_init 2 49617 NULL
100873 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100874 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100875 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100876 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100877 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100878 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
100879 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100880 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100881 +check_frame_49741 check_frame 0 49741 NULL
100882 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100883 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100884 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
100885 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100886 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100887 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100888 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100889 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100890 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100891 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100892 +add_uuid_49831 add_uuid 4 49831 NULL
100893 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100894 +twl4030_write_49846 twl4030_write 2 49846 NULL
100895 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100896 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100897 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100898 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100899 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100900 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100901 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100902 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100903 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100904 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100905 +__module_alloc_50004 __module_alloc 1 50004 NULL
100906 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100907 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100908 +isdn_read_50021 isdn_read 3 50021 NULL
100909 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
100910 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100911 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100912 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100913 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100914 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100915 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100916 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100917 +read_file_slot_50111 read_file_slot 3 50111 NULL
100918 +copy_items_50140 copy_items 6 50140 NULL
100919 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100920 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100921 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100922 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100923 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100924 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100925 +odev_update_50169 odev_update 2 50169 NULL
100926 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100927 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100928 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100929 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100930 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100931 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100932 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100933 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100934 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100935 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100936 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100937 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100938 +do_launder_page_50329 do_launder_page 0 50329 NULL
100939 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100940 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100941 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100942 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100943 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100944 +tpm_read_50344 tpm_read 3 50344 NULL
100945 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100946 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100947 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100948 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100949 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100950 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100951 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100952 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100953 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
100954 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100955 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100956 +force_mapping_50464 force_mapping 2 50464 NULL
100957 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100958 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100959 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100960 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100961 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100962 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100963 +fat_readpages_50582 fat_readpages 4 50582 NULL
100964 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100965 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100966 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100967 +__ffs_50625 __ffs 0 50625 NULL
100968 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100969 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100970 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100971 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100972 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100973 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100974 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
100975 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
100976 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100977 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100978 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100979 +skb_padto_50759 skb_padto 2 50759 NULL
100980 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100981 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100982 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100983 +tpm_write_50798 tpm_write 3 50798 NULL
100984 +write_flush_50803 write_flush 3 50803 NULL
100985 +dvb_play_50814 dvb_play 3 50814 NULL
100986 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100987 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100988 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100989 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100990 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
100991 +self_check_write_50856 self_check_write 5 50856 NULL
100992 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100993 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100994 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100995 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100996 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100997 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100998 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100999 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
101000 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
101001 +timeout_write_50991 timeout_write 3 50991 NULL
101002 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
101003 +proc_write_51003 proc_write 3 51003 NULL
101004 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
101005 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
101006 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
101007 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
101008 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
101009 +dump_midi_51040 dump_midi 3 51040 NULL
101010 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
101011 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
101012 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
101013 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
101014 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
101015 +ti_recv_51110 ti_recv 3 51110 NULL
101016 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
101017 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
101018 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
101019 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
101020 +set_dirty_51144 set_dirty 3 51144 NULL
101021 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
101022 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
101023 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
101024 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
101025 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
101026 +tipc_send_51238 tipc_send 4 51238 NULL
101027 +drm_property_create_51239 drm_property_create 4 51239 NULL
101028 +st_read_51251 st_read 3 51251 NULL
101029 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
101030 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
101031 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
101032 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
101033 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
101034 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
101035 +get_cell_51316 get_cell 2 51316 NULL
101036 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
101037 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
101038 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
101039 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
101040 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
101041 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
101042 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
101043 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
101044 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
101045 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
101046 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
101047 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
101048 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
101049 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
101050 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
101051 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
101052 +vaddr_51480 vaddr 0 51480 NULL
101053 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
101054 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
101055 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
101056 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
101057 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
101058 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
101059 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
101060 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
101061 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
101062 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
101063 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
101064 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
101065 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
101066 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
101067 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
101068 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
101069 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
101070 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
101071 +sel_write_access_51704 sel_write_access 3 51704 NULL
101072 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
101073 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
101074 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
101075 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
101076 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
101077 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
101078 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
101079 +if_write_51756 if_write 3 51756 NULL
101080 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
101081 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
101082 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
101083 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
101084 +ioread32_51847 ioread32 0 51847 NULL nohasharray
101085 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
101086 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
101087 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
101088 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
101089 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
101090 +user_read_51881 user_read 3 51881 NULL
101091 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
101092 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
101093 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
101094 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
101095 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
101096 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
101097 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
101098 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
101099 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
101100 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
101101 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
101102 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
101103 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
101104 +rdmalt_52022 rdmalt 0 52022 NULL
101105 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
101106 +override_release_52032 override_release 2 52032 NULL
101107 +end_port_52042 end_port 0 52042 NULL
101108 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
101109 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
101110 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
101111 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
101112 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
101113 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
101114 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
101115 +retry_count_read_52129 retry_count_read 3 52129 NULL
101116 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
101117 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
101118 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
101119 +htable_size_52148 htable_size 0-1 52148 NULL
101120 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
101121 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
101122 +alix_present_52165 alix_present 1 52165 NULL
101123 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
101124 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
101125 +print_prefix_52176 print_prefix 0 52176 NULL
101126 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
101127 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
101128 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
101129 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
101130 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
101131 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
101132 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
101133 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
101134 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
101135 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
101136 +read_file_reset_52310 read_file_reset 3 52310 NULL
101137 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
101138 +hwflags_read_52318 hwflags_read 3 52318 NULL
101139 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
101140 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
101141 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
101142 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
101143 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
101144 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
101145 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
101146 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
101147 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
101148 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
101149 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
101150 +delay_status_52431 delay_status 5 52431 NULL
101151 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
101152 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
101153 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
101154 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
101155 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
101156 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
101157 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
101158 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
101159 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
101160 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
101161 +from_oblock_52546 from_oblock 0-1 52546 NULL
101162 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
101163 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
101164 +emit_code_52583 emit_code 0-3 52583 NULL
101165 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
101166 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
101167 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
101168 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
101169 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
101170 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
101171 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
101172 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
101173 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
101174 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
101175 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
101176 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
101177 +twlreg_write_52880 twlreg_write 3 52880 NULL
101178 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
101179 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
101180 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
101181 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
101182 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
101183 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
101184 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
101185 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
101186 +send_packet_52960 send_packet 4 52960 NULL
101187 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
101188 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
101189 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
101190 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
101191 +num_node_state_52989 num_node_state 0 52989 NULL
101192 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
101193 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
101194 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
101195 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
101196 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
101197 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
101198 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
101199 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
101200 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
101201 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
101202 +verity_status_53120 verity_status 5 53120 NULL
101203 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
101204 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
101205 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
101206 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
101207 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
101208 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
101209 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
101210 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
101211 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
101212 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
101213 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
101214 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
101215 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
101216 +vm_mmap_53339 vm_mmap 0 53339 NULL
101217 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
101218 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
101219 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
101220 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
101221 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
101222 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
101223 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
101224 +n2_run_53459 n2_run 3 53459 NULL
101225 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
101226 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
101227 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
101228 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
101229 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
101230 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
101231 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
101232 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
101233 +check_acl_53512 check_acl 0 53512 NULL
101234 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
101235 +set_registers_53582 set_registers 3 53582 NULL
101236 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
101237 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
101238 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
101239 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
101240 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
101241 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
101242 +_preload_range_53676 _preload_range 2-3 53676 NULL
101243 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
101244 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
101245 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
101246 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
101247 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
101248 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
101249 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
101250 +wdm_write_53735 wdm_write 3 53735 NULL
101251 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
101252 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
101253 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
101254 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
101255 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
101256 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
101257 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
101258 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
101259 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
101260 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
101261 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
101262 +pms_read_53873 pms_read 3 53873 NULL
101263 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
101264 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
101265 +proc_file_read_53905 proc_file_read 3 53905 NULL
101266 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
101267 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
101268 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
101269 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
101270 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
101271 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
101272 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
101273 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
101274 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
101275 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
101276 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
101277 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
101278 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
101279 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
101280 +_malloc_54077 _malloc 1 54077 NULL
101281 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
101282 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
101283 +create_xattr_54106 create_xattr 5 54106 NULL
101284 +strn_len_54122 strn_len 0 54122 NULL
101285 +isku_receive_54130 isku_receive 4 54130 NULL
101286 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
101287 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
101288 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
101289 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
101290 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
101291 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
101292 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
101293 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
101294 +reada_add_block_54247 reada_add_block 2 54247 NULL
101295 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
101296 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
101297 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
101298 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
101299 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
101300 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
101301 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
101302 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
101303 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
101304 +sprintf_54306 sprintf 0 54306 NULL
101305 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
101306 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
101307 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
101308 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
101309 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
101310 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
101311 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
101312 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
101313 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
101314 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
101315 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
101316 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
101317 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
101318 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
101319 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
101320 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
101321 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
101322 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
101323 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
101324 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
101325 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
101326 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
101327 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
101328 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
101329 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
101330 +viacam_read_54526 viacam_read 3 54526 NULL
101331 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
101332 +setsockopt_54539 setsockopt 5 54539 NULL
101333 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
101334 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
101335 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
101336 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
101337 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
101338 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
101339 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
101340 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
101341 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
101342 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
101343 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
101344 +evm_read_key_54674 evm_read_key 3 54674 NULL
101345 +resource_string_54699 resource_string 0 54699 NULL
101346 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
101347 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
101348 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
101349 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
101350 +kzalloc_54740 kzalloc 1 54740 NULL
101351 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
101352 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
101353 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
101354 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
101355 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
101356 +domain_init_54797 domain_init 2 54797 NULL
101357 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
101358 +get_dev_size_54807 get_dev_size 0 54807 NULL
101359 +nfsd_write_54809 nfsd_write 6 54809 NULL
101360 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
101361 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
101362 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
101363 +write_rio_54837 write_rio 3 54837 NULL
101364 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
101365 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
101366 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
101367 +printer_read_54851 printer_read 3 54851 NULL
101368 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
101369 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
101370 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
101371 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
101372 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
101373 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
101374 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
101375 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
101376 +add_port_54941 add_port 2 54941 NULL
101377 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
101378 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
101379 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
101380 +c4_add_card_54968 c4_add_card 3 54968 NULL
101381 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
101382 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
101383 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
101384 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
101385 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
101386 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
101387 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
101388 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
101389 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
101390 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
101391 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
101392 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
101393 +corrupt_data_55120 corrupt_data 0 55120 NULL
101394 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
101395 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
101396 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
101397 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
101398 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
101399 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
101400 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
101401 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
101402 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
101403 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
101404 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
101405 +dump_command_55220 dump_command 1 55220 NULL
101406 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
101407 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
101408 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
101409 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
101410 +ptrace_request_55288 ptrace_request 3 55288 NULL
101411 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
101412 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
101413 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
101414 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
101415 +do_shmat_55336 do_shmat 5 55336 NULL
101416 +vme_user_read_55338 vme_user_read 3 55338 NULL
101417 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
101418 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
101419 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
101420 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
101421 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
101422 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
101423 +alloc_skb_55439 alloc_skb 1 55439 NULL
101424 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
101425 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
101426 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
101427 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
101428 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
101429 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
101430 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
101431 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
101432 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
101433 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
101434 +ea_get_55522 ea_get 0 55522 NULL
101435 +buffer_size_55534 buffer_size 0 55534 NULL
101436 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
101437 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
101438 +add_partition_55588 add_partition 2 55588 NULL
101439 +free_pages_55603 free_pages 1 55603 NULL
101440 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
101441 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
101442 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
101443 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
101444 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
101445 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
101446 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
101447 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
101448 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
101449 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
101450 +read_oldmem_55658 read_oldmem 3 55658 NULL
101451 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
101452 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
101453 +get_info_55681 get_info 3 55681 NULL
101454 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101455 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101456 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101457 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101458 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
101459 +set_local_name_55757 set_local_name 4 55757 NULL
101460 +strlen_55778 strlen 0 55778 NULL
101461 +set_spte_55783 set_spte 5-4 55783 NULL
101462 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101463 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101464 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101465 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101466 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101467 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101468 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101469 +hsc_write_55875 hsc_write 3 55875 NULL
101470 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101471 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101472 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
101473 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101474 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
101475 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101476 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101477 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101478 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101479 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101480 +__set_discard_56081 __set_discard 2 56081 NULL
101481 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101482 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101483 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101484 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101485 +map_addr_56144 map_addr 7 56144 NULL
101486 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101487 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101488 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101489 +skb_headroom_56200 skb_headroom 0 56200 NULL
101490 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101491 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101492 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101493 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101494 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101495 +fd_copyin_56247 fd_copyin 3 56247 NULL
101496 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101497 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101498 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101499 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101500 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101501 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101502 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101503 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101504 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101505 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101506 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101507 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101508 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101509 +dev_read_56369 dev_read 3 56369 NULL
101510 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101511 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101512 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101513 +store_msg_56417 store_msg 3 56417 NULL
101514 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101515 +fl_create_56435 fl_create 5 56435 NULL
101516 +gnttab_map_56439 gnttab_map 2 56439 NULL
101517 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101518 +set_connectable_56458 set_connectable 4 56458 NULL
101519 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101520 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101521 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101522 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
101523 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101524 +ip_options_get_56538 ip_options_get 4 56538 NULL
101525 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101526 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101527 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101528 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101529 +event_filter_write_56609 event_filter_write 3 56609 NULL
101530 +gather_array_56641 gather_array 3 56641 NULL
101531 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101532 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101533 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101534 +build_map_info_56696 build_map_info 2 56696 NULL
101535 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101536 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101537 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101538 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101539 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101540 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101541 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101542 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101543 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101544 +hash_lookup_56792 hash_lookup 2 56792 NULL
101545 +do_syslog_56807 do_syslog 3 56807 NULL
101546 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101547 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101548 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101549 +wb_lookup_56858 wb_lookup 2 56858 NULL
101550 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101551 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101552 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101553 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101554 +strcspn_56913 strcspn 0 56913 NULL
101555 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101556 +check_header_56930 check_header 2 56930 NULL
101557 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101558 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101559 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101560 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101561 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101562 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
101563 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101564 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101565 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101566 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101567 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101568 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101569 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101570 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101571 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101572 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101573 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101574 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101575 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101576 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101577 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101578 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101579 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101580 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101581 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
101582 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101583 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101584 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101585 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101586 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101587 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101588 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101589 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101590 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101591 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101592 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101593 +fw_file_size_57307 fw_file_size 0 57307 NULL
101594 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101595 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101596 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101597 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101598 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101599 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101600 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101601 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101602 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101603 +read_file_blob_57406 read_file_blob 3 57406 NULL
101604 +enclosure_register_57412 enclosure_register 3 57412 NULL
101605 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101606 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101607 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101608 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101609 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101610 +ReadReg_57453 ReadReg 0 57453 NULL
101611 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101612 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101613 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101614 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101615 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101616 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101617 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101618 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101619 +skb_headlen_57501 skb_headlen 0 57501 NULL
101620 +copy_in_user_57502 copy_in_user 3 57502 NULL
101621 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101622 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101623 +init_tag_map_57515 init_tag_map 3 57515 NULL
101624 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101625 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101626 +inode_permission_57531 inode_permission 0 57531 NULL
101627 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101628 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101629 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101630 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101631 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
101632 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
101633 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101634 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101635 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
101636 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101637 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101638 +mem_read_57631 mem_read 3 57631 NULL
101639 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101640 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101641 +r3964_write_57662 r3964_write 4 57662 NULL
101642 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101643 +__lgwrite_57669 __lgwrite 4 57669 NULL
101644 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101645 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101646 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101647 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101648 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101649 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
101650 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101651 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101652 +ld2_57794 ld2 0 57794 NULL
101653 +ivtv_read_57796 ivtv_read 3 57796 NULL
101654 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101655 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
101656 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101657 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101658 +copy_to_user_57835 copy_to_user 3 57835 NULL
101659 +flash_read_57843 flash_read 3 57843 NULL
101660 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101661 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101662 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101663 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101664 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101665 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101666 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101667 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101668 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101669 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101670 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101671 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101672 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
101673 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101674 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101675 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101676 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101677 +mce_async_out_58056 mce_async_out 3 58056 NULL
101678 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101679 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101680 +cm4040_write_58079 cm4040_write 3 58079 NULL
101681 +udi_log_event_58105 udi_log_event 3 58105 NULL
101682 +savemem_58129 savemem 3 58129 NULL
101683 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101684 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101685 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101686 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101687 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101688 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
101689 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101690 +read_file_debug_58256 read_file_debug 3 58256 NULL
101691 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101692 +profile_load_58267 profile_load 3 58267 NULL
101693 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101694 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101695 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101696 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101697 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101698 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101699 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101700 +next_pidmap_58347 next_pidmap 2 58347 NULL
101701 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101702 +save_hint_58359 save_hint 2 58359 NULL
101703 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101704 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101705 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101706 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101707 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101708 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101709 +capabilities_read_58457 capabilities_read 3 58457 NULL
101710 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101711 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101712 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101713 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101714 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101715 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101716 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
101717 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101718 +__clear_discard_58546 __clear_discard 2 58546 NULL
101719 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101720 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101721 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101722 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101723 +xip_file_read_58592 xip_file_read 3 58592 NULL
101724 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101725 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101726 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101727 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101728 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101729 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101730 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101731 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
101732 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
101733 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101734 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101735 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101736 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
101737 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101738 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101739 +acpi_map_58725 acpi_map 1-2 58725 NULL
101740 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101741 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101742 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101743 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101744 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101745 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
101746 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101747 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101748 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101749 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101750 +ep_read_58813 ep_read 3 58813 NULL
101751 +command_write_58841 command_write 3 58841 NULL
101752 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101753 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101754 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101755 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101756 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101757 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101758 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101759 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101760 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101761 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101762 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
101763 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101764 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
101765 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101766 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101767 +ep_write_59008 ep_write 3 59008 NULL
101768 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101769 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101770 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101771 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101772 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101773 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101774 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101775 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101776 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101777 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101778 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101779 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101780 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101781 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101782 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101783 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101784 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101785 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101786 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101787 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101788 +dt3155_read_59226 dt3155_read 3 59226 NULL
101789 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101790 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101791 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101792 +nla_len_59258 nla_len 0 59258 NULL
101793 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101794 +fd_copyout_59323 fd_copyout 3 59323 NULL
101795 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101796 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101797 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
101798 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
101799 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101800 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101801 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101802 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101803 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101804 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101805 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101806 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101807 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101808 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101809 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101810 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
101811 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101812 +tunables_write_59563 tunables_write 3 59563 NULL
101813 +memdup_user_59590 memdup_user 2 59590 NULL
101814 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101815 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101816 +mtrr_write_59622 mtrr_write 3 59622 NULL
101817 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101818 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101819 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101820 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101821 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101822 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101823 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
101824 +sriov_enable_59689 sriov_enable 2 59689 NULL
101825 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101826 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101827 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101828 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101829 +strnlen_59746 strnlen 0 59746 NULL
101830 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101831 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101832 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101833 +venus_remove_59781 venus_remove 4 59781 NULL
101834 +ipw_write_59807 ipw_write 3 59807 NULL
101835 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101836 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101837 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101838 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101839 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
101840 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101841 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101842 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101843 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
101844 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101845 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101846 +lookup_node_59953 lookup_node 2 59953 NULL
101847 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
101848 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
101849 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
101850 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101851 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101852 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101853 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101854 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
101855 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101856 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101857 +register_device_60015 register_device 2-3 60015 NULL
101858 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101859 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101860 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101861 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101862 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101863 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101864 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101865 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
101866 +compat_writev_60063 compat_writev 3 60063 NULL
101867 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
101868 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101869 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101870 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101871 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101872 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101873 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101874 +init_state_60165 init_state 2 60165 NULL
101875 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101876 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101877 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101878 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101879 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101880 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101881 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101882 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101883 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101884 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
101885 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
101886 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101887 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101888 +printer_write_60276 printer_write 3 60276 NULL
101889 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101890 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101891 +getDataLength_60301 getDataLength 0 60301 NULL
101892 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101893 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101894 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101895 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101896 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
101897 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101898 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101899 +driver_names_read_60399 driver_names_read 3 60399 NULL
101900 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
101901 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101902 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101903 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101904 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101905 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101906 +rx_data_60442 rx_data 4 60442 NULL
101907 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101908 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
101909 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101910 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101911 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101912 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101913 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101914 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101915 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101916 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101917 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101918 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101919 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101920 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101921 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101922 +init_data_container_60709 init_data_container 1 60709 NULL
101923 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101924 +raid_status_60755 raid_status 5 60755 NULL
101925 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101926 +opticon_write_60775 opticon_write 4 60775 NULL
101927 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101928 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101929 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101930 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101931 +generic_writepages_60871 generic_writepages 0 60871 NULL
101932 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101933 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101934 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101935 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101936 +sys_mlock_60932 sys_mlock 1 60932 NULL
101937 +pti_char_write_60960 pti_char_write 3 60960 NULL
101938 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101939 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101940 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101941 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101942 +symtab_init_61050 symtab_init 2 61050 NULL
101943 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101944 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101945 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101946 +get_derived_key_61100 get_derived_key 4 61100 NULL
101947 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101948 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101949 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101950 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101951 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101952 +__vmalloc_61168 __vmalloc 1 61168 NULL
101953 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101954 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101955 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101956 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101957 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101958 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101959 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101960 +sys_add_key_61288 sys_add_key 4 61288 NULL
101961 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101962 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101963 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101964 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101965 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101966 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101967 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101968 +change_xattr_61390 change_xattr 5 61390 NULL
101969 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101970 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101971 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101972 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101973 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101974 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101975 +erst_errno_61526 erst_errno 0 61526 NULL
101976 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101977 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101978 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101979 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101980 +seq_open_private_61589 seq_open_private 3 61589 NULL
101981 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101982 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101983 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101984 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101985 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101986 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101987 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101988 +resize_stripes_61650 resize_stripes 2 61650 NULL
101989 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101990 +insert_one_name_61668 insert_one_name 7 61668 NULL
101991 +lock_loop_61681 lock_loop 1 61681 NULL
101992 +filter_read_61692 filter_read 3 61692 NULL
101993 +iov_length_61716 iov_length 0 61716 NULL
101994 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101995 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101996 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101997 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101998 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101999 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
102000 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
102001 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
102002 +get_fw_name_61874 get_fw_name 3 61874 NULL
102003 +free_init_pages_61875 free_init_pages 2 61875 NULL
102004 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
102005 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
102006 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
102007 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
102008 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
102009 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
102010 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
102011 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
102012 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
102013 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
102014 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
102015 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
102016 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
102017 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
102018 +cow_file_range_61979 cow_file_range 3 61979 NULL
102019 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
102020 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
102021 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
102022 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
102023 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
102024 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
102025 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
102026 +do_pselect_62061 do_pselect 1 62061 NULL
102027 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
102028 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
102029 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
102030 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
102031 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
102032 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
102033 +ql_status_62135 ql_status 5 62135 NULL
102034 +video_usercopy_62151 video_usercopy 2 62151 NULL
102035 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
102036 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
102037 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
102038 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
102039 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
102040 +allocate_partition_62245 allocate_partition 4 62245 NULL
102041 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
102042 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
102043 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
102044 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
102045 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
102046 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
102047 +subseq_list_62332 subseq_list 3-0 62332 NULL
102048 +flash_write_62354 flash_write 3 62354 NULL
102049 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
102050 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
102051 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
102052 +altera_irscan_62396 altera_irscan 2 62396 NULL
102053 +set_ssp_62411 set_ssp 4 62411 NULL
102054 +unmap_single_62423 unmap_single 2 62423 NULL
102055 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
102056 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
102057 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
102058 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
102059 +remove_mapping_62491 remove_mapping 2 62491 NULL
102060 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
102061 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
102062 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
102063 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
102064 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
102065 +debugfs_read_62535 debugfs_read 3 62535 NULL
102066 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
102067 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
102068 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
102069 +get_subdir_62581 get_subdir 3 62581 NULL
102070 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
102071 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
102072 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
102073 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
102074 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
102075 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
102076 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
102077 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
102078 +write_62671 write 3 62671 NULL
102079 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
102080 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
102081 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
102082 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
102083 +rdm_62719 rdm 0 62719 NULL
102084 +key_replays_read_62746 key_replays_read 3 62746 NULL
102085 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
102086 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
102087 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
102088 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
102089 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
102090 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
102091 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
102092 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
102093 +set_swbp_62853 set_swbp 3 62853 NULL
102094 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
102095 +aoechr_write_62883 aoechr_write 3 62883 NULL
102096 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
102097 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
102098 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
102099 +getdqbuf_62908 getdqbuf 1 62908 NULL
102100 +try_async_pf_62914 try_async_pf 3 62914 NULL
102101 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
102102 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
102103 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
102104 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
102105 +unlink1_63059 unlink1 3 63059 NULL
102106 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
102107 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
102108 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
102109 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
102110 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
102111 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
102112 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
102113 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
102114 +vme_master_read_63221 vme_master_read 0 63221 NULL
102115 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
102116 +ptp_read_63251 ptp_read 4 63251 NULL
102117 +raid5_resize_63306 raid5_resize 2 63306 NULL
102118 +proc_info_read_63344 proc_info_read 3 63344 NULL
102119 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
102120 +idmouse_read_63374 idmouse_read 3 63374 NULL
102121 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
102122 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
102123 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
102124 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
102125 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
102126 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
102127 +kone_send_63435 kone_send 4 63435 NULL
102128 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
102129 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
102130 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
102131 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
102132 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
102133 +read_kcore_63488 read_kcore 3 63488 NULL
102134 +save_hint_63497 save_hint 2 63497 NULL
102135 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
102136 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
102137 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
102138 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
102139 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
102140 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
102141 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
102142 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
102143 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
102144 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
102145 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
102146 +module_alloc_63630 module_alloc 1 63630 NULL
102147 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
102148 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
102149 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
102150 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
102151 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
102152 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
102153 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
102154 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
102155 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
102156 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
102157 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
102158 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
102159 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
102160 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
102161 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
102162 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
102163 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
102164 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
102165 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
102166 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
102167 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
102168 +sel_write_load_63830 sel_write_load 3 63830 NULL
102169 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
102170 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
102171 +divas_write_63901 divas_write 3 63901 NULL
102172 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
102173 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
102174 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
102175 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
102176 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
102177 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
102178 +__team_options_register_63941 __team_options_register 3 63941 NULL
102179 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
102180 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
102181 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
102182 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
102183 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
102184 +kmemdup_64015 kmemdup 2 64015 NULL
102185 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
102186 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
102187 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
102188 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
102189 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
102190 +get_u8_64076 get_u8 0 64076 NULL
102191 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
102192 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
102193 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
102194 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
102195 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
102196 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
102197 +init_bch_64130 init_bch 1-2 64130 NULL
102198 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
102199 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
102200 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
102201 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
102202 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
102203 +read_pulse_64227 read_pulse 0-3 64227 NULL
102204 +header_len_64232 header_len 0 64232 NULL
102205 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
102206 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
102207 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
102208 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
102209 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
102210 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
102211 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
102212 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
102213 +ffz_64324 ffz 0 64324 NULL
102214 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
102215 +ts_write_64336 ts_write 3 64336 NULL
102216 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
102217 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
102218 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
102219 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
102220 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
102221 +ilo_write_64378 ilo_write 3 64378 NULL
102222 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
102223 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
102224 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
102225 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
102226 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
102227 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
102228 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
102229 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
102230 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
102231 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
102232 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
102233 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
102234 +cap_capable_64462 cap_capable 0 64462 NULL
102235 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
102236 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
102237 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
102238 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
102239 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
102240 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
102241 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
102242 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
102243 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
102244 +__spi_sync_64561 __spi_sync 0 64561 NULL
102245 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
102246 +fanotify_write_64623 fanotify_write 3 64623 NULL
102247 +to_dblock_64655 to_dblock 0-1 64655 NULL
102248 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
102249 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
102250 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
102251 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
102252 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
102253 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
102254 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
102255 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
102256 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
102257 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
102258 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
102259 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
102260 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
102261 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
102262 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
102263 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
102264 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
102265 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
102266 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
102267 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
102268 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
102269 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
102270 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
102271 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
102272 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
102273 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
102274 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
102275 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
102276 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
102277 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
102278 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
102279 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
102280 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
102281 +pskb_pull_65005 pskb_pull 2 65005 NULL
102282 +unifi_write_65012 unifi_write 3 65012 NULL
102283 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
102284 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
102285 +insert_dent_65034 insert_dent 7 65034 NULL
102286 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
102287 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
102288 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
102289 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
102290 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
102291 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
102292 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
102293 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
102294 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
102295 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
102296 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
102297 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
102298 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
102299 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
102300 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
102301 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
102302 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
102303 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
102304 +get_var_len_65304 get_var_len 0 65304 NULL
102305 +unpack_array_65318 unpack_array 0 65318 NULL
102306 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
102307 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
102308 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
102309 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
102310 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
102311 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
102312 +strchr_65372 strchr 0 65372 NULL
102313 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
102314 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
102315 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
102316 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
102317 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
102318 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
102319 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
102320 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
102321 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
102322 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
102323 +alloc_dr_65495 alloc_dr 2 65495 NULL
102324 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
102325 new file mode 100644
102326 index 0000000..9db0d0e
102327 --- /dev/null
102328 +++ b/tools/gcc/size_overflow_plugin.c
102329 @@ -0,0 +1,2114 @@
102330 +/*
102331 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
102332 + * Licensed under the GPL v2, or (at your option) v3
102333 + *
102334 + * Homepage:
102335 + * http://www.grsecurity.net/~ephox/overflow_plugin/
102336 + *
102337 + * Documentation:
102338 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
102339 + *
102340 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
102341 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
102342 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
102343 + *
102344 + * Usage:
102345 + * $ 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
102346 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
102347 + */
102348 +
102349 +#include "gcc-plugin.h"
102350 +#include "config.h"
102351 +#include "system.h"
102352 +#include "coretypes.h"
102353 +#include "tree.h"
102354 +#include "tree-pass.h"
102355 +#include "intl.h"
102356 +#include "plugin-version.h"
102357 +#include "tm.h"
102358 +#include "toplev.h"
102359 +#include "function.h"
102360 +#include "tree-flow.h"
102361 +#include "plugin.h"
102362 +#include "gimple.h"
102363 +#include "diagnostic.h"
102364 +#include "cfgloop.h"
102365 +
102366 +#if BUILDING_GCC_VERSION >= 4008
102367 +#define TODO_dump_func 0
102368 +#endif
102369 +
102370 +struct size_overflow_hash {
102371 + const struct size_overflow_hash * const next;
102372 + const char * const name;
102373 + const unsigned int param;
102374 +};
102375 +
102376 +#include "size_overflow_hash.h"
102377 +
102378 +enum mark {
102379 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
102380 +};
102381 +
102382 +enum err_code_conditions {
102383 + CAST_ONLY, FROM_CONST
102384 +};
102385 +
102386 +static unsigned int call_count = 0;
102387 +
102388 +#define __unused __attribute__((__unused__))
102389 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102390 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
102391 +#define BEFORE_STMT true
102392 +#define AFTER_STMT false
102393 +#define CREATE_NEW_VAR NULL_TREE
102394 +#define CODES_LIMIT 32
102395 +#define MAX_PARAM 31
102396 +#define MY_STMT GF_PLF_1
102397 +#define NO_CAST_CHECK GF_PLF_2
102398 +#define FROM_ARG true
102399 +#define FROM_RET false
102400 +
102401 +#if BUILDING_GCC_VERSION == 4005
102402 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
102403 +#endif
102404 +
102405 +int plugin_is_GPL_compatible;
102406 +void debug_gimple_stmt(gimple gs);
102407 +
102408 +static tree expand(struct pointer_set_t *visited, tree lhs);
102409 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
102410 +static tree report_size_overflow_decl;
102411 +static const_tree const_char_ptr_type_node;
102412 +static unsigned int handle_function(void);
102413 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
102414 +static tree get_size_overflow_type(gimple stmt, const_tree node);
102415 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
102416 +static void print_missing_msg(tree func, unsigned int argnum);
102417 +
102418 +static struct plugin_info size_overflow_plugin_info = {
102419 + .version = "20130410beta",
102420 + .help = "no-size-overflow\tturn off size overflow checking\n",
102421 +};
102422 +
102423 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102424 +{
102425 + unsigned int arg_count;
102426 + enum tree_code code = TREE_CODE(*node);
102427 +
102428 + switch (code) {
102429 + case FUNCTION_DECL:
102430 + arg_count = type_num_arguments(TREE_TYPE(*node));
102431 + break;
102432 + case FUNCTION_TYPE:
102433 + case METHOD_TYPE:
102434 + arg_count = type_num_arguments(*node);
102435 + break;
102436 + default:
102437 + *no_add_attrs = true;
102438 + error("%s: %qE attribute only applies to functions", __func__, name);
102439 + return NULL_TREE;
102440 + }
102441 +
102442 + for (; args; args = TREE_CHAIN(args)) {
102443 + tree position = TREE_VALUE(args);
102444 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102445 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102446 + *no_add_attrs = true;
102447 + }
102448 + }
102449 + return NULL_TREE;
102450 +}
102451 +
102452 +static const char* get_asm_name(tree node)
102453 +{
102454 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
102455 +}
102456 +
102457 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102458 +{
102459 + unsigned int arg_count, arg_num;
102460 + enum tree_code code = TREE_CODE(*node);
102461 +
102462 + switch (code) {
102463 + case FUNCTION_DECL:
102464 + arg_count = type_num_arguments(TREE_TYPE(*node));
102465 + break;
102466 + case FUNCTION_TYPE:
102467 + case METHOD_TYPE:
102468 + arg_count = type_num_arguments(*node);
102469 + break;
102470 + case FIELD_DECL:
102471 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102472 + if (arg_num != 0) {
102473 + *no_add_attrs = true;
102474 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102475 + }
102476 + return NULL_TREE;
102477 + default:
102478 + *no_add_attrs = true;
102479 + error("%qE attribute only applies to functions", name);
102480 + return NULL_TREE;
102481 + }
102482 +
102483 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102484 + return NULL_TREE;
102485 +
102486 + for (; args; args = TREE_CHAIN(args)) {
102487 + tree position = TREE_VALUE(args);
102488 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102489 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102490 + *no_add_attrs = true;
102491 + }
102492 + }
102493 + return NULL_TREE;
102494 +}
102495 +
102496 +static struct attribute_spec size_overflow_attr = {
102497 + .name = "size_overflow",
102498 + .min_length = 1,
102499 + .max_length = -1,
102500 + .decl_required = true,
102501 + .type_required = false,
102502 + .function_type_required = false,
102503 + .handler = handle_size_overflow_attribute,
102504 +#if BUILDING_GCC_VERSION >= 4007
102505 + .affects_type_identity = false
102506 +#endif
102507 +};
102508 +
102509 +static struct attribute_spec intentional_overflow_attr = {
102510 + .name = "intentional_overflow",
102511 + .min_length = 1,
102512 + .max_length = -1,
102513 + .decl_required = true,
102514 + .type_required = false,
102515 + .function_type_required = false,
102516 + .handler = handle_intentional_overflow_attribute,
102517 +#if BUILDING_GCC_VERSION >= 4007
102518 + .affects_type_identity = false
102519 +#endif
102520 +};
102521 +
102522 +static void register_attributes(void __unused *event_data, void __unused *data)
102523 +{
102524 + register_attribute(&size_overflow_attr);
102525 + register_attribute(&intentional_overflow_attr);
102526 +}
102527 +
102528 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102529 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102530 +{
102531 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102532 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102533 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102534 +
102535 + unsigned int m = 0x57559429;
102536 + unsigned int n = 0x5052acdb;
102537 + const unsigned int *key4 = (const unsigned int *)key;
102538 + unsigned int h = len;
102539 + unsigned int k = len + seed + n;
102540 + unsigned long long p;
102541 +
102542 + while (len >= 8) {
102543 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102544 + len -= 8;
102545 + }
102546 + if (len >= 4) {
102547 + cwmixb(key4[0]) key4 += 1;
102548 + len -= 4;
102549 + }
102550 + if (len)
102551 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102552 + cwmixb(h ^ (k + n));
102553 + return k ^ h;
102554 +
102555 +#undef cwfold
102556 +#undef cwmixa
102557 +#undef cwmixb
102558 +}
102559 +
102560 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102561 +{
102562 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102563 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102564 + return fn ^ codes;
102565 +}
102566 +
102567 +static inline tree get_original_function_decl(tree fndecl)
102568 +{
102569 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102570 + return DECL_ABSTRACT_ORIGIN(fndecl);
102571 + return fndecl;
102572 +}
102573 +
102574 +static inline gimple get_def_stmt(const_tree node)
102575 +{
102576 + gcc_assert(node != NULL_TREE);
102577 + if (TREE_CODE(node) != SSA_NAME)
102578 + return NULL;
102579 + return SSA_NAME_DEF_STMT(node);
102580 +}
102581 +
102582 +static unsigned char get_tree_code(const_tree type)
102583 +{
102584 + switch (TREE_CODE(type)) {
102585 + case ARRAY_TYPE:
102586 + return 0;
102587 + case BOOLEAN_TYPE:
102588 + return 1;
102589 + case ENUMERAL_TYPE:
102590 + return 2;
102591 + case FUNCTION_TYPE:
102592 + return 3;
102593 + case INTEGER_TYPE:
102594 + return 4;
102595 + case POINTER_TYPE:
102596 + return 5;
102597 + case RECORD_TYPE:
102598 + return 6;
102599 + case UNION_TYPE:
102600 + return 7;
102601 + case VOID_TYPE:
102602 + return 8;
102603 + case REAL_TYPE:
102604 + return 9;
102605 + case VECTOR_TYPE:
102606 + return 10;
102607 + case REFERENCE_TYPE:
102608 + return 11;
102609 + case OFFSET_TYPE:
102610 + return 12;
102611 + case COMPLEX_TYPE:
102612 + return 13;
102613 + default:
102614 + debug_tree((tree)type);
102615 + gcc_unreachable();
102616 + }
102617 +}
102618 +
102619 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102620 +{
102621 + gcc_assert(type != NULL_TREE);
102622 +
102623 + while (type && len < CODES_LIMIT) {
102624 + tree_codes[len] = get_tree_code(type);
102625 + len++;
102626 + type = TREE_TYPE(type);
102627 + }
102628 + return len;
102629 +}
102630 +
102631 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102632 +{
102633 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102634 + enum tree_code code = TREE_CODE(type);
102635 + size_t len = 0;
102636 +
102637 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102638 +
102639 + arg = TYPE_ARG_TYPES(type);
102640 + // skip builtins __builtin_constant_p
102641 + if (!arg && DECL_BUILT_IN(fndecl))
102642 + return 0;
102643 +
102644 + if (TREE_CODE_CLASS(code) == tcc_type)
102645 + result = type;
102646 + else
102647 + result = DECL_RESULT(fndecl);
102648 +
102649 + gcc_assert(result != NULL_TREE);
102650 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102651 +
102652 + if (arg == NULL_TREE) {
102653 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102654 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102655 + if (arg_field == NULL_TREE)
102656 + return 0;
102657 + arg = TREE_TYPE(arg_field);
102658 + len = add_type_codes(arg, tree_codes, len);
102659 + gcc_assert(len != 0);
102660 + return len;
102661 + }
102662 +
102663 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102664 + while (arg && len < CODES_LIMIT) {
102665 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102666 + arg = TREE_CHAIN(arg);
102667 + }
102668 +
102669 + gcc_assert(len != 0);
102670 + return len;
102671 +}
102672 +
102673 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102674 +{
102675 + unsigned int hash;
102676 + const struct size_overflow_hash *entry;
102677 + unsigned char tree_codes[CODES_LIMIT];
102678 + size_t len;
102679 + const char *func_name;
102680 +
102681 + fndecl = get_original_function_decl(fndecl);
102682 + len = get_function_decl(fndecl, tree_codes);
102683 + if (len == 0)
102684 + return NULL;
102685 +
102686 + func_name = get_asm_name(fndecl);
102687 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102688 +
102689 + entry = size_overflow_hash[hash];
102690 + while (entry) {
102691 + if (!strcmp(entry->name, func_name))
102692 + return entry;
102693 + entry = entry->next;
102694 + }
102695 +
102696 + return NULL;
102697 +}
102698 +
102699 +static bool is_bool(const_tree node)
102700 +{
102701 + const_tree type;
102702 +
102703 + if (node == NULL_TREE)
102704 + return false;
102705 +
102706 + type = TREE_TYPE(node);
102707 + if (!INTEGRAL_TYPE_P(type))
102708 + return false;
102709 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102710 + return true;
102711 + if (TYPE_PRECISION(type) == 1)
102712 + return true;
102713 + return false;
102714 +}
102715 +
102716 +static bool skip_types(const_tree var)
102717 +{
102718 + tree type;
102719 +
102720 + if (is_gimple_constant(var))
102721 + return true;
102722 +
102723 + switch (TREE_CODE(var)) {
102724 + case ADDR_EXPR:
102725 +#if BUILDING_GCC_VERSION >= 4006
102726 + case MEM_REF:
102727 +#endif
102728 + case ARRAY_REF:
102729 + case BIT_FIELD_REF:
102730 + case INDIRECT_REF:
102731 + case TARGET_MEM_REF:
102732 + return true;
102733 + case PARM_DECL:
102734 + case VAR_DECL:
102735 + case COMPONENT_REF:
102736 + return false;
102737 + default:
102738 + break;
102739 + }
102740 +
102741 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102742 +
102743 + type = TREE_TYPE(var);
102744 + switch (TREE_CODE(type)) {
102745 + case INTEGER_TYPE:
102746 + case ENUMERAL_TYPE:
102747 + return false;
102748 + case BOOLEAN_TYPE:
102749 + return is_bool(var);
102750 + default:
102751 + break;
102752 + }
102753 +
102754 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102755 +
102756 + type = TREE_TYPE(type);
102757 + gcc_assert(type != NULL_TREE);
102758 + switch (TREE_CODE(type)) {
102759 + case RECORD_TYPE:
102760 + case POINTER_TYPE:
102761 + case ARRAY_TYPE:
102762 + return true;
102763 + case VOID_TYPE:
102764 + case INTEGER_TYPE:
102765 + case UNION_TYPE:
102766 + return false;
102767 + default:
102768 + break;
102769 + }
102770 +
102771 + debug_tree((tree)var);
102772 + gcc_unreachable();
102773 +}
102774 +
102775 +static unsigned int find_arg_number(const_tree arg, tree func)
102776 +{
102777 + tree var;
102778 + unsigned int argnum = 1;
102779 +
102780 + if (TREE_CODE(arg) == SSA_NAME)
102781 + arg = SSA_NAME_VAR(arg);
102782 +
102783 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102784 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102785 + continue;
102786 + if (!skip_types(var))
102787 + return argnum;
102788 + }
102789 +
102790 + return 0;
102791 +}
102792 +
102793 +static tree create_new_var(tree type)
102794 +{
102795 + tree new_var = create_tmp_var(type, "cicus");
102796 +
102797 +#if BUILDING_GCC_VERSION <= 4007
102798 + add_referenced_var(new_var);
102799 + mark_sym_for_renaming(new_var);
102800 +#endif
102801 + return new_var;
102802 +}
102803 +
102804 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102805 +{
102806 + gimple assign;
102807 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102808 + tree type = TREE_TYPE(rhs1);
102809 + tree lhs = create_new_var(type);
102810 +
102811 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102812 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102813 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102814 +
102815 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102816 + update_stmt(assign);
102817 + gimple_set_plf(assign, MY_STMT, true);
102818 + return assign;
102819 +}
102820 +
102821 +static tree cast_a_tree(tree type, tree var)
102822 +{
102823 + gcc_assert(type != NULL_TREE);
102824 + gcc_assert(var != NULL_TREE);
102825 + gcc_assert(fold_convertible_p(type, var));
102826 +
102827 + return fold_convert(type, var);
102828 +}
102829 +
102830 +static tree get_lhs(const_gimple stmt)
102831 +{
102832 + switch (gimple_code(stmt)) {
102833 + case GIMPLE_ASSIGN:
102834 + return gimple_get_lhs(stmt);
102835 + case GIMPLE_PHI:
102836 + return gimple_phi_result(stmt);
102837 + case GIMPLE_CALL:
102838 + return gimple_call_lhs(stmt);
102839 + default:
102840 + return NULL_TREE;
102841 + }
102842 +}
102843 +
102844 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102845 +{
102846 + const_gimple def_stmt = get_def_stmt(rhs);
102847 +
102848 + if (force)
102849 + return false;
102850 +
102851 + if (is_gimple_constant(rhs))
102852 + return false;
102853 +
102854 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102855 + return false;
102856 +
102857 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102858 + return false;
102859 +
102860 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102861 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102862 + return false;
102863 +
102864 + return true;
102865 +}
102866 +
102867 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102868 +{
102869 + gimple assign, def_stmt;
102870 +
102871 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102872 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102873 + gcc_unreachable();
102874 +
102875 + def_stmt = get_def_stmt(rhs);
102876 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102877 + return def_stmt;
102878 +
102879 + if (lhs == CREATE_NEW_VAR)
102880 + lhs = create_new_var(dst_type);
102881 +
102882 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102883 +
102884 + if (!gsi_end_p(*gsi)) {
102885 + location_t loc = gimple_location(gsi_stmt(*gsi));
102886 + gimple_set_location(assign, loc);
102887 + }
102888 +
102889 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102890 +
102891 + if (before)
102892 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102893 + else
102894 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102895 + update_stmt(assign);
102896 + gimple_set_plf(assign, MY_STMT, true);
102897 +
102898 + return assign;
102899 +}
102900 +
102901 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102902 +{
102903 + gimple_stmt_iterator gsi;
102904 + tree lhs;
102905 + const_gimple new_stmt;
102906 +
102907 + if (rhs == NULL_TREE)
102908 + return NULL_TREE;
102909 +
102910 + gsi = gsi_for_stmt(stmt);
102911 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102912 +
102913 + lhs = get_lhs(new_stmt);
102914 + gcc_assert(lhs != NULL_TREE);
102915 + return lhs;
102916 +}
102917 +
102918 +static tree cast_to_TI_type(gimple stmt, tree node)
102919 +{
102920 + gimple_stmt_iterator gsi;
102921 + gimple cast_stmt;
102922 + tree type = TREE_TYPE(node);
102923 +
102924 + if (types_compatible_p(type, intTI_type_node))
102925 + return node;
102926 +
102927 + gsi = gsi_for_stmt(stmt);
102928 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102929 + return gimple_get_lhs(cast_stmt);
102930 +}
102931 +
102932 +static void check_function_hash(const_gimple stmt)
102933 +{
102934 + tree func;
102935 + const struct size_overflow_hash *hash;
102936 +
102937 + if (gimple_code(stmt) != GIMPLE_CALL)
102938 + return;
102939 +
102940 + func = gimple_call_fndecl(stmt);
102941 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102942 + if (func == NULL_TREE)
102943 + return;
102944 +
102945 + hash = get_function_hash(func);
102946 + if (!hash)
102947 + print_missing_msg(func, 0);
102948 +}
102949 +
102950 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102951 +{
102952 + tree lhs, new_lhs;
102953 + gimple_stmt_iterator gsi;
102954 +
102955 + if (rhs1 == NULL_TREE) {
102956 + debug_gimple_stmt(oldstmt);
102957 + error("%s: rhs1 is NULL_TREE", __func__);
102958 + gcc_unreachable();
102959 + }
102960 +
102961 + switch (gimple_code(oldstmt)) {
102962 + case GIMPLE_ASM:
102963 + lhs = rhs1;
102964 + break;
102965 + case GIMPLE_CALL:
102966 + lhs = gimple_call_lhs(oldstmt);
102967 + break;
102968 + case GIMPLE_ASSIGN:
102969 + lhs = gimple_get_lhs(oldstmt);
102970 + break;
102971 + default:
102972 + debug_gimple_stmt(oldstmt);
102973 + gcc_unreachable();
102974 + }
102975 +
102976 + gsi = gsi_for_stmt(oldstmt);
102977 + pointer_set_insert(visited, oldstmt);
102978 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102979 + basic_block next_bb, cur_bb;
102980 + const_edge e;
102981 +
102982 + gcc_assert(before == false);
102983 + gcc_assert(stmt_can_throw_internal(oldstmt));
102984 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102985 + gcc_assert(!gsi_end_p(gsi));
102986 +
102987 + cur_bb = gimple_bb(oldstmt);
102988 + next_bb = cur_bb->next_bb;
102989 + e = find_edge(cur_bb, next_bb);
102990 + gcc_assert(e != NULL);
102991 + gcc_assert(e->flags & EDGE_FALLTHRU);
102992 +
102993 + gsi = gsi_after_labels(next_bb);
102994 + gcc_assert(!gsi_end_p(gsi));
102995 +
102996 + before = true;
102997 + oldstmt = gsi_stmt(gsi);
102998 + }
102999 +
103000 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
103001 + return new_lhs;
103002 +}
103003 +
103004 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
103005 +{
103006 + gimple stmt;
103007 + gimple_stmt_iterator gsi;
103008 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
103009 +
103010 + if (gimple_plf(oldstmt, MY_STMT))
103011 + return lhs;
103012 +
103013 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
103014 + rhs1 = gimple_assign_rhs1(oldstmt);
103015 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
103016 + }
103017 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
103018 + rhs2 = gimple_assign_rhs2(oldstmt);
103019 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
103020 + }
103021 +
103022 + stmt = gimple_copy(oldstmt);
103023 + gimple_set_location(stmt, gimple_location(oldstmt));
103024 + gimple_set_plf(stmt, MY_STMT, true);
103025 +
103026 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
103027 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
103028 +
103029 + size_overflow_type = get_size_overflow_type(oldstmt, node);
103030 +
103031 + new_var = create_new_var(size_overflow_type);
103032 + new_var = make_ssa_name(new_var, stmt);
103033 + gimple_set_lhs(stmt, new_var);
103034 +
103035 + if (rhs1 != NULL_TREE)
103036 + gimple_assign_set_rhs1(stmt, rhs1);
103037 +
103038 + if (rhs2 != NULL_TREE)
103039 + gimple_assign_set_rhs2(stmt, rhs2);
103040 +#if BUILDING_GCC_VERSION >= 4007
103041 + if (rhs3 != NULL_TREE)
103042 + gimple_assign_set_rhs3(stmt, rhs3);
103043 +#endif
103044 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
103045 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
103046 +
103047 + gsi = gsi_for_stmt(oldstmt);
103048 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
103049 + update_stmt(stmt);
103050 + pointer_set_insert(visited, oldstmt);
103051 + return gimple_get_lhs(stmt);
103052 +}
103053 +
103054 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
103055 +{
103056 + basic_block first_bb;
103057 + gimple assign;
103058 + gimple_stmt_iterator gsi;
103059 +
103060 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103061 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103062 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
103063 +
103064 + gsi = gsi_start_bb(first_bb);
103065 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
103066 + return gimple_get_lhs(assign);
103067 +}
103068 +
103069 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
103070 +{
103071 + gimple_stmt_iterator gsi;
103072 + const_gimple assign;
103073 + gimple def_stmt = get_def_stmt(new_arg);
103074 +
103075 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
103076 + gsi = gsi_after_labels(gimple_bb(def_stmt));
103077 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
103078 + } else {
103079 + gsi = gsi_for_stmt(def_stmt);
103080 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
103081 + }
103082 +
103083 + return gimple_get_lhs(assign);
103084 +}
103085 +
103086 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
103087 +{
103088 + basic_block bb;
103089 + gimple_stmt_iterator gsi;
103090 + const_gimple assign, def_stmt;
103091 +
103092 + def_stmt = get_def_stmt(arg);
103093 + bb = gimple_bb(def_stmt);
103094 + gcc_assert(bb->index != 0);
103095 + gsi = gsi_after_labels(bb);
103096 +
103097 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
103098 + return gimple_get_lhs(assign);
103099 +}
103100 +
103101 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
103102 +{
103103 + tree size_overflow_type;
103104 + const_gimple def_stmt = get_def_stmt(arg);
103105 +
103106 + if (phi_ssa_name != NULL_TREE)
103107 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
103108 +
103109 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
103110 +
103111 + if (new_arg != NULL_TREE) {
103112 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
103113 + return use_phi_ssa_name(phi_ssa_name, new_arg);
103114 + }
103115 +
103116 + switch(gimple_code(def_stmt)) {
103117 + case GIMPLE_PHI:
103118 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
103119 + case GIMPLE_NOP:
103120 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
103121 + default:
103122 + debug_gimple_stmt((gimple)def_stmt);
103123 + gcc_unreachable();
103124 + }
103125 +}
103126 +
103127 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
103128 +{
103129 + basic_block bb;
103130 + gimple phi;
103131 + gimple_seq seq;
103132 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
103133 +
103134 + bb = gsi_bb(gsi);
103135 +
103136 + phi = create_phi_node(result, bb);
103137 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
103138 + seq = phi_nodes(bb);
103139 + gsi = gsi_last(seq);
103140 + gsi_remove(&gsi, false);
103141 +
103142 + gsi = gsi_for_stmt(oldstmt);
103143 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
103144 + gimple_set_bb(phi, bb);
103145 + gimple_set_plf(phi, MY_STMT, true);
103146 + return phi;
103147 +}
103148 +
103149 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
103150 +{
103151 + gimple new_phi = NULL;
103152 + gimple oldstmt = get_def_stmt(orig_result);
103153 + tree phi_ssa_name = NULL_TREE;
103154 + unsigned int i;
103155 +
103156 + pointer_set_insert(visited, oldstmt);
103157 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
103158 + tree arg, new_arg;
103159 +
103160 + arg = gimple_phi_arg_def(oldstmt, i);
103161 +
103162 + new_arg = expand(visited, arg);
103163 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
103164 + if (i == 0) {
103165 + phi_ssa_name = new_arg;
103166 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
103167 + }
103168 +
103169 + gcc_assert(new_phi != NULL);
103170 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
103171 + }
103172 +
103173 + gcc_assert(new_phi != NULL);
103174 + update_stmt(new_phi);
103175 + return gimple_phi_result(new_phi);
103176 +}
103177 +
103178 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
103179 +{
103180 + const_gimple assign;
103181 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103182 + tree origtype = TREE_TYPE(orig_rhs);
103183 +
103184 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
103185 +
103186 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103187 + return gimple_get_lhs(assign);
103188 +}
103189 +
103190 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
103191 +{
103192 + const_tree rhs1, lhs, rhs1_type, lhs_type;
103193 + enum machine_mode lhs_mode, rhs_mode;
103194 + gimple def_stmt = get_def_stmt(no_const_rhs);
103195 +
103196 + if (!gimple_assign_cast_p(def_stmt))
103197 + return false;
103198 +
103199 + rhs1 = gimple_assign_rhs1(def_stmt);
103200 + lhs = gimple_get_lhs(def_stmt);
103201 + rhs1_type = TREE_TYPE(rhs1);
103202 + lhs_type = TREE_TYPE(lhs);
103203 + rhs_mode = TYPE_MODE(rhs1_type);
103204 + lhs_mode = TYPE_MODE(lhs_type);
103205 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
103206 + return false;
103207 +
103208 + return true;
103209 +}
103210 +
103211 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
103212 +{
103213 + tree rhs1 = gimple_assign_rhs1(stmt);
103214 + tree lhs = gimple_get_lhs(stmt);
103215 + const_tree rhs1_type = TREE_TYPE(rhs1);
103216 + const_tree lhs_type = TREE_TYPE(lhs);
103217 +
103218 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
103219 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103220 +
103221 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
103222 +}
103223 +
103224 +static bool no_uses(tree node)
103225 +{
103226 + imm_use_iterator imm_iter;
103227 + use_operand_p use_p;
103228 +
103229 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
103230 + const_gimple use_stmt = USE_STMT(use_p);
103231 + if (use_stmt == NULL)
103232 + return true;
103233 + if (is_gimple_debug(use_stmt))
103234 + continue;
103235 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
103236 + continue;
103237 + return false;
103238 + }
103239 + return true;
103240 +}
103241 +
103242 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
103243 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
103244 +{
103245 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
103246 + gimple def_stmt = get_def_stmt(lhs);
103247 +
103248 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103249 + return false;
103250 +
103251 + rhs1 = gimple_assign_rhs1(def_stmt);
103252 + rhs_type = TREE_TYPE(rhs1);
103253 + lhs_type = TREE_TYPE(lhs);
103254 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
103255 + return false;
103256 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
103257 + return false;
103258 +
103259 + def_stmt = get_def_stmt(rhs1);
103260 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
103261 + return false;
103262 +
103263 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
103264 + return false;
103265 +
103266 + rhs1 = gimple_assign_rhs1(def_stmt);
103267 + rhs2 = gimple_assign_rhs2(def_stmt);
103268 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
103269 + return false;
103270 +
103271 + if (is_gimple_constant(rhs2))
103272 + not_const_rhs = rhs1;
103273 + else
103274 + not_const_rhs = rhs2;
103275 +
103276 + return no_uses(not_const_rhs);
103277 +}
103278 +
103279 +static bool skip_lhs_cast_check(const_gimple stmt)
103280 +{
103281 + const_tree rhs = gimple_assign_rhs1(stmt);
103282 + const_gimple def_stmt = get_def_stmt(rhs);
103283 +
103284 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
103285 + if (gimple_code(def_stmt) == GIMPLE_ASM)
103286 + return true;
103287 +
103288 + if (is_const_plus_unsigned_signed_truncation(rhs))
103289 + return true;
103290 +
103291 + return false;
103292 +}
103293 +
103294 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
103295 +{
103296 + bool cast_lhs, cast_rhs;
103297 + tree lhs = gimple_get_lhs(stmt);
103298 + tree rhs = gimple_assign_rhs1(stmt);
103299 + const_tree lhs_type = TREE_TYPE(lhs);
103300 + const_tree rhs_type = TREE_TYPE(rhs);
103301 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
103302 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
103303 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
103304 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
103305 +
103306 + static bool check_lhs[3][4] = {
103307 + // ss su us uu
103308 + { false, true, true, false }, // lhs > rhs
103309 + { false, false, false, false }, // lhs = rhs
103310 + { true, true, true, true }, // lhs < rhs
103311 + };
103312 +
103313 + static bool check_rhs[3][4] = {
103314 + // ss su us uu
103315 + { true, false, true, true }, // lhs > rhs
103316 + { true, false, true, true }, // lhs = rhs
103317 + { true, false, true, true }, // lhs < rhs
103318 + };
103319 +
103320 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
103321 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
103322 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103323 +
103324 + if (lhs_size > rhs_size) {
103325 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103326 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103327 + } else if (lhs_size == rhs_size) {
103328 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103329 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103330 + } else {
103331 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103332 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103333 + }
103334 +
103335 + if (!cast_lhs && !cast_rhs)
103336 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103337 +
103338 + if (cast_lhs && !skip_lhs_cast_check(stmt))
103339 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
103340 +
103341 + if (cast_rhs)
103342 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
103343 +
103344 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103345 +}
103346 +
103347 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
103348 +{
103349 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
103350 +
103351 + if (gimple_plf(stmt, MY_STMT))
103352 + return lhs;
103353 +
103354 + rhs1 = gimple_assign_rhs1(stmt);
103355 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
103356 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103357 +
103358 + new_rhs1 = expand(visited, rhs1);
103359 +
103360 + if (new_rhs1 == NULL_TREE)
103361 + return create_cast_assign(visited, stmt);
103362 +
103363 + if (gimple_plf(stmt, NO_CAST_CHECK))
103364 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103365 +
103366 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
103367 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
103368 +
103369 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
103370 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
103371 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103372 + }
103373 +
103374 + if (!gimple_assign_cast_p(stmt))
103375 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103376 +
103377 + return create_cast_overflow_check(visited, new_rhs1, stmt);
103378 +}
103379 +
103380 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
103381 +{
103382 + tree rhs1, lhs = gimple_get_lhs(stmt);
103383 + gimple def_stmt = get_def_stmt(lhs);
103384 +
103385 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
103386 + rhs1 = gimple_assign_rhs1(def_stmt);
103387 +
103388 + if (is_gimple_constant(rhs1))
103389 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103390 +
103391 + switch (TREE_CODE(rhs1)) {
103392 + case SSA_NAME:
103393 + return handle_unary_rhs(visited, def_stmt);
103394 + case ARRAY_REF:
103395 + case BIT_FIELD_REF:
103396 + case ADDR_EXPR:
103397 + case COMPONENT_REF:
103398 + case INDIRECT_REF:
103399 +#if BUILDING_GCC_VERSION >= 4006
103400 + case MEM_REF:
103401 +#endif
103402 + case TARGET_MEM_REF:
103403 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103404 + case PARM_DECL:
103405 + case VAR_DECL:
103406 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103407 +
103408 + default:
103409 + debug_gimple_stmt(def_stmt);
103410 + debug_tree(rhs1);
103411 + gcc_unreachable();
103412 + }
103413 +}
103414 +
103415 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
103416 +{
103417 + gimple cond_stmt;
103418 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
103419 +
103420 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
103421 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
103422 + update_stmt(cond_stmt);
103423 +}
103424 +
103425 +static tree create_string_param(tree string)
103426 +{
103427 + tree i_type, a_type;
103428 + const int length = TREE_STRING_LENGTH(string);
103429 +
103430 + gcc_assert(length > 0);
103431 +
103432 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
103433 + a_type = build_array_type(char_type_node, i_type);
103434 +
103435 + TREE_TYPE(string) = a_type;
103436 + TREE_CONSTANT(string) = 1;
103437 + TREE_READONLY(string) = 1;
103438 +
103439 + return build1(ADDR_EXPR, ptr_type_node, string);
103440 +}
103441 +
103442 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
103443 +{
103444 + gimple func_stmt;
103445 + const_gimple def_stmt;
103446 + const_tree loc_line;
103447 + tree loc_file, ssa_name, current_func;
103448 + expanded_location xloc;
103449 + char *ssa_name_buf;
103450 + int len;
103451 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
103452 +
103453 + def_stmt = get_def_stmt(arg);
103454 + xloc = expand_location(gimple_location(def_stmt));
103455 +
103456 + if (!gimple_has_location(def_stmt)) {
103457 + xloc = expand_location(gimple_location(stmt));
103458 + if (!gimple_has_location(stmt))
103459 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103460 + }
103461 +
103462 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103463 +
103464 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103465 + loc_file = create_string_param(loc_file);
103466 +
103467 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103468 + current_func = create_string_param(current_func);
103469 +
103470 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103471 + call_count++;
103472 + 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);
103473 + gcc_assert(len > 0);
103474 + ssa_name = build_string(len + 1, ssa_name_buf);
103475 + free(ssa_name_buf);
103476 + ssa_name = create_string_param(ssa_name);
103477 +
103478 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103479 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103480 +
103481 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103482 +}
103483 +
103484 +static void __unused print_the_code_insertions(const_gimple stmt)
103485 +{
103486 + location_t loc = gimple_location(stmt);
103487 +
103488 + inform(loc, "Integer size_overflow check applied here.");
103489 +}
103490 +
103491 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103492 +{
103493 + basic_block cond_bb, join_bb, bb_true;
103494 + edge e;
103495 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103496 +
103497 + cond_bb = gimple_bb(stmt);
103498 + if (before)
103499 + gsi_prev(&gsi);
103500 + if (gsi_end_p(gsi))
103501 + e = split_block_after_labels(cond_bb);
103502 + else
103503 + e = split_block(cond_bb, gsi_stmt(gsi));
103504 + cond_bb = e->src;
103505 + join_bb = e->dest;
103506 + e->flags = EDGE_FALSE_VALUE;
103507 + e->probability = REG_BR_PROB_BASE;
103508 +
103509 + bb_true = create_empty_bb(cond_bb);
103510 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103511 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103512 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103513 +
103514 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103515 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103516 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103517 +
103518 + if (current_loops != NULL) {
103519 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103520 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103521 + }
103522 +
103523 + insert_cond(cond_bb, arg, cond_code, type_value);
103524 + insert_cond_result(bb_true, stmt, arg, min);
103525 +
103526 +// print_the_code_insertions(stmt);
103527 +}
103528 +
103529 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103530 +{
103531 + const_tree rhs_type = TREE_TYPE(rhs);
103532 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103533 +
103534 + gcc_assert(rhs_type != NULL_TREE);
103535 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103536 + return;
103537 +
103538 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103539 +
103540 + if (is_const_plus_unsigned_signed_truncation(rhs))
103541 + return;
103542 +
103543 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103544 + // typemax (-1) < typemin (0)
103545 + if (TREE_OVERFLOW(type_max))
103546 + return;
103547 +
103548 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103549 +
103550 + cast_rhs_type = TREE_TYPE(cast_rhs);
103551 + type_max_type = TREE_TYPE(type_max);
103552 + type_min_type = TREE_TYPE(type_min);
103553 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103554 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103555 +
103556 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103557 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103558 +}
103559 +
103560 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103561 +{
103562 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103563 + return false;
103564 + if (!is_gimple_constant(rhs))
103565 + return false;
103566 + return true;
103567 +}
103568 +
103569 +static tree get_def_stmt_rhs(const_tree var)
103570 +{
103571 + tree rhs1, def_stmt_rhs1;
103572 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103573 +
103574 + def_stmt = get_def_stmt(var);
103575 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103576 +
103577 + rhs1 = gimple_assign_rhs1(def_stmt);
103578 + rhs1_def_stmt = get_def_stmt(rhs1);
103579 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103580 + return rhs1;
103581 +
103582 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103583 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103584 +
103585 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103586 + case GIMPLE_CALL:
103587 + case GIMPLE_NOP:
103588 + case GIMPLE_ASM:
103589 + case GIMPLE_PHI:
103590 + return def_stmt_rhs1;
103591 + case GIMPLE_ASSIGN:
103592 + return rhs1;
103593 + default:
103594 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103595 + gcc_unreachable();
103596 + }
103597 +}
103598 +
103599 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103600 +{
103601 + tree new_rhs, orig_rhs;
103602 + void (*gimple_assign_set_rhs)(gimple, tree);
103603 + tree rhs1 = gimple_assign_rhs1(stmt);
103604 + tree rhs2 = gimple_assign_rhs2(stmt);
103605 + tree lhs = gimple_get_lhs(stmt);
103606 +
103607 + if (!check_overflow)
103608 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103609 +
103610 + if (change_rhs == NULL_TREE)
103611 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103612 +
103613 + if (new_rhs2 == NULL_TREE) {
103614 + orig_rhs = rhs1;
103615 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103616 + } else {
103617 + orig_rhs = rhs2;
103618 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103619 + }
103620 +
103621 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103622 +
103623 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103624 + gimple_assign_set_rhs(stmt, new_rhs);
103625 + update_stmt(stmt);
103626 +
103627 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103628 +}
103629 +
103630 +static bool is_subtraction_special(const_gimple stmt)
103631 +{
103632 + gimple rhs1_def_stmt, rhs2_def_stmt;
103633 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103634 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103635 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103636 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103637 +
103638 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103639 + return false;
103640 +
103641 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103642 +
103643 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103644 + return false;
103645 +
103646 + rhs1_def_stmt = get_def_stmt(rhs1);
103647 + rhs2_def_stmt = get_def_stmt(rhs2);
103648 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103649 + return false;
103650 +
103651 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103652 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103653 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103654 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103655 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103656 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103657 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103658 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103659 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103660 + return false;
103661 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103662 + return false;
103663 +
103664 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103665 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103666 + return true;
103667 +}
103668 +
103669 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103670 +{
103671 + tree new_rhs1, new_rhs2;
103672 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103673 + gimple assign, stmt = get_def_stmt(lhs);
103674 + tree rhs1 = gimple_assign_rhs1(stmt);
103675 + tree rhs2 = gimple_assign_rhs2(stmt);
103676 +
103677 + if (!is_subtraction_special(stmt))
103678 + return NULL_TREE;
103679 +
103680 + new_rhs1 = expand(visited, rhs1);
103681 + new_rhs2 = expand(visited, rhs2);
103682 +
103683 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103684 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103685 +
103686 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103687 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103688 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103689 + }
103690 +
103691 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103692 + new_lhs = gimple_get_lhs(assign);
103693 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103694 +
103695 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103696 +}
103697 +
103698 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103699 +{
103700 + const_gimple def_stmt;
103701 +
103702 + if (TREE_CODE(rhs) != SSA_NAME)
103703 + return false;
103704 +
103705 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103706 + return false;
103707 +
103708 + def_stmt = get_def_stmt(rhs);
103709 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103710 + return false;
103711 +
103712 + return true;
103713 +}
103714 +
103715 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103716 +{
103717 + tree rhs1, rhs2, new_lhs;
103718 + gimple def_stmt = get_def_stmt(lhs);
103719 + tree new_rhs1 = NULL_TREE;
103720 + tree new_rhs2 = NULL_TREE;
103721 +
103722 + rhs1 = gimple_assign_rhs1(def_stmt);
103723 + rhs2 = gimple_assign_rhs2(def_stmt);
103724 +
103725 + /* no DImode/TImode division in the 32/64 bit kernel */
103726 + switch (gimple_assign_rhs_code(def_stmt)) {
103727 + case RDIV_EXPR:
103728 + case TRUNC_DIV_EXPR:
103729 + case CEIL_DIV_EXPR:
103730 + case FLOOR_DIV_EXPR:
103731 + case ROUND_DIV_EXPR:
103732 + case TRUNC_MOD_EXPR:
103733 + case CEIL_MOD_EXPR:
103734 + case FLOOR_MOD_EXPR:
103735 + case ROUND_MOD_EXPR:
103736 + case EXACT_DIV_EXPR:
103737 + case POINTER_PLUS_EXPR:
103738 + case BIT_AND_EXPR:
103739 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103740 + default:
103741 + break;
103742 + }
103743 +
103744 + new_lhs = handle_integer_truncation(visited, lhs);
103745 + if (new_lhs != NULL_TREE)
103746 + return new_lhs;
103747 +
103748 + if (TREE_CODE(rhs1) == SSA_NAME)
103749 + new_rhs1 = expand(visited, rhs1);
103750 + if (TREE_CODE(rhs2) == SSA_NAME)
103751 + new_rhs2 = expand(visited, rhs2);
103752 +
103753 + if (is_a_neg_overflow(def_stmt, rhs2))
103754 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103755 + if (is_a_neg_overflow(def_stmt, rhs1))
103756 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103757 +
103758 +
103759 + if (is_a_constant_overflow(def_stmt, rhs2))
103760 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103761 + if (is_a_constant_overflow(def_stmt, rhs1))
103762 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103763 +
103764 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103765 +}
103766 +
103767 +#if BUILDING_GCC_VERSION >= 4007
103768 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103769 +{
103770 + if (is_gimple_constant(rhs))
103771 + return cast_a_tree(size_overflow_type, rhs);
103772 + if (TREE_CODE(rhs) != SSA_NAME)
103773 + return NULL_TREE;
103774 + return expand(visited, rhs);
103775 +}
103776 +
103777 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103778 +{
103779 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103780 + gimple def_stmt = get_def_stmt(lhs);
103781 +
103782 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103783 +
103784 + rhs1 = gimple_assign_rhs1(def_stmt);
103785 + rhs2 = gimple_assign_rhs2(def_stmt);
103786 + rhs3 = gimple_assign_rhs3(def_stmt);
103787 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103788 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103789 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103790 +
103791 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103792 +}
103793 +#endif
103794 +
103795 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103796 +{
103797 + const_tree type;
103798 + tree new_type;
103799 +
103800 + gcc_assert(node != NULL_TREE);
103801 +
103802 + type = TREE_TYPE(node);
103803 +
103804 + if (gimple_plf(stmt, MY_STMT))
103805 + return TREE_TYPE(node);
103806 +
103807 + switch (TYPE_MODE(type)) {
103808 + case QImode:
103809 + new_type = intHI_type_node;
103810 + break;
103811 + case HImode:
103812 + new_type = intSI_type_node;
103813 + break;
103814 + case SImode:
103815 + new_type = intDI_type_node;
103816 + break;
103817 + case DImode:
103818 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103819 + new_type = intDI_type_node;
103820 + else
103821 + new_type = intTI_type_node;
103822 + break;
103823 + default:
103824 + debug_tree((tree)node);
103825 + error("%s: unsupported gcc configuration.", __func__);
103826 + gcc_unreachable();
103827 + }
103828 +
103829 + if (TYPE_QUALS(type) != 0)
103830 + return build_qualified_type(new_type, TYPE_QUALS(type));
103831 + return new_type;
103832 +}
103833 +
103834 +static tree expand_visited(gimple def_stmt)
103835 +{
103836 + const_gimple next_stmt;
103837 + gimple_stmt_iterator gsi;
103838 + enum gimple_code code = gimple_code(def_stmt);
103839 +
103840 + if (code == GIMPLE_ASM)
103841 + return NULL_TREE;
103842 +
103843 + gsi = gsi_for_stmt(def_stmt);
103844 + gsi_next(&gsi);
103845 +
103846 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103847 + return NULL_TREE;
103848 + gcc_assert(!gsi_end_p(gsi));
103849 + next_stmt = gsi_stmt(gsi);
103850 +
103851 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103852 + return NULL_TREE;
103853 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103854 +
103855 + return get_lhs(next_stmt);
103856 +}
103857 +
103858 +static tree expand(struct pointer_set_t *visited, tree lhs)
103859 +{
103860 + gimple def_stmt;
103861 +
103862 + if (skip_types(lhs))
103863 + return NULL_TREE;
103864 +
103865 + def_stmt = get_def_stmt(lhs);
103866 +
103867 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103868 + return NULL_TREE;
103869 +
103870 + if (gimple_plf(def_stmt, MY_STMT))
103871 + return lhs;
103872 +
103873 + if (pointer_set_contains(visited, def_stmt))
103874 + return expand_visited(def_stmt);
103875 +
103876 + switch (gimple_code(def_stmt)) {
103877 + case GIMPLE_PHI:
103878 + return handle_phi(visited, lhs);
103879 + case GIMPLE_CALL:
103880 + case GIMPLE_ASM:
103881 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103882 + case GIMPLE_ASSIGN:
103883 + switch (gimple_num_ops(def_stmt)) {
103884 + case 2:
103885 + return handle_unary_ops(visited, def_stmt);
103886 + case 3:
103887 + return handle_binary_ops(visited, lhs);
103888 +#if BUILDING_GCC_VERSION >= 4007
103889 + case 4:
103890 + return handle_ternary_ops(visited, lhs);
103891 +#endif
103892 + }
103893 + default:
103894 + debug_gimple_stmt(def_stmt);
103895 + error("%s: unknown gimple code", __func__);
103896 + gcc_unreachable();
103897 + }
103898 +}
103899 +
103900 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103901 +{
103902 + const_gimple assign;
103903 + tree orig_type = TREE_TYPE(orig_node);
103904 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103905 +
103906 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103907 + return gimple_get_lhs(assign);
103908 +}
103909 +
103910 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103911 +{
103912 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103913 + update_stmt(stmt);
103914 +}
103915 +
103916 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103917 +{
103918 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103919 + update_stmt(stmt);
103920 +}
103921 +
103922 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103923 +{
103924 + tree arg;
103925 + const_tree origarg;
103926 +
103927 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103928 + return true;
103929 +
103930 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103931 + while (origarg && *argnum) {
103932 + (*argnum)--;
103933 + origarg = TREE_CHAIN(origarg);
103934 + }
103935 +
103936 + gcc_assert(*argnum == 0);
103937 +
103938 + gcc_assert(origarg != NULL_TREE);
103939 + *argnum = 0;
103940 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103941 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103942 + return true;
103943 + return false;
103944 +}
103945 +
103946 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103947 +{
103948 + gimple phi = get_def_stmt(result);
103949 + unsigned int i, n = gimple_phi_num_args(phi);
103950 +
103951 + if (!phi)
103952 + return MARK_NO;
103953 +
103954 + pointer_set_insert(visited, phi);
103955 + for (i = 0; i < n; i++) {
103956 + enum mark marked;
103957 + const_tree arg = gimple_phi_arg_def(phi, i);
103958 + marked = pre_expand(visited, search_err_code, arg);
103959 + if (marked != MARK_NO)
103960 + return marked;
103961 + }
103962 + return MARK_NO;
103963 +}
103964 +
103965 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103966 +{
103967 + gimple def_stmt = get_def_stmt(lhs);
103968 + const_tree rhs;
103969 +
103970 + if (!def_stmt)
103971 + return MARK_NO;
103972 +
103973 + rhs = gimple_assign_rhs1(def_stmt);
103974 +
103975 + def_stmt = get_def_stmt(rhs);
103976 + if (is_gimple_constant(rhs))
103977 + search_err_code[FROM_CONST] = true;
103978 +
103979 + return pre_expand(visited, search_err_code, rhs);
103980 +}
103981 +
103982 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103983 +{
103984 + gimple def_stmt = get_def_stmt(lhs);
103985 + const_tree rhs1, rhs2;
103986 + enum mark marked;
103987 +
103988 + if (!def_stmt)
103989 + return MARK_NO;
103990 +
103991 + search_err_code[CAST_ONLY] = false;
103992 +
103993 + rhs1 = gimple_assign_rhs1(def_stmt);
103994 + rhs2 = gimple_assign_rhs2(def_stmt);
103995 + marked = pre_expand(visited, search_err_code, rhs1);
103996 + if (marked != MARK_NO)
103997 + return marked;
103998 + return pre_expand(visited, search_err_code, rhs2);
103999 +}
104000 +
104001 +static const_tree search_field_decl(const_tree comp_ref)
104002 +{
104003 + const_tree field = NULL_TREE;
104004 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
104005 +
104006 + for (i = 0; i < len; i++) {
104007 + field = TREE_OPERAND(comp_ref, i);
104008 + if (TREE_CODE(field) == FIELD_DECL)
104009 + break;
104010 + }
104011 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
104012 + return field;
104013 +}
104014 +
104015 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
104016 +{
104017 + const_tree attr, p;
104018 +
104019 + // 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);
104020 + if (fndecl == NULL_TREE)
104021 + return MARK_NO;
104022 +
104023 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
104024 + if (!attr || !TREE_VALUE(attr))
104025 + return MARK_NO;
104026 +
104027 + p = TREE_VALUE(attr);
104028 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
104029 + return MARK_TURN_OFF;
104030 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
104031 + return MARK_NOT_INTENTIONAL;
104032 + if (argnum == 0) {
104033 + gcc_assert(current_function_decl == fndecl);
104034 + return MARK_NO;
104035 + }
104036 +
104037 + do {
104038 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
104039 + return MARK_YES;
104040 + p = TREE_CHAIN(p);
104041 + } while (p);
104042 +
104043 + return MARK_NO;
104044 +}
104045 +
104046 +static void print_missing_msg(tree func, unsigned int argnum)
104047 +{
104048 + unsigned int new_hash;
104049 + size_t len;
104050 + unsigned char tree_codes[CODES_LIMIT];
104051 + location_t loc;
104052 + const char *curfunc;
104053 +
104054 + func = get_original_function_decl(func);
104055 + loc = DECL_SOURCE_LOCATION(func);
104056 + curfunc = get_asm_name(func);
104057 +
104058 + len = get_function_decl(func, tree_codes);
104059 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
104060 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
104061 +}
104062 +
104063 +static unsigned int search_missing_attribute(const_tree arg)
104064 +{
104065 + unsigned int argnum;
104066 + const struct size_overflow_hash *hash;
104067 + const_tree type = TREE_TYPE(arg);
104068 + tree func = get_original_function_decl(current_function_decl);
104069 +
104070 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
104071 +
104072 + if (TREE_CODE(type) == POINTER_TYPE)
104073 + return 0;
104074 +
104075 + argnum = find_arg_number(arg, func);
104076 + if (argnum == 0)
104077 + return 0;
104078 +
104079 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
104080 + return argnum;
104081 +
104082 + hash = get_function_hash(func);
104083 + if (!hash || !(hash->param & (1U << argnum))) {
104084 + print_missing_msg(func, argnum);
104085 + return 0;
104086 + }
104087 + return argnum;
104088 +}
104089 +
104090 +static enum mark is_already_marked(const_tree lhs)
104091 +{
104092 + unsigned int argnum;
104093 + const_tree fndecl;
104094 +
104095 + argnum = search_missing_attribute(lhs);
104096 + fndecl = get_original_function_decl(current_function_decl);
104097 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
104098 + return MARK_YES;
104099 + return MARK_NO;
104100 +}
104101 +
104102 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
104103 +{
104104 + const_gimple def_stmt;
104105 +
104106 + if (skip_types(lhs))
104107 + return MARK_NO;
104108 +
104109 + if (TREE_CODE(lhs) == PARM_DECL)
104110 + return is_already_marked(lhs);
104111 +
104112 + if (TREE_CODE(lhs) == COMPONENT_REF) {
104113 + const_tree field, attr;
104114 +
104115 + field = search_field_decl(lhs);
104116 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
104117 + if (!attr || !TREE_VALUE(attr))
104118 + return MARK_NO;
104119 + return MARK_YES;
104120 + }
104121 +
104122 + def_stmt = get_def_stmt(lhs);
104123 +
104124 + if (!def_stmt)
104125 + return MARK_NO;
104126 +
104127 + if (pointer_set_contains(visited, def_stmt))
104128 + return MARK_NO;
104129 +
104130 + switch (gimple_code(def_stmt)) {
104131 + case GIMPLE_NOP:
104132 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
104133 + return is_already_marked(lhs);
104134 + return MARK_NO;
104135 + case GIMPLE_PHI:
104136 + return walk_phi(visited, search_err_code, lhs);
104137 + case GIMPLE_CALL:
104138 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
104139 + return MARK_TURN_OFF;
104140 + check_function_hash(def_stmt);
104141 + return MARK_NO;
104142 + case GIMPLE_ASM:
104143 + search_err_code[CAST_ONLY] = false;
104144 + return MARK_NO;
104145 + case GIMPLE_ASSIGN:
104146 + switch (gimple_num_ops(def_stmt)) {
104147 + case 2:
104148 + return walk_unary_ops(visited, search_err_code, lhs);
104149 + case 3:
104150 + return walk_binary_ops(visited, search_err_code, lhs);
104151 + }
104152 + default:
104153 + debug_gimple_stmt((gimple)def_stmt);
104154 + error("%s: unknown gimple code", __func__);
104155 + gcc_unreachable();
104156 + }
104157 +}
104158 +
104159 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
104160 +static bool skip_asm(const_tree arg)
104161 +{
104162 + gimple def_stmt = get_def_stmt(arg);
104163 +
104164 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
104165 + return false;
104166 +
104167 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
104168 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
104169 +}
104170 +
104171 +/*
104172 +0</MARK_YES: no dup, search attributes (so, int)
104173 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
104174 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
104175 +*/
104176 +
104177 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
104178 +{
104179 + struct pointer_set_t *visited;
104180 + enum mark is_marked, is_found;
104181 + location_t loc;
104182 + bool search_err_code[2] = {true, false};
104183 +
104184 + is_marked = mark_status(current_function_decl, 0);
104185 + if (is_marked == MARK_TURN_OFF)
104186 + return true;
104187 +
104188 + is_marked = mark_status(fndecl, argnum + 1);
104189 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
104190 + return true;
104191 +
104192 + visited = pointer_set_create();
104193 + is_found = pre_expand(visited, search_err_code, arg);
104194 + pointer_set_destroy(visited);
104195 +
104196 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
104197 + return true;
104198 +
104199 + if (where == FROM_ARG && skip_asm(arg))
104200 + return true;
104201 +
104202 + if (is_found == MARK_TURN_OFF)
104203 + return true;
104204 +
104205 + if ((is_found == MARK_YES && is_marked == MARK_YES))
104206 + return true;
104207 +
104208 + if (is_found == MARK_YES) {
104209 + loc = DECL_SOURCE_LOCATION(fndecl);
104210 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
104211 + return true;
104212 + }
104213 + return false;
104214 +}
104215 +
104216 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
104217 +{
104218 + struct pointer_set_t *visited;
104219 + tree arg, new_arg;
104220 + bool match;
104221 +
104222 + if (argnum == 0)
104223 + return;
104224 +
104225 + argnum--;
104226 +
104227 + match = get_function_arg(&argnum, fndecl);
104228 + if (!match)
104229 + return;
104230 + gcc_assert(gimple_call_num_args(stmt) > argnum);
104231 + arg = gimple_call_arg(stmt, argnum);
104232 + if (arg == NULL_TREE)
104233 + return;
104234 +
104235 + if (skip_types(arg))
104236 + return;
104237 +
104238 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
104239 + return;
104240 +
104241 + visited = pointer_set_create();
104242 + new_arg = expand(visited, arg);
104243 + pointer_set_destroy(visited);
104244 +
104245 + if (new_arg == NULL_TREE)
104246 + return;
104247 +
104248 + change_function_arg(stmt, arg, argnum, new_arg);
104249 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
104250 +}
104251 +
104252 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
104253 +{
104254 + tree p = TREE_VALUE(attr);
104255 + do {
104256 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
104257 + p = TREE_CHAIN(p);
104258 + } while (p);
104259 +}
104260 +
104261 +static void handle_function_by_hash(gimple stmt, tree fndecl)
104262 +{
104263 + unsigned int num;
104264 + const struct size_overflow_hash *hash;
104265 +
104266 + hash = get_function_hash(fndecl);
104267 + if (!hash)
104268 + return;
104269 +
104270 + for (num = 0; num <= MAX_PARAM; num++)
104271 + if (hash->param & (1U << num))
104272 + handle_function_arg(stmt, fndecl, num);
104273 +}
104274 +
104275 +static bool check_return_value(void)
104276 +{
104277 + const struct size_overflow_hash *hash;
104278 +
104279 + hash = get_function_hash(current_function_decl);
104280 + if (!hash || !(hash->param & 1U << 0))
104281 + return false;
104282 +
104283 + return true;
104284 +}
104285 +
104286 +static void handle_return_value(gimple ret_stmt)
104287 +{
104288 + struct pointer_set_t *visited;
104289 + tree ret, new_ret;
104290 +
104291 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
104292 + return;
104293 +
104294 + ret = gimple_return_retval(ret_stmt);
104295 +
104296 + if (skip_types(ret))
104297 + return;
104298 +
104299 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
104300 + return;
104301 +
104302 + visited = pointer_set_create();
104303 + new_ret = expand(visited, ret);
104304 + pointer_set_destroy(visited);
104305 +
104306 + change_function_return(ret_stmt, ret, new_ret);
104307 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
104308 +}
104309 +
104310 +static void set_plf_false(void)
104311 +{
104312 + basic_block bb;
104313 +
104314 + FOR_ALL_BB(bb) {
104315 + gimple_stmt_iterator si;
104316 +
104317 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
104318 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104319 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
104320 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104321 + }
104322 +}
104323 +
104324 +static unsigned int handle_function(void)
104325 +{
104326 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
104327 + bool check_ret;
104328 +
104329 + set_plf_false();
104330 +
104331 + check_ret = check_return_value();
104332 +
104333 + do {
104334 + gimple_stmt_iterator gsi;
104335 + next = bb->next_bb;
104336 +
104337 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104338 + tree fndecl, attr;
104339 + gimple stmt = gsi_stmt(gsi);
104340 +
104341 + if (check_ret)
104342 + handle_return_value(stmt);
104343 +
104344 + if (!(is_gimple_call(stmt)))
104345 + continue;
104346 + fndecl = gimple_call_fndecl(stmt);
104347 + if (fndecl == NULL_TREE)
104348 + continue;
104349 + if (gimple_call_num_args(stmt) == 0)
104350 + continue;
104351 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
104352 + if (!attr || !TREE_VALUE(attr))
104353 + handle_function_by_hash(stmt, fndecl);
104354 + else
104355 + handle_function_by_attribute(stmt, attr, fndecl);
104356 + gsi = gsi_for_stmt(stmt);
104357 + next = gimple_bb(stmt)->next_bb;
104358 + }
104359 + bb = next;
104360 + } while (bb);
104361 + return 0;
104362 +}
104363 +
104364 +static struct gimple_opt_pass size_overflow_pass = {
104365 + .pass = {
104366 + .type = GIMPLE_PASS,
104367 + .name = "size_overflow",
104368 +#if BUILDING_GCC_VERSION >= 4008
104369 + .optinfo_flags = OPTGROUP_NONE,
104370 +#endif
104371 + .gate = NULL,
104372 + .execute = handle_function,
104373 + .sub = NULL,
104374 + .next = NULL,
104375 + .static_pass_number = 0,
104376 + .tv_id = TV_NONE,
104377 + .properties_required = PROP_cfg,
104378 + .properties_provided = 0,
104379 + .properties_destroyed = 0,
104380 + .todo_flags_start = 0,
104381 + .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
104382 + }
104383 +};
104384 +
104385 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
104386 +{
104387 + tree fntype;
104388 +
104389 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
104390 +
104391 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
104392 + fntype = build_function_type_list(void_type_node,
104393 + const_char_ptr_type_node,
104394 + unsigned_type_node,
104395 + const_char_ptr_type_node,
104396 + const_char_ptr_type_node,
104397 + NULL_TREE);
104398 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
104399 +
104400 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
104401 + TREE_PUBLIC(report_size_overflow_decl) = 1;
104402 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
104403 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
104404 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
104405 +}
104406 +
104407 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104408 +{
104409 + int i;
104410 + const char * const plugin_name = plugin_info->base_name;
104411 + const int argc = plugin_info->argc;
104412 + const struct plugin_argument * const argv = plugin_info->argv;
104413 + bool enable = true;
104414 +
104415 + struct register_pass_info size_overflow_pass_info = {
104416 + .pass = &size_overflow_pass.pass,
104417 + .reference_pass_name = "ssa",
104418 + .ref_pass_instance_number = 1,
104419 + .pos_op = PASS_POS_INSERT_AFTER
104420 + };
104421 +
104422 + if (!plugin_default_version_check(version, &gcc_version)) {
104423 + error(G_("incompatible gcc/plugin versions"));
104424 + return 1;
104425 + }
104426 +
104427 + for (i = 0; i < argc; ++i) {
104428 + if (!strcmp(argv[i].key, "no-size-overflow")) {
104429 + enable = false;
104430 + continue;
104431 + }
104432 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104433 + }
104434 +
104435 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
104436 + if (enable) {
104437 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
104438 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
104439 + }
104440 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104441 +
104442 + return 0;
104443 +}
104444 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
104445 new file mode 100644
104446 index 0000000..ac2901e
104447 --- /dev/null
104448 +++ b/tools/gcc/stackleak_plugin.c
104449 @@ -0,0 +1,327 @@
104450 +/*
104451 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
104452 + * Licensed under the GPL v2
104453 + *
104454 + * Note: the choice of the license means that the compilation process is
104455 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104456 + * but for the kernel it doesn't matter since it doesn't link against
104457 + * any of the gcc libraries
104458 + *
104459 + * gcc plugin to help implement various PaX features
104460 + *
104461 + * - track lowest stack pointer
104462 + *
104463 + * TODO:
104464 + * - initialize all local variables
104465 + *
104466 + * BUGS:
104467 + * - none known
104468 + */
104469 +#include "gcc-plugin.h"
104470 +#include "config.h"
104471 +#include "system.h"
104472 +#include "coretypes.h"
104473 +#include "tree.h"
104474 +#include "tree-pass.h"
104475 +#include "flags.h"
104476 +#include "intl.h"
104477 +#include "toplev.h"
104478 +#include "plugin.h"
104479 +//#include "expr.h" where are you...
104480 +#include "diagnostic.h"
104481 +#include "plugin-version.h"
104482 +#include "tm.h"
104483 +#include "function.h"
104484 +#include "basic-block.h"
104485 +#include "gimple.h"
104486 +#include "rtl.h"
104487 +#include "emit-rtl.h"
104488 +
104489 +#if BUILDING_GCC_VERSION >= 4008
104490 +#define TODO_dump_func 0
104491 +#endif
104492 +
104493 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104494 +
104495 +int plugin_is_GPL_compatible;
104496 +
104497 +static int track_frame_size = -1;
104498 +static const char track_function[] = "pax_track_stack";
104499 +static const char check_function[] = "pax_check_alloca";
104500 +static bool init_locals;
104501 +
104502 +static struct plugin_info stackleak_plugin_info = {
104503 + .version = "201302112000",
104504 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104505 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104506 +};
104507 +
104508 +static bool gate_stackleak_track_stack(void);
104509 +static unsigned int execute_stackleak_tree_instrument(void);
104510 +static unsigned int execute_stackleak_final(void);
104511 +
104512 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104513 + .pass = {
104514 + .type = GIMPLE_PASS,
104515 + .name = "stackleak_tree_instrument",
104516 +#if BUILDING_GCC_VERSION >= 4008
104517 + .optinfo_flags = OPTGROUP_NONE,
104518 +#endif
104519 + .gate = gate_stackleak_track_stack,
104520 + .execute = execute_stackleak_tree_instrument,
104521 + .sub = NULL,
104522 + .next = NULL,
104523 + .static_pass_number = 0,
104524 + .tv_id = TV_NONE,
104525 + .properties_required = PROP_gimple_leh | PROP_cfg,
104526 + .properties_provided = 0,
104527 + .properties_destroyed = 0,
104528 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104529 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104530 + }
104531 +};
104532 +
104533 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104534 + .pass = {
104535 + .type = RTL_PASS,
104536 + .name = "stackleak_final",
104537 +#if BUILDING_GCC_VERSION >= 4008
104538 + .optinfo_flags = OPTGROUP_NONE,
104539 +#endif
104540 + .gate = gate_stackleak_track_stack,
104541 + .execute = execute_stackleak_final,
104542 + .sub = NULL,
104543 + .next = NULL,
104544 + .static_pass_number = 0,
104545 + .tv_id = TV_NONE,
104546 + .properties_required = 0,
104547 + .properties_provided = 0,
104548 + .properties_destroyed = 0,
104549 + .todo_flags_start = 0,
104550 + .todo_flags_finish = TODO_dump_func
104551 + }
104552 +};
104553 +
104554 +static bool gate_stackleak_track_stack(void)
104555 +{
104556 + return track_frame_size >= 0;
104557 +}
104558 +
104559 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104560 +{
104561 + gimple check_alloca;
104562 + tree fntype, fndecl, alloca_size;
104563 +
104564 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104565 + fndecl = build_fn_decl(check_function, fntype);
104566 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104567 +
104568 + // insert call to void pax_check_alloca(unsigned long size)
104569 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104570 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104571 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104572 +}
104573 +
104574 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104575 +{
104576 + gimple track_stack;
104577 + tree fntype, fndecl;
104578 +
104579 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104580 + fndecl = build_fn_decl(track_function, fntype);
104581 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104582 +
104583 + // insert call to void pax_track_stack(void)
104584 + track_stack = gimple_build_call(fndecl, 0);
104585 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104586 +}
104587 +
104588 +#if BUILDING_GCC_VERSION == 4005
104589 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104590 +{
104591 + tree fndecl;
104592 +
104593 + if (!is_gimple_call(stmt))
104594 + return false;
104595 + fndecl = gimple_call_fndecl(stmt);
104596 + if (!fndecl)
104597 + return false;
104598 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104599 + return false;
104600 +// print_node(stderr, "pax", fndecl, 4);
104601 + return DECL_FUNCTION_CODE(fndecl) == code;
104602 +}
104603 +#endif
104604 +
104605 +static bool is_alloca(gimple stmt)
104606 +{
104607 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104608 + return true;
104609 +
104610 +#if BUILDING_GCC_VERSION >= 4007
104611 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104612 + return true;
104613 +#endif
104614 +
104615 + return false;
104616 +}
104617 +
104618 +static unsigned int execute_stackleak_tree_instrument(void)
104619 +{
104620 + basic_block bb, entry_bb;
104621 + bool prologue_instrumented = false, is_leaf = true;
104622 +
104623 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104624 +
104625 + // 1. loop through BBs and GIMPLE statements
104626 + FOR_EACH_BB(bb) {
104627 + gimple_stmt_iterator gsi;
104628 +
104629 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104630 + gimple stmt;
104631 +
104632 + stmt = gsi_stmt(gsi);
104633 +
104634 + if (is_gimple_call(stmt))
104635 + is_leaf = false;
104636 +
104637 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104638 + if (!is_alloca(stmt))
104639 + continue;
104640 +
104641 + // 2. insert stack overflow check before each __builtin_alloca call
104642 + stackleak_check_alloca(&gsi);
104643 +
104644 + // 3. insert track call after each __builtin_alloca call
104645 + stackleak_add_instrumentation(&gsi);
104646 + if (bb == entry_bb)
104647 + prologue_instrumented = true;
104648 + }
104649 + }
104650 +
104651 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104652 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104653 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104654 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104655 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104656 + return 0;
104657 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104658 + return 0;
104659 +
104660 + // 4. insert track call at the beginning
104661 + if (!prologue_instrumented) {
104662 + gimple_stmt_iterator gsi;
104663 +
104664 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104665 + if (dom_info_available_p(CDI_DOMINATORS))
104666 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104667 + gsi = gsi_start_bb(bb);
104668 + stackleak_add_instrumentation(&gsi);
104669 + }
104670 +
104671 + return 0;
104672 +}
104673 +
104674 +static unsigned int execute_stackleak_final(void)
104675 +{
104676 + rtx insn, next;
104677 +
104678 + if (cfun->calls_alloca)
104679 + return 0;
104680 +
104681 + // keep calls only if function frame is big enough
104682 + if (get_frame_size() >= track_frame_size)
104683 + return 0;
104684 +
104685 + // 1. find pax_track_stack calls
104686 + for (insn = get_insns(); insn; insn = next) {
104687 + // 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))
104688 + rtx body;
104689 +
104690 + next = NEXT_INSN(insn);
104691 + if (!CALL_P(insn))
104692 + continue;
104693 + body = PATTERN(insn);
104694 + if (GET_CODE(body) != CALL)
104695 + continue;
104696 + body = XEXP(body, 0);
104697 + if (GET_CODE(body) != MEM)
104698 + continue;
104699 + body = XEXP(body, 0);
104700 + if (GET_CODE(body) != SYMBOL_REF)
104701 + continue;
104702 + if (strcmp(XSTR(body, 0), track_function))
104703 + continue;
104704 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104705 + // 2. delete call
104706 + delete_insn_and_edges(insn);
104707 +#if BUILDING_GCC_VERSION >= 4007
104708 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104709 + insn = next;
104710 + next = NEXT_INSN(insn);
104711 + delete_insn_and_edges(insn);
104712 + }
104713 +#endif
104714 + }
104715 +
104716 +// print_simple_rtl(stderr, get_insns());
104717 +// print_rtl(stderr, get_insns());
104718 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104719 +
104720 + return 0;
104721 +}
104722 +
104723 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104724 +{
104725 + const char * const plugin_name = plugin_info->base_name;
104726 + const int argc = plugin_info->argc;
104727 + const struct plugin_argument * const argv = plugin_info->argv;
104728 + int i;
104729 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104730 + .pass = &stackleak_tree_instrument_pass.pass,
104731 +// .reference_pass_name = "tree_profile",
104732 + .reference_pass_name = "optimized",
104733 + .ref_pass_instance_number = 1,
104734 + .pos_op = PASS_POS_INSERT_BEFORE
104735 + };
104736 + struct register_pass_info stackleak_final_pass_info = {
104737 + .pass = &stackleak_final_rtl_opt_pass.pass,
104738 + .reference_pass_name = "final",
104739 + .ref_pass_instance_number = 1,
104740 + .pos_op = PASS_POS_INSERT_BEFORE
104741 + };
104742 +
104743 + if (!plugin_default_version_check(version, &gcc_version)) {
104744 + error(G_("incompatible gcc/plugin versions"));
104745 + return 1;
104746 + }
104747 +
104748 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104749 +
104750 + for (i = 0; i < argc; ++i) {
104751 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104752 + if (!argv[i].value) {
104753 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104754 + continue;
104755 + }
104756 + track_frame_size = atoi(argv[i].value);
104757 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104758 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104759 + continue;
104760 + }
104761 + if (!strcmp(argv[i].key, "initialize-locals")) {
104762 + if (argv[i].value) {
104763 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104764 + continue;
104765 + }
104766 + init_locals = true;
104767 + continue;
104768 + }
104769 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104770 + }
104771 +
104772 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104773 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104774 +
104775 + return 0;
104776 +}
104777 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104778 new file mode 100644
104779 index 0000000..4fae911
104780 --- /dev/null
104781 +++ b/tools/gcc/structleak_plugin.c
104782 @@ -0,0 +1,277 @@
104783 +/*
104784 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104785 + * Licensed under the GPL v2
104786 + *
104787 + * Note: the choice of the license means that the compilation process is
104788 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104789 + * but for the kernel it doesn't matter since it doesn't link against
104790 + * any of the gcc libraries
104791 + *
104792 + * gcc plugin to forcibly initialize certain local variables that could
104793 + * otherwise leak kernel stack to userland if they aren't properly initialized
104794 + * by later code
104795 + *
104796 + * Homepage: http://pax.grsecurity.net/
104797 + *
104798 + * Usage:
104799 + * $ # for 4.5/4.6/C based 4.7
104800 + * $ 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
104801 + * $ # for C++ based 4.7/4.8+
104802 + * $ 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
104803 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104804 + *
104805 + * TODO: eliminate redundant initializers
104806 + * increase type coverage
104807 + */
104808 +
104809 +#include "gcc-plugin.h"
104810 +#include "config.h"
104811 +#include "system.h"
104812 +#include "coretypes.h"
104813 +#include "tree.h"
104814 +#include "tree-pass.h"
104815 +#include "intl.h"
104816 +#include "plugin-version.h"
104817 +#include "tm.h"
104818 +#include "toplev.h"
104819 +#include "function.h"
104820 +#include "tree-flow.h"
104821 +#include "plugin.h"
104822 +#include "gimple.h"
104823 +#include "diagnostic.h"
104824 +#include "cfgloop.h"
104825 +#include "langhooks.h"
104826 +
104827 +#if BUILDING_GCC_VERSION >= 4008
104828 +#define TODO_dump_func 0
104829 +#endif
104830 +
104831 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104832 +
104833 +// unused type flag in all versions 4.5-4.8
104834 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104835 +
104836 +int plugin_is_GPL_compatible;
104837 +void debug_gimple_stmt(gimple gs);
104838 +
104839 +static struct plugin_info structleak_plugin_info = {
104840 + .version = "201304082245",
104841 + .help = "disable\tdo not activate plugin\n",
104842 +};
104843 +
104844 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104845 +{
104846 + *no_add_attrs = true;
104847 +
104848 + // check for types? for now accept everything linux has to offer
104849 + if (TREE_CODE(*node) != FIELD_DECL)
104850 + return NULL_TREE;
104851 +
104852 + *no_add_attrs = false;
104853 + return NULL_TREE;
104854 +}
104855 +
104856 +static struct attribute_spec user_attr = {
104857 + .name = "user",
104858 + .min_length = 0,
104859 + .max_length = 0,
104860 + .decl_required = false,
104861 + .type_required = false,
104862 + .function_type_required = false,
104863 + .handler = handle_user_attribute,
104864 +#if BUILDING_GCC_VERSION >= 4007
104865 + .affects_type_identity = true
104866 +#endif
104867 +};
104868 +
104869 +static void register_attributes(void *event_data, void *data)
104870 +{
104871 + register_attribute(&user_attr);
104872 +// register_attribute(&force_attr);
104873 +}
104874 +
104875 +static tree get_field_type(tree field)
104876 +{
104877 + return strip_array_types(TREE_TYPE(field));
104878 +}
104879 +
104880 +static bool is_userspace_type(tree type)
104881 +{
104882 + tree field;
104883 +
104884 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104885 + tree fieldtype = get_field_type(field);
104886 + enum tree_code code = TREE_CODE(fieldtype);
104887 +
104888 + if (code == RECORD_TYPE || code == UNION_TYPE)
104889 + if (is_userspace_type(fieldtype))
104890 + return true;
104891 +
104892 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104893 + return true;
104894 + }
104895 + return false;
104896 +}
104897 +
104898 +static void finish_type(void *event_data, void *data)
104899 +{
104900 + tree type = (tree)event_data;
104901 +
104902 + if (TYPE_USERSPACE(type))
104903 + return;
104904 +
104905 + if (is_userspace_type(type))
104906 + TYPE_USERSPACE(type) = 1;
104907 +}
104908 +
104909 +static void initialize(tree var)
104910 +{
104911 + basic_block bb;
104912 + gimple_stmt_iterator gsi;
104913 + tree initializer;
104914 + gimple init_stmt;
104915 +
104916 + // this is the original entry bb before the forced split
104917 + // TODO: check further BBs in case more splits occured before us
104918 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104919 +
104920 + // first check if the variable is already initialized, warn otherwise
104921 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104922 + gimple stmt = gsi_stmt(gsi);
104923 + tree rhs1;
104924 +
104925 + // we're looking for an assignment of a single rhs...
104926 + if (!gimple_assign_single_p(stmt))
104927 + continue;
104928 + rhs1 = gimple_assign_rhs1(stmt);
104929 +#if BUILDING_GCC_VERSION >= 4007
104930 + // ... of a non-clobbering expression...
104931 + if (TREE_CLOBBER_P(rhs1))
104932 + continue;
104933 +#endif
104934 + // ... to our variable...
104935 + if (gimple_get_lhs(stmt) != var)
104936 + continue;
104937 + // if it's an initializer then we're good
104938 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104939 + return;
104940 + }
104941 +
104942 + // these aren't the 0days you're looking for
104943 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
104944 +
104945 + // build the initializer expression
104946 + initializer = build_constructor(TREE_TYPE(var), NULL);
104947 +
104948 + // build the initializer stmt
104949 + init_stmt = gimple_build_assign(var, initializer);
104950 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104951 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104952 + update_stmt(init_stmt);
104953 +}
104954 +
104955 +static unsigned int handle_function(void)
104956 +{
104957 + basic_block bb;
104958 + unsigned int ret = 0;
104959 + tree var;
104960 +
104961 +#if BUILDING_GCC_VERSION == 4005
104962 + tree vars;
104963 +#else
104964 + unsigned int i;
104965 +#endif
104966 +
104967 + // split the first bb where we can put the forced initializers
104968 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104969 + if (dom_info_available_p(CDI_DOMINATORS))
104970 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104971 +
104972 + // enumarate all local variables and forcibly initialize our targets
104973 +#if BUILDING_GCC_VERSION == 4005
104974 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104975 + var = TREE_VALUE(vars);
104976 +#else
104977 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104978 +#endif
104979 + tree type = TREE_TYPE(var);
104980 +
104981 + gcc_assert(DECL_P(var));
104982 + if (!auto_var_in_fn_p(var, current_function_decl))
104983 + continue;
104984 +
104985 + // only care about structure types
104986 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104987 + continue;
104988 +
104989 + // if the type is of interest, examine the variable
104990 + if (TYPE_USERSPACE(type))
104991 + initialize(var);
104992 + }
104993 +
104994 + return ret;
104995 +}
104996 +
104997 +static struct gimple_opt_pass structleak_pass = {
104998 + .pass = {
104999 + .type = GIMPLE_PASS,
105000 + .name = "structleak",
105001 +#if BUILDING_GCC_VERSION >= 4008
105002 + .optinfo_flags = OPTGROUP_NONE,
105003 +#endif
105004 + .gate = NULL,
105005 + .execute = handle_function,
105006 + .sub = NULL,
105007 + .next = NULL,
105008 + .static_pass_number = 0,
105009 + .tv_id = TV_NONE,
105010 + .properties_required = PROP_cfg,
105011 + .properties_provided = 0,
105012 + .properties_destroyed = 0,
105013 + .todo_flags_start = 0,
105014 + .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
105015 + }
105016 +};
105017 +
105018 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
105019 +{
105020 + int i;
105021 + const char * const plugin_name = plugin_info->base_name;
105022 + const int argc = plugin_info->argc;
105023 + const struct plugin_argument * const argv = plugin_info->argv;
105024 + bool enable = true;
105025 +
105026 + struct register_pass_info structleak_pass_info = {
105027 + .pass = &structleak_pass.pass,
105028 + .reference_pass_name = "ssa",
105029 + .ref_pass_instance_number = 1,
105030 + .pos_op = PASS_POS_INSERT_AFTER
105031 + };
105032 +
105033 + if (!plugin_default_version_check(version, &gcc_version)) {
105034 + error(G_("incompatible gcc/plugin versions"));
105035 + return 1;
105036 + }
105037 +
105038 + if (strcmp(lang_hooks.name, "GNU C")) {
105039 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
105040 + enable = false;
105041 + }
105042 +
105043 + for (i = 0; i < argc; ++i) {
105044 + if (!strcmp(argv[i].key, "disable")) {
105045 + enable = false;
105046 + continue;
105047 + }
105048 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105049 + }
105050 +
105051 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
105052 + if (enable) {
105053 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
105054 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
105055 + }
105056 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
105057 +
105058 + return 0;
105059 +}
105060 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
105061 index 6789d78..4afd019e 100644
105062 --- a/tools/perf/util/include/asm/alternative-asm.h
105063 +++ b/tools/perf/util/include/asm/alternative-asm.h
105064 @@ -5,4 +5,7 @@
105065
105066 #define altinstruction_entry #
105067
105068 + .macro pax_force_retaddr rip=0, reload=0
105069 + .endm
105070 +
105071 #endif
105072 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
105073 index 96b919d..c49bb74 100644
105074 --- a/tools/perf/util/include/linux/compiler.h
105075 +++ b/tools/perf/util/include/linux/compiler.h
105076 @@ -18,4 +18,12 @@
105077 #define __force
105078 #endif
105079
105080 +#ifndef __size_overflow
105081 +# define __size_overflow(...)
105082 +#endif
105083 +
105084 +#ifndef __intentional_overflow
105085 +# define __intentional_overflow(...)
105086 +#endif
105087 +
105088 #endif
105089 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
105090 index 302681c..3bde377 100644
105091 --- a/virt/kvm/kvm_main.c
105092 +++ b/virt/kvm/kvm_main.c
105093 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
105094
105095 static cpumask_var_t cpus_hardware_enabled;
105096 static int kvm_usage_count = 0;
105097 -static atomic_t hardware_enable_failed;
105098 +static atomic_unchecked_t hardware_enable_failed;
105099
105100 struct kmem_cache *kvm_vcpu_cache;
105101 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
105102
105103 -static __read_mostly struct preempt_ops kvm_preempt_ops;
105104 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
105105 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
105106 +static struct preempt_ops kvm_preempt_ops = {
105107 + .sched_in = kvm_sched_in,
105108 + .sched_out = kvm_sched_out,
105109 +};
105110
105111 struct dentry *kvm_debugfs_dir;
105112
105113 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
105114 /* We can read the guest memory with __xxx_user() later on. */
105115 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
105116 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
105117 - !access_ok(VERIFY_WRITE,
105118 + !__access_ok(VERIFY_WRITE,
105119 (void __user *)(unsigned long)mem->userspace_addr,
105120 mem->memory_size)))
105121 goto out;
105122 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
105123 return 0;
105124 }
105125
105126 -static struct file_operations kvm_vcpu_fops = {
105127 +static file_operations_no_const kvm_vcpu_fops __read_only = {
105128 .release = kvm_vcpu_release,
105129 .unlocked_ioctl = kvm_vcpu_ioctl,
105130 #ifdef CONFIG_COMPAT
105131 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
105132 return 0;
105133 }
105134
105135 -static struct file_operations kvm_vm_fops = {
105136 +static file_operations_no_const kvm_vm_fops __read_only = {
105137 .release = kvm_vm_release,
105138 .unlocked_ioctl = kvm_vm_ioctl,
105139 #ifdef CONFIG_COMPAT
105140 @@ -2662,7 +2667,7 @@ out:
105141 return r;
105142 }
105143
105144 -static struct file_operations kvm_chardev_ops = {
105145 +static file_operations_no_const kvm_chardev_ops __read_only = {
105146 .unlocked_ioctl = kvm_dev_ioctl,
105147 .compat_ioctl = kvm_dev_ioctl,
105148 .llseek = noop_llseek,
105149 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
105150
105151 if (r) {
105152 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
105153 - atomic_inc(&hardware_enable_failed);
105154 + atomic_inc_unchecked(&hardware_enable_failed);
105155 printk(KERN_INFO "kvm: enabling virtualization on "
105156 "CPU%d failed\n", cpu);
105157 }
105158 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
105159
105160 kvm_usage_count++;
105161 if (kvm_usage_count == 1) {
105162 - atomic_set(&hardware_enable_failed, 0);
105163 + atomic_set_unchecked(&hardware_enable_failed, 0);
105164 on_each_cpu(hardware_enable_nolock, NULL, 1);
105165
105166 - if (atomic_read(&hardware_enable_failed)) {
105167 + if (atomic_read_unchecked(&hardware_enable_failed)) {
105168 hardware_disable_all_nolock();
105169 r = -EBUSY;
105170 }
105171 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
105172 kvm_arch_vcpu_put(vcpu);
105173 }
105174
105175 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105176 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105177 struct module *module)
105178 {
105179 int r;
105180 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105181 if (!vcpu_align)
105182 vcpu_align = __alignof__(struct kvm_vcpu);
105183 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
105184 - 0, NULL);
105185 + SLAB_USERCOPY, NULL);
105186 if (!kvm_vcpu_cache) {
105187 r = -ENOMEM;
105188 goto out_free_3;
105189 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105190 if (r)
105191 goto out_free;
105192
105193 + pax_open_kernel();
105194 kvm_chardev_ops.owner = module;
105195 kvm_vm_fops.owner = module;
105196 kvm_vcpu_fops.owner = module;
105197 + pax_close_kernel();
105198
105199 r = misc_register(&kvm_dev);
105200 if (r) {
105201 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105202
105203 register_syscore_ops(&kvm_syscore_ops);
105204
105205 - kvm_preempt_ops.sched_in = kvm_sched_in;
105206 - kvm_preempt_ops.sched_out = kvm_sched_out;
105207 -
105208 r = kvm_init_debug();
105209 if (r) {
105210 printk(KERN_ERR "kvm: create debugfs files failed\n");