]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.0-201307122308.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.0-201307122308.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 e5e3ba0..02c9b98 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..510061e 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..0193da8 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,62 @@ 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
4064 + therefore, when kernexec is disabled, instead of L_PTE_USER | L_PTE_RDONLY
4065 + which turns into supervisor rwx, userland rx, we instead omit that entirely,
4066 + leaving it as supervisor rwx only
4067 + */
4068 +#ifdef CONFIG_PAX_KERNEXEC
4069 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_RDONLY,
4070 +#else
4071 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4072 +#endif
4073 .prot_l1 = PMD_TYPE_TABLE,
4074 - .domain = DOMAIN_USER,
4075 + .domain = DOMAIN_VECTORS,
4076 },
4077 - [MT_MEMORY] = {
4078 + [MT_MEMORY_RWX] = {
4079 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4080 .prot_l1 = PMD_TYPE_TABLE,
4081 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4082 .domain = DOMAIN_KERNEL,
4083 },
4084 + [MT_MEMORY_RW] = {
4085 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4086 + .prot_l1 = PMD_TYPE_TABLE,
4087 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4088 + .domain = DOMAIN_KERNEL,
4089 + },
4090 + [MT_MEMORY_RX] = {
4091 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4092 + .prot_l1 = PMD_TYPE_TABLE,
4093 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4094 + .domain = DOMAIN_KERNEL,
4095 + },
4096 [MT_ROM] = {
4097 - .prot_sect = PMD_TYPE_SECT,
4098 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4099 .domain = DOMAIN_KERNEL,
4100 },
4101 - [MT_MEMORY_NONCACHED] = {
4102 + [MT_MEMORY_NONCACHED_RW] = {
4103 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4104 L_PTE_MT_BUFFERABLE,
4105 .prot_l1 = PMD_TYPE_TABLE,
4106 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4107 .domain = DOMAIN_KERNEL,
4108 },
4109 + [MT_MEMORY_NONCACHED_RX] = {
4110 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4111 + L_PTE_MT_BUFFERABLE,
4112 + .prot_l1 = PMD_TYPE_TABLE,
4113 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4114 + .domain = DOMAIN_KERNEL,
4115 + },
4116 [MT_MEMORY_DTCM] = {
4117 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4118 - L_PTE_XN,
4119 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4120 .prot_l1 = PMD_TYPE_TABLE,
4121 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4122 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4123 .domain = DOMAIN_KERNEL,
4124 },
4125 [MT_MEMORY_ITCM] = {
4126 @@ -316,10 +366,10 @@ static struct mem_type mem_types[] = {
4127 },
4128 [MT_MEMORY_SO] = {
4129 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4130 - L_PTE_MT_UNCACHED | L_PTE_XN,
4131 + L_PTE_MT_UNCACHED,
4132 .prot_l1 = PMD_TYPE_TABLE,
4133 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4134 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4135 + PMD_SECT_UNCACHED,
4136 .domain = DOMAIN_KERNEL,
4137 },
4138 [MT_MEMORY_DMA_READY] = {
4139 @@ -405,9 +455,35 @@ static void __init build_mem_type_table(void)
4140 * to prevent speculative instruction fetches.
4141 */
4142 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4143 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4144 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4145 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4146 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4147 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4148 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4149 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4150 +
4151 + /* Mark other regions on ARMv6+ as execute-never */
4152 +
4153 +#ifdef CONFIG_PAX_KERNEXEC
4154 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4155 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4156 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4157 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4158 +#ifndef CONFIG_ARM_LPAE
4159 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4160 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4161 +#endif
4162 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4163 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4164 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4165 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4166 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4167 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4168 +#endif
4169 +
4170 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4171 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4172 }
4173 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4174 /*
4175 @@ -468,6 +544,9 @@ static void __init build_mem_type_table(void)
4176 * from SVC mode and no access from userspace.
4177 */
4178 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4179 +#ifdef CONFIG_PAX_KERNEXEC
4180 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4181 +#endif
4182 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4183 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4184 #endif
4185 @@ -485,11 +564,17 @@ static void __init build_mem_type_table(void)
4186 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4187 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4188 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4189 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4190 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4191 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4192 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4193 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4194 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4195 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4196 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4197 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4198 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4199 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4200 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4201 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4202 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4203 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4204 }
4205 }
4206
4207 @@ -500,15 +585,20 @@ static void __init build_mem_type_table(void)
4208 if (cpu_arch >= CPU_ARCH_ARMv6) {
4209 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4210 /* Non-cacheable Normal is XCB = 001 */
4211 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4212 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4213 + PMD_SECT_BUFFERED;
4214 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4215 PMD_SECT_BUFFERED;
4216 } else {
4217 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4218 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4219 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4220 + PMD_SECT_TEX(1);
4221 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4222 PMD_SECT_TEX(1);
4223 }
4224 } else {
4225 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4226 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4227 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4228 }
4229
4230 #ifdef CONFIG_ARM_LPAE
4231 @@ -524,6 +614,8 @@ static void __init build_mem_type_table(void)
4232 vecs_pgprot |= PTE_EXT_AF;
4233 #endif
4234
4235 + user_pgprot |= __supported_pte_mask;
4236 +
4237 for (i = 0; i < 16; i++) {
4238 pteval_t v = pgprot_val(protection_map[i]);
4239 protection_map[i] = __pgprot(v | user_pgprot);
4240 @@ -541,10 +633,15 @@ static void __init build_mem_type_table(void)
4241
4242 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4243 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4244 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4245 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4246 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4247 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4248 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4249 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4250 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4251 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4252 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4253 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4254 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4255 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4256 mem_types[MT_ROM].prot_sect |= cp->pmd;
4257
4258 switch (cp->pmd) {
4259 @@ -1166,18 +1263,15 @@ void __init arm_mm_memblock_reserve(void)
4260 * called function. This means you can't use any function or debugging
4261 * method which may touch any device, otherwise the kernel _will_ crash.
4262 */
4263 +
4264 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4265 +
4266 static void __init devicemaps_init(struct machine_desc *mdesc)
4267 {
4268 struct map_desc map;
4269 unsigned long addr;
4270 - void *vectors;
4271
4272 - /*
4273 - * Allocate the vector page early.
4274 - */
4275 - vectors = early_alloc(PAGE_SIZE);
4276 -
4277 - early_trap_init(vectors);
4278 + early_trap_init(&vectors);
4279
4280 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4281 pmd_clear(pmd_off_k(addr));
4282 @@ -1217,7 +1311,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4283 * location (0xffff0000). If we aren't using high-vectors, also
4284 * create a mapping at the low-vectors virtual address.
4285 */
4286 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4287 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4288 map.virtual = 0xffff0000;
4289 map.length = PAGE_SIZE;
4290 map.type = MT_HIGH_VECTORS;
4291 @@ -1275,8 +1369,39 @@ static void __init map_lowmem(void)
4292 map.pfn = __phys_to_pfn(start);
4293 map.virtual = __phys_to_virt(start);
4294 map.length = end - start;
4295 - map.type = MT_MEMORY;
4296
4297 +#ifdef CONFIG_PAX_KERNEXEC
4298 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4299 + struct map_desc kernel;
4300 + struct map_desc initmap;
4301 +
4302 + /* when freeing initmem we will make this RW */
4303 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4304 + initmap.virtual = (unsigned long)__init_begin;
4305 + initmap.length = _sdata - __init_begin;
4306 + initmap.type = MT_MEMORY_RWX;
4307 + create_mapping(&initmap);
4308 +
4309 + /* when freeing initmem we will make this RX */
4310 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4311 + kernel.virtual = (unsigned long)_stext;
4312 + kernel.length = __init_begin - _stext;
4313 + kernel.type = MT_MEMORY_RWX;
4314 + create_mapping(&kernel);
4315 +
4316 + if (map.virtual < (unsigned long)_stext) {
4317 + map.length = (unsigned long)_stext - map.virtual;
4318 + map.type = MT_MEMORY_RWX;
4319 + create_mapping(&map);
4320 + }
4321 +
4322 + map.pfn = __phys_to_pfn(__pa(_sdata));
4323 + map.virtual = (unsigned long)_sdata;
4324 + map.length = end - __pa(_sdata);
4325 + }
4326 +#endif
4327 +
4328 + map.type = MT_MEMORY_RW;
4329 create_mapping(&map);
4330 }
4331 }
4332 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4333 index 9704097..3e36dde 100644
4334 --- a/arch/arm/mm/proc-v7-2level.S
4335 +++ b/arch/arm/mm/proc-v7-2level.S
4336 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4337 tst r1, #L_PTE_XN
4338 orrne r3, r3, #PTE_EXT_XN
4339
4340 + tst r1, #L_PTE_PXN
4341 + orrne r3, r3, #PTE_EXT_PXN
4342 +
4343 tst r1, #L_PTE_YOUNG
4344 tstne r1, #L_PTE_VALID
4345 #ifndef CONFIG_CPU_USE_DOMAINS
4346 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4347 index a5bc92d..0bb4730 100644
4348 --- a/arch/arm/plat-omap/sram.c
4349 +++ b/arch/arm/plat-omap/sram.c
4350 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4351 * Looks like we need to preserve some bootloader code at the
4352 * beginning of SRAM for jumping to flash for reboot to work...
4353 */
4354 + pax_open_kernel();
4355 memset_io(omap_sram_base + omap_sram_skip, 0,
4356 omap_sram_size - omap_sram_skip);
4357 + pax_close_kernel();
4358 }
4359 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4360 index ce6d763..cfea917 100644
4361 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4362 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4363 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4364 int (*started)(unsigned ch);
4365 int (*flush)(unsigned ch);
4366 int (*stop)(unsigned ch);
4367 -};
4368 +} __no_const;
4369
4370 extern void *samsung_dmadev_get_ops(void);
4371 extern void *s3c_dma_get_ops(void);
4372 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4373 index f4726dc..39ed646 100644
4374 --- a/arch/arm64/kernel/debug-monitors.c
4375 +++ b/arch/arm64/kernel/debug-monitors.c
4376 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4377 return NOTIFY_OK;
4378 }
4379
4380 -static struct notifier_block __cpuinitdata os_lock_nb = {
4381 +static struct notifier_block os_lock_nb = {
4382 .notifier_call = os_lock_notify,
4383 };
4384
4385 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4386 index 5ab825c..96aaec8 100644
4387 --- a/arch/arm64/kernel/hw_breakpoint.c
4388 +++ b/arch/arm64/kernel/hw_breakpoint.c
4389 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4390 return NOTIFY_OK;
4391 }
4392
4393 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4394 +static struct notifier_block hw_breakpoint_reset_nb = {
4395 .notifier_call = hw_breakpoint_reset_notify,
4396 };
4397
4398 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4399 index c3a58a1..78fbf54 100644
4400 --- a/arch/avr32/include/asm/cache.h
4401 +++ b/arch/avr32/include/asm/cache.h
4402 @@ -1,8 +1,10 @@
4403 #ifndef __ASM_AVR32_CACHE_H
4404 #define __ASM_AVR32_CACHE_H
4405
4406 +#include <linux/const.h>
4407 +
4408 #define L1_CACHE_SHIFT 5
4409 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4410 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4411
4412 /*
4413 * Memory returned by kmalloc() may be used for DMA, so we must make
4414 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4415 index d232888..87c8df1 100644
4416 --- a/arch/avr32/include/asm/elf.h
4417 +++ b/arch/avr32/include/asm/elf.h
4418 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4419 the loader. We need to make sure that it is out of the way of the program
4420 that it will "exec", and that there is sufficient room for the brk. */
4421
4422 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4423 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4424
4425 +#ifdef CONFIG_PAX_ASLR
4426 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4427 +
4428 +#define PAX_DELTA_MMAP_LEN 15
4429 +#define PAX_DELTA_STACK_LEN 15
4430 +#endif
4431
4432 /* This yields a mask that user programs can use to figure out what
4433 instruction set this CPU supports. This could be done in user space,
4434 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4435 index 479330b..53717a8 100644
4436 --- a/arch/avr32/include/asm/kmap_types.h
4437 +++ b/arch/avr32/include/asm/kmap_types.h
4438 @@ -2,9 +2,9 @@
4439 #define __ASM_AVR32_KMAP_TYPES_H
4440
4441 #ifdef CONFIG_DEBUG_HIGHMEM
4442 -# define KM_TYPE_NR 29
4443 +# define KM_TYPE_NR 30
4444 #else
4445 -# define KM_TYPE_NR 14
4446 +# define KM_TYPE_NR 15
4447 #endif
4448
4449 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4450 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4451 index b2f2d2d..d1c85cb 100644
4452 --- a/arch/avr32/mm/fault.c
4453 +++ b/arch/avr32/mm/fault.c
4454 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4455
4456 int exception_trace = 1;
4457
4458 +#ifdef CONFIG_PAX_PAGEEXEC
4459 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4460 +{
4461 + unsigned long i;
4462 +
4463 + printk(KERN_ERR "PAX: bytes at PC: ");
4464 + for (i = 0; i < 20; i++) {
4465 + unsigned char c;
4466 + if (get_user(c, (unsigned char *)pc+i))
4467 + printk(KERN_CONT "???????? ");
4468 + else
4469 + printk(KERN_CONT "%02x ", c);
4470 + }
4471 + printk("\n");
4472 +}
4473 +#endif
4474 +
4475 /*
4476 * This routine handles page faults. It determines the address and the
4477 * problem, and then passes it off to one of the appropriate routines.
4478 @@ -174,6 +191,16 @@ bad_area:
4479 up_read(&mm->mmap_sem);
4480
4481 if (user_mode(regs)) {
4482 +
4483 +#ifdef CONFIG_PAX_PAGEEXEC
4484 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4485 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4486 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4487 + do_group_exit(SIGKILL);
4488 + }
4489 + }
4490 +#endif
4491 +
4492 if (exception_trace && printk_ratelimit())
4493 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4494 "sp %08lx ecr %lu\n",
4495 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4496 index 568885a..f8008df 100644
4497 --- a/arch/blackfin/include/asm/cache.h
4498 +++ b/arch/blackfin/include/asm/cache.h
4499 @@ -7,6 +7,7 @@
4500 #ifndef __ARCH_BLACKFIN_CACHE_H
4501 #define __ARCH_BLACKFIN_CACHE_H
4502
4503 +#include <linux/const.h>
4504 #include <linux/linkage.h> /* for asmlinkage */
4505
4506 /*
4507 @@ -14,7 +15,7 @@
4508 * Blackfin loads 32 bytes for cache
4509 */
4510 #define L1_CACHE_SHIFT 5
4511 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4512 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4513 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4514
4515 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4516 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4517 index aea2718..3639a60 100644
4518 --- a/arch/cris/include/arch-v10/arch/cache.h
4519 +++ b/arch/cris/include/arch-v10/arch/cache.h
4520 @@ -1,8 +1,9 @@
4521 #ifndef _ASM_ARCH_CACHE_H
4522 #define _ASM_ARCH_CACHE_H
4523
4524 +#include <linux/const.h>
4525 /* Etrax 100LX have 32-byte cache-lines. */
4526 -#define L1_CACHE_BYTES 32
4527 #define L1_CACHE_SHIFT 5
4528 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4529
4530 #endif /* _ASM_ARCH_CACHE_H */
4531 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4532 index 7caf25d..ee65ac5 100644
4533 --- a/arch/cris/include/arch-v32/arch/cache.h
4534 +++ b/arch/cris/include/arch-v32/arch/cache.h
4535 @@ -1,11 +1,12 @@
4536 #ifndef _ASM_CRIS_ARCH_CACHE_H
4537 #define _ASM_CRIS_ARCH_CACHE_H
4538
4539 +#include <linux/const.h>
4540 #include <arch/hwregs/dma.h>
4541
4542 /* A cache-line is 32 bytes. */
4543 -#define L1_CACHE_BYTES 32
4544 #define L1_CACHE_SHIFT 5
4545 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4546
4547 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4548
4549 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4550 index b86329d..6709906 100644
4551 --- a/arch/frv/include/asm/atomic.h
4552 +++ b/arch/frv/include/asm/atomic.h
4553 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4554 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4555 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4556
4557 +#define atomic64_read_unchecked(v) atomic64_read(v)
4558 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4559 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4560 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4561 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4562 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4563 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4564 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4565 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4566 +
4567 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4568 {
4569 int c, old;
4570 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4571 index 2797163..c2a401d 100644
4572 --- a/arch/frv/include/asm/cache.h
4573 +++ b/arch/frv/include/asm/cache.h
4574 @@ -12,10 +12,11 @@
4575 #ifndef __ASM_CACHE_H
4576 #define __ASM_CACHE_H
4577
4578 +#include <linux/const.h>
4579
4580 /* bytes per L1 cache line */
4581 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4582 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4583 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4584
4585 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4586 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4587 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4588 index 43901f2..0d8b865 100644
4589 --- a/arch/frv/include/asm/kmap_types.h
4590 +++ b/arch/frv/include/asm/kmap_types.h
4591 @@ -2,6 +2,6 @@
4592 #ifndef _ASM_KMAP_TYPES_H
4593 #define _ASM_KMAP_TYPES_H
4594
4595 -#define KM_TYPE_NR 17
4596 +#define KM_TYPE_NR 18
4597
4598 #endif
4599 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4600 index 836f147..4cf23f5 100644
4601 --- a/arch/frv/mm/elf-fdpic.c
4602 +++ b/arch/frv/mm/elf-fdpic.c
4603 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4604 {
4605 struct vm_area_struct *vma;
4606 struct vm_unmapped_area_info info;
4607 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4608
4609 if (len > TASK_SIZE)
4610 return -ENOMEM;
4611 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4612 if (addr) {
4613 addr = PAGE_ALIGN(addr);
4614 vma = find_vma(current->mm, addr);
4615 - if (TASK_SIZE - len >= addr &&
4616 - (!vma || addr + len <= vma->vm_start))
4617 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4618 goto success;
4619 }
4620
4621 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4622 info.high_limit = (current->mm->start_stack - 0x00200000);
4623 info.align_mask = 0;
4624 info.align_offset = 0;
4625 + info.threadstack_offset = offset;
4626 addr = vm_unmapped_area(&info);
4627 if (!(addr & ~PAGE_MASK))
4628 goto success;
4629 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4630 index f4ca594..adc72fd6 100644
4631 --- a/arch/hexagon/include/asm/cache.h
4632 +++ b/arch/hexagon/include/asm/cache.h
4633 @@ -21,9 +21,11 @@
4634 #ifndef __ASM_CACHE_H
4635 #define __ASM_CACHE_H
4636
4637 +#include <linux/const.h>
4638 +
4639 /* Bytes per L1 cache line */
4640 -#define L1_CACHE_SHIFT (5)
4641 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4642 +#define L1_CACHE_SHIFT 5
4643 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4644
4645 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4646 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4647 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4648 index 6e6fe18..a6ae668 100644
4649 --- a/arch/ia64/include/asm/atomic.h
4650 +++ b/arch/ia64/include/asm/atomic.h
4651 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4652 #define atomic64_inc(v) atomic64_add(1, (v))
4653 #define atomic64_dec(v) atomic64_sub(1, (v))
4654
4655 +#define atomic64_read_unchecked(v) atomic64_read(v)
4656 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4657 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4658 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4659 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4660 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4661 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4662 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4663 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4664 +
4665 /* Atomic operations are already serializing */
4666 #define smp_mb__before_atomic_dec() barrier()
4667 #define smp_mb__after_atomic_dec() barrier()
4668 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4669 index 988254a..e1ee885 100644
4670 --- a/arch/ia64/include/asm/cache.h
4671 +++ b/arch/ia64/include/asm/cache.h
4672 @@ -1,6 +1,7 @@
4673 #ifndef _ASM_IA64_CACHE_H
4674 #define _ASM_IA64_CACHE_H
4675
4676 +#include <linux/const.h>
4677
4678 /*
4679 * Copyright (C) 1998-2000 Hewlett-Packard Co
4680 @@ -9,7 +10,7 @@
4681
4682 /* Bytes per L1 (data) cache line. */
4683 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4684 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4685 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4686
4687 #ifdef CONFIG_SMP
4688 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4689 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4690 index 5a83c5c..4d7f553 100644
4691 --- a/arch/ia64/include/asm/elf.h
4692 +++ b/arch/ia64/include/asm/elf.h
4693 @@ -42,6 +42,13 @@
4694 */
4695 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4696
4697 +#ifdef CONFIG_PAX_ASLR
4698 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4699 +
4700 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4701 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4702 +#endif
4703 +
4704 #define PT_IA_64_UNWIND 0x70000001
4705
4706 /* IA-64 relocations: */
4707 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4708 index 96a8d92..617a1cf 100644
4709 --- a/arch/ia64/include/asm/pgalloc.h
4710 +++ b/arch/ia64/include/asm/pgalloc.h
4711 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4712 pgd_val(*pgd_entry) = __pa(pud);
4713 }
4714
4715 +static inline void
4716 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4717 +{
4718 + pgd_populate(mm, pgd_entry, pud);
4719 +}
4720 +
4721 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4722 {
4723 return quicklist_alloc(0, GFP_KERNEL, NULL);
4724 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4725 pud_val(*pud_entry) = __pa(pmd);
4726 }
4727
4728 +static inline void
4729 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4730 +{
4731 + pud_populate(mm, pud_entry, pmd);
4732 +}
4733 +
4734 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4735 {
4736 return quicklist_alloc(0, GFP_KERNEL, NULL);
4737 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4738 index 815810c..d60bd4c 100644
4739 --- a/arch/ia64/include/asm/pgtable.h
4740 +++ b/arch/ia64/include/asm/pgtable.h
4741 @@ -12,7 +12,7 @@
4742 * David Mosberger-Tang <davidm@hpl.hp.com>
4743 */
4744
4745 -
4746 +#include <linux/const.h>
4747 #include <asm/mman.h>
4748 #include <asm/page.h>
4749 #include <asm/processor.h>
4750 @@ -142,6 +142,17 @@
4751 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4752 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4753 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4754 +
4755 +#ifdef CONFIG_PAX_PAGEEXEC
4756 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4757 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4758 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4759 +#else
4760 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4761 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4762 +# define PAGE_COPY_NOEXEC PAGE_COPY
4763 +#endif
4764 +
4765 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4766 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4767 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4768 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4769 index 54ff557..70c88b7 100644
4770 --- a/arch/ia64/include/asm/spinlock.h
4771 +++ b/arch/ia64/include/asm/spinlock.h
4772 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4773 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4774
4775 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4776 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4777 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4778 }
4779
4780 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4781 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4782 index 449c8c0..18965fb 100644
4783 --- a/arch/ia64/include/asm/uaccess.h
4784 +++ b/arch/ia64/include/asm/uaccess.h
4785 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4786 static inline unsigned long
4787 __copy_to_user (void __user *to, const void *from, unsigned long count)
4788 {
4789 + if (count > INT_MAX)
4790 + return count;
4791 +
4792 + if (!__builtin_constant_p(count))
4793 + check_object_size(from, count, true);
4794 +
4795 return __copy_user(to, (__force void __user *) from, count);
4796 }
4797
4798 static inline unsigned long
4799 __copy_from_user (void *to, const void __user *from, unsigned long count)
4800 {
4801 + if (count > INT_MAX)
4802 + return count;
4803 +
4804 + if (!__builtin_constant_p(count))
4805 + check_object_size(to, count, false);
4806 +
4807 return __copy_user((__force void __user *) to, from, count);
4808 }
4809
4810 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4811 ({ \
4812 void __user *__cu_to = (to); \
4813 const void *__cu_from = (from); \
4814 - long __cu_len = (n); \
4815 + unsigned long __cu_len = (n); \
4816 \
4817 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4818 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4819 + if (!__builtin_constant_p(n)) \
4820 + check_object_size(__cu_from, __cu_len, true); \
4821 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4822 + } \
4823 __cu_len; \
4824 })
4825
4826 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4827 ({ \
4828 void *__cu_to = (to); \
4829 const void __user *__cu_from = (from); \
4830 - long __cu_len = (n); \
4831 + unsigned long __cu_len = (n); \
4832 \
4833 __chk_user_ptr(__cu_from); \
4834 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4835 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4836 + if (!__builtin_constant_p(n)) \
4837 + check_object_size(__cu_to, __cu_len, false); \
4838 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4839 + } \
4840 __cu_len; \
4841 })
4842
4843 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4844 index 2d67317..07d8bfa 100644
4845 --- a/arch/ia64/kernel/err_inject.c
4846 +++ b/arch/ia64/kernel/err_inject.c
4847 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4848 return NOTIFY_OK;
4849 }
4850
4851 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4852 +static struct notifier_block err_inject_cpu_notifier =
4853 {
4854 .notifier_call = err_inject_cpu_callback,
4855 };
4856 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4857 index d7396db..b33e873 100644
4858 --- a/arch/ia64/kernel/mca.c
4859 +++ b/arch/ia64/kernel/mca.c
4860 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4861 return NOTIFY_OK;
4862 }
4863
4864 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4865 +static struct notifier_block mca_cpu_notifier = {
4866 .notifier_call = mca_cpu_callback
4867 };
4868
4869 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4870 index 24603be..948052d 100644
4871 --- a/arch/ia64/kernel/module.c
4872 +++ b/arch/ia64/kernel/module.c
4873 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4874 void
4875 module_free (struct module *mod, void *module_region)
4876 {
4877 - if (mod && mod->arch.init_unw_table &&
4878 - module_region == mod->module_init) {
4879 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4880 unw_remove_unwind_table(mod->arch.init_unw_table);
4881 mod->arch.init_unw_table = NULL;
4882 }
4883 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4884 }
4885
4886 static inline int
4887 +in_init_rx (const struct module *mod, uint64_t addr)
4888 +{
4889 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4890 +}
4891 +
4892 +static inline int
4893 +in_init_rw (const struct module *mod, uint64_t addr)
4894 +{
4895 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4896 +}
4897 +
4898 +static inline int
4899 in_init (const struct module *mod, uint64_t addr)
4900 {
4901 - return addr - (uint64_t) mod->module_init < mod->init_size;
4902 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4903 +}
4904 +
4905 +static inline int
4906 +in_core_rx (const struct module *mod, uint64_t addr)
4907 +{
4908 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4909 +}
4910 +
4911 +static inline int
4912 +in_core_rw (const struct module *mod, uint64_t addr)
4913 +{
4914 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4915 }
4916
4917 static inline int
4918 in_core (const struct module *mod, uint64_t addr)
4919 {
4920 - return addr - (uint64_t) mod->module_core < mod->core_size;
4921 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4922 }
4923
4924 static inline int
4925 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4926 break;
4927
4928 case RV_BDREL:
4929 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4930 + if (in_init_rx(mod, val))
4931 + val -= (uint64_t) mod->module_init_rx;
4932 + else if (in_init_rw(mod, val))
4933 + val -= (uint64_t) mod->module_init_rw;
4934 + else if (in_core_rx(mod, val))
4935 + val -= (uint64_t) mod->module_core_rx;
4936 + else if (in_core_rw(mod, val))
4937 + val -= (uint64_t) mod->module_core_rw;
4938 break;
4939
4940 case RV_LTV:
4941 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4942 * addresses have been selected...
4943 */
4944 uint64_t gp;
4945 - if (mod->core_size > MAX_LTOFF)
4946 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4947 /*
4948 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4949 * at the end of the module.
4950 */
4951 - gp = mod->core_size - MAX_LTOFF / 2;
4952 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4953 else
4954 - gp = mod->core_size / 2;
4955 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4956 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4957 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4958 mod->arch.gp = gp;
4959 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4960 }
4961 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4962 index 2b3c2d7..a318d84 100644
4963 --- a/arch/ia64/kernel/palinfo.c
4964 +++ b/arch/ia64/kernel/palinfo.c
4965 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4966 return NOTIFY_OK;
4967 }
4968
4969 -static struct notifier_block __refdata palinfo_cpu_notifier =
4970 +static struct notifier_block palinfo_cpu_notifier =
4971 {
4972 .notifier_call = palinfo_cpu_callback,
4973 .priority = 0,
4974 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4975 index 4bc580a..7767f24 100644
4976 --- a/arch/ia64/kernel/salinfo.c
4977 +++ b/arch/ia64/kernel/salinfo.c
4978 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4979 return NOTIFY_OK;
4980 }
4981
4982 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4983 +static struct notifier_block salinfo_cpu_notifier =
4984 {
4985 .notifier_call = salinfo_cpu_callback,
4986 .priority = 0,
4987 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4988 index 41e33f8..65180b2 100644
4989 --- a/arch/ia64/kernel/sys_ia64.c
4990 +++ b/arch/ia64/kernel/sys_ia64.c
4991 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4992 unsigned long align_mask = 0;
4993 struct mm_struct *mm = current->mm;
4994 struct vm_unmapped_area_info info;
4995 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4996
4997 if (len > RGN_MAP_LIMIT)
4998 return -ENOMEM;
4999 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5000 if (REGION_NUMBER(addr) == RGN_HPAGE)
5001 addr = 0;
5002 #endif
5003 +
5004 +#ifdef CONFIG_PAX_RANDMMAP
5005 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5006 + addr = mm->free_area_cache;
5007 + else
5008 +#endif
5009 +
5010 if (!addr)
5011 addr = TASK_UNMAPPED_BASE;
5012
5013 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5014 info.high_limit = TASK_SIZE;
5015 info.align_mask = align_mask;
5016 info.align_offset = 0;
5017 + info.threadstack_offset = offset;
5018 return vm_unmapped_area(&info);
5019 }
5020
5021 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5022 index dc00b2c..cce53c2 100644
5023 --- a/arch/ia64/kernel/topology.c
5024 +++ b/arch/ia64/kernel/topology.c
5025 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5026 return NOTIFY_OK;
5027 }
5028
5029 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5030 +static struct notifier_block cache_cpu_notifier =
5031 {
5032 .notifier_call = cache_cpu_callback
5033 };
5034 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5035 index 0ccb28f..8992469 100644
5036 --- a/arch/ia64/kernel/vmlinux.lds.S
5037 +++ b/arch/ia64/kernel/vmlinux.lds.S
5038 @@ -198,7 +198,7 @@ SECTIONS {
5039 /* Per-cpu data: */
5040 . = ALIGN(PERCPU_PAGE_SIZE);
5041 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5042 - __phys_per_cpu_start = __per_cpu_load;
5043 + __phys_per_cpu_start = per_cpu_load;
5044 /*
5045 * ensure percpu data fits
5046 * into percpu page size
5047 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5048 index 6cf0341..d352594 100644
5049 --- a/arch/ia64/mm/fault.c
5050 +++ b/arch/ia64/mm/fault.c
5051 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5052 return pte_present(pte);
5053 }
5054
5055 +#ifdef CONFIG_PAX_PAGEEXEC
5056 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5057 +{
5058 + unsigned long i;
5059 +
5060 + printk(KERN_ERR "PAX: bytes at PC: ");
5061 + for (i = 0; i < 8; i++) {
5062 + unsigned int c;
5063 + if (get_user(c, (unsigned int *)pc+i))
5064 + printk(KERN_CONT "???????? ");
5065 + else
5066 + printk(KERN_CONT "%08x ", c);
5067 + }
5068 + printk("\n");
5069 +}
5070 +#endif
5071 +
5072 # define VM_READ_BIT 0
5073 # define VM_WRITE_BIT 1
5074 # define VM_EXEC_BIT 2
5075 @@ -149,8 +166,21 @@ retry:
5076 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5077 goto bad_area;
5078
5079 - if ((vma->vm_flags & mask) != mask)
5080 + if ((vma->vm_flags & mask) != mask) {
5081 +
5082 +#ifdef CONFIG_PAX_PAGEEXEC
5083 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5084 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5085 + goto bad_area;
5086 +
5087 + up_read(&mm->mmap_sem);
5088 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5089 + do_group_exit(SIGKILL);
5090 + }
5091 +#endif
5092 +
5093 goto bad_area;
5094 + }
5095
5096 /*
5097 * If for any reason at all we couldn't handle the fault, make
5098 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5099 index 76069c1..c2aa816 100644
5100 --- a/arch/ia64/mm/hugetlbpage.c
5101 +++ b/arch/ia64/mm/hugetlbpage.c
5102 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5103 unsigned long pgoff, unsigned long flags)
5104 {
5105 struct vm_unmapped_area_info info;
5106 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5107
5108 if (len > RGN_MAP_LIMIT)
5109 return -ENOMEM;
5110 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5111 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5112 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5113 info.align_offset = 0;
5114 + info.threadstack_offset = offset;
5115 return vm_unmapped_area(&info);
5116 }
5117
5118 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5119 index d1fe4b4..2628f37 100644
5120 --- a/arch/ia64/mm/init.c
5121 +++ b/arch/ia64/mm/init.c
5122 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5123 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5124 vma->vm_end = vma->vm_start + PAGE_SIZE;
5125 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5126 +
5127 +#ifdef CONFIG_PAX_PAGEEXEC
5128 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5129 + vma->vm_flags &= ~VM_EXEC;
5130 +
5131 +#ifdef CONFIG_PAX_MPROTECT
5132 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5133 + vma->vm_flags &= ~VM_MAYEXEC;
5134 +#endif
5135 +
5136 + }
5137 +#endif
5138 +
5139 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5140 down_write(&current->mm->mmap_sem);
5141 if (insert_vm_struct(current->mm, vma)) {
5142 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5143 index 40b3ee9..8c2c112 100644
5144 --- a/arch/m32r/include/asm/cache.h
5145 +++ b/arch/m32r/include/asm/cache.h
5146 @@ -1,8 +1,10 @@
5147 #ifndef _ASM_M32R_CACHE_H
5148 #define _ASM_M32R_CACHE_H
5149
5150 +#include <linux/const.h>
5151 +
5152 /* L1 cache line size */
5153 #define L1_CACHE_SHIFT 4
5154 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5155 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5156
5157 #endif /* _ASM_M32R_CACHE_H */
5158 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5159 index 82abd15..d95ae5d 100644
5160 --- a/arch/m32r/lib/usercopy.c
5161 +++ b/arch/m32r/lib/usercopy.c
5162 @@ -14,6 +14,9 @@
5163 unsigned long
5164 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5165 {
5166 + if ((long)n < 0)
5167 + return n;
5168 +
5169 prefetch(from);
5170 if (access_ok(VERIFY_WRITE, to, n))
5171 __copy_user(to,from,n);
5172 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5173 unsigned long
5174 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5175 {
5176 + if ((long)n < 0)
5177 + return n;
5178 +
5179 prefetchw(to);
5180 if (access_ok(VERIFY_READ, from, n))
5181 __copy_user_zeroing(to,from,n);
5182 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5183 index 0395c51..5f26031 100644
5184 --- a/arch/m68k/include/asm/cache.h
5185 +++ b/arch/m68k/include/asm/cache.h
5186 @@ -4,9 +4,11 @@
5187 #ifndef __ARCH_M68K_CACHE_H
5188 #define __ARCH_M68K_CACHE_H
5189
5190 +#include <linux/const.h>
5191 +
5192 /* bytes per L1 cache line */
5193 #define L1_CACHE_SHIFT 4
5194 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5195 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5196
5197 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5198
5199 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5200 index 3c52fa6..11b2ad8 100644
5201 --- a/arch/metag/mm/hugetlbpage.c
5202 +++ b/arch/metag/mm/hugetlbpage.c
5203 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5204 info.high_limit = TASK_SIZE;
5205 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5206 info.align_offset = 0;
5207 + info.threadstack_offset = 0;
5208 return vm_unmapped_area(&info);
5209 }
5210
5211 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5212 index 4efe96a..60e8699 100644
5213 --- a/arch/microblaze/include/asm/cache.h
5214 +++ b/arch/microblaze/include/asm/cache.h
5215 @@ -13,11 +13,12 @@
5216 #ifndef _ASM_MICROBLAZE_CACHE_H
5217 #define _ASM_MICROBLAZE_CACHE_H
5218
5219 +#include <linux/const.h>
5220 #include <asm/registers.h>
5221
5222 #define L1_CACHE_SHIFT 5
5223 /* word-granular cache in microblaze */
5224 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5225 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5226
5227 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5228
5229 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5230 index 08b6079..eb272cf 100644
5231 --- a/arch/mips/include/asm/atomic.h
5232 +++ b/arch/mips/include/asm/atomic.h
5233 @@ -21,6 +21,10 @@
5234 #include <asm/cmpxchg.h>
5235 #include <asm/war.h>
5236
5237 +#ifdef CONFIG_GENERIC_ATOMIC64
5238 +#include <asm-generic/atomic64.h>
5239 +#endif
5240 +
5241 #define ATOMIC_INIT(i) { (i) }
5242
5243 /*
5244 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5245 */
5246 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5247
5248 +#define atomic64_read_unchecked(v) atomic64_read(v)
5249 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5250 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5251 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5252 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5253 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5254 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5255 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5256 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5257 +
5258 #endif /* CONFIG_64BIT */
5259
5260 /*
5261 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5262 index b4db69f..8f3b093 100644
5263 --- a/arch/mips/include/asm/cache.h
5264 +++ b/arch/mips/include/asm/cache.h
5265 @@ -9,10 +9,11 @@
5266 #ifndef _ASM_CACHE_H
5267 #define _ASM_CACHE_H
5268
5269 +#include <linux/const.h>
5270 #include <kmalloc.h>
5271
5272 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5273 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5274 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5275
5276 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5277 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5278 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5279 index cf3ae24..238d22f 100644
5280 --- a/arch/mips/include/asm/elf.h
5281 +++ b/arch/mips/include/asm/elf.h
5282 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5283 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5284 #endif
5285
5286 +#ifdef CONFIG_PAX_ASLR
5287 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5288 +
5289 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5290 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5291 +#endif
5292 +
5293 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5294 struct linux_binprm;
5295 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5296 int uses_interp);
5297
5298 -struct mm_struct;
5299 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5300 -#define arch_randomize_brk arch_randomize_brk
5301 -
5302 #endif /* _ASM_ELF_H */
5303 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5304 index c1f6afa..38cc6e9 100644
5305 --- a/arch/mips/include/asm/exec.h
5306 +++ b/arch/mips/include/asm/exec.h
5307 @@ -12,6 +12,6 @@
5308 #ifndef _ASM_EXEC_H
5309 #define _ASM_EXEC_H
5310
5311 -extern unsigned long arch_align_stack(unsigned long sp);
5312 +#define arch_align_stack(x) ((x) & ~0xfUL)
5313
5314 #endif /* _ASM_EXEC_H */
5315 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5316 index f59552f..3abe9b9 100644
5317 --- a/arch/mips/include/asm/page.h
5318 +++ b/arch/mips/include/asm/page.h
5319 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5320 #ifdef CONFIG_CPU_MIPS32
5321 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5322 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5323 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5324 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5325 #else
5326 typedef struct { unsigned long long pte; } pte_t;
5327 #define pte_val(x) ((x).pte)
5328 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5329 index 881d18b..cea38bc 100644
5330 --- a/arch/mips/include/asm/pgalloc.h
5331 +++ b/arch/mips/include/asm/pgalloc.h
5332 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5333 {
5334 set_pud(pud, __pud((unsigned long)pmd));
5335 }
5336 +
5337 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5338 +{
5339 + pud_populate(mm, pud, pmd);
5340 +}
5341 #endif
5342
5343 /*
5344 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5345 index 895320e..bf63e10 100644
5346 --- a/arch/mips/include/asm/thread_info.h
5347 +++ b/arch/mips/include/asm/thread_info.h
5348 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5349 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5350 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5351 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5352 +/* li takes a 32bit immediate */
5353 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5354 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5355
5356 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5357 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5358 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5359 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5360 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5361 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5362 +
5363 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5364
5365 /* work to do in syscall_trace_leave() */
5366 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5367 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5368
5369 /* work to do on interrupt/exception return */
5370 #define _TIF_WORK_MASK \
5371 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5372 /* work to do on any return to u-space */
5373 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5374 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5375
5376 #endif /* __KERNEL__ */
5377
5378 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5379 index 1188e00..41cf144 100644
5380 --- a/arch/mips/kernel/binfmt_elfn32.c
5381 +++ b/arch/mips/kernel/binfmt_elfn32.c
5382 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5383 #undef ELF_ET_DYN_BASE
5384 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5385
5386 +#ifdef CONFIG_PAX_ASLR
5387 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5388 +
5389 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5390 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5391 +#endif
5392 +
5393 #include <asm/processor.h>
5394 #include <linux/module.h>
5395 #include <linux/elfcore.h>
5396 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5397 index 202e581..689ca79 100644
5398 --- a/arch/mips/kernel/binfmt_elfo32.c
5399 +++ b/arch/mips/kernel/binfmt_elfo32.c
5400 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5401 #undef ELF_ET_DYN_BASE
5402 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5403
5404 +#ifdef CONFIG_PAX_ASLR
5405 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5406 +
5407 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5408 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5409 +#endif
5410 +
5411 #include <asm/processor.h>
5412
5413 /*
5414 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5415 index c6a041d..b3e7318 100644
5416 --- a/arch/mips/kernel/process.c
5417 +++ b/arch/mips/kernel/process.c
5418 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5419 out:
5420 return pc;
5421 }
5422 -
5423 -/*
5424 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5425 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5426 - */
5427 -unsigned long arch_align_stack(unsigned long sp)
5428 -{
5429 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5430 - sp -= get_random_int() & ~PAGE_MASK;
5431 -
5432 - return sp & ALMASK;
5433 -}
5434 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5435 index 9c6299c..2fb4c22 100644
5436 --- a/arch/mips/kernel/ptrace.c
5437 +++ b/arch/mips/kernel/ptrace.c
5438 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5439 return arch;
5440 }
5441
5442 +#ifdef CONFIG_GRKERNSEC_SETXID
5443 +extern void gr_delayed_cred_worker(void);
5444 +#endif
5445 +
5446 /*
5447 * Notification of system call entry/exit
5448 * - triggered by current->work.syscall_trace
5449 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5450 /* do the secure computing check first */
5451 secure_computing_strict(regs->regs[2]);
5452
5453 +#ifdef CONFIG_GRKERNSEC_SETXID
5454 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5455 + gr_delayed_cred_worker();
5456 +#endif
5457 +
5458 if (!(current->ptrace & PT_PTRACED))
5459 goto out;
5460
5461 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5462 index 9b36424..e7f4154 100644
5463 --- a/arch/mips/kernel/scall32-o32.S
5464 +++ b/arch/mips/kernel/scall32-o32.S
5465 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5466
5467 stack_done:
5468 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5469 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5470 + li t1, _TIF_SYSCALL_WORK
5471 and t0, t1
5472 bnez t0, syscall_trace_entry # -> yes
5473
5474 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5475 index 97a5909..59622f8 100644
5476 --- a/arch/mips/kernel/scall64-64.S
5477 +++ b/arch/mips/kernel/scall64-64.S
5478 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5479
5480 sd a3, PT_R26(sp) # save a3 for syscall restarting
5481
5482 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5483 + li t1, _TIF_SYSCALL_WORK
5484 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5485 and t0, t1, t0
5486 bnez t0, syscall_trace_entry
5487 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5488 index edcb659..fb2ab09 100644
5489 --- a/arch/mips/kernel/scall64-n32.S
5490 +++ b/arch/mips/kernel/scall64-n32.S
5491 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5492
5493 sd a3, PT_R26(sp) # save a3 for syscall restarting
5494
5495 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5496 + li t1, _TIF_SYSCALL_WORK
5497 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5498 and t0, t1, t0
5499 bnez t0, n32_syscall_trace_entry
5500 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5501 index 74f485d..47d2c38 100644
5502 --- a/arch/mips/kernel/scall64-o32.S
5503 +++ b/arch/mips/kernel/scall64-o32.S
5504 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5505 PTR 4b, bad_stack
5506 .previous
5507
5508 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5509 + li t1, _TIF_SYSCALL_WORK
5510 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5511 and t0, t1, t0
5512 bnez t0, trace_a_syscall
5513 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5514 index 0fead53..a2c0fb5 100644
5515 --- a/arch/mips/mm/fault.c
5516 +++ b/arch/mips/mm/fault.c
5517 @@ -27,6 +27,23 @@
5518 #include <asm/highmem.h> /* For VMALLOC_END */
5519 #include <linux/kdebug.h>
5520
5521 +#ifdef CONFIG_PAX_PAGEEXEC
5522 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5523 +{
5524 + unsigned long i;
5525 +
5526 + printk(KERN_ERR "PAX: bytes at PC: ");
5527 + for (i = 0; i < 5; i++) {
5528 + unsigned int c;
5529 + if (get_user(c, (unsigned int *)pc+i))
5530 + printk(KERN_CONT "???????? ");
5531 + else
5532 + printk(KERN_CONT "%08x ", c);
5533 + }
5534 + printk("\n");
5535 +}
5536 +#endif
5537 +
5538 /*
5539 * This routine handles page faults. It determines the address,
5540 * and the problem, and then passes it off to one of the appropriate
5541 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5542 index 7e5fe27..9656513 100644
5543 --- a/arch/mips/mm/mmap.c
5544 +++ b/arch/mips/mm/mmap.c
5545 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5546 struct vm_area_struct *vma;
5547 unsigned long addr = addr0;
5548 int do_color_align;
5549 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5550 struct vm_unmapped_area_info info;
5551
5552 if (unlikely(len > TASK_SIZE))
5553 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5554 do_color_align = 1;
5555
5556 /* requesting a specific address */
5557 +
5558 +#ifdef CONFIG_PAX_RANDMMAP
5559 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5560 +#endif
5561 +
5562 if (addr) {
5563 if (do_color_align)
5564 addr = COLOUR_ALIGN(addr, pgoff);
5565 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5566 addr = PAGE_ALIGN(addr);
5567
5568 vma = find_vma(mm, addr);
5569 - if (TASK_SIZE - len >= addr &&
5570 - (!vma || addr + len <= vma->vm_start))
5571 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5572 return addr;
5573 }
5574
5575 info.length = len;
5576 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5577 info.align_offset = pgoff << PAGE_SHIFT;
5578 + info.threadstack_offset = offset;
5579
5580 if (dir == DOWN) {
5581 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5582 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5583 {
5584 unsigned long random_factor = 0UL;
5585
5586 +#ifdef CONFIG_PAX_RANDMMAP
5587 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5588 +#endif
5589 +
5590 if (current->flags & PF_RANDOMIZE) {
5591 random_factor = get_random_int();
5592 random_factor = random_factor << PAGE_SHIFT;
5593 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5594
5595 if (mmap_is_legacy()) {
5596 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5597 +
5598 +#ifdef CONFIG_PAX_RANDMMAP
5599 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5600 + mm->mmap_base += mm->delta_mmap;
5601 +#endif
5602 +
5603 mm->get_unmapped_area = arch_get_unmapped_area;
5604 mm->unmap_area = arch_unmap_area;
5605 } else {
5606 mm->mmap_base = mmap_base(random_factor);
5607 +
5608 +#ifdef CONFIG_PAX_RANDMMAP
5609 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5610 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5611 +#endif
5612 +
5613 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5614 mm->unmap_area = arch_unmap_area_topdown;
5615 }
5616 }
5617
5618 -static inline unsigned long brk_rnd(void)
5619 -{
5620 - unsigned long rnd = get_random_int();
5621 -
5622 - rnd = rnd << PAGE_SHIFT;
5623 - /* 8MB for 32bit, 256MB for 64bit */
5624 - if (TASK_IS_32BIT_ADDR)
5625 - rnd = rnd & 0x7ffffful;
5626 - else
5627 - rnd = rnd & 0xffffffful;
5628 -
5629 - return rnd;
5630 -}
5631 -
5632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5633 -{
5634 - unsigned long base = mm->brk;
5635 - unsigned long ret;
5636 -
5637 - ret = PAGE_ALIGN(base + brk_rnd());
5638 -
5639 - if (ret < mm->brk)
5640 - return mm->brk;
5641 -
5642 - return ret;
5643 -}
5644 -
5645 int __virt_addr_valid(const volatile void *kaddr)
5646 {
5647 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5648 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5649 index 967d144..db12197 100644
5650 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5651 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5652 @@ -11,12 +11,14 @@
5653 #ifndef _ASM_PROC_CACHE_H
5654 #define _ASM_PROC_CACHE_H
5655
5656 +#include <linux/const.h>
5657 +
5658 /* L1 cache */
5659
5660 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5661 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5662 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5663 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5664 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5665 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5666
5667 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5668 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5669 index bcb5df2..84fabd2 100644
5670 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5671 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5672 @@ -16,13 +16,15 @@
5673 #ifndef _ASM_PROC_CACHE_H
5674 #define _ASM_PROC_CACHE_H
5675
5676 +#include <linux/const.h>
5677 +
5678 /*
5679 * L1 cache
5680 */
5681 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5682 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5683 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5684 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5685 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5686 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5687
5688 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5689 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5690 index 4ce7a01..449202a 100644
5691 --- a/arch/openrisc/include/asm/cache.h
5692 +++ b/arch/openrisc/include/asm/cache.h
5693 @@ -19,11 +19,13 @@
5694 #ifndef __ASM_OPENRISC_CACHE_H
5695 #define __ASM_OPENRISC_CACHE_H
5696
5697 +#include <linux/const.h>
5698 +
5699 /* FIXME: How can we replace these with values from the CPU...
5700 * they shouldn't be hard-coded!
5701 */
5702
5703 -#define L1_CACHE_BYTES 16
5704 #define L1_CACHE_SHIFT 4
5705 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5706
5707 #endif /* __ASM_OPENRISC_CACHE_H */
5708 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5709 index 472886c..00e7df9 100644
5710 --- a/arch/parisc/include/asm/atomic.h
5711 +++ b/arch/parisc/include/asm/atomic.h
5712 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5713 return dec;
5714 }
5715
5716 +#define atomic64_read_unchecked(v) atomic64_read(v)
5717 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5718 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5719 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5720 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5721 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5722 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5723 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5724 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5725 +
5726 #endif /* !CONFIG_64BIT */
5727
5728
5729 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5730 index 47f11c7..3420df2 100644
5731 --- a/arch/parisc/include/asm/cache.h
5732 +++ b/arch/parisc/include/asm/cache.h
5733 @@ -5,6 +5,7 @@
5734 #ifndef __ARCH_PARISC_CACHE_H
5735 #define __ARCH_PARISC_CACHE_H
5736
5737 +#include <linux/const.h>
5738
5739 /*
5740 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5741 @@ -15,13 +16,13 @@
5742 * just ruin performance.
5743 */
5744 #ifdef CONFIG_PA20
5745 -#define L1_CACHE_BYTES 64
5746 #define L1_CACHE_SHIFT 6
5747 #else
5748 -#define L1_CACHE_BYTES 32
5749 #define L1_CACHE_SHIFT 5
5750 #endif
5751
5752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5753 +
5754 #ifndef __ASSEMBLY__
5755
5756 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5757 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5758 index ad2b503..bdf1651 100644
5759 --- a/arch/parisc/include/asm/elf.h
5760 +++ b/arch/parisc/include/asm/elf.h
5761 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5762
5763 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5764
5765 +#ifdef CONFIG_PAX_ASLR
5766 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5767 +
5768 +#define PAX_DELTA_MMAP_LEN 16
5769 +#define PAX_DELTA_STACK_LEN 16
5770 +#endif
5771 +
5772 /* This yields a mask that user programs can use to figure out what
5773 instruction set this CPU supports. This could be done in user space,
5774 but it's not easy, and we've already done it here. */
5775 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5776 index fc987a1..6e068ef 100644
5777 --- a/arch/parisc/include/asm/pgalloc.h
5778 +++ b/arch/parisc/include/asm/pgalloc.h
5779 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5780 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5781 }
5782
5783 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5784 +{
5785 + pgd_populate(mm, pgd, pmd);
5786 +}
5787 +
5788 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5789 {
5790 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5791 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5792 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5793 #define pmd_free(mm, x) do { } while (0)
5794 #define pgd_populate(mm, pmd, pte) BUG()
5795 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5796
5797 #endif
5798
5799 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5800 index 1e40d7f..a3eb445 100644
5801 --- a/arch/parisc/include/asm/pgtable.h
5802 +++ b/arch/parisc/include/asm/pgtable.h
5803 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5804 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5805 #define PAGE_COPY PAGE_EXECREAD
5806 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5807 +
5808 +#ifdef CONFIG_PAX_PAGEEXEC
5809 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5810 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5811 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5812 +#else
5813 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5814 +# define PAGE_COPY_NOEXEC PAGE_COPY
5815 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5816 +#endif
5817 +
5818 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5819 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5820 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5821 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5822 index e0a8235..ce2f1e1 100644
5823 --- a/arch/parisc/include/asm/uaccess.h
5824 +++ b/arch/parisc/include/asm/uaccess.h
5825 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5826 const void __user *from,
5827 unsigned long n)
5828 {
5829 - int sz = __compiletime_object_size(to);
5830 + size_t sz = __compiletime_object_size(to);
5831 int ret = -EFAULT;
5832
5833 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5834 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5835 ret = __copy_from_user(to, from, n);
5836 else
5837 copy_from_user_overflow();
5838 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5839 index 2a625fb..9908930 100644
5840 --- a/arch/parisc/kernel/module.c
5841 +++ b/arch/parisc/kernel/module.c
5842 @@ -98,16 +98,38 @@
5843
5844 /* three functions to determine where in the module core
5845 * or init pieces the location is */
5846 +static inline int in_init_rx(struct module *me, void *loc)
5847 +{
5848 + return (loc >= me->module_init_rx &&
5849 + loc < (me->module_init_rx + me->init_size_rx));
5850 +}
5851 +
5852 +static inline int in_init_rw(struct module *me, void *loc)
5853 +{
5854 + return (loc >= me->module_init_rw &&
5855 + loc < (me->module_init_rw + me->init_size_rw));
5856 +}
5857 +
5858 static inline int in_init(struct module *me, void *loc)
5859 {
5860 - return (loc >= me->module_init &&
5861 - loc <= (me->module_init + me->init_size));
5862 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5863 +}
5864 +
5865 +static inline int in_core_rx(struct module *me, void *loc)
5866 +{
5867 + return (loc >= me->module_core_rx &&
5868 + loc < (me->module_core_rx + me->core_size_rx));
5869 +}
5870 +
5871 +static inline int in_core_rw(struct module *me, void *loc)
5872 +{
5873 + return (loc >= me->module_core_rw &&
5874 + loc < (me->module_core_rw + me->core_size_rw));
5875 }
5876
5877 static inline int in_core(struct module *me, void *loc)
5878 {
5879 - return (loc >= me->module_core &&
5880 - loc <= (me->module_core + me->core_size));
5881 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5882 }
5883
5884 static inline int in_local(struct module *me, void *loc)
5885 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5886 }
5887
5888 /* align things a bit */
5889 - me->core_size = ALIGN(me->core_size, 16);
5890 - me->arch.got_offset = me->core_size;
5891 - me->core_size += gots * sizeof(struct got_entry);
5892 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5893 + me->arch.got_offset = me->core_size_rw;
5894 + me->core_size_rw += gots * sizeof(struct got_entry);
5895
5896 - me->core_size = ALIGN(me->core_size, 16);
5897 - me->arch.fdesc_offset = me->core_size;
5898 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5899 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5900 + me->arch.fdesc_offset = me->core_size_rw;
5901 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5902
5903 me->arch.got_max = gots;
5904 me->arch.fdesc_max = fdescs;
5905 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5906
5907 BUG_ON(value == 0);
5908
5909 - got = me->module_core + me->arch.got_offset;
5910 + got = me->module_core_rw + me->arch.got_offset;
5911 for (i = 0; got[i].addr; i++)
5912 if (got[i].addr == value)
5913 goto out;
5914 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5915 #ifdef CONFIG_64BIT
5916 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5917 {
5918 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5919 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5920
5921 if (!value) {
5922 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5923 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5924
5925 /* Create new one */
5926 fdesc->addr = value;
5927 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5928 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5929 return (Elf_Addr)fdesc;
5930 }
5931 #endif /* CONFIG_64BIT */
5932 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5933
5934 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5935 end = table + sechdrs[me->arch.unwind_section].sh_size;
5936 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5937 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5938
5939 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5940 me->arch.unwind_section, table, end, gp);
5941 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5942 index 5dfd248..64914ac 100644
5943 --- a/arch/parisc/kernel/sys_parisc.c
5944 +++ b/arch/parisc/kernel/sys_parisc.c
5945 @@ -33,9 +33,11 @@
5946 #include <linux/utsname.h>
5947 #include <linux/personality.h>
5948
5949 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5950 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5951 + unsigned long flags)
5952 {
5953 struct vm_unmapped_area_info info;
5954 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5955
5956 info.flags = 0;
5957 info.length = len;
5958 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5959 info.high_limit = TASK_SIZE;
5960 info.align_mask = 0;
5961 info.align_offset = 0;
5962 + info.threadstack_offset = offset;
5963 return vm_unmapped_area(&info);
5964 }
5965
5966 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5967 return (unsigned long) mapping >> 8;
5968 }
5969
5970 -static unsigned long get_shared_area(struct address_space *mapping,
5971 - unsigned long addr, unsigned long len, unsigned long pgoff)
5972 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5973 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5974 {
5975 struct vm_unmapped_area_info info;
5976 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5977
5978 info.flags = 0;
5979 info.length = len;
5980 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5981 info.high_limit = TASK_SIZE;
5982 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5983 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5984 + info.threadstack_offset = offset;
5985 return vm_unmapped_area(&info);
5986 }
5987
5988 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5989 return -EINVAL;
5990 return addr;
5991 }
5992 - if (!addr)
5993 + if (!addr) {
5994 addr = TASK_UNMAPPED_BASE;
5995
5996 +#ifdef CONFIG_PAX_RANDMMAP
5997 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5998 + addr += current->mm->delta_mmap;
5999 +#endif
6000 +
6001 + }
6002 +
6003 if (filp) {
6004 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6005 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6006 } else if(flags & MAP_SHARED) {
6007 - addr = get_shared_area(NULL, addr, len, pgoff);
6008 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6009 } else {
6010 - addr = get_unshared_area(addr, len);
6011 + addr = get_unshared_area(filp, addr, len, flags);
6012 }
6013 return addr;
6014 }
6015 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6016 index 04e47c6..7a8faf6 100644
6017 --- a/arch/parisc/kernel/traps.c
6018 +++ b/arch/parisc/kernel/traps.c
6019 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6020
6021 down_read(&current->mm->mmap_sem);
6022 vma = find_vma(current->mm,regs->iaoq[0]);
6023 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6024 - && (vma->vm_flags & VM_EXEC)) {
6025 -
6026 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6027 fault_address = regs->iaoq[0];
6028 fault_space = regs->iasq[0];
6029
6030 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6031 index f247a34..dc0f219 100644
6032 --- a/arch/parisc/mm/fault.c
6033 +++ b/arch/parisc/mm/fault.c
6034 @@ -15,6 +15,7 @@
6035 #include <linux/sched.h>
6036 #include <linux/interrupt.h>
6037 #include <linux/module.h>
6038 +#include <linux/unistd.h>
6039
6040 #include <asm/uaccess.h>
6041 #include <asm/traps.h>
6042 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6043 static unsigned long
6044 parisc_acctyp(unsigned long code, unsigned int inst)
6045 {
6046 - if (code == 6 || code == 16)
6047 + if (code == 6 || code == 7 || code == 16)
6048 return VM_EXEC;
6049
6050 switch (inst & 0xf0000000) {
6051 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6052 }
6053 #endif
6054
6055 +#ifdef CONFIG_PAX_PAGEEXEC
6056 +/*
6057 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6058 + *
6059 + * returns 1 when task should be killed
6060 + * 2 when rt_sigreturn trampoline was detected
6061 + * 3 when unpatched PLT trampoline was detected
6062 + */
6063 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6064 +{
6065 +
6066 +#ifdef CONFIG_PAX_EMUPLT
6067 + int err;
6068 +
6069 + do { /* PaX: unpatched PLT emulation */
6070 + unsigned int bl, depwi;
6071 +
6072 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6073 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6074 +
6075 + if (err)
6076 + break;
6077 +
6078 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6079 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6080 +
6081 + err = get_user(ldw, (unsigned int *)addr);
6082 + err |= get_user(bv, (unsigned int *)(addr+4));
6083 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6084 +
6085 + if (err)
6086 + break;
6087 +
6088 + if (ldw == 0x0E801096U &&
6089 + bv == 0xEAC0C000U &&
6090 + ldw2 == 0x0E881095U)
6091 + {
6092 + unsigned int resolver, map;
6093 +
6094 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6095 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6096 + if (err)
6097 + break;
6098 +
6099 + regs->gr[20] = instruction_pointer(regs)+8;
6100 + regs->gr[21] = map;
6101 + regs->gr[22] = resolver;
6102 + regs->iaoq[0] = resolver | 3UL;
6103 + regs->iaoq[1] = regs->iaoq[0] + 4;
6104 + return 3;
6105 + }
6106 + }
6107 + } while (0);
6108 +#endif
6109 +
6110 +#ifdef CONFIG_PAX_EMUTRAMP
6111 +
6112 +#ifndef CONFIG_PAX_EMUSIGRT
6113 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6114 + return 1;
6115 +#endif
6116 +
6117 + do { /* PaX: rt_sigreturn emulation */
6118 + unsigned int ldi1, ldi2, bel, nop;
6119 +
6120 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6121 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6122 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6123 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6124 +
6125 + if (err)
6126 + break;
6127 +
6128 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6129 + ldi2 == 0x3414015AU &&
6130 + bel == 0xE4008200U &&
6131 + nop == 0x08000240U)
6132 + {
6133 + regs->gr[25] = (ldi1 & 2) >> 1;
6134 + regs->gr[20] = __NR_rt_sigreturn;
6135 + regs->gr[31] = regs->iaoq[1] + 16;
6136 + regs->sr[0] = regs->iasq[1];
6137 + regs->iaoq[0] = 0x100UL;
6138 + regs->iaoq[1] = regs->iaoq[0] + 4;
6139 + regs->iasq[0] = regs->sr[2];
6140 + regs->iasq[1] = regs->sr[2];
6141 + return 2;
6142 + }
6143 + } while (0);
6144 +#endif
6145 +
6146 + return 1;
6147 +}
6148 +
6149 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6150 +{
6151 + unsigned long i;
6152 +
6153 + printk(KERN_ERR "PAX: bytes at PC: ");
6154 + for (i = 0; i < 5; i++) {
6155 + unsigned int c;
6156 + if (get_user(c, (unsigned int *)pc+i))
6157 + printk(KERN_CONT "???????? ");
6158 + else
6159 + printk(KERN_CONT "%08x ", c);
6160 + }
6161 + printk("\n");
6162 +}
6163 +#endif
6164 +
6165 int fixup_exception(struct pt_regs *regs)
6166 {
6167 const struct exception_table_entry *fix;
6168 @@ -194,8 +305,33 @@ good_area:
6169
6170 acc_type = parisc_acctyp(code,regs->iir);
6171
6172 - if ((vma->vm_flags & acc_type) != acc_type)
6173 + if ((vma->vm_flags & acc_type) != acc_type) {
6174 +
6175 +#ifdef CONFIG_PAX_PAGEEXEC
6176 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6177 + (address & ~3UL) == instruction_pointer(regs))
6178 + {
6179 + up_read(&mm->mmap_sem);
6180 + switch (pax_handle_fetch_fault(regs)) {
6181 +
6182 +#ifdef CONFIG_PAX_EMUPLT
6183 + case 3:
6184 + return;
6185 +#endif
6186 +
6187 +#ifdef CONFIG_PAX_EMUTRAMP
6188 + case 2:
6189 + return;
6190 +#endif
6191 +
6192 + }
6193 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6194 + do_group_exit(SIGKILL);
6195 + }
6196 +#endif
6197 +
6198 goto bad_area;
6199 + }
6200
6201 /*
6202 * If for any reason at all we couldn't handle the fault, make
6203 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6204 index e3b1d41..8e81edf 100644
6205 --- a/arch/powerpc/include/asm/atomic.h
6206 +++ b/arch/powerpc/include/asm/atomic.h
6207 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6208 return t1;
6209 }
6210
6211 +#define atomic64_read_unchecked(v) atomic64_read(v)
6212 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6213 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6214 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6215 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6216 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6217 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6218 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6219 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6220 +
6221 #endif /* __powerpc64__ */
6222
6223 #endif /* __KERNEL__ */
6224 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6225 index 9e495c9..b6878e5 100644
6226 --- a/arch/powerpc/include/asm/cache.h
6227 +++ b/arch/powerpc/include/asm/cache.h
6228 @@ -3,6 +3,7 @@
6229
6230 #ifdef __KERNEL__
6231
6232 +#include <linux/const.h>
6233
6234 /* bytes per L1 cache line */
6235 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6236 @@ -22,7 +23,7 @@
6237 #define L1_CACHE_SHIFT 7
6238 #endif
6239
6240 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6241 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6242
6243 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6244
6245 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6246 index cc0655a..13eac2e 100644
6247 --- a/arch/powerpc/include/asm/elf.h
6248 +++ b/arch/powerpc/include/asm/elf.h
6249 @@ -28,8 +28,19 @@
6250 the loader. We need to make sure that it is out of the way of the program
6251 that it will "exec", and that there is sufficient room for the brk. */
6252
6253 -extern unsigned long randomize_et_dyn(unsigned long base);
6254 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6255 +#define ELF_ET_DYN_BASE (0x20000000)
6256 +
6257 +#ifdef CONFIG_PAX_ASLR
6258 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6259 +
6260 +#ifdef __powerpc64__
6261 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6262 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6263 +#else
6264 +#define PAX_DELTA_MMAP_LEN 15
6265 +#define PAX_DELTA_STACK_LEN 15
6266 +#endif
6267 +#endif
6268
6269 /*
6270 * Our registers are always unsigned longs, whether we're a 32 bit
6271 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6272 (0x7ff >> (PAGE_SHIFT - 12)) : \
6273 (0x3ffff >> (PAGE_SHIFT - 12)))
6274
6275 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6276 -#define arch_randomize_brk arch_randomize_brk
6277 -
6278 -
6279 #ifdef CONFIG_SPU_BASE
6280 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6281 #define NT_SPU 1
6282 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6283 index 8196e9c..d83a9f3 100644
6284 --- a/arch/powerpc/include/asm/exec.h
6285 +++ b/arch/powerpc/include/asm/exec.h
6286 @@ -4,6 +4,6 @@
6287 #ifndef _ASM_POWERPC_EXEC_H
6288 #define _ASM_POWERPC_EXEC_H
6289
6290 -extern unsigned long arch_align_stack(unsigned long sp);
6291 +#define arch_align_stack(x) ((x) & ~0xfUL)
6292
6293 #endif /* _ASM_POWERPC_EXEC_H */
6294 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6295 index 5acabbd..7ea14fa 100644
6296 --- a/arch/powerpc/include/asm/kmap_types.h
6297 +++ b/arch/powerpc/include/asm/kmap_types.h
6298 @@ -10,7 +10,7 @@
6299 * 2 of the License, or (at your option) any later version.
6300 */
6301
6302 -#define KM_TYPE_NR 16
6303 +#define KM_TYPE_NR 17
6304
6305 #endif /* __KERNEL__ */
6306 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6307 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6308 index 8565c25..2865190 100644
6309 --- a/arch/powerpc/include/asm/mman.h
6310 +++ b/arch/powerpc/include/asm/mman.h
6311 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6312 }
6313 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6314
6315 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6316 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6317 {
6318 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6319 }
6320 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6321 index 988c812..63c7d70 100644
6322 --- a/arch/powerpc/include/asm/page.h
6323 +++ b/arch/powerpc/include/asm/page.h
6324 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6325 * and needs to be executable. This means the whole heap ends
6326 * up being executable.
6327 */
6328 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6329 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6330 +#define VM_DATA_DEFAULT_FLAGS32 \
6331 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6332 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6333
6334 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6335 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6336 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6337 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6338 #endif
6339
6340 +#define ktla_ktva(addr) (addr)
6341 +#define ktva_ktla(addr) (addr)
6342 +
6343 #ifndef CONFIG_PPC_BOOK3S_64
6344 /*
6345 * Use the top bit of the higher-level page table entries to indicate whether
6346 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6347 index 88693ce..ac6f9ab 100644
6348 --- a/arch/powerpc/include/asm/page_64.h
6349 +++ b/arch/powerpc/include/asm/page_64.h
6350 @@ -153,15 +153,18 @@ do { \
6351 * stack by default, so in the absence of a PT_GNU_STACK program header
6352 * we turn execute permission off.
6353 */
6354 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6355 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6356 +#define VM_STACK_DEFAULT_FLAGS32 \
6357 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6358 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6359
6360 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6361 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6362
6363 +#ifndef CONFIG_PAX_PAGEEXEC
6364 #define VM_STACK_DEFAULT_FLAGS \
6365 (is_32bit_task() ? \
6366 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6367 +#endif
6368
6369 #include <asm-generic/getorder.h>
6370
6371 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6372 index b66ae72..4a378cd 100644
6373 --- a/arch/powerpc/include/asm/pgalloc-64.h
6374 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6375 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6376 #ifndef CONFIG_PPC_64K_PAGES
6377
6378 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6379 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6380
6381 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6382 {
6383 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6384 pud_set(pud, (unsigned long)pmd);
6385 }
6386
6387 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6388 +{
6389 + pud_populate(mm, pud, pmd);
6390 +}
6391 +
6392 #define pmd_populate(mm, pmd, pte_page) \
6393 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6394 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6395 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6396 #endif
6397
6398 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6399 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6400
6401 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6402 pte_t *pte)
6403 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6404 index 7aeb955..19f748e 100644
6405 --- a/arch/powerpc/include/asm/pgtable.h
6406 +++ b/arch/powerpc/include/asm/pgtable.h
6407 @@ -2,6 +2,7 @@
6408 #define _ASM_POWERPC_PGTABLE_H
6409 #ifdef __KERNEL__
6410
6411 +#include <linux/const.h>
6412 #ifndef __ASSEMBLY__
6413 #include <asm/processor.h> /* For TASK_SIZE */
6414 #include <asm/mmu.h>
6415 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6416 index 4aad413..85d86bf 100644
6417 --- a/arch/powerpc/include/asm/pte-hash32.h
6418 +++ b/arch/powerpc/include/asm/pte-hash32.h
6419 @@ -21,6 +21,7 @@
6420 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6421 #define _PAGE_USER 0x004 /* usermode access allowed */
6422 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6423 +#define _PAGE_EXEC _PAGE_GUARDED
6424 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6425 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6426 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6427 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6428 index 4a9e408..724aa59 100644
6429 --- a/arch/powerpc/include/asm/reg.h
6430 +++ b/arch/powerpc/include/asm/reg.h
6431 @@ -234,6 +234,7 @@
6432 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6433 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6434 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6435 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6436 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6437 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6438 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6439 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6440 index ffbaabe..eabe843 100644
6441 --- a/arch/powerpc/include/asm/smp.h
6442 +++ b/arch/powerpc/include/asm/smp.h
6443 @@ -50,7 +50,7 @@ struct smp_ops_t {
6444 int (*cpu_disable)(void);
6445 void (*cpu_die)(unsigned int nr);
6446 int (*cpu_bootable)(unsigned int nr);
6447 -};
6448 +} __no_const;
6449
6450 extern void smp_send_debugger_break(void);
6451 extern void start_secondary_resume(void);
6452 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6453 index ba7b197..d292e26 100644
6454 --- a/arch/powerpc/include/asm/thread_info.h
6455 +++ b/arch/powerpc/include/asm/thread_info.h
6456 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6457 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6458 TIF_NEED_RESCHED */
6459 #define TIF_32BIT 4 /* 32 bit binary */
6460 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6461 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6462 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6463 #define TIF_SINGLESTEP 8 /* singlestepping active */
6464 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6465 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6466 for stack store? */
6467 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6468 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6469 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6470 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6471
6472 /* as above, but as bit values */
6473 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6474 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6475 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6476 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6477 #define _TIF_NOHZ (1<<TIF_NOHZ)
6478 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6479 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6480 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6481 - _TIF_NOHZ)
6482 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6483
6484 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6485 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6486 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6487 index 4db4959..aba5c41 100644
6488 --- a/arch/powerpc/include/asm/uaccess.h
6489 +++ b/arch/powerpc/include/asm/uaccess.h
6490 @@ -318,52 +318,6 @@ do { \
6491 extern unsigned long __copy_tofrom_user(void __user *to,
6492 const void __user *from, unsigned long size);
6493
6494 -#ifndef __powerpc64__
6495 -
6496 -static inline unsigned long copy_from_user(void *to,
6497 - const void __user *from, unsigned long n)
6498 -{
6499 - unsigned long over;
6500 -
6501 - if (access_ok(VERIFY_READ, from, n))
6502 - return __copy_tofrom_user((__force void __user *)to, from, n);
6503 - if ((unsigned long)from < TASK_SIZE) {
6504 - over = (unsigned long)from + n - TASK_SIZE;
6505 - return __copy_tofrom_user((__force void __user *)to, from,
6506 - n - over) + over;
6507 - }
6508 - return n;
6509 -}
6510 -
6511 -static inline unsigned long copy_to_user(void __user *to,
6512 - const void *from, unsigned long n)
6513 -{
6514 - unsigned long over;
6515 -
6516 - if (access_ok(VERIFY_WRITE, to, n))
6517 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6518 - if ((unsigned long)to < TASK_SIZE) {
6519 - over = (unsigned long)to + n - TASK_SIZE;
6520 - return __copy_tofrom_user(to, (__force void __user *)from,
6521 - n - over) + over;
6522 - }
6523 - return n;
6524 -}
6525 -
6526 -#else /* __powerpc64__ */
6527 -
6528 -#define __copy_in_user(to, from, size) \
6529 - __copy_tofrom_user((to), (from), (size))
6530 -
6531 -extern unsigned long copy_from_user(void *to, const void __user *from,
6532 - unsigned long n);
6533 -extern unsigned long copy_to_user(void __user *to, const void *from,
6534 - unsigned long n);
6535 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6536 - unsigned long n);
6537 -
6538 -#endif /* __powerpc64__ */
6539 -
6540 static inline unsigned long __copy_from_user_inatomic(void *to,
6541 const void __user *from, unsigned long n)
6542 {
6543 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6544 if (ret == 0)
6545 return 0;
6546 }
6547 +
6548 + if (!__builtin_constant_p(n))
6549 + check_object_size(to, n, false);
6550 +
6551 return __copy_tofrom_user((__force void __user *)to, from, n);
6552 }
6553
6554 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6555 if (ret == 0)
6556 return 0;
6557 }
6558 +
6559 + if (!__builtin_constant_p(n))
6560 + check_object_size(from, n, true);
6561 +
6562 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6563 }
6564
6565 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6566 return __copy_to_user_inatomic(to, from, size);
6567 }
6568
6569 +#ifndef __powerpc64__
6570 +
6571 +static inline unsigned long __must_check copy_from_user(void *to,
6572 + const void __user *from, unsigned long n)
6573 +{
6574 + unsigned long over;
6575 +
6576 + if ((long)n < 0)
6577 + return n;
6578 +
6579 + if (access_ok(VERIFY_READ, from, n)) {
6580 + if (!__builtin_constant_p(n))
6581 + check_object_size(to, n, false);
6582 + return __copy_tofrom_user((__force void __user *)to, from, n);
6583 + }
6584 + if ((unsigned long)from < TASK_SIZE) {
6585 + over = (unsigned long)from + n - TASK_SIZE;
6586 + if (!__builtin_constant_p(n - over))
6587 + check_object_size(to, n - over, false);
6588 + return __copy_tofrom_user((__force void __user *)to, from,
6589 + n - over) + over;
6590 + }
6591 + return n;
6592 +}
6593 +
6594 +static inline unsigned long __must_check copy_to_user(void __user *to,
6595 + const void *from, unsigned long n)
6596 +{
6597 + unsigned long over;
6598 +
6599 + if ((long)n < 0)
6600 + return n;
6601 +
6602 + if (access_ok(VERIFY_WRITE, to, n)) {
6603 + if (!__builtin_constant_p(n))
6604 + check_object_size(from, n, true);
6605 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6606 + }
6607 + if ((unsigned long)to < TASK_SIZE) {
6608 + over = (unsigned long)to + n - TASK_SIZE;
6609 + if (!__builtin_constant_p(n))
6610 + check_object_size(from, n - over, true);
6611 + return __copy_tofrom_user(to, (__force void __user *)from,
6612 + n - over) + over;
6613 + }
6614 + return n;
6615 +}
6616 +
6617 +#else /* __powerpc64__ */
6618 +
6619 +#define __copy_in_user(to, from, size) \
6620 + __copy_tofrom_user((to), (from), (size))
6621 +
6622 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6623 +{
6624 + if ((long)n < 0 || n > INT_MAX)
6625 + return n;
6626 +
6627 + if (!__builtin_constant_p(n))
6628 + check_object_size(to, n, false);
6629 +
6630 + if (likely(access_ok(VERIFY_READ, from, n)))
6631 + n = __copy_from_user(to, from, n);
6632 + else
6633 + memset(to, 0, n);
6634 + return n;
6635 +}
6636 +
6637 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6638 +{
6639 + if ((long)n < 0 || n > INT_MAX)
6640 + return n;
6641 +
6642 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6643 + if (!__builtin_constant_p(n))
6644 + check_object_size(from, n, true);
6645 + n = __copy_to_user(to, from, n);
6646 + }
6647 + return n;
6648 +}
6649 +
6650 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6651 + unsigned long n);
6652 +
6653 +#endif /* __powerpc64__ */
6654 +
6655 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6656
6657 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6658 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6659 index 645170a..6cf0271 100644
6660 --- a/arch/powerpc/kernel/exceptions-64e.S
6661 +++ b/arch/powerpc/kernel/exceptions-64e.S
6662 @@ -757,6 +757,7 @@ storage_fault_common:
6663 std r14,_DAR(r1)
6664 std r15,_DSISR(r1)
6665 addi r3,r1,STACK_FRAME_OVERHEAD
6666 + bl .save_nvgprs
6667 mr r4,r14
6668 mr r5,r15
6669 ld r14,PACA_EXGEN+EX_R14(r13)
6670 @@ -765,8 +766,7 @@ storage_fault_common:
6671 cmpdi r3,0
6672 bne- 1f
6673 b .ret_from_except_lite
6674 -1: bl .save_nvgprs
6675 - mr r5,r3
6676 +1: mr r5,r3
6677 addi r3,r1,STACK_FRAME_OVERHEAD
6678 ld r4,_DAR(r1)
6679 bl .bad_page_fault
6680 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6681 index 40e4a17..5a84b37 100644
6682 --- a/arch/powerpc/kernel/exceptions-64s.S
6683 +++ b/arch/powerpc/kernel/exceptions-64s.S
6684 @@ -1362,10 +1362,10 @@ handle_page_fault:
6685 11: ld r4,_DAR(r1)
6686 ld r5,_DSISR(r1)
6687 addi r3,r1,STACK_FRAME_OVERHEAD
6688 + bl .save_nvgprs
6689 bl .do_page_fault
6690 cmpdi r3,0
6691 beq+ 12f
6692 - bl .save_nvgprs
6693 mr r5,r3
6694 addi r3,r1,STACK_FRAME_OVERHEAD
6695 lwz r4,_DAR(r1)
6696 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6697 index 2e3200c..72095ce 100644
6698 --- a/arch/powerpc/kernel/module_32.c
6699 +++ b/arch/powerpc/kernel/module_32.c
6700 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6701 me->arch.core_plt_section = i;
6702 }
6703 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6704 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6705 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6706 return -ENOEXEC;
6707 }
6708
6709 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6710
6711 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6712 /* Init, or core PLT? */
6713 - if (location >= mod->module_core
6714 - && location < mod->module_core + mod->core_size)
6715 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6716 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6717 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6718 - else
6719 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6720 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6721 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6722 + else {
6723 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6724 + return ~0UL;
6725 + }
6726
6727 /* Find this entry, or if that fails, the next avail. entry */
6728 while (entry->jump[0]) {
6729 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6730 index 076d124..6cb2cbf 100644
6731 --- a/arch/powerpc/kernel/process.c
6732 +++ b/arch/powerpc/kernel/process.c
6733 @@ -874,8 +874,8 @@ void show_regs(struct pt_regs * regs)
6734 * Lookup NIP late so we have the best change of getting the
6735 * above info out without failing
6736 */
6737 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6738 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6739 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6740 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6741 #endif
6742 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6743 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6744 @@ -1335,10 +1335,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6745 newsp = stack[0];
6746 ip = stack[STACK_FRAME_LR_SAVE];
6747 if (!firstframe || ip != lr) {
6748 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6749 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6750 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6751 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6752 - printk(" (%pS)",
6753 + printk(" (%pA)",
6754 (void *)current->ret_stack[curr_frame].ret);
6755 curr_frame--;
6756 }
6757 @@ -1358,7 +1358,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6758 struct pt_regs *regs = (struct pt_regs *)
6759 (sp + STACK_FRAME_OVERHEAD);
6760 lr = regs->link;
6761 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6762 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6763 regs->trap, (void *)regs->nip, (void *)lr);
6764 firstframe = 1;
6765 }
6766 @@ -1394,58 +1394,3 @@ void notrace __ppc64_runlatch_off(void)
6767 mtspr(SPRN_CTRLT, ctrl);
6768 }
6769 #endif /* CONFIG_PPC64 */
6770 -
6771 -unsigned long arch_align_stack(unsigned long sp)
6772 -{
6773 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6774 - sp -= get_random_int() & ~PAGE_MASK;
6775 - return sp & ~0xf;
6776 -}
6777 -
6778 -static inline unsigned long brk_rnd(void)
6779 -{
6780 - unsigned long rnd = 0;
6781 -
6782 - /* 8MB for 32bit, 1GB for 64bit */
6783 - if (is_32bit_task())
6784 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6785 - else
6786 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6787 -
6788 - return rnd << PAGE_SHIFT;
6789 -}
6790 -
6791 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6792 -{
6793 - unsigned long base = mm->brk;
6794 - unsigned long ret;
6795 -
6796 -#ifdef CONFIG_PPC_STD_MMU_64
6797 - /*
6798 - * If we are using 1TB segments and we are allowed to randomise
6799 - * the heap, we can put it above 1TB so it is backed by a 1TB
6800 - * segment. Otherwise the heap will be in the bottom 1TB
6801 - * which always uses 256MB segments and this may result in a
6802 - * performance penalty.
6803 - */
6804 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6805 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6806 -#endif
6807 -
6808 - ret = PAGE_ALIGN(base + brk_rnd());
6809 -
6810 - if (ret < mm->brk)
6811 - return mm->brk;
6812 -
6813 - return ret;
6814 -}
6815 -
6816 -unsigned long randomize_et_dyn(unsigned long base)
6817 -{
6818 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6819 -
6820 - if (ret < base)
6821 - return base;
6822 -
6823 - return ret;
6824 -}
6825 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6826 index 98c2fc1..b73a4ca 100644
6827 --- a/arch/powerpc/kernel/ptrace.c
6828 +++ b/arch/powerpc/kernel/ptrace.c
6829 @@ -1781,6 +1781,10 @@ long arch_ptrace(struct task_struct *child, long request,
6830 return ret;
6831 }
6832
6833 +#ifdef CONFIG_GRKERNSEC_SETXID
6834 +extern void gr_delayed_cred_worker(void);
6835 +#endif
6836 +
6837 /*
6838 * We must return the syscall number to actually look up in the table.
6839 * This can be -1L to skip running any syscall at all.
6840 @@ -1793,6 +1797,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6841
6842 secure_computing_strict(regs->gpr[0]);
6843
6844 +#ifdef CONFIG_GRKERNSEC_SETXID
6845 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6846 + gr_delayed_cred_worker();
6847 +#endif
6848 +
6849 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6850 tracehook_report_syscall_entry(regs))
6851 /*
6852 @@ -1827,6 +1836,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6853 {
6854 int step;
6855
6856 +#ifdef CONFIG_GRKERNSEC_SETXID
6857 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6858 + gr_delayed_cred_worker();
6859 +#endif
6860 +
6861 audit_syscall_exit(regs);
6862
6863 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6864 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6865 index 201385c..0f01828 100644
6866 --- a/arch/powerpc/kernel/signal_32.c
6867 +++ b/arch/powerpc/kernel/signal_32.c
6868 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6869 /* Save user registers on the stack */
6870 frame = &rt_sf->uc.uc_mcontext;
6871 addr = frame;
6872 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6873 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6874 sigret = 0;
6875 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6876 } else {
6877 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6878 index 3459473..2d40783 100644
6879 --- a/arch/powerpc/kernel/signal_64.c
6880 +++ b/arch/powerpc/kernel/signal_64.c
6881 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6882 #endif
6883
6884 /* Set up to return from userspace. */
6885 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6886 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6887 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6888 } else {
6889 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6890 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6891 index e68a845..8b140e6 100644
6892 --- a/arch/powerpc/kernel/sysfs.c
6893 +++ b/arch/powerpc/kernel/sysfs.c
6894 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6895 return NOTIFY_OK;
6896 }
6897
6898 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6899 +static struct notifier_block sysfs_cpu_nb = {
6900 .notifier_call = sysfs_cpu_notify,
6901 };
6902
6903 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6904 index c0e5caf..68e8305 100644
6905 --- a/arch/powerpc/kernel/traps.c
6906 +++ b/arch/powerpc/kernel/traps.c
6907 @@ -143,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6908 return flags;
6909 }
6910
6911 +extern void gr_handle_kernel_exploit(void);
6912 +
6913 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6914 int signr)
6915 {
6916 @@ -192,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6917 panic("Fatal exception in interrupt");
6918 if (panic_on_oops)
6919 panic("Fatal exception");
6920 +
6921 + gr_handle_kernel_exploit();
6922 +
6923 do_exit(signr);
6924 }
6925
6926 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6927 index d4f463a..8fb7431 100644
6928 --- a/arch/powerpc/kernel/vdso.c
6929 +++ b/arch/powerpc/kernel/vdso.c
6930 @@ -34,6 +34,7 @@
6931 #include <asm/firmware.h>
6932 #include <asm/vdso.h>
6933 #include <asm/vdso_datapage.h>
6934 +#include <asm/mman.h>
6935
6936 #include "setup.h"
6937
6938 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6939 vdso_base = VDSO32_MBASE;
6940 #endif
6941
6942 - current->mm->context.vdso_base = 0;
6943 + current->mm->context.vdso_base = ~0UL;
6944
6945 /* vDSO has a problem and was disabled, just don't "enable" it for the
6946 * process
6947 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6948 vdso_base = get_unmapped_area(NULL, vdso_base,
6949 (vdso_pages << PAGE_SHIFT) +
6950 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6951 - 0, 0);
6952 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6953 if (IS_ERR_VALUE(vdso_base)) {
6954 rc = vdso_base;
6955 goto fail_mmapsem;
6956 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6957 index 5eea6f3..5d10396 100644
6958 --- a/arch/powerpc/lib/usercopy_64.c
6959 +++ b/arch/powerpc/lib/usercopy_64.c
6960 @@ -9,22 +9,6 @@
6961 #include <linux/module.h>
6962 #include <asm/uaccess.h>
6963
6964 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6965 -{
6966 - if (likely(access_ok(VERIFY_READ, from, n)))
6967 - n = __copy_from_user(to, from, n);
6968 - else
6969 - memset(to, 0, n);
6970 - return n;
6971 -}
6972 -
6973 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6974 -{
6975 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6976 - n = __copy_to_user(to, from, n);
6977 - return n;
6978 -}
6979 -
6980 unsigned long copy_in_user(void __user *to, const void __user *from,
6981 unsigned long n)
6982 {
6983 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6984 return n;
6985 }
6986
6987 -EXPORT_SYMBOL(copy_from_user);
6988 -EXPORT_SYMBOL(copy_to_user);
6989 EXPORT_SYMBOL(copy_in_user);
6990
6991 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6992 index 8726779..a33c512 100644
6993 --- a/arch/powerpc/mm/fault.c
6994 +++ b/arch/powerpc/mm/fault.c
6995 @@ -33,6 +33,10 @@
6996 #include <linux/magic.h>
6997 #include <linux/ratelimit.h>
6998 #include <linux/context_tracking.h>
6999 +#include <linux/slab.h>
7000 +#include <linux/pagemap.h>
7001 +#include <linux/compiler.h>
7002 +#include <linux/unistd.h>
7003
7004 #include <asm/firmware.h>
7005 #include <asm/page.h>
7006 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7007 }
7008 #endif
7009
7010 +#ifdef CONFIG_PAX_PAGEEXEC
7011 +/*
7012 + * PaX: decide what to do with offenders (regs->nip = fault address)
7013 + *
7014 + * returns 1 when task should be killed
7015 + */
7016 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7017 +{
7018 + return 1;
7019 +}
7020 +
7021 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7022 +{
7023 + unsigned long i;
7024 +
7025 + printk(KERN_ERR "PAX: bytes at PC: ");
7026 + for (i = 0; i < 5; i++) {
7027 + unsigned int c;
7028 + if (get_user(c, (unsigned int __user *)pc+i))
7029 + printk(KERN_CONT "???????? ");
7030 + else
7031 + printk(KERN_CONT "%08x ", c);
7032 + }
7033 + printk("\n");
7034 +}
7035 +#endif
7036 +
7037 /*
7038 * Check whether the instruction at regs->nip is a store using
7039 * an update addressing form which will update r1.
7040 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7041 * indicate errors in DSISR but can validly be set in SRR1.
7042 */
7043 if (trap == 0x400)
7044 - error_code &= 0x48200000;
7045 + error_code &= 0x58200000;
7046 else
7047 is_write = error_code & DSISR_ISSTORE;
7048 #else
7049 @@ -371,7 +402,7 @@ good_area:
7050 * "undefined". Of those that can be set, this is the only
7051 * one which seems bad.
7052 */
7053 - if (error_code & 0x10000000)
7054 + if (error_code & DSISR_GUARDED)
7055 /* Guarded storage error. */
7056 goto bad_area;
7057 #endif /* CONFIG_8xx */
7058 @@ -386,7 +417,7 @@ good_area:
7059 * processors use the same I/D cache coherency mechanism
7060 * as embedded.
7061 */
7062 - if (error_code & DSISR_PROTFAULT)
7063 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7064 goto bad_area;
7065 #endif /* CONFIG_PPC_STD_MMU */
7066
7067 @@ -471,6 +502,23 @@ bad_area:
7068 bad_area_nosemaphore:
7069 /* User mode accesses cause a SIGSEGV */
7070 if (user_mode(regs)) {
7071 +
7072 +#ifdef CONFIG_PAX_PAGEEXEC
7073 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7074 +#ifdef CONFIG_PPC_STD_MMU
7075 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7076 +#else
7077 + if (is_exec && regs->nip == address) {
7078 +#endif
7079 + switch (pax_handle_fetch_fault(regs)) {
7080 + }
7081 +
7082 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7083 + do_group_exit(SIGKILL);
7084 + }
7085 + }
7086 +#endif
7087 +
7088 _exception(SIGSEGV, regs, code, address);
7089 goto bail;
7090 }
7091 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7092 index 67a42ed..cd463e0 100644
7093 --- a/arch/powerpc/mm/mmap_64.c
7094 +++ b/arch/powerpc/mm/mmap_64.c
7095 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7096 {
7097 unsigned long rnd = 0;
7098
7099 +#ifdef CONFIG_PAX_RANDMMAP
7100 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7101 +#endif
7102 +
7103 if (current->flags & PF_RANDOMIZE) {
7104 /* 8MB for 32bit, 1GB for 64bit */
7105 if (is_32bit_task())
7106 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7107 */
7108 if (mmap_is_legacy()) {
7109 mm->mmap_base = TASK_UNMAPPED_BASE;
7110 +
7111 +#ifdef CONFIG_PAX_RANDMMAP
7112 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7113 + mm->mmap_base += mm->delta_mmap;
7114 +#endif
7115 +
7116 mm->get_unmapped_area = arch_get_unmapped_area;
7117 mm->unmap_area = arch_unmap_area;
7118 } else {
7119 mm->mmap_base = mmap_base();
7120 +
7121 +#ifdef CONFIG_PAX_RANDMMAP
7122 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7123 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7124 +#endif
7125 +
7126 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7127 mm->unmap_area = arch_unmap_area_topdown;
7128 }
7129 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7130 index e779642..e5bb889 100644
7131 --- a/arch/powerpc/mm/mmu_context_nohash.c
7132 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7133 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7134 return NOTIFY_OK;
7135 }
7136
7137 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7138 +static struct notifier_block mmu_context_cpu_nb = {
7139 .notifier_call = mmu_context_cpu_notify,
7140 };
7141
7142 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7143 index 88c0425..717feb8 100644
7144 --- a/arch/powerpc/mm/numa.c
7145 +++ b/arch/powerpc/mm/numa.c
7146 @@ -919,7 +919,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7147 return ret;
7148 }
7149
7150 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7151 +static struct notifier_block ppc64_numa_nb = {
7152 .notifier_call = cpu_numa_callback,
7153 .priority = 1 /* Must run before sched domains notifier. */
7154 };
7155 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7156 index 3e99c14..f00953c 100644
7157 --- a/arch/powerpc/mm/slice.c
7158 +++ b/arch/powerpc/mm/slice.c
7159 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7160 if ((mm->task_size - len) < addr)
7161 return 0;
7162 vma = find_vma(mm, addr);
7163 - return (!vma || (addr + len) <= vma->vm_start);
7164 + return check_heap_stack_gap(vma, addr, len, 0);
7165 }
7166
7167 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7168 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7169 info.align_offset = 0;
7170
7171 addr = TASK_UNMAPPED_BASE;
7172 +
7173 +#ifdef CONFIG_PAX_RANDMMAP
7174 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7175 + addr += mm->delta_mmap;
7176 +#endif
7177 +
7178 while (addr < TASK_SIZE) {
7179 info.low_limit = addr;
7180 if (!slice_scan_available(addr, available, 1, &addr))
7181 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7182 if (fixed && addr > (mm->task_size - len))
7183 return -EINVAL;
7184
7185 +#ifdef CONFIG_PAX_RANDMMAP
7186 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7187 + addr = 0;
7188 +#endif
7189 +
7190 /* If hint, make sure it matches our alignment restrictions */
7191 if (!fixed && addr) {
7192 addr = _ALIGN_UP(addr, 1ul << pshift);
7193 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7194 index 9098692..3d54cd1 100644
7195 --- a/arch/powerpc/platforms/cell/spufs/file.c
7196 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7197 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7198 return VM_FAULT_NOPAGE;
7199 }
7200
7201 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7202 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7203 unsigned long address,
7204 - void *buf, int len, int write)
7205 + void *buf, size_t len, int write)
7206 {
7207 struct spu_context *ctx = vma->vm_file->private_data;
7208 unsigned long offset = address - vma->vm_start;
7209 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7210 index bdb738a..49c9f95 100644
7211 --- a/arch/powerpc/platforms/powermac/smp.c
7212 +++ b/arch/powerpc/platforms/powermac/smp.c
7213 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7214 return NOTIFY_OK;
7215 }
7216
7217 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7218 +static struct notifier_block smp_core99_cpu_nb = {
7219 .notifier_call = smp_core99_cpu_notify,
7220 };
7221 #endif /* CONFIG_HOTPLUG_CPU */
7222 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7223 index c797832..ce575c8 100644
7224 --- a/arch/s390/include/asm/atomic.h
7225 +++ b/arch/s390/include/asm/atomic.h
7226 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7227 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7228 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7229
7230 +#define atomic64_read_unchecked(v) atomic64_read(v)
7231 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7232 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7233 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7234 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7235 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7236 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7237 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7238 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7239 +
7240 #define smp_mb__before_atomic_dec() smp_mb()
7241 #define smp_mb__after_atomic_dec() smp_mb()
7242 #define smp_mb__before_atomic_inc() smp_mb()
7243 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7244 index 4d7ccac..d03d0ad 100644
7245 --- a/arch/s390/include/asm/cache.h
7246 +++ b/arch/s390/include/asm/cache.h
7247 @@ -9,8 +9,10 @@
7248 #ifndef __ARCH_S390_CACHE_H
7249 #define __ARCH_S390_CACHE_H
7250
7251 -#define L1_CACHE_BYTES 256
7252 +#include <linux/const.h>
7253 +
7254 #define L1_CACHE_SHIFT 8
7255 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7256 #define NET_SKB_PAD 32
7257
7258 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7259 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7260 index 78f4f87..598ce39 100644
7261 --- a/arch/s390/include/asm/elf.h
7262 +++ b/arch/s390/include/asm/elf.h
7263 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7264 the loader. We need to make sure that it is out of the way of the program
7265 that it will "exec", and that there is sufficient room for the brk. */
7266
7267 -extern unsigned long randomize_et_dyn(unsigned long base);
7268 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7269 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7270 +
7271 +#ifdef CONFIG_PAX_ASLR
7272 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7273 +
7274 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7275 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7276 +#endif
7277
7278 /* This yields a mask that user programs can use to figure out what
7279 instruction set this CPU supports. */
7280 @@ -222,9 +228,6 @@ struct linux_binprm;
7281 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7282 int arch_setup_additional_pages(struct linux_binprm *, int);
7283
7284 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7285 -#define arch_randomize_brk arch_randomize_brk
7286 -
7287 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7288
7289 #endif
7290 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7291 index c4a93d6..4d2a9b4 100644
7292 --- a/arch/s390/include/asm/exec.h
7293 +++ b/arch/s390/include/asm/exec.h
7294 @@ -7,6 +7,6 @@
7295 #ifndef __ASM_EXEC_H
7296 #define __ASM_EXEC_H
7297
7298 -extern unsigned long arch_align_stack(unsigned long sp);
7299 +#define arch_align_stack(x) ((x) & ~0xfUL)
7300
7301 #endif /* __ASM_EXEC_H */
7302 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7303 index 9c33ed4..e40cbef 100644
7304 --- a/arch/s390/include/asm/uaccess.h
7305 +++ b/arch/s390/include/asm/uaccess.h
7306 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7307 copy_to_user(void __user *to, const void *from, unsigned long n)
7308 {
7309 might_fault();
7310 +
7311 + if ((long)n < 0)
7312 + return n;
7313 +
7314 return __copy_to_user(to, from, n);
7315 }
7316
7317 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7318 static inline unsigned long __must_check
7319 __copy_from_user(void *to, const void __user *from, unsigned long n)
7320 {
7321 + if ((long)n < 0)
7322 + return n;
7323 +
7324 if (__builtin_constant_p(n) && (n <= 256))
7325 return uaccess.copy_from_user_small(n, from, to);
7326 else
7327 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7328 static inline unsigned long __must_check
7329 copy_from_user(void *to, const void __user *from, unsigned long n)
7330 {
7331 - unsigned int sz = __compiletime_object_size(to);
7332 + size_t sz = __compiletime_object_size(to);
7333
7334 might_fault();
7335 - if (unlikely(sz != -1 && sz < n)) {
7336 +
7337 + if ((long)n < 0)
7338 + return n;
7339 +
7340 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7341 copy_from_user_overflow();
7342 return n;
7343 }
7344 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7345 index 7845e15..59c4353 100644
7346 --- a/arch/s390/kernel/module.c
7347 +++ b/arch/s390/kernel/module.c
7348 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7349
7350 /* Increase core size by size of got & plt and set start
7351 offsets for got and plt. */
7352 - me->core_size = ALIGN(me->core_size, 4);
7353 - me->arch.got_offset = me->core_size;
7354 - me->core_size += me->arch.got_size;
7355 - me->arch.plt_offset = me->core_size;
7356 - me->core_size += me->arch.plt_size;
7357 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7358 + me->arch.got_offset = me->core_size_rw;
7359 + me->core_size_rw += me->arch.got_size;
7360 + me->arch.plt_offset = me->core_size_rx;
7361 + me->core_size_rx += me->arch.plt_size;
7362 return 0;
7363 }
7364
7365 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7366 if (info->got_initialized == 0) {
7367 Elf_Addr *gotent;
7368
7369 - gotent = me->module_core + me->arch.got_offset +
7370 + gotent = me->module_core_rw + me->arch.got_offset +
7371 info->got_offset;
7372 *gotent = val;
7373 info->got_initialized = 1;
7374 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7375 rc = apply_rela_bits(loc, val, 0, 64, 0);
7376 else if (r_type == R_390_GOTENT ||
7377 r_type == R_390_GOTPLTENT) {
7378 - val += (Elf_Addr) me->module_core - loc;
7379 + val += (Elf_Addr) me->module_core_rw - loc;
7380 rc = apply_rela_bits(loc, val, 1, 32, 1);
7381 }
7382 break;
7383 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7384 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7385 if (info->plt_initialized == 0) {
7386 unsigned int *ip;
7387 - ip = me->module_core + me->arch.plt_offset +
7388 + ip = me->module_core_rx + me->arch.plt_offset +
7389 info->plt_offset;
7390 #ifndef CONFIG_64BIT
7391 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7392 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7393 val - loc + 0xffffUL < 0x1ffffeUL) ||
7394 (r_type == R_390_PLT32DBL &&
7395 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7396 - val = (Elf_Addr) me->module_core +
7397 + val = (Elf_Addr) me->module_core_rx +
7398 me->arch.plt_offset +
7399 info->plt_offset;
7400 val += rela->r_addend - loc;
7401 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7402 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7403 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7404 val = val + rela->r_addend -
7405 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7406 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7407 if (r_type == R_390_GOTOFF16)
7408 rc = apply_rela_bits(loc, val, 0, 16, 0);
7409 else if (r_type == R_390_GOTOFF32)
7410 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7411 break;
7412 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7413 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7414 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7415 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7416 rela->r_addend - loc;
7417 if (r_type == R_390_GOTPC)
7418 rc = apply_rela_bits(loc, val, 1, 32, 0);
7419 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7420 index 2bc3edd..ab9d598 100644
7421 --- a/arch/s390/kernel/process.c
7422 +++ b/arch/s390/kernel/process.c
7423 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7424 }
7425 return 0;
7426 }
7427 -
7428 -unsigned long arch_align_stack(unsigned long sp)
7429 -{
7430 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7431 - sp -= get_random_int() & ~PAGE_MASK;
7432 - return sp & ~0xf;
7433 -}
7434 -
7435 -static inline unsigned long brk_rnd(void)
7436 -{
7437 - /* 8MB for 32bit, 1GB for 64bit */
7438 - if (is_32bit_task())
7439 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7440 - else
7441 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7442 -}
7443 -
7444 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7445 -{
7446 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7447 -
7448 - if (ret < mm->brk)
7449 - return mm->brk;
7450 - return ret;
7451 -}
7452 -
7453 -unsigned long randomize_et_dyn(unsigned long base)
7454 -{
7455 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7456 -
7457 - if (!(current->flags & PF_RANDOMIZE))
7458 - return base;
7459 - if (ret < base)
7460 - return base;
7461 - return ret;
7462 -}
7463 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7464 index 06bafec..2bca531 100644
7465 --- a/arch/s390/mm/mmap.c
7466 +++ b/arch/s390/mm/mmap.c
7467 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7468 */
7469 if (mmap_is_legacy()) {
7470 mm->mmap_base = TASK_UNMAPPED_BASE;
7471 +
7472 +#ifdef CONFIG_PAX_RANDMMAP
7473 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7474 + mm->mmap_base += mm->delta_mmap;
7475 +#endif
7476 +
7477 mm->get_unmapped_area = arch_get_unmapped_area;
7478 mm->unmap_area = arch_unmap_area;
7479 } else {
7480 mm->mmap_base = mmap_base();
7481 +
7482 +#ifdef CONFIG_PAX_RANDMMAP
7483 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7484 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7485 +#endif
7486 +
7487 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7488 mm->unmap_area = arch_unmap_area_topdown;
7489 }
7490 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7491 */
7492 if (mmap_is_legacy()) {
7493 mm->mmap_base = TASK_UNMAPPED_BASE;
7494 +
7495 +#ifdef CONFIG_PAX_RANDMMAP
7496 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7497 + mm->mmap_base += mm->delta_mmap;
7498 +#endif
7499 +
7500 mm->get_unmapped_area = s390_get_unmapped_area;
7501 mm->unmap_area = arch_unmap_area;
7502 } else {
7503 mm->mmap_base = mmap_base();
7504 +
7505 +#ifdef CONFIG_PAX_RANDMMAP
7506 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7507 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7508 +#endif
7509 +
7510 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7511 mm->unmap_area = arch_unmap_area_topdown;
7512 }
7513 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7514 index ae3d59f..f65f075 100644
7515 --- a/arch/score/include/asm/cache.h
7516 +++ b/arch/score/include/asm/cache.h
7517 @@ -1,7 +1,9 @@
7518 #ifndef _ASM_SCORE_CACHE_H
7519 #define _ASM_SCORE_CACHE_H
7520
7521 +#include <linux/const.h>
7522 +
7523 #define L1_CACHE_SHIFT 4
7524 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7525 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7526
7527 #endif /* _ASM_SCORE_CACHE_H */
7528 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7529 index f9f3cd5..58ff438 100644
7530 --- a/arch/score/include/asm/exec.h
7531 +++ b/arch/score/include/asm/exec.h
7532 @@ -1,6 +1,6 @@
7533 #ifndef _ASM_SCORE_EXEC_H
7534 #define _ASM_SCORE_EXEC_H
7535
7536 -extern unsigned long arch_align_stack(unsigned long sp);
7537 +#define arch_align_stack(x) (x)
7538
7539 #endif /* _ASM_SCORE_EXEC_H */
7540 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7541 index f4c6d02..e9355c3 100644
7542 --- a/arch/score/kernel/process.c
7543 +++ b/arch/score/kernel/process.c
7544 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7545
7546 return task_pt_regs(task)->cp0_epc;
7547 }
7548 -
7549 -unsigned long arch_align_stack(unsigned long sp)
7550 -{
7551 - return sp;
7552 -}
7553 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7554 index ef9e555..331bd29 100644
7555 --- a/arch/sh/include/asm/cache.h
7556 +++ b/arch/sh/include/asm/cache.h
7557 @@ -9,10 +9,11 @@
7558 #define __ASM_SH_CACHE_H
7559 #ifdef __KERNEL__
7560
7561 +#include <linux/const.h>
7562 #include <linux/init.h>
7563 #include <cpu/cache.h>
7564
7565 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7566 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7567
7568 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7569
7570 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7571 index 03f2b55..b0270327 100644
7572 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7573 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7574 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7575 return NOTIFY_OK;
7576 }
7577
7578 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7579 +static struct notifier_block shx3_cpu_notifier = {
7580 .notifier_call = shx3_cpu_callback,
7581 };
7582
7583 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7584 index 6777177..cb5e44f 100644
7585 --- a/arch/sh/mm/mmap.c
7586 +++ b/arch/sh/mm/mmap.c
7587 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7588 struct mm_struct *mm = current->mm;
7589 struct vm_area_struct *vma;
7590 int do_colour_align;
7591 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7592 struct vm_unmapped_area_info info;
7593
7594 if (flags & MAP_FIXED) {
7595 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7596 if (filp || (flags & MAP_SHARED))
7597 do_colour_align = 1;
7598
7599 +#ifdef CONFIG_PAX_RANDMMAP
7600 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7601 +#endif
7602 +
7603 if (addr) {
7604 if (do_colour_align)
7605 addr = COLOUR_ALIGN(addr, pgoff);
7606 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7607 addr = PAGE_ALIGN(addr);
7608
7609 vma = find_vma(mm, addr);
7610 - if (TASK_SIZE - len >= addr &&
7611 - (!vma || addr + len <= vma->vm_start))
7612 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7613 return addr;
7614 }
7615
7616 info.flags = 0;
7617 info.length = len;
7618 - info.low_limit = TASK_UNMAPPED_BASE;
7619 + info.low_limit = mm->mmap_base;
7620 info.high_limit = TASK_SIZE;
7621 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7622 info.align_offset = pgoff << PAGE_SHIFT;
7623 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7624 struct mm_struct *mm = current->mm;
7625 unsigned long addr = addr0;
7626 int do_colour_align;
7627 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7628 struct vm_unmapped_area_info info;
7629
7630 if (flags & MAP_FIXED) {
7631 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7632 if (filp || (flags & MAP_SHARED))
7633 do_colour_align = 1;
7634
7635 +#ifdef CONFIG_PAX_RANDMMAP
7636 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7637 +#endif
7638 +
7639 /* requesting a specific address */
7640 if (addr) {
7641 if (do_colour_align)
7642 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7643 addr = PAGE_ALIGN(addr);
7644
7645 vma = find_vma(mm, addr);
7646 - if (TASK_SIZE - len >= addr &&
7647 - (!vma || addr + len <= vma->vm_start))
7648 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7649 return addr;
7650 }
7651
7652 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7653 VM_BUG_ON(addr != -ENOMEM);
7654 info.flags = 0;
7655 info.low_limit = TASK_UNMAPPED_BASE;
7656 +
7657 +#ifdef CONFIG_PAX_RANDMMAP
7658 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7659 + info.low_limit += mm->delta_mmap;
7660 +#endif
7661 +
7662 info.high_limit = TASK_SIZE;
7663 addr = vm_unmapped_area(&info);
7664 }
7665 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7666 index be56a24..443328f 100644
7667 --- a/arch/sparc/include/asm/atomic_64.h
7668 +++ b/arch/sparc/include/asm/atomic_64.h
7669 @@ -14,18 +14,40 @@
7670 #define ATOMIC64_INIT(i) { (i) }
7671
7672 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7673 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7674 +{
7675 + return v->counter;
7676 +}
7677 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7678 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7679 +{
7680 + return v->counter;
7681 +}
7682
7683 #define atomic_set(v, i) (((v)->counter) = i)
7684 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7685 +{
7686 + v->counter = i;
7687 +}
7688 #define atomic64_set(v, i) (((v)->counter) = i)
7689 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7690 +{
7691 + v->counter = i;
7692 +}
7693
7694 extern void atomic_add(int, atomic_t *);
7695 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7696 extern void atomic64_add(long, atomic64_t *);
7697 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7698 extern void atomic_sub(int, atomic_t *);
7699 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7700 extern void atomic64_sub(long, atomic64_t *);
7701 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7702
7703 extern int atomic_add_ret(int, atomic_t *);
7704 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7705 extern long atomic64_add_ret(long, atomic64_t *);
7706 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7707 extern int atomic_sub_ret(int, atomic_t *);
7708 extern long atomic64_sub_ret(long, atomic64_t *);
7709
7710 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7711 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7712
7713 #define atomic_inc_return(v) atomic_add_ret(1, v)
7714 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7715 +{
7716 + return atomic_add_ret_unchecked(1, v);
7717 +}
7718 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7719 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7720 +{
7721 + return atomic64_add_ret_unchecked(1, v);
7722 +}
7723
7724 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7725 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7726
7727 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7728 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7729 +{
7730 + return atomic_add_ret_unchecked(i, v);
7731 +}
7732 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7733 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7734 +{
7735 + return atomic64_add_ret_unchecked(i, v);
7736 +}
7737
7738 /*
7739 * atomic_inc_and_test - increment and test
7740 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7741 * other cases.
7742 */
7743 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7744 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7745 +{
7746 + return atomic_inc_return_unchecked(v) == 0;
7747 +}
7748 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7749
7750 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7751 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7752 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7753
7754 #define atomic_inc(v) atomic_add(1, v)
7755 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7756 +{
7757 + atomic_add_unchecked(1, v);
7758 +}
7759 #define atomic64_inc(v) atomic64_add(1, v)
7760 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7761 +{
7762 + atomic64_add_unchecked(1, v);
7763 +}
7764
7765 #define atomic_dec(v) atomic_sub(1, v)
7766 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7767 +{
7768 + atomic_sub_unchecked(1, v);
7769 +}
7770 #define atomic64_dec(v) atomic64_sub(1, v)
7771 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7772 +{
7773 + atomic64_sub_unchecked(1, v);
7774 +}
7775
7776 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7777 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7778
7779 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7780 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7781 +{
7782 + return cmpxchg(&v->counter, old, new);
7783 +}
7784 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7785 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7786 +{
7787 + return xchg(&v->counter, new);
7788 +}
7789
7790 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7791 {
7792 - int c, old;
7793 + int c, old, new;
7794 c = atomic_read(v);
7795 for (;;) {
7796 - if (unlikely(c == (u)))
7797 + if (unlikely(c == u))
7798 break;
7799 - old = atomic_cmpxchg((v), c, c + (a));
7800 +
7801 + asm volatile("addcc %2, %0, %0\n"
7802 +
7803 +#ifdef CONFIG_PAX_REFCOUNT
7804 + "tvs %%icc, 6\n"
7805 +#endif
7806 +
7807 + : "=r" (new)
7808 + : "0" (c), "ir" (a)
7809 + : "cc");
7810 +
7811 + old = atomic_cmpxchg(v, c, new);
7812 if (likely(old == c))
7813 break;
7814 c = old;
7815 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7816 #define atomic64_cmpxchg(v, o, n) \
7817 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7818 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7819 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7820 +{
7821 + return xchg(&v->counter, new);
7822 +}
7823
7824 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7825 {
7826 - long c, old;
7827 + long c, old, new;
7828 c = atomic64_read(v);
7829 for (;;) {
7830 - if (unlikely(c == (u)))
7831 + if (unlikely(c == u))
7832 break;
7833 - old = atomic64_cmpxchg((v), c, c + (a));
7834 +
7835 + asm volatile("addcc %2, %0, %0\n"
7836 +
7837 +#ifdef CONFIG_PAX_REFCOUNT
7838 + "tvs %%xcc, 6\n"
7839 +#endif
7840 +
7841 + : "=r" (new)
7842 + : "0" (c), "ir" (a)
7843 + : "cc");
7844 +
7845 + old = atomic64_cmpxchg(v, c, new);
7846 if (likely(old == c))
7847 break;
7848 c = old;
7849 }
7850 - return c != (u);
7851 + return c != u;
7852 }
7853
7854 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7855 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7856 index 5bb6991..5c2132e 100644
7857 --- a/arch/sparc/include/asm/cache.h
7858 +++ b/arch/sparc/include/asm/cache.h
7859 @@ -7,10 +7,12 @@
7860 #ifndef _SPARC_CACHE_H
7861 #define _SPARC_CACHE_H
7862
7863 +#include <linux/const.h>
7864 +
7865 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7866
7867 #define L1_CACHE_SHIFT 5
7868 -#define L1_CACHE_BYTES 32
7869 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7870
7871 #ifdef CONFIG_SPARC32
7872 #define SMP_CACHE_BYTES_SHIFT 5
7873 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7874 index a24e41f..47677ff 100644
7875 --- a/arch/sparc/include/asm/elf_32.h
7876 +++ b/arch/sparc/include/asm/elf_32.h
7877 @@ -114,6 +114,13 @@ typedef struct {
7878
7879 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7880
7881 +#ifdef CONFIG_PAX_ASLR
7882 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7883 +
7884 +#define PAX_DELTA_MMAP_LEN 16
7885 +#define PAX_DELTA_STACK_LEN 16
7886 +#endif
7887 +
7888 /* This yields a mask that user programs can use to figure out what
7889 instruction set this cpu supports. This can NOT be done in userspace
7890 on Sparc. */
7891 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7892 index 370ca1e..d4f4a98 100644
7893 --- a/arch/sparc/include/asm/elf_64.h
7894 +++ b/arch/sparc/include/asm/elf_64.h
7895 @@ -189,6 +189,13 @@ typedef struct {
7896 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7897 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7898
7899 +#ifdef CONFIG_PAX_ASLR
7900 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7901 +
7902 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7903 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7904 +#endif
7905 +
7906 extern unsigned long sparc64_elf_hwcap;
7907 #define ELF_HWCAP sparc64_elf_hwcap
7908
7909 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7910 index 9b1c36d..209298b 100644
7911 --- a/arch/sparc/include/asm/pgalloc_32.h
7912 +++ b/arch/sparc/include/asm/pgalloc_32.h
7913 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7914 }
7915
7916 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7917 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7918
7919 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7920 unsigned long address)
7921 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7922 index bcfe063..b333142 100644
7923 --- a/arch/sparc/include/asm/pgalloc_64.h
7924 +++ b/arch/sparc/include/asm/pgalloc_64.h
7925 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7926 }
7927
7928 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7929 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7930
7931 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7932 {
7933 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7934 index 6fc1348..390c50a 100644
7935 --- a/arch/sparc/include/asm/pgtable_32.h
7936 +++ b/arch/sparc/include/asm/pgtable_32.h
7937 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7938 #define PAGE_SHARED SRMMU_PAGE_SHARED
7939 #define PAGE_COPY SRMMU_PAGE_COPY
7940 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7941 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7942 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7943 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7944 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7945
7946 /* Top-level page directory - dummy used by init-mm.
7947 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7948
7949 /* xwr */
7950 #define __P000 PAGE_NONE
7951 -#define __P001 PAGE_READONLY
7952 -#define __P010 PAGE_COPY
7953 -#define __P011 PAGE_COPY
7954 +#define __P001 PAGE_READONLY_NOEXEC
7955 +#define __P010 PAGE_COPY_NOEXEC
7956 +#define __P011 PAGE_COPY_NOEXEC
7957 #define __P100 PAGE_READONLY
7958 #define __P101 PAGE_READONLY
7959 #define __P110 PAGE_COPY
7960 #define __P111 PAGE_COPY
7961
7962 #define __S000 PAGE_NONE
7963 -#define __S001 PAGE_READONLY
7964 -#define __S010 PAGE_SHARED
7965 -#define __S011 PAGE_SHARED
7966 +#define __S001 PAGE_READONLY_NOEXEC
7967 +#define __S010 PAGE_SHARED_NOEXEC
7968 +#define __S011 PAGE_SHARED_NOEXEC
7969 #define __S100 PAGE_READONLY
7970 #define __S101 PAGE_READONLY
7971 #define __S110 PAGE_SHARED
7972 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7973 index 79da178..c2eede8 100644
7974 --- a/arch/sparc/include/asm/pgtsrmmu.h
7975 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7976 @@ -115,6 +115,11 @@
7977 SRMMU_EXEC | SRMMU_REF)
7978 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7979 SRMMU_EXEC | SRMMU_REF)
7980 +
7981 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7982 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7983 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7984 +
7985 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7986 SRMMU_DIRTY | SRMMU_REF)
7987
7988 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7989 index 9689176..63c18ea 100644
7990 --- a/arch/sparc/include/asm/spinlock_64.h
7991 +++ b/arch/sparc/include/asm/spinlock_64.h
7992 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7993
7994 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7995
7996 -static void inline arch_read_lock(arch_rwlock_t *lock)
7997 +static inline void arch_read_lock(arch_rwlock_t *lock)
7998 {
7999 unsigned long tmp1, tmp2;
8000
8001 __asm__ __volatile__ (
8002 "1: ldsw [%2], %0\n"
8003 " brlz,pn %0, 2f\n"
8004 -"4: add %0, 1, %1\n"
8005 +"4: addcc %0, 1, %1\n"
8006 +
8007 +#ifdef CONFIG_PAX_REFCOUNT
8008 +" tvs %%icc, 6\n"
8009 +#endif
8010 +
8011 " cas [%2], %0, %1\n"
8012 " cmp %0, %1\n"
8013 " bne,pn %%icc, 1b\n"
8014 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8015 " .previous"
8016 : "=&r" (tmp1), "=&r" (tmp2)
8017 : "r" (lock)
8018 - : "memory");
8019 + : "memory", "cc");
8020 }
8021
8022 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8023 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8024 {
8025 int tmp1, tmp2;
8026
8027 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8028 "1: ldsw [%2], %0\n"
8029 " brlz,a,pn %0, 2f\n"
8030 " mov 0, %0\n"
8031 -" add %0, 1, %1\n"
8032 +" addcc %0, 1, %1\n"
8033 +
8034 +#ifdef CONFIG_PAX_REFCOUNT
8035 +" tvs %%icc, 6\n"
8036 +#endif
8037 +
8038 " cas [%2], %0, %1\n"
8039 " cmp %0, %1\n"
8040 " bne,pn %%icc, 1b\n"
8041 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8042 return tmp1;
8043 }
8044
8045 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8046 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8047 {
8048 unsigned long tmp1, tmp2;
8049
8050 __asm__ __volatile__(
8051 "1: lduw [%2], %0\n"
8052 -" sub %0, 1, %1\n"
8053 +" subcc %0, 1, %1\n"
8054 +
8055 +#ifdef CONFIG_PAX_REFCOUNT
8056 +" tvs %%icc, 6\n"
8057 +#endif
8058 +
8059 " cas [%2], %0, %1\n"
8060 " cmp %0, %1\n"
8061 " bne,pn %%xcc, 1b\n"
8062 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8063 : "memory");
8064 }
8065
8066 -static void inline arch_write_lock(arch_rwlock_t *lock)
8067 +static inline void arch_write_lock(arch_rwlock_t *lock)
8068 {
8069 unsigned long mask, tmp1, tmp2;
8070
8071 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8072 : "memory");
8073 }
8074
8075 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8076 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8077 {
8078 __asm__ __volatile__(
8079 " stw %%g0, [%0]"
8080 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8081 : "memory");
8082 }
8083
8084 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8085 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8086 {
8087 unsigned long mask, tmp1, tmp2, result;
8088
8089 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8090 index dd38075..e7cac83 100644
8091 --- a/arch/sparc/include/asm/thread_info_32.h
8092 +++ b/arch/sparc/include/asm/thread_info_32.h
8093 @@ -49,6 +49,8 @@ struct thread_info {
8094 unsigned long w_saved;
8095
8096 struct restart_block restart_block;
8097 +
8098 + unsigned long lowest_stack;
8099 };
8100
8101 /*
8102 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8103 index d5e5042..9bfee76 100644
8104 --- a/arch/sparc/include/asm/thread_info_64.h
8105 +++ b/arch/sparc/include/asm/thread_info_64.h
8106 @@ -63,6 +63,8 @@ struct thread_info {
8107 struct pt_regs *kern_una_regs;
8108 unsigned int kern_una_insn;
8109
8110 + unsigned long lowest_stack;
8111 +
8112 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8113 };
8114
8115 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8116 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8117 /* flag bit 6 is available */
8118 #define TIF_32BIT 7 /* 32-bit binary */
8119 -/* flag bit 8 is available */
8120 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8121 #define TIF_SECCOMP 9 /* secure computing */
8122 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8123 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8124 +
8125 /* NOTE: Thread flags >= 12 should be ones we have no interest
8126 * in using in assembly, else we can't use the mask as
8127 * an immediate value in instructions such as andcc.
8128 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8129 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8130 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8131 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8132 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8133
8134 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8135 _TIF_DO_NOTIFY_RESUME_MASK | \
8136 _TIF_NEED_RESCHED)
8137 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8138
8139 +#define _TIF_WORK_SYSCALL \
8140 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8141 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8142 +
8143 +
8144 /*
8145 * Thread-synchronous status.
8146 *
8147 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8148 index 0167d26..767bb0c 100644
8149 --- a/arch/sparc/include/asm/uaccess.h
8150 +++ b/arch/sparc/include/asm/uaccess.h
8151 @@ -1,5 +1,6 @@
8152 #ifndef ___ASM_SPARC_UACCESS_H
8153 #define ___ASM_SPARC_UACCESS_H
8154 +
8155 #if defined(__sparc__) && defined(__arch64__)
8156 #include <asm/uaccess_64.h>
8157 #else
8158 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8159 index 53a28dd..50c38c3 100644
8160 --- a/arch/sparc/include/asm/uaccess_32.h
8161 +++ b/arch/sparc/include/asm/uaccess_32.h
8162 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8163
8164 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8165 {
8166 - if (n && __access_ok((unsigned long) to, n))
8167 + if ((long)n < 0)
8168 + return n;
8169 +
8170 + if (n && __access_ok((unsigned long) to, n)) {
8171 + if (!__builtin_constant_p(n))
8172 + check_object_size(from, n, true);
8173 return __copy_user(to, (__force void __user *) from, n);
8174 - else
8175 + } else
8176 return n;
8177 }
8178
8179 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8180 {
8181 + if ((long)n < 0)
8182 + return n;
8183 +
8184 + if (!__builtin_constant_p(n))
8185 + check_object_size(from, n, true);
8186 +
8187 return __copy_user(to, (__force void __user *) from, n);
8188 }
8189
8190 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8191 {
8192 - if (n && __access_ok((unsigned long) from, n))
8193 + if ((long)n < 0)
8194 + return n;
8195 +
8196 + if (n && __access_ok((unsigned long) from, n)) {
8197 + if (!__builtin_constant_p(n))
8198 + check_object_size(to, n, false);
8199 return __copy_user((__force void __user *) to, from, n);
8200 - else
8201 + } else
8202 return n;
8203 }
8204
8205 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8206 {
8207 + if ((long)n < 0)
8208 + return n;
8209 +
8210 return __copy_user((__force void __user *) to, from, n);
8211 }
8212
8213 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8214 index e562d3c..191f176 100644
8215 --- a/arch/sparc/include/asm/uaccess_64.h
8216 +++ b/arch/sparc/include/asm/uaccess_64.h
8217 @@ -10,6 +10,7 @@
8218 #include <linux/compiler.h>
8219 #include <linux/string.h>
8220 #include <linux/thread_info.h>
8221 +#include <linux/kernel.h>
8222 #include <asm/asi.h>
8223 #include <asm/spitfire.h>
8224 #include <asm-generic/uaccess-unaligned.h>
8225 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8226 static inline unsigned long __must_check
8227 copy_from_user(void *to, const void __user *from, unsigned long size)
8228 {
8229 - unsigned long ret = ___copy_from_user(to, from, size);
8230 + unsigned long ret;
8231
8232 + if ((long)size < 0 || size > INT_MAX)
8233 + return size;
8234 +
8235 + if (!__builtin_constant_p(size))
8236 + check_object_size(to, size, false);
8237 +
8238 + ret = ___copy_from_user(to, from, size);
8239 if (unlikely(ret))
8240 ret = copy_from_user_fixup(to, from, size);
8241
8242 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8243 static inline unsigned long __must_check
8244 copy_to_user(void __user *to, const void *from, unsigned long size)
8245 {
8246 - unsigned long ret = ___copy_to_user(to, from, size);
8247 + unsigned long ret;
8248
8249 + if ((long)size < 0 || size > INT_MAX)
8250 + return size;
8251 +
8252 + if (!__builtin_constant_p(size))
8253 + check_object_size(from, size, true);
8254 +
8255 + ret = ___copy_to_user(to, from, size);
8256 if (unlikely(ret))
8257 ret = copy_to_user_fixup(to, from, size);
8258 return ret;
8259 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8260 index d432fb2..6056af1 100644
8261 --- a/arch/sparc/kernel/Makefile
8262 +++ b/arch/sparc/kernel/Makefile
8263 @@ -3,7 +3,7 @@
8264 #
8265
8266 asflags-y := -ansi
8267 -ccflags-y := -Werror
8268 +#ccflags-y := -Werror
8269
8270 extra-y := head_$(BITS).o
8271
8272 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8273 index 5ef48da..11d460f 100644
8274 --- a/arch/sparc/kernel/ds.c
8275 +++ b/arch/sparc/kernel/ds.c
8276 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8277 char *base, *p;
8278 int msg_len, loops;
8279
8280 + if (strlen(var) + strlen(value) + 2 >
8281 + sizeof(pkt) - sizeof(pkt.header)) {
8282 + printk(KERN_ERR PFX
8283 + "contents length: %zu, which more than max: %lu,"
8284 + "so could not set (%s) variable to (%s).\n",
8285 + strlen(var) + strlen(value) + 2,
8286 + sizeof(pkt) - sizeof(pkt.header), var, value);
8287 + return;
8288 + }
8289 +
8290 memset(&pkt, 0, sizeof(pkt));
8291 pkt.header.data.tag.type = DS_DATA;
8292 pkt.header.data.handle = cp->handle;
8293 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8294 index fdd819d..5af08c8 100644
8295 --- a/arch/sparc/kernel/process_32.c
8296 +++ b/arch/sparc/kernel/process_32.c
8297 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8298
8299 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8300 r->psr, r->pc, r->npc, r->y, print_tainted());
8301 - printk("PC: <%pS>\n", (void *) r->pc);
8302 + printk("PC: <%pA>\n", (void *) r->pc);
8303 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8304 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8305 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8306 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8307 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8308 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8309 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8310 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8311
8312 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8313 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8314 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8315 rw = (struct reg_window32 *) fp;
8316 pc = rw->ins[7];
8317 printk("[%08lx : ", pc);
8318 - printk("%pS ] ", (void *) pc);
8319 + printk("%pA ] ", (void *) pc);
8320 fp = rw->ins[6];
8321 } while (++count < 16);
8322 printk("\n");
8323 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8324 index baebab2..9cd13b1 100644
8325 --- a/arch/sparc/kernel/process_64.c
8326 +++ b/arch/sparc/kernel/process_64.c
8327 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8328 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8329 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8330 if (regs->tstate & TSTATE_PRIV)
8331 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8332 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8333 }
8334
8335 void show_regs(struct pt_regs *regs)
8336 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8337
8338 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8339 regs->tpc, regs->tnpc, regs->y, print_tainted());
8340 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8341 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8342 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8343 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8344 regs->u_regs[3]);
8345 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8346 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8347 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8348 regs->u_regs[15]);
8349 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8350 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8351 show_regwindow(regs);
8352 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8353 }
8354 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8355 ((tp && tp->task) ? tp->task->pid : -1));
8356
8357 if (gp->tstate & TSTATE_PRIV) {
8358 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8359 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8360 (void *) gp->tpc,
8361 (void *) gp->o7,
8362 (void *) gp->i7,
8363 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8364 index 79cc0d1..ec62734 100644
8365 --- a/arch/sparc/kernel/prom_common.c
8366 +++ b/arch/sparc/kernel/prom_common.c
8367 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8368
8369 unsigned int prom_early_allocated __initdata;
8370
8371 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8372 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8373 .nextprop = prom_common_nextprop,
8374 .getproplen = prom_getproplen,
8375 .getproperty = prom_getproperty,
8376 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8377 index 7ff45e4..a58f271 100644
8378 --- a/arch/sparc/kernel/ptrace_64.c
8379 +++ b/arch/sparc/kernel/ptrace_64.c
8380 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8381 return ret;
8382 }
8383
8384 +#ifdef CONFIG_GRKERNSEC_SETXID
8385 +extern void gr_delayed_cred_worker(void);
8386 +#endif
8387 +
8388 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8389 {
8390 int ret = 0;
8391 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8392 /* do the secure computing check first */
8393 secure_computing_strict(regs->u_regs[UREG_G1]);
8394
8395 +#ifdef CONFIG_GRKERNSEC_SETXID
8396 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8397 + gr_delayed_cred_worker();
8398 +#endif
8399 +
8400 if (test_thread_flag(TIF_SYSCALL_TRACE))
8401 ret = tracehook_report_syscall_entry(regs);
8402
8403 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8404
8405 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8406 {
8407 +#ifdef CONFIG_GRKERNSEC_SETXID
8408 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8409 + gr_delayed_cred_worker();
8410 +#endif
8411 +
8412 audit_syscall_exit(regs);
8413
8414 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8415 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8416 index 3a8d184..49498a8 100644
8417 --- a/arch/sparc/kernel/sys_sparc_32.c
8418 +++ b/arch/sparc/kernel/sys_sparc_32.c
8419 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8420 if (len > TASK_SIZE - PAGE_SIZE)
8421 return -ENOMEM;
8422 if (!addr)
8423 - addr = TASK_UNMAPPED_BASE;
8424 + addr = current->mm->mmap_base;
8425
8426 info.flags = 0;
8427 info.length = len;
8428 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8429 index 2daaaa6..d29bb82 100644
8430 --- a/arch/sparc/kernel/sys_sparc_64.c
8431 +++ b/arch/sparc/kernel/sys_sparc_64.c
8432 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8433 struct vm_area_struct * vma;
8434 unsigned long task_size = TASK_SIZE;
8435 int do_color_align;
8436 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8437 struct vm_unmapped_area_info info;
8438
8439 if (flags & MAP_FIXED) {
8440 /* We do not accept a shared mapping if it would violate
8441 * cache aliasing constraints.
8442 */
8443 - if ((flags & MAP_SHARED) &&
8444 + if ((filp || (flags & MAP_SHARED)) &&
8445 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8446 return -EINVAL;
8447 return addr;
8448 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8449 if (filp || (flags & MAP_SHARED))
8450 do_color_align = 1;
8451
8452 +#ifdef CONFIG_PAX_RANDMMAP
8453 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8454 +#endif
8455 +
8456 if (addr) {
8457 if (do_color_align)
8458 addr = COLOR_ALIGN(addr, pgoff);
8459 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8460 addr = PAGE_ALIGN(addr);
8461
8462 vma = find_vma(mm, addr);
8463 - if (task_size - len >= addr &&
8464 - (!vma || addr + len <= vma->vm_start))
8465 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8466 return addr;
8467 }
8468
8469 info.flags = 0;
8470 info.length = len;
8471 - info.low_limit = TASK_UNMAPPED_BASE;
8472 + info.low_limit = mm->mmap_base;
8473 info.high_limit = min(task_size, VA_EXCLUDE_START);
8474 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8475 info.align_offset = pgoff << PAGE_SHIFT;
8476 + info.threadstack_offset = offset;
8477 addr = vm_unmapped_area(&info);
8478
8479 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8480 VM_BUG_ON(addr != -ENOMEM);
8481 info.low_limit = VA_EXCLUDE_END;
8482 +
8483 +#ifdef CONFIG_PAX_RANDMMAP
8484 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8485 + info.low_limit += mm->delta_mmap;
8486 +#endif
8487 +
8488 info.high_limit = task_size;
8489 addr = vm_unmapped_area(&info);
8490 }
8491 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8492 unsigned long task_size = STACK_TOP32;
8493 unsigned long addr = addr0;
8494 int do_color_align;
8495 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8496 struct vm_unmapped_area_info info;
8497
8498 /* This should only ever run for 32-bit processes. */
8499 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8500 /* We do not accept a shared mapping if it would violate
8501 * cache aliasing constraints.
8502 */
8503 - if ((flags & MAP_SHARED) &&
8504 + if ((filp || (flags & MAP_SHARED)) &&
8505 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8506 return -EINVAL;
8507 return addr;
8508 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8509 if (filp || (flags & MAP_SHARED))
8510 do_color_align = 1;
8511
8512 +#ifdef CONFIG_PAX_RANDMMAP
8513 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8514 +#endif
8515 +
8516 /* requesting a specific address */
8517 if (addr) {
8518 if (do_color_align)
8519 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8520 addr = PAGE_ALIGN(addr);
8521
8522 vma = find_vma(mm, addr);
8523 - if (task_size - len >= addr &&
8524 - (!vma || addr + len <= vma->vm_start))
8525 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8526 return addr;
8527 }
8528
8529 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8530 info.high_limit = mm->mmap_base;
8531 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8532 info.align_offset = pgoff << PAGE_SHIFT;
8533 + info.threadstack_offset = offset;
8534 addr = vm_unmapped_area(&info);
8535
8536 /*
8537 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8538 VM_BUG_ON(addr != -ENOMEM);
8539 info.flags = 0;
8540 info.low_limit = TASK_UNMAPPED_BASE;
8541 +
8542 +#ifdef CONFIG_PAX_RANDMMAP
8543 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8544 + info.low_limit += mm->delta_mmap;
8545 +#endif
8546 +
8547 info.high_limit = STACK_TOP32;
8548 addr = vm_unmapped_area(&info);
8549 }
8550 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8551 {
8552 unsigned long rnd = 0UL;
8553
8554 +#ifdef CONFIG_PAX_RANDMMAP
8555 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8556 +#endif
8557 +
8558 if (current->flags & PF_RANDOMIZE) {
8559 unsigned long val = get_random_int();
8560 if (test_thread_flag(TIF_32BIT))
8561 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8562 gap == RLIM_INFINITY ||
8563 sysctl_legacy_va_layout) {
8564 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8565 +
8566 +#ifdef CONFIG_PAX_RANDMMAP
8567 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8568 + mm->mmap_base += mm->delta_mmap;
8569 +#endif
8570 +
8571 mm->get_unmapped_area = arch_get_unmapped_area;
8572 mm->unmap_area = arch_unmap_area;
8573 } else {
8574 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8575 gap = (task_size / 6 * 5);
8576
8577 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8578 +
8579 +#ifdef CONFIG_PAX_RANDMMAP
8580 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8581 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8582 +#endif
8583 +
8584 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8585 mm->unmap_area = arch_unmap_area_topdown;
8586 }
8587 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8588 index 22a1098..6255eb9 100644
8589 --- a/arch/sparc/kernel/syscalls.S
8590 +++ b/arch/sparc/kernel/syscalls.S
8591 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8592 #endif
8593 .align 32
8594 1: ldx [%g6 + TI_FLAGS], %l5
8595 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8596 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8597 be,pt %icc, rtrap
8598 nop
8599 call syscall_trace_leave
8600 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8601
8602 srl %i5, 0, %o5 ! IEU1
8603 srl %i2, 0, %o2 ! IEU0 Group
8604 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8605 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8606 bne,pn %icc, linux_syscall_trace32 ! CTI
8607 mov %i0, %l5 ! IEU1
8608 call %l7 ! CTI Group brk forced
8609 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8610
8611 mov %i3, %o3 ! IEU1
8612 mov %i4, %o4 ! IEU0 Group
8613 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8614 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8615 bne,pn %icc, linux_syscall_trace ! CTI Group
8616 mov %i0, %l5 ! IEU0
8617 2: call %l7 ! CTI Group brk forced
8618 @@ -223,7 +223,7 @@ ret_sys_call:
8619
8620 cmp %o0, -ERESTART_RESTARTBLOCK
8621 bgeu,pn %xcc, 1f
8622 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8623 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8624 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8625
8626 2:
8627 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8628 index 654e8aa..45f431b 100644
8629 --- a/arch/sparc/kernel/sysfs.c
8630 +++ b/arch/sparc/kernel/sysfs.c
8631 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8632 return NOTIFY_OK;
8633 }
8634
8635 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8636 +static struct notifier_block sysfs_cpu_nb = {
8637 .notifier_call = sysfs_cpu_notify,
8638 };
8639
8640 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8641 index 6629829..036032d 100644
8642 --- a/arch/sparc/kernel/traps_32.c
8643 +++ b/arch/sparc/kernel/traps_32.c
8644 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8645 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8646 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8647
8648 +extern void gr_handle_kernel_exploit(void);
8649 +
8650 void die_if_kernel(char *str, struct pt_regs *regs)
8651 {
8652 static int die_counter;
8653 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8654 count++ < 30 &&
8655 (((unsigned long) rw) >= PAGE_OFFSET) &&
8656 !(((unsigned long) rw) & 0x7)) {
8657 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8658 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8659 (void *) rw->ins[7]);
8660 rw = (struct reg_window32 *)rw->ins[6];
8661 }
8662 }
8663 printk("Instruction DUMP:");
8664 instruction_dump ((unsigned long *) regs->pc);
8665 - if(regs->psr & PSR_PS)
8666 + if(regs->psr & PSR_PS) {
8667 + gr_handle_kernel_exploit();
8668 do_exit(SIGKILL);
8669 + }
8670 do_exit(SIGSEGV);
8671 }
8672
8673 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8674 index b3f833a..ac74b2d 100644
8675 --- a/arch/sparc/kernel/traps_64.c
8676 +++ b/arch/sparc/kernel/traps_64.c
8677 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8678 i + 1,
8679 p->trapstack[i].tstate, p->trapstack[i].tpc,
8680 p->trapstack[i].tnpc, p->trapstack[i].tt);
8681 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8682 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8683 }
8684 }
8685
8686 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8687
8688 lvl -= 0x100;
8689 if (regs->tstate & TSTATE_PRIV) {
8690 +
8691 +#ifdef CONFIG_PAX_REFCOUNT
8692 + if (lvl == 6)
8693 + pax_report_refcount_overflow(regs);
8694 +#endif
8695 +
8696 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8697 die_if_kernel(buffer, regs);
8698 }
8699 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8700 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8701 {
8702 char buffer[32];
8703 -
8704 +
8705 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8706 0, lvl, SIGTRAP) == NOTIFY_STOP)
8707 return;
8708
8709 +#ifdef CONFIG_PAX_REFCOUNT
8710 + if (lvl == 6)
8711 + pax_report_refcount_overflow(regs);
8712 +#endif
8713 +
8714 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8715
8716 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8717 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8718 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8719 printk("%s" "ERROR(%d): ",
8720 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8721 - printk("TPC<%pS>\n", (void *) regs->tpc);
8722 + printk("TPC<%pA>\n", (void *) regs->tpc);
8723 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8724 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8725 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8726 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8727 smp_processor_id(),
8728 (type & 0x1) ? 'I' : 'D',
8729 regs->tpc);
8730 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8731 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8732 panic("Irrecoverable Cheetah+ parity error.");
8733 }
8734
8735 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8736 smp_processor_id(),
8737 (type & 0x1) ? 'I' : 'D',
8738 regs->tpc);
8739 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8740 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8741 }
8742
8743 struct sun4v_error_entry {
8744 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8745
8746 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8747 regs->tpc, tl);
8748 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8749 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8750 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8751 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8752 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8753 (void *) regs->u_regs[UREG_I7]);
8754 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8755 "pte[%lx] error[%lx]\n",
8756 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8757
8758 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8759 regs->tpc, tl);
8760 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8761 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8762 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8763 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8764 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8765 (void *) regs->u_regs[UREG_I7]);
8766 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8767 "pte[%lx] error[%lx]\n",
8768 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8769 fp = (unsigned long)sf->fp + STACK_BIAS;
8770 }
8771
8772 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8773 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8774 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8775 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8776 int index = tsk->curr_ret_stack;
8777 if (tsk->ret_stack && index >= graph) {
8778 pc = tsk->ret_stack[index - graph].ret;
8779 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8780 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8781 graph++;
8782 }
8783 }
8784 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8785 return (struct reg_window *) (fp + STACK_BIAS);
8786 }
8787
8788 +extern void gr_handle_kernel_exploit(void);
8789 +
8790 void die_if_kernel(char *str, struct pt_regs *regs)
8791 {
8792 static int die_counter;
8793 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8794 while (rw &&
8795 count++ < 30 &&
8796 kstack_valid(tp, (unsigned long) rw)) {
8797 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8798 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8799 (void *) rw->ins[7]);
8800
8801 rw = kernel_stack_up(rw);
8802 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8803 }
8804 user_instruction_dump ((unsigned int __user *) regs->tpc);
8805 }
8806 - if (regs->tstate & TSTATE_PRIV)
8807 + if (regs->tstate & TSTATE_PRIV) {
8808 + gr_handle_kernel_exploit();
8809 do_exit(SIGKILL);
8810 + }
8811 do_exit(SIGSEGV);
8812 }
8813 EXPORT_SYMBOL(die_if_kernel);
8814 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8815 index 8201c25e..072a2a7 100644
8816 --- a/arch/sparc/kernel/unaligned_64.c
8817 +++ b/arch/sparc/kernel/unaligned_64.c
8818 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8819 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8820
8821 if (__ratelimit(&ratelimit)) {
8822 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8823 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8824 regs->tpc, (void *) regs->tpc);
8825 }
8826 }
8827 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8828 index dbe119b..089c7c1 100644
8829 --- a/arch/sparc/lib/Makefile
8830 +++ b/arch/sparc/lib/Makefile
8831 @@ -2,7 +2,7 @@
8832 #
8833
8834 asflags-y := -ansi -DST_DIV0=0x02
8835 -ccflags-y := -Werror
8836 +#ccflags-y := -Werror
8837
8838 lib-$(CONFIG_SPARC32) += ashrdi3.o
8839 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8840 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8841 index 85c233d..68500e0 100644
8842 --- a/arch/sparc/lib/atomic_64.S
8843 +++ b/arch/sparc/lib/atomic_64.S
8844 @@ -17,7 +17,12 @@
8845 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8846 BACKOFF_SETUP(%o2)
8847 1: lduw [%o1], %g1
8848 - add %g1, %o0, %g7
8849 + addcc %g1, %o0, %g7
8850 +
8851 +#ifdef CONFIG_PAX_REFCOUNT
8852 + tvs %icc, 6
8853 +#endif
8854 +
8855 cas [%o1], %g1, %g7
8856 cmp %g1, %g7
8857 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8858 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8859 2: BACKOFF_SPIN(%o2, %o3, 1b)
8860 ENDPROC(atomic_add)
8861
8862 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8863 + BACKOFF_SETUP(%o2)
8864 +1: lduw [%o1], %g1
8865 + add %g1, %o0, %g7
8866 + cas [%o1], %g1, %g7
8867 + cmp %g1, %g7
8868 + bne,pn %icc, 2f
8869 + nop
8870 + retl
8871 + nop
8872 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8873 +ENDPROC(atomic_add_unchecked)
8874 +
8875 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8876 BACKOFF_SETUP(%o2)
8877 1: lduw [%o1], %g1
8878 - sub %g1, %o0, %g7
8879 + subcc %g1, %o0, %g7
8880 +
8881 +#ifdef CONFIG_PAX_REFCOUNT
8882 + tvs %icc, 6
8883 +#endif
8884 +
8885 cas [%o1], %g1, %g7
8886 cmp %g1, %g7
8887 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8888 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8889 2: BACKOFF_SPIN(%o2, %o3, 1b)
8890 ENDPROC(atomic_sub)
8891
8892 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8893 + BACKOFF_SETUP(%o2)
8894 +1: lduw [%o1], %g1
8895 + sub %g1, %o0, %g7
8896 + cas [%o1], %g1, %g7
8897 + cmp %g1, %g7
8898 + bne,pn %icc, 2f
8899 + nop
8900 + retl
8901 + nop
8902 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8903 +ENDPROC(atomic_sub_unchecked)
8904 +
8905 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8906 BACKOFF_SETUP(%o2)
8907 1: lduw [%o1], %g1
8908 - add %g1, %o0, %g7
8909 + addcc %g1, %o0, %g7
8910 +
8911 +#ifdef CONFIG_PAX_REFCOUNT
8912 + tvs %icc, 6
8913 +#endif
8914 +
8915 cas [%o1], %g1, %g7
8916 cmp %g1, %g7
8917 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8918 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8919 2: BACKOFF_SPIN(%o2, %o3, 1b)
8920 ENDPROC(atomic_add_ret)
8921
8922 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8923 + BACKOFF_SETUP(%o2)
8924 +1: lduw [%o1], %g1
8925 + addcc %g1, %o0, %g7
8926 + cas [%o1], %g1, %g7
8927 + cmp %g1, %g7
8928 + bne,pn %icc, 2f
8929 + add %g7, %o0, %g7
8930 + sra %g7, 0, %o0
8931 + retl
8932 + nop
8933 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8934 +ENDPROC(atomic_add_ret_unchecked)
8935 +
8936 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8937 BACKOFF_SETUP(%o2)
8938 1: lduw [%o1], %g1
8939 - sub %g1, %o0, %g7
8940 + subcc %g1, %o0, %g7
8941 +
8942 +#ifdef CONFIG_PAX_REFCOUNT
8943 + tvs %icc, 6
8944 +#endif
8945 +
8946 cas [%o1], %g1, %g7
8947 cmp %g1, %g7
8948 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8949 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8950 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8951 BACKOFF_SETUP(%o2)
8952 1: ldx [%o1], %g1
8953 - add %g1, %o0, %g7
8954 + addcc %g1, %o0, %g7
8955 +
8956 +#ifdef CONFIG_PAX_REFCOUNT
8957 + tvs %xcc, 6
8958 +#endif
8959 +
8960 casx [%o1], %g1, %g7
8961 cmp %g1, %g7
8962 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8963 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8964 2: BACKOFF_SPIN(%o2, %o3, 1b)
8965 ENDPROC(atomic64_add)
8966
8967 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8968 + BACKOFF_SETUP(%o2)
8969 +1: ldx [%o1], %g1
8970 + addcc %g1, %o0, %g7
8971 + casx [%o1], %g1, %g7
8972 + cmp %g1, %g7
8973 + bne,pn %xcc, 2f
8974 + nop
8975 + retl
8976 + nop
8977 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8978 +ENDPROC(atomic64_add_unchecked)
8979 +
8980 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8981 BACKOFF_SETUP(%o2)
8982 1: ldx [%o1], %g1
8983 - sub %g1, %o0, %g7
8984 + subcc %g1, %o0, %g7
8985 +
8986 +#ifdef CONFIG_PAX_REFCOUNT
8987 + tvs %xcc, 6
8988 +#endif
8989 +
8990 casx [%o1], %g1, %g7
8991 cmp %g1, %g7
8992 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8993 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8994 2: BACKOFF_SPIN(%o2, %o3, 1b)
8995 ENDPROC(atomic64_sub)
8996
8997 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8998 + BACKOFF_SETUP(%o2)
8999 +1: ldx [%o1], %g1
9000 + subcc %g1, %o0, %g7
9001 + casx [%o1], %g1, %g7
9002 + cmp %g1, %g7
9003 + bne,pn %xcc, 2f
9004 + nop
9005 + retl
9006 + nop
9007 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9008 +ENDPROC(atomic64_sub_unchecked)
9009 +
9010 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9011 BACKOFF_SETUP(%o2)
9012 1: ldx [%o1], %g1
9013 - add %g1, %o0, %g7
9014 + addcc %g1, %o0, %g7
9015 +
9016 +#ifdef CONFIG_PAX_REFCOUNT
9017 + tvs %xcc, 6
9018 +#endif
9019 +
9020 casx [%o1], %g1, %g7
9021 cmp %g1, %g7
9022 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9023 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9024 2: BACKOFF_SPIN(%o2, %o3, 1b)
9025 ENDPROC(atomic64_add_ret)
9026
9027 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9028 + BACKOFF_SETUP(%o2)
9029 +1: ldx [%o1], %g1
9030 + addcc %g1, %o0, %g7
9031 + casx [%o1], %g1, %g7
9032 + cmp %g1, %g7
9033 + bne,pn %xcc, 2f
9034 + add %g7, %o0, %g7
9035 + mov %g7, %o0
9036 + retl
9037 + nop
9038 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9039 +ENDPROC(atomic64_add_ret_unchecked)
9040 +
9041 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9042 BACKOFF_SETUP(%o2)
9043 1: ldx [%o1], %g1
9044 - sub %g1, %o0, %g7
9045 + subcc %g1, %o0, %g7
9046 +
9047 +#ifdef CONFIG_PAX_REFCOUNT
9048 + tvs %xcc, 6
9049 +#endif
9050 +
9051 casx [%o1], %g1, %g7
9052 cmp %g1, %g7
9053 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9054 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9055 index 0c4e35e..745d3e4 100644
9056 --- a/arch/sparc/lib/ksyms.c
9057 +++ b/arch/sparc/lib/ksyms.c
9058 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9059
9060 /* Atomic counter implementation. */
9061 EXPORT_SYMBOL(atomic_add);
9062 +EXPORT_SYMBOL(atomic_add_unchecked);
9063 EXPORT_SYMBOL(atomic_add_ret);
9064 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9065 EXPORT_SYMBOL(atomic_sub);
9066 +EXPORT_SYMBOL(atomic_sub_unchecked);
9067 EXPORT_SYMBOL(atomic_sub_ret);
9068 EXPORT_SYMBOL(atomic64_add);
9069 +EXPORT_SYMBOL(atomic64_add_unchecked);
9070 EXPORT_SYMBOL(atomic64_add_ret);
9071 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9072 EXPORT_SYMBOL(atomic64_sub);
9073 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9074 EXPORT_SYMBOL(atomic64_sub_ret);
9075 EXPORT_SYMBOL(atomic64_dec_if_positive);
9076
9077 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9078 index 30c3ecc..736f015 100644
9079 --- a/arch/sparc/mm/Makefile
9080 +++ b/arch/sparc/mm/Makefile
9081 @@ -2,7 +2,7 @@
9082 #
9083
9084 asflags-y := -ansi
9085 -ccflags-y := -Werror
9086 +#ccflags-y := -Werror
9087
9088 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9089 obj-y += fault_$(BITS).o
9090 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9091 index e98bfda..ea8d221 100644
9092 --- a/arch/sparc/mm/fault_32.c
9093 +++ b/arch/sparc/mm/fault_32.c
9094 @@ -21,6 +21,9 @@
9095 #include <linux/perf_event.h>
9096 #include <linux/interrupt.h>
9097 #include <linux/kdebug.h>
9098 +#include <linux/slab.h>
9099 +#include <linux/pagemap.h>
9100 +#include <linux/compiler.h>
9101
9102 #include <asm/page.h>
9103 #include <asm/pgtable.h>
9104 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9105 return safe_compute_effective_address(regs, insn);
9106 }
9107
9108 +#ifdef CONFIG_PAX_PAGEEXEC
9109 +#ifdef CONFIG_PAX_DLRESOLVE
9110 +static void pax_emuplt_close(struct vm_area_struct *vma)
9111 +{
9112 + vma->vm_mm->call_dl_resolve = 0UL;
9113 +}
9114 +
9115 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9116 +{
9117 + unsigned int *kaddr;
9118 +
9119 + vmf->page = alloc_page(GFP_HIGHUSER);
9120 + if (!vmf->page)
9121 + return VM_FAULT_OOM;
9122 +
9123 + kaddr = kmap(vmf->page);
9124 + memset(kaddr, 0, PAGE_SIZE);
9125 + kaddr[0] = 0x9DE3BFA8U; /* save */
9126 + flush_dcache_page(vmf->page);
9127 + kunmap(vmf->page);
9128 + return VM_FAULT_MAJOR;
9129 +}
9130 +
9131 +static const struct vm_operations_struct pax_vm_ops = {
9132 + .close = pax_emuplt_close,
9133 + .fault = pax_emuplt_fault
9134 +};
9135 +
9136 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9137 +{
9138 + int ret;
9139 +
9140 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9141 + vma->vm_mm = current->mm;
9142 + vma->vm_start = addr;
9143 + vma->vm_end = addr + PAGE_SIZE;
9144 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9145 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9146 + vma->vm_ops = &pax_vm_ops;
9147 +
9148 + ret = insert_vm_struct(current->mm, vma);
9149 + if (ret)
9150 + return ret;
9151 +
9152 + ++current->mm->total_vm;
9153 + return 0;
9154 +}
9155 +#endif
9156 +
9157 +/*
9158 + * PaX: decide what to do with offenders (regs->pc = fault address)
9159 + *
9160 + * returns 1 when task should be killed
9161 + * 2 when patched PLT trampoline was detected
9162 + * 3 when unpatched PLT trampoline was detected
9163 + */
9164 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9165 +{
9166 +
9167 +#ifdef CONFIG_PAX_EMUPLT
9168 + int err;
9169 +
9170 + do { /* PaX: patched PLT emulation #1 */
9171 + unsigned int sethi1, sethi2, jmpl;
9172 +
9173 + err = get_user(sethi1, (unsigned int *)regs->pc);
9174 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9175 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9176 +
9177 + if (err)
9178 + break;
9179 +
9180 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9181 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9182 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9183 + {
9184 + unsigned int addr;
9185 +
9186 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9187 + addr = regs->u_regs[UREG_G1];
9188 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9189 + regs->pc = addr;
9190 + regs->npc = addr+4;
9191 + return 2;
9192 + }
9193 + } while (0);
9194 +
9195 + do { /* PaX: patched PLT emulation #2 */
9196 + unsigned int ba;
9197 +
9198 + err = get_user(ba, (unsigned int *)regs->pc);
9199 +
9200 + if (err)
9201 + break;
9202 +
9203 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9204 + unsigned int addr;
9205 +
9206 + if ((ba & 0xFFC00000U) == 0x30800000U)
9207 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9208 + else
9209 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9210 + regs->pc = addr;
9211 + regs->npc = addr+4;
9212 + return 2;
9213 + }
9214 + } while (0);
9215 +
9216 + do { /* PaX: patched PLT emulation #3 */
9217 + unsigned int sethi, bajmpl, nop;
9218 +
9219 + err = get_user(sethi, (unsigned int *)regs->pc);
9220 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9221 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9222 +
9223 + if (err)
9224 + break;
9225 +
9226 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9227 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9228 + nop == 0x01000000U)
9229 + {
9230 + unsigned int addr;
9231 +
9232 + addr = (sethi & 0x003FFFFFU) << 10;
9233 + regs->u_regs[UREG_G1] = addr;
9234 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9235 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9236 + else
9237 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9238 + regs->pc = addr;
9239 + regs->npc = addr+4;
9240 + return 2;
9241 + }
9242 + } while (0);
9243 +
9244 + do { /* PaX: unpatched PLT emulation step 1 */
9245 + unsigned int sethi, ba, nop;
9246 +
9247 + err = get_user(sethi, (unsigned int *)regs->pc);
9248 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9249 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9250 +
9251 + if (err)
9252 + break;
9253 +
9254 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9255 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9256 + nop == 0x01000000U)
9257 + {
9258 + unsigned int addr, save, call;
9259 +
9260 + if ((ba & 0xFFC00000U) == 0x30800000U)
9261 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9262 + else
9263 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9264 +
9265 + err = get_user(save, (unsigned int *)addr);
9266 + err |= get_user(call, (unsigned int *)(addr+4));
9267 + err |= get_user(nop, (unsigned int *)(addr+8));
9268 + if (err)
9269 + break;
9270 +
9271 +#ifdef CONFIG_PAX_DLRESOLVE
9272 + if (save == 0x9DE3BFA8U &&
9273 + (call & 0xC0000000U) == 0x40000000U &&
9274 + nop == 0x01000000U)
9275 + {
9276 + struct vm_area_struct *vma;
9277 + unsigned long call_dl_resolve;
9278 +
9279 + down_read(&current->mm->mmap_sem);
9280 + call_dl_resolve = current->mm->call_dl_resolve;
9281 + up_read(&current->mm->mmap_sem);
9282 + if (likely(call_dl_resolve))
9283 + goto emulate;
9284 +
9285 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9286 +
9287 + down_write(&current->mm->mmap_sem);
9288 + if (current->mm->call_dl_resolve) {
9289 + call_dl_resolve = current->mm->call_dl_resolve;
9290 + up_write(&current->mm->mmap_sem);
9291 + if (vma)
9292 + kmem_cache_free(vm_area_cachep, vma);
9293 + goto emulate;
9294 + }
9295 +
9296 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9297 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9298 + up_write(&current->mm->mmap_sem);
9299 + if (vma)
9300 + kmem_cache_free(vm_area_cachep, vma);
9301 + return 1;
9302 + }
9303 +
9304 + if (pax_insert_vma(vma, call_dl_resolve)) {
9305 + up_write(&current->mm->mmap_sem);
9306 + kmem_cache_free(vm_area_cachep, vma);
9307 + return 1;
9308 + }
9309 +
9310 + current->mm->call_dl_resolve = call_dl_resolve;
9311 + up_write(&current->mm->mmap_sem);
9312 +
9313 +emulate:
9314 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9315 + regs->pc = call_dl_resolve;
9316 + regs->npc = addr+4;
9317 + return 3;
9318 + }
9319 +#endif
9320 +
9321 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9322 + if ((save & 0xFFC00000U) == 0x05000000U &&
9323 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9324 + nop == 0x01000000U)
9325 + {
9326 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9327 + regs->u_regs[UREG_G2] = addr + 4;
9328 + addr = (save & 0x003FFFFFU) << 10;
9329 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9330 + regs->pc = addr;
9331 + regs->npc = addr+4;
9332 + return 3;
9333 + }
9334 + }
9335 + } while (0);
9336 +
9337 + do { /* PaX: unpatched PLT emulation step 2 */
9338 + unsigned int save, call, nop;
9339 +
9340 + err = get_user(save, (unsigned int *)(regs->pc-4));
9341 + err |= get_user(call, (unsigned int *)regs->pc);
9342 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9343 + if (err)
9344 + break;
9345 +
9346 + if (save == 0x9DE3BFA8U &&
9347 + (call & 0xC0000000U) == 0x40000000U &&
9348 + nop == 0x01000000U)
9349 + {
9350 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9351 +
9352 + regs->u_regs[UREG_RETPC] = regs->pc;
9353 + regs->pc = dl_resolve;
9354 + regs->npc = dl_resolve+4;
9355 + return 3;
9356 + }
9357 + } while (0);
9358 +#endif
9359 +
9360 + return 1;
9361 +}
9362 +
9363 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9364 +{
9365 + unsigned long i;
9366 +
9367 + printk(KERN_ERR "PAX: bytes at PC: ");
9368 + for (i = 0; i < 8; i++) {
9369 + unsigned int c;
9370 + if (get_user(c, (unsigned int *)pc+i))
9371 + printk(KERN_CONT "???????? ");
9372 + else
9373 + printk(KERN_CONT "%08x ", c);
9374 + }
9375 + printk("\n");
9376 +}
9377 +#endif
9378 +
9379 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9380 int text_fault)
9381 {
9382 @@ -230,6 +504,24 @@ good_area:
9383 if (!(vma->vm_flags & VM_WRITE))
9384 goto bad_area;
9385 } else {
9386 +
9387 +#ifdef CONFIG_PAX_PAGEEXEC
9388 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9389 + up_read(&mm->mmap_sem);
9390 + switch (pax_handle_fetch_fault(regs)) {
9391 +
9392 +#ifdef CONFIG_PAX_EMUPLT
9393 + case 2:
9394 + case 3:
9395 + return;
9396 +#endif
9397 +
9398 + }
9399 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9400 + do_group_exit(SIGKILL);
9401 + }
9402 +#endif
9403 +
9404 /* Allow reads even for write-only mappings */
9405 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9406 goto bad_area;
9407 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9408 index 5062ff3..e0b75f3 100644
9409 --- a/arch/sparc/mm/fault_64.c
9410 +++ b/arch/sparc/mm/fault_64.c
9411 @@ -21,6 +21,9 @@
9412 #include <linux/kprobes.h>
9413 #include <linux/kdebug.h>
9414 #include <linux/percpu.h>
9415 +#include <linux/slab.h>
9416 +#include <linux/pagemap.h>
9417 +#include <linux/compiler.h>
9418
9419 #include <asm/page.h>
9420 #include <asm/pgtable.h>
9421 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9422 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9423 regs->tpc);
9424 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9425 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9426 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9427 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9428 dump_stack();
9429 unhandled_fault(regs->tpc, current, regs);
9430 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9431 show_regs(regs);
9432 }
9433
9434 +#ifdef CONFIG_PAX_PAGEEXEC
9435 +#ifdef CONFIG_PAX_DLRESOLVE
9436 +static void pax_emuplt_close(struct vm_area_struct *vma)
9437 +{
9438 + vma->vm_mm->call_dl_resolve = 0UL;
9439 +}
9440 +
9441 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9442 +{
9443 + unsigned int *kaddr;
9444 +
9445 + vmf->page = alloc_page(GFP_HIGHUSER);
9446 + if (!vmf->page)
9447 + return VM_FAULT_OOM;
9448 +
9449 + kaddr = kmap(vmf->page);
9450 + memset(kaddr, 0, PAGE_SIZE);
9451 + kaddr[0] = 0x9DE3BFA8U; /* save */
9452 + flush_dcache_page(vmf->page);
9453 + kunmap(vmf->page);
9454 + return VM_FAULT_MAJOR;
9455 +}
9456 +
9457 +static const struct vm_operations_struct pax_vm_ops = {
9458 + .close = pax_emuplt_close,
9459 + .fault = pax_emuplt_fault
9460 +};
9461 +
9462 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9463 +{
9464 + int ret;
9465 +
9466 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9467 + vma->vm_mm = current->mm;
9468 + vma->vm_start = addr;
9469 + vma->vm_end = addr + PAGE_SIZE;
9470 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9471 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9472 + vma->vm_ops = &pax_vm_ops;
9473 +
9474 + ret = insert_vm_struct(current->mm, vma);
9475 + if (ret)
9476 + return ret;
9477 +
9478 + ++current->mm->total_vm;
9479 + return 0;
9480 +}
9481 +#endif
9482 +
9483 +/*
9484 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9485 + *
9486 + * returns 1 when task should be killed
9487 + * 2 when patched PLT trampoline was detected
9488 + * 3 when unpatched PLT trampoline was detected
9489 + */
9490 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9491 +{
9492 +
9493 +#ifdef CONFIG_PAX_EMUPLT
9494 + int err;
9495 +
9496 + do { /* PaX: patched PLT emulation #1 */
9497 + unsigned int sethi1, sethi2, jmpl;
9498 +
9499 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9500 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9501 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9502 +
9503 + if (err)
9504 + break;
9505 +
9506 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9507 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9508 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9509 + {
9510 + unsigned long addr;
9511 +
9512 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9513 + addr = regs->u_regs[UREG_G1];
9514 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9515 +
9516 + if (test_thread_flag(TIF_32BIT))
9517 + addr &= 0xFFFFFFFFUL;
9518 +
9519 + regs->tpc = addr;
9520 + regs->tnpc = addr+4;
9521 + return 2;
9522 + }
9523 + } while (0);
9524 +
9525 + do { /* PaX: patched PLT emulation #2 */
9526 + unsigned int ba;
9527 +
9528 + err = get_user(ba, (unsigned int *)regs->tpc);
9529 +
9530 + if (err)
9531 + break;
9532 +
9533 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9534 + unsigned long addr;
9535 +
9536 + if ((ba & 0xFFC00000U) == 0x30800000U)
9537 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9538 + else
9539 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9540 +
9541 + if (test_thread_flag(TIF_32BIT))
9542 + addr &= 0xFFFFFFFFUL;
9543 +
9544 + regs->tpc = addr;
9545 + regs->tnpc = addr+4;
9546 + return 2;
9547 + }
9548 + } while (0);
9549 +
9550 + do { /* PaX: patched PLT emulation #3 */
9551 + unsigned int sethi, bajmpl, nop;
9552 +
9553 + err = get_user(sethi, (unsigned int *)regs->tpc);
9554 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9555 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9556 +
9557 + if (err)
9558 + break;
9559 +
9560 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9561 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9562 + nop == 0x01000000U)
9563 + {
9564 + unsigned long addr;
9565 +
9566 + addr = (sethi & 0x003FFFFFU) << 10;
9567 + regs->u_regs[UREG_G1] = addr;
9568 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9569 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9570 + else
9571 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9572 +
9573 + if (test_thread_flag(TIF_32BIT))
9574 + addr &= 0xFFFFFFFFUL;
9575 +
9576 + regs->tpc = addr;
9577 + regs->tnpc = addr+4;
9578 + return 2;
9579 + }
9580 + } while (0);
9581 +
9582 + do { /* PaX: patched PLT emulation #4 */
9583 + unsigned int sethi, mov1, call, mov2;
9584 +
9585 + err = get_user(sethi, (unsigned int *)regs->tpc);
9586 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9587 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9588 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9589 +
9590 + if (err)
9591 + break;
9592 +
9593 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9594 + mov1 == 0x8210000FU &&
9595 + (call & 0xC0000000U) == 0x40000000U &&
9596 + mov2 == 0x9E100001U)
9597 + {
9598 + unsigned long addr;
9599 +
9600 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9601 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9602 +
9603 + if (test_thread_flag(TIF_32BIT))
9604 + addr &= 0xFFFFFFFFUL;
9605 +
9606 + regs->tpc = addr;
9607 + regs->tnpc = addr+4;
9608 + return 2;
9609 + }
9610 + } while (0);
9611 +
9612 + do { /* PaX: patched PLT emulation #5 */
9613 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9614 +
9615 + err = get_user(sethi, (unsigned int *)regs->tpc);
9616 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9617 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9618 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9619 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9620 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9621 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9622 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9623 +
9624 + if (err)
9625 + break;
9626 +
9627 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9628 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9629 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9630 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9631 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9632 + sllx == 0x83287020U &&
9633 + jmpl == 0x81C04005U &&
9634 + nop == 0x01000000U)
9635 + {
9636 + unsigned long addr;
9637 +
9638 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9639 + regs->u_regs[UREG_G1] <<= 32;
9640 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9641 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9642 + regs->tpc = addr;
9643 + regs->tnpc = addr+4;
9644 + return 2;
9645 + }
9646 + } while (0);
9647 +
9648 + do { /* PaX: patched PLT emulation #6 */
9649 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9650 +
9651 + err = get_user(sethi, (unsigned int *)regs->tpc);
9652 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9653 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9654 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9655 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9656 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9657 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9658 +
9659 + if (err)
9660 + break;
9661 +
9662 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9663 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9664 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9665 + sllx == 0x83287020U &&
9666 + (or & 0xFFFFE000U) == 0x8A116000U &&
9667 + jmpl == 0x81C04005U &&
9668 + nop == 0x01000000U)
9669 + {
9670 + unsigned long addr;
9671 +
9672 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9673 + regs->u_regs[UREG_G1] <<= 32;
9674 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9675 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9676 + regs->tpc = addr;
9677 + regs->tnpc = addr+4;
9678 + return 2;
9679 + }
9680 + } while (0);
9681 +
9682 + do { /* PaX: unpatched PLT emulation step 1 */
9683 + unsigned int sethi, ba, nop;
9684 +
9685 + err = get_user(sethi, (unsigned int *)regs->tpc);
9686 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9687 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9688 +
9689 + if (err)
9690 + break;
9691 +
9692 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9693 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9694 + nop == 0x01000000U)
9695 + {
9696 + unsigned long addr;
9697 + unsigned int save, call;
9698 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9699 +
9700 + if ((ba & 0xFFC00000U) == 0x30800000U)
9701 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9702 + else
9703 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9704 +
9705 + if (test_thread_flag(TIF_32BIT))
9706 + addr &= 0xFFFFFFFFUL;
9707 +
9708 + err = get_user(save, (unsigned int *)addr);
9709 + err |= get_user(call, (unsigned int *)(addr+4));
9710 + err |= get_user(nop, (unsigned int *)(addr+8));
9711 + if (err)
9712 + break;
9713 +
9714 +#ifdef CONFIG_PAX_DLRESOLVE
9715 + if (save == 0x9DE3BFA8U &&
9716 + (call & 0xC0000000U) == 0x40000000U &&
9717 + nop == 0x01000000U)
9718 + {
9719 + struct vm_area_struct *vma;
9720 + unsigned long call_dl_resolve;
9721 +
9722 + down_read(&current->mm->mmap_sem);
9723 + call_dl_resolve = current->mm->call_dl_resolve;
9724 + up_read(&current->mm->mmap_sem);
9725 + if (likely(call_dl_resolve))
9726 + goto emulate;
9727 +
9728 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9729 +
9730 + down_write(&current->mm->mmap_sem);
9731 + if (current->mm->call_dl_resolve) {
9732 + call_dl_resolve = current->mm->call_dl_resolve;
9733 + up_write(&current->mm->mmap_sem);
9734 + if (vma)
9735 + kmem_cache_free(vm_area_cachep, vma);
9736 + goto emulate;
9737 + }
9738 +
9739 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9740 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9741 + up_write(&current->mm->mmap_sem);
9742 + if (vma)
9743 + kmem_cache_free(vm_area_cachep, vma);
9744 + return 1;
9745 + }
9746 +
9747 + if (pax_insert_vma(vma, call_dl_resolve)) {
9748 + up_write(&current->mm->mmap_sem);
9749 + kmem_cache_free(vm_area_cachep, vma);
9750 + return 1;
9751 + }
9752 +
9753 + current->mm->call_dl_resolve = call_dl_resolve;
9754 + up_write(&current->mm->mmap_sem);
9755 +
9756 +emulate:
9757 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9758 + regs->tpc = call_dl_resolve;
9759 + regs->tnpc = addr+4;
9760 + return 3;
9761 + }
9762 +#endif
9763 +
9764 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9765 + if ((save & 0xFFC00000U) == 0x05000000U &&
9766 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9767 + nop == 0x01000000U)
9768 + {
9769 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9770 + regs->u_regs[UREG_G2] = addr + 4;
9771 + addr = (save & 0x003FFFFFU) << 10;
9772 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9773 +
9774 + if (test_thread_flag(TIF_32BIT))
9775 + addr &= 0xFFFFFFFFUL;
9776 +
9777 + regs->tpc = addr;
9778 + regs->tnpc = addr+4;
9779 + return 3;
9780 + }
9781 +
9782 + /* PaX: 64-bit PLT stub */
9783 + err = get_user(sethi1, (unsigned int *)addr);
9784 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9785 + err |= get_user(or1, (unsigned int *)(addr+8));
9786 + err |= get_user(or2, (unsigned int *)(addr+12));
9787 + err |= get_user(sllx, (unsigned int *)(addr+16));
9788 + err |= get_user(add, (unsigned int *)(addr+20));
9789 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9790 + err |= get_user(nop, (unsigned int *)(addr+28));
9791 + if (err)
9792 + break;
9793 +
9794 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9795 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9796 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9797 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9798 + sllx == 0x89293020U &&
9799 + add == 0x8A010005U &&
9800 + jmpl == 0x89C14000U &&
9801 + nop == 0x01000000U)
9802 + {
9803 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9804 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9805 + regs->u_regs[UREG_G4] <<= 32;
9806 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9807 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9808 + regs->u_regs[UREG_G4] = addr + 24;
9809 + addr = regs->u_regs[UREG_G5];
9810 + regs->tpc = addr;
9811 + regs->tnpc = addr+4;
9812 + return 3;
9813 + }
9814 + }
9815 + } while (0);
9816 +
9817 +#ifdef CONFIG_PAX_DLRESOLVE
9818 + do { /* PaX: unpatched PLT emulation step 2 */
9819 + unsigned int save, call, nop;
9820 +
9821 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9822 + err |= get_user(call, (unsigned int *)regs->tpc);
9823 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9824 + if (err)
9825 + break;
9826 +
9827 + if (save == 0x9DE3BFA8U &&
9828 + (call & 0xC0000000U) == 0x40000000U &&
9829 + nop == 0x01000000U)
9830 + {
9831 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9832 +
9833 + if (test_thread_flag(TIF_32BIT))
9834 + dl_resolve &= 0xFFFFFFFFUL;
9835 +
9836 + regs->u_regs[UREG_RETPC] = regs->tpc;
9837 + regs->tpc = dl_resolve;
9838 + regs->tnpc = dl_resolve+4;
9839 + return 3;
9840 + }
9841 + } while (0);
9842 +#endif
9843 +
9844 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9845 + unsigned int sethi, ba, nop;
9846 +
9847 + err = get_user(sethi, (unsigned int *)regs->tpc);
9848 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9849 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9850 +
9851 + if (err)
9852 + break;
9853 +
9854 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9855 + (ba & 0xFFF00000U) == 0x30600000U &&
9856 + nop == 0x01000000U)
9857 + {
9858 + unsigned long addr;
9859 +
9860 + addr = (sethi & 0x003FFFFFU) << 10;
9861 + regs->u_regs[UREG_G1] = addr;
9862 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9863 +
9864 + if (test_thread_flag(TIF_32BIT))
9865 + addr &= 0xFFFFFFFFUL;
9866 +
9867 + regs->tpc = addr;
9868 + regs->tnpc = addr+4;
9869 + return 2;
9870 + }
9871 + } while (0);
9872 +
9873 +#endif
9874 +
9875 + return 1;
9876 +}
9877 +
9878 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9879 +{
9880 + unsigned long i;
9881 +
9882 + printk(KERN_ERR "PAX: bytes at PC: ");
9883 + for (i = 0; i < 8; i++) {
9884 + unsigned int c;
9885 + if (get_user(c, (unsigned int *)pc+i))
9886 + printk(KERN_CONT "???????? ");
9887 + else
9888 + printk(KERN_CONT "%08x ", c);
9889 + }
9890 + printk("\n");
9891 +}
9892 +#endif
9893 +
9894 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9895 {
9896 struct mm_struct *mm = current->mm;
9897 @@ -341,6 +804,29 @@ retry:
9898 if (!vma)
9899 goto bad_area;
9900
9901 +#ifdef CONFIG_PAX_PAGEEXEC
9902 + /* PaX: detect ITLB misses on non-exec pages */
9903 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9904 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9905 + {
9906 + if (address != regs->tpc)
9907 + goto good_area;
9908 +
9909 + up_read(&mm->mmap_sem);
9910 + switch (pax_handle_fetch_fault(regs)) {
9911 +
9912 +#ifdef CONFIG_PAX_EMUPLT
9913 + case 2:
9914 + case 3:
9915 + return;
9916 +#endif
9917 +
9918 + }
9919 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9920 + do_group_exit(SIGKILL);
9921 + }
9922 +#endif
9923 +
9924 /* Pure DTLB misses do not tell us whether the fault causing
9925 * load/store/atomic was a write or not, it only says that there
9926 * was no match. So in such a case we (carefully) read the
9927 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9928 index d2b5944..bd813f2 100644
9929 --- a/arch/sparc/mm/hugetlbpage.c
9930 +++ b/arch/sparc/mm/hugetlbpage.c
9931 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9932
9933 info.flags = 0;
9934 info.length = len;
9935 - info.low_limit = TASK_UNMAPPED_BASE;
9936 + info.low_limit = mm->mmap_base;
9937 info.high_limit = min(task_size, VA_EXCLUDE_START);
9938 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9939 info.align_offset = 0;
9940 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9941 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9942 VM_BUG_ON(addr != -ENOMEM);
9943 info.low_limit = VA_EXCLUDE_END;
9944 +
9945 +#ifdef CONFIG_PAX_RANDMMAP
9946 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9947 + info.low_limit += mm->delta_mmap;
9948 +#endif
9949 +
9950 info.high_limit = task_size;
9951 addr = vm_unmapped_area(&info);
9952 }
9953 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9954 VM_BUG_ON(addr != -ENOMEM);
9955 info.flags = 0;
9956 info.low_limit = TASK_UNMAPPED_BASE;
9957 +
9958 +#ifdef CONFIG_PAX_RANDMMAP
9959 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9960 + info.low_limit += mm->delta_mmap;
9961 +#endif
9962 +
9963 info.high_limit = STACK_TOP32;
9964 addr = vm_unmapped_area(&info);
9965 }
9966 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9967 struct mm_struct *mm = current->mm;
9968 struct vm_area_struct *vma;
9969 unsigned long task_size = TASK_SIZE;
9970 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9971
9972 if (test_thread_flag(TIF_32BIT))
9973 task_size = STACK_TOP32;
9974 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9975 return addr;
9976 }
9977
9978 +#ifdef CONFIG_PAX_RANDMMAP
9979 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9980 +#endif
9981 +
9982 if (addr) {
9983 addr = ALIGN(addr, HPAGE_SIZE);
9984 vma = find_vma(mm, addr);
9985 - if (task_size - len >= addr &&
9986 - (!vma || addr + len <= vma->vm_start))
9987 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9988 return addr;
9989 }
9990 if (mm->get_unmapped_area == arch_get_unmapped_area)
9991 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
9992 index f4500c6..889656c 100644
9993 --- a/arch/tile/include/asm/atomic_64.h
9994 +++ b/arch/tile/include/asm/atomic_64.h
9995 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9996
9997 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9998
9999 +#define atomic64_read_unchecked(v) atomic64_read(v)
10000 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10001 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10002 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10003 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10004 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10005 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10006 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10007 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10008 +
10009 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10010 #define smp_mb__before_atomic_dec() smp_mb()
10011 #define smp_mb__after_atomic_dec() smp_mb()
10012 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10013 index a9a5299..0fce79e 100644
10014 --- a/arch/tile/include/asm/cache.h
10015 +++ b/arch/tile/include/asm/cache.h
10016 @@ -15,11 +15,12 @@
10017 #ifndef _ASM_TILE_CACHE_H
10018 #define _ASM_TILE_CACHE_H
10019
10020 +#include <linux/const.h>
10021 #include <arch/chip.h>
10022
10023 /* bytes per L1 data cache line */
10024 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10025 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10026 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10027
10028 /* bytes per L2 cache line */
10029 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10030 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10031 index 8a082bc..7a6bf87 100644
10032 --- a/arch/tile/include/asm/uaccess.h
10033 +++ b/arch/tile/include/asm/uaccess.h
10034 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10035 const void __user *from,
10036 unsigned long n)
10037 {
10038 - int sz = __compiletime_object_size(to);
10039 + size_t sz = __compiletime_object_size(to);
10040
10041 - if (likely(sz == -1 || sz >= n))
10042 + if (likely(sz == (size_t)-1 || sz >= n))
10043 n = _copy_from_user(to, from, n);
10044 else
10045 copy_from_user_overflow();
10046 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10047 index 650ccff..45fe2d6 100644
10048 --- a/arch/tile/mm/hugetlbpage.c
10049 +++ b/arch/tile/mm/hugetlbpage.c
10050 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10051 info.high_limit = TASK_SIZE;
10052 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10053 info.align_offset = 0;
10054 + info.threadstack_offset = 0;
10055 return vm_unmapped_area(&info);
10056 }
10057
10058 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10059 info.high_limit = current->mm->mmap_base;
10060 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10061 info.align_offset = 0;
10062 + info.threadstack_offset = 0;
10063 addr = vm_unmapped_area(&info);
10064
10065 /*
10066 diff --git a/arch/um/Makefile b/arch/um/Makefile
10067 index 133f7de..1d6f2f1 100644
10068 --- a/arch/um/Makefile
10069 +++ b/arch/um/Makefile
10070 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10071 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10072 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10073
10074 +ifdef CONSTIFY_PLUGIN
10075 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10076 +endif
10077 +
10078 #This will adjust *FLAGS accordingly to the platform.
10079 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10080
10081 diff --git a/arch/um/defconfig b/arch/um/defconfig
10082 index 08107a7..ab22afe 100644
10083 --- a/arch/um/defconfig
10084 +++ b/arch/um/defconfig
10085 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10086 CONFIG_X86_L1_CACHE_SHIFT=5
10087 CONFIG_X86_XADD=y
10088 CONFIG_X86_PPRO_FENCE=y
10089 -CONFIG_X86_WP_WORKS_OK=y
10090 CONFIG_X86_INVLPG=y
10091 CONFIG_X86_BSWAP=y
10092 CONFIG_X86_POPAD_OK=y
10093 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10094 index 19e1bdd..3665b77 100644
10095 --- a/arch/um/include/asm/cache.h
10096 +++ b/arch/um/include/asm/cache.h
10097 @@ -1,6 +1,7 @@
10098 #ifndef __UM_CACHE_H
10099 #define __UM_CACHE_H
10100
10101 +#include <linux/const.h>
10102
10103 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10104 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10105 @@ -12,6 +13,6 @@
10106 # define L1_CACHE_SHIFT 5
10107 #endif
10108
10109 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10110 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10111
10112 #endif
10113 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10114 index 2e0a6b1..a64d0f5 100644
10115 --- a/arch/um/include/asm/kmap_types.h
10116 +++ b/arch/um/include/asm/kmap_types.h
10117 @@ -8,6 +8,6 @@
10118
10119 /* No more #include "asm/arch/kmap_types.h" ! */
10120
10121 -#define KM_TYPE_NR 14
10122 +#define KM_TYPE_NR 15
10123
10124 #endif
10125 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10126 index 5ff53d9..5850cdf 100644
10127 --- a/arch/um/include/asm/page.h
10128 +++ b/arch/um/include/asm/page.h
10129 @@ -14,6 +14,9 @@
10130 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10131 #define PAGE_MASK (~(PAGE_SIZE-1))
10132
10133 +#define ktla_ktva(addr) (addr)
10134 +#define ktva_ktla(addr) (addr)
10135 +
10136 #ifndef __ASSEMBLY__
10137
10138 struct page;
10139 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10140 index 0032f92..cd151e0 100644
10141 --- a/arch/um/include/asm/pgtable-3level.h
10142 +++ b/arch/um/include/asm/pgtable-3level.h
10143 @@ -58,6 +58,7 @@
10144 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10145 #define pud_populate(mm, pud, pmd) \
10146 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10147 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10148
10149 #ifdef CONFIG_64BIT
10150 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10151 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10152 index bbcef52..6a2a483 100644
10153 --- a/arch/um/kernel/process.c
10154 +++ b/arch/um/kernel/process.c
10155 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10156 return 2;
10157 }
10158
10159 -/*
10160 - * Only x86 and x86_64 have an arch_align_stack().
10161 - * All other arches have "#define arch_align_stack(x) (x)"
10162 - * in their asm/system.h
10163 - * As this is included in UML from asm-um/system-generic.h,
10164 - * we can use it to behave as the subarch does.
10165 - */
10166 -#ifndef arch_align_stack
10167 -unsigned long arch_align_stack(unsigned long sp)
10168 -{
10169 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10170 - sp -= get_random_int() % 8192;
10171 - return sp & ~0xf;
10172 -}
10173 -#endif
10174 -
10175 unsigned long get_wchan(struct task_struct *p)
10176 {
10177 unsigned long stack_page, sp, ip;
10178 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10179 index ad8f795..2c7eec6 100644
10180 --- a/arch/unicore32/include/asm/cache.h
10181 +++ b/arch/unicore32/include/asm/cache.h
10182 @@ -12,8 +12,10 @@
10183 #ifndef __UNICORE_CACHE_H__
10184 #define __UNICORE_CACHE_H__
10185
10186 -#define L1_CACHE_SHIFT (5)
10187 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10188 +#include <linux/const.h>
10189 +
10190 +#define L1_CACHE_SHIFT 5
10191 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10192
10193 /*
10194 * Memory returned by kmalloc() may be used for DMA, so we must make
10195 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10196 index fe120da..24177f7 100644
10197 --- a/arch/x86/Kconfig
10198 +++ b/arch/x86/Kconfig
10199 @@ -239,7 +239,7 @@ config X86_HT
10200
10201 config X86_32_LAZY_GS
10202 def_bool y
10203 - depends on X86_32 && !CC_STACKPROTECTOR
10204 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10205
10206 config ARCH_HWEIGHT_CFLAGS
10207 string
10208 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10209
10210 config X86_MSR
10211 tristate "/dev/cpu/*/msr - Model-specific register support"
10212 + depends on !GRKERNSEC_KMEM
10213 ---help---
10214 This device gives privileged processes access to the x86
10215 Model-Specific Registers (MSRs). It is a character device with
10216 @@ -1096,7 +1097,7 @@ choice
10217
10218 config NOHIGHMEM
10219 bool "off"
10220 - depends on !X86_NUMAQ
10221 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10222 ---help---
10223 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10224 However, the address space of 32-bit x86 processors is only 4
10225 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10226
10227 config HIGHMEM4G
10228 bool "4GB"
10229 - depends on !X86_NUMAQ
10230 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10231 ---help---
10232 Select this if you have a 32-bit processor and between 1 and 4
10233 gigabytes of physical RAM.
10234 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10235 hex
10236 default 0xB0000000 if VMSPLIT_3G_OPT
10237 default 0x80000000 if VMSPLIT_2G
10238 - default 0x78000000 if VMSPLIT_2G_OPT
10239 + default 0x70000000 if VMSPLIT_2G_OPT
10240 default 0x40000000 if VMSPLIT_1G
10241 default 0xC0000000
10242 depends on X86_32
10243 @@ -1584,6 +1585,7 @@ config SECCOMP
10244
10245 config CC_STACKPROTECTOR
10246 bool "Enable -fstack-protector buffer overflow detection"
10247 + depends on X86_64 || !PAX_MEMORY_UDEREF
10248 ---help---
10249 This option turns on the -fstack-protector GCC feature. This
10250 feature puts, at the beginning of functions, a canary value on
10251 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10252 config PHYSICAL_ALIGN
10253 hex "Alignment value to which kernel should be aligned" if X86_32
10254 default "0x1000000"
10255 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10256 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10257 range 0x2000 0x1000000
10258 ---help---
10259 This value puts the alignment restrictions on physical address
10260 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10261 If unsure, say N.
10262
10263 config COMPAT_VDSO
10264 - def_bool y
10265 + def_bool n
10266 prompt "Compat VDSO support"
10267 depends on X86_32 || IA32_EMULATION
10268 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10269 ---help---
10270 Map the 32-bit VDSO to the predictable old-style address too.
10271
10272 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10273 index c026cca..14657ae 100644
10274 --- a/arch/x86/Kconfig.cpu
10275 +++ b/arch/x86/Kconfig.cpu
10276 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10277
10278 config X86_F00F_BUG
10279 def_bool y
10280 - depends on M586MMX || M586TSC || M586 || M486
10281 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10282
10283 config X86_INVD_BUG
10284 def_bool y
10285 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10286
10287 config X86_ALIGNMENT_16
10288 def_bool y
10289 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10290 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10291
10292 config X86_INTEL_USERCOPY
10293 def_bool y
10294 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10295 # generates cmov.
10296 config X86_CMOV
10297 def_bool y
10298 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10299 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10300
10301 config X86_MINIMUM_CPU_FAMILY
10302 int
10303 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10304 index c198b7e..63eea60 100644
10305 --- a/arch/x86/Kconfig.debug
10306 +++ b/arch/x86/Kconfig.debug
10307 @@ -84,7 +84,7 @@ config X86_PTDUMP
10308 config DEBUG_RODATA
10309 bool "Write protect kernel read-only data structures"
10310 default y
10311 - depends on DEBUG_KERNEL
10312 + depends on DEBUG_KERNEL && BROKEN
10313 ---help---
10314 Mark the kernel read-only data as write-protected in the pagetables,
10315 in order to catch accidental (and incorrect) writes to such const
10316 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10317
10318 config DEBUG_SET_MODULE_RONX
10319 bool "Set loadable kernel module data as NX and text as RO"
10320 - depends on MODULES
10321 + depends on MODULES && BROKEN
10322 ---help---
10323 This option helps catch unintended modifications to loadable
10324 kernel module's text and read-only data. It also prevents execution
10325 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10326 index 5c47726..8c4fa67 100644
10327 --- a/arch/x86/Makefile
10328 +++ b/arch/x86/Makefile
10329 @@ -54,6 +54,7 @@ else
10330 UTS_MACHINE := x86_64
10331 CHECKFLAGS += -D__x86_64__ -m64
10332
10333 + biarch := $(call cc-option,-m64)
10334 KBUILD_AFLAGS += -m64
10335 KBUILD_CFLAGS += -m64
10336
10337 @@ -234,3 +235,12 @@ define archhelp
10338 echo ' FDARGS="..." arguments for the booted kernel'
10339 echo ' FDINITRD=file initrd for the booted kernel'
10340 endef
10341 +
10342 +define OLD_LD
10343 +
10344 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10345 +*** Please upgrade your binutils to 2.18 or newer
10346 +endef
10347 +
10348 +archprepare:
10349 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10350 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10351 index 379814b..add62ce 100644
10352 --- a/arch/x86/boot/Makefile
10353 +++ b/arch/x86/boot/Makefile
10354 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10355 $(call cc-option, -fno-stack-protector) \
10356 $(call cc-option, -mpreferred-stack-boundary=2)
10357 KBUILD_CFLAGS += $(call cc-option, -m32)
10358 +ifdef CONSTIFY_PLUGIN
10359 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10360 +endif
10361 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10362 GCOV_PROFILE := n
10363
10364 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10365 index 878e4b9..20537ab 100644
10366 --- a/arch/x86/boot/bitops.h
10367 +++ b/arch/x86/boot/bitops.h
10368 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10369 u8 v;
10370 const u32 *p = (const u32 *)addr;
10371
10372 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10373 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10374 return v;
10375 }
10376
10377 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10378
10379 static inline void set_bit(int nr, void *addr)
10380 {
10381 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10382 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10383 }
10384
10385 #endif /* BOOT_BITOPS_H */
10386 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10387 index 5b75319..331a4ca 100644
10388 --- a/arch/x86/boot/boot.h
10389 +++ b/arch/x86/boot/boot.h
10390 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10391 static inline u16 ds(void)
10392 {
10393 u16 seg;
10394 - asm("movw %%ds,%0" : "=rm" (seg));
10395 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10396 return seg;
10397 }
10398
10399 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10400 static inline int memcmp(const void *s1, const void *s2, size_t len)
10401 {
10402 u8 diff;
10403 - asm("repe; cmpsb; setnz %0"
10404 + asm volatile("repe; cmpsb; setnz %0"
10405 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10406 return diff;
10407 }
10408 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10409 index 5ef205c..342191d 100644
10410 --- a/arch/x86/boot/compressed/Makefile
10411 +++ b/arch/x86/boot/compressed/Makefile
10412 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10413 KBUILD_CFLAGS += $(cflags-y)
10414 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10415 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10416 +ifdef CONSTIFY_PLUGIN
10417 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10418 +endif
10419
10420 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10421 GCOV_PROFILE := n
10422 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10423 index c205035..5853587 100644
10424 --- a/arch/x86/boot/compressed/eboot.c
10425 +++ b/arch/x86/boot/compressed/eboot.c
10426 @@ -150,7 +150,6 @@ again:
10427 *addr = max_addr;
10428 }
10429
10430 -free_pool:
10431 efi_call_phys1(sys_table->boottime->free_pool, map);
10432
10433 fail:
10434 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10435 if (i == map_size / desc_size)
10436 status = EFI_NOT_FOUND;
10437
10438 -free_pool:
10439 efi_call_phys1(sys_table->boottime->free_pool, map);
10440 fail:
10441 return status;
10442 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10443 index a53440e..c3dbf1e 100644
10444 --- a/arch/x86/boot/compressed/efi_stub_32.S
10445 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10446 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10447 * parameter 2, ..., param n. To make things easy, we save the return
10448 * address of efi_call_phys in a global variable.
10449 */
10450 - popl %ecx
10451 - movl %ecx, saved_return_addr(%edx)
10452 - /* get the function pointer into ECX*/
10453 - popl %ecx
10454 - movl %ecx, efi_rt_function_ptr(%edx)
10455 + popl saved_return_addr(%edx)
10456 + popl efi_rt_function_ptr(%edx)
10457
10458 /*
10459 * 3. Call the physical function.
10460 */
10461 - call *%ecx
10462 + call *efi_rt_function_ptr(%edx)
10463
10464 /*
10465 * 4. Balance the stack. And because EAX contain the return value,
10466 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10467 1: popl %edx
10468 subl $1b, %edx
10469
10470 - movl efi_rt_function_ptr(%edx), %ecx
10471 - pushl %ecx
10472 + pushl efi_rt_function_ptr(%edx)
10473
10474 /*
10475 * 10. Push the saved return address onto the stack and return.
10476 */
10477 - movl saved_return_addr(%edx), %ecx
10478 - pushl %ecx
10479 - ret
10480 + jmpl *saved_return_addr(%edx)
10481 ENDPROC(efi_call_phys)
10482 .previous
10483
10484 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10485 index 1e3184f..0d11e2e 100644
10486 --- a/arch/x86/boot/compressed/head_32.S
10487 +++ b/arch/x86/boot/compressed/head_32.S
10488 @@ -118,7 +118,7 @@ preferred_addr:
10489 notl %eax
10490 andl %eax, %ebx
10491 #else
10492 - movl $LOAD_PHYSICAL_ADDR, %ebx
10493 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10494 #endif
10495
10496 /* Target address to relocate to for decompression */
10497 @@ -204,7 +204,7 @@ relocated:
10498 * and where it was actually loaded.
10499 */
10500 movl %ebp, %ebx
10501 - subl $LOAD_PHYSICAL_ADDR, %ebx
10502 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10503 jz 2f /* Nothing to be done if loaded at compiled addr. */
10504 /*
10505 * Process relocations.
10506 @@ -212,8 +212,7 @@ relocated:
10507
10508 1: subl $4, %edi
10509 movl (%edi), %ecx
10510 - testl %ecx, %ecx
10511 - jz 2f
10512 + jecxz 2f
10513 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10514 jmp 1b
10515 2:
10516 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10517 index 16f24e6..47491a3 100644
10518 --- a/arch/x86/boot/compressed/head_64.S
10519 +++ b/arch/x86/boot/compressed/head_64.S
10520 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10521 notl %eax
10522 andl %eax, %ebx
10523 #else
10524 - movl $LOAD_PHYSICAL_ADDR, %ebx
10525 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10526 #endif
10527
10528 /* Target address to relocate to for decompression */
10529 @@ -272,7 +272,7 @@ preferred_addr:
10530 notq %rax
10531 andq %rax, %rbp
10532 #else
10533 - movq $LOAD_PHYSICAL_ADDR, %rbp
10534 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10535 #endif
10536
10537 /* Target address to relocate to for decompression */
10538 @@ -363,8 +363,8 @@ gdt:
10539 .long gdt
10540 .word 0
10541 .quad 0x0000000000000000 /* NULL descriptor */
10542 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10543 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10544 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10545 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10546 .quad 0x0080890000000000 /* TS descriptor */
10547 .quad 0x0000000000000000 /* TS continued */
10548 gdt_end:
10549 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10550 index 7cb56c6..d382d84 100644
10551 --- a/arch/x86/boot/compressed/misc.c
10552 +++ b/arch/x86/boot/compressed/misc.c
10553 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10554 case PT_LOAD:
10555 #ifdef CONFIG_RELOCATABLE
10556 dest = output;
10557 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10558 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10559 #else
10560 dest = (void *)(phdr->p_paddr);
10561 #endif
10562 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10563 error("Destination address too large");
10564 #endif
10565 #ifndef CONFIG_RELOCATABLE
10566 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10567 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10568 error("Wrong destination address");
10569 #endif
10570
10571 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10572 index 4d3ff03..e4972ff 100644
10573 --- a/arch/x86/boot/cpucheck.c
10574 +++ b/arch/x86/boot/cpucheck.c
10575 @@ -74,7 +74,7 @@ static int has_fpu(void)
10576 u16 fcw = -1, fsw = -1;
10577 u32 cr0;
10578
10579 - asm("movl %%cr0,%0" : "=r" (cr0));
10580 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10581 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10582 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10583 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10584 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10585 {
10586 u32 f0, f1;
10587
10588 - asm("pushfl ; "
10589 + asm volatile("pushfl ; "
10590 "pushfl ; "
10591 "popl %0 ; "
10592 "movl %0,%1 ; "
10593 @@ -115,7 +115,7 @@ static void get_flags(void)
10594 set_bit(X86_FEATURE_FPU, cpu.flags);
10595
10596 if (has_eflag(X86_EFLAGS_ID)) {
10597 - asm("cpuid"
10598 + asm volatile("cpuid"
10599 : "=a" (max_intel_level),
10600 "=b" (cpu_vendor[0]),
10601 "=d" (cpu_vendor[1]),
10602 @@ -124,7 +124,7 @@ static void get_flags(void)
10603
10604 if (max_intel_level >= 0x00000001 &&
10605 max_intel_level <= 0x0000ffff) {
10606 - asm("cpuid"
10607 + asm volatile("cpuid"
10608 : "=a" (tfms),
10609 "=c" (cpu.flags[4]),
10610 "=d" (cpu.flags[0])
10611 @@ -136,7 +136,7 @@ static void get_flags(void)
10612 cpu.model += ((tfms >> 16) & 0xf) << 4;
10613 }
10614
10615 - asm("cpuid"
10616 + asm volatile("cpuid"
10617 : "=a" (max_amd_level)
10618 : "a" (0x80000000)
10619 : "ebx", "ecx", "edx");
10620 @@ -144,7 +144,7 @@ static void get_flags(void)
10621 if (max_amd_level >= 0x80000001 &&
10622 max_amd_level <= 0x8000ffff) {
10623 u32 eax = 0x80000001;
10624 - asm("cpuid"
10625 + asm volatile("cpuid"
10626 : "+a" (eax),
10627 "=c" (cpu.flags[6]),
10628 "=d" (cpu.flags[1])
10629 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10630 u32 ecx = MSR_K7_HWCR;
10631 u32 eax, edx;
10632
10633 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10634 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10635 eax &= ~(1 << 15);
10636 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10637 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10638
10639 get_flags(); /* Make sure it really did something */
10640 err = check_flags();
10641 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10642 u32 ecx = MSR_VIA_FCR;
10643 u32 eax, edx;
10644
10645 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10646 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10647 eax |= (1<<1)|(1<<7);
10648 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10649 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10650
10651 set_bit(X86_FEATURE_CX8, cpu.flags);
10652 err = check_flags();
10653 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10654 u32 eax, edx;
10655 u32 level = 1;
10656
10657 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10658 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10659 - asm("cpuid"
10660 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10661 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10662 + asm volatile("cpuid"
10663 : "+a" (level), "=d" (cpu.flags[0])
10664 : : "ecx", "ebx");
10665 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10666 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10667
10668 err = check_flags();
10669 }
10670 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10671 index 9ec06a1..2c25e79 100644
10672 --- a/arch/x86/boot/header.S
10673 +++ b/arch/x86/boot/header.S
10674 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10675 # single linked list of
10676 # struct setup_data
10677
10678 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10679 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10680
10681 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10682 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10683 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10684 +#else
10685 #define VO_INIT_SIZE (VO__end - VO__text)
10686 +#endif
10687 #if ZO_INIT_SIZE > VO_INIT_SIZE
10688 #define INIT_SIZE ZO_INIT_SIZE
10689 #else
10690 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10691 index db75d07..8e6d0af 100644
10692 --- a/arch/x86/boot/memory.c
10693 +++ b/arch/x86/boot/memory.c
10694 @@ -19,7 +19,7 @@
10695
10696 static int detect_memory_e820(void)
10697 {
10698 - int count = 0;
10699 + unsigned int count = 0;
10700 struct biosregs ireg, oreg;
10701 struct e820entry *desc = boot_params.e820_map;
10702 static struct e820entry buf; /* static so it is zeroed */
10703 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10704 index 11e8c6e..fdbb1ed 100644
10705 --- a/arch/x86/boot/video-vesa.c
10706 +++ b/arch/x86/boot/video-vesa.c
10707 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10708
10709 boot_params.screen_info.vesapm_seg = oreg.es;
10710 boot_params.screen_info.vesapm_off = oreg.di;
10711 + boot_params.screen_info.vesapm_size = oreg.cx;
10712 }
10713
10714 /*
10715 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10716 index 43eda28..5ab5fdb 100644
10717 --- a/arch/x86/boot/video.c
10718 +++ b/arch/x86/boot/video.c
10719 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10720 static unsigned int get_entry(void)
10721 {
10722 char entry_buf[4];
10723 - int i, len = 0;
10724 + unsigned int i, len = 0;
10725 int key;
10726 unsigned int v;
10727
10728 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10729 index 9105655..5e37f27 100644
10730 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10731 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10732 @@ -8,6 +8,8 @@
10733 * including this sentence is retained in full.
10734 */
10735
10736 +#include <asm/alternative-asm.h>
10737 +
10738 .extern crypto_ft_tab
10739 .extern crypto_it_tab
10740 .extern crypto_fl_tab
10741 @@ -70,6 +72,8 @@
10742 je B192; \
10743 leaq 32(r9),r9;
10744
10745 +#define ret pax_force_retaddr 0, 1; ret
10746 +
10747 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10748 movq r1,r2; \
10749 movq r3,r4; \
10750 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10751 index 477e9d7..3ab339f 100644
10752 --- a/arch/x86/crypto/aesni-intel_asm.S
10753 +++ b/arch/x86/crypto/aesni-intel_asm.S
10754 @@ -31,6 +31,7 @@
10755
10756 #include <linux/linkage.h>
10757 #include <asm/inst.h>
10758 +#include <asm/alternative-asm.h>
10759
10760 #ifdef __x86_64__
10761 .data
10762 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
10763 pop %r14
10764 pop %r13
10765 pop %r12
10766 + pax_force_retaddr 0, 1
10767 ret
10768 ENDPROC(aesni_gcm_dec)
10769
10770 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
10771 pop %r14
10772 pop %r13
10773 pop %r12
10774 + pax_force_retaddr 0, 1
10775 ret
10776 ENDPROC(aesni_gcm_enc)
10777
10778 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
10779 pxor %xmm1, %xmm0
10780 movaps %xmm0, (TKEYP)
10781 add $0x10, TKEYP
10782 + pax_force_retaddr_bts
10783 ret
10784 ENDPROC(_key_expansion_128)
10785 ENDPROC(_key_expansion_256a)
10786 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
10787 shufps $0b01001110, %xmm2, %xmm1
10788 movaps %xmm1, 0x10(TKEYP)
10789 add $0x20, TKEYP
10790 + pax_force_retaddr_bts
10791 ret
10792 ENDPROC(_key_expansion_192a)
10793
10794 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
10795
10796 movaps %xmm0, (TKEYP)
10797 add $0x10, TKEYP
10798 + pax_force_retaddr_bts
10799 ret
10800 ENDPROC(_key_expansion_192b)
10801
10802 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
10803 pxor %xmm1, %xmm2
10804 movaps %xmm2, (TKEYP)
10805 add $0x10, TKEYP
10806 + pax_force_retaddr_bts
10807 ret
10808 ENDPROC(_key_expansion_256b)
10809
10810 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
10811 #ifndef __x86_64__
10812 popl KEYP
10813 #endif
10814 + pax_force_retaddr 0, 1
10815 ret
10816 ENDPROC(aesni_set_key)
10817
10818 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
10819 popl KLEN
10820 popl KEYP
10821 #endif
10822 + pax_force_retaddr 0, 1
10823 ret
10824 ENDPROC(aesni_enc)
10825
10826 @@ -1974,6 +1983,7 @@ _aesni_enc1:
10827 AESENC KEY STATE
10828 movaps 0x70(TKEYP), KEY
10829 AESENCLAST KEY STATE
10830 + pax_force_retaddr_bts
10831 ret
10832 ENDPROC(_aesni_enc1)
10833
10834 @@ -2083,6 +2093,7 @@ _aesni_enc4:
10835 AESENCLAST KEY STATE2
10836 AESENCLAST KEY STATE3
10837 AESENCLAST KEY STATE4
10838 + pax_force_retaddr_bts
10839 ret
10840 ENDPROC(_aesni_enc4)
10841
10842 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
10843 popl KLEN
10844 popl KEYP
10845 #endif
10846 + pax_force_retaddr 0, 1
10847 ret
10848 ENDPROC(aesni_dec)
10849
10850 @@ -2164,6 +2176,7 @@ _aesni_dec1:
10851 AESDEC KEY STATE
10852 movaps 0x70(TKEYP), KEY
10853 AESDECLAST KEY STATE
10854 + pax_force_retaddr_bts
10855 ret
10856 ENDPROC(_aesni_dec1)
10857
10858 @@ -2273,6 +2286,7 @@ _aesni_dec4:
10859 AESDECLAST KEY STATE2
10860 AESDECLAST KEY STATE3
10861 AESDECLAST KEY STATE4
10862 + pax_force_retaddr_bts
10863 ret
10864 ENDPROC(_aesni_dec4)
10865
10866 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
10867 popl KEYP
10868 popl LEN
10869 #endif
10870 + pax_force_retaddr 0, 1
10871 ret
10872 ENDPROC(aesni_ecb_enc)
10873
10874 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
10875 popl KEYP
10876 popl LEN
10877 #endif
10878 + pax_force_retaddr 0, 1
10879 ret
10880 ENDPROC(aesni_ecb_dec)
10881
10882 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
10883 popl LEN
10884 popl IVP
10885 #endif
10886 + pax_force_retaddr 0, 1
10887 ret
10888 ENDPROC(aesni_cbc_enc)
10889
10890 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
10891 popl LEN
10892 popl IVP
10893 #endif
10894 + pax_force_retaddr 0, 1
10895 ret
10896 ENDPROC(aesni_cbc_dec)
10897
10898 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
10899 mov $1, TCTR_LOW
10900 MOVQ_R64_XMM TCTR_LOW INC
10901 MOVQ_R64_XMM CTR TCTR_LOW
10902 + pax_force_retaddr_bts
10903 ret
10904 ENDPROC(_aesni_inc_init)
10905
10906 @@ -2579,6 +2598,7 @@ _aesni_inc:
10907 .Linc_low:
10908 movaps CTR, IV
10909 PSHUFB_XMM BSWAP_MASK IV
10910 + pax_force_retaddr_bts
10911 ret
10912 ENDPROC(_aesni_inc)
10913
10914 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
10915 .Lctr_enc_ret:
10916 movups IV, (IVP)
10917 .Lctr_enc_just_ret:
10918 + pax_force_retaddr 0, 1
10919 ret
10920 ENDPROC(aesni_ctr_enc)
10921
10922 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
10923 pxor INC, STATE4
10924 movdqu STATE4, 0x70(OUTP)
10925
10926 + pax_force_retaddr 0, 1
10927 ret
10928 ENDPROC(aesni_xts_crypt8)
10929
10930 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10931 index 246c670..4d1ed00 100644
10932 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10933 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10934 @@ -21,6 +21,7 @@
10935 */
10936
10937 #include <linux/linkage.h>
10938 +#include <asm/alternative-asm.h>
10939
10940 .file "blowfish-x86_64-asm.S"
10941 .text
10942 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10943 jnz .L__enc_xor;
10944
10945 write_block();
10946 + pax_force_retaddr 0, 1
10947 ret;
10948 .L__enc_xor:
10949 xor_block();
10950 + pax_force_retaddr 0, 1
10951 ret;
10952 ENDPROC(__blowfish_enc_blk)
10953
10954 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10955
10956 movq %r11, %rbp;
10957
10958 + pax_force_retaddr 0, 1
10959 ret;
10960 ENDPROC(blowfish_dec_blk)
10961
10962 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10963
10964 popq %rbx;
10965 popq %rbp;
10966 + pax_force_retaddr 0, 1
10967 ret;
10968
10969 .L__enc_xor4:
10970 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10971
10972 popq %rbx;
10973 popq %rbp;
10974 + pax_force_retaddr 0, 1
10975 ret;
10976 ENDPROC(__blowfish_enc_blk_4way)
10977
10978 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10979 popq %rbx;
10980 popq %rbp;
10981
10982 + pax_force_retaddr 0, 1
10983 ret;
10984 ENDPROC(blowfish_dec_blk_4way)
10985 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10986 index 310319c..ce174a4 100644
10987 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10988 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10989 @@ -21,6 +21,7 @@
10990 */
10991
10992 #include <linux/linkage.h>
10993 +#include <asm/alternative-asm.h>
10994
10995 .file "camellia-x86_64-asm_64.S"
10996 .text
10997 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
10998 enc_outunpack(mov, RT1);
10999
11000 movq RRBP, %rbp;
11001 + pax_force_retaddr 0, 1
11002 ret;
11003
11004 .L__enc_xor:
11005 enc_outunpack(xor, RT1);
11006
11007 movq RRBP, %rbp;
11008 + pax_force_retaddr 0, 1
11009 ret;
11010 ENDPROC(__camellia_enc_blk)
11011
11012 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11013 dec_outunpack();
11014
11015 movq RRBP, %rbp;
11016 + pax_force_retaddr 0, 1
11017 ret;
11018 ENDPROC(camellia_dec_blk)
11019
11020 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11021
11022 movq RRBP, %rbp;
11023 popq %rbx;
11024 + pax_force_retaddr 0, 1
11025 ret;
11026
11027 .L__enc2_xor:
11028 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11029
11030 movq RRBP, %rbp;
11031 popq %rbx;
11032 + pax_force_retaddr 0, 1
11033 ret;
11034 ENDPROC(__camellia_enc_blk_2way)
11035
11036 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11037
11038 movq RRBP, %rbp;
11039 movq RXOR, %rbx;
11040 + pax_force_retaddr 0, 1
11041 ret;
11042 ENDPROC(camellia_dec_blk_2way)
11043 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11044 index c35fd5d..c1ee236 100644
11045 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11046 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11047 @@ -24,6 +24,7 @@
11048 */
11049
11050 #include <linux/linkage.h>
11051 +#include <asm/alternative-asm.h>
11052
11053 .file "cast5-avx-x86_64-asm_64.S"
11054
11055 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11056 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11057 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11058
11059 + pax_force_retaddr 0, 1
11060 ret;
11061 ENDPROC(__cast5_enc_blk16)
11062
11063 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11064 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11065 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11066
11067 + pax_force_retaddr 0, 1
11068 ret;
11069
11070 .L__skip_dec:
11071 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11072 vmovdqu RR4, (6*4*4)(%r11);
11073 vmovdqu RL4, (7*4*4)(%r11);
11074
11075 + pax_force_retaddr
11076 ret;
11077 ENDPROC(cast5_ecb_enc_16way)
11078
11079 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11080 vmovdqu RR4, (6*4*4)(%r11);
11081 vmovdqu RL4, (7*4*4)(%r11);
11082
11083 + pax_force_retaddr
11084 ret;
11085 ENDPROC(cast5_ecb_dec_16way)
11086
11087 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11088
11089 popq %r12;
11090
11091 + pax_force_retaddr
11092 ret;
11093 ENDPROC(cast5_cbc_dec_16way)
11094
11095 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11096
11097 popq %r12;
11098
11099 + pax_force_retaddr
11100 ret;
11101 ENDPROC(cast5_ctr_16way)
11102 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11103 index e3531f8..18ded3a 100644
11104 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11105 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11106 @@ -24,6 +24,7 @@
11107 */
11108
11109 #include <linux/linkage.h>
11110 +#include <asm/alternative-asm.h>
11111 #include "glue_helper-asm-avx.S"
11112
11113 .file "cast6-avx-x86_64-asm_64.S"
11114 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11115 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11116 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11117
11118 + pax_force_retaddr 0, 1
11119 ret;
11120 ENDPROC(__cast6_enc_blk8)
11121
11122 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11123 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11124 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11125
11126 + pax_force_retaddr 0, 1
11127 ret;
11128 ENDPROC(__cast6_dec_blk8)
11129
11130 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11131
11132 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11133
11134 + pax_force_retaddr
11135 ret;
11136 ENDPROC(cast6_ecb_enc_8way)
11137
11138 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11139
11140 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11141
11142 + pax_force_retaddr
11143 ret;
11144 ENDPROC(cast6_ecb_dec_8way)
11145
11146 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11147
11148 popq %r12;
11149
11150 + pax_force_retaddr
11151 ret;
11152 ENDPROC(cast6_cbc_dec_8way)
11153
11154 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11155
11156 popq %r12;
11157
11158 + pax_force_retaddr
11159 ret;
11160 ENDPROC(cast6_ctr_8way)
11161
11162 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11163 /* dst <= regs xor IVs(in dst) */
11164 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11165
11166 + pax_force_retaddr
11167 ret;
11168 ENDPROC(cast6_xts_enc_8way)
11169
11170 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11171 /* dst <= regs xor IVs(in dst) */
11172 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11173
11174 + pax_force_retaddr
11175 ret;
11176 ENDPROC(cast6_xts_dec_8way)
11177 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11178 index 9279e0b..9270820 100644
11179 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11180 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11181 @@ -1,4 +1,5 @@
11182 #include <linux/linkage.h>
11183 +#include <asm/alternative-asm.h>
11184
11185 # enter salsa20_encrypt_bytes
11186 ENTRY(salsa20_encrypt_bytes)
11187 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11188 add %r11,%rsp
11189 mov %rdi,%rax
11190 mov %rsi,%rdx
11191 + pax_force_retaddr 0, 1
11192 ret
11193 # bytesatleast65:
11194 ._bytesatleast65:
11195 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11196 add %r11,%rsp
11197 mov %rdi,%rax
11198 mov %rsi,%rdx
11199 + pax_force_retaddr
11200 ret
11201 ENDPROC(salsa20_keysetup)
11202
11203 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11204 add %r11,%rsp
11205 mov %rdi,%rax
11206 mov %rsi,%rdx
11207 + pax_force_retaddr
11208 ret
11209 ENDPROC(salsa20_ivsetup)
11210 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11211 index 2f202f4..d9164d6 100644
11212 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11213 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11214 @@ -24,6 +24,7 @@
11215 */
11216
11217 #include <linux/linkage.h>
11218 +#include <asm/alternative-asm.h>
11219 #include "glue_helper-asm-avx.S"
11220
11221 .file "serpent-avx-x86_64-asm_64.S"
11222 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11223 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11224 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11225
11226 + pax_force_retaddr
11227 ret;
11228 ENDPROC(__serpent_enc_blk8_avx)
11229
11230 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11231 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11232 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11233
11234 + pax_force_retaddr
11235 ret;
11236 ENDPROC(__serpent_dec_blk8_avx)
11237
11238 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11239
11240 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11241
11242 + pax_force_retaddr
11243 ret;
11244 ENDPROC(serpent_ecb_enc_8way_avx)
11245
11246 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11247
11248 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11249
11250 + pax_force_retaddr
11251 ret;
11252 ENDPROC(serpent_ecb_dec_8way_avx)
11253
11254 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11255
11256 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11257
11258 + pax_force_retaddr
11259 ret;
11260 ENDPROC(serpent_cbc_dec_8way_avx)
11261
11262 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11263
11264 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11265
11266 + pax_force_retaddr
11267 ret;
11268 ENDPROC(serpent_ctr_8way_avx)
11269
11270 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11271 /* dst <= regs xor IVs(in dst) */
11272 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11273
11274 + pax_force_retaddr
11275 ret;
11276 ENDPROC(serpent_xts_enc_8way_avx)
11277
11278 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11279 /* dst <= regs xor IVs(in dst) */
11280 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11281
11282 + pax_force_retaddr
11283 ret;
11284 ENDPROC(serpent_xts_dec_8way_avx)
11285 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11286 index acc066c..1559cc4 100644
11287 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11288 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11289 @@ -25,6 +25,7 @@
11290 */
11291
11292 #include <linux/linkage.h>
11293 +#include <asm/alternative-asm.h>
11294
11295 .file "serpent-sse2-x86_64-asm_64.S"
11296 .text
11297 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11298 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11299 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11300
11301 + pax_force_retaddr
11302 ret;
11303
11304 .L__enc_xor8:
11305 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11306 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11307
11308 + pax_force_retaddr
11309 ret;
11310 ENDPROC(__serpent_enc_blk_8way)
11311
11312 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11313 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11314 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11315
11316 + pax_force_retaddr
11317 ret;
11318 ENDPROC(serpent_dec_blk_8way)
11319 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11320 index a410950..3356d42 100644
11321 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11322 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11323 @@ -29,6 +29,7 @@
11324 */
11325
11326 #include <linux/linkage.h>
11327 +#include <asm/alternative-asm.h>
11328
11329 #define CTX %rdi // arg1
11330 #define BUF %rsi // arg2
11331 @@ -104,6 +105,7 @@
11332 pop %r12
11333 pop %rbp
11334 pop %rbx
11335 + pax_force_retaddr 0, 1
11336 ret
11337
11338 ENDPROC(\name)
11339 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11340 index 0505813..63b1d00 100644
11341 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11342 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11343 @@ -24,6 +24,7 @@
11344 */
11345
11346 #include <linux/linkage.h>
11347 +#include <asm/alternative-asm.h>
11348 #include "glue_helper-asm-avx.S"
11349
11350 .file "twofish-avx-x86_64-asm_64.S"
11351 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
11352 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11353 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11354
11355 + pax_force_retaddr 0, 1
11356 ret;
11357 ENDPROC(__twofish_enc_blk8)
11358
11359 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
11360 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11361 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11362
11363 + pax_force_retaddr 0, 1
11364 ret;
11365 ENDPROC(__twofish_dec_blk8)
11366
11367 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
11368
11369 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11370
11371 + pax_force_retaddr 0, 1
11372 ret;
11373 ENDPROC(twofish_ecb_enc_8way)
11374
11375 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
11376
11377 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11378
11379 + pax_force_retaddr 0, 1
11380 ret;
11381 ENDPROC(twofish_ecb_dec_8way)
11382
11383 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
11384
11385 popq %r12;
11386
11387 + pax_force_retaddr 0, 1
11388 ret;
11389 ENDPROC(twofish_cbc_dec_8way)
11390
11391 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
11392
11393 popq %r12;
11394
11395 + pax_force_retaddr 0, 1
11396 ret;
11397 ENDPROC(twofish_ctr_8way)
11398
11399 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
11400 /* dst <= regs xor IVs(in dst) */
11401 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11402
11403 + pax_force_retaddr 0, 1
11404 ret;
11405 ENDPROC(twofish_xts_enc_8way)
11406
11407 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
11408 /* dst <= regs xor IVs(in dst) */
11409 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11410
11411 + pax_force_retaddr 0, 1
11412 ret;
11413 ENDPROC(twofish_xts_dec_8way)
11414 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11415 index 1c3b7ce..b365c5e 100644
11416 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11417 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11418 @@ -21,6 +21,7 @@
11419 */
11420
11421 #include <linux/linkage.h>
11422 +#include <asm/alternative-asm.h>
11423
11424 .file "twofish-x86_64-asm-3way.S"
11425 .text
11426 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11427 popq %r13;
11428 popq %r14;
11429 popq %r15;
11430 + pax_force_retaddr 0, 1
11431 ret;
11432
11433 .L__enc_xor3:
11434 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11435 popq %r13;
11436 popq %r14;
11437 popq %r15;
11438 + pax_force_retaddr 0, 1
11439 ret;
11440 ENDPROC(__twofish_enc_blk_3way)
11441
11442 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11443 popq %r13;
11444 popq %r14;
11445 popq %r15;
11446 + pax_force_retaddr 0, 1
11447 ret;
11448 ENDPROC(twofish_dec_blk_3way)
11449 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11450 index a039d21..29e7615 100644
11451 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11452 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11453 @@ -22,6 +22,7 @@
11454
11455 #include <linux/linkage.h>
11456 #include <asm/asm-offsets.h>
11457 +#include <asm/alternative-asm.h>
11458
11459 #define a_offset 0
11460 #define b_offset 4
11461 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11462
11463 popq R1
11464 movq $1,%rax
11465 + pax_force_retaddr 0, 1
11466 ret
11467 ENDPROC(twofish_enc_blk)
11468
11469 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11470
11471 popq R1
11472 movq $1,%rax
11473 + pax_force_retaddr 0, 1
11474 ret
11475 ENDPROC(twofish_dec_blk)
11476 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11477 index 52ff81c..98af645 100644
11478 --- a/arch/x86/ia32/ia32_aout.c
11479 +++ b/arch/x86/ia32/ia32_aout.c
11480 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11481 unsigned long dump_start, dump_size;
11482 struct user32 dump;
11483
11484 + memset(&dump, 0, sizeof(dump));
11485 +
11486 fs = get_fs();
11487 set_fs(KERNEL_DS);
11488 has_dumped = 1;
11489 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11490 index cf1a471..3bc4cf8 100644
11491 --- a/arch/x86/ia32/ia32_signal.c
11492 +++ b/arch/x86/ia32/ia32_signal.c
11493 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11494 sp -= frame_size;
11495 /* Align the stack pointer according to the i386 ABI,
11496 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11497 - sp = ((sp + 4) & -16ul) - 4;
11498 + sp = ((sp - 12) & -16ul) - 4;
11499 return (void __user *) sp;
11500 }
11501
11502 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11503 * These are actually not used anymore, but left because some
11504 * gdb versions depend on them as a marker.
11505 */
11506 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11507 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11508 } put_user_catch(err);
11509
11510 if (err)
11511 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11512 0xb8,
11513 __NR_ia32_rt_sigreturn,
11514 0x80cd,
11515 - 0,
11516 + 0
11517 };
11518
11519 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11520 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11521
11522 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11523 restorer = ksig->ka.sa.sa_restorer;
11524 + else if (current->mm->context.vdso)
11525 + /* Return stub is in 32bit vsyscall page */
11526 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11527 else
11528 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11529 - rt_sigreturn);
11530 + restorer = &frame->retcode;
11531 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11532
11533 /*
11534 * Not actually used anymore, but left because some gdb
11535 * versions need it.
11536 */
11537 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11538 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11539 } put_user_catch(err);
11540
11541 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11542 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11543 index 474dc1b..24aaa3e 100644
11544 --- a/arch/x86/ia32/ia32entry.S
11545 +++ b/arch/x86/ia32/ia32entry.S
11546 @@ -15,8 +15,10 @@
11547 #include <asm/irqflags.h>
11548 #include <asm/asm.h>
11549 #include <asm/smap.h>
11550 +#include <asm/pgtable.h>
11551 #include <linux/linkage.h>
11552 #include <linux/err.h>
11553 +#include <asm/alternative-asm.h>
11554
11555 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11556 #include <linux/elf-em.h>
11557 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11558 ENDPROC(native_irq_enable_sysexit)
11559 #endif
11560
11561 + .macro pax_enter_kernel_user
11562 + pax_set_fptr_mask
11563 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11564 + call pax_enter_kernel_user
11565 +#endif
11566 + .endm
11567 +
11568 + .macro pax_exit_kernel_user
11569 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11570 + call pax_exit_kernel_user
11571 +#endif
11572 +#ifdef CONFIG_PAX_RANDKSTACK
11573 + pushq %rax
11574 + pushq %r11
11575 + call pax_randomize_kstack
11576 + popq %r11
11577 + popq %rax
11578 +#endif
11579 + .endm
11580 +
11581 + .macro pax_erase_kstack
11582 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11583 + call pax_erase_kstack
11584 +#endif
11585 + .endm
11586 +
11587 /*
11588 * 32bit SYSENTER instruction entry.
11589 *
11590 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11591 CFI_REGISTER rsp,rbp
11592 SWAPGS_UNSAFE_STACK
11593 movq PER_CPU_VAR(kernel_stack), %rsp
11594 - addq $(KERNEL_STACK_OFFSET),%rsp
11595 - /*
11596 - * No need to follow this irqs on/off section: the syscall
11597 - * disabled irqs, here we enable it straight after entry:
11598 - */
11599 - ENABLE_INTERRUPTS(CLBR_NONE)
11600 movl %ebp,%ebp /* zero extension */
11601 pushq_cfi $__USER32_DS
11602 /*CFI_REL_OFFSET ss,0*/
11603 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11604 CFI_REL_OFFSET rsp,0
11605 pushfq_cfi
11606 /*CFI_REL_OFFSET rflags,0*/
11607 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11608 - CFI_REGISTER rip,r10
11609 + orl $X86_EFLAGS_IF,(%rsp)
11610 + GET_THREAD_INFO(%r11)
11611 + movl TI_sysenter_return(%r11), %r11d
11612 + CFI_REGISTER rip,r11
11613 pushq_cfi $__USER32_CS
11614 /*CFI_REL_OFFSET cs,0*/
11615 movl %eax, %eax
11616 - pushq_cfi %r10
11617 + pushq_cfi %r11
11618 CFI_REL_OFFSET rip,0
11619 pushq_cfi %rax
11620 cld
11621 SAVE_ARGS 0,1,0
11622 + pax_enter_kernel_user
11623 +
11624 +#ifdef CONFIG_PAX_RANDKSTACK
11625 + pax_erase_kstack
11626 +#endif
11627 +
11628 + /*
11629 + * No need to follow this irqs on/off section: the syscall
11630 + * disabled irqs, here we enable it straight after entry:
11631 + */
11632 + ENABLE_INTERRUPTS(CLBR_NONE)
11633 /* no need to do an access_ok check here because rbp has been
11634 32bit zero extended */
11635 +
11636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11637 + mov pax_user_shadow_base,%r11
11638 + add %r11,%rbp
11639 +#endif
11640 +
11641 ASM_STAC
11642 1: movl (%rbp),%ebp
11643 _ASM_EXTABLE(1b,ia32_badarg)
11644 ASM_CLAC
11645 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11646 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11647 + GET_THREAD_INFO(%r11)
11648 + orl $TS_COMPAT,TI_status(%r11)
11649 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11650 CFI_REMEMBER_STATE
11651 jnz sysenter_tracesys
11652 cmpq $(IA32_NR_syscalls-1),%rax
11653 @@ -162,12 +204,15 @@ sysenter_do_call:
11654 sysenter_dispatch:
11655 call *ia32_sys_call_table(,%rax,8)
11656 movq %rax,RAX-ARGOFFSET(%rsp)
11657 + GET_THREAD_INFO(%r11)
11658 DISABLE_INTERRUPTS(CLBR_NONE)
11659 TRACE_IRQS_OFF
11660 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11661 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11662 jnz sysexit_audit
11663 sysexit_from_sys_call:
11664 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11665 + pax_exit_kernel_user
11666 + pax_erase_kstack
11667 + andl $~TS_COMPAT,TI_status(%r11)
11668 /* clear IF, that popfq doesn't enable interrupts early */
11669 andl $~0x200,EFLAGS-R11(%rsp)
11670 movl RIP-R11(%rsp),%edx /* User %eip */
11671 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11672 movl %eax,%esi /* 2nd arg: syscall number */
11673 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11674 call __audit_syscall_entry
11675 +
11676 + pax_erase_kstack
11677 +
11678 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11679 cmpq $(IA32_NR_syscalls-1),%rax
11680 ja ia32_badsys
11681 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11682 .endm
11683
11684 .macro auditsys_exit exit
11685 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11686 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11687 jnz ia32_ret_from_sys_call
11688 TRACE_IRQS_ON
11689 ENABLE_INTERRUPTS(CLBR_NONE)
11690 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11691 1: setbe %al /* 1 if error, 0 if not */
11692 movzbl %al,%edi /* zero-extend that into %edi */
11693 call __audit_syscall_exit
11694 + GET_THREAD_INFO(%r11)
11695 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11696 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11697 DISABLE_INTERRUPTS(CLBR_NONE)
11698 TRACE_IRQS_OFF
11699 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11700 + testl %edi,TI_flags(%r11)
11701 jz \exit
11702 CLEAR_RREGS -ARGOFFSET
11703 jmp int_with_check
11704 @@ -237,7 +286,7 @@ sysexit_audit:
11705
11706 sysenter_tracesys:
11707 #ifdef CONFIG_AUDITSYSCALL
11708 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11709 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11710 jz sysenter_auditsys
11711 #endif
11712 SAVE_REST
11713 @@ -249,6 +298,9 @@ sysenter_tracesys:
11714 RESTORE_REST
11715 cmpq $(IA32_NR_syscalls-1),%rax
11716 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11717 +
11718 + pax_erase_kstack
11719 +
11720 jmp sysenter_do_call
11721 CFI_ENDPROC
11722 ENDPROC(ia32_sysenter_target)
11723 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11724 ENTRY(ia32_cstar_target)
11725 CFI_STARTPROC32 simple
11726 CFI_SIGNAL_FRAME
11727 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11728 + CFI_DEF_CFA rsp,0
11729 CFI_REGISTER rip,rcx
11730 /*CFI_REGISTER rflags,r11*/
11731 SWAPGS_UNSAFE_STACK
11732 movl %esp,%r8d
11733 CFI_REGISTER rsp,r8
11734 movq PER_CPU_VAR(kernel_stack),%rsp
11735 + SAVE_ARGS 8*6,0,0
11736 + pax_enter_kernel_user
11737 +
11738 +#ifdef CONFIG_PAX_RANDKSTACK
11739 + pax_erase_kstack
11740 +#endif
11741 +
11742 /*
11743 * No need to follow this irqs on/off section: the syscall
11744 * disabled irqs and here we enable it straight after entry:
11745 */
11746 ENABLE_INTERRUPTS(CLBR_NONE)
11747 - SAVE_ARGS 8,0,0
11748 movl %eax,%eax /* zero extension */
11749 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11750 movq %rcx,RIP-ARGOFFSET(%rsp)
11751 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11752 /* no need to do an access_ok check here because r8 has been
11753 32bit zero extended */
11754 /* hardware stack frame is complete now */
11755 +
11756 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11757 + mov pax_user_shadow_base,%r11
11758 + add %r11,%r8
11759 +#endif
11760 +
11761 ASM_STAC
11762 1: movl (%r8),%r9d
11763 _ASM_EXTABLE(1b,ia32_badarg)
11764 ASM_CLAC
11765 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11766 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11767 + GET_THREAD_INFO(%r11)
11768 + orl $TS_COMPAT,TI_status(%r11)
11769 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11770 CFI_REMEMBER_STATE
11771 jnz cstar_tracesys
11772 cmpq $IA32_NR_syscalls-1,%rax
11773 @@ -319,12 +384,15 @@ cstar_do_call:
11774 cstar_dispatch:
11775 call *ia32_sys_call_table(,%rax,8)
11776 movq %rax,RAX-ARGOFFSET(%rsp)
11777 + GET_THREAD_INFO(%r11)
11778 DISABLE_INTERRUPTS(CLBR_NONE)
11779 TRACE_IRQS_OFF
11780 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11781 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11782 jnz sysretl_audit
11783 sysretl_from_sys_call:
11784 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11785 + pax_exit_kernel_user
11786 + pax_erase_kstack
11787 + andl $~TS_COMPAT,TI_status(%r11)
11788 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11789 movl RIP-ARGOFFSET(%rsp),%ecx
11790 CFI_REGISTER rip,rcx
11791 @@ -352,7 +420,7 @@ sysretl_audit:
11792
11793 cstar_tracesys:
11794 #ifdef CONFIG_AUDITSYSCALL
11795 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11796 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11797 jz cstar_auditsys
11798 #endif
11799 xchgl %r9d,%ebp
11800 @@ -366,6 +434,9 @@ cstar_tracesys:
11801 xchgl %ebp,%r9d
11802 cmpq $(IA32_NR_syscalls-1),%rax
11803 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11804 +
11805 + pax_erase_kstack
11806 +
11807 jmp cstar_do_call
11808 END(ia32_cstar_target)
11809
11810 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11811 CFI_REL_OFFSET rip,RIP-RIP
11812 PARAVIRT_ADJUST_EXCEPTION_FRAME
11813 SWAPGS
11814 - /*
11815 - * No need to follow this irqs on/off section: the syscall
11816 - * disabled irqs and here we enable it straight after entry:
11817 - */
11818 - ENABLE_INTERRUPTS(CLBR_NONE)
11819 movl %eax,%eax
11820 pushq_cfi %rax
11821 cld
11822 /* note the registers are not zero extended to the sf.
11823 this could be a problem. */
11824 SAVE_ARGS 0,1,0
11825 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11826 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11827 + pax_enter_kernel_user
11828 +
11829 +#ifdef CONFIG_PAX_RANDKSTACK
11830 + pax_erase_kstack
11831 +#endif
11832 +
11833 + /*
11834 + * No need to follow this irqs on/off section: the syscall
11835 + * disabled irqs and here we enable it straight after entry:
11836 + */
11837 + ENABLE_INTERRUPTS(CLBR_NONE)
11838 + GET_THREAD_INFO(%r11)
11839 + orl $TS_COMPAT,TI_status(%r11)
11840 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11841 jnz ia32_tracesys
11842 cmpq $(IA32_NR_syscalls-1),%rax
11843 ja ia32_badsys
11844 @@ -442,6 +520,9 @@ ia32_tracesys:
11845 RESTORE_REST
11846 cmpq $(IA32_NR_syscalls-1),%rax
11847 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11848 +
11849 + pax_erase_kstack
11850 +
11851 jmp ia32_do_call
11852 END(ia32_syscall)
11853
11854 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11855 index 8e0ceec..af13504 100644
11856 --- a/arch/x86/ia32/sys_ia32.c
11857 +++ b/arch/x86/ia32/sys_ia32.c
11858 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11859 */
11860 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11861 {
11862 - typeof(ubuf->st_uid) uid = 0;
11863 - typeof(ubuf->st_gid) gid = 0;
11864 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11865 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11866 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11867 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11868 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11869 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11870 index 372231c..a5aa1a1 100644
11871 --- a/arch/x86/include/asm/alternative-asm.h
11872 +++ b/arch/x86/include/asm/alternative-asm.h
11873 @@ -18,6 +18,45 @@
11874 .endm
11875 #endif
11876
11877 +#ifdef KERNEXEC_PLUGIN
11878 + .macro pax_force_retaddr_bts rip=0
11879 + btsq $63,\rip(%rsp)
11880 + .endm
11881 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11882 + .macro pax_force_retaddr rip=0, reload=0
11883 + btsq $63,\rip(%rsp)
11884 + .endm
11885 + .macro pax_force_fptr ptr
11886 + btsq $63,\ptr
11887 + .endm
11888 + .macro pax_set_fptr_mask
11889 + .endm
11890 +#endif
11891 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11892 + .macro pax_force_retaddr rip=0, reload=0
11893 + .if \reload
11894 + pax_set_fptr_mask
11895 + .endif
11896 + orq %r10,\rip(%rsp)
11897 + .endm
11898 + .macro pax_force_fptr ptr
11899 + orq %r10,\ptr
11900 + .endm
11901 + .macro pax_set_fptr_mask
11902 + movabs $0x8000000000000000,%r10
11903 + .endm
11904 +#endif
11905 +#else
11906 + .macro pax_force_retaddr rip=0, reload=0
11907 + .endm
11908 + .macro pax_force_fptr ptr
11909 + .endm
11910 + .macro pax_force_retaddr_bts rip=0
11911 + .endm
11912 + .macro pax_set_fptr_mask
11913 + .endm
11914 +#endif
11915 +
11916 .macro altinstruction_entry orig alt feature orig_len alt_len
11917 .long \orig - .
11918 .long \alt - .
11919 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11920 index 58ed6d9..f1cbe58 100644
11921 --- a/arch/x86/include/asm/alternative.h
11922 +++ b/arch/x86/include/asm/alternative.h
11923 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11924 ".pushsection .discard,\"aw\",@progbits\n" \
11925 DISCARD_ENTRY(1) \
11926 ".popsection\n" \
11927 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11928 + ".pushsection .altinstr_replacement, \"a\"\n" \
11929 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11930 ".popsection"
11931
11932 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11933 DISCARD_ENTRY(1) \
11934 DISCARD_ENTRY(2) \
11935 ".popsection\n" \
11936 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11937 + ".pushsection .altinstr_replacement, \"a\"\n" \
11938 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11939 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11940 ".popsection"
11941 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11942 index 3388034..050f0b9 100644
11943 --- a/arch/x86/include/asm/apic.h
11944 +++ b/arch/x86/include/asm/apic.h
11945 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11946
11947 #ifdef CONFIG_X86_LOCAL_APIC
11948
11949 -extern unsigned int apic_verbosity;
11950 +extern int apic_verbosity;
11951 extern int local_apic_timer_c2_ok;
11952
11953 extern int disable_apic;
11954 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11955 index 20370c6..a2eb9b0 100644
11956 --- a/arch/x86/include/asm/apm.h
11957 +++ b/arch/x86/include/asm/apm.h
11958 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11959 __asm__ __volatile__(APM_DO_ZERO_SEGS
11960 "pushl %%edi\n\t"
11961 "pushl %%ebp\n\t"
11962 - "lcall *%%cs:apm_bios_entry\n\t"
11963 + "lcall *%%ss:apm_bios_entry\n\t"
11964 "setc %%al\n\t"
11965 "popl %%ebp\n\t"
11966 "popl %%edi\n\t"
11967 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11968 __asm__ __volatile__(APM_DO_ZERO_SEGS
11969 "pushl %%edi\n\t"
11970 "pushl %%ebp\n\t"
11971 - "lcall *%%cs:apm_bios_entry\n\t"
11972 + "lcall *%%ss:apm_bios_entry\n\t"
11973 "setc %%bl\n\t"
11974 "popl %%ebp\n\t"
11975 "popl %%edi\n\t"
11976 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11977 index 722aa3b..3a0bb27 100644
11978 --- a/arch/x86/include/asm/atomic.h
11979 +++ b/arch/x86/include/asm/atomic.h
11980 @@ -22,7 +22,18 @@
11981 */
11982 static inline int atomic_read(const atomic_t *v)
11983 {
11984 - return (*(volatile int *)&(v)->counter);
11985 + return (*(volatile const int *)&(v)->counter);
11986 +}
11987 +
11988 +/**
11989 + * atomic_read_unchecked - read atomic variable
11990 + * @v: pointer of type atomic_unchecked_t
11991 + *
11992 + * Atomically reads the value of @v.
11993 + */
11994 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11995 +{
11996 + return (*(volatile const int *)&(v)->counter);
11997 }
11998
11999 /**
12000 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12001 }
12002
12003 /**
12004 + * atomic_set_unchecked - set atomic variable
12005 + * @v: pointer of type atomic_unchecked_t
12006 + * @i: required value
12007 + *
12008 + * Atomically sets the value of @v to @i.
12009 + */
12010 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12011 +{
12012 + v->counter = i;
12013 +}
12014 +
12015 +/**
12016 * atomic_add - add integer to atomic variable
12017 * @i: integer value to add
12018 * @v: pointer of type atomic_t
12019 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12020 */
12021 static inline void atomic_add(int i, atomic_t *v)
12022 {
12023 - asm volatile(LOCK_PREFIX "addl %1,%0"
12024 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12025 +
12026 +#ifdef CONFIG_PAX_REFCOUNT
12027 + "jno 0f\n"
12028 + LOCK_PREFIX "subl %1,%0\n"
12029 + "int $4\n0:\n"
12030 + _ASM_EXTABLE(0b, 0b)
12031 +#endif
12032 +
12033 + : "+m" (v->counter)
12034 + : "ir" (i));
12035 +}
12036 +
12037 +/**
12038 + * atomic_add_unchecked - add integer to atomic variable
12039 + * @i: integer value to add
12040 + * @v: pointer of type atomic_unchecked_t
12041 + *
12042 + * Atomically adds @i to @v.
12043 + */
12044 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12045 +{
12046 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12047 : "+m" (v->counter)
12048 : "ir" (i));
12049 }
12050 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12051 */
12052 static inline void atomic_sub(int i, atomic_t *v)
12053 {
12054 - asm volatile(LOCK_PREFIX "subl %1,%0"
12055 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12056 +
12057 +#ifdef CONFIG_PAX_REFCOUNT
12058 + "jno 0f\n"
12059 + LOCK_PREFIX "addl %1,%0\n"
12060 + "int $4\n0:\n"
12061 + _ASM_EXTABLE(0b, 0b)
12062 +#endif
12063 +
12064 + : "+m" (v->counter)
12065 + : "ir" (i));
12066 +}
12067 +
12068 +/**
12069 + * atomic_sub_unchecked - subtract integer from atomic variable
12070 + * @i: integer value to subtract
12071 + * @v: pointer of type atomic_unchecked_t
12072 + *
12073 + * Atomically subtracts @i from @v.
12074 + */
12075 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12076 +{
12077 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12078 : "+m" (v->counter)
12079 : "ir" (i));
12080 }
12081 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12082 {
12083 unsigned char c;
12084
12085 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12086 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12087 +
12088 +#ifdef CONFIG_PAX_REFCOUNT
12089 + "jno 0f\n"
12090 + LOCK_PREFIX "addl %2,%0\n"
12091 + "int $4\n0:\n"
12092 + _ASM_EXTABLE(0b, 0b)
12093 +#endif
12094 +
12095 + "sete %1\n"
12096 : "+m" (v->counter), "=qm" (c)
12097 : "ir" (i) : "memory");
12098 return c;
12099 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12100 */
12101 static inline void atomic_inc(atomic_t *v)
12102 {
12103 - asm volatile(LOCK_PREFIX "incl %0"
12104 + asm volatile(LOCK_PREFIX "incl %0\n"
12105 +
12106 +#ifdef CONFIG_PAX_REFCOUNT
12107 + "jno 0f\n"
12108 + LOCK_PREFIX "decl %0\n"
12109 + "int $4\n0:\n"
12110 + _ASM_EXTABLE(0b, 0b)
12111 +#endif
12112 +
12113 + : "+m" (v->counter));
12114 +}
12115 +
12116 +/**
12117 + * atomic_inc_unchecked - increment atomic variable
12118 + * @v: pointer of type atomic_unchecked_t
12119 + *
12120 + * Atomically increments @v by 1.
12121 + */
12122 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12123 +{
12124 + asm volatile(LOCK_PREFIX "incl %0\n"
12125 : "+m" (v->counter));
12126 }
12127
12128 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12129 */
12130 static inline void atomic_dec(atomic_t *v)
12131 {
12132 - asm volatile(LOCK_PREFIX "decl %0"
12133 + asm volatile(LOCK_PREFIX "decl %0\n"
12134 +
12135 +#ifdef CONFIG_PAX_REFCOUNT
12136 + "jno 0f\n"
12137 + LOCK_PREFIX "incl %0\n"
12138 + "int $4\n0:\n"
12139 + _ASM_EXTABLE(0b, 0b)
12140 +#endif
12141 +
12142 + : "+m" (v->counter));
12143 +}
12144 +
12145 +/**
12146 + * atomic_dec_unchecked - decrement atomic variable
12147 + * @v: pointer of type atomic_unchecked_t
12148 + *
12149 + * Atomically decrements @v by 1.
12150 + */
12151 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12152 +{
12153 + asm volatile(LOCK_PREFIX "decl %0\n"
12154 : "+m" (v->counter));
12155 }
12156
12157 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12158 {
12159 unsigned char c;
12160
12161 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12162 + asm volatile(LOCK_PREFIX "decl %0\n"
12163 +
12164 +#ifdef CONFIG_PAX_REFCOUNT
12165 + "jno 0f\n"
12166 + LOCK_PREFIX "incl %0\n"
12167 + "int $4\n0:\n"
12168 + _ASM_EXTABLE(0b, 0b)
12169 +#endif
12170 +
12171 + "sete %1\n"
12172 : "+m" (v->counter), "=qm" (c)
12173 : : "memory");
12174 return c != 0;
12175 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12176 {
12177 unsigned char c;
12178
12179 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12180 + asm volatile(LOCK_PREFIX "incl %0\n"
12181 +
12182 +#ifdef CONFIG_PAX_REFCOUNT
12183 + "jno 0f\n"
12184 + LOCK_PREFIX "decl %0\n"
12185 + "int $4\n0:\n"
12186 + _ASM_EXTABLE(0b, 0b)
12187 +#endif
12188 +
12189 + "sete %1\n"
12190 + : "+m" (v->counter), "=qm" (c)
12191 + : : "memory");
12192 + return c != 0;
12193 +}
12194 +
12195 +/**
12196 + * atomic_inc_and_test_unchecked - increment and test
12197 + * @v: pointer of type atomic_unchecked_t
12198 + *
12199 + * Atomically increments @v by 1
12200 + * and returns true if the result is zero, or false for all
12201 + * other cases.
12202 + */
12203 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12204 +{
12205 + unsigned char c;
12206 +
12207 + asm volatile(LOCK_PREFIX "incl %0\n"
12208 + "sete %1\n"
12209 : "+m" (v->counter), "=qm" (c)
12210 : : "memory");
12211 return c != 0;
12212 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12213 {
12214 unsigned char c;
12215
12216 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12217 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12218 +
12219 +#ifdef CONFIG_PAX_REFCOUNT
12220 + "jno 0f\n"
12221 + LOCK_PREFIX "subl %2,%0\n"
12222 + "int $4\n0:\n"
12223 + _ASM_EXTABLE(0b, 0b)
12224 +#endif
12225 +
12226 + "sets %1\n"
12227 : "+m" (v->counter), "=qm" (c)
12228 : "ir" (i) : "memory");
12229 return c;
12230 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12231 */
12232 static inline int atomic_add_return(int i, atomic_t *v)
12233 {
12234 + return i + xadd_check_overflow(&v->counter, i);
12235 +}
12236 +
12237 +/**
12238 + * atomic_add_return_unchecked - add integer and return
12239 + * @i: integer value to add
12240 + * @v: pointer of type atomic_unchecked_t
12241 + *
12242 + * Atomically adds @i to @v and returns @i + @v
12243 + */
12244 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12245 +{
12246 return i + xadd(&v->counter, i);
12247 }
12248
12249 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12250 }
12251
12252 #define atomic_inc_return(v) (atomic_add_return(1, v))
12253 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12254 +{
12255 + return atomic_add_return_unchecked(1, v);
12256 +}
12257 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12258
12259 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12260 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12261 return cmpxchg(&v->counter, old, new);
12262 }
12263
12264 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12265 +{
12266 + return cmpxchg(&v->counter, old, new);
12267 +}
12268 +
12269 static inline int atomic_xchg(atomic_t *v, int new)
12270 {
12271 return xchg(&v->counter, new);
12272 }
12273
12274 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12275 +{
12276 + return xchg(&v->counter, new);
12277 +}
12278 +
12279 /**
12280 * __atomic_add_unless - add unless the number is already a given value
12281 * @v: pointer of type atomic_t
12282 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12283 */
12284 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12285 {
12286 - int c, old;
12287 + int c, old, new;
12288 c = atomic_read(v);
12289 for (;;) {
12290 - if (unlikely(c == (u)))
12291 + if (unlikely(c == u))
12292 break;
12293 - old = atomic_cmpxchg((v), c, c + (a));
12294 +
12295 + asm volatile("addl %2,%0\n"
12296 +
12297 +#ifdef CONFIG_PAX_REFCOUNT
12298 + "jno 0f\n"
12299 + "subl %2,%0\n"
12300 + "int $4\n0:\n"
12301 + _ASM_EXTABLE(0b, 0b)
12302 +#endif
12303 +
12304 + : "=r" (new)
12305 + : "0" (c), "ir" (a));
12306 +
12307 + old = atomic_cmpxchg(v, c, new);
12308 if (likely(old == c))
12309 break;
12310 c = old;
12311 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12312 }
12313
12314 /**
12315 + * atomic_inc_not_zero_hint - increment if not null
12316 + * @v: pointer of type atomic_t
12317 + * @hint: probable value of the atomic before the increment
12318 + *
12319 + * This version of atomic_inc_not_zero() gives a hint of probable
12320 + * value of the atomic. This helps processor to not read the memory
12321 + * before doing the atomic read/modify/write cycle, lowering
12322 + * number of bus transactions on some arches.
12323 + *
12324 + * Returns: 0 if increment was not done, 1 otherwise.
12325 + */
12326 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12327 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12328 +{
12329 + int val, c = hint, new;
12330 +
12331 + /* sanity test, should be removed by compiler if hint is a constant */
12332 + if (!hint)
12333 + return __atomic_add_unless(v, 1, 0);
12334 +
12335 + do {
12336 + asm volatile("incl %0\n"
12337 +
12338 +#ifdef CONFIG_PAX_REFCOUNT
12339 + "jno 0f\n"
12340 + "decl %0\n"
12341 + "int $4\n0:\n"
12342 + _ASM_EXTABLE(0b, 0b)
12343 +#endif
12344 +
12345 + : "=r" (new)
12346 + : "0" (c));
12347 +
12348 + val = atomic_cmpxchg(v, c, new);
12349 + if (val == c)
12350 + return 1;
12351 + c = val;
12352 + } while (c);
12353 +
12354 + return 0;
12355 +}
12356 +
12357 +/**
12358 * atomic_inc_short - increment of a short integer
12359 * @v: pointer to type int
12360 *
12361 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12362 #endif
12363
12364 /* These are x86-specific, used by some header files */
12365 -#define atomic_clear_mask(mask, addr) \
12366 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12367 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12368 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12369 +{
12370 + asm volatile(LOCK_PREFIX "andl %1,%0"
12371 + : "+m" (v->counter)
12372 + : "r" (~(mask))
12373 + : "memory");
12374 +}
12375
12376 -#define atomic_set_mask(mask, addr) \
12377 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12378 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12379 - : "memory")
12380 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12381 +{
12382 + asm volatile(LOCK_PREFIX "andl %1,%0"
12383 + : "+m" (v->counter)
12384 + : "r" (~(mask))
12385 + : "memory");
12386 +}
12387 +
12388 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12389 +{
12390 + asm volatile(LOCK_PREFIX "orl %1,%0"
12391 + : "+m" (v->counter)
12392 + : "r" (mask)
12393 + : "memory");
12394 +}
12395 +
12396 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12397 +{
12398 + asm volatile(LOCK_PREFIX "orl %1,%0"
12399 + : "+m" (v->counter)
12400 + : "r" (mask)
12401 + : "memory");
12402 +}
12403
12404 /* Atomic operations are already serializing on x86 */
12405 #define smp_mb__before_atomic_dec() barrier()
12406 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12407 index b154de7..aadebd8 100644
12408 --- a/arch/x86/include/asm/atomic64_32.h
12409 +++ b/arch/x86/include/asm/atomic64_32.h
12410 @@ -12,6 +12,14 @@ typedef struct {
12411 u64 __aligned(8) counter;
12412 } atomic64_t;
12413
12414 +#ifdef CONFIG_PAX_REFCOUNT
12415 +typedef struct {
12416 + u64 __aligned(8) counter;
12417 +} atomic64_unchecked_t;
12418 +#else
12419 +typedef atomic64_t atomic64_unchecked_t;
12420 +#endif
12421 +
12422 #define ATOMIC64_INIT(val) { (val) }
12423
12424 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12425 @@ -37,21 +45,31 @@ typedef struct {
12426 ATOMIC64_DECL_ONE(sym##_386)
12427
12428 ATOMIC64_DECL_ONE(add_386);
12429 +ATOMIC64_DECL_ONE(add_unchecked_386);
12430 ATOMIC64_DECL_ONE(sub_386);
12431 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12432 ATOMIC64_DECL_ONE(inc_386);
12433 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12434 ATOMIC64_DECL_ONE(dec_386);
12435 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12436 #endif
12437
12438 #define alternative_atomic64(f, out, in...) \
12439 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12440
12441 ATOMIC64_DECL(read);
12442 +ATOMIC64_DECL(read_unchecked);
12443 ATOMIC64_DECL(set);
12444 +ATOMIC64_DECL(set_unchecked);
12445 ATOMIC64_DECL(xchg);
12446 ATOMIC64_DECL(add_return);
12447 +ATOMIC64_DECL(add_return_unchecked);
12448 ATOMIC64_DECL(sub_return);
12449 +ATOMIC64_DECL(sub_return_unchecked);
12450 ATOMIC64_DECL(inc_return);
12451 +ATOMIC64_DECL(inc_return_unchecked);
12452 ATOMIC64_DECL(dec_return);
12453 +ATOMIC64_DECL(dec_return_unchecked);
12454 ATOMIC64_DECL(dec_if_positive);
12455 ATOMIC64_DECL(inc_not_zero);
12456 ATOMIC64_DECL(add_unless);
12457 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12458 }
12459
12460 /**
12461 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12462 + * @p: pointer to type atomic64_unchecked_t
12463 + * @o: expected value
12464 + * @n: new value
12465 + *
12466 + * Atomically sets @v to @n if it was equal to @o and returns
12467 + * the old value.
12468 + */
12469 +
12470 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12471 +{
12472 + return cmpxchg64(&v->counter, o, n);
12473 +}
12474 +
12475 +/**
12476 * atomic64_xchg - xchg atomic64 variable
12477 * @v: pointer to type atomic64_t
12478 * @n: value to assign
12479 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12480 }
12481
12482 /**
12483 + * atomic64_set_unchecked - set atomic64 variable
12484 + * @v: pointer to type atomic64_unchecked_t
12485 + * @n: value to assign
12486 + *
12487 + * Atomically sets the value of @v to @n.
12488 + */
12489 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12490 +{
12491 + unsigned high = (unsigned)(i >> 32);
12492 + unsigned low = (unsigned)i;
12493 + alternative_atomic64(set, /* no output */,
12494 + "S" (v), "b" (low), "c" (high)
12495 + : "eax", "edx", "memory");
12496 +}
12497 +
12498 +/**
12499 * atomic64_read - read atomic64 variable
12500 * @v: pointer to type atomic64_t
12501 *
12502 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12503 }
12504
12505 /**
12506 + * atomic64_read_unchecked - read atomic64 variable
12507 + * @v: pointer to type atomic64_unchecked_t
12508 + *
12509 + * Atomically reads the value of @v and returns it.
12510 + */
12511 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12512 +{
12513 + long long r;
12514 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12515 + return r;
12516 + }
12517 +
12518 +/**
12519 * atomic64_add_return - add and return
12520 * @i: integer value to add
12521 * @v: pointer to type atomic64_t
12522 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12523 return i;
12524 }
12525
12526 +/**
12527 + * atomic64_add_return_unchecked - add and return
12528 + * @i: integer value to add
12529 + * @v: pointer to type atomic64_unchecked_t
12530 + *
12531 + * Atomically adds @i to @v and returns @i + *@v
12532 + */
12533 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12534 +{
12535 + alternative_atomic64(add_return_unchecked,
12536 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12537 + ASM_NO_INPUT_CLOBBER("memory"));
12538 + return i;
12539 +}
12540 +
12541 /*
12542 * Other variants with different arithmetic operators:
12543 */
12544 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12545 return a;
12546 }
12547
12548 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12549 +{
12550 + long long a;
12551 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12552 + "S" (v) : "memory", "ecx");
12553 + return a;
12554 +}
12555 +
12556 static inline long long atomic64_dec_return(atomic64_t *v)
12557 {
12558 long long a;
12559 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12560 }
12561
12562 /**
12563 + * atomic64_add_unchecked - add integer to atomic64 variable
12564 + * @i: integer value to add
12565 + * @v: pointer to type atomic64_unchecked_t
12566 + *
12567 + * Atomically adds @i to @v.
12568 + */
12569 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12570 +{
12571 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12572 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12573 + ASM_NO_INPUT_CLOBBER("memory"));
12574 + return i;
12575 +}
12576 +
12577 +/**
12578 * atomic64_sub - subtract the atomic64 variable
12579 * @i: integer value to subtract
12580 * @v: pointer to type atomic64_t
12581 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12582 index 0e1cbfc..5623683 100644
12583 --- a/arch/x86/include/asm/atomic64_64.h
12584 +++ b/arch/x86/include/asm/atomic64_64.h
12585 @@ -18,7 +18,19 @@
12586 */
12587 static inline long atomic64_read(const atomic64_t *v)
12588 {
12589 - return (*(volatile long *)&(v)->counter);
12590 + return (*(volatile const long *)&(v)->counter);
12591 +}
12592 +
12593 +/**
12594 + * atomic64_read_unchecked - read atomic64 variable
12595 + * @v: pointer of type atomic64_unchecked_t
12596 + *
12597 + * Atomically reads the value of @v.
12598 + * Doesn't imply a read memory barrier.
12599 + */
12600 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12601 +{
12602 + return (*(volatile const long *)&(v)->counter);
12603 }
12604
12605 /**
12606 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12607 }
12608
12609 /**
12610 + * atomic64_set_unchecked - set atomic64 variable
12611 + * @v: pointer to type atomic64_unchecked_t
12612 + * @i: required value
12613 + *
12614 + * Atomically sets the value of @v to @i.
12615 + */
12616 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12617 +{
12618 + v->counter = i;
12619 +}
12620 +
12621 +/**
12622 * atomic64_add - add integer to atomic64 variable
12623 * @i: integer value to add
12624 * @v: pointer to type atomic64_t
12625 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12626 */
12627 static inline void atomic64_add(long i, atomic64_t *v)
12628 {
12629 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12630 +
12631 +#ifdef CONFIG_PAX_REFCOUNT
12632 + "jno 0f\n"
12633 + LOCK_PREFIX "subq %1,%0\n"
12634 + "int $4\n0:\n"
12635 + _ASM_EXTABLE(0b, 0b)
12636 +#endif
12637 +
12638 + : "=m" (v->counter)
12639 + : "er" (i), "m" (v->counter));
12640 +}
12641 +
12642 +/**
12643 + * atomic64_add_unchecked - add integer to atomic64 variable
12644 + * @i: integer value to add
12645 + * @v: pointer to type atomic64_unchecked_t
12646 + *
12647 + * Atomically adds @i to @v.
12648 + */
12649 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12650 +{
12651 asm volatile(LOCK_PREFIX "addq %1,%0"
12652 : "=m" (v->counter)
12653 : "er" (i), "m" (v->counter));
12654 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12655 */
12656 static inline void atomic64_sub(long i, atomic64_t *v)
12657 {
12658 - asm volatile(LOCK_PREFIX "subq %1,%0"
12659 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12660 +
12661 +#ifdef CONFIG_PAX_REFCOUNT
12662 + "jno 0f\n"
12663 + LOCK_PREFIX "addq %1,%0\n"
12664 + "int $4\n0:\n"
12665 + _ASM_EXTABLE(0b, 0b)
12666 +#endif
12667 +
12668 + : "=m" (v->counter)
12669 + : "er" (i), "m" (v->counter));
12670 +}
12671 +
12672 +/**
12673 + * atomic64_sub_unchecked - subtract the atomic64 variable
12674 + * @i: integer value to subtract
12675 + * @v: pointer to type atomic64_unchecked_t
12676 + *
12677 + * Atomically subtracts @i from @v.
12678 + */
12679 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12680 +{
12681 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12682 : "=m" (v->counter)
12683 : "er" (i), "m" (v->counter));
12684 }
12685 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12686 {
12687 unsigned char c;
12688
12689 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12690 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12691 +
12692 +#ifdef CONFIG_PAX_REFCOUNT
12693 + "jno 0f\n"
12694 + LOCK_PREFIX "addq %2,%0\n"
12695 + "int $4\n0:\n"
12696 + _ASM_EXTABLE(0b, 0b)
12697 +#endif
12698 +
12699 + "sete %1\n"
12700 : "=m" (v->counter), "=qm" (c)
12701 : "er" (i), "m" (v->counter) : "memory");
12702 return c;
12703 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12704 */
12705 static inline void atomic64_inc(atomic64_t *v)
12706 {
12707 + asm volatile(LOCK_PREFIX "incq %0\n"
12708 +
12709 +#ifdef CONFIG_PAX_REFCOUNT
12710 + "jno 0f\n"
12711 + LOCK_PREFIX "decq %0\n"
12712 + "int $4\n0:\n"
12713 + _ASM_EXTABLE(0b, 0b)
12714 +#endif
12715 +
12716 + : "=m" (v->counter)
12717 + : "m" (v->counter));
12718 +}
12719 +
12720 +/**
12721 + * atomic64_inc_unchecked - increment atomic64 variable
12722 + * @v: pointer to type atomic64_unchecked_t
12723 + *
12724 + * Atomically increments @v by 1.
12725 + */
12726 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12727 +{
12728 asm volatile(LOCK_PREFIX "incq %0"
12729 : "=m" (v->counter)
12730 : "m" (v->counter));
12731 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12732 */
12733 static inline void atomic64_dec(atomic64_t *v)
12734 {
12735 - asm volatile(LOCK_PREFIX "decq %0"
12736 + asm volatile(LOCK_PREFIX "decq %0\n"
12737 +
12738 +#ifdef CONFIG_PAX_REFCOUNT
12739 + "jno 0f\n"
12740 + LOCK_PREFIX "incq %0\n"
12741 + "int $4\n0:\n"
12742 + _ASM_EXTABLE(0b, 0b)
12743 +#endif
12744 +
12745 + : "=m" (v->counter)
12746 + : "m" (v->counter));
12747 +}
12748 +
12749 +/**
12750 + * atomic64_dec_unchecked - decrement atomic64 variable
12751 + * @v: pointer to type atomic64_t
12752 + *
12753 + * Atomically decrements @v by 1.
12754 + */
12755 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12756 +{
12757 + asm volatile(LOCK_PREFIX "decq %0\n"
12758 : "=m" (v->counter)
12759 : "m" (v->counter));
12760 }
12761 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12762 {
12763 unsigned char c;
12764
12765 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12766 + asm volatile(LOCK_PREFIX "decq %0\n"
12767 +
12768 +#ifdef CONFIG_PAX_REFCOUNT
12769 + "jno 0f\n"
12770 + LOCK_PREFIX "incq %0\n"
12771 + "int $4\n0:\n"
12772 + _ASM_EXTABLE(0b, 0b)
12773 +#endif
12774 +
12775 + "sete %1\n"
12776 : "=m" (v->counter), "=qm" (c)
12777 : "m" (v->counter) : "memory");
12778 return c != 0;
12779 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12780 {
12781 unsigned char c;
12782
12783 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12784 + asm volatile(LOCK_PREFIX "incq %0\n"
12785 +
12786 +#ifdef CONFIG_PAX_REFCOUNT
12787 + "jno 0f\n"
12788 + LOCK_PREFIX "decq %0\n"
12789 + "int $4\n0:\n"
12790 + _ASM_EXTABLE(0b, 0b)
12791 +#endif
12792 +
12793 + "sete %1\n"
12794 : "=m" (v->counter), "=qm" (c)
12795 : "m" (v->counter) : "memory");
12796 return c != 0;
12797 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12798 {
12799 unsigned char c;
12800
12801 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12802 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12803 +
12804 +#ifdef CONFIG_PAX_REFCOUNT
12805 + "jno 0f\n"
12806 + LOCK_PREFIX "subq %2,%0\n"
12807 + "int $4\n0:\n"
12808 + _ASM_EXTABLE(0b, 0b)
12809 +#endif
12810 +
12811 + "sets %1\n"
12812 : "=m" (v->counter), "=qm" (c)
12813 : "er" (i), "m" (v->counter) : "memory");
12814 return c;
12815 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12816 */
12817 static inline long atomic64_add_return(long i, atomic64_t *v)
12818 {
12819 + return i + xadd_check_overflow(&v->counter, i);
12820 +}
12821 +
12822 +/**
12823 + * atomic64_add_return_unchecked - add and return
12824 + * @i: integer value to add
12825 + * @v: pointer to type atomic64_unchecked_t
12826 + *
12827 + * Atomically adds @i to @v and returns @i + @v
12828 + */
12829 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12830 +{
12831 return i + xadd(&v->counter, i);
12832 }
12833
12834 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12835 }
12836
12837 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12838 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12839 +{
12840 + return atomic64_add_return_unchecked(1, v);
12841 +}
12842 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12843
12844 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12845 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12846 return cmpxchg(&v->counter, old, new);
12847 }
12848
12849 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12850 +{
12851 + return cmpxchg(&v->counter, old, new);
12852 +}
12853 +
12854 static inline long atomic64_xchg(atomic64_t *v, long new)
12855 {
12856 return xchg(&v->counter, new);
12857 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12858 */
12859 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12860 {
12861 - long c, old;
12862 + long c, old, new;
12863 c = atomic64_read(v);
12864 for (;;) {
12865 - if (unlikely(c == (u)))
12866 + if (unlikely(c == u))
12867 break;
12868 - old = atomic64_cmpxchg((v), c, c + (a));
12869 +
12870 + asm volatile("add %2,%0\n"
12871 +
12872 +#ifdef CONFIG_PAX_REFCOUNT
12873 + "jno 0f\n"
12874 + "sub %2,%0\n"
12875 + "int $4\n0:\n"
12876 + _ASM_EXTABLE(0b, 0b)
12877 +#endif
12878 +
12879 + : "=r" (new)
12880 + : "0" (c), "ir" (a));
12881 +
12882 + old = atomic64_cmpxchg(v, c, new);
12883 if (likely(old == c))
12884 break;
12885 c = old;
12886 }
12887 - return c != (u);
12888 + return c != u;
12889 }
12890
12891 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12892 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12893 index 6dfd019..28e188d 100644
12894 --- a/arch/x86/include/asm/bitops.h
12895 +++ b/arch/x86/include/asm/bitops.h
12896 @@ -40,7 +40,7 @@
12897 * a mask operation on a byte.
12898 */
12899 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12900 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12901 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12902 #define CONST_MASK(nr) (1 << ((nr) & 7))
12903
12904 /**
12905 @@ -486,7 +486,7 @@ static inline int fls(int x)
12906 * at position 64.
12907 */
12908 #ifdef CONFIG_X86_64
12909 -static __always_inline int fls64(__u64 x)
12910 +static __always_inline long fls64(__u64 x)
12911 {
12912 int bitpos = -1;
12913 /*
12914 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12915 index 4fa687a..60f2d39 100644
12916 --- a/arch/x86/include/asm/boot.h
12917 +++ b/arch/x86/include/asm/boot.h
12918 @@ -6,10 +6,15 @@
12919 #include <uapi/asm/boot.h>
12920
12921 /* Physical address where kernel should be loaded. */
12922 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12923 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12924 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12925 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12926
12927 +#ifndef __ASSEMBLY__
12928 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12929 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12930 +#endif
12931 +
12932 /* Minimum kernel alignment, as a power of two */
12933 #ifdef CONFIG_X86_64
12934 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12935 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12936 index 48f99f1..d78ebf9 100644
12937 --- a/arch/x86/include/asm/cache.h
12938 +++ b/arch/x86/include/asm/cache.h
12939 @@ -5,12 +5,13 @@
12940
12941 /* L1 cache line size */
12942 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12943 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12944 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12945
12946 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12947 +#define __read_only __attribute__((__section__(".data..read_only")))
12948
12949 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12950 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12951 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12952
12953 #ifdef CONFIG_X86_VSMP
12954 #ifdef CONFIG_SMP
12955 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12956 index 9863ee3..4a1f8e1 100644
12957 --- a/arch/x86/include/asm/cacheflush.h
12958 +++ b/arch/x86/include/asm/cacheflush.h
12959 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12960 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12961
12962 if (pg_flags == _PGMT_DEFAULT)
12963 - return -1;
12964 + return ~0UL;
12965 else if (pg_flags == _PGMT_WC)
12966 return _PAGE_CACHE_WC;
12967 else if (pg_flags == _PGMT_UC_MINUS)
12968 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12969 index 46fc474..b02b0f9 100644
12970 --- a/arch/x86/include/asm/checksum_32.h
12971 +++ b/arch/x86/include/asm/checksum_32.h
12972 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12973 int len, __wsum sum,
12974 int *src_err_ptr, int *dst_err_ptr);
12975
12976 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12977 + int len, __wsum sum,
12978 + int *src_err_ptr, int *dst_err_ptr);
12979 +
12980 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12981 + int len, __wsum sum,
12982 + int *src_err_ptr, int *dst_err_ptr);
12983 +
12984 /*
12985 * Note: when you get a NULL pointer exception here this means someone
12986 * passed in an incorrect kernel address to one of these functions.
12987 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12988 int *err_ptr)
12989 {
12990 might_sleep();
12991 - return csum_partial_copy_generic((__force void *)src, dst,
12992 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12993 len, sum, err_ptr, NULL);
12994 }
12995
12996 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12997 {
12998 might_sleep();
12999 if (access_ok(VERIFY_WRITE, dst, len))
13000 - return csum_partial_copy_generic(src, (__force void *)dst,
13001 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13002 len, sum, NULL, err_ptr);
13003
13004 if (len)
13005 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13006 index d47786a..ce1b05d 100644
13007 --- a/arch/x86/include/asm/cmpxchg.h
13008 +++ b/arch/x86/include/asm/cmpxchg.h
13009 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13010 __compiletime_error("Bad argument size for cmpxchg");
13011 extern void __xadd_wrong_size(void)
13012 __compiletime_error("Bad argument size for xadd");
13013 +extern void __xadd_check_overflow_wrong_size(void)
13014 + __compiletime_error("Bad argument size for xadd_check_overflow");
13015 extern void __add_wrong_size(void)
13016 __compiletime_error("Bad argument size for add");
13017 +extern void __add_check_overflow_wrong_size(void)
13018 + __compiletime_error("Bad argument size for add_check_overflow");
13019
13020 /*
13021 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13022 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13023 __ret; \
13024 })
13025
13026 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13027 + ({ \
13028 + __typeof__ (*(ptr)) __ret = (arg); \
13029 + switch (sizeof(*(ptr))) { \
13030 + case __X86_CASE_L: \
13031 + asm volatile (lock #op "l %0, %1\n" \
13032 + "jno 0f\n" \
13033 + "mov %0,%1\n" \
13034 + "int $4\n0:\n" \
13035 + _ASM_EXTABLE(0b, 0b) \
13036 + : "+r" (__ret), "+m" (*(ptr)) \
13037 + : : "memory", "cc"); \
13038 + break; \
13039 + case __X86_CASE_Q: \
13040 + asm volatile (lock #op "q %q0, %1\n" \
13041 + "jno 0f\n" \
13042 + "mov %0,%1\n" \
13043 + "int $4\n0:\n" \
13044 + _ASM_EXTABLE(0b, 0b) \
13045 + : "+r" (__ret), "+m" (*(ptr)) \
13046 + : : "memory", "cc"); \
13047 + break; \
13048 + default: \
13049 + __ ## op ## _check_overflow_wrong_size(); \
13050 + } \
13051 + __ret; \
13052 + })
13053 +
13054 /*
13055 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13056 * Since this is generally used to protect other memory information, we
13057 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13058 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13059 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13060
13061 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13062 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13063 +
13064 #define __add(ptr, inc, lock) \
13065 ({ \
13066 __typeof__ (*(ptr)) __ret = (inc); \
13067 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13068 index 59c6c40..5e0b22c 100644
13069 --- a/arch/x86/include/asm/compat.h
13070 +++ b/arch/x86/include/asm/compat.h
13071 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13072 typedef u32 compat_uint_t;
13073 typedef u32 compat_ulong_t;
13074 typedef u64 __attribute__((aligned(4))) compat_u64;
13075 -typedef u32 compat_uptr_t;
13076 +typedef u32 __user compat_uptr_t;
13077
13078 struct compat_timespec {
13079 compat_time_t tv_sec;
13080 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13081 index e99ac27..e89e28c 100644
13082 --- a/arch/x86/include/asm/cpufeature.h
13083 +++ b/arch/x86/include/asm/cpufeature.h
13084 @@ -211,7 +211,7 @@
13085 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13086 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13087 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13088 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13089 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13090 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13091 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13092 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13093 @@ -394,7 +394,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13094 ".section .discard,\"aw\",@progbits\n"
13095 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13096 ".previous\n"
13097 - ".section .altinstr_replacement,\"ax\"\n"
13098 + ".section .altinstr_replacement,\"a\"\n"
13099 "3: movb $1,%0\n"
13100 "4:\n"
13101 ".previous\n"
13102 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13103 index 8bf1c06..b6ae785 100644
13104 --- a/arch/x86/include/asm/desc.h
13105 +++ b/arch/x86/include/asm/desc.h
13106 @@ -4,6 +4,7 @@
13107 #include <asm/desc_defs.h>
13108 #include <asm/ldt.h>
13109 #include <asm/mmu.h>
13110 +#include <asm/pgtable.h>
13111
13112 #include <linux/smp.h>
13113 #include <linux/percpu.h>
13114 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13115
13116 desc->type = (info->read_exec_only ^ 1) << 1;
13117 desc->type |= info->contents << 2;
13118 + desc->type |= info->seg_not_present ^ 1;
13119
13120 desc->s = 1;
13121 desc->dpl = 0x3;
13122 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13123 }
13124
13125 extern struct desc_ptr idt_descr;
13126 -extern gate_desc idt_table[];
13127 extern struct desc_ptr nmi_idt_descr;
13128 -extern gate_desc nmi_idt_table[];
13129 -
13130 -struct gdt_page {
13131 - struct desc_struct gdt[GDT_ENTRIES];
13132 -} __attribute__((aligned(PAGE_SIZE)));
13133 -
13134 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13135 +extern gate_desc idt_table[256];
13136 +extern gate_desc nmi_idt_table[256];
13137
13138 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13139 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13140 {
13141 - return per_cpu(gdt_page, cpu).gdt;
13142 + return cpu_gdt_table[cpu];
13143 }
13144
13145 #ifdef CONFIG_X86_64
13146 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13147 unsigned long base, unsigned dpl, unsigned flags,
13148 unsigned short seg)
13149 {
13150 - gate->a = (seg << 16) | (base & 0xffff);
13151 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13152 + gate->gate.offset_low = base;
13153 + gate->gate.seg = seg;
13154 + gate->gate.reserved = 0;
13155 + gate->gate.type = type;
13156 + gate->gate.s = 0;
13157 + gate->gate.dpl = dpl;
13158 + gate->gate.p = 1;
13159 + gate->gate.offset_high = base >> 16;
13160 }
13161
13162 #endif
13163 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13164
13165 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13166 {
13167 + pax_open_kernel();
13168 memcpy(&idt[entry], gate, sizeof(*gate));
13169 + pax_close_kernel();
13170 }
13171
13172 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13173 {
13174 + pax_open_kernel();
13175 memcpy(&ldt[entry], desc, 8);
13176 + pax_close_kernel();
13177 }
13178
13179 static inline void
13180 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13181 default: size = sizeof(*gdt); break;
13182 }
13183
13184 + pax_open_kernel();
13185 memcpy(&gdt[entry], desc, size);
13186 + pax_close_kernel();
13187 }
13188
13189 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13190 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13191
13192 static inline void native_load_tr_desc(void)
13193 {
13194 + pax_open_kernel();
13195 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13196 + pax_close_kernel();
13197 }
13198
13199 static inline void native_load_gdt(const struct desc_ptr *dtr)
13200 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13201 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13202 unsigned int i;
13203
13204 + pax_open_kernel();
13205 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13206 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13207 + pax_close_kernel();
13208 }
13209
13210 #define _LDT_empty(info) \
13211 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13212 preempt_enable();
13213 }
13214
13215 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13216 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13217 {
13218 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13219 }
13220 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13221 }
13222
13223 #ifdef CONFIG_X86_64
13224 -static inline void set_nmi_gate(int gate, void *addr)
13225 +static inline void set_nmi_gate(int gate, const void *addr)
13226 {
13227 gate_desc s;
13228
13229 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13230 }
13231 #endif
13232
13233 -static inline void _set_gate(int gate, unsigned type, void *addr,
13234 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13235 unsigned dpl, unsigned ist, unsigned seg)
13236 {
13237 gate_desc s;
13238 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13239 * Pentium F0 0F bugfix can have resulted in the mapped
13240 * IDT being write-protected.
13241 */
13242 -static inline void set_intr_gate(unsigned int n, void *addr)
13243 +static inline void set_intr_gate(unsigned int n, const void *addr)
13244 {
13245 BUG_ON((unsigned)n > 0xFF);
13246 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13247 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13248 /*
13249 * This routine sets up an interrupt gate at directory privilege level 3.
13250 */
13251 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13252 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13253 {
13254 BUG_ON((unsigned)n > 0xFF);
13255 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13256 }
13257
13258 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13259 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13260 {
13261 BUG_ON((unsigned)n > 0xFF);
13262 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13263 }
13264
13265 -static inline void set_trap_gate(unsigned int n, void *addr)
13266 +static inline void set_trap_gate(unsigned int n, const void *addr)
13267 {
13268 BUG_ON((unsigned)n > 0xFF);
13269 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13270 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13271 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13272 {
13273 BUG_ON((unsigned)n > 0xFF);
13274 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13275 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13276 }
13277
13278 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13279 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13280 {
13281 BUG_ON((unsigned)n > 0xFF);
13282 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13283 }
13284
13285 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13286 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13287 {
13288 BUG_ON((unsigned)n > 0xFF);
13289 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13290 }
13291
13292 +#ifdef CONFIG_X86_32
13293 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13294 +{
13295 + struct desc_struct d;
13296 +
13297 + if (likely(limit))
13298 + limit = (limit - 1UL) >> PAGE_SHIFT;
13299 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13300 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13301 +}
13302 +#endif
13303 +
13304 #endif /* _ASM_X86_DESC_H */
13305 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13306 index 278441f..b95a174 100644
13307 --- a/arch/x86/include/asm/desc_defs.h
13308 +++ b/arch/x86/include/asm/desc_defs.h
13309 @@ -31,6 +31,12 @@ struct desc_struct {
13310 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13311 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13312 };
13313 + struct {
13314 + u16 offset_low;
13315 + u16 seg;
13316 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13317 + unsigned offset_high: 16;
13318 + } gate;
13319 };
13320 } __attribute__((packed));
13321
13322 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13323 index ced283a..ffe04cc 100644
13324 --- a/arch/x86/include/asm/div64.h
13325 +++ b/arch/x86/include/asm/div64.h
13326 @@ -39,7 +39,7 @@
13327 __mod; \
13328 })
13329
13330 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13331 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13332 {
13333 union {
13334 u64 v64;
13335 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13336 index 9c999c1..3860cb8 100644
13337 --- a/arch/x86/include/asm/elf.h
13338 +++ b/arch/x86/include/asm/elf.h
13339 @@ -243,7 +243,25 @@ extern int force_personality32;
13340 the loader. We need to make sure that it is out of the way of the program
13341 that it will "exec", and that there is sufficient room for the brk. */
13342
13343 +#ifdef CONFIG_PAX_SEGMEXEC
13344 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13345 +#else
13346 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13347 +#endif
13348 +
13349 +#ifdef CONFIG_PAX_ASLR
13350 +#ifdef CONFIG_X86_32
13351 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13352 +
13353 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13354 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13355 +#else
13356 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13357 +
13358 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13359 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13360 +#endif
13361 +#endif
13362
13363 /* This yields a mask that user programs can use to figure out what
13364 instruction set this CPU supports. This could be done in user space,
13365 @@ -296,16 +314,12 @@ do { \
13366
13367 #define ARCH_DLINFO \
13368 do { \
13369 - if (vdso_enabled) \
13370 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13371 - (unsigned long)current->mm->context.vdso); \
13372 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13373 } while (0)
13374
13375 #define ARCH_DLINFO_X32 \
13376 do { \
13377 - if (vdso_enabled) \
13378 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13379 - (unsigned long)current->mm->context.vdso); \
13380 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13381 } while (0)
13382
13383 #define AT_SYSINFO 32
13384 @@ -320,7 +334,7 @@ else \
13385
13386 #endif /* !CONFIG_X86_32 */
13387
13388 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13389 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13390
13391 #define VDSO_ENTRY \
13392 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13393 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13394 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13395 #define compat_arch_setup_additional_pages syscall32_setup_pages
13396
13397 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13398 -#define arch_randomize_brk arch_randomize_brk
13399 -
13400 /*
13401 * True on X86_32 or when emulating IA32 on X86_64
13402 */
13403 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13404 index 75ce3f4..882e801 100644
13405 --- a/arch/x86/include/asm/emergency-restart.h
13406 +++ b/arch/x86/include/asm/emergency-restart.h
13407 @@ -13,6 +13,6 @@ enum reboot_type {
13408
13409 extern enum reboot_type reboot_type;
13410
13411 -extern void machine_emergency_restart(void);
13412 +extern void machine_emergency_restart(void) __noreturn;
13413
13414 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13415 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13416 index e25cc33..425d099 100644
13417 --- a/arch/x86/include/asm/fpu-internal.h
13418 +++ b/arch/x86/include/asm/fpu-internal.h
13419 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13420 ({ \
13421 int err; \
13422 asm volatile(ASM_STAC "\n" \
13423 - "1:" #insn "\n\t" \
13424 + "1:" \
13425 + __copyuser_seg \
13426 + #insn "\n\t" \
13427 "2: " ASM_CLAC "\n" \
13428 ".section .fixup,\"ax\"\n" \
13429 "3: movl $-1,%[err]\n" \
13430 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13431 "emms\n\t" /* clear stack tags */
13432 "fildl %P[addr]", /* set F?P to defined value */
13433 X86_FEATURE_FXSAVE_LEAK,
13434 - [addr] "m" (tsk->thread.fpu.has_fpu));
13435 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13436
13437 return fpu_restore_checking(&tsk->thread.fpu);
13438 }
13439 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13440 index be27ba1..8f13ff9 100644
13441 --- a/arch/x86/include/asm/futex.h
13442 +++ b/arch/x86/include/asm/futex.h
13443 @@ -12,6 +12,7 @@
13444 #include <asm/smap.h>
13445
13446 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13447 + typecheck(u32 __user *, uaddr); \
13448 asm volatile("\t" ASM_STAC "\n" \
13449 "1:\t" insn "\n" \
13450 "2:\t" ASM_CLAC "\n" \
13451 @@ -20,15 +21,16 @@
13452 "\tjmp\t2b\n" \
13453 "\t.previous\n" \
13454 _ASM_EXTABLE(1b, 3b) \
13455 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13456 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13457 : "i" (-EFAULT), "0" (oparg), "1" (0))
13458
13459 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13460 + typecheck(u32 __user *, uaddr); \
13461 asm volatile("\t" ASM_STAC "\n" \
13462 "1:\tmovl %2, %0\n" \
13463 "\tmovl\t%0, %3\n" \
13464 "\t" insn "\n" \
13465 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13466 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13467 "\tjnz\t1b\n" \
13468 "3:\t" ASM_CLAC "\n" \
13469 "\t.section .fixup,\"ax\"\n" \
13470 @@ -38,7 +40,7 @@
13471 _ASM_EXTABLE(1b, 4b) \
13472 _ASM_EXTABLE(2b, 4b) \
13473 : "=&a" (oldval), "=&r" (ret), \
13474 - "+m" (*uaddr), "=&r" (tem) \
13475 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13476 : "r" (oparg), "i" (-EFAULT), "1" (0))
13477
13478 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13479 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13480
13481 switch (op) {
13482 case FUTEX_OP_SET:
13483 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13484 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13485 break;
13486 case FUTEX_OP_ADD:
13487 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13488 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13489 uaddr, oparg);
13490 break;
13491 case FUTEX_OP_OR:
13492 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13493 return -EFAULT;
13494
13495 asm volatile("\t" ASM_STAC "\n"
13496 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13497 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13498 "2:\t" ASM_CLAC "\n"
13499 "\t.section .fixup, \"ax\"\n"
13500 "3:\tmov %3, %0\n"
13501 "\tjmp 2b\n"
13502 "\t.previous\n"
13503 _ASM_EXTABLE(1b, 3b)
13504 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13505 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13506 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13507 : "memory"
13508 );
13509 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13510 index 1da97ef..9c2ebff 100644
13511 --- a/arch/x86/include/asm/hw_irq.h
13512 +++ b/arch/x86/include/asm/hw_irq.h
13513 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
13514 extern void enable_IO_APIC(void);
13515
13516 /* Statistics */
13517 -extern atomic_t irq_err_count;
13518 -extern atomic_t irq_mis_count;
13519 +extern atomic_unchecked_t irq_err_count;
13520 +extern atomic_unchecked_t irq_mis_count;
13521
13522 /* EISA */
13523 extern void eisa_set_level_irq(unsigned int irq);
13524 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13525 index a203659..9889f1c 100644
13526 --- a/arch/x86/include/asm/i8259.h
13527 +++ b/arch/x86/include/asm/i8259.h
13528 @@ -62,7 +62,7 @@ struct legacy_pic {
13529 void (*init)(int auto_eoi);
13530 int (*irq_pending)(unsigned int irq);
13531 void (*make_irq)(unsigned int irq);
13532 -};
13533 +} __do_const;
13534
13535 extern struct legacy_pic *legacy_pic;
13536 extern struct legacy_pic null_legacy_pic;
13537 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13538 index d8e8eef..1765f78 100644
13539 --- a/arch/x86/include/asm/io.h
13540 +++ b/arch/x86/include/asm/io.h
13541 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13542 "m" (*(volatile type __force *)addr) barrier); }
13543
13544 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13545 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13546 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13547 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13548 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13549
13550 build_mmio_read(__readb, "b", unsigned char, "=q", )
13551 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13552 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13553 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13554 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13555
13556 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13557 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13558 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13559 return ioremap_nocache(offset, size);
13560 }
13561
13562 -extern void iounmap(volatile void __iomem *addr);
13563 +extern void iounmap(const volatile void __iomem *addr);
13564
13565 extern void set_iounmap_nonlazy(void);
13566
13567 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13568
13569 #include <linux/vmalloc.h>
13570
13571 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13572 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13573 +{
13574 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13575 +}
13576 +
13577 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13578 +{
13579 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13580 +}
13581 +
13582 /*
13583 * Convert a virtual cached pointer to an uncached pointer
13584 */
13585 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13586 index bba3cf8..06bc8da 100644
13587 --- a/arch/x86/include/asm/irqflags.h
13588 +++ b/arch/x86/include/asm/irqflags.h
13589 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13590 sti; \
13591 sysexit
13592
13593 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13594 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13595 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13596 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13597 +
13598 #else
13599 #define INTERRUPT_RETURN iret
13600 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13601 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13602 index 5a6d287..f815789 100644
13603 --- a/arch/x86/include/asm/kprobes.h
13604 +++ b/arch/x86/include/asm/kprobes.h
13605 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13606 #define RELATIVEJUMP_SIZE 5
13607 #define RELATIVECALL_OPCODE 0xe8
13608 #define RELATIVE_ADDR_SIZE 4
13609 -#define MAX_STACK_SIZE 64
13610 -#define MIN_STACK_SIZE(ADDR) \
13611 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13612 - THREAD_SIZE - (unsigned long)(ADDR))) \
13613 - ? (MAX_STACK_SIZE) \
13614 - : (((unsigned long)current_thread_info()) + \
13615 - THREAD_SIZE - (unsigned long)(ADDR)))
13616 +#define MAX_STACK_SIZE 64UL
13617 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13618
13619 #define flush_insn_slot(p) do { } while (0)
13620
13621 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13622 index 2d89e39..baee879 100644
13623 --- a/arch/x86/include/asm/local.h
13624 +++ b/arch/x86/include/asm/local.h
13625 @@ -10,33 +10,97 @@ typedef struct {
13626 atomic_long_t a;
13627 } local_t;
13628
13629 +typedef struct {
13630 + atomic_long_unchecked_t a;
13631 +} local_unchecked_t;
13632 +
13633 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13634
13635 #define local_read(l) atomic_long_read(&(l)->a)
13636 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13637 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13638 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13639
13640 static inline void local_inc(local_t *l)
13641 {
13642 - asm volatile(_ASM_INC "%0"
13643 + asm volatile(_ASM_INC "%0\n"
13644 +
13645 +#ifdef CONFIG_PAX_REFCOUNT
13646 + "jno 0f\n"
13647 + _ASM_DEC "%0\n"
13648 + "int $4\n0:\n"
13649 + _ASM_EXTABLE(0b, 0b)
13650 +#endif
13651 +
13652 + : "+m" (l->a.counter));
13653 +}
13654 +
13655 +static inline void local_inc_unchecked(local_unchecked_t *l)
13656 +{
13657 + asm volatile(_ASM_INC "%0\n"
13658 : "+m" (l->a.counter));
13659 }
13660
13661 static inline void local_dec(local_t *l)
13662 {
13663 - asm volatile(_ASM_DEC "%0"
13664 + asm volatile(_ASM_DEC "%0\n"
13665 +
13666 +#ifdef CONFIG_PAX_REFCOUNT
13667 + "jno 0f\n"
13668 + _ASM_INC "%0\n"
13669 + "int $4\n0:\n"
13670 + _ASM_EXTABLE(0b, 0b)
13671 +#endif
13672 +
13673 + : "+m" (l->a.counter));
13674 +}
13675 +
13676 +static inline void local_dec_unchecked(local_unchecked_t *l)
13677 +{
13678 + asm volatile(_ASM_DEC "%0\n"
13679 : "+m" (l->a.counter));
13680 }
13681
13682 static inline void local_add(long i, local_t *l)
13683 {
13684 - asm volatile(_ASM_ADD "%1,%0"
13685 + asm volatile(_ASM_ADD "%1,%0\n"
13686 +
13687 +#ifdef CONFIG_PAX_REFCOUNT
13688 + "jno 0f\n"
13689 + _ASM_SUB "%1,%0\n"
13690 + "int $4\n0:\n"
13691 + _ASM_EXTABLE(0b, 0b)
13692 +#endif
13693 +
13694 + : "+m" (l->a.counter)
13695 + : "ir" (i));
13696 +}
13697 +
13698 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13699 +{
13700 + asm volatile(_ASM_ADD "%1,%0\n"
13701 : "+m" (l->a.counter)
13702 : "ir" (i));
13703 }
13704
13705 static inline void local_sub(long i, local_t *l)
13706 {
13707 - asm volatile(_ASM_SUB "%1,%0"
13708 + asm volatile(_ASM_SUB "%1,%0\n"
13709 +
13710 +#ifdef CONFIG_PAX_REFCOUNT
13711 + "jno 0f\n"
13712 + _ASM_ADD "%1,%0\n"
13713 + "int $4\n0:\n"
13714 + _ASM_EXTABLE(0b, 0b)
13715 +#endif
13716 +
13717 + : "+m" (l->a.counter)
13718 + : "ir" (i));
13719 +}
13720 +
13721 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13722 +{
13723 + asm volatile(_ASM_SUB "%1,%0\n"
13724 : "+m" (l->a.counter)
13725 : "ir" (i));
13726 }
13727 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13728 {
13729 unsigned char c;
13730
13731 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13732 + asm volatile(_ASM_SUB "%2,%0\n"
13733 +
13734 +#ifdef CONFIG_PAX_REFCOUNT
13735 + "jno 0f\n"
13736 + _ASM_ADD "%2,%0\n"
13737 + "int $4\n0:\n"
13738 + _ASM_EXTABLE(0b, 0b)
13739 +#endif
13740 +
13741 + "sete %1\n"
13742 : "+m" (l->a.counter), "=qm" (c)
13743 : "ir" (i) : "memory");
13744 return c;
13745 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13746 {
13747 unsigned char c;
13748
13749 - asm volatile(_ASM_DEC "%0; sete %1"
13750 + asm volatile(_ASM_DEC "%0\n"
13751 +
13752 +#ifdef CONFIG_PAX_REFCOUNT
13753 + "jno 0f\n"
13754 + _ASM_INC "%0\n"
13755 + "int $4\n0:\n"
13756 + _ASM_EXTABLE(0b, 0b)
13757 +#endif
13758 +
13759 + "sete %1\n"
13760 : "+m" (l->a.counter), "=qm" (c)
13761 : : "memory");
13762 return c != 0;
13763 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13764 {
13765 unsigned char c;
13766
13767 - asm volatile(_ASM_INC "%0; sete %1"
13768 + asm volatile(_ASM_INC "%0\n"
13769 +
13770 +#ifdef CONFIG_PAX_REFCOUNT
13771 + "jno 0f\n"
13772 + _ASM_DEC "%0\n"
13773 + "int $4\n0:\n"
13774 + _ASM_EXTABLE(0b, 0b)
13775 +#endif
13776 +
13777 + "sete %1\n"
13778 : "+m" (l->a.counter), "=qm" (c)
13779 : : "memory");
13780 return c != 0;
13781 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13782 {
13783 unsigned char c;
13784
13785 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13786 + asm volatile(_ASM_ADD "%2,%0\n"
13787 +
13788 +#ifdef CONFIG_PAX_REFCOUNT
13789 + "jno 0f\n"
13790 + _ASM_SUB "%2,%0\n"
13791 + "int $4\n0:\n"
13792 + _ASM_EXTABLE(0b, 0b)
13793 +#endif
13794 +
13795 + "sets %1\n"
13796 : "+m" (l->a.counter), "=qm" (c)
13797 : "ir" (i) : "memory");
13798 return c;
13799 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13800 static inline long local_add_return(long i, local_t *l)
13801 {
13802 long __i = i;
13803 + asm volatile(_ASM_XADD "%0, %1\n"
13804 +
13805 +#ifdef CONFIG_PAX_REFCOUNT
13806 + "jno 0f\n"
13807 + _ASM_MOV "%0,%1\n"
13808 + "int $4\n0:\n"
13809 + _ASM_EXTABLE(0b, 0b)
13810 +#endif
13811 +
13812 + : "+r" (i), "+m" (l->a.counter)
13813 + : : "memory");
13814 + return i + __i;
13815 +}
13816 +
13817 +/**
13818 + * local_add_return_unchecked - add and return
13819 + * @i: integer value to add
13820 + * @l: pointer to type local_unchecked_t
13821 + *
13822 + * Atomically adds @i to @l and returns @i + @l
13823 + */
13824 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13825 +{
13826 + long __i = i;
13827 asm volatile(_ASM_XADD "%0, %1;"
13828 : "+r" (i), "+m" (l->a.counter)
13829 : : "memory");
13830 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13831
13832 #define local_cmpxchg(l, o, n) \
13833 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13834 +#define local_cmpxchg_unchecked(l, o, n) \
13835 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13836 /* Always has a lock prefix */
13837 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13838
13839 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13840 new file mode 100644
13841 index 0000000..2bfd3ba
13842 --- /dev/null
13843 +++ b/arch/x86/include/asm/mman.h
13844 @@ -0,0 +1,15 @@
13845 +#ifndef _X86_MMAN_H
13846 +#define _X86_MMAN_H
13847 +
13848 +#include <uapi/asm/mman.h>
13849 +
13850 +#ifdef __KERNEL__
13851 +#ifndef __ASSEMBLY__
13852 +#ifdef CONFIG_X86_32
13853 +#define arch_mmap_check i386_mmap_check
13854 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13855 +#endif
13856 +#endif
13857 +#endif
13858 +
13859 +#endif /* X86_MMAN_H */
13860 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13861 index 5f55e69..e20bfb1 100644
13862 --- a/arch/x86/include/asm/mmu.h
13863 +++ b/arch/x86/include/asm/mmu.h
13864 @@ -9,7 +9,7 @@
13865 * we put the segment information here.
13866 */
13867 typedef struct {
13868 - void *ldt;
13869 + struct desc_struct *ldt;
13870 int size;
13871
13872 #ifdef CONFIG_X86_64
13873 @@ -18,7 +18,19 @@ typedef struct {
13874 #endif
13875
13876 struct mutex lock;
13877 - void *vdso;
13878 + unsigned long vdso;
13879 +
13880 +#ifdef CONFIG_X86_32
13881 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13882 + unsigned long user_cs_base;
13883 + unsigned long user_cs_limit;
13884 +
13885 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13886 + cpumask_t cpu_user_cs_mask;
13887 +#endif
13888 +
13889 +#endif
13890 +#endif
13891 } mm_context_t;
13892
13893 #ifdef CONFIG_SMP
13894 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13895 index cdbf367..adb37ac 100644
13896 --- a/arch/x86/include/asm/mmu_context.h
13897 +++ b/arch/x86/include/asm/mmu_context.h
13898 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13899
13900 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13901 {
13902 +
13903 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13904 + unsigned int i;
13905 + pgd_t *pgd;
13906 +
13907 + pax_open_kernel();
13908 + pgd = get_cpu_pgd(smp_processor_id());
13909 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13910 + set_pgd_batched(pgd+i, native_make_pgd(0));
13911 + pax_close_kernel();
13912 +#endif
13913 +
13914 #ifdef CONFIG_SMP
13915 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13916 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13917 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13918 struct task_struct *tsk)
13919 {
13920 unsigned cpu = smp_processor_id();
13921 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13922 + int tlbstate = TLBSTATE_OK;
13923 +#endif
13924
13925 if (likely(prev != next)) {
13926 #ifdef CONFIG_SMP
13927 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13928 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13929 +#endif
13930 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13931 this_cpu_write(cpu_tlbstate.active_mm, next);
13932 #endif
13933 cpumask_set_cpu(cpu, mm_cpumask(next));
13934
13935 /* Re-load page tables */
13936 +#ifdef CONFIG_PAX_PER_CPU_PGD
13937 + pax_open_kernel();
13938 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13939 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13940 + pax_close_kernel();
13941 + load_cr3(get_cpu_pgd(cpu));
13942 +#else
13943 load_cr3(next->pgd);
13944 +#endif
13945
13946 /* stop flush ipis for the previous mm */
13947 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13948 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13949 */
13950 if (unlikely(prev->context.ldt != next->context.ldt))
13951 load_LDT_nolock(&next->context);
13952 - }
13953 +
13954 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13955 + if (!(__supported_pte_mask & _PAGE_NX)) {
13956 + smp_mb__before_clear_bit();
13957 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13958 + smp_mb__after_clear_bit();
13959 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13960 + }
13961 +#endif
13962 +
13963 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13964 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13965 + prev->context.user_cs_limit != next->context.user_cs_limit))
13966 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13967 #ifdef CONFIG_SMP
13968 + else if (unlikely(tlbstate != TLBSTATE_OK))
13969 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13970 +#endif
13971 +#endif
13972 +
13973 + }
13974 else {
13975 +
13976 +#ifdef CONFIG_PAX_PER_CPU_PGD
13977 + pax_open_kernel();
13978 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13979 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13980 + pax_close_kernel();
13981 + load_cr3(get_cpu_pgd(cpu));
13982 +#endif
13983 +
13984 +#ifdef CONFIG_SMP
13985 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13986 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13987
13988 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13989 * tlb flush IPI delivery. We must reload CR3
13990 * to make sure to use no freed page tables.
13991 */
13992 +
13993 +#ifndef CONFIG_PAX_PER_CPU_PGD
13994 load_cr3(next->pgd);
13995 +#endif
13996 +
13997 load_LDT_nolock(&next->context);
13998 +
13999 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14000 + if (!(__supported_pte_mask & _PAGE_NX))
14001 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14002 +#endif
14003 +
14004 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14005 +#ifdef CONFIG_PAX_PAGEEXEC
14006 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14007 +#endif
14008 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14009 +#endif
14010 +
14011 }
14012 +#endif
14013 }
14014 -#endif
14015 }
14016
14017 #define activate_mm(prev, next) \
14018 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14019 index e3b7819..b257c64 100644
14020 --- a/arch/x86/include/asm/module.h
14021 +++ b/arch/x86/include/asm/module.h
14022 @@ -5,6 +5,7 @@
14023
14024 #ifdef CONFIG_X86_64
14025 /* X86_64 does not define MODULE_PROC_FAMILY */
14026 +#define MODULE_PROC_FAMILY ""
14027 #elif defined CONFIG_M486
14028 #define MODULE_PROC_FAMILY "486 "
14029 #elif defined CONFIG_M586
14030 @@ -57,8 +58,20 @@
14031 #error unknown processor family
14032 #endif
14033
14034 -#ifdef CONFIG_X86_32
14035 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14036 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14037 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14038 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14039 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14040 +#else
14041 +#define MODULE_PAX_KERNEXEC ""
14042 #endif
14043
14044 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14045 +#define MODULE_PAX_UDEREF "UDEREF "
14046 +#else
14047 +#define MODULE_PAX_UDEREF ""
14048 +#endif
14049 +
14050 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14051 +
14052 #endif /* _ASM_X86_MODULE_H */
14053 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14054 index 86f9301..b365cda 100644
14055 --- a/arch/x86/include/asm/nmi.h
14056 +++ b/arch/x86/include/asm/nmi.h
14057 @@ -40,11 +40,11 @@ struct nmiaction {
14058 nmi_handler_t handler;
14059 unsigned long flags;
14060 const char *name;
14061 -};
14062 +} __do_const;
14063
14064 #define register_nmi_handler(t, fn, fg, n, init...) \
14065 ({ \
14066 - static struct nmiaction init fn##_na = { \
14067 + static const struct nmiaction init fn##_na = { \
14068 .handler = (fn), \
14069 .name = (n), \
14070 .flags = (fg), \
14071 @@ -52,7 +52,7 @@ struct nmiaction {
14072 __register_nmi_handler((t), &fn##_na); \
14073 })
14074
14075 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14076 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14077
14078 void unregister_nmi_handler(unsigned int, const char *);
14079
14080 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
14081 index c878924..21f4889 100644
14082 --- a/arch/x86/include/asm/page.h
14083 +++ b/arch/x86/include/asm/page.h
14084 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
14085 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
14086
14087 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
14088 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
14089
14090 #define __boot_va(x) __va(x)
14091 #define __boot_pa(x) __pa(x)
14092 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14093 index 0f1ddee..e2fc3d1 100644
14094 --- a/arch/x86/include/asm/page_64.h
14095 +++ b/arch/x86/include/asm/page_64.h
14096 @@ -7,9 +7,9 @@
14097
14098 /* duplicated to the one in bootmem.h */
14099 extern unsigned long max_pfn;
14100 -extern unsigned long phys_base;
14101 +extern const unsigned long phys_base;
14102
14103 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14104 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14105 {
14106 unsigned long y = x - __START_KERNEL_map;
14107
14108 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14109 index cfdc9ee..3f7b5d6 100644
14110 --- a/arch/x86/include/asm/paravirt.h
14111 +++ b/arch/x86/include/asm/paravirt.h
14112 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
14113 return (pmd_t) { ret };
14114 }
14115
14116 -static inline pmdval_t pmd_val(pmd_t pmd)
14117 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14118 {
14119 pmdval_t ret;
14120
14121 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14122 val);
14123 }
14124
14125 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14126 +{
14127 + pgdval_t val = native_pgd_val(pgd);
14128 +
14129 + if (sizeof(pgdval_t) > sizeof(long))
14130 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14131 + val, (u64)val >> 32);
14132 + else
14133 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14134 + val);
14135 +}
14136 +
14137 static inline void pgd_clear(pgd_t *pgdp)
14138 {
14139 set_pgd(pgdp, __pgd(0));
14140 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14141 pv_mmu_ops.set_fixmap(idx, phys, flags);
14142 }
14143
14144 +#ifdef CONFIG_PAX_KERNEXEC
14145 +static inline unsigned long pax_open_kernel(void)
14146 +{
14147 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14148 +}
14149 +
14150 +static inline unsigned long pax_close_kernel(void)
14151 +{
14152 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14153 +}
14154 +#else
14155 +static inline unsigned long pax_open_kernel(void) { return 0; }
14156 +static inline unsigned long pax_close_kernel(void) { return 0; }
14157 +#endif
14158 +
14159 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14160
14161 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14162 @@ -926,7 +953,7 @@ extern void default_banner(void);
14163
14164 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14165 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14166 -#define PARA_INDIRECT(addr) *%cs:addr
14167 +#define PARA_INDIRECT(addr) *%ss:addr
14168 #endif
14169
14170 #define INTERRUPT_RETURN \
14171 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
14172 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14173 CLBR_NONE, \
14174 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14175 +
14176 +#define GET_CR0_INTO_RDI \
14177 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14178 + mov %rax,%rdi
14179 +
14180 +#define SET_RDI_INTO_CR0 \
14181 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14182 +
14183 +#define GET_CR3_INTO_RDI \
14184 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14185 + mov %rax,%rdi
14186 +
14187 +#define SET_RDI_INTO_CR3 \
14188 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14189 +
14190 #endif /* CONFIG_X86_32 */
14191
14192 #endif /* __ASSEMBLY__ */
14193 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14194 index 0db1fca..52310cc 100644
14195 --- a/arch/x86/include/asm/paravirt_types.h
14196 +++ b/arch/x86/include/asm/paravirt_types.h
14197 @@ -84,7 +84,7 @@ struct pv_init_ops {
14198 */
14199 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14200 unsigned long addr, unsigned len);
14201 -};
14202 +} __no_const;
14203
14204
14205 struct pv_lazy_ops {
14206 @@ -98,7 +98,7 @@ struct pv_time_ops {
14207 unsigned long long (*sched_clock)(void);
14208 unsigned long long (*steal_clock)(int cpu);
14209 unsigned long (*get_tsc_khz)(void);
14210 -};
14211 +} __no_const;
14212
14213 struct pv_cpu_ops {
14214 /* hooks for various privileged instructions */
14215 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14216
14217 void (*start_context_switch)(struct task_struct *prev);
14218 void (*end_context_switch)(struct task_struct *next);
14219 -};
14220 +} __no_const;
14221
14222 struct pv_irq_ops {
14223 /*
14224 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14225 unsigned long start_eip,
14226 unsigned long start_esp);
14227 #endif
14228 -};
14229 +} __no_const;
14230
14231 struct pv_mmu_ops {
14232 unsigned long (*read_cr2)(void);
14233 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14234 struct paravirt_callee_save make_pud;
14235
14236 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14237 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14238 #endif /* PAGETABLE_LEVELS == 4 */
14239 #endif /* PAGETABLE_LEVELS >= 3 */
14240
14241 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14242 an mfn. We can tell which is which from the index. */
14243 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14244 phys_addr_t phys, pgprot_t flags);
14245 +
14246 +#ifdef CONFIG_PAX_KERNEXEC
14247 + unsigned long (*pax_open_kernel)(void);
14248 + unsigned long (*pax_close_kernel)(void);
14249 +#endif
14250 +
14251 };
14252
14253 struct arch_spinlock;
14254 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14255 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14256 int (*spin_trylock)(struct arch_spinlock *lock);
14257 void (*spin_unlock)(struct arch_spinlock *lock);
14258 -};
14259 +} __no_const;
14260
14261 /* This contains all the paravirt structures: we get a convenient
14262 * number for each function using the offset which we use to indicate
14263 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14264 index b4389a4..7024269 100644
14265 --- a/arch/x86/include/asm/pgalloc.h
14266 +++ b/arch/x86/include/asm/pgalloc.h
14267 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14268 pmd_t *pmd, pte_t *pte)
14269 {
14270 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14271 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14272 +}
14273 +
14274 +static inline void pmd_populate_user(struct mm_struct *mm,
14275 + pmd_t *pmd, pte_t *pte)
14276 +{
14277 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14278 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14279 }
14280
14281 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14282
14283 #ifdef CONFIG_X86_PAE
14284 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14285 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14286 +{
14287 + pud_populate(mm, pudp, pmd);
14288 +}
14289 #else /* !CONFIG_X86_PAE */
14290 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14291 {
14292 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14293 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14294 }
14295 +
14296 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14297 +{
14298 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14299 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14300 +}
14301 #endif /* CONFIG_X86_PAE */
14302
14303 #if PAGETABLE_LEVELS > 3
14304 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14305 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14306 }
14307
14308 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14309 +{
14310 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14311 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14312 +}
14313 +
14314 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14315 {
14316 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14317 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14318 index f2b489c..4f7e2e5 100644
14319 --- a/arch/x86/include/asm/pgtable-2level.h
14320 +++ b/arch/x86/include/asm/pgtable-2level.h
14321 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14322
14323 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14324 {
14325 + pax_open_kernel();
14326 *pmdp = pmd;
14327 + pax_close_kernel();
14328 }
14329
14330 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14331 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14332 index 4cc9f2b..5fd9226 100644
14333 --- a/arch/x86/include/asm/pgtable-3level.h
14334 +++ b/arch/x86/include/asm/pgtable-3level.h
14335 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14336
14337 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14338 {
14339 + pax_open_kernel();
14340 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14341 + pax_close_kernel();
14342 }
14343
14344 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14345 {
14346 + pax_open_kernel();
14347 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14348 + pax_close_kernel();
14349 }
14350
14351 /*
14352 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14353 index 1e67223..dd6e7ea 100644
14354 --- a/arch/x86/include/asm/pgtable.h
14355 +++ b/arch/x86/include/asm/pgtable.h
14356 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14357
14358 #ifndef __PAGETABLE_PUD_FOLDED
14359 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14360 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14361 #define pgd_clear(pgd) native_pgd_clear(pgd)
14362 #endif
14363
14364 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14365
14366 #define arch_end_context_switch(prev) do {} while(0)
14367
14368 +#define pax_open_kernel() native_pax_open_kernel()
14369 +#define pax_close_kernel() native_pax_close_kernel()
14370 #endif /* CONFIG_PARAVIRT */
14371
14372 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14373 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14374 +
14375 +#ifdef CONFIG_PAX_KERNEXEC
14376 +static inline unsigned long native_pax_open_kernel(void)
14377 +{
14378 + unsigned long cr0;
14379 +
14380 + preempt_disable();
14381 + barrier();
14382 + cr0 = read_cr0() ^ X86_CR0_WP;
14383 + BUG_ON(cr0 & X86_CR0_WP);
14384 + write_cr0(cr0);
14385 + return cr0 ^ X86_CR0_WP;
14386 +}
14387 +
14388 +static inline unsigned long native_pax_close_kernel(void)
14389 +{
14390 + unsigned long cr0;
14391 +
14392 + cr0 = read_cr0() ^ X86_CR0_WP;
14393 + BUG_ON(!(cr0 & X86_CR0_WP));
14394 + write_cr0(cr0);
14395 + barrier();
14396 + preempt_enable_no_resched();
14397 + return cr0 ^ X86_CR0_WP;
14398 +}
14399 +#else
14400 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14401 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14402 +#endif
14403 +
14404 /*
14405 * The following only work if pte_present() is true.
14406 * Undefined behaviour if not..
14407 */
14408 +static inline int pte_user(pte_t pte)
14409 +{
14410 + return pte_val(pte) & _PAGE_USER;
14411 +}
14412 +
14413 static inline int pte_dirty(pte_t pte)
14414 {
14415 return pte_flags(pte) & _PAGE_DIRTY;
14416 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14417 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14418 }
14419
14420 +static inline unsigned long pgd_pfn(pgd_t pgd)
14421 +{
14422 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14423 +}
14424 +
14425 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14426
14427 static inline int pmd_large(pmd_t pte)
14428 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14429 return pte_clear_flags(pte, _PAGE_RW);
14430 }
14431
14432 +static inline pte_t pte_mkread(pte_t pte)
14433 +{
14434 + return __pte(pte_val(pte) | _PAGE_USER);
14435 +}
14436 +
14437 static inline pte_t pte_mkexec(pte_t pte)
14438 {
14439 - return pte_clear_flags(pte, _PAGE_NX);
14440 +#ifdef CONFIG_X86_PAE
14441 + if (__supported_pte_mask & _PAGE_NX)
14442 + return pte_clear_flags(pte, _PAGE_NX);
14443 + else
14444 +#endif
14445 + return pte_set_flags(pte, _PAGE_USER);
14446 +}
14447 +
14448 +static inline pte_t pte_exprotect(pte_t pte)
14449 +{
14450 +#ifdef CONFIG_X86_PAE
14451 + if (__supported_pte_mask & _PAGE_NX)
14452 + return pte_set_flags(pte, _PAGE_NX);
14453 + else
14454 +#endif
14455 + return pte_clear_flags(pte, _PAGE_USER);
14456 }
14457
14458 static inline pte_t pte_mkdirty(pte_t pte)
14459 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14460 #endif
14461
14462 #ifndef __ASSEMBLY__
14463 +
14464 +#ifdef CONFIG_PAX_PER_CPU_PGD
14465 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14466 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14467 +{
14468 + return cpu_pgd[cpu];
14469 +}
14470 +#endif
14471 +
14472 #include <linux/mm_types.h>
14473 #include <linux/log2.h>
14474
14475 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14476 * Currently stuck as a macro due to indirect forward reference to
14477 * linux/mmzone.h's __section_mem_map_addr() definition:
14478 */
14479 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14480 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14481
14482 /* Find an entry in the second-level page table.. */
14483 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14484 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14485 * Currently stuck as a macro due to indirect forward reference to
14486 * linux/mmzone.h's __section_mem_map_addr() definition:
14487 */
14488 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14489 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14490
14491 /* to find an entry in a page-table-directory. */
14492 static inline unsigned long pud_index(unsigned long address)
14493 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14494
14495 static inline int pgd_bad(pgd_t pgd)
14496 {
14497 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14498 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14499 }
14500
14501 static inline int pgd_none(pgd_t pgd)
14502 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14503 * pgd_offset() returns a (pgd_t *)
14504 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14505 */
14506 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14507 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14508 +
14509 +#ifdef CONFIG_PAX_PER_CPU_PGD
14510 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14511 +#endif
14512 +
14513 /*
14514 * a shortcut which implies the use of the kernel's pgd, instead
14515 * of a process's
14516 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14517 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14518 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14519
14520 +#ifdef CONFIG_X86_32
14521 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14522 +#else
14523 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14524 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14525 +
14526 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14527 +#ifdef __ASSEMBLY__
14528 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14529 +#else
14530 +extern unsigned long pax_user_shadow_base;
14531 +#endif
14532 +#endif
14533 +
14534 +#endif
14535 +
14536 #ifndef __ASSEMBLY__
14537
14538 extern int direct_gbpages;
14539 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14540 * dst and src can be on the same page, but the range must not overlap,
14541 * and must not cross a page boundary.
14542 */
14543 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14544 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14545 {
14546 - memcpy(dst, src, count * sizeof(pgd_t));
14547 + pax_open_kernel();
14548 + while (count--)
14549 + *dst++ = *src++;
14550 + pax_close_kernel();
14551 }
14552
14553 +#ifdef CONFIG_PAX_PER_CPU_PGD
14554 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14555 +#endif
14556 +
14557 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14558 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14559 +#else
14560 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14561 +#endif
14562 +
14563 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14564 static inline int page_level_shift(enum pg_level level)
14565 {
14566 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14567 index 9ee3221..b979c6b 100644
14568 --- a/arch/x86/include/asm/pgtable_32.h
14569 +++ b/arch/x86/include/asm/pgtable_32.h
14570 @@ -25,9 +25,6 @@
14571 struct mm_struct;
14572 struct vm_area_struct;
14573
14574 -extern pgd_t swapper_pg_dir[1024];
14575 -extern pgd_t initial_page_table[1024];
14576 -
14577 static inline void pgtable_cache_init(void) { }
14578 static inline void check_pgt_cache(void) { }
14579 void paging_init(void);
14580 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14581 # include <asm/pgtable-2level.h>
14582 #endif
14583
14584 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14585 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14586 +#ifdef CONFIG_X86_PAE
14587 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14588 +#endif
14589 +
14590 #if defined(CONFIG_HIGHPTE)
14591 #define pte_offset_map(dir, address) \
14592 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14593 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14594 /* Clear a kernel PTE and flush it from the TLB */
14595 #define kpte_clear_flush(ptep, vaddr) \
14596 do { \
14597 + pax_open_kernel(); \
14598 pte_clear(&init_mm, (vaddr), (ptep)); \
14599 + pax_close_kernel(); \
14600 __flush_tlb_one((vaddr)); \
14601 } while (0)
14602
14603 #endif /* !__ASSEMBLY__ */
14604
14605 +#define HAVE_ARCH_UNMAPPED_AREA
14606 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14607 +
14608 /*
14609 * kern_addr_valid() is (1) for FLATMEM and (0) for
14610 * SPARSEMEM and DISCONTIGMEM
14611 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14612 index ed5903b..c7fe163 100644
14613 --- a/arch/x86/include/asm/pgtable_32_types.h
14614 +++ b/arch/x86/include/asm/pgtable_32_types.h
14615 @@ -8,7 +8,7 @@
14616 */
14617 #ifdef CONFIG_X86_PAE
14618 # include <asm/pgtable-3level_types.h>
14619 -# define PMD_SIZE (1UL << PMD_SHIFT)
14620 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14621 # define PMD_MASK (~(PMD_SIZE - 1))
14622 #else
14623 # include <asm/pgtable-2level_types.h>
14624 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14625 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14626 #endif
14627
14628 +#ifdef CONFIG_PAX_KERNEXEC
14629 +#ifndef __ASSEMBLY__
14630 +extern unsigned char MODULES_EXEC_VADDR[];
14631 +extern unsigned char MODULES_EXEC_END[];
14632 +#endif
14633 +#include <asm/boot.h>
14634 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14635 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14636 +#else
14637 +#define ktla_ktva(addr) (addr)
14638 +#define ktva_ktla(addr) (addr)
14639 +#endif
14640 +
14641 #define MODULES_VADDR VMALLOC_START
14642 #define MODULES_END VMALLOC_END
14643 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14644 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14645 index e22c1db..23a625a 100644
14646 --- a/arch/x86/include/asm/pgtable_64.h
14647 +++ b/arch/x86/include/asm/pgtable_64.h
14648 @@ -16,10 +16,14 @@
14649
14650 extern pud_t level3_kernel_pgt[512];
14651 extern pud_t level3_ident_pgt[512];
14652 +extern pud_t level3_vmalloc_start_pgt[512];
14653 +extern pud_t level3_vmalloc_end_pgt[512];
14654 +extern pud_t level3_vmemmap_pgt[512];
14655 +extern pud_t level2_vmemmap_pgt[512];
14656 extern pmd_t level2_kernel_pgt[512];
14657 extern pmd_t level2_fixmap_pgt[512];
14658 -extern pmd_t level2_ident_pgt[512];
14659 -extern pgd_t init_level4_pgt[];
14660 +extern pmd_t level2_ident_pgt[512*2];
14661 +extern pgd_t init_level4_pgt[512];
14662
14663 #define swapper_pg_dir init_level4_pgt
14664
14665 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14666
14667 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14668 {
14669 + pax_open_kernel();
14670 *pmdp = pmd;
14671 + pax_close_kernel();
14672 }
14673
14674 static inline void native_pmd_clear(pmd_t *pmd)
14675 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14676
14677 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14678 {
14679 + pax_open_kernel();
14680 *pudp = pud;
14681 + pax_close_kernel();
14682 }
14683
14684 static inline void native_pud_clear(pud_t *pud)
14685 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14686
14687 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14688 {
14689 + pax_open_kernel();
14690 + *pgdp = pgd;
14691 + pax_close_kernel();
14692 +}
14693 +
14694 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14695 +{
14696 *pgdp = pgd;
14697 }
14698
14699 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14700 index 2d88344..4679fc3 100644
14701 --- a/arch/x86/include/asm/pgtable_64_types.h
14702 +++ b/arch/x86/include/asm/pgtable_64_types.h
14703 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14704 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14705 #define MODULES_END _AC(0xffffffffff000000, UL)
14706 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14707 +#define MODULES_EXEC_VADDR MODULES_VADDR
14708 +#define MODULES_EXEC_END MODULES_END
14709 +
14710 +#define ktla_ktva(addr) (addr)
14711 +#define ktva_ktla(addr) (addr)
14712
14713 #define EARLY_DYNAMIC_PAGE_TABLES 64
14714
14715 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14716 index e642300..0ef8f31 100644
14717 --- a/arch/x86/include/asm/pgtable_types.h
14718 +++ b/arch/x86/include/asm/pgtable_types.h
14719 @@ -16,13 +16,12 @@
14720 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14721 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14722 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14723 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14724 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14725 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14726 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14727 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14728 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14729 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14730 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14731 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14732 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14733 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14734
14735 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14736 @@ -40,7 +39,6 @@
14737 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14738 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14739 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14740 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14741 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14742 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14743 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14744 @@ -57,8 +55,10 @@
14745
14746 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14747 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14748 -#else
14749 +#elif defined(CONFIG_KMEMCHECK)
14750 #define _PAGE_NX (_AT(pteval_t, 0))
14751 +#else
14752 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14753 #endif
14754
14755 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14756 @@ -116,6 +116,9 @@
14757 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14758 _PAGE_ACCESSED)
14759
14760 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14761 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14762 +
14763 #define __PAGE_KERNEL_EXEC \
14764 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14765 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14766 @@ -126,7 +129,7 @@
14767 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14768 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14769 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14770 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14771 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14772 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14773 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14774 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14775 @@ -188,8 +191,8 @@
14776 * bits are combined, this will alow user to access the high address mapped
14777 * VDSO in the presence of CONFIG_COMPAT_VDSO
14778 */
14779 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14780 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14781 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14782 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14783 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14784 #endif
14785
14786 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14787 {
14788 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14789 }
14790 +#endif
14791
14792 +#if PAGETABLE_LEVELS == 3
14793 +#include <asm-generic/pgtable-nopud.h>
14794 +#endif
14795 +
14796 +#if PAGETABLE_LEVELS == 2
14797 +#include <asm-generic/pgtable-nopmd.h>
14798 +#endif
14799 +
14800 +#ifndef __ASSEMBLY__
14801 #if PAGETABLE_LEVELS > 3
14802 typedef struct { pudval_t pud; } pud_t;
14803
14804 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14805 return pud.pud;
14806 }
14807 #else
14808 -#include <asm-generic/pgtable-nopud.h>
14809 -
14810 static inline pudval_t native_pud_val(pud_t pud)
14811 {
14812 return native_pgd_val(pud.pgd);
14813 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14814 return pmd.pmd;
14815 }
14816 #else
14817 -#include <asm-generic/pgtable-nopmd.h>
14818 -
14819 static inline pmdval_t native_pmd_val(pmd_t pmd)
14820 {
14821 return native_pgd_val(pmd.pud.pgd);
14822 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14823
14824 extern pteval_t __supported_pte_mask;
14825 extern void set_nx(void);
14826 -extern int nx_enabled;
14827
14828 #define pgprot_writecombine pgprot_writecombine
14829 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14830 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14831 index 22224b3..4080dab 100644
14832 --- a/arch/x86/include/asm/processor.h
14833 +++ b/arch/x86/include/asm/processor.h
14834 @@ -282,7 +282,7 @@ struct tss_struct {
14835
14836 } ____cacheline_aligned;
14837
14838 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14839 +extern struct tss_struct init_tss[NR_CPUS];
14840
14841 /*
14842 * Save the original ist values for checking stack pointers during debugging
14843 @@ -823,11 +823,18 @@ static inline void spin_lock_prefetch(const void *x)
14844 */
14845 #define TASK_SIZE PAGE_OFFSET
14846 #define TASK_SIZE_MAX TASK_SIZE
14847 +
14848 +#ifdef CONFIG_PAX_SEGMEXEC
14849 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14850 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14851 +#else
14852 #define STACK_TOP TASK_SIZE
14853 -#define STACK_TOP_MAX STACK_TOP
14854 +#endif
14855 +
14856 +#define STACK_TOP_MAX TASK_SIZE
14857
14858 #define INIT_THREAD { \
14859 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14860 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14861 .vm86_info = NULL, \
14862 .sysenter_cs = __KERNEL_CS, \
14863 .io_bitmap_ptr = NULL, \
14864 @@ -841,7 +848,7 @@ static inline void spin_lock_prefetch(const void *x)
14865 */
14866 #define INIT_TSS { \
14867 .x86_tss = { \
14868 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14869 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14870 .ss0 = __KERNEL_DS, \
14871 .ss1 = __KERNEL_CS, \
14872 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14873 @@ -852,11 +859,7 @@ static inline void spin_lock_prefetch(const void *x)
14874 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14875
14876 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14877 -#define KSTK_TOP(info) \
14878 -({ \
14879 - unsigned long *__ptr = (unsigned long *)(info); \
14880 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14881 -})
14882 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14883
14884 /*
14885 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14886 @@ -871,7 +874,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14887 #define task_pt_regs(task) \
14888 ({ \
14889 struct pt_regs *__regs__; \
14890 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14891 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14892 __regs__ - 1; \
14893 })
14894
14895 @@ -881,13 +884,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14896 /*
14897 * User space process size. 47bits minus one guard page.
14898 */
14899 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14900 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14901
14902 /* This decides where the kernel will search for a free chunk of vm
14903 * space during mmap's.
14904 */
14905 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14906 - 0xc0000000 : 0xFFFFe000)
14907 + 0xc0000000 : 0xFFFFf000)
14908
14909 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14910 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14911 @@ -898,11 +901,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14912 #define STACK_TOP_MAX TASK_SIZE_MAX
14913
14914 #define INIT_THREAD { \
14915 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14916 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14917 }
14918
14919 #define INIT_TSS { \
14920 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14921 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14922 }
14923
14924 /*
14925 @@ -930,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14926 */
14927 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14928
14929 +#ifdef CONFIG_PAX_SEGMEXEC
14930 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14931 +#endif
14932 +
14933 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14934
14935 /* Get/set a process' ability to use the timestamp counter instruction */
14936 @@ -970,7 +977,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
14937 return ratio;
14938 }
14939
14940 -extern unsigned long arch_align_stack(unsigned long sp);
14941 +#define arch_align_stack(x) ((x) & ~0xfUL)
14942 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14943
14944 void default_idle(void);
14945 @@ -980,6 +987,6 @@ bool xen_set_default_idle(void);
14946 #define xen_set_default_idle 0
14947 #endif
14948
14949 -void stop_this_cpu(void *dummy);
14950 +void stop_this_cpu(void *dummy) __noreturn;
14951
14952 #endif /* _ASM_X86_PROCESSOR_H */
14953 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14954 index 942a086..6c26446 100644
14955 --- a/arch/x86/include/asm/ptrace.h
14956 +++ b/arch/x86/include/asm/ptrace.h
14957 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14958 }
14959
14960 /*
14961 - * user_mode_vm(regs) determines whether a register set came from user mode.
14962 + * user_mode(regs) determines whether a register set came from user mode.
14963 * This is true if V8086 mode was enabled OR if the register set was from
14964 * protected mode with RPL-3 CS value. This tricky test checks that with
14965 * one comparison. Many places in the kernel can bypass this full check
14966 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14967 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14968 + * be used.
14969 */
14970 -static inline int user_mode(struct pt_regs *regs)
14971 +static inline int user_mode_novm(struct pt_regs *regs)
14972 {
14973 #ifdef CONFIG_X86_32
14974 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14975 #else
14976 - return !!(regs->cs & 3);
14977 + return !!(regs->cs & SEGMENT_RPL_MASK);
14978 #endif
14979 }
14980
14981 -static inline int user_mode_vm(struct pt_regs *regs)
14982 +static inline int user_mode(struct pt_regs *regs)
14983 {
14984 #ifdef CONFIG_X86_32
14985 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14986 USER_RPL;
14987 #else
14988 - return user_mode(regs);
14989 + return user_mode_novm(regs);
14990 #endif
14991 }
14992
14993 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14994 #ifdef CONFIG_X86_64
14995 static inline bool user_64bit_mode(struct pt_regs *regs)
14996 {
14997 + unsigned long cs = regs->cs & 0xffff;
14998 #ifndef CONFIG_PARAVIRT
14999 /*
15000 * On non-paravirt systems, this is the only long mode CPL 3
15001 * selector. We do not allow long mode selectors in the LDT.
15002 */
15003 - return regs->cs == __USER_CS;
15004 + return cs == __USER_CS;
15005 #else
15006 /* Headers are too twisted for this to go in paravirt.h. */
15007 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15008 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15009 #endif
15010 }
15011
15012 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15013 * Traps from the kernel do not save sp and ss.
15014 * Use the helper function to retrieve sp.
15015 */
15016 - if (offset == offsetof(struct pt_regs, sp) &&
15017 - regs->cs == __KERNEL_CS)
15018 - return kernel_stack_pointer(regs);
15019 + if (offset == offsetof(struct pt_regs, sp)) {
15020 + unsigned long cs = regs->cs & 0xffff;
15021 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15022 + return kernel_stack_pointer(regs);
15023 + }
15024 #endif
15025 return *(unsigned long *)((unsigned long)regs + offset);
15026 }
15027 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15028 index 9c6b890..5305f53 100644
15029 --- a/arch/x86/include/asm/realmode.h
15030 +++ b/arch/x86/include/asm/realmode.h
15031 @@ -22,16 +22,14 @@ struct real_mode_header {
15032 #endif
15033 /* APM/BIOS reboot */
15034 u32 machine_real_restart_asm;
15035 -#ifdef CONFIG_X86_64
15036 u32 machine_real_restart_seg;
15037 -#endif
15038 };
15039
15040 /* This must match data at trampoline_32/64.S */
15041 struct trampoline_header {
15042 #ifdef CONFIG_X86_32
15043 u32 start;
15044 - u16 gdt_pad;
15045 + u16 boot_cs;
15046 u16 gdt_limit;
15047 u32 gdt_base;
15048 #else
15049 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15050 index a82c4f1..ac45053 100644
15051 --- a/arch/x86/include/asm/reboot.h
15052 +++ b/arch/x86/include/asm/reboot.h
15053 @@ -6,13 +6,13 @@
15054 struct pt_regs;
15055
15056 struct machine_ops {
15057 - void (*restart)(char *cmd);
15058 - void (*halt)(void);
15059 - void (*power_off)(void);
15060 + void (* __noreturn restart)(char *cmd);
15061 + void (* __noreturn halt)(void);
15062 + void (* __noreturn power_off)(void);
15063 void (*shutdown)(void);
15064 void (*crash_shutdown)(struct pt_regs *);
15065 - void (*emergency_restart)(void);
15066 -};
15067 + void (* __noreturn emergency_restart)(void);
15068 +} __no_const;
15069
15070 extern struct machine_ops machine_ops;
15071
15072 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15073 index cad82c9..2e5c5c1 100644
15074 --- a/arch/x86/include/asm/rwsem.h
15075 +++ b/arch/x86/include/asm/rwsem.h
15076 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15077 {
15078 asm volatile("# beginning down_read\n\t"
15079 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15080 +
15081 +#ifdef CONFIG_PAX_REFCOUNT
15082 + "jno 0f\n"
15083 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15084 + "int $4\n0:\n"
15085 + _ASM_EXTABLE(0b, 0b)
15086 +#endif
15087 +
15088 /* adds 0x00000001 */
15089 " jns 1f\n"
15090 " call call_rwsem_down_read_failed\n"
15091 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15092 "1:\n\t"
15093 " mov %1,%2\n\t"
15094 " add %3,%2\n\t"
15095 +
15096 +#ifdef CONFIG_PAX_REFCOUNT
15097 + "jno 0f\n"
15098 + "sub %3,%2\n"
15099 + "int $4\n0:\n"
15100 + _ASM_EXTABLE(0b, 0b)
15101 +#endif
15102 +
15103 " jle 2f\n\t"
15104 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15105 " jnz 1b\n\t"
15106 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15107 long tmp;
15108 asm volatile("# beginning down_write\n\t"
15109 LOCK_PREFIX " xadd %1,(%2)\n\t"
15110 +
15111 +#ifdef CONFIG_PAX_REFCOUNT
15112 + "jno 0f\n"
15113 + "mov %1,(%2)\n"
15114 + "int $4\n0:\n"
15115 + _ASM_EXTABLE(0b, 0b)
15116 +#endif
15117 +
15118 /* adds 0xffff0001, returns the old value */
15119 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
15120 /* was the active mask 0 before? */
15121 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15122 long tmp;
15123 asm volatile("# beginning __up_read\n\t"
15124 LOCK_PREFIX " xadd %1,(%2)\n\t"
15125 +
15126 +#ifdef CONFIG_PAX_REFCOUNT
15127 + "jno 0f\n"
15128 + "mov %1,(%2)\n"
15129 + "int $4\n0:\n"
15130 + _ASM_EXTABLE(0b, 0b)
15131 +#endif
15132 +
15133 /* subtracts 1, returns the old value */
15134 " jns 1f\n\t"
15135 " call call_rwsem_wake\n" /* expects old value in %edx */
15136 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15137 long tmp;
15138 asm volatile("# beginning __up_write\n\t"
15139 LOCK_PREFIX " xadd %1,(%2)\n\t"
15140 +
15141 +#ifdef CONFIG_PAX_REFCOUNT
15142 + "jno 0f\n"
15143 + "mov %1,(%2)\n"
15144 + "int $4\n0:\n"
15145 + _ASM_EXTABLE(0b, 0b)
15146 +#endif
15147 +
15148 /* subtracts 0xffff0001, returns the old value */
15149 " jns 1f\n\t"
15150 " call call_rwsem_wake\n" /* expects old value in %edx */
15151 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15152 {
15153 asm volatile("# beginning __downgrade_write\n\t"
15154 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15155 +
15156 +#ifdef CONFIG_PAX_REFCOUNT
15157 + "jno 0f\n"
15158 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15159 + "int $4\n0:\n"
15160 + _ASM_EXTABLE(0b, 0b)
15161 +#endif
15162 +
15163 /*
15164 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15165 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15166 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15167 */
15168 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15169 {
15170 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15171 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15172 +
15173 +#ifdef CONFIG_PAX_REFCOUNT
15174 + "jno 0f\n"
15175 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15176 + "int $4\n0:\n"
15177 + _ASM_EXTABLE(0b, 0b)
15178 +#endif
15179 +
15180 : "+m" (sem->count)
15181 : "er" (delta));
15182 }
15183 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15184 */
15185 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15186 {
15187 - return delta + xadd(&sem->count, delta);
15188 + return delta + xadd_check_overflow(&sem->count, delta);
15189 }
15190
15191 #endif /* __KERNEL__ */
15192 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15193 index c48a950..c6d7468 100644
15194 --- a/arch/x86/include/asm/segment.h
15195 +++ b/arch/x86/include/asm/segment.h
15196 @@ -64,10 +64,15 @@
15197 * 26 - ESPFIX small SS
15198 * 27 - per-cpu [ offset to per-cpu data area ]
15199 * 28 - stack_canary-20 [ for stack protector ]
15200 - * 29 - unused
15201 - * 30 - unused
15202 + * 29 - PCI BIOS CS
15203 + * 30 - PCI BIOS DS
15204 * 31 - TSS for double fault handler
15205 */
15206 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15207 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15208 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15209 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15210 +
15211 #define GDT_ENTRY_TLS_MIN 6
15212 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15213
15214 @@ -79,6 +84,8 @@
15215
15216 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15217
15218 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15219 +
15220 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15221
15222 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15223 @@ -104,6 +111,12 @@
15224 #define __KERNEL_STACK_CANARY 0
15225 #endif
15226
15227 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15228 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15229 +
15230 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15231 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15232 +
15233 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15234
15235 /*
15236 @@ -141,7 +154,7 @@
15237 */
15238
15239 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15240 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15241 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15242
15243
15244 #else
15245 @@ -165,6 +178,8 @@
15246 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15247 #define __USER32_DS __USER_DS
15248
15249 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15250 +
15251 #define GDT_ENTRY_TSS 8 /* needs two entries */
15252 #define GDT_ENTRY_LDT 10 /* needs two entries */
15253 #define GDT_ENTRY_TLS_MIN 12
15254 @@ -185,6 +200,7 @@
15255 #endif
15256
15257 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15258 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15259 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15260 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15261 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15262 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15263 {
15264 unsigned long __limit;
15265 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15266 - return __limit + 1;
15267 + return __limit;
15268 }
15269
15270 #endif /* !__ASSEMBLY__ */
15271 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15272 index b073aae..39f9bdd 100644
15273 --- a/arch/x86/include/asm/smp.h
15274 +++ b/arch/x86/include/asm/smp.h
15275 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15276 /* cpus sharing the last level cache: */
15277 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15278 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15279 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15280 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15281
15282 static inline struct cpumask *cpu_sibling_mask(int cpu)
15283 {
15284 @@ -79,7 +79,7 @@ struct smp_ops {
15285
15286 void (*send_call_func_ipi)(const struct cpumask *mask);
15287 void (*send_call_func_single_ipi)(int cpu);
15288 -};
15289 +} __no_const;
15290
15291 /* Globals due to paravirt */
15292 extern void set_cpu_sibling_map(int cpu);
15293 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15294 extern int safe_smp_processor_id(void);
15295
15296 #elif defined(CONFIG_X86_64_SMP)
15297 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15298 -
15299 -#define stack_smp_processor_id() \
15300 -({ \
15301 - struct thread_info *ti; \
15302 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15303 - ti->cpu; \
15304 -})
15305 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15306 +#define stack_smp_processor_id() raw_smp_processor_id()
15307 #define safe_smp_processor_id() smp_processor_id()
15308
15309 #endif
15310 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15311 index 33692ea..350a534 100644
15312 --- a/arch/x86/include/asm/spinlock.h
15313 +++ b/arch/x86/include/asm/spinlock.h
15314 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15315 static inline void arch_read_lock(arch_rwlock_t *rw)
15316 {
15317 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15318 +
15319 +#ifdef CONFIG_PAX_REFCOUNT
15320 + "jno 0f\n"
15321 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15322 + "int $4\n0:\n"
15323 + _ASM_EXTABLE(0b, 0b)
15324 +#endif
15325 +
15326 "jns 1f\n"
15327 "call __read_lock_failed\n\t"
15328 "1:\n"
15329 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15330 static inline void arch_write_lock(arch_rwlock_t *rw)
15331 {
15332 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15333 +
15334 +#ifdef CONFIG_PAX_REFCOUNT
15335 + "jno 0f\n"
15336 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15337 + "int $4\n0:\n"
15338 + _ASM_EXTABLE(0b, 0b)
15339 +#endif
15340 +
15341 "jz 1f\n"
15342 "call __write_lock_failed\n\t"
15343 "1:\n"
15344 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15345
15346 static inline void arch_read_unlock(arch_rwlock_t *rw)
15347 {
15348 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15349 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15350 +
15351 +#ifdef CONFIG_PAX_REFCOUNT
15352 + "jno 0f\n"
15353 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15354 + "int $4\n0:\n"
15355 + _ASM_EXTABLE(0b, 0b)
15356 +#endif
15357 +
15358 :"+m" (rw->lock) : : "memory");
15359 }
15360
15361 static inline void arch_write_unlock(arch_rwlock_t *rw)
15362 {
15363 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15364 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15365 +
15366 +#ifdef CONFIG_PAX_REFCOUNT
15367 + "jno 0f\n"
15368 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15369 + "int $4\n0:\n"
15370 + _ASM_EXTABLE(0b, 0b)
15371 +#endif
15372 +
15373 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15374 }
15375
15376 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15377 index 6a99859..03cb807 100644
15378 --- a/arch/x86/include/asm/stackprotector.h
15379 +++ b/arch/x86/include/asm/stackprotector.h
15380 @@ -47,7 +47,7 @@
15381 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15382 */
15383 #define GDT_STACK_CANARY_INIT \
15384 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15385 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15386
15387 /*
15388 * Initialize the stackprotector canary value.
15389 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15390
15391 static inline void load_stack_canary_segment(void)
15392 {
15393 -#ifdef CONFIG_X86_32
15394 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15395 asm volatile ("mov %0, %%gs" : : "r" (0));
15396 #endif
15397 }
15398 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15399 index 70bbe39..4ae2bd4 100644
15400 --- a/arch/x86/include/asm/stacktrace.h
15401 +++ b/arch/x86/include/asm/stacktrace.h
15402 @@ -11,28 +11,20 @@
15403
15404 extern int kstack_depth_to_print;
15405
15406 -struct thread_info;
15407 +struct task_struct;
15408 struct stacktrace_ops;
15409
15410 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15411 - unsigned long *stack,
15412 - unsigned long bp,
15413 - const struct stacktrace_ops *ops,
15414 - void *data,
15415 - unsigned long *end,
15416 - int *graph);
15417 +typedef unsigned long walk_stack_t(struct task_struct *task,
15418 + void *stack_start,
15419 + unsigned long *stack,
15420 + unsigned long bp,
15421 + const struct stacktrace_ops *ops,
15422 + void *data,
15423 + unsigned long *end,
15424 + int *graph);
15425
15426 -extern unsigned long
15427 -print_context_stack(struct thread_info *tinfo,
15428 - unsigned long *stack, unsigned long bp,
15429 - const struct stacktrace_ops *ops, void *data,
15430 - unsigned long *end, int *graph);
15431 -
15432 -extern unsigned long
15433 -print_context_stack_bp(struct thread_info *tinfo,
15434 - unsigned long *stack, unsigned long bp,
15435 - const struct stacktrace_ops *ops, void *data,
15436 - unsigned long *end, int *graph);
15437 +extern walk_stack_t print_context_stack;
15438 +extern walk_stack_t print_context_stack_bp;
15439
15440 /* Generic stack tracer with callbacks */
15441
15442 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15443 void (*address)(void *data, unsigned long address, int reliable);
15444 /* On negative return stop dumping */
15445 int (*stack)(void *data, char *name);
15446 - walk_stack_t walk_stack;
15447 + walk_stack_t *walk_stack;
15448 };
15449
15450 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15451 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15452 index 4ec45b3..a4f0a8a 100644
15453 --- a/arch/x86/include/asm/switch_to.h
15454 +++ b/arch/x86/include/asm/switch_to.h
15455 @@ -108,7 +108,7 @@ do { \
15456 "call __switch_to\n\t" \
15457 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15458 __switch_canary \
15459 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15460 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15461 "movq %%rax,%%rdi\n\t" \
15462 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15463 "jnz ret_from_fork\n\t" \
15464 @@ -119,7 +119,7 @@ do { \
15465 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15466 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15467 [_tif_fork] "i" (_TIF_FORK), \
15468 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15469 + [thread_info] "m" (current_tinfo), \
15470 [current_task] "m" (current_task) \
15471 __switch_canary_iparam \
15472 : "memory", "cc" __EXTRA_CLOBBER)
15473 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15474 index a1df6e8..e002940 100644
15475 --- a/arch/x86/include/asm/thread_info.h
15476 +++ b/arch/x86/include/asm/thread_info.h
15477 @@ -10,6 +10,7 @@
15478 #include <linux/compiler.h>
15479 #include <asm/page.h>
15480 #include <asm/types.h>
15481 +#include <asm/percpu.h>
15482
15483 /*
15484 * low level task data that entry.S needs immediate access to
15485 @@ -23,7 +24,6 @@ struct exec_domain;
15486 #include <linux/atomic.h>
15487
15488 struct thread_info {
15489 - struct task_struct *task; /* main task structure */
15490 struct exec_domain *exec_domain; /* execution domain */
15491 __u32 flags; /* low level flags */
15492 __u32 status; /* thread synchronous flags */
15493 @@ -33,19 +33,13 @@ struct thread_info {
15494 mm_segment_t addr_limit;
15495 struct restart_block restart_block;
15496 void __user *sysenter_return;
15497 -#ifdef CONFIG_X86_32
15498 - unsigned long previous_esp; /* ESP of the previous stack in
15499 - case of nested (IRQ) stacks
15500 - */
15501 - __u8 supervisor_stack[0];
15502 -#endif
15503 + unsigned long lowest_stack;
15504 unsigned int sig_on_uaccess_error:1;
15505 unsigned int uaccess_err:1; /* uaccess failed */
15506 };
15507
15508 -#define INIT_THREAD_INFO(tsk) \
15509 +#define INIT_THREAD_INFO \
15510 { \
15511 - .task = &tsk, \
15512 .exec_domain = &default_exec_domain, \
15513 .flags = 0, \
15514 .cpu = 0, \
15515 @@ -56,7 +50,7 @@ struct thread_info {
15516 }, \
15517 }
15518
15519 -#define init_thread_info (init_thread_union.thread_info)
15520 +#define init_thread_info (init_thread_union.stack)
15521 #define init_stack (init_thread_union.stack)
15522
15523 #else /* !__ASSEMBLY__ */
15524 @@ -97,6 +91,7 @@ struct thread_info {
15525 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15526 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15527 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15528 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15529
15530 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15531 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15532 @@ -121,17 +116,18 @@ struct thread_info {
15533 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15534 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15535 #define _TIF_X32 (1 << TIF_X32)
15536 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15537
15538 /* work to do in syscall_trace_enter() */
15539 #define _TIF_WORK_SYSCALL_ENTRY \
15540 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15541 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15542 - _TIF_NOHZ)
15543 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15544
15545 /* work to do in syscall_trace_leave() */
15546 #define _TIF_WORK_SYSCALL_EXIT \
15547 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15548 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15549 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15550
15551 /* work to do on interrupt/exception return */
15552 #define _TIF_WORK_MASK \
15553 @@ -142,7 +138,7 @@ struct thread_info {
15554 /* work to do on any return to user space */
15555 #define _TIF_ALLWORK_MASK \
15556 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15557 - _TIF_NOHZ)
15558 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15559
15560 /* Only used for 64 bit */
15561 #define _TIF_DO_NOTIFY_MASK \
15562 @@ -158,45 +154,40 @@ struct thread_info {
15563
15564 #define PREEMPT_ACTIVE 0x10000000
15565
15566 -#ifdef CONFIG_X86_32
15567 -
15568 -#define STACK_WARN (THREAD_SIZE/8)
15569 -/*
15570 - * macros/functions for gaining access to the thread information structure
15571 - *
15572 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15573 - */
15574 -#ifndef __ASSEMBLY__
15575 -
15576 -
15577 -/* how to get the current stack pointer from C */
15578 -register unsigned long current_stack_pointer asm("esp") __used;
15579 -
15580 -/* how to get the thread information struct from C */
15581 -static inline struct thread_info *current_thread_info(void)
15582 -{
15583 - return (struct thread_info *)
15584 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15585 -}
15586 -
15587 -#else /* !__ASSEMBLY__ */
15588 -
15589 +#ifdef __ASSEMBLY__
15590 /* how to get the thread information struct from ASM */
15591 #define GET_THREAD_INFO(reg) \
15592 - movl $-THREAD_SIZE, reg; \
15593 - andl %esp, reg
15594 + mov PER_CPU_VAR(current_tinfo), reg
15595
15596 /* use this one if reg already contains %esp */
15597 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15598 - andl $-THREAD_SIZE, reg
15599 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15600 +#else
15601 +/* how to get the thread information struct from C */
15602 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15603 +
15604 +static __always_inline struct thread_info *current_thread_info(void)
15605 +{
15606 + return this_cpu_read_stable(current_tinfo);
15607 +}
15608 +#endif
15609 +
15610 +#ifdef CONFIG_X86_32
15611 +
15612 +#define STACK_WARN (THREAD_SIZE/8)
15613 +/*
15614 + * macros/functions for gaining access to the thread information structure
15615 + *
15616 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15617 + */
15618 +#ifndef __ASSEMBLY__
15619 +
15620 +/* how to get the current stack pointer from C */
15621 +register unsigned long current_stack_pointer asm("esp") __used;
15622
15623 #endif
15624
15625 #else /* X86_32 */
15626
15627 -#include <asm/percpu.h>
15628 -#define KERNEL_STACK_OFFSET (5*8)
15629 -
15630 /*
15631 * macros/functions for gaining access to the thread information structure
15632 * preempt_count needs to be 1 initially, until the scheduler is functional.
15633 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15634 #ifndef __ASSEMBLY__
15635 DECLARE_PER_CPU(unsigned long, kernel_stack);
15636
15637 -static inline struct thread_info *current_thread_info(void)
15638 -{
15639 - struct thread_info *ti;
15640 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15641 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15642 - return ti;
15643 -}
15644 -
15645 -#else /* !__ASSEMBLY__ */
15646 -
15647 -/* how to get the thread information struct from ASM */
15648 -#define GET_THREAD_INFO(reg) \
15649 - movq PER_CPU_VAR(kernel_stack),reg ; \
15650 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15651 -
15652 -/*
15653 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15654 - * a certain register (to be used in assembler memory operands).
15655 - */
15656 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15657 -
15658 +/* how to get the current stack pointer from C */
15659 +register unsigned long current_stack_pointer asm("rsp") __used;
15660 #endif
15661
15662 #endif /* !X86_32 */
15663 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
15664 extern void arch_task_cache_init(void);
15665 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15666 extern void arch_release_task_struct(struct task_struct *tsk);
15667 +
15668 +#define __HAVE_THREAD_FUNCTIONS
15669 +#define task_thread_info(task) (&(task)->tinfo)
15670 +#define task_stack_page(task) ((task)->stack)
15671 +#define setup_thread_stack(p, org) do {} while (0)
15672 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15673 +
15674 #endif
15675 #endif /* _ASM_X86_THREAD_INFO_H */
15676 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15677 index 5ee2687..70d5895 100644
15678 --- a/arch/x86/include/asm/uaccess.h
15679 +++ b/arch/x86/include/asm/uaccess.h
15680 @@ -7,6 +7,7 @@
15681 #include <linux/compiler.h>
15682 #include <linux/thread_info.h>
15683 #include <linux/string.h>
15684 +#include <linux/sched.h>
15685 #include <asm/asm.h>
15686 #include <asm/page.h>
15687 #include <asm/smap.h>
15688 @@ -29,7 +30,12 @@
15689
15690 #define get_ds() (KERNEL_DS)
15691 #define get_fs() (current_thread_info()->addr_limit)
15692 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15693 +void __set_fs(mm_segment_t x);
15694 +void set_fs(mm_segment_t x);
15695 +#else
15696 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15697 +#endif
15698
15699 #define segment_eq(a, b) ((a).seg == (b).seg)
15700
15701 @@ -77,8 +83,33 @@
15702 * checks that the pointer is in the user space range - after calling
15703 * this function, memory access functions may still return -EFAULT.
15704 */
15705 -#define access_ok(type, addr, size) \
15706 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15707 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15708 +#define access_ok(type, addr, size) \
15709 +({ \
15710 + long __size = size; \
15711 + unsigned long __addr = (unsigned long)addr; \
15712 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15713 + unsigned long __end_ao = __addr + __size - 1; \
15714 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15715 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15716 + while(__addr_ao <= __end_ao) { \
15717 + char __c_ao; \
15718 + __addr_ao += PAGE_SIZE; \
15719 + if (__size > PAGE_SIZE) \
15720 + cond_resched(); \
15721 + if (__get_user(__c_ao, (char __user *)__addr)) \
15722 + break; \
15723 + if (type != VERIFY_WRITE) { \
15724 + __addr = __addr_ao; \
15725 + continue; \
15726 + } \
15727 + if (__put_user(__c_ao, (char __user *)__addr)) \
15728 + break; \
15729 + __addr = __addr_ao; \
15730 + } \
15731 + } \
15732 + __ret_ao; \
15733 +})
15734
15735 /*
15736 * The exception table consists of pairs of addresses relative to the
15737 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15738 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15739 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15740
15741 -
15742 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15743 +#define __copyuser_seg "gs;"
15744 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15745 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15746 +#else
15747 +#define __copyuser_seg
15748 +#define __COPYUSER_SET_ES
15749 +#define __COPYUSER_RESTORE_ES
15750 +#endif
15751
15752 #ifdef CONFIG_X86_32
15753 #define __put_user_asm_u64(x, addr, err, errret) \
15754 asm volatile(ASM_STAC "\n" \
15755 - "1: movl %%eax,0(%2)\n" \
15756 - "2: movl %%edx,4(%2)\n" \
15757 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15758 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15759 "3: " ASM_CLAC "\n" \
15760 ".section .fixup,\"ax\"\n" \
15761 "4: movl %3,%0\n" \
15762 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15763
15764 #define __put_user_asm_ex_u64(x, addr) \
15765 asm volatile(ASM_STAC "\n" \
15766 - "1: movl %%eax,0(%1)\n" \
15767 - "2: movl %%edx,4(%1)\n" \
15768 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15769 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15770 "3: " ASM_CLAC "\n" \
15771 _ASM_EXTABLE_EX(1b, 2b) \
15772 _ASM_EXTABLE_EX(2b, 3b) \
15773 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15774 __typeof__(*(ptr)) __pu_val; \
15775 __chk_user_ptr(ptr); \
15776 might_fault(); \
15777 - __pu_val = x; \
15778 + __pu_val = (x); \
15779 switch (sizeof(*(ptr))) { \
15780 case 1: \
15781 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15782 @@ -345,7 +384,7 @@ do { \
15783
15784 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15785 asm volatile(ASM_STAC "\n" \
15786 - "1: mov"itype" %2,%"rtype"1\n" \
15787 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15788 "2: " ASM_CLAC "\n" \
15789 ".section .fixup,\"ax\"\n" \
15790 "3: mov %3,%0\n" \
15791 @@ -353,7 +392,7 @@ do { \
15792 " jmp 2b\n" \
15793 ".previous\n" \
15794 _ASM_EXTABLE(1b, 3b) \
15795 - : "=r" (err), ltype(x) \
15796 + : "=r" (err), ltype (x) \
15797 : "m" (__m(addr)), "i" (errret), "0" (err))
15798
15799 #define __get_user_size_ex(x, ptr, size) \
15800 @@ -378,7 +417,7 @@ do { \
15801 } while (0)
15802
15803 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15804 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15805 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15806 "2:\n" \
15807 _ASM_EXTABLE_EX(1b, 2b) \
15808 : ltype(x) : "m" (__m(addr)))
15809 @@ -395,13 +434,24 @@ do { \
15810 int __gu_err; \
15811 unsigned long __gu_val; \
15812 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15813 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15814 + (x) = (__typeof__(*(ptr)))__gu_val; \
15815 __gu_err; \
15816 })
15817
15818 /* FIXME: this hack is definitely wrong -AK */
15819 struct __large_struct { unsigned long buf[100]; };
15820 -#define __m(x) (*(struct __large_struct __user *)(x))
15821 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15822 +#define ____m(x) \
15823 +({ \
15824 + unsigned long ____x = (unsigned long)(x); \
15825 + if (____x < pax_user_shadow_base) \
15826 + ____x += pax_user_shadow_base; \
15827 + (typeof(x))____x; \
15828 +})
15829 +#else
15830 +#define ____m(x) (x)
15831 +#endif
15832 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15833
15834 /*
15835 * Tell gcc we read from memory instead of writing: this is because
15836 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15837 */
15838 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15839 asm volatile(ASM_STAC "\n" \
15840 - "1: mov"itype" %"rtype"1,%2\n" \
15841 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15842 "2: " ASM_CLAC "\n" \
15843 ".section .fixup,\"ax\"\n" \
15844 "3: mov %3,%0\n" \
15845 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15846 ".previous\n" \
15847 _ASM_EXTABLE(1b, 3b) \
15848 : "=r"(err) \
15849 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15850 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15851
15852 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15853 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15854 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15855 "2:\n" \
15856 _ASM_EXTABLE_EX(1b, 2b) \
15857 : : ltype(x), "m" (__m(addr)))
15858 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15859 * On error, the variable @x is set to zero.
15860 */
15861
15862 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15863 +#define __get_user(x, ptr) get_user((x), (ptr))
15864 +#else
15865 #define __get_user(x, ptr) \
15866 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15867 +#endif
15868
15869 /**
15870 * __put_user: - Write a simple value into user space, with less checking.
15871 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15872 * Returns zero on success, or -EFAULT on error.
15873 */
15874
15875 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15876 +#define __put_user(x, ptr) put_user((x), (ptr))
15877 +#else
15878 #define __put_user(x, ptr) \
15879 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15880 +#endif
15881
15882 #define __get_user_unaligned __get_user
15883 #define __put_user_unaligned __put_user
15884 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15885 #define get_user_ex(x, ptr) do { \
15886 unsigned long __gue_val; \
15887 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15888 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15889 + (x) = (__typeof__(*(ptr)))__gue_val; \
15890 } while (0)
15891
15892 #define put_user_try uaccess_try
15893 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15894 extern __must_check long strlen_user(const char __user *str);
15895 extern __must_check long strnlen_user(const char __user *str, long n);
15896
15897 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15898 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15899 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15900 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15901
15902 /*
15903 * movsl can be slow when source and dest are not both 8-byte aligned
15904 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15905 index 7f760a9..04b1c65 100644
15906 --- a/arch/x86/include/asm/uaccess_32.h
15907 +++ b/arch/x86/include/asm/uaccess_32.h
15908 @@ -11,15 +11,15 @@
15909 #include <asm/page.h>
15910
15911 unsigned long __must_check __copy_to_user_ll
15912 - (void __user *to, const void *from, unsigned long n);
15913 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15914 unsigned long __must_check __copy_from_user_ll
15915 - (void *to, const void __user *from, unsigned long n);
15916 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15917 unsigned long __must_check __copy_from_user_ll_nozero
15918 - (void *to, const void __user *from, unsigned long n);
15919 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15920 unsigned long __must_check __copy_from_user_ll_nocache
15921 - (void *to, const void __user *from, unsigned long n);
15922 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15923 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15924 - (void *to, const void __user *from, unsigned long n);
15925 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15926
15927 /**
15928 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15929 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15930 static __always_inline unsigned long __must_check
15931 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15932 {
15933 + if ((long)n < 0)
15934 + return n;
15935 +
15936 + check_object_size(from, n, true);
15937 +
15938 if (__builtin_constant_p(n)) {
15939 unsigned long ret;
15940
15941 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15942 __copy_to_user(void __user *to, const void *from, unsigned long n)
15943 {
15944 might_fault();
15945 +
15946 return __copy_to_user_inatomic(to, from, n);
15947 }
15948
15949 static __always_inline unsigned long
15950 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15951 {
15952 + if ((long)n < 0)
15953 + return n;
15954 +
15955 /* Avoid zeroing the tail if the copy fails..
15956 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15957 * but as the zeroing behaviour is only significant when n is not
15958 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15959 __copy_from_user(void *to, const void __user *from, unsigned long n)
15960 {
15961 might_fault();
15962 +
15963 + if ((long)n < 0)
15964 + return n;
15965 +
15966 + check_object_size(to, n, false);
15967 +
15968 if (__builtin_constant_p(n)) {
15969 unsigned long ret;
15970
15971 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15972 const void __user *from, unsigned long n)
15973 {
15974 might_fault();
15975 +
15976 + if ((long)n < 0)
15977 + return n;
15978 +
15979 if (__builtin_constant_p(n)) {
15980 unsigned long ret;
15981
15982 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15983 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15984 unsigned long n)
15985 {
15986 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15987 + if ((long)n < 0)
15988 + return n;
15989 +
15990 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15991 }
15992
15993 -unsigned long __must_check copy_to_user(void __user *to,
15994 - const void *from, unsigned long n);
15995 -unsigned long __must_check _copy_from_user(void *to,
15996 - const void __user *from,
15997 - unsigned long n);
15998 -
15999 +extern void copy_to_user_overflow(void)
16000 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16001 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16002 +#else
16003 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16004 +#endif
16005 +;
16006
16007 extern void copy_from_user_overflow(void)
16008 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16009 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16010 #endif
16011 ;
16012
16013 -static inline unsigned long __must_check copy_from_user(void *to,
16014 - const void __user *from,
16015 - unsigned long n)
16016 +/**
16017 + * copy_to_user: - Copy a block of data into user space.
16018 + * @to: Destination address, in user space.
16019 + * @from: Source address, in kernel space.
16020 + * @n: Number of bytes to copy.
16021 + *
16022 + * Context: User context only. This function may sleep.
16023 + *
16024 + * Copy data from kernel space to user space.
16025 + *
16026 + * Returns number of bytes that could not be copied.
16027 + * On success, this will be zero.
16028 + */
16029 +static inline unsigned long __must_check
16030 +copy_to_user(void __user *to, const void *from, unsigned long n)
16031 {
16032 - int sz = __compiletime_object_size(to);
16033 + size_t sz = __compiletime_object_size(from);
16034
16035 - if (likely(sz == -1 || sz >= n))
16036 - n = _copy_from_user(to, from, n);
16037 - else
16038 + if (unlikely(sz != (size_t)-1 && sz < n))
16039 + copy_to_user_overflow();
16040 + else if (access_ok(VERIFY_WRITE, to, n))
16041 + n = __copy_to_user(to, from, n);
16042 + return n;
16043 +}
16044 +
16045 +/**
16046 + * copy_from_user: - Copy a block of data from user space.
16047 + * @to: Destination address, in kernel space.
16048 + * @from: Source address, in user space.
16049 + * @n: Number of bytes to copy.
16050 + *
16051 + * Context: User context only. This function may sleep.
16052 + *
16053 + * Copy data from user space to kernel space.
16054 + *
16055 + * Returns number of bytes that could not be copied.
16056 + * On success, this will be zero.
16057 + *
16058 + * If some data could not be copied, this function will pad the copied
16059 + * data to the requested size using zero bytes.
16060 + */
16061 +static inline unsigned long __must_check
16062 +copy_from_user(void *to, const void __user *from, unsigned long n)
16063 +{
16064 + size_t sz = __compiletime_object_size(to);
16065 +
16066 + check_object_size(to, n, false);
16067 +
16068 + if (unlikely(sz != (size_t)-1 && sz < n))
16069 copy_from_user_overflow();
16070 -
16071 + else if (access_ok(VERIFY_READ, from, n))
16072 + n = __copy_from_user(to, from, n);
16073 + else if ((long)n > 0)
16074 + memset(to, 0, n);
16075 return n;
16076 }
16077
16078 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16079 index 142810c..1f2a0a7 100644
16080 --- a/arch/x86/include/asm/uaccess_64.h
16081 +++ b/arch/x86/include/asm/uaccess_64.h
16082 @@ -10,6 +10,9 @@
16083 #include <asm/alternative.h>
16084 #include <asm/cpufeature.h>
16085 #include <asm/page.h>
16086 +#include <asm/pgtable.h>
16087 +
16088 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16089
16090 /*
16091 * Copy To/From Userspace
16092 @@ -17,13 +20,13 @@
16093
16094 /* Handles exceptions in both to and from, but doesn't do access_ok */
16095 __must_check unsigned long
16096 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16097 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16098 __must_check unsigned long
16099 -copy_user_generic_string(void *to, const void *from, unsigned len);
16100 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16101 __must_check unsigned long
16102 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16103 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16104
16105 -static __always_inline __must_check unsigned long
16106 +static __always_inline __must_check __size_overflow(3) unsigned long
16107 copy_user_generic(void *to, const void *from, unsigned len)
16108 {
16109 unsigned ret;
16110 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16111 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16112 "=d" (len)),
16113 "1" (to), "2" (from), "3" (len)
16114 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16115 + : "memory", "rcx", "r8", "r9", "r11");
16116 return ret;
16117 }
16118
16119 +static __always_inline __must_check unsigned long
16120 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16121 +static __always_inline __must_check unsigned long
16122 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16123 __must_check unsigned long
16124 -_copy_to_user(void __user *to, const void *from, unsigned len);
16125 -__must_check unsigned long
16126 -_copy_from_user(void *to, const void __user *from, unsigned len);
16127 -__must_check unsigned long
16128 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16129 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16130 +
16131 +extern void copy_to_user_overflow(void)
16132 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16133 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16134 +#else
16135 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16136 +#endif
16137 +;
16138 +
16139 +extern void copy_from_user_overflow(void)
16140 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16141 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16142 +#else
16143 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16144 +#endif
16145 +;
16146
16147 static inline unsigned long __must_check copy_from_user(void *to,
16148 const void __user *from,
16149 unsigned long n)
16150 {
16151 - int sz = __compiletime_object_size(to);
16152 -
16153 might_fault();
16154 - if (likely(sz == -1 || sz >= n))
16155 - n = _copy_from_user(to, from, n);
16156 -#ifdef CONFIG_DEBUG_VM
16157 - else
16158 - WARN(1, "Buffer overflow detected!\n");
16159 -#endif
16160 +
16161 + check_object_size(to, n, false);
16162 +
16163 + if (access_ok(VERIFY_READ, from, n))
16164 + n = __copy_from_user(to, from, n);
16165 + else if (n < INT_MAX)
16166 + memset(to, 0, n);
16167 return n;
16168 }
16169
16170 static __always_inline __must_check
16171 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16172 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16173 {
16174 might_fault();
16175
16176 - return _copy_to_user(dst, src, size);
16177 + if (access_ok(VERIFY_WRITE, dst, size))
16178 + size = __copy_to_user(dst, src, size);
16179 + return size;
16180 }
16181
16182 static __always_inline __must_check
16183 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16184 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16185 {
16186 - int ret = 0;
16187 + size_t sz = __compiletime_object_size(dst);
16188 + unsigned ret = 0;
16189
16190 might_fault();
16191 +
16192 + if (size > INT_MAX)
16193 + return size;
16194 +
16195 + check_object_size(dst, size, false);
16196 +
16197 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16198 + if (!__access_ok(VERIFY_READ, src, size))
16199 + return size;
16200 +#endif
16201 +
16202 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16203 + copy_from_user_overflow();
16204 + return size;
16205 + }
16206 +
16207 if (!__builtin_constant_p(size))
16208 - return copy_user_generic(dst, (__force void *)src, size);
16209 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16210 switch (size) {
16211 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16212 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16213 ret, "b", "b", "=q", 1);
16214 return ret;
16215 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16216 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16217 ret, "w", "w", "=r", 2);
16218 return ret;
16219 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16220 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16221 ret, "l", "k", "=r", 4);
16222 return ret;
16223 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16224 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16225 ret, "q", "", "=r", 8);
16226 return ret;
16227 case 10:
16228 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16229 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16230 ret, "q", "", "=r", 10);
16231 if (unlikely(ret))
16232 return ret;
16233 __get_user_asm(*(u16 *)(8 + (char *)dst),
16234 - (u16 __user *)(8 + (char __user *)src),
16235 + (const u16 __user *)(8 + (const char __user *)src),
16236 ret, "w", "w", "=r", 2);
16237 return ret;
16238 case 16:
16239 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16240 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16241 ret, "q", "", "=r", 16);
16242 if (unlikely(ret))
16243 return ret;
16244 __get_user_asm(*(u64 *)(8 + (char *)dst),
16245 - (u64 __user *)(8 + (char __user *)src),
16246 + (const u64 __user *)(8 + (const char __user *)src),
16247 ret, "q", "", "=r", 8);
16248 return ret;
16249 default:
16250 - return copy_user_generic(dst, (__force void *)src, size);
16251 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16252 }
16253 }
16254
16255 static __always_inline __must_check
16256 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16257 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16258 {
16259 - int ret = 0;
16260 + size_t sz = __compiletime_object_size(src);
16261 + unsigned ret = 0;
16262
16263 might_fault();
16264 +
16265 + if (size > INT_MAX)
16266 + return size;
16267 +
16268 + check_object_size(src, size, true);
16269 +
16270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16271 + if (!__access_ok(VERIFY_WRITE, dst, size))
16272 + return size;
16273 +#endif
16274 +
16275 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16276 + copy_to_user_overflow();
16277 + return size;
16278 + }
16279 +
16280 if (!__builtin_constant_p(size))
16281 - return copy_user_generic((__force void *)dst, src, size);
16282 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16283 switch (size) {
16284 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16285 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16286 ret, "b", "b", "iq", 1);
16287 return ret;
16288 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16289 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16290 ret, "w", "w", "ir", 2);
16291 return ret;
16292 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16293 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16294 ret, "l", "k", "ir", 4);
16295 return ret;
16296 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16297 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16298 ret, "q", "", "er", 8);
16299 return ret;
16300 case 10:
16301 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16302 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16303 ret, "q", "", "er", 10);
16304 if (unlikely(ret))
16305 return ret;
16306 asm("":::"memory");
16307 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16308 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16309 ret, "w", "w", "ir", 2);
16310 return ret;
16311 case 16:
16312 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16313 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16314 ret, "q", "", "er", 16);
16315 if (unlikely(ret))
16316 return ret;
16317 asm("":::"memory");
16318 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16319 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16320 ret, "q", "", "er", 8);
16321 return ret;
16322 default:
16323 - return copy_user_generic((__force void *)dst, src, size);
16324 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16325 }
16326 }
16327
16328 static __always_inline __must_check
16329 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16330 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16331 {
16332 - int ret = 0;
16333 + unsigned ret = 0;
16334
16335 might_fault();
16336 +
16337 + if (size > INT_MAX)
16338 + return size;
16339 +
16340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16341 + if (!__access_ok(VERIFY_READ, src, size))
16342 + return size;
16343 + if (!__access_ok(VERIFY_WRITE, dst, size))
16344 + return size;
16345 +#endif
16346 +
16347 if (!__builtin_constant_p(size))
16348 - return copy_user_generic((__force void *)dst,
16349 - (__force void *)src, size);
16350 + return copy_user_generic((__force_kernel void *)____m(dst),
16351 + (__force_kernel const void *)____m(src), size);
16352 switch (size) {
16353 case 1: {
16354 u8 tmp;
16355 - __get_user_asm(tmp, (u8 __user *)src,
16356 + __get_user_asm(tmp, (const u8 __user *)src,
16357 ret, "b", "b", "=q", 1);
16358 if (likely(!ret))
16359 __put_user_asm(tmp, (u8 __user *)dst,
16360 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16361 }
16362 case 2: {
16363 u16 tmp;
16364 - __get_user_asm(tmp, (u16 __user *)src,
16365 + __get_user_asm(tmp, (const u16 __user *)src,
16366 ret, "w", "w", "=r", 2);
16367 if (likely(!ret))
16368 __put_user_asm(tmp, (u16 __user *)dst,
16369 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16370
16371 case 4: {
16372 u32 tmp;
16373 - __get_user_asm(tmp, (u32 __user *)src,
16374 + __get_user_asm(tmp, (const u32 __user *)src,
16375 ret, "l", "k", "=r", 4);
16376 if (likely(!ret))
16377 __put_user_asm(tmp, (u32 __user *)dst,
16378 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16379 }
16380 case 8: {
16381 u64 tmp;
16382 - __get_user_asm(tmp, (u64 __user *)src,
16383 + __get_user_asm(tmp, (const u64 __user *)src,
16384 ret, "q", "", "=r", 8);
16385 if (likely(!ret))
16386 __put_user_asm(tmp, (u64 __user *)dst,
16387 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16388 return ret;
16389 }
16390 default:
16391 - return copy_user_generic((__force void *)dst,
16392 - (__force void *)src, size);
16393 + return copy_user_generic((__force_kernel void *)____m(dst),
16394 + (__force_kernel const void *)____m(src), size);
16395 }
16396 }
16397
16398 static __must_check __always_inline int
16399 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16400 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16401 {
16402 - return copy_user_generic(dst, (__force const void *)src, size);
16403 + if (size > INT_MAX)
16404 + return size;
16405 +
16406 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16407 + if (!__access_ok(VERIFY_READ, src, size))
16408 + return size;
16409 +#endif
16410 +
16411 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16412 }
16413
16414 -static __must_check __always_inline int
16415 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16416 +static __must_check __always_inline unsigned long
16417 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16418 {
16419 - return copy_user_generic((__force void *)dst, src, size);
16420 + if (size > INT_MAX)
16421 + return size;
16422 +
16423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16424 + if (!__access_ok(VERIFY_WRITE, dst, size))
16425 + return size;
16426 +#endif
16427 +
16428 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16429 }
16430
16431 -extern long __copy_user_nocache(void *dst, const void __user *src,
16432 - unsigned size, int zerorest);
16433 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16434 + unsigned long size, int zerorest) __size_overflow(3);
16435
16436 -static inline int
16437 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16438 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16439 {
16440 might_sleep();
16441 +
16442 + if (size > INT_MAX)
16443 + return size;
16444 +
16445 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16446 + if (!__access_ok(VERIFY_READ, src, size))
16447 + return size;
16448 +#endif
16449 +
16450 return __copy_user_nocache(dst, src, size, 1);
16451 }
16452
16453 -static inline int
16454 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16455 - unsigned size)
16456 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16457 + unsigned long size)
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, 0);
16468 }
16469
16470 -unsigned long
16471 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16472 +extern unsigned long
16473 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16474
16475 #endif /* _ASM_X86_UACCESS_64_H */
16476 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16477 index 5b238981..77fdd78 100644
16478 --- a/arch/x86/include/asm/word-at-a-time.h
16479 +++ b/arch/x86/include/asm/word-at-a-time.h
16480 @@ -11,7 +11,7 @@
16481 * and shift, for example.
16482 */
16483 struct word_at_a_time {
16484 - const unsigned long one_bits, high_bits;
16485 + unsigned long one_bits, high_bits;
16486 };
16487
16488 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16489 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16490 index d8d9922..bf6cecb 100644
16491 --- a/arch/x86/include/asm/x86_init.h
16492 +++ b/arch/x86/include/asm/x86_init.h
16493 @@ -129,7 +129,7 @@ struct x86_init_ops {
16494 struct x86_init_timers timers;
16495 struct x86_init_iommu iommu;
16496 struct x86_init_pci pci;
16497 -};
16498 +} __no_const;
16499
16500 /**
16501 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16502 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16503 void (*setup_percpu_clockev)(void);
16504 void (*early_percpu_clock_init)(void);
16505 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16506 -};
16507 +} __no_const;
16508
16509 /**
16510 * struct x86_platform_ops - platform specific runtime functions
16511 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16512 void (*save_sched_clock_state)(void);
16513 void (*restore_sched_clock_state)(void);
16514 void (*apic_post_init)(void);
16515 -};
16516 +} __no_const;
16517
16518 struct pci_dev;
16519 struct msi_msg;
16520 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16521 void (*teardown_msi_irqs)(struct pci_dev *dev);
16522 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16523 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16524 -};
16525 +} __no_const;
16526
16527 struct IO_APIC_route_entry;
16528 struct io_apic_irq_attr;
16529 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16530 unsigned int destination, int vector,
16531 struct io_apic_irq_attr *attr);
16532 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16533 -};
16534 +} __no_const;
16535
16536 extern struct x86_init_ops x86_init;
16537 extern struct x86_cpuinit_ops x86_cpuinit;
16538 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16539 index 0415cda..b43d877 100644
16540 --- a/arch/x86/include/asm/xsave.h
16541 +++ b/arch/x86/include/asm/xsave.h
16542 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16543 return -EFAULT;
16544
16545 __asm__ __volatile__(ASM_STAC "\n"
16546 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16547 + "1:"
16548 + __copyuser_seg
16549 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16550 "2: " ASM_CLAC "\n"
16551 ".section .fixup,\"ax\"\n"
16552 "3: movl $-1,%[err]\n"
16553 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16554 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16555 {
16556 int err;
16557 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16558 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16559 u32 lmask = mask;
16560 u32 hmask = mask >> 32;
16561
16562 __asm__ __volatile__(ASM_STAC "\n"
16563 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16564 + "1:"
16565 + __copyuser_seg
16566 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16567 "2: " ASM_CLAC "\n"
16568 ".section .fixup,\"ax\"\n"
16569 "3: movl $-1,%[err]\n"
16570 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16571 index bbae024..e1528f9 100644
16572 --- a/arch/x86/include/uapi/asm/e820.h
16573 +++ b/arch/x86/include/uapi/asm/e820.h
16574 @@ -63,7 +63,7 @@ struct e820map {
16575 #define ISA_START_ADDRESS 0xa0000
16576 #define ISA_END_ADDRESS 0x100000
16577
16578 -#define BIOS_BEGIN 0x000a0000
16579 +#define BIOS_BEGIN 0x000c0000
16580 #define BIOS_END 0x00100000
16581
16582 #define BIOS_ROM_BASE 0xffe00000
16583 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16584 index 7bd3bd3..5dac791 100644
16585 --- a/arch/x86/kernel/Makefile
16586 +++ b/arch/x86/kernel/Makefile
16587 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16588 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16589 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16590 obj-y += probe_roms.o
16591 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16592 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16593 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16594 obj-y += syscall_$(BITS).o
16595 obj-$(CONFIG_X86_64) += vsyscall_64.o
16596 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16597 index 230c8ea..f915130 100644
16598 --- a/arch/x86/kernel/acpi/boot.c
16599 +++ b/arch/x86/kernel/acpi/boot.c
16600 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16601 * If your system is blacklisted here, but you find that acpi=force
16602 * works for you, please contact linux-acpi@vger.kernel.org
16603 */
16604 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16605 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16606 /*
16607 * Boxes that need ACPI disabled
16608 */
16609 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16610 };
16611
16612 /* second table for DMI checks that should run after early-quirks */
16613 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16614 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16615 /*
16616 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16617 * which includes some code which overrides all temperature
16618 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16619 index b44577b..27d8443 100644
16620 --- a/arch/x86/kernel/acpi/sleep.c
16621 +++ b/arch/x86/kernel/acpi/sleep.c
16622 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16623 #else /* CONFIG_64BIT */
16624 #ifdef CONFIG_SMP
16625 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16626 +
16627 + pax_open_kernel();
16628 early_gdt_descr.address =
16629 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16630 + pax_close_kernel();
16631 +
16632 initial_gs = per_cpu_offset(smp_processor_id());
16633 #endif
16634 initial_code = (unsigned long)wakeup_long64;
16635 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16636 index d1daa66..59fecba 100644
16637 --- a/arch/x86/kernel/acpi/wakeup_32.S
16638 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16639 @@ -29,13 +29,11 @@ wakeup_pmode_return:
16640 # and restore the stack ... but you need gdt for this to work
16641 movl saved_context_esp, %esp
16642
16643 - movl %cs:saved_magic, %eax
16644 - cmpl $0x12345678, %eax
16645 + cmpl $0x12345678, saved_magic
16646 jne bogus_magic
16647
16648 # jump to place where we left off
16649 - movl saved_eip, %eax
16650 - jmp *%eax
16651 + jmp *(saved_eip)
16652
16653 bogus_magic:
16654 jmp bogus_magic
16655 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16656 index c15cf9a..0e63558 100644
16657 --- a/arch/x86/kernel/alternative.c
16658 +++ b/arch/x86/kernel/alternative.c
16659 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16660 */
16661 for (a = start; a < end; a++) {
16662 instr = (u8 *)&a->instr_offset + a->instr_offset;
16663 +
16664 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16665 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16666 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16667 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16668 +#endif
16669 +
16670 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16671 BUG_ON(a->replacementlen > a->instrlen);
16672 BUG_ON(a->instrlen > sizeof(insnbuf));
16673 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16674 for (poff = start; poff < end; poff++) {
16675 u8 *ptr = (u8 *)poff + *poff;
16676
16677 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16678 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16679 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16680 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16681 +#endif
16682 +
16683 if (!*poff || ptr < text || ptr >= text_end)
16684 continue;
16685 /* turn DS segment override prefix into lock prefix */
16686 - if (*ptr == 0x3e)
16687 + if (*ktla_ktva(ptr) == 0x3e)
16688 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16689 }
16690 mutex_unlock(&text_mutex);
16691 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16692 for (poff = start; poff < end; poff++) {
16693 u8 *ptr = (u8 *)poff + *poff;
16694
16695 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16696 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16697 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16698 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16699 +#endif
16700 +
16701 if (!*poff || ptr < text || ptr >= text_end)
16702 continue;
16703 /* turn lock prefix into DS segment override prefix */
16704 - if (*ptr == 0xf0)
16705 + if (*ktla_ktva(ptr) == 0xf0)
16706 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16707 }
16708 mutex_unlock(&text_mutex);
16709 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16710
16711 BUG_ON(p->len > MAX_PATCH_LEN);
16712 /* prep the buffer with the original instructions */
16713 - memcpy(insnbuf, p->instr, p->len);
16714 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16715 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16716 (unsigned long)p->instr, p->len);
16717
16718 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16719 if (!uniproc_patched || num_possible_cpus() == 1)
16720 free_init_pages("SMP alternatives",
16721 (unsigned long)__smp_locks,
16722 - (unsigned long)__smp_locks_end);
16723 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16724 #endif
16725
16726 apply_paravirt(__parainstructions, __parainstructions_end);
16727 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16728 * instructions. And on the local CPU you need to be protected again NMI or MCE
16729 * handlers seeing an inconsistent instruction while you patch.
16730 */
16731 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16732 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16733 size_t len)
16734 {
16735 unsigned long flags;
16736 local_irq_save(flags);
16737 - memcpy(addr, opcode, len);
16738 +
16739 + pax_open_kernel();
16740 + memcpy(ktla_ktva(addr), opcode, len);
16741 sync_core();
16742 + pax_close_kernel();
16743 +
16744 local_irq_restore(flags);
16745 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16746 that causes hangs on some VIA CPUs. */
16747 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16748 */
16749 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16750 {
16751 - unsigned long flags;
16752 - char *vaddr;
16753 + unsigned char *vaddr = ktla_ktva(addr);
16754 struct page *pages[2];
16755 - int i;
16756 + size_t i;
16757
16758 if (!core_kernel_text((unsigned long)addr)) {
16759 - pages[0] = vmalloc_to_page(addr);
16760 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16761 + pages[0] = vmalloc_to_page(vaddr);
16762 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16763 } else {
16764 - pages[0] = virt_to_page(addr);
16765 + pages[0] = virt_to_page(vaddr);
16766 WARN_ON(!PageReserved(pages[0]));
16767 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16768 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16769 }
16770 BUG_ON(!pages[0]);
16771 - local_irq_save(flags);
16772 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16773 - if (pages[1])
16774 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16775 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16776 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16777 - clear_fixmap(FIX_TEXT_POKE0);
16778 - if (pages[1])
16779 - clear_fixmap(FIX_TEXT_POKE1);
16780 - local_flush_tlb();
16781 - sync_core();
16782 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16783 - that causes hangs on some VIA CPUs. */
16784 + text_poke_early(addr, opcode, len);
16785 for (i = 0; i < len; i++)
16786 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16787 - local_irq_restore(flags);
16788 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16789 return addr;
16790 }
16791
16792 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16793 index 904611b..004dde6 100644
16794 --- a/arch/x86/kernel/apic/apic.c
16795 +++ b/arch/x86/kernel/apic/apic.c
16796 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16797 /*
16798 * Debug level, exported for io_apic.c
16799 */
16800 -unsigned int apic_verbosity;
16801 +int apic_verbosity;
16802
16803 int pic_mode;
16804
16805 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16806 apic_write(APIC_ESR, 0);
16807 v1 = apic_read(APIC_ESR);
16808 ack_APIC_irq();
16809 - atomic_inc(&irq_err_count);
16810 + atomic_inc_unchecked(&irq_err_count);
16811
16812 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16813 smp_processor_id(), v0 , v1);
16814 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16815 index 00c77cf..2dc6a2d 100644
16816 --- a/arch/x86/kernel/apic/apic_flat_64.c
16817 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16818 @@ -157,7 +157,7 @@ static int flat_probe(void)
16819 return 1;
16820 }
16821
16822 -static struct apic apic_flat = {
16823 +static struct apic apic_flat __read_only = {
16824 .name = "flat",
16825 .probe = flat_probe,
16826 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16827 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16828 return 0;
16829 }
16830
16831 -static struct apic apic_physflat = {
16832 +static struct apic apic_physflat __read_only = {
16833
16834 .name = "physical flat",
16835 .probe = physflat_probe,
16836 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16837 index e145f28..2752888 100644
16838 --- a/arch/x86/kernel/apic/apic_noop.c
16839 +++ b/arch/x86/kernel/apic/apic_noop.c
16840 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16841 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16842 }
16843
16844 -struct apic apic_noop = {
16845 +struct apic apic_noop __read_only = {
16846 .name = "noop",
16847 .probe = noop_probe,
16848 .acpi_madt_oem_check = NULL,
16849 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16850 index d50e364..543bee3 100644
16851 --- a/arch/x86/kernel/apic/bigsmp_32.c
16852 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16853 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16854 return dmi_bigsmp;
16855 }
16856
16857 -static struct apic apic_bigsmp = {
16858 +static struct apic apic_bigsmp __read_only = {
16859
16860 .name = "bigsmp",
16861 .probe = probe_bigsmp,
16862 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16863 index 0874799..a7a7892 100644
16864 --- a/arch/x86/kernel/apic/es7000_32.c
16865 +++ b/arch/x86/kernel/apic/es7000_32.c
16866 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16867 return ret && es7000_apic_is_cluster();
16868 }
16869
16870 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16871 -static struct apic __refdata apic_es7000_cluster = {
16872 +static struct apic apic_es7000_cluster __read_only = {
16873
16874 .name = "es7000",
16875 .probe = probe_es7000,
16876 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16877 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16878 };
16879
16880 -static struct apic __refdata apic_es7000 = {
16881 +static struct apic apic_es7000 __read_only = {
16882
16883 .name = "es7000",
16884 .probe = probe_es7000,
16885 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16886 index 9ed796c..e930fe4 100644
16887 --- a/arch/x86/kernel/apic/io_apic.c
16888 +++ b/arch/x86/kernel/apic/io_apic.c
16889 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16890 }
16891 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16892
16893 -void lock_vector_lock(void)
16894 +void lock_vector_lock(void) __acquires(vector_lock)
16895 {
16896 /* Used to the online set of cpus does not change
16897 * during assign_irq_vector.
16898 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16899 raw_spin_lock(&vector_lock);
16900 }
16901
16902 -void unlock_vector_lock(void)
16903 +void unlock_vector_lock(void) __releases(vector_lock)
16904 {
16905 raw_spin_unlock(&vector_lock);
16906 }
16907 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16908 ack_APIC_irq();
16909 }
16910
16911 -atomic_t irq_mis_count;
16912 +atomic_unchecked_t irq_mis_count;
16913
16914 #ifdef CONFIG_GENERIC_PENDING_IRQ
16915 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16916 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16917 * at the cpu.
16918 */
16919 if (!(v & (1 << (i & 0x1f)))) {
16920 - atomic_inc(&irq_mis_count);
16921 + atomic_inc_unchecked(&irq_mis_count);
16922
16923 eoi_ioapic_irq(irq, cfg);
16924 }
16925 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16926 index d661ee9..791fd33 100644
16927 --- a/arch/x86/kernel/apic/numaq_32.c
16928 +++ b/arch/x86/kernel/apic/numaq_32.c
16929 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16930 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16931 }
16932
16933 -/* Use __refdata to keep false positive warning calm. */
16934 -static struct apic __refdata apic_numaq = {
16935 +static struct apic apic_numaq __read_only = {
16936
16937 .name = "NUMAQ",
16938 .probe = probe_numaq,
16939 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16940 index eb35ef9..f184a21 100644
16941 --- a/arch/x86/kernel/apic/probe_32.c
16942 +++ b/arch/x86/kernel/apic/probe_32.c
16943 @@ -72,7 +72,7 @@ static int probe_default(void)
16944 return 1;
16945 }
16946
16947 -static struct apic apic_default = {
16948 +static struct apic apic_default __read_only = {
16949
16950 .name = "default",
16951 .probe = probe_default,
16952 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16953 index 77c95c0..434f8a4 100644
16954 --- a/arch/x86/kernel/apic/summit_32.c
16955 +++ b/arch/x86/kernel/apic/summit_32.c
16956 @@ -486,7 +486,7 @@ void setup_summit(void)
16957 }
16958 #endif
16959
16960 -static struct apic apic_summit = {
16961 +static struct apic apic_summit __read_only = {
16962
16963 .name = "summit",
16964 .probe = probe_summit,
16965 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16966 index c88baa4..757aee1 100644
16967 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16968 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16969 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16970 return notifier_from_errno(err);
16971 }
16972
16973 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16974 +static struct notifier_block x2apic_cpu_notifier = {
16975 .notifier_call = update_clusterinfo,
16976 };
16977
16978 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16979 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16980 }
16981
16982 -static struct apic apic_x2apic_cluster = {
16983 +static struct apic apic_x2apic_cluster __read_only = {
16984
16985 .name = "cluster x2apic",
16986 .probe = x2apic_cluster_probe,
16987 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16988 index 562a76d..a003c0f 100644
16989 --- a/arch/x86/kernel/apic/x2apic_phys.c
16990 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16991 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16992 return apic == &apic_x2apic_phys;
16993 }
16994
16995 -static struct apic apic_x2apic_phys = {
16996 +static struct apic apic_x2apic_phys __read_only = {
16997
16998 .name = "physical x2apic",
16999 .probe = x2apic_phys_probe,
17000 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17001 index 794f6eb..67e1db2 100644
17002 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17003 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17004 @@ -342,7 +342,7 @@ static int uv_probe(void)
17005 return apic == &apic_x2apic_uv_x;
17006 }
17007
17008 -static struct apic __refdata apic_x2apic_uv_x = {
17009 +static struct apic apic_x2apic_uv_x __read_only = {
17010
17011 .name = "UV large system",
17012 .probe = uv_probe,
17013 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17014 index 53a4e27..038760a 100644
17015 --- a/arch/x86/kernel/apm_32.c
17016 +++ b/arch/x86/kernel/apm_32.c
17017 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
17018 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17019 * even though they are called in protected mode.
17020 */
17021 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17022 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17023 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17024
17025 static const char driver_version[] = "1.16ac"; /* no spaces */
17026 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
17027 BUG_ON(cpu != 0);
17028 gdt = get_cpu_gdt_table(cpu);
17029 save_desc_40 = gdt[0x40 / 8];
17030 +
17031 + pax_open_kernel();
17032 gdt[0x40 / 8] = bad_bios_desc;
17033 + pax_close_kernel();
17034
17035 apm_irq_save(flags);
17036 APM_DO_SAVE_SEGS;
17037 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
17038 &call->esi);
17039 APM_DO_RESTORE_SEGS;
17040 apm_irq_restore(flags);
17041 +
17042 + pax_open_kernel();
17043 gdt[0x40 / 8] = save_desc_40;
17044 + pax_close_kernel();
17045 +
17046 put_cpu();
17047
17048 return call->eax & 0xff;
17049 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
17050 BUG_ON(cpu != 0);
17051 gdt = get_cpu_gdt_table(cpu);
17052 save_desc_40 = gdt[0x40 / 8];
17053 +
17054 + pax_open_kernel();
17055 gdt[0x40 / 8] = bad_bios_desc;
17056 + pax_close_kernel();
17057
17058 apm_irq_save(flags);
17059 APM_DO_SAVE_SEGS;
17060 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
17061 &call->eax);
17062 APM_DO_RESTORE_SEGS;
17063 apm_irq_restore(flags);
17064 +
17065 + pax_open_kernel();
17066 gdt[0x40 / 8] = save_desc_40;
17067 + pax_close_kernel();
17068 +
17069 put_cpu();
17070 return error;
17071 }
17072 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
17073 * code to that CPU.
17074 */
17075 gdt = get_cpu_gdt_table(0);
17076 +
17077 + pax_open_kernel();
17078 set_desc_base(&gdt[APM_CS >> 3],
17079 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17080 set_desc_base(&gdt[APM_CS_16 >> 3],
17081 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17082 set_desc_base(&gdt[APM_DS >> 3],
17083 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17084 + pax_close_kernel();
17085
17086 proc_create("apm", 0, NULL, &apm_file_ops);
17087
17088 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17089 index 2861082..6d4718e 100644
17090 --- a/arch/x86/kernel/asm-offsets.c
17091 +++ b/arch/x86/kernel/asm-offsets.c
17092 @@ -33,6 +33,8 @@ void common(void) {
17093 OFFSET(TI_status, thread_info, status);
17094 OFFSET(TI_addr_limit, thread_info, addr_limit);
17095 OFFSET(TI_preempt_count, thread_info, preempt_count);
17096 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17097 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17098
17099 BLANK();
17100 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17101 @@ -53,8 +55,26 @@ void common(void) {
17102 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17103 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17104 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17105 +
17106 +#ifdef CONFIG_PAX_KERNEXEC
17107 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17108 #endif
17109
17110 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17111 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17112 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17113 +#ifdef CONFIG_X86_64
17114 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17115 +#endif
17116 +#endif
17117 +
17118 +#endif
17119 +
17120 + BLANK();
17121 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17122 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17123 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17124 +
17125 #ifdef CONFIG_XEN
17126 BLANK();
17127 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17128 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17129 index e7c798b..2b2019b 100644
17130 --- a/arch/x86/kernel/asm-offsets_64.c
17131 +++ b/arch/x86/kernel/asm-offsets_64.c
17132 @@ -77,6 +77,7 @@ int main(void)
17133 BLANK();
17134 #undef ENTRY
17135
17136 + DEFINE(TSS_size, sizeof(struct tss_struct));
17137 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17138 BLANK();
17139
17140 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17141 index b0684e4..22ccfd7 100644
17142 --- a/arch/x86/kernel/cpu/Makefile
17143 +++ b/arch/x86/kernel/cpu/Makefile
17144 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17145 CFLAGS_REMOVE_perf_event.o = -pg
17146 endif
17147
17148 -# Make sure load_percpu_segment has no stackprotector
17149 -nostackp := $(call cc-option, -fno-stack-protector)
17150 -CFLAGS_common.o := $(nostackp)
17151 -
17152 obj-y := intel_cacheinfo.o scattered.o topology.o
17153 obj-y += proc.o capflags.o powerflags.o common.o
17154 obj-y += rdrand.o
17155 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17156 index 5013a48..0782c53 100644
17157 --- a/arch/x86/kernel/cpu/amd.c
17158 +++ b/arch/x86/kernel/cpu/amd.c
17159 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17160 unsigned int size)
17161 {
17162 /* AMD errata T13 (order #21922) */
17163 - if ((c->x86 == 6)) {
17164 + if (c->x86 == 6) {
17165 /* Duron Rev A0 */
17166 if (c->x86_model == 3 && c->x86_mask == 0)
17167 size = 64;
17168 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17169 index 22018f7..bc6f5e3 100644
17170 --- a/arch/x86/kernel/cpu/common.c
17171 +++ b/arch/x86/kernel/cpu/common.c
17172 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17173
17174 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17175
17176 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17177 -#ifdef CONFIG_X86_64
17178 - /*
17179 - * We need valid kernel segments for data and code in long mode too
17180 - * IRET will check the segment types kkeil 2000/10/28
17181 - * Also sysret mandates a special GDT layout
17182 - *
17183 - * TLS descriptors are currently at a different place compared to i386.
17184 - * Hopefully nobody expects them at a fixed place (Wine?)
17185 - */
17186 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17187 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17188 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17189 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17190 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17191 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17192 -#else
17193 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17194 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17195 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17196 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17197 - /*
17198 - * Segments used for calling PnP BIOS have byte granularity.
17199 - * They code segments and data segments have fixed 64k limits,
17200 - * the transfer segment sizes are set at run time.
17201 - */
17202 - /* 32-bit code */
17203 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17204 - /* 16-bit code */
17205 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17206 - /* 16-bit data */
17207 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17208 - /* 16-bit data */
17209 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17210 - /* 16-bit data */
17211 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17212 - /*
17213 - * The APM segments have byte granularity and their bases
17214 - * are set at run time. All have 64k limits.
17215 - */
17216 - /* 32-bit code */
17217 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17218 - /* 16-bit code */
17219 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17220 - /* data */
17221 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17222 -
17223 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17224 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17225 - GDT_STACK_CANARY_INIT
17226 -#endif
17227 -} };
17228 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17229 -
17230 static int __init x86_xsave_setup(char *s)
17231 {
17232 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17233 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17234 {
17235 struct desc_ptr gdt_descr;
17236
17237 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17238 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17239 gdt_descr.size = GDT_SIZE - 1;
17240 load_gdt(&gdt_descr);
17241 /* Reload the per-cpu base */
17242 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17243 /* Filter out anything that depends on CPUID levels we don't have */
17244 filter_cpuid_features(c, true);
17245
17246 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17247 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17248 +#endif
17249 +
17250 /* If the model name is still unset, do table lookup. */
17251 if (!c->x86_model_id[0]) {
17252 const char *p;
17253 @@ -1069,10 +1019,12 @@ static __init int setup_disablecpuid(char *arg)
17254 }
17255 __setup("clearcpuid=", setup_disablecpuid);
17256
17257 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17258 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17259 +
17260 #ifdef CONFIG_X86_64
17261 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17262 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17263 - (unsigned long) nmi_idt_table };
17264 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17265
17266 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17267 irq_stack_union) __aligned(PAGE_SIZE);
17268 @@ -1086,7 +1038,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17269 EXPORT_PER_CPU_SYMBOL(current_task);
17270
17271 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17272 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17273 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17274 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17275
17276 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17277 @@ -1231,7 +1183,7 @@ void __cpuinit cpu_init(void)
17278 load_ucode_ap();
17279
17280 cpu = stack_smp_processor_id();
17281 - t = &per_cpu(init_tss, cpu);
17282 + t = init_tss + cpu;
17283 oist = &per_cpu(orig_ist, cpu);
17284
17285 #ifdef CONFIG_NUMA
17286 @@ -1257,7 +1209,7 @@ void __cpuinit cpu_init(void)
17287 switch_to_new_gdt(cpu);
17288 loadsegment(fs, 0);
17289
17290 - load_idt((const struct desc_ptr *)&idt_descr);
17291 + load_idt(&idt_descr);
17292
17293 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17294 syscall_init();
17295 @@ -1266,7 +1218,6 @@ void __cpuinit cpu_init(void)
17296 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17297 barrier();
17298
17299 - x86_configure_nx();
17300 enable_x2apic();
17301
17302 /*
17303 @@ -1318,7 +1269,7 @@ void __cpuinit cpu_init(void)
17304 {
17305 int cpu = smp_processor_id();
17306 struct task_struct *curr = current;
17307 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17308 + struct tss_struct *t = init_tss + cpu;
17309 struct thread_struct *thread = &curr->thread;
17310
17311 show_ucode_info_early();
17312 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17313 index 7c6f7d5..8cac382 100644
17314 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17315 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17316 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17317 };
17318
17319 #ifdef CONFIG_AMD_NB
17320 +static struct attribute *default_attrs_amd_nb[] = {
17321 + &type.attr,
17322 + &level.attr,
17323 + &coherency_line_size.attr,
17324 + &physical_line_partition.attr,
17325 + &ways_of_associativity.attr,
17326 + &number_of_sets.attr,
17327 + &size.attr,
17328 + &shared_cpu_map.attr,
17329 + &shared_cpu_list.attr,
17330 + NULL,
17331 + NULL,
17332 + NULL,
17333 + NULL
17334 +};
17335 +
17336 static struct attribute ** __cpuinit amd_l3_attrs(void)
17337 {
17338 static struct attribute **attrs;
17339 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17340
17341 n = ARRAY_SIZE(default_attrs);
17342
17343 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17344 - n += 2;
17345 -
17346 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17347 - n += 1;
17348 -
17349 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17350 - if (attrs == NULL)
17351 - return attrs = default_attrs;
17352 -
17353 - for (n = 0; default_attrs[n]; n++)
17354 - attrs[n] = default_attrs[n];
17355 + attrs = default_attrs_amd_nb;
17356
17357 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17358 attrs[n++] = &cache_disable_0.attr;
17359 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17360 .default_attrs = default_attrs,
17361 };
17362
17363 +#ifdef CONFIG_AMD_NB
17364 +static struct kobj_type ktype_cache_amd_nb = {
17365 + .sysfs_ops = &sysfs_ops,
17366 + .default_attrs = default_attrs_amd_nb,
17367 +};
17368 +#endif
17369 +
17370 static struct kobj_type ktype_percpu_entry = {
17371 .sysfs_ops = &sysfs_ops,
17372 };
17373 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17374 return retval;
17375 }
17376
17377 +#ifdef CONFIG_AMD_NB
17378 + amd_l3_attrs();
17379 +#endif
17380 +
17381 for (i = 0; i < num_cache_leaves; i++) {
17382 + struct kobj_type *ktype;
17383 +
17384 this_object = INDEX_KOBJECT_PTR(cpu, i);
17385 this_object->cpu = cpu;
17386 this_object->index = i;
17387
17388 this_leaf = CPUID4_INFO_IDX(cpu, i);
17389
17390 - ktype_cache.default_attrs = default_attrs;
17391 + ktype = &ktype_cache;
17392 #ifdef CONFIG_AMD_NB
17393 if (this_leaf->base.nb)
17394 - ktype_cache.default_attrs = amd_l3_attrs();
17395 + ktype = &ktype_cache_amd_nb;
17396 #endif
17397 retval = kobject_init_and_add(&(this_object->kobj),
17398 - &ktype_cache,
17399 + ktype,
17400 per_cpu(ici_cache_kobject, cpu),
17401 "index%1lu", i);
17402 if (unlikely(retval)) {
17403 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17404 return NOTIFY_OK;
17405 }
17406
17407 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17408 +static struct notifier_block cacheinfo_cpu_notifier = {
17409 .notifier_call = cacheinfo_cpu_callback,
17410 };
17411
17412 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17413 index 9239504..b2471ce 100644
17414 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17415 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17416 @@ -45,6 +45,7 @@
17417 #include <asm/processor.h>
17418 #include <asm/mce.h>
17419 #include <asm/msr.h>
17420 +#include <asm/local.h>
17421
17422 #include "mce-internal.h"
17423
17424 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17425 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17426 m->cs, m->ip);
17427
17428 - if (m->cs == __KERNEL_CS)
17429 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17430 print_symbol("{%s}", m->ip);
17431 pr_cont("\n");
17432 }
17433 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17434
17435 #define PANIC_TIMEOUT 5 /* 5 seconds */
17436
17437 -static atomic_t mce_paniced;
17438 +static atomic_unchecked_t mce_paniced;
17439
17440 static int fake_panic;
17441 -static atomic_t mce_fake_paniced;
17442 +static atomic_unchecked_t mce_fake_paniced;
17443
17444 /* Panic in progress. Enable interrupts and wait for final IPI */
17445 static void wait_for_panic(void)
17446 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17447 /*
17448 * Make sure only one CPU runs in machine check panic
17449 */
17450 - if (atomic_inc_return(&mce_paniced) > 1)
17451 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17452 wait_for_panic();
17453 barrier();
17454
17455 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17456 console_verbose();
17457 } else {
17458 /* Don't log too much for fake panic */
17459 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17460 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17461 return;
17462 }
17463 /* First print corrected ones that are still unlogged */
17464 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17465 if (!fake_panic) {
17466 if (panic_timeout == 0)
17467 panic_timeout = mca_cfg.panic_timeout;
17468 - panic(msg);
17469 + panic("%s", msg);
17470 } else
17471 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17472 }
17473 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17474 * might have been modified by someone else.
17475 */
17476 rmb();
17477 - if (atomic_read(&mce_paniced))
17478 + if (atomic_read_unchecked(&mce_paniced))
17479 wait_for_panic();
17480 if (!mca_cfg.monarch_timeout)
17481 goto out;
17482 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17483 }
17484
17485 /* Call the installed machine check handler for this CPU setup. */
17486 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17487 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17488 unexpected_machine_check;
17489
17490 /*
17491 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17492 return;
17493 }
17494
17495 + pax_open_kernel();
17496 machine_check_vector = do_machine_check;
17497 + pax_close_kernel();
17498
17499 __mcheck_cpu_init_generic();
17500 __mcheck_cpu_init_vendor(c);
17501 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17502 */
17503
17504 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17505 -static int mce_chrdev_open_count; /* #times opened */
17506 +static local_t mce_chrdev_open_count; /* #times opened */
17507 static int mce_chrdev_open_exclu; /* already open exclusive? */
17508
17509 static int mce_chrdev_open(struct inode *inode, struct file *file)
17510 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17511 spin_lock(&mce_chrdev_state_lock);
17512
17513 if (mce_chrdev_open_exclu ||
17514 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17515 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17516 spin_unlock(&mce_chrdev_state_lock);
17517
17518 return -EBUSY;
17519 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17520
17521 if (file->f_flags & O_EXCL)
17522 mce_chrdev_open_exclu = 1;
17523 - mce_chrdev_open_count++;
17524 + local_inc(&mce_chrdev_open_count);
17525
17526 spin_unlock(&mce_chrdev_state_lock);
17527
17528 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17529 {
17530 spin_lock(&mce_chrdev_state_lock);
17531
17532 - mce_chrdev_open_count--;
17533 + local_dec(&mce_chrdev_open_count);
17534 mce_chrdev_open_exclu = 0;
17535
17536 spin_unlock(&mce_chrdev_state_lock);
17537 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17538 return NOTIFY_OK;
17539 }
17540
17541 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17542 +static struct notifier_block mce_cpu_notifier = {
17543 .notifier_call = mce_cpu_callback,
17544 };
17545
17546 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17547
17548 for (i = 0; i < mca_cfg.banks; i++) {
17549 struct mce_bank *b = &mce_banks[i];
17550 - struct device_attribute *a = &b->attr;
17551 + device_attribute_no_const *a = &b->attr;
17552
17553 sysfs_attr_init(&a->attr);
17554 a->attr.name = b->attrname;
17555 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17556 static void mce_reset(void)
17557 {
17558 cpu_missing = 0;
17559 - atomic_set(&mce_fake_paniced, 0);
17560 + atomic_set_unchecked(&mce_fake_paniced, 0);
17561 atomic_set(&mce_executing, 0);
17562 atomic_set(&mce_callin, 0);
17563 atomic_set(&global_nwo, 0);
17564 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17565 index 1c044b1..37a2a43 100644
17566 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17567 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17568 @@ -11,6 +11,7 @@
17569 #include <asm/processor.h>
17570 #include <asm/mce.h>
17571 #include <asm/msr.h>
17572 +#include <asm/pgtable.h>
17573
17574 /* By default disabled */
17575 int mce_p5_enabled __read_mostly;
17576 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17577 if (!cpu_has(c, X86_FEATURE_MCE))
17578 return;
17579
17580 + pax_open_kernel();
17581 machine_check_vector = pentium_machine_check;
17582 + pax_close_kernel();
17583 /* Make sure the vector pointer is visible before we enable MCEs: */
17584 wmb();
17585
17586 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17587 index 47a1870..8c019a7 100644
17588 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17589 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17590 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17591 return notifier_from_errno(err);
17592 }
17593
17594 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17595 +static struct notifier_block thermal_throttle_cpu_notifier =
17596 {
17597 .notifier_call = thermal_throttle_cpu_callback,
17598 };
17599 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17600 index e9a701a..35317d6 100644
17601 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17602 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17603 @@ -10,6 +10,7 @@
17604 #include <asm/processor.h>
17605 #include <asm/mce.h>
17606 #include <asm/msr.h>
17607 +#include <asm/pgtable.h>
17608
17609 /* Machine check handler for WinChip C6: */
17610 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17611 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17612 {
17613 u32 lo, hi;
17614
17615 + pax_open_kernel();
17616 machine_check_vector = winchip_machine_check;
17617 + pax_close_kernel();
17618 /* Make sure the vector pointer is visible before we enable MCEs: */
17619 wmb();
17620
17621 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17622 index 726bf96..81f0526 100644
17623 --- a/arch/x86/kernel/cpu/mtrr/main.c
17624 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17625 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17626 u64 size_or_mask, size_and_mask;
17627 static bool mtrr_aps_delayed_init;
17628
17629 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17630 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17631
17632 const struct mtrr_ops *mtrr_if;
17633
17634 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17635 index df5e41f..816c719 100644
17636 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17637 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17638 @@ -25,7 +25,7 @@ struct mtrr_ops {
17639 int (*validate_add_page)(unsigned long base, unsigned long size,
17640 unsigned int type);
17641 int (*have_wrcomb)(void);
17642 -};
17643 +} __do_const;
17644
17645 extern int generic_get_free_region(unsigned long base, unsigned long size,
17646 int replace_reg);
17647 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17648 index 1025f3c..824f677 100644
17649 --- a/arch/x86/kernel/cpu/perf_event.c
17650 +++ b/arch/x86/kernel/cpu/perf_event.c
17651 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
17652 pr_info("no hardware sampling interrupt available.\n");
17653 }
17654
17655 -static struct attribute_group x86_pmu_format_group = {
17656 +static attribute_group_no_const x86_pmu_format_group = {
17657 .name = "format",
17658 .attrs = NULL,
17659 };
17660 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
17661 NULL,
17662 };
17663
17664 -static struct attribute_group x86_pmu_events_group = {
17665 +static attribute_group_no_const x86_pmu_events_group = {
17666 .name = "events",
17667 .attrs = events_attr,
17668 };
17669 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
17670 if (idx > GDT_ENTRIES)
17671 return 0;
17672
17673 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17674 + desc = get_cpu_gdt_table(smp_processor_id());
17675 }
17676
17677 return get_desc_base(desc + idx);
17678 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17679 break;
17680
17681 perf_callchain_store(entry, frame.return_address);
17682 - fp = frame.next_frame;
17683 + fp = (const void __force_user *)frame.next_frame;
17684 }
17685 }
17686
17687 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17688 index a9e2207..d70c83a 100644
17689 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17690 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17691 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
17692 * v2 and above have a perf capabilities MSR
17693 */
17694 if (version > 1) {
17695 - u64 capabilities;
17696 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17697
17698 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17699 - x86_pmu.intel_cap.capabilities = capabilities;
17700 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17701 + x86_pmu.intel_cap.capabilities = capabilities;
17702 }
17703
17704 intel_ds_init();
17705 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17706 index 52441a2..f94fae8 100644
17707 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17708 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17709 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17710 static int __init uncore_type_init(struct intel_uncore_type *type)
17711 {
17712 struct intel_uncore_pmu *pmus;
17713 - struct attribute_group *attr_group;
17714 + attribute_group_no_const *attr_group;
17715 struct attribute **attrs;
17716 int i, j;
17717
17718 @@ -3518,7 +3518,7 @@ static int
17719 return NOTIFY_OK;
17720 }
17721
17722 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17723 +static struct notifier_block uncore_cpu_nb = {
17724 .notifier_call = uncore_cpu_notifier,
17725 /*
17726 * to migrate uncore events, our notifier should be executed
17727 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17728 index f952891..4722ad4 100644
17729 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17730 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17731 @@ -488,7 +488,7 @@ struct intel_uncore_box {
17732 struct uncore_event_desc {
17733 struct kobj_attribute attr;
17734 const char *config;
17735 -};
17736 +} __do_const;
17737
17738 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17739 { \
17740 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17741 index 1e4dbcf..b9a34c2 100644
17742 --- a/arch/x86/kernel/cpuid.c
17743 +++ b/arch/x86/kernel/cpuid.c
17744 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17745 return notifier_from_errno(err);
17746 }
17747
17748 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17749 +static struct notifier_block cpuid_class_cpu_notifier =
17750 {
17751 .notifier_call = cpuid_class_cpu_callback,
17752 };
17753 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17754 index 74467fe..18793d5 100644
17755 --- a/arch/x86/kernel/crash.c
17756 +++ b/arch/x86/kernel/crash.c
17757 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17758 {
17759 #ifdef CONFIG_X86_32
17760 struct pt_regs fixed_regs;
17761 -#endif
17762
17763 -#ifdef CONFIG_X86_32
17764 - if (!user_mode_vm(regs)) {
17765 + if (!user_mode(regs)) {
17766 crash_fixup_ss_esp(&fixed_regs, regs);
17767 regs = &fixed_regs;
17768 }
17769 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17770 index afa64ad..dce67dd 100644
17771 --- a/arch/x86/kernel/crash_dump_64.c
17772 +++ b/arch/x86/kernel/crash_dump_64.c
17773 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17774 return -ENOMEM;
17775
17776 if (userbuf) {
17777 - if (copy_to_user(buf, vaddr + offset, csize)) {
17778 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17779 iounmap(vaddr);
17780 return -EFAULT;
17781 }
17782 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17783 index 155a13f..1672b9b 100644
17784 --- a/arch/x86/kernel/doublefault_32.c
17785 +++ b/arch/x86/kernel/doublefault_32.c
17786 @@ -11,7 +11,7 @@
17787
17788 #define DOUBLEFAULT_STACKSIZE (1024)
17789 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17790 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17791 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17792
17793 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17794
17795 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17796 unsigned long gdt, tss;
17797
17798 native_store_gdt(&gdt_desc);
17799 - gdt = gdt_desc.address;
17800 + gdt = (unsigned long)gdt_desc.address;
17801
17802 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17803
17804 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17805 /* 0x2 bit is always set */
17806 .flags = X86_EFLAGS_SF | 0x2,
17807 .sp = STACK_START,
17808 - .es = __USER_DS,
17809 + .es = __KERNEL_DS,
17810 .cs = __KERNEL_CS,
17811 .ss = __KERNEL_DS,
17812 - .ds = __USER_DS,
17813 + .ds = __KERNEL_DS,
17814 .fs = __KERNEL_PERCPU,
17815
17816 .__cr3 = __pa_nodebug(swapper_pg_dir),
17817 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17818 index deb6421..622e0ed 100644
17819 --- a/arch/x86/kernel/dumpstack.c
17820 +++ b/arch/x86/kernel/dumpstack.c
17821 @@ -2,6 +2,9 @@
17822 * Copyright (C) 1991, 1992 Linus Torvalds
17823 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17824 */
17825 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17826 +#define __INCLUDED_BY_HIDESYM 1
17827 +#endif
17828 #include <linux/kallsyms.h>
17829 #include <linux/kprobes.h>
17830 #include <linux/uaccess.h>
17831 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17832 static void
17833 print_ftrace_graph_addr(unsigned long addr, void *data,
17834 const struct stacktrace_ops *ops,
17835 - struct thread_info *tinfo, int *graph)
17836 + struct task_struct *task, int *graph)
17837 {
17838 - struct task_struct *task;
17839 unsigned long ret_addr;
17840 int index;
17841
17842 if (addr != (unsigned long)return_to_handler)
17843 return;
17844
17845 - task = tinfo->task;
17846 index = task->curr_ret_stack;
17847
17848 if (!task->ret_stack || index < *graph)
17849 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17850 static inline void
17851 print_ftrace_graph_addr(unsigned long addr, void *data,
17852 const struct stacktrace_ops *ops,
17853 - struct thread_info *tinfo, int *graph)
17854 + struct task_struct *task, int *graph)
17855 { }
17856 #endif
17857
17858 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17859 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17860 */
17861
17862 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17863 - void *p, unsigned int size, void *end)
17864 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17865 {
17866 - void *t = tinfo;
17867 if (end) {
17868 if (p < end && p >= (end-THREAD_SIZE))
17869 return 1;
17870 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17871 }
17872
17873 unsigned long
17874 -print_context_stack(struct thread_info *tinfo,
17875 +print_context_stack(struct task_struct *task, void *stack_start,
17876 unsigned long *stack, unsigned long bp,
17877 const struct stacktrace_ops *ops, void *data,
17878 unsigned long *end, int *graph)
17879 {
17880 struct stack_frame *frame = (struct stack_frame *)bp;
17881
17882 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17883 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17884 unsigned long addr;
17885
17886 addr = *stack;
17887 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17888 } else {
17889 ops->address(data, addr, 0);
17890 }
17891 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17892 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17893 }
17894 stack++;
17895 }
17896 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17897 EXPORT_SYMBOL_GPL(print_context_stack);
17898
17899 unsigned long
17900 -print_context_stack_bp(struct thread_info *tinfo,
17901 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17902 unsigned long *stack, unsigned long bp,
17903 const struct stacktrace_ops *ops, void *data,
17904 unsigned long *end, int *graph)
17905 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17906 struct stack_frame *frame = (struct stack_frame *)bp;
17907 unsigned long *ret_addr = &frame->return_address;
17908
17909 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17910 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17911 unsigned long addr = *ret_addr;
17912
17913 if (!__kernel_text_address(addr))
17914 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17915 ops->address(data, addr, 1);
17916 frame = frame->next_frame;
17917 ret_addr = &frame->return_address;
17918 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17919 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17920 }
17921
17922 return (unsigned long)frame;
17923 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
17924 }
17925 EXPORT_SYMBOL_GPL(oops_begin);
17926
17927 +extern void gr_handle_kernel_exploit(void);
17928 +
17929 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17930 {
17931 if (regs && kexec_should_crash(current))
17932 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17933 panic("Fatal exception in interrupt");
17934 if (panic_on_oops)
17935 panic("Fatal exception");
17936 - do_exit(signr);
17937 +
17938 + gr_handle_kernel_exploit();
17939 +
17940 + do_group_exit(signr);
17941 }
17942
17943 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17944 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17945 print_modules();
17946 show_regs(regs);
17947 #ifdef CONFIG_X86_32
17948 - if (user_mode_vm(regs)) {
17949 + if (user_mode(regs)) {
17950 sp = regs->sp;
17951 ss = regs->ss & 0xffff;
17952 } else {
17953 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17954 unsigned long flags = oops_begin();
17955 int sig = SIGSEGV;
17956
17957 - if (!user_mode_vm(regs))
17958 + if (!user_mode(regs))
17959 report_bug(regs->ip, regs);
17960
17961 if (__die(str, regs, err))
17962 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17963 index f2a1770..540657f 100644
17964 --- a/arch/x86/kernel/dumpstack_32.c
17965 +++ b/arch/x86/kernel/dumpstack_32.c
17966 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17967 bp = stack_frame(task, regs);
17968
17969 for (;;) {
17970 - struct thread_info *context;
17971 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17972
17973 - context = (struct thread_info *)
17974 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17975 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17976 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17977
17978 - stack = (unsigned long *)context->previous_esp;
17979 - if (!stack)
17980 + if (stack_start == task_stack_page(task))
17981 break;
17982 + stack = *(unsigned long **)stack_start;
17983 if (ops->stack(data, "IRQ") < 0)
17984 break;
17985 touch_nmi_watchdog();
17986 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
17987 int i;
17988
17989 show_regs_print_info(KERN_EMERG);
17990 - __show_regs(regs, !user_mode_vm(regs));
17991 + __show_regs(regs, !user_mode(regs));
17992
17993 /*
17994 * When in-kernel, we also print out the stack and code at the
17995 * time of the fault..
17996 */
17997 - if (!user_mode_vm(regs)) {
17998 + if (!user_mode(regs)) {
17999 unsigned int code_prologue = code_bytes * 43 / 64;
18000 unsigned int code_len = code_bytes;
18001 unsigned char c;
18002 u8 *ip;
18003 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18004
18005 pr_emerg("Stack:\n");
18006 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18007
18008 pr_emerg("Code:");
18009
18010 - ip = (u8 *)regs->ip - code_prologue;
18011 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18012 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18013 /* try starting at IP */
18014 - ip = (u8 *)regs->ip;
18015 + ip = (u8 *)regs->ip + cs_base;
18016 code_len = code_len - code_prologue + 1;
18017 }
18018 for (i = 0; i < code_len; i++, ip++) {
18019 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
18020 pr_cont(" Bad EIP value.");
18021 break;
18022 }
18023 - if (ip == (u8 *)regs->ip)
18024 + if (ip == (u8 *)regs->ip + cs_base)
18025 pr_cont(" <%02x>", c);
18026 else
18027 pr_cont(" %02x", c);
18028 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
18029 {
18030 unsigned short ud2;
18031
18032 + ip = ktla_ktva(ip);
18033 if (ip < PAGE_OFFSET)
18034 return 0;
18035 if (probe_kernel_address((unsigned short *)ip, ud2))
18036 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
18037
18038 return ud2 == 0x0b0f;
18039 }
18040 +
18041 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18042 +void pax_check_alloca(unsigned long size)
18043 +{
18044 + unsigned long sp = (unsigned long)&sp, stack_left;
18045 +
18046 + /* all kernel stacks are of the same size */
18047 + stack_left = sp & (THREAD_SIZE - 1);
18048 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18049 +}
18050 +EXPORT_SYMBOL(pax_check_alloca);
18051 +#endif
18052 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18053 index addb207..99635fa 100644
18054 --- a/arch/x86/kernel/dumpstack_64.c
18055 +++ b/arch/x86/kernel/dumpstack_64.c
18056 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18057 unsigned long *irq_stack_end =
18058 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18059 unsigned used = 0;
18060 - struct thread_info *tinfo;
18061 int graph = 0;
18062 unsigned long dummy;
18063 + void *stack_start;
18064
18065 if (!task)
18066 task = current;
18067 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18068 * current stack address. If the stacks consist of nested
18069 * exceptions
18070 */
18071 - tinfo = task_thread_info(task);
18072 for (;;) {
18073 char *id;
18074 unsigned long *estack_end;
18075 +
18076 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18077 &used, &id);
18078
18079 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18080 if (ops->stack(data, id) < 0)
18081 break;
18082
18083 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18084 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18085 data, estack_end, &graph);
18086 ops->stack(data, "<EOE>");
18087 /*
18088 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18089 * second-to-last pointer (index -2 to end) in the
18090 * exception stack:
18091 */
18092 + if ((u16)estack_end[-1] != __KERNEL_DS)
18093 + goto out;
18094 stack = (unsigned long *) estack_end[-2];
18095 continue;
18096 }
18097 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18098 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18099 if (ops->stack(data, "IRQ") < 0)
18100 break;
18101 - bp = ops->walk_stack(tinfo, stack, bp,
18102 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18103 ops, data, irq_stack_end, &graph);
18104 /*
18105 * We link to the next stack (which would be
18106 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18107 /*
18108 * This handles the process stack:
18109 */
18110 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18111 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18112 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18113 +out:
18114 put_cpu();
18115 }
18116 EXPORT_SYMBOL(dump_trace);
18117 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
18118
18119 return ud2 == 0x0b0f;
18120 }
18121 +
18122 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18123 +void pax_check_alloca(unsigned long size)
18124 +{
18125 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18126 + unsigned cpu, used;
18127 + char *id;
18128 +
18129 + /* check the process stack first */
18130 + stack_start = (unsigned long)task_stack_page(current);
18131 + stack_end = stack_start + THREAD_SIZE;
18132 + if (likely(stack_start <= sp && sp < stack_end)) {
18133 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18134 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18135 + return;
18136 + }
18137 +
18138 + cpu = get_cpu();
18139 +
18140 + /* check the irq stacks */
18141 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18142 + stack_start = stack_end - IRQ_STACK_SIZE;
18143 + if (stack_start <= sp && sp < stack_end) {
18144 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18145 + put_cpu();
18146 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18147 + return;
18148 + }
18149 +
18150 + /* check the exception stacks */
18151 + used = 0;
18152 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18153 + stack_start = stack_end - EXCEPTION_STKSZ;
18154 + if (stack_end && stack_start <= sp && sp < stack_end) {
18155 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18156 + put_cpu();
18157 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18158 + return;
18159 + }
18160 +
18161 + put_cpu();
18162 +
18163 + /* unknown stack */
18164 + BUG();
18165 +}
18166 +EXPORT_SYMBOL(pax_check_alloca);
18167 +#endif
18168 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18169 index d32abea..74daf4f 100644
18170 --- a/arch/x86/kernel/e820.c
18171 +++ b/arch/x86/kernel/e820.c
18172 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18173
18174 static void early_panic(char *msg)
18175 {
18176 - early_printk(msg);
18177 - panic(msg);
18178 + early_printk("%s", msg);
18179 + panic("%s", msg);
18180 }
18181
18182 static int userdef __initdata;
18183 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18184 index d15f575..d692043 100644
18185 --- a/arch/x86/kernel/early_printk.c
18186 +++ b/arch/x86/kernel/early_printk.c
18187 @@ -7,6 +7,7 @@
18188 #include <linux/pci_regs.h>
18189 #include <linux/pci_ids.h>
18190 #include <linux/errno.h>
18191 +#include <linux/sched.h>
18192 #include <asm/io.h>
18193 #include <asm/processor.h>
18194 #include <asm/fcntl.h>
18195 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18196 index 8f3e2de..caecc4e 100644
18197 --- a/arch/x86/kernel/entry_32.S
18198 +++ b/arch/x86/kernel/entry_32.S
18199 @@ -177,13 +177,153 @@
18200 /*CFI_REL_OFFSET gs, PT_GS*/
18201 .endm
18202 .macro SET_KERNEL_GS reg
18203 +
18204 +#ifdef CONFIG_CC_STACKPROTECTOR
18205 movl $(__KERNEL_STACK_CANARY), \reg
18206 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18207 + movl $(__USER_DS), \reg
18208 +#else
18209 + xorl \reg, \reg
18210 +#endif
18211 +
18212 movl \reg, %gs
18213 .endm
18214
18215 #endif /* CONFIG_X86_32_LAZY_GS */
18216
18217 -.macro SAVE_ALL
18218 +.macro pax_enter_kernel
18219 +#ifdef CONFIG_PAX_KERNEXEC
18220 + call pax_enter_kernel
18221 +#endif
18222 +.endm
18223 +
18224 +.macro pax_exit_kernel
18225 +#ifdef CONFIG_PAX_KERNEXEC
18226 + call pax_exit_kernel
18227 +#endif
18228 +.endm
18229 +
18230 +#ifdef CONFIG_PAX_KERNEXEC
18231 +ENTRY(pax_enter_kernel)
18232 +#ifdef CONFIG_PARAVIRT
18233 + pushl %eax
18234 + pushl %ecx
18235 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18236 + mov %eax, %esi
18237 +#else
18238 + mov %cr0, %esi
18239 +#endif
18240 + bts $16, %esi
18241 + jnc 1f
18242 + mov %cs, %esi
18243 + cmp $__KERNEL_CS, %esi
18244 + jz 3f
18245 + ljmp $__KERNEL_CS, $3f
18246 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18247 +2:
18248 +#ifdef CONFIG_PARAVIRT
18249 + mov %esi, %eax
18250 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18251 +#else
18252 + mov %esi, %cr0
18253 +#endif
18254 +3:
18255 +#ifdef CONFIG_PARAVIRT
18256 + popl %ecx
18257 + popl %eax
18258 +#endif
18259 + ret
18260 +ENDPROC(pax_enter_kernel)
18261 +
18262 +ENTRY(pax_exit_kernel)
18263 +#ifdef CONFIG_PARAVIRT
18264 + pushl %eax
18265 + pushl %ecx
18266 +#endif
18267 + mov %cs, %esi
18268 + cmp $__KERNEXEC_KERNEL_CS, %esi
18269 + jnz 2f
18270 +#ifdef CONFIG_PARAVIRT
18271 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18272 + mov %eax, %esi
18273 +#else
18274 + mov %cr0, %esi
18275 +#endif
18276 + btr $16, %esi
18277 + ljmp $__KERNEL_CS, $1f
18278 +1:
18279 +#ifdef CONFIG_PARAVIRT
18280 + mov %esi, %eax
18281 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18282 +#else
18283 + mov %esi, %cr0
18284 +#endif
18285 +2:
18286 +#ifdef CONFIG_PARAVIRT
18287 + popl %ecx
18288 + popl %eax
18289 +#endif
18290 + ret
18291 +ENDPROC(pax_exit_kernel)
18292 +#endif
18293 +
18294 + .macro pax_erase_kstack
18295 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18296 + call pax_erase_kstack
18297 +#endif
18298 + .endm
18299 +
18300 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18301 +/*
18302 + * ebp: thread_info
18303 + */
18304 +ENTRY(pax_erase_kstack)
18305 + pushl %edi
18306 + pushl %ecx
18307 + pushl %eax
18308 +
18309 + mov TI_lowest_stack(%ebp), %edi
18310 + mov $-0xBEEF, %eax
18311 + std
18312 +
18313 +1: mov %edi, %ecx
18314 + and $THREAD_SIZE_asm - 1, %ecx
18315 + shr $2, %ecx
18316 + repne scasl
18317 + jecxz 2f
18318 +
18319 + cmp $2*16, %ecx
18320 + jc 2f
18321 +
18322 + mov $2*16, %ecx
18323 + repe scasl
18324 + jecxz 2f
18325 + jne 1b
18326 +
18327 +2: cld
18328 + mov %esp, %ecx
18329 + sub %edi, %ecx
18330 +
18331 + cmp $THREAD_SIZE_asm, %ecx
18332 + jb 3f
18333 + ud2
18334 +3:
18335 +
18336 + shr $2, %ecx
18337 + rep stosl
18338 +
18339 + mov TI_task_thread_sp0(%ebp), %edi
18340 + sub $128, %edi
18341 + mov %edi, TI_lowest_stack(%ebp)
18342 +
18343 + popl %eax
18344 + popl %ecx
18345 + popl %edi
18346 + ret
18347 +ENDPROC(pax_erase_kstack)
18348 +#endif
18349 +
18350 +.macro __SAVE_ALL _DS
18351 cld
18352 PUSH_GS
18353 pushl_cfi %fs
18354 @@ -206,7 +346,7 @@
18355 CFI_REL_OFFSET ecx, 0
18356 pushl_cfi %ebx
18357 CFI_REL_OFFSET ebx, 0
18358 - movl $(__USER_DS), %edx
18359 + movl $\_DS, %edx
18360 movl %edx, %ds
18361 movl %edx, %es
18362 movl $(__KERNEL_PERCPU), %edx
18363 @@ -214,6 +354,15 @@
18364 SET_KERNEL_GS %edx
18365 .endm
18366
18367 +.macro SAVE_ALL
18368 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18369 + __SAVE_ALL __KERNEL_DS
18370 + pax_enter_kernel
18371 +#else
18372 + __SAVE_ALL __USER_DS
18373 +#endif
18374 +.endm
18375 +
18376 .macro RESTORE_INT_REGS
18377 popl_cfi %ebx
18378 CFI_RESTORE ebx
18379 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18380 popfl_cfi
18381 jmp syscall_exit
18382 CFI_ENDPROC
18383 -END(ret_from_fork)
18384 +ENDPROC(ret_from_fork)
18385
18386 ENTRY(ret_from_kernel_thread)
18387 CFI_STARTPROC
18388 @@ -344,7 +493,15 @@ ret_from_intr:
18389 andl $SEGMENT_RPL_MASK, %eax
18390 #endif
18391 cmpl $USER_RPL, %eax
18392 +
18393 +#ifdef CONFIG_PAX_KERNEXEC
18394 + jae resume_userspace
18395 +
18396 + pax_exit_kernel
18397 + jmp resume_kernel
18398 +#else
18399 jb resume_kernel # not returning to v8086 or userspace
18400 +#endif
18401
18402 ENTRY(resume_userspace)
18403 LOCKDEP_SYS_EXIT
18404 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18405 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18406 # int/exception return?
18407 jne work_pending
18408 - jmp restore_all
18409 -END(ret_from_exception)
18410 + jmp restore_all_pax
18411 +ENDPROC(ret_from_exception)
18412
18413 #ifdef CONFIG_PREEMPT
18414 ENTRY(resume_kernel)
18415 @@ -372,7 +529,7 @@ need_resched:
18416 jz restore_all
18417 call preempt_schedule_irq
18418 jmp need_resched
18419 -END(resume_kernel)
18420 +ENDPROC(resume_kernel)
18421 #endif
18422 CFI_ENDPROC
18423 /*
18424 @@ -406,30 +563,45 @@ sysenter_past_esp:
18425 /*CFI_REL_OFFSET cs, 0*/
18426 /*
18427 * Push current_thread_info()->sysenter_return to the stack.
18428 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18429 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18430 */
18431 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18432 + pushl_cfi $0
18433 CFI_REL_OFFSET eip, 0
18434
18435 pushl_cfi %eax
18436 SAVE_ALL
18437 + GET_THREAD_INFO(%ebp)
18438 + movl TI_sysenter_return(%ebp),%ebp
18439 + movl %ebp,PT_EIP(%esp)
18440 ENABLE_INTERRUPTS(CLBR_NONE)
18441
18442 /*
18443 * Load the potential sixth argument from user stack.
18444 * Careful about security.
18445 */
18446 + movl PT_OLDESP(%esp),%ebp
18447 +
18448 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18449 + mov PT_OLDSS(%esp),%ds
18450 +1: movl %ds:(%ebp),%ebp
18451 + push %ss
18452 + pop %ds
18453 +#else
18454 cmpl $__PAGE_OFFSET-3,%ebp
18455 jae syscall_fault
18456 ASM_STAC
18457 1: movl (%ebp),%ebp
18458 ASM_CLAC
18459 +#endif
18460 +
18461 movl %ebp,PT_EBP(%esp)
18462 _ASM_EXTABLE(1b,syscall_fault)
18463
18464 GET_THREAD_INFO(%ebp)
18465
18466 +#ifdef CONFIG_PAX_RANDKSTACK
18467 + pax_erase_kstack
18468 +#endif
18469 +
18470 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18471 jnz sysenter_audit
18472 sysenter_do_call:
18473 @@ -444,12 +616,24 @@ sysenter_do_call:
18474 testl $_TIF_ALLWORK_MASK, %ecx
18475 jne sysexit_audit
18476 sysenter_exit:
18477 +
18478 +#ifdef CONFIG_PAX_RANDKSTACK
18479 + pushl_cfi %eax
18480 + movl %esp, %eax
18481 + call pax_randomize_kstack
18482 + popl_cfi %eax
18483 +#endif
18484 +
18485 + pax_erase_kstack
18486 +
18487 /* if something modifies registers it must also disable sysexit */
18488 movl PT_EIP(%esp), %edx
18489 movl PT_OLDESP(%esp), %ecx
18490 xorl %ebp,%ebp
18491 TRACE_IRQS_ON
18492 1: mov PT_FS(%esp), %fs
18493 +2: mov PT_DS(%esp), %ds
18494 +3: mov PT_ES(%esp), %es
18495 PTGS_TO_GS
18496 ENABLE_INTERRUPTS_SYSEXIT
18497
18498 @@ -466,6 +650,9 @@ sysenter_audit:
18499 movl %eax,%edx /* 2nd arg: syscall number */
18500 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18501 call __audit_syscall_entry
18502 +
18503 + pax_erase_kstack
18504 +
18505 pushl_cfi %ebx
18506 movl PT_EAX(%esp),%eax /* reload syscall number */
18507 jmp sysenter_do_call
18508 @@ -491,10 +678,16 @@ sysexit_audit:
18509
18510 CFI_ENDPROC
18511 .pushsection .fixup,"ax"
18512 -2: movl $0,PT_FS(%esp)
18513 +4: movl $0,PT_FS(%esp)
18514 + jmp 1b
18515 +5: movl $0,PT_DS(%esp)
18516 + jmp 1b
18517 +6: movl $0,PT_ES(%esp)
18518 jmp 1b
18519 .popsection
18520 - _ASM_EXTABLE(1b,2b)
18521 + _ASM_EXTABLE(1b,4b)
18522 + _ASM_EXTABLE(2b,5b)
18523 + _ASM_EXTABLE(3b,6b)
18524 PTGS_TO_GS_EX
18525 ENDPROC(ia32_sysenter_target)
18526
18527 @@ -509,6 +702,11 @@ ENTRY(system_call)
18528 pushl_cfi %eax # save orig_eax
18529 SAVE_ALL
18530 GET_THREAD_INFO(%ebp)
18531 +
18532 +#ifdef CONFIG_PAX_RANDKSTACK
18533 + pax_erase_kstack
18534 +#endif
18535 +
18536 # system call tracing in operation / emulation
18537 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18538 jnz syscall_trace_entry
18539 @@ -527,6 +725,15 @@ syscall_exit:
18540 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18541 jne syscall_exit_work
18542
18543 +restore_all_pax:
18544 +
18545 +#ifdef CONFIG_PAX_RANDKSTACK
18546 + movl %esp, %eax
18547 + call pax_randomize_kstack
18548 +#endif
18549 +
18550 + pax_erase_kstack
18551 +
18552 restore_all:
18553 TRACE_IRQS_IRET
18554 restore_all_notrace:
18555 @@ -583,14 +790,34 @@ ldt_ss:
18556 * compensating for the offset by changing to the ESPFIX segment with
18557 * a base address that matches for the difference.
18558 */
18559 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18560 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18561 mov %esp, %edx /* load kernel esp */
18562 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18563 mov %dx, %ax /* eax: new kernel esp */
18564 sub %eax, %edx /* offset (low word is 0) */
18565 +#ifdef CONFIG_SMP
18566 + movl PER_CPU_VAR(cpu_number), %ebx
18567 + shll $PAGE_SHIFT_asm, %ebx
18568 + addl $cpu_gdt_table, %ebx
18569 +#else
18570 + movl $cpu_gdt_table, %ebx
18571 +#endif
18572 shr $16, %edx
18573 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18574 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18575 +
18576 +#ifdef CONFIG_PAX_KERNEXEC
18577 + mov %cr0, %esi
18578 + btr $16, %esi
18579 + mov %esi, %cr0
18580 +#endif
18581 +
18582 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18583 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18584 +
18585 +#ifdef CONFIG_PAX_KERNEXEC
18586 + bts $16, %esi
18587 + mov %esi, %cr0
18588 +#endif
18589 +
18590 pushl_cfi $__ESPFIX_SS
18591 pushl_cfi %eax /* new kernel esp */
18592 /* Disable interrupts, but do not irqtrace this section: we
18593 @@ -619,20 +846,18 @@ work_resched:
18594 movl TI_flags(%ebp), %ecx
18595 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18596 # than syscall tracing?
18597 - jz restore_all
18598 + jz restore_all_pax
18599 testb $_TIF_NEED_RESCHED, %cl
18600 jnz work_resched
18601
18602 work_notifysig: # deal with pending signals and
18603 # notify-resume requests
18604 + movl %esp, %eax
18605 #ifdef CONFIG_VM86
18606 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18607 - movl %esp, %eax
18608 jne work_notifysig_v86 # returning to kernel-space or
18609 # vm86-space
18610 1:
18611 -#else
18612 - movl %esp, %eax
18613 #endif
18614 TRACE_IRQS_ON
18615 ENABLE_INTERRUPTS(CLBR_NONE)
18616 @@ -653,7 +878,7 @@ work_notifysig_v86:
18617 movl %eax, %esp
18618 jmp 1b
18619 #endif
18620 -END(work_pending)
18621 +ENDPROC(work_pending)
18622
18623 # perform syscall exit tracing
18624 ALIGN
18625 @@ -661,11 +886,14 @@ syscall_trace_entry:
18626 movl $-ENOSYS,PT_EAX(%esp)
18627 movl %esp, %eax
18628 call syscall_trace_enter
18629 +
18630 + pax_erase_kstack
18631 +
18632 /* What it returned is what we'll actually use. */
18633 cmpl $(NR_syscalls), %eax
18634 jnae syscall_call
18635 jmp syscall_exit
18636 -END(syscall_trace_entry)
18637 +ENDPROC(syscall_trace_entry)
18638
18639 # perform syscall exit tracing
18640 ALIGN
18641 @@ -678,21 +906,25 @@ syscall_exit_work:
18642 movl %esp, %eax
18643 call syscall_trace_leave
18644 jmp resume_userspace
18645 -END(syscall_exit_work)
18646 +ENDPROC(syscall_exit_work)
18647 CFI_ENDPROC
18648
18649 RING0_INT_FRAME # can't unwind into user space anyway
18650 syscall_fault:
18651 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18652 + push %ss
18653 + pop %ds
18654 +#endif
18655 ASM_CLAC
18656 GET_THREAD_INFO(%ebp)
18657 movl $-EFAULT,PT_EAX(%esp)
18658 jmp resume_userspace
18659 -END(syscall_fault)
18660 +ENDPROC(syscall_fault)
18661
18662 syscall_badsys:
18663 movl $-ENOSYS,PT_EAX(%esp)
18664 jmp resume_userspace
18665 -END(syscall_badsys)
18666 +ENDPROC(syscall_badsys)
18667 CFI_ENDPROC
18668 /*
18669 * End of kprobes section
18670 @@ -708,8 +940,15 @@ END(syscall_badsys)
18671 * normal stack and adjusts ESP with the matching offset.
18672 */
18673 /* fixup the stack */
18674 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18675 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18676 +#ifdef CONFIG_SMP
18677 + movl PER_CPU_VAR(cpu_number), %ebx
18678 + shll $PAGE_SHIFT_asm, %ebx
18679 + addl $cpu_gdt_table, %ebx
18680 +#else
18681 + movl $cpu_gdt_table, %ebx
18682 +#endif
18683 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18684 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18685 shl $16, %eax
18686 addl %esp, %eax /* the adjusted stack pointer */
18687 pushl_cfi $__KERNEL_DS
18688 @@ -762,7 +1001,7 @@ vector=vector+1
18689 .endr
18690 2: jmp common_interrupt
18691 .endr
18692 -END(irq_entries_start)
18693 +ENDPROC(irq_entries_start)
18694
18695 .previous
18696 END(interrupt)
18697 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18698 pushl_cfi $do_coprocessor_error
18699 jmp error_code
18700 CFI_ENDPROC
18701 -END(coprocessor_error)
18702 +ENDPROC(coprocessor_error)
18703
18704 ENTRY(simd_coprocessor_error)
18705 RING0_INT_FRAME
18706 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18707 #endif
18708 jmp error_code
18709 CFI_ENDPROC
18710 -END(simd_coprocessor_error)
18711 +ENDPROC(simd_coprocessor_error)
18712
18713 ENTRY(device_not_available)
18714 RING0_INT_FRAME
18715 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18716 pushl_cfi $do_device_not_available
18717 jmp error_code
18718 CFI_ENDPROC
18719 -END(device_not_available)
18720 +ENDPROC(device_not_available)
18721
18722 #ifdef CONFIG_PARAVIRT
18723 ENTRY(native_iret)
18724 iret
18725 _ASM_EXTABLE(native_iret, iret_exc)
18726 -END(native_iret)
18727 +ENDPROC(native_iret)
18728
18729 ENTRY(native_irq_enable_sysexit)
18730 sti
18731 sysexit
18732 -END(native_irq_enable_sysexit)
18733 +ENDPROC(native_irq_enable_sysexit)
18734 #endif
18735
18736 ENTRY(overflow)
18737 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18738 pushl_cfi $do_overflow
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(overflow)
18742 +ENDPROC(overflow)
18743
18744 ENTRY(bounds)
18745 RING0_INT_FRAME
18746 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18747 pushl_cfi $do_bounds
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(bounds)
18751 +ENDPROC(bounds)
18752
18753 ENTRY(invalid_op)
18754 RING0_INT_FRAME
18755 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18756 pushl_cfi $do_invalid_op
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(invalid_op)
18760 +ENDPROC(invalid_op)
18761
18762 ENTRY(coprocessor_segment_overrun)
18763 RING0_INT_FRAME
18764 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18765 pushl_cfi $do_coprocessor_segment_overrun
18766 jmp error_code
18767 CFI_ENDPROC
18768 -END(coprocessor_segment_overrun)
18769 +ENDPROC(coprocessor_segment_overrun)
18770
18771 ENTRY(invalid_TSS)
18772 RING0_EC_FRAME
18773 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18774 pushl_cfi $do_invalid_TSS
18775 jmp error_code
18776 CFI_ENDPROC
18777 -END(invalid_TSS)
18778 +ENDPROC(invalid_TSS)
18779
18780 ENTRY(segment_not_present)
18781 RING0_EC_FRAME
18782 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18783 pushl_cfi $do_segment_not_present
18784 jmp error_code
18785 CFI_ENDPROC
18786 -END(segment_not_present)
18787 +ENDPROC(segment_not_present)
18788
18789 ENTRY(stack_segment)
18790 RING0_EC_FRAME
18791 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18792 pushl_cfi $do_stack_segment
18793 jmp error_code
18794 CFI_ENDPROC
18795 -END(stack_segment)
18796 +ENDPROC(stack_segment)
18797
18798 ENTRY(alignment_check)
18799 RING0_EC_FRAME
18800 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18801 pushl_cfi $do_alignment_check
18802 jmp error_code
18803 CFI_ENDPROC
18804 -END(alignment_check)
18805 +ENDPROC(alignment_check)
18806
18807 ENTRY(divide_error)
18808 RING0_INT_FRAME
18809 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18810 pushl_cfi $do_divide_error
18811 jmp error_code
18812 CFI_ENDPROC
18813 -END(divide_error)
18814 +ENDPROC(divide_error)
18815
18816 #ifdef CONFIG_X86_MCE
18817 ENTRY(machine_check)
18818 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18819 pushl_cfi machine_check_vector
18820 jmp error_code
18821 CFI_ENDPROC
18822 -END(machine_check)
18823 +ENDPROC(machine_check)
18824 #endif
18825
18826 ENTRY(spurious_interrupt_bug)
18827 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18828 pushl_cfi $do_spurious_interrupt_bug
18829 jmp error_code
18830 CFI_ENDPROC
18831 -END(spurious_interrupt_bug)
18832 +ENDPROC(spurious_interrupt_bug)
18833 /*
18834 * End of kprobes section
18835 */
18836 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18837
18838 ENTRY(mcount)
18839 ret
18840 -END(mcount)
18841 +ENDPROC(mcount)
18842
18843 ENTRY(ftrace_caller)
18844 cmpl $0, function_trace_stop
18845 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18846 .globl ftrace_stub
18847 ftrace_stub:
18848 ret
18849 -END(ftrace_caller)
18850 +ENDPROC(ftrace_caller)
18851
18852 ENTRY(ftrace_regs_caller)
18853 pushf /* push flags before compare (in cs location) */
18854 @@ -1197,7 +1436,7 @@ trace:
18855 popl %ecx
18856 popl %eax
18857 jmp ftrace_stub
18858 -END(mcount)
18859 +ENDPROC(mcount)
18860 #endif /* CONFIG_DYNAMIC_FTRACE */
18861 #endif /* CONFIG_FUNCTION_TRACER */
18862
18863 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18864 popl %ecx
18865 popl %eax
18866 ret
18867 -END(ftrace_graph_caller)
18868 +ENDPROC(ftrace_graph_caller)
18869
18870 .globl return_to_handler
18871 return_to_handler:
18872 @@ -1271,15 +1510,18 @@ error_code:
18873 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18874 REG_TO_PTGS %ecx
18875 SET_KERNEL_GS %ecx
18876 - movl $(__USER_DS), %ecx
18877 + movl $(__KERNEL_DS), %ecx
18878 movl %ecx, %ds
18879 movl %ecx, %es
18880 +
18881 + pax_enter_kernel
18882 +
18883 TRACE_IRQS_OFF
18884 movl %esp,%eax # pt_regs pointer
18885 call *%edi
18886 jmp ret_from_exception
18887 CFI_ENDPROC
18888 -END(page_fault)
18889 +ENDPROC(page_fault)
18890
18891 /*
18892 * Debug traps and NMI can happen at the one SYSENTER instruction
18893 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18894 call do_debug
18895 jmp ret_from_exception
18896 CFI_ENDPROC
18897 -END(debug)
18898 +ENDPROC(debug)
18899
18900 /*
18901 * NMI is doubly nasty. It can happen _while_ we're handling
18902 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18903 xorl %edx,%edx # zero error code
18904 movl %esp,%eax # pt_regs pointer
18905 call do_nmi
18906 +
18907 + pax_exit_kernel
18908 +
18909 jmp restore_all_notrace
18910 CFI_ENDPROC
18911
18912 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18913 FIXUP_ESPFIX_STACK # %eax == %esp
18914 xorl %edx,%edx # zero error code
18915 call do_nmi
18916 +
18917 + pax_exit_kernel
18918 +
18919 RESTORE_REGS
18920 lss 12+4(%esp), %esp # back to espfix stack
18921 CFI_ADJUST_CFA_OFFSET -24
18922 jmp irq_return
18923 CFI_ENDPROC
18924 -END(nmi)
18925 +ENDPROC(nmi)
18926
18927 ENTRY(int3)
18928 RING0_INT_FRAME
18929 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18930 call do_int3
18931 jmp ret_from_exception
18932 CFI_ENDPROC
18933 -END(int3)
18934 +ENDPROC(int3)
18935
18936 ENTRY(general_protection)
18937 RING0_EC_FRAME
18938 pushl_cfi $do_general_protection
18939 jmp error_code
18940 CFI_ENDPROC
18941 -END(general_protection)
18942 +ENDPROC(general_protection)
18943
18944 #ifdef CONFIG_KVM_GUEST
18945 ENTRY(async_page_fault)
18946 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18947 pushl_cfi $do_async_page_fault
18948 jmp error_code
18949 CFI_ENDPROC
18950 -END(async_page_fault)
18951 +ENDPROC(async_page_fault)
18952 #endif
18953
18954 /*
18955 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18956 index 7272089..6204f9c5 100644
18957 --- a/arch/x86/kernel/entry_64.S
18958 +++ b/arch/x86/kernel/entry_64.S
18959 @@ -59,6 +59,8 @@
18960 #include <asm/context_tracking.h>
18961 #include <asm/smap.h>
18962 #include <linux/err.h>
18963 +#include <asm/pgtable.h>
18964 +#include <asm/alternative-asm.h>
18965
18966 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18967 #include <linux/elf-em.h>
18968 @@ -80,8 +82,9 @@
18969 #ifdef CONFIG_DYNAMIC_FTRACE
18970
18971 ENTRY(function_hook)
18972 + pax_force_retaddr
18973 retq
18974 -END(function_hook)
18975 +ENDPROC(function_hook)
18976
18977 /* skip is set if stack has been adjusted */
18978 .macro ftrace_caller_setup skip=0
18979 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18980 #endif
18981
18982 GLOBAL(ftrace_stub)
18983 + pax_force_retaddr
18984 retq
18985 -END(ftrace_caller)
18986 +ENDPROC(ftrace_caller)
18987
18988 ENTRY(ftrace_regs_caller)
18989 /* Save the current flags before compare (in SS location)*/
18990 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18991 popfq
18992 jmp ftrace_stub
18993
18994 -END(ftrace_regs_caller)
18995 +ENDPROC(ftrace_regs_caller)
18996
18997
18998 #else /* ! CONFIG_DYNAMIC_FTRACE */
18999 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19000 #endif
19001
19002 GLOBAL(ftrace_stub)
19003 + pax_force_retaddr
19004 retq
19005
19006 trace:
19007 @@ -225,12 +230,13 @@ trace:
19008 #endif
19009 subq $MCOUNT_INSN_SIZE, %rdi
19010
19011 + pax_force_fptr ftrace_trace_function
19012 call *ftrace_trace_function
19013
19014 MCOUNT_RESTORE_FRAME
19015
19016 jmp ftrace_stub
19017 -END(function_hook)
19018 +ENDPROC(function_hook)
19019 #endif /* CONFIG_DYNAMIC_FTRACE */
19020 #endif /* CONFIG_FUNCTION_TRACER */
19021
19022 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19023
19024 MCOUNT_RESTORE_FRAME
19025
19026 + pax_force_retaddr
19027 retq
19028 -END(ftrace_graph_caller)
19029 +ENDPROC(ftrace_graph_caller)
19030
19031 GLOBAL(return_to_handler)
19032 subq $24, %rsp
19033 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19034 movq 8(%rsp), %rdx
19035 movq (%rsp), %rax
19036 addq $24, %rsp
19037 + pax_force_fptr %rdi
19038 jmp *%rdi
19039 +ENDPROC(return_to_handler)
19040 #endif
19041
19042
19043 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19044 ENDPROC(native_usergs_sysret64)
19045 #endif /* CONFIG_PARAVIRT */
19046
19047 + .macro ljmpq sel, off
19048 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19049 + .byte 0x48; ljmp *1234f(%rip)
19050 + .pushsection .rodata
19051 + .align 16
19052 + 1234: .quad \off; .word \sel
19053 + .popsection
19054 +#else
19055 + pushq $\sel
19056 + pushq $\off
19057 + lretq
19058 +#endif
19059 + .endm
19060 +
19061 + .macro pax_enter_kernel
19062 + pax_set_fptr_mask
19063 +#ifdef CONFIG_PAX_KERNEXEC
19064 + call pax_enter_kernel
19065 +#endif
19066 + .endm
19067 +
19068 + .macro pax_exit_kernel
19069 +#ifdef CONFIG_PAX_KERNEXEC
19070 + call pax_exit_kernel
19071 +#endif
19072 + .endm
19073 +
19074 +#ifdef CONFIG_PAX_KERNEXEC
19075 +ENTRY(pax_enter_kernel)
19076 + pushq %rdi
19077 +
19078 +#ifdef CONFIG_PARAVIRT
19079 + PV_SAVE_REGS(CLBR_RDI)
19080 +#endif
19081 +
19082 + GET_CR0_INTO_RDI
19083 + bts $16,%rdi
19084 + jnc 3f
19085 + mov %cs,%edi
19086 + cmp $__KERNEL_CS,%edi
19087 + jnz 2f
19088 +1:
19089 +
19090 +#ifdef CONFIG_PARAVIRT
19091 + PV_RESTORE_REGS(CLBR_RDI)
19092 +#endif
19093 +
19094 + popq %rdi
19095 + pax_force_retaddr
19096 + retq
19097 +
19098 +2: ljmpq __KERNEL_CS,1b
19099 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19100 +4: SET_RDI_INTO_CR0
19101 + jmp 1b
19102 +ENDPROC(pax_enter_kernel)
19103 +
19104 +ENTRY(pax_exit_kernel)
19105 + pushq %rdi
19106 +
19107 +#ifdef CONFIG_PARAVIRT
19108 + PV_SAVE_REGS(CLBR_RDI)
19109 +#endif
19110 +
19111 + mov %cs,%rdi
19112 + cmp $__KERNEXEC_KERNEL_CS,%edi
19113 + jz 2f
19114 + GET_CR0_INTO_RDI
19115 + bts $16,%rdi
19116 + jnc 4f
19117 +1:
19118 +
19119 +#ifdef CONFIG_PARAVIRT
19120 + PV_RESTORE_REGS(CLBR_RDI);
19121 +#endif
19122 +
19123 + popq %rdi
19124 + pax_force_retaddr
19125 + retq
19126 +
19127 +2: GET_CR0_INTO_RDI
19128 + btr $16,%rdi
19129 + jnc 4f
19130 + ljmpq __KERNEL_CS,3f
19131 +3: SET_RDI_INTO_CR0
19132 + jmp 1b
19133 +4: ud2
19134 + jmp 4b
19135 +ENDPROC(pax_exit_kernel)
19136 +#endif
19137 +
19138 + .macro pax_enter_kernel_user
19139 + pax_set_fptr_mask
19140 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19141 + call pax_enter_kernel_user
19142 +#endif
19143 + .endm
19144 +
19145 + .macro pax_exit_kernel_user
19146 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19147 + call pax_exit_kernel_user
19148 +#endif
19149 +#ifdef CONFIG_PAX_RANDKSTACK
19150 + pushq %rax
19151 + pushq %r11
19152 + call pax_randomize_kstack
19153 + popq %r11
19154 + popq %rax
19155 +#endif
19156 + .endm
19157 +
19158 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19159 +ENTRY(pax_enter_kernel_user)
19160 + pushq %rdi
19161 + pushq %rbx
19162 +
19163 +#ifdef CONFIG_PARAVIRT
19164 + PV_SAVE_REGS(CLBR_RDI)
19165 +#endif
19166 +
19167 + GET_CR3_INTO_RDI
19168 + mov %rdi,%rbx
19169 + add $__START_KERNEL_map,%rbx
19170 + sub phys_base(%rip),%rbx
19171 +
19172 +#ifdef CONFIG_PARAVIRT
19173 + cmpl $0, pv_info+PARAVIRT_enabled
19174 + jz 1f
19175 + pushq %rdi
19176 + i = 0
19177 + .rept USER_PGD_PTRS
19178 + mov i*8(%rbx),%rsi
19179 + mov $0,%sil
19180 + lea i*8(%rbx),%rdi
19181 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19182 + i = i + 1
19183 + .endr
19184 + popq %rdi
19185 + jmp 2f
19186 +1:
19187 +#endif
19188 +
19189 + i = 0
19190 + .rept USER_PGD_PTRS
19191 + movb $0,i*8(%rbx)
19192 + i = i + 1
19193 + .endr
19194 +
19195 +#ifdef CONFIG_PARAVIRT
19196 +2:
19197 +#endif
19198 + SET_RDI_INTO_CR3
19199 +
19200 +#ifdef CONFIG_PAX_KERNEXEC
19201 + GET_CR0_INTO_RDI
19202 + bts $16,%rdi
19203 + SET_RDI_INTO_CR0
19204 +#endif
19205 +
19206 +#ifdef CONFIG_PARAVIRT
19207 + PV_RESTORE_REGS(CLBR_RDI)
19208 +#endif
19209 +
19210 + popq %rbx
19211 + popq %rdi
19212 + pax_force_retaddr
19213 + retq
19214 +ENDPROC(pax_enter_kernel_user)
19215 +
19216 +ENTRY(pax_exit_kernel_user)
19217 + pushq %rdi
19218 + pushq %rbx
19219 +
19220 +#ifdef CONFIG_PARAVIRT
19221 + PV_SAVE_REGS(CLBR_RDI)
19222 +#endif
19223 +
19224 +#ifdef CONFIG_PAX_KERNEXEC
19225 + GET_CR0_INTO_RDI
19226 + btr $16,%rdi
19227 + jnc 3f
19228 + SET_RDI_INTO_CR0
19229 +#endif
19230 +
19231 + GET_CR3_INTO_RDI
19232 + mov %rdi,%rbx
19233 + add $__START_KERNEL_map,%rbx
19234 + sub phys_base(%rip),%rbx
19235 +
19236 +#ifdef CONFIG_PARAVIRT
19237 + cmpl $0, pv_info+PARAVIRT_enabled
19238 + jz 1f
19239 + i = 0
19240 + .rept USER_PGD_PTRS
19241 + mov i*8(%rbx),%rsi
19242 + mov $0x67,%sil
19243 + lea i*8(%rbx),%rdi
19244 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19245 + i = i + 1
19246 + .endr
19247 + jmp 2f
19248 +1:
19249 +#endif
19250 +
19251 + i = 0
19252 + .rept USER_PGD_PTRS
19253 + movb $0x67,i*8(%rbx)
19254 + i = i + 1
19255 + .endr
19256 +
19257 +#ifdef CONFIG_PARAVIRT
19258 +2: PV_RESTORE_REGS(CLBR_RDI)
19259 +#endif
19260 +
19261 + popq %rbx
19262 + popq %rdi
19263 + pax_force_retaddr
19264 + retq
19265 +3: ud2
19266 + jmp 3b
19267 +ENDPROC(pax_exit_kernel_user)
19268 +#endif
19269 +
19270 + .macro pax_enter_kernel_nmi
19271 + pax_set_fptr_mask
19272 +
19273 +#ifdef CONFIG_PAX_KERNEXEC
19274 + GET_CR0_INTO_RDI
19275 + bts $16,%rdi
19276 + jc 110f
19277 + SET_RDI_INTO_CR0
19278 + or $2,%ebx
19279 +110:
19280 +#endif
19281 + .endm
19282 +
19283 + .macro pax_exit_kernel_nmi
19284 +#ifdef CONFIG_PAX_KERNEXEC
19285 + btr $1,%ebx
19286 + jnc 110f
19287 + GET_CR0_INTO_RDI
19288 + btr $16,%rdi
19289 + SET_RDI_INTO_CR0
19290 +110:
19291 +#endif
19292 + .endm
19293 +
19294 + .macro pax_erase_kstack
19295 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19296 + call pax_erase_kstack
19297 +#endif
19298 + .endm
19299 +
19300 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19301 +ENTRY(pax_erase_kstack)
19302 + pushq %rdi
19303 + pushq %rcx
19304 + pushq %rax
19305 + pushq %r11
19306 +
19307 + GET_THREAD_INFO(%r11)
19308 + mov TI_lowest_stack(%r11), %rdi
19309 + mov $-0xBEEF, %rax
19310 + std
19311 +
19312 +1: mov %edi, %ecx
19313 + and $THREAD_SIZE_asm - 1, %ecx
19314 + shr $3, %ecx
19315 + repne scasq
19316 + jecxz 2f
19317 +
19318 + cmp $2*8, %ecx
19319 + jc 2f
19320 +
19321 + mov $2*8, %ecx
19322 + repe scasq
19323 + jecxz 2f
19324 + jne 1b
19325 +
19326 +2: cld
19327 + mov %esp, %ecx
19328 + sub %edi, %ecx
19329 +
19330 + cmp $THREAD_SIZE_asm, %rcx
19331 + jb 3f
19332 + ud2
19333 +3:
19334 +
19335 + shr $3, %ecx
19336 + rep stosq
19337 +
19338 + mov TI_task_thread_sp0(%r11), %rdi
19339 + sub $256, %rdi
19340 + mov %rdi, TI_lowest_stack(%r11)
19341 +
19342 + popq %r11
19343 + popq %rax
19344 + popq %rcx
19345 + popq %rdi
19346 + pax_force_retaddr
19347 + ret
19348 +ENDPROC(pax_erase_kstack)
19349 +#endif
19350
19351 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19352 #ifdef CONFIG_TRACE_IRQFLAGS
19353 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19354 .endm
19355
19356 .macro UNFAKE_STACK_FRAME
19357 - addq $8*6, %rsp
19358 - CFI_ADJUST_CFA_OFFSET -(6*8)
19359 + addq $8*6 + ARG_SKIP, %rsp
19360 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19361 .endm
19362
19363 /*
19364 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19365 movq %rsp, %rsi
19366
19367 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19368 - testl $3, CS-RBP(%rsi)
19369 + testb $3, CS-RBP(%rsi)
19370 je 1f
19371 SWAPGS
19372 /*
19373 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19374 movq_cfi r15, R15+16
19375 movq %r11, 8(%rsp) /* return address */
19376 FIXUP_TOP_OF_STACK %r11, 16
19377 + pax_force_retaddr
19378 ret
19379 CFI_ENDPROC
19380 -END(save_rest)
19381 +ENDPROC(save_rest)
19382
19383 /* save complete stack frame */
19384 .pushsection .kprobes.text, "ax"
19385 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19386 js 1f /* negative -> in kernel */
19387 SWAPGS
19388 xorl %ebx,%ebx
19389 -1: ret
19390 +1: pax_force_retaddr_bts
19391 + ret
19392 CFI_ENDPROC
19393 -END(save_paranoid)
19394 +ENDPROC(save_paranoid)
19395 .popsection
19396
19397 /*
19398 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19399
19400 RESTORE_REST
19401
19402 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19403 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19404 jz 1f
19405
19406 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19407 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19408 RESTORE_REST
19409 jmp int_ret_from_sys_call
19410 CFI_ENDPROC
19411 -END(ret_from_fork)
19412 +ENDPROC(ret_from_fork)
19413
19414 /*
19415 * System call entry. Up to 6 arguments in registers are supported.
19416 @@ -608,7 +922,7 @@ END(ret_from_fork)
19417 ENTRY(system_call)
19418 CFI_STARTPROC simple
19419 CFI_SIGNAL_FRAME
19420 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19421 + CFI_DEF_CFA rsp,0
19422 CFI_REGISTER rip,rcx
19423 /*CFI_REGISTER rflags,r11*/
19424 SWAPGS_UNSAFE_STACK
19425 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19426
19427 movq %rsp,PER_CPU_VAR(old_rsp)
19428 movq PER_CPU_VAR(kernel_stack),%rsp
19429 + SAVE_ARGS 8*6,0
19430 + pax_enter_kernel_user
19431 +
19432 +#ifdef CONFIG_PAX_RANDKSTACK
19433 + pax_erase_kstack
19434 +#endif
19435 +
19436 /*
19437 * No need to follow this irqs off/on section - it's straight
19438 * and short:
19439 */
19440 ENABLE_INTERRUPTS(CLBR_NONE)
19441 - SAVE_ARGS 8,0
19442 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19443 movq %rcx,RIP-ARGOFFSET(%rsp)
19444 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19445 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19446 + GET_THREAD_INFO(%rcx)
19447 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19448 jnz tracesys
19449 system_call_fastpath:
19450 #if __SYSCALL_MASK == ~0
19451 @@ -640,7 +961,7 @@ system_call_fastpath:
19452 cmpl $__NR_syscall_max,%eax
19453 #endif
19454 ja badsys
19455 - movq %r10,%rcx
19456 + movq R10-ARGOFFSET(%rsp),%rcx
19457 call *sys_call_table(,%rax,8) # XXX: rip relative
19458 movq %rax,RAX-ARGOFFSET(%rsp)
19459 /*
19460 @@ -654,10 +975,13 @@ sysret_check:
19461 LOCKDEP_SYS_EXIT
19462 DISABLE_INTERRUPTS(CLBR_NONE)
19463 TRACE_IRQS_OFF
19464 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19465 + GET_THREAD_INFO(%rcx)
19466 + movl TI_flags(%rcx),%edx
19467 andl %edi,%edx
19468 jnz sysret_careful
19469 CFI_REMEMBER_STATE
19470 + pax_exit_kernel_user
19471 + pax_erase_kstack
19472 /*
19473 * sysretq will re-enable interrupts:
19474 */
19475 @@ -709,14 +1033,18 @@ badsys:
19476 * jump back to the normal fast path.
19477 */
19478 auditsys:
19479 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19480 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19481 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19482 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19483 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19484 movq %rax,%rsi /* 2nd arg: syscall number */
19485 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19486 call __audit_syscall_entry
19487 +
19488 + pax_erase_kstack
19489 +
19490 LOAD_ARGS 0 /* reload call-clobbered registers */
19491 + pax_set_fptr_mask
19492 jmp system_call_fastpath
19493
19494 /*
19495 @@ -737,7 +1065,7 @@ sysret_audit:
19496 /* Do syscall tracing */
19497 tracesys:
19498 #ifdef CONFIG_AUDITSYSCALL
19499 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19500 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19501 jz auditsys
19502 #endif
19503 SAVE_REST
19504 @@ -745,12 +1073,16 @@ tracesys:
19505 FIXUP_TOP_OF_STACK %rdi
19506 movq %rsp,%rdi
19507 call syscall_trace_enter
19508 +
19509 + pax_erase_kstack
19510 +
19511 /*
19512 * Reload arg registers from stack in case ptrace changed them.
19513 * We don't reload %rax because syscall_trace_enter() returned
19514 * the value it wants us to use in the table lookup.
19515 */
19516 LOAD_ARGS ARGOFFSET, 1
19517 + pax_set_fptr_mask
19518 RESTORE_REST
19519 #if __SYSCALL_MASK == ~0
19520 cmpq $__NR_syscall_max,%rax
19521 @@ -759,7 +1091,7 @@ tracesys:
19522 cmpl $__NR_syscall_max,%eax
19523 #endif
19524 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19525 - movq %r10,%rcx /* fixup for C */
19526 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19527 call *sys_call_table(,%rax,8)
19528 movq %rax,RAX-ARGOFFSET(%rsp)
19529 /* Use IRET because user could have changed frame */
19530 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19531 andl %edi,%edx
19532 jnz int_careful
19533 andl $~TS_COMPAT,TI_status(%rcx)
19534 - jmp retint_swapgs
19535 + pax_exit_kernel_user
19536 + pax_erase_kstack
19537 + jmp retint_swapgs_pax
19538
19539 /* Either reschedule or signal or syscall exit tracking needed. */
19540 /* First do a reschedule test. */
19541 @@ -826,7 +1160,7 @@ int_restore_rest:
19542 TRACE_IRQS_OFF
19543 jmp int_with_check
19544 CFI_ENDPROC
19545 -END(system_call)
19546 +ENDPROC(system_call)
19547
19548 .macro FORK_LIKE func
19549 ENTRY(stub_\func)
19550 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19551 DEFAULT_FRAME 0 8 /* offset 8: return address */
19552 call sys_\func
19553 RESTORE_TOP_OF_STACK %r11, 8
19554 + pax_force_retaddr
19555 ret $REST_SKIP /* pop extended registers */
19556 CFI_ENDPROC
19557 -END(stub_\func)
19558 +ENDPROC(stub_\func)
19559 .endm
19560
19561 .macro FIXED_FRAME label,func
19562 @@ -851,9 +1186,10 @@ ENTRY(\label)
19563 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19564 call \func
19565 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19566 + pax_force_retaddr
19567 ret
19568 CFI_ENDPROC
19569 -END(\label)
19570 +ENDPROC(\label)
19571 .endm
19572
19573 FORK_LIKE clone
19574 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19575 movq_cfi_restore R12+8, r12
19576 movq_cfi_restore RBP+8, rbp
19577 movq_cfi_restore RBX+8, rbx
19578 + pax_force_retaddr
19579 ret $REST_SKIP /* pop extended registers */
19580 CFI_ENDPROC
19581 -END(ptregscall_common)
19582 +ENDPROC(ptregscall_common)
19583
19584 ENTRY(stub_execve)
19585 CFI_STARTPROC
19586 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19587 RESTORE_REST
19588 jmp int_ret_from_sys_call
19589 CFI_ENDPROC
19590 -END(stub_execve)
19591 +ENDPROC(stub_execve)
19592
19593 /*
19594 * sigreturn is special because it needs to restore all registers on return.
19595 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19596 RESTORE_REST
19597 jmp int_ret_from_sys_call
19598 CFI_ENDPROC
19599 -END(stub_rt_sigreturn)
19600 +ENDPROC(stub_rt_sigreturn)
19601
19602 #ifdef CONFIG_X86_X32_ABI
19603 ENTRY(stub_x32_rt_sigreturn)
19604 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19605 RESTORE_REST
19606 jmp int_ret_from_sys_call
19607 CFI_ENDPROC
19608 -END(stub_x32_rt_sigreturn)
19609 +ENDPROC(stub_x32_rt_sigreturn)
19610
19611 ENTRY(stub_x32_execve)
19612 CFI_STARTPROC
19613 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19614 RESTORE_REST
19615 jmp int_ret_from_sys_call
19616 CFI_ENDPROC
19617 -END(stub_x32_execve)
19618 +ENDPROC(stub_x32_execve)
19619
19620 #endif
19621
19622 @@ -967,7 +1304,7 @@ vector=vector+1
19623 2: jmp common_interrupt
19624 .endr
19625 CFI_ENDPROC
19626 -END(irq_entries_start)
19627 +ENDPROC(irq_entries_start)
19628
19629 .previous
19630 END(interrupt)
19631 @@ -987,6 +1324,16 @@ END(interrupt)
19632 subq $ORIG_RAX-RBP, %rsp
19633 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19634 SAVE_ARGS_IRQ
19635 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19636 + testb $3, CS(%rdi)
19637 + jnz 1f
19638 + pax_enter_kernel
19639 + jmp 2f
19640 +1: pax_enter_kernel_user
19641 +2:
19642 +#else
19643 + pax_enter_kernel
19644 +#endif
19645 call \func
19646 .endm
19647
19648 @@ -1019,7 +1366,7 @@ ret_from_intr:
19649
19650 exit_intr:
19651 GET_THREAD_INFO(%rcx)
19652 - testl $3,CS-ARGOFFSET(%rsp)
19653 + testb $3,CS-ARGOFFSET(%rsp)
19654 je retint_kernel
19655
19656 /* Interrupt came from user space */
19657 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19658 * The iretq could re-enable interrupts:
19659 */
19660 DISABLE_INTERRUPTS(CLBR_ANY)
19661 + pax_exit_kernel_user
19662 +retint_swapgs_pax:
19663 TRACE_IRQS_IRETQ
19664 SWAPGS
19665 jmp restore_args
19666
19667 retint_restore_args: /* return to kernel space */
19668 DISABLE_INTERRUPTS(CLBR_ANY)
19669 + pax_exit_kernel
19670 + pax_force_retaddr (RIP-ARGOFFSET)
19671 /*
19672 * The iretq could re-enable interrupts:
19673 */
19674 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19675 #endif
19676
19677 CFI_ENDPROC
19678 -END(common_interrupt)
19679 +ENDPROC(common_interrupt)
19680 /*
19681 * End of kprobes section
19682 */
19683 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19684 interrupt \do_sym
19685 jmp ret_from_intr
19686 CFI_ENDPROC
19687 -END(\sym)
19688 +ENDPROC(\sym)
19689 .endm
19690
19691 #ifdef CONFIG_SMP
19692 @@ -1208,12 +1559,22 @@ ENTRY(\sym)
19693 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19694 call error_entry
19695 DEFAULT_FRAME 0
19696 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19697 + testb $3, CS(%rsp)
19698 + jnz 1f
19699 + pax_enter_kernel
19700 + jmp 2f
19701 +1: pax_enter_kernel_user
19702 +2:
19703 +#else
19704 + pax_enter_kernel
19705 +#endif
19706 movq %rsp,%rdi /* pt_regs pointer */
19707 xorl %esi,%esi /* no error code */
19708 call \do_sym
19709 jmp error_exit /* %ebx: no swapgs flag */
19710 CFI_ENDPROC
19711 -END(\sym)
19712 +ENDPROC(\sym)
19713 .endm
19714
19715 .macro paranoidzeroentry sym do_sym
19716 @@ -1226,15 +1587,25 @@ ENTRY(\sym)
19717 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19718 call save_paranoid
19719 TRACE_IRQS_OFF
19720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19721 + testb $3, CS(%rsp)
19722 + jnz 1f
19723 + pax_enter_kernel
19724 + jmp 2f
19725 +1: pax_enter_kernel_user
19726 +2:
19727 +#else
19728 + pax_enter_kernel
19729 +#endif
19730 movq %rsp,%rdi /* pt_regs pointer */
19731 xorl %esi,%esi /* no error code */
19732 call \do_sym
19733 jmp paranoid_exit /* %ebx: no swapgs flag */
19734 CFI_ENDPROC
19735 -END(\sym)
19736 +ENDPROC(\sym)
19737 .endm
19738
19739 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19740 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19741 .macro paranoidzeroentry_ist sym do_sym ist
19742 ENTRY(\sym)
19743 INTR_FRAME
19744 @@ -1245,14 +1616,30 @@ ENTRY(\sym)
19745 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19746 call save_paranoid
19747 TRACE_IRQS_OFF_DEBUG
19748 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19749 + testb $3, CS(%rsp)
19750 + jnz 1f
19751 + pax_enter_kernel
19752 + jmp 2f
19753 +1: pax_enter_kernel_user
19754 +2:
19755 +#else
19756 + pax_enter_kernel
19757 +#endif
19758 movq %rsp,%rdi /* pt_regs pointer */
19759 xorl %esi,%esi /* no error code */
19760 +#ifdef CONFIG_SMP
19761 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19762 + lea init_tss(%r12), %r12
19763 +#else
19764 + lea init_tss(%rip), %r12
19765 +#endif
19766 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19767 call \do_sym
19768 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19769 jmp paranoid_exit /* %ebx: no swapgs flag */
19770 CFI_ENDPROC
19771 -END(\sym)
19772 +ENDPROC(\sym)
19773 .endm
19774
19775 .macro errorentry sym do_sym
19776 @@ -1264,13 +1651,23 @@ ENTRY(\sym)
19777 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19778 call error_entry
19779 DEFAULT_FRAME 0
19780 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19781 + testb $3, CS(%rsp)
19782 + jnz 1f
19783 + pax_enter_kernel
19784 + jmp 2f
19785 +1: pax_enter_kernel_user
19786 +2:
19787 +#else
19788 + pax_enter_kernel
19789 +#endif
19790 movq %rsp,%rdi /* pt_regs pointer */
19791 movq ORIG_RAX(%rsp),%rsi /* get error code */
19792 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19793 call \do_sym
19794 jmp error_exit /* %ebx: no swapgs flag */
19795 CFI_ENDPROC
19796 -END(\sym)
19797 +ENDPROC(\sym)
19798 .endm
19799
19800 /* error code is on the stack already */
19801 @@ -1284,13 +1681,23 @@ ENTRY(\sym)
19802 call save_paranoid
19803 DEFAULT_FRAME 0
19804 TRACE_IRQS_OFF
19805 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19806 + testb $3, CS(%rsp)
19807 + jnz 1f
19808 + pax_enter_kernel
19809 + jmp 2f
19810 +1: pax_enter_kernel_user
19811 +2:
19812 +#else
19813 + pax_enter_kernel
19814 +#endif
19815 movq %rsp,%rdi /* pt_regs pointer */
19816 movq ORIG_RAX(%rsp),%rsi /* get error code */
19817 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19818 call \do_sym
19819 jmp paranoid_exit /* %ebx: no swapgs flag */
19820 CFI_ENDPROC
19821 -END(\sym)
19822 +ENDPROC(\sym)
19823 .endm
19824
19825 zeroentry divide_error do_divide_error
19826 @@ -1320,9 +1727,10 @@ gs_change:
19827 2: mfence /* workaround */
19828 SWAPGS
19829 popfq_cfi
19830 + pax_force_retaddr
19831 ret
19832 CFI_ENDPROC
19833 -END(native_load_gs_index)
19834 +ENDPROC(native_load_gs_index)
19835
19836 _ASM_EXTABLE(gs_change,bad_gs)
19837 .section .fixup,"ax"
19838 @@ -1350,9 +1758,10 @@ ENTRY(call_softirq)
19839 CFI_DEF_CFA_REGISTER rsp
19840 CFI_ADJUST_CFA_OFFSET -8
19841 decl PER_CPU_VAR(irq_count)
19842 + pax_force_retaddr
19843 ret
19844 CFI_ENDPROC
19845 -END(call_softirq)
19846 +ENDPROC(call_softirq)
19847
19848 #ifdef CONFIG_XEN
19849 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19850 @@ -1390,7 +1799,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19851 decl PER_CPU_VAR(irq_count)
19852 jmp error_exit
19853 CFI_ENDPROC
19854 -END(xen_do_hypervisor_callback)
19855 +ENDPROC(xen_do_hypervisor_callback)
19856
19857 /*
19858 * Hypervisor uses this for application faults while it executes.
19859 @@ -1449,7 +1858,7 @@ ENTRY(xen_failsafe_callback)
19860 SAVE_ALL
19861 jmp error_exit
19862 CFI_ENDPROC
19863 -END(xen_failsafe_callback)
19864 +ENDPROC(xen_failsafe_callback)
19865
19866 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19867 xen_hvm_callback_vector xen_evtchn_do_upcall
19868 @@ -1501,18 +1910,33 @@ ENTRY(paranoid_exit)
19869 DEFAULT_FRAME
19870 DISABLE_INTERRUPTS(CLBR_NONE)
19871 TRACE_IRQS_OFF_DEBUG
19872 - testl %ebx,%ebx /* swapgs needed? */
19873 + testl $1,%ebx /* swapgs needed? */
19874 jnz paranoid_restore
19875 - testl $3,CS(%rsp)
19876 + testb $3,CS(%rsp)
19877 jnz paranoid_userspace
19878 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19879 + pax_exit_kernel
19880 + TRACE_IRQS_IRETQ 0
19881 + SWAPGS_UNSAFE_STACK
19882 + RESTORE_ALL 8
19883 + pax_force_retaddr_bts
19884 + jmp irq_return
19885 +#endif
19886 paranoid_swapgs:
19887 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19888 + pax_exit_kernel_user
19889 +#else
19890 + pax_exit_kernel
19891 +#endif
19892 TRACE_IRQS_IRETQ 0
19893 SWAPGS_UNSAFE_STACK
19894 RESTORE_ALL 8
19895 jmp irq_return
19896 paranoid_restore:
19897 + pax_exit_kernel
19898 TRACE_IRQS_IRETQ_DEBUG 0
19899 RESTORE_ALL 8
19900 + pax_force_retaddr_bts
19901 jmp irq_return
19902 paranoid_userspace:
19903 GET_THREAD_INFO(%rcx)
19904 @@ -1541,7 +1965,7 @@ paranoid_schedule:
19905 TRACE_IRQS_OFF
19906 jmp paranoid_userspace
19907 CFI_ENDPROC
19908 -END(paranoid_exit)
19909 +ENDPROC(paranoid_exit)
19910
19911 /*
19912 * Exception entry point. This expects an error code/orig_rax on the stack.
19913 @@ -1568,12 +1992,13 @@ ENTRY(error_entry)
19914 movq_cfi r14, R14+8
19915 movq_cfi r15, R15+8
19916 xorl %ebx,%ebx
19917 - testl $3,CS+8(%rsp)
19918 + testb $3,CS+8(%rsp)
19919 je error_kernelspace
19920 error_swapgs:
19921 SWAPGS
19922 error_sti:
19923 TRACE_IRQS_OFF
19924 + pax_force_retaddr_bts
19925 ret
19926
19927 /*
19928 @@ -1600,7 +2025,7 @@ bstep_iret:
19929 movq %rcx,RIP+8(%rsp)
19930 jmp error_swapgs
19931 CFI_ENDPROC
19932 -END(error_entry)
19933 +ENDPROC(error_entry)
19934
19935
19936 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19937 @@ -1611,7 +2036,7 @@ ENTRY(error_exit)
19938 DISABLE_INTERRUPTS(CLBR_NONE)
19939 TRACE_IRQS_OFF
19940 GET_THREAD_INFO(%rcx)
19941 - testl %eax,%eax
19942 + testl $1,%eax
19943 jne retint_kernel
19944 LOCKDEP_SYS_EXIT_IRQ
19945 movl TI_flags(%rcx),%edx
19946 @@ -1620,7 +2045,7 @@ ENTRY(error_exit)
19947 jnz retint_careful
19948 jmp retint_swapgs
19949 CFI_ENDPROC
19950 -END(error_exit)
19951 +ENDPROC(error_exit)
19952
19953 /*
19954 * Test if a given stack is an NMI stack or not.
19955 @@ -1678,9 +2103,11 @@ ENTRY(nmi)
19956 * If %cs was not the kernel segment, then the NMI triggered in user
19957 * space, which means it is definitely not nested.
19958 */
19959 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19960 + je 1f
19961 cmpl $__KERNEL_CS, 16(%rsp)
19962 jne first_nmi
19963 -
19964 +1:
19965 /*
19966 * Check the special variable on the stack to see if NMIs are
19967 * executing.
19968 @@ -1714,8 +2141,7 @@ nested_nmi:
19969
19970 1:
19971 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19972 - leaq -1*8(%rsp), %rdx
19973 - movq %rdx, %rsp
19974 + subq $8, %rsp
19975 CFI_ADJUST_CFA_OFFSET 1*8
19976 leaq -10*8(%rsp), %rdx
19977 pushq_cfi $__KERNEL_DS
19978 @@ -1733,6 +2159,7 @@ nested_nmi_out:
19979 CFI_RESTORE rdx
19980
19981 /* No need to check faults here */
19982 +# pax_force_retaddr_bts
19983 INTERRUPT_RETURN
19984
19985 CFI_RESTORE_STATE
19986 @@ -1849,6 +2276,8 @@ end_repeat_nmi:
19987 */
19988 movq %cr2, %r12
19989
19990 + pax_enter_kernel_nmi
19991 +
19992 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19993 movq %rsp,%rdi
19994 movq $-1,%rsi
19995 @@ -1861,26 +2290,31 @@ end_repeat_nmi:
19996 movq %r12, %cr2
19997 1:
19998
19999 - testl %ebx,%ebx /* swapgs needed? */
20000 + testl $1,%ebx /* swapgs needed? */
20001 jnz nmi_restore
20002 nmi_swapgs:
20003 SWAPGS_UNSAFE_STACK
20004 nmi_restore:
20005 + pax_exit_kernel_nmi
20006 /* Pop the extra iret frame at once */
20007 RESTORE_ALL 6*8
20008 + testb $3, 8(%rsp)
20009 + jnz 1f
20010 + pax_force_retaddr_bts
20011 +1:
20012
20013 /* Clear the NMI executing stack variable */
20014 movq $0, 5*8(%rsp)
20015 jmp irq_return
20016 CFI_ENDPROC
20017 -END(nmi)
20018 +ENDPROC(nmi)
20019
20020 ENTRY(ignore_sysret)
20021 CFI_STARTPROC
20022 mov $-ENOSYS,%eax
20023 sysret
20024 CFI_ENDPROC
20025 -END(ignore_sysret)
20026 +ENDPROC(ignore_sysret)
20027
20028 /*
20029 * End of kprobes section
20030 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20031 index 42a392a..fbbd930 100644
20032 --- a/arch/x86/kernel/ftrace.c
20033 +++ b/arch/x86/kernel/ftrace.c
20034 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20035 {
20036 unsigned char replaced[MCOUNT_INSN_SIZE];
20037
20038 + ip = ktla_ktva(ip);
20039 +
20040 /*
20041 * Note: Due to modules and __init, code can
20042 * disappear and change, we need to protect against faulting
20043 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20044 unsigned char old[MCOUNT_INSN_SIZE], *new;
20045 int ret;
20046
20047 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20048 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20049 new = ftrace_call_replace(ip, (unsigned long)func);
20050
20051 /* See comment above by declaration of modifying_ftrace_code */
20052 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20053 /* Also update the regs callback function */
20054 if (!ret) {
20055 ip = (unsigned long)(&ftrace_regs_call);
20056 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20057 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20058 new = ftrace_call_replace(ip, (unsigned long)func);
20059 ret = ftrace_modify_code(ip, old, new);
20060 }
20061 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20062 * kernel identity mapping to modify code.
20063 */
20064 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20065 - ip = (unsigned long)__va(__pa_symbol(ip));
20066 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20067
20068 return probe_kernel_write((void *)ip, val, size);
20069 }
20070 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20071 unsigned char replaced[MCOUNT_INSN_SIZE];
20072 unsigned char brk = BREAKPOINT_INSTRUCTION;
20073
20074 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20075 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20076 return -EFAULT;
20077
20078 /* Make sure it is what we expect it to be */
20079 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20080 return ret;
20081
20082 fail_update:
20083 - probe_kernel_write((void *)ip, &old_code[0], 1);
20084 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20085 goto out;
20086 }
20087
20088 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20089 {
20090 unsigned char code[MCOUNT_INSN_SIZE];
20091
20092 + ip = ktla_ktva(ip);
20093 +
20094 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20095 return -EFAULT;
20096
20097 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20098 index 55b6761..a6456fc 100644
20099 --- a/arch/x86/kernel/head64.c
20100 +++ b/arch/x86/kernel/head64.c
20101 @@ -67,12 +67,12 @@ again:
20102 pgd = *pgd_p;
20103
20104 /*
20105 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
20106 - * critical -- __PAGE_OFFSET would point us back into the dynamic
20107 + * The use of __early_va rather than __va here is critical:
20108 + * __va would point us back into the dynamic
20109 * range and we might end up looping forever...
20110 */
20111 if (pgd)
20112 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20113 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
20114 else {
20115 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20116 reset_early_page_tables();
20117 @@ -82,13 +82,13 @@ again:
20118 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
20119 for (i = 0; i < PTRS_PER_PUD; i++)
20120 pud_p[i] = 0;
20121 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20122 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
20123 }
20124 pud_p += pud_index(address);
20125 pud = *pud_p;
20126
20127 if (pud)
20128 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20129 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
20130 else {
20131 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20132 reset_early_page_tables();
20133 @@ -98,7 +98,7 @@ again:
20134 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
20135 for (i = 0; i < PTRS_PER_PMD; i++)
20136 pmd_p[i] = 0;
20137 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20138 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
20139 }
20140 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
20141 pmd_p[pmd_index(address)] = pmd;
20142 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20143 if (console_loglevel == 10)
20144 early_printk("Kernel alive\n");
20145
20146 - clear_page(init_level4_pgt);
20147 /* set init_level4_pgt kernel high mapping*/
20148 init_level4_pgt[511] = early_level4_pgt[511];
20149
20150 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20151 index 73afd11..d1670f5 100644
20152 --- a/arch/x86/kernel/head_32.S
20153 +++ b/arch/x86/kernel/head_32.S
20154 @@ -26,6 +26,12 @@
20155 /* Physical address */
20156 #define pa(X) ((X) - __PAGE_OFFSET)
20157
20158 +#ifdef CONFIG_PAX_KERNEXEC
20159 +#define ta(X) (X)
20160 +#else
20161 +#define ta(X) ((X) - __PAGE_OFFSET)
20162 +#endif
20163 +
20164 /*
20165 * References to members of the new_cpu_data structure.
20166 */
20167 @@ -55,11 +61,7 @@
20168 * and small than max_low_pfn, otherwise will waste some page table entries
20169 */
20170
20171 -#if PTRS_PER_PMD > 1
20172 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20173 -#else
20174 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20175 -#endif
20176 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20177
20178 /* Number of possible pages in the lowmem region */
20179 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20180 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20181 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20182
20183 /*
20184 + * Real beginning of normal "text" segment
20185 + */
20186 +ENTRY(stext)
20187 +ENTRY(_stext)
20188 +
20189 +/*
20190 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20191 * %esi points to the real-mode code as a 32-bit pointer.
20192 * CS and DS must be 4 GB flat segments, but we don't depend on
20193 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20194 * can.
20195 */
20196 __HEAD
20197 +
20198 +#ifdef CONFIG_PAX_KERNEXEC
20199 + jmp startup_32
20200 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20201 +.fill PAGE_SIZE-5,1,0xcc
20202 +#endif
20203 +
20204 ENTRY(startup_32)
20205 movl pa(stack_start),%ecx
20206
20207 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20208 2:
20209 leal -__PAGE_OFFSET(%ecx),%esp
20210
20211 +#ifdef CONFIG_SMP
20212 + movl $pa(cpu_gdt_table),%edi
20213 + movl $__per_cpu_load,%eax
20214 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20215 + rorl $16,%eax
20216 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20217 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20218 + movl $__per_cpu_end - 1,%eax
20219 + subl $__per_cpu_start,%eax
20220 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20221 +#endif
20222 +
20223 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20224 + movl $NR_CPUS,%ecx
20225 + movl $pa(cpu_gdt_table),%edi
20226 +1:
20227 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20228 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20229 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20230 + addl $PAGE_SIZE_asm,%edi
20231 + loop 1b
20232 +#endif
20233 +
20234 +#ifdef CONFIG_PAX_KERNEXEC
20235 + movl $pa(boot_gdt),%edi
20236 + movl $__LOAD_PHYSICAL_ADDR,%eax
20237 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20238 + rorl $16,%eax
20239 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20240 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20241 + rorl $16,%eax
20242 +
20243 + ljmp $(__BOOT_CS),$1f
20244 +1:
20245 +
20246 + movl $NR_CPUS,%ecx
20247 + movl $pa(cpu_gdt_table),%edi
20248 + addl $__PAGE_OFFSET,%eax
20249 +1:
20250 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20251 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20252 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20253 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20254 + rorl $16,%eax
20255 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20256 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20257 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20258 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20259 + rorl $16,%eax
20260 + addl $PAGE_SIZE_asm,%edi
20261 + loop 1b
20262 +#endif
20263 +
20264 /*
20265 * Clear BSS first so that there are no surprises...
20266 */
20267 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20268 movl %eax, pa(max_pfn_mapped)
20269
20270 /* Do early initialization of the fixmap area */
20271 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20272 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20273 +#ifdef CONFIG_COMPAT_VDSO
20274 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20275 +#else
20276 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20277 +#endif
20278 #else /* Not PAE */
20279
20280 page_pde_offset = (__PAGE_OFFSET >> 20);
20281 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20282 movl %eax, pa(max_pfn_mapped)
20283
20284 /* Do early initialization of the fixmap area */
20285 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20286 - movl %eax,pa(initial_page_table+0xffc)
20287 +#ifdef CONFIG_COMPAT_VDSO
20288 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20289 +#else
20290 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20291 +#endif
20292 #endif
20293
20294 #ifdef CONFIG_PARAVIRT
20295 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20296 cmpl $num_subarch_entries, %eax
20297 jae bad_subarch
20298
20299 - movl pa(subarch_entries)(,%eax,4), %eax
20300 - subl $__PAGE_OFFSET, %eax
20301 - jmp *%eax
20302 + jmp *pa(subarch_entries)(,%eax,4)
20303
20304 bad_subarch:
20305 WEAK(lguest_entry)
20306 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20307 __INITDATA
20308
20309 subarch_entries:
20310 - .long default_entry /* normal x86/PC */
20311 - .long lguest_entry /* lguest hypervisor */
20312 - .long xen_entry /* Xen hypervisor */
20313 - .long default_entry /* Moorestown MID */
20314 + .long ta(default_entry) /* normal x86/PC */
20315 + .long ta(lguest_entry) /* lguest hypervisor */
20316 + .long ta(xen_entry) /* Xen hypervisor */
20317 + .long ta(default_entry) /* Moorestown MID */
20318 num_subarch_entries = (. - subarch_entries) / 4
20319 .previous
20320 #else
20321 @@ -355,6 +427,7 @@ default_entry:
20322 movl pa(mmu_cr4_features),%eax
20323 movl %eax,%cr4
20324
20325 +#ifdef CONFIG_X86_PAE
20326 testb $X86_CR4_PAE, %al # check if PAE is enabled
20327 jz enable_paging
20328
20329 @@ -383,6 +456,9 @@ default_entry:
20330 /* Make changes effective */
20331 wrmsr
20332
20333 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20334 +#endif
20335 +
20336 enable_paging:
20337
20338 /*
20339 @@ -451,14 +527,20 @@ is486:
20340 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20341 movl %eax,%ss # after changing gdt.
20342
20343 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20344 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20345 movl %eax,%ds
20346 movl %eax,%es
20347
20348 movl $(__KERNEL_PERCPU), %eax
20349 movl %eax,%fs # set this cpu's percpu
20350
20351 +#ifdef CONFIG_CC_STACKPROTECTOR
20352 movl $(__KERNEL_STACK_CANARY),%eax
20353 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20354 + movl $(__USER_DS),%eax
20355 +#else
20356 + xorl %eax,%eax
20357 +#endif
20358 movl %eax,%gs
20359
20360 xorl %eax,%eax # Clear LDT
20361 @@ -534,8 +616,11 @@ setup_once:
20362 * relocation. Manually set base address in stack canary
20363 * segment descriptor.
20364 */
20365 - movl $gdt_page,%eax
20366 + movl $cpu_gdt_table,%eax
20367 movl $stack_canary,%ecx
20368 +#ifdef CONFIG_SMP
20369 + addl $__per_cpu_load,%ecx
20370 +#endif
20371 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20372 shrl $16, %ecx
20373 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20374 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20375 /* This is global to keep gas from relaxing the jumps */
20376 ENTRY(early_idt_handler)
20377 cld
20378 - cmpl $2,%ss:early_recursion_flag
20379 + cmpl $1,%ss:early_recursion_flag
20380 je hlt_loop
20381 incl %ss:early_recursion_flag
20382
20383 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20384 pushl (20+6*4)(%esp) /* trapno */
20385 pushl $fault_msg
20386 call printk
20387 -#endif
20388 call dump_stack
20389 +#endif
20390 hlt_loop:
20391 hlt
20392 jmp hlt_loop
20393 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20394 /* This is the default interrupt "handler" :-) */
20395 ALIGN
20396 ignore_int:
20397 - cld
20398 #ifdef CONFIG_PRINTK
20399 + cmpl $2,%ss:early_recursion_flag
20400 + je hlt_loop
20401 + incl %ss:early_recursion_flag
20402 + cld
20403 pushl %eax
20404 pushl %ecx
20405 pushl %edx
20406 @@ -634,9 +722,6 @@ ignore_int:
20407 movl $(__KERNEL_DS),%eax
20408 movl %eax,%ds
20409 movl %eax,%es
20410 - cmpl $2,early_recursion_flag
20411 - je hlt_loop
20412 - incl early_recursion_flag
20413 pushl 16(%esp)
20414 pushl 24(%esp)
20415 pushl 32(%esp)
20416 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20417 /*
20418 * BSS section
20419 */
20420 -__PAGE_ALIGNED_BSS
20421 - .align PAGE_SIZE
20422 #ifdef CONFIG_X86_PAE
20423 +.section .initial_pg_pmd,"a",@progbits
20424 initial_pg_pmd:
20425 .fill 1024*KPMDS,4,0
20426 #else
20427 +.section .initial_page_table,"a",@progbits
20428 ENTRY(initial_page_table)
20429 .fill 1024,4,0
20430 #endif
20431 +.section .initial_pg_fixmap,"a",@progbits
20432 initial_pg_fixmap:
20433 .fill 1024,4,0
20434 +.section .empty_zero_page,"a",@progbits
20435 ENTRY(empty_zero_page)
20436 .fill 4096,1,0
20437 +.section .swapper_pg_dir,"a",@progbits
20438 ENTRY(swapper_pg_dir)
20439 +#ifdef CONFIG_X86_PAE
20440 + .fill 4,8,0
20441 +#else
20442 .fill 1024,4,0
20443 +#endif
20444 +
20445 +/*
20446 + * The IDT has to be page-aligned to simplify the Pentium
20447 + * F0 0F bug workaround.. We have a special link segment
20448 + * for this.
20449 + */
20450 +.section .idt,"a",@progbits
20451 +ENTRY(idt_table)
20452 + .fill 256,8,0
20453
20454 /*
20455 * This starts the data section.
20456 */
20457 #ifdef CONFIG_X86_PAE
20458 -__PAGE_ALIGNED_DATA
20459 - /* Page-aligned for the benefit of paravirt? */
20460 - .align PAGE_SIZE
20461 +.section .initial_page_table,"a",@progbits
20462 ENTRY(initial_page_table)
20463 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20464 # if KPMDS == 3
20465 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20466 # error "Kernel PMDs should be 1, 2 or 3"
20467 # endif
20468 .align PAGE_SIZE /* needs to be page-sized too */
20469 +
20470 +#ifdef CONFIG_PAX_PER_CPU_PGD
20471 +ENTRY(cpu_pgd)
20472 + .rept NR_CPUS
20473 + .fill 4,8,0
20474 + .endr
20475 +#endif
20476 +
20477 #endif
20478
20479 .data
20480 .balign 4
20481 ENTRY(stack_start)
20482 - .long init_thread_union+THREAD_SIZE
20483 + .long init_thread_union+THREAD_SIZE-8
20484
20485 __INITRODATA
20486 int_msg:
20487 @@ -744,7 +851,7 @@ fault_msg:
20488 * segment size, and 32-bit linear address value:
20489 */
20490
20491 - .data
20492 +.section .rodata,"a",@progbits
20493 .globl boot_gdt_descr
20494 .globl idt_descr
20495
20496 @@ -753,7 +860,7 @@ fault_msg:
20497 .word 0 # 32 bit align gdt_desc.address
20498 boot_gdt_descr:
20499 .word __BOOT_DS+7
20500 - .long boot_gdt - __PAGE_OFFSET
20501 + .long pa(boot_gdt)
20502
20503 .word 0 # 32-bit align idt_desc.address
20504 idt_descr:
20505 @@ -764,7 +871,7 @@ idt_descr:
20506 .word 0 # 32 bit align gdt_desc.address
20507 ENTRY(early_gdt_descr)
20508 .word GDT_ENTRIES*8-1
20509 - .long gdt_page /* Overwritten for secondary CPUs */
20510 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20511
20512 /*
20513 * The boot_gdt must mirror the equivalent in setup.S and is
20514 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20515 .align L1_CACHE_BYTES
20516 ENTRY(boot_gdt)
20517 .fill GDT_ENTRY_BOOT_CS,8,0
20518 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20519 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20520 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20521 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20522 +
20523 + .align PAGE_SIZE_asm
20524 +ENTRY(cpu_gdt_table)
20525 + .rept NR_CPUS
20526 + .quad 0x0000000000000000 /* NULL descriptor */
20527 + .quad 0x0000000000000000 /* 0x0b reserved */
20528 + .quad 0x0000000000000000 /* 0x13 reserved */
20529 + .quad 0x0000000000000000 /* 0x1b reserved */
20530 +
20531 +#ifdef CONFIG_PAX_KERNEXEC
20532 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20533 +#else
20534 + .quad 0x0000000000000000 /* 0x20 unused */
20535 +#endif
20536 +
20537 + .quad 0x0000000000000000 /* 0x28 unused */
20538 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20539 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20540 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20541 + .quad 0x0000000000000000 /* 0x4b reserved */
20542 + .quad 0x0000000000000000 /* 0x53 reserved */
20543 + .quad 0x0000000000000000 /* 0x5b reserved */
20544 +
20545 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20546 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20547 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20548 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20549 +
20550 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20551 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20552 +
20553 + /*
20554 + * Segments used for calling PnP BIOS have byte granularity.
20555 + * The code segments and data segments have fixed 64k limits,
20556 + * the transfer segment sizes are set at run time.
20557 + */
20558 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20559 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20560 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20561 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20562 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20563 +
20564 + /*
20565 + * The APM segments have byte granularity and their bases
20566 + * are set at run time. All have 64k limits.
20567 + */
20568 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20569 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20570 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20571 +
20572 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20573 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20574 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20575 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20576 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20577 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20578 +
20579 + /* Be sure this is zeroed to avoid false validations in Xen */
20580 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20581 + .endr
20582 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20583 index 321d65e..863089b 100644
20584 --- a/arch/x86/kernel/head_64.S
20585 +++ b/arch/x86/kernel/head_64.S
20586 @@ -20,6 +20,8 @@
20587 #include <asm/processor-flags.h>
20588 #include <asm/percpu.h>
20589 #include <asm/nops.h>
20590 +#include <asm/cpufeature.h>
20591 +#include <asm/alternative-asm.h>
20592
20593 #ifdef CONFIG_PARAVIRT
20594 #include <asm/asm-offsets.h>
20595 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20596 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20597 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20598 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20599 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20600 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20601 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20602 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20603 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20604 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20605
20606 .text
20607 __HEAD
20608 @@ -89,11 +97,23 @@ startup_64:
20609 * Fixup the physical addresses in the page table
20610 */
20611 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20612 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20613 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20614 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20615 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20616 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20617
20618 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20619 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20620 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
20621 +#ifndef CONFIG_XEN
20622 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
20623 +#endif
20624
20625 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20626 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20627 +
20628 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20629 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
20630 +
20631 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20632
20633 /*
20634 * Set up the identity mapping for the switchover. These
20635 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
20636 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20637 1:
20638
20639 - /* Enable PAE mode and PGE */
20640 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20641 + /* Enable PAE mode and PSE/PGE */
20642 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20643 movq %rcx, %cr4
20644
20645 /* Setup early boot stage 4 level pagetables. */
20646 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
20647 movl $MSR_EFER, %ecx
20648 rdmsr
20649 btsl $_EFER_SCE, %eax /* Enable System Call */
20650 - btl $20,%edi /* No Execute supported? */
20651 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20652 jnc 1f
20653 btsl $_EFER_NX, %eax
20654 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20655 + leaq init_level4_pgt(%rip), %rdi
20656 +#ifndef CONFIG_EFI
20657 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20658 +#endif
20659 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20660 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20661 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20662 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20663 1: wrmsr /* Make changes effective */
20664
20665 /* Setup cr0 */
20666 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
20667 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20668 * address given in m16:64.
20669 */
20670 + pax_set_fptr_mask
20671 movq initial_code(%rip),%rax
20672 pushq $0 # fake return address to stop unwinder
20673 pushq $__KERNEL_CS # set correct cs
20674 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
20675 call dump_stack
20676 #ifdef CONFIG_KALLSYMS
20677 leaq early_idt_ripmsg(%rip),%rdi
20678 - movq 40(%rsp),%rsi # %rip again
20679 + movq 88(%rsp),%rsi # %rip again
20680 call __print_symbol
20681 #endif
20682 #endif /* EARLY_PRINTK */
20683 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
20684 early_recursion_flag:
20685 .long 0
20686
20687 + .section .rodata,"a",@progbits
20688 #ifdef CONFIG_EARLY_PRINTK
20689 early_idt_msg:
20690 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20691 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
20692 NEXT_PAGE(early_dynamic_pgts)
20693 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
20694
20695 - .data
20696 + .section .rodata,"a",@progbits
20697
20698 -#ifndef CONFIG_XEN
20699 NEXT_PAGE(init_level4_pgt)
20700 - .fill 512,8,0
20701 -#else
20702 -NEXT_PAGE(init_level4_pgt)
20703 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20704 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20705 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20706 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20707 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20708 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20709 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20710 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20711 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20712 .org init_level4_pgt + L4_START_KERNEL*8, 0
20713 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20714 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20715
20716 +#ifdef CONFIG_PAX_PER_CPU_PGD
20717 +NEXT_PAGE(cpu_pgd)
20718 + .rept NR_CPUS
20719 + .fill 512,8,0
20720 + .endr
20721 +#endif
20722 +
20723 NEXT_PAGE(level3_ident_pgt)
20724 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20725 +#ifdef CONFIG_XEN
20726 .fill 511, 8, 0
20727 +#else
20728 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20729 + .fill 510,8,0
20730 +#endif
20731 +
20732 +NEXT_PAGE(level3_vmalloc_start_pgt)
20733 + .fill 512,8,0
20734 +
20735 +NEXT_PAGE(level3_vmalloc_end_pgt)
20736 + .fill 512,8,0
20737 +
20738 +NEXT_PAGE(level3_vmemmap_pgt)
20739 + .fill L3_VMEMMAP_START,8,0
20740 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20741 +
20742 NEXT_PAGE(level2_ident_pgt)
20743 - /* Since I easily can, map the first 1G.
20744 + /* Since I easily can, map the first 2G.
20745 * Don't set NX because code runs from these pages.
20746 */
20747 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20748 -#endif
20749 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20750
20751 NEXT_PAGE(level3_kernel_pgt)
20752 .fill L3_START_KERNEL,8,0
20753 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
20754 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20755 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20756
20757 +NEXT_PAGE(level2_vmemmap_pgt)
20758 + .fill 512,8,0
20759 +
20760 NEXT_PAGE(level2_kernel_pgt)
20761 /*
20762 * 512 MB kernel mapping. We spend a full page on this pagetable
20763 @@ -488,39 +544,64 @@ NEXT_PAGE(level2_kernel_pgt)
20764 KERNEL_IMAGE_SIZE/PMD_SIZE)
20765
20766 NEXT_PAGE(level2_fixmap_pgt)
20767 - .fill 506,8,0
20768 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20769 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20770 - .fill 5,8,0
20771 + .fill 507,8,0
20772 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20773 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20774 + .fill 4,8,0
20775
20776 -NEXT_PAGE(level1_fixmap_pgt)
20777 +NEXT_PAGE(level1_vsyscall_pgt)
20778 .fill 512,8,0
20779
20780 #undef PMDS
20781
20782 - .data
20783 + .align PAGE_SIZE
20784 +ENTRY(cpu_gdt_table)
20785 + .rept NR_CPUS
20786 + .quad 0x0000000000000000 /* NULL descriptor */
20787 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20788 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20789 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20790 + .quad 0x00cffb000000ffff /* __USER32_CS */
20791 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20792 + .quad 0x00affb000000ffff /* __USER_CS */
20793 +
20794 +#ifdef CONFIG_PAX_KERNEXEC
20795 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20796 +#else
20797 + .quad 0x0 /* unused */
20798 +#endif
20799 +
20800 + .quad 0,0 /* TSS */
20801 + .quad 0,0 /* LDT */
20802 + .quad 0,0,0 /* three TLS descriptors */
20803 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20804 + /* asm/segment.h:GDT_ENTRIES must match this */
20805 +
20806 + /* zero the remaining page */
20807 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20808 + .endr
20809 +
20810 .align 16
20811 .globl early_gdt_descr
20812 early_gdt_descr:
20813 .word GDT_ENTRIES*8-1
20814 early_gdt_descr_base:
20815 - .quad INIT_PER_CPU_VAR(gdt_page)
20816 + .quad cpu_gdt_table
20817
20818 ENTRY(phys_base)
20819 /* This must match the first entry in level2_kernel_pgt */
20820 .quad 0x0000000000000000
20821
20822 #include "../../x86/xen/xen-head.S"
20823 -
20824 - .section .bss, "aw", @nobits
20825 - .align L1_CACHE_BYTES
20826 -ENTRY(idt_table)
20827 - .skip IDT_ENTRIES * 16
20828
20829 - .align L1_CACHE_BYTES
20830 -ENTRY(nmi_idt_table)
20831 - .skip IDT_ENTRIES * 16
20832 -
20833 - __PAGE_ALIGNED_BSS
20834 + .section .rodata,"a",@progbits
20835 NEXT_PAGE(empty_zero_page)
20836 .skip PAGE_SIZE
20837 +
20838 + .align L1_CACHE_BYTES
20839 +ENTRY(idt_table)
20840 + .fill 512,8,0
20841 +
20842 + .align L1_CACHE_BYTES
20843 +ENTRY(nmi_idt_table)
20844 + .fill 512,8,0
20845 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20846 index 0fa6912..37fce70 100644
20847 --- a/arch/x86/kernel/i386_ksyms_32.c
20848 +++ b/arch/x86/kernel/i386_ksyms_32.c
20849 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20850 EXPORT_SYMBOL(cmpxchg8b_emu);
20851 #endif
20852
20853 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20854 +
20855 /* Networking helper routines. */
20856 EXPORT_SYMBOL(csum_partial_copy_generic);
20857 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20858 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20859
20860 EXPORT_SYMBOL(__get_user_1);
20861 EXPORT_SYMBOL(__get_user_2);
20862 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20863
20864 EXPORT_SYMBOL(csum_partial);
20865 EXPORT_SYMBOL(empty_zero_page);
20866 +
20867 +#ifdef CONFIG_PAX_KERNEXEC
20868 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20869 +#endif
20870 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20871 index cb33909..1163b40 100644
20872 --- a/arch/x86/kernel/i387.c
20873 +++ b/arch/x86/kernel/i387.c
20874 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20875 static inline bool interrupted_user_mode(void)
20876 {
20877 struct pt_regs *regs = get_irq_regs();
20878 - return regs && user_mode_vm(regs);
20879 + return regs && user_mode(regs);
20880 }
20881
20882 /*
20883 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20884 index 9a5c460..84868423 100644
20885 --- a/arch/x86/kernel/i8259.c
20886 +++ b/arch/x86/kernel/i8259.c
20887 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20888 static void make_8259A_irq(unsigned int irq)
20889 {
20890 disable_irq_nosync(irq);
20891 - io_apic_irqs &= ~(1<<irq);
20892 + io_apic_irqs &= ~(1UL<<irq);
20893 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20894 i8259A_chip.name);
20895 enable_irq(irq);
20896 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20897 "spurious 8259A interrupt: IRQ%d.\n", irq);
20898 spurious_irq_mask |= irqmask;
20899 }
20900 - atomic_inc(&irq_err_count);
20901 + atomic_inc_unchecked(&irq_err_count);
20902 /*
20903 * Theoretically we do not have to handle this IRQ,
20904 * but in Linux this does not cause problems and is
20905 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20906 /* (slave's support for AEOI in flat mode is to be investigated) */
20907 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20908
20909 + pax_open_kernel();
20910 if (auto_eoi)
20911 /*
20912 * In AEOI mode we just have to mask the interrupt
20913 * when acking.
20914 */
20915 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20916 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20917 else
20918 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20919 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20920 + pax_close_kernel();
20921
20922 udelay(100); /* wait for 8259A to initialize */
20923
20924 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20925 index a979b5b..1d6db75 100644
20926 --- a/arch/x86/kernel/io_delay.c
20927 +++ b/arch/x86/kernel/io_delay.c
20928 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20929 * Quirk table for systems that misbehave (lock up, etc.) if port
20930 * 0x80 is used:
20931 */
20932 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20933 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20934 {
20935 .callback = dmi_io_delay_0xed_port,
20936 .ident = "Compaq Presario V6000",
20937 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20938 index 4ddaf66..6292f4e 100644
20939 --- a/arch/x86/kernel/ioport.c
20940 +++ b/arch/x86/kernel/ioport.c
20941 @@ -6,6 +6,7 @@
20942 #include <linux/sched.h>
20943 #include <linux/kernel.h>
20944 #include <linux/capability.h>
20945 +#include <linux/security.h>
20946 #include <linux/errno.h>
20947 #include <linux/types.h>
20948 #include <linux/ioport.h>
20949 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20950
20951 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20952 return -EINVAL;
20953 +#ifdef CONFIG_GRKERNSEC_IO
20954 + if (turn_on && grsec_disable_privio) {
20955 + gr_handle_ioperm();
20956 + return -EPERM;
20957 + }
20958 +#endif
20959 if (turn_on && !capable(CAP_SYS_RAWIO))
20960 return -EPERM;
20961
20962 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20963 * because the ->io_bitmap_max value must match the bitmap
20964 * contents:
20965 */
20966 - tss = &per_cpu(init_tss, get_cpu());
20967 + tss = init_tss + get_cpu();
20968
20969 if (turn_on)
20970 bitmap_clear(t->io_bitmap_ptr, from, num);
20971 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20972 return -EINVAL;
20973 /* Trying to gain more privileges? */
20974 if (level > old) {
20975 +#ifdef CONFIG_GRKERNSEC_IO
20976 + if (grsec_disable_privio) {
20977 + gr_handle_iopl();
20978 + return -EPERM;
20979 + }
20980 +#endif
20981 if (!capable(CAP_SYS_RAWIO))
20982 return -EPERM;
20983 }
20984 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20985 index ac0631d..ff7cb62 100644
20986 --- a/arch/x86/kernel/irq.c
20987 +++ b/arch/x86/kernel/irq.c
20988 @@ -18,7 +18,7 @@
20989 #include <asm/mce.h>
20990 #include <asm/hw_irq.h>
20991
20992 -atomic_t irq_err_count;
20993 +atomic_unchecked_t irq_err_count;
20994
20995 /* Function pointer for generic interrupt vector handling */
20996 void (*x86_platform_ipi_callback)(void) = NULL;
20997 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20998 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20999 seq_printf(p, " Machine check polls\n");
21000 #endif
21001 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21002 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21003 #if defined(CONFIG_X86_IO_APIC)
21004 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21005 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21006 #endif
21007 return 0;
21008 }
21009 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21010
21011 u64 arch_irq_stat(void)
21012 {
21013 - u64 sum = atomic_read(&irq_err_count);
21014 + u64 sum = atomic_read_unchecked(&irq_err_count);
21015 return sum;
21016 }
21017
21018 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21019 index 344faf8..355f60d 100644
21020 --- a/arch/x86/kernel/irq_32.c
21021 +++ b/arch/x86/kernel/irq_32.c
21022 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21023 __asm__ __volatile__("andl %%esp,%0" :
21024 "=r" (sp) : "0" (THREAD_SIZE - 1));
21025
21026 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21027 + return sp < STACK_WARN;
21028 }
21029
21030 static void print_stack_overflow(void)
21031 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21032 * per-CPU IRQ handling contexts (thread information and stack)
21033 */
21034 union irq_ctx {
21035 - struct thread_info tinfo;
21036 - u32 stack[THREAD_SIZE/sizeof(u32)];
21037 + unsigned long previous_esp;
21038 + u32 stack[THREAD_SIZE/sizeof(u32)];
21039 } __attribute__((aligned(THREAD_SIZE)));
21040
21041 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21042 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21043 static inline int
21044 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21045 {
21046 - union irq_ctx *curctx, *irqctx;
21047 + union irq_ctx *irqctx;
21048 u32 *isp, arg1, arg2;
21049
21050 - curctx = (union irq_ctx *) current_thread_info();
21051 irqctx = __this_cpu_read(hardirq_ctx);
21052
21053 /*
21054 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21055 * handler) we can't do that and just have to keep using the
21056 * current stack (which is the irq stack already after all)
21057 */
21058 - if (unlikely(curctx == irqctx))
21059 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21060 return 0;
21061
21062 /* build the stack frame on the IRQ stack */
21063 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21064 - irqctx->tinfo.task = curctx->tinfo.task;
21065 - irqctx->tinfo.previous_esp = current_stack_pointer;
21066 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21067 + irqctx->previous_esp = current_stack_pointer;
21068
21069 - /* Copy the preempt_count so that the [soft]irq checks work. */
21070 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21071 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21072 + __set_fs(MAKE_MM_SEG(0));
21073 +#endif
21074
21075 if (unlikely(overflow))
21076 call_on_stack(print_stack_overflow, isp);
21077 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21078 : "0" (irq), "1" (desc), "2" (isp),
21079 "D" (desc->handle_irq)
21080 : "memory", "cc", "ecx");
21081 +
21082 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21083 + __set_fs(current_thread_info()->addr_limit);
21084 +#endif
21085 +
21086 return 1;
21087 }
21088
21089 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21090 */
21091 void __cpuinit irq_ctx_init(int cpu)
21092 {
21093 - union irq_ctx *irqctx;
21094 -
21095 if (per_cpu(hardirq_ctx, cpu))
21096 return;
21097
21098 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21099 - THREADINFO_GFP,
21100 - THREAD_SIZE_ORDER));
21101 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21102 - irqctx->tinfo.cpu = cpu;
21103 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21104 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21105 -
21106 - per_cpu(hardirq_ctx, cpu) = irqctx;
21107 -
21108 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21109 - THREADINFO_GFP,
21110 - THREAD_SIZE_ORDER));
21111 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21112 - irqctx->tinfo.cpu = cpu;
21113 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21114 -
21115 - per_cpu(softirq_ctx, cpu) = irqctx;
21116 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21117 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21118 +
21119 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21120 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21121
21122 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21123 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21124 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21125 asmlinkage void do_softirq(void)
21126 {
21127 unsigned long flags;
21128 - struct thread_info *curctx;
21129 union irq_ctx *irqctx;
21130 u32 *isp;
21131
21132 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21133 local_irq_save(flags);
21134
21135 if (local_softirq_pending()) {
21136 - curctx = current_thread_info();
21137 irqctx = __this_cpu_read(softirq_ctx);
21138 - irqctx->tinfo.task = curctx->task;
21139 - irqctx->tinfo.previous_esp = current_stack_pointer;
21140 + irqctx->previous_esp = current_stack_pointer;
21141
21142 /* build the stack frame on the softirq stack */
21143 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21144 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21145 +
21146 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21147 + __set_fs(MAKE_MM_SEG(0));
21148 +#endif
21149
21150 call_on_stack(__do_softirq, isp);
21151 +
21152 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21153 + __set_fs(current_thread_info()->addr_limit);
21154 +#endif
21155 +
21156 /*
21157 * Shouldn't happen, we returned above if in_interrupt():
21158 */
21159 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21160 if (unlikely(!desc))
21161 return false;
21162
21163 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21164 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21165 if (unlikely(overflow))
21166 print_stack_overflow();
21167 desc->handle_irq(irq, desc);
21168 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21169 index d04d3ec..ea4b374 100644
21170 --- a/arch/x86/kernel/irq_64.c
21171 +++ b/arch/x86/kernel/irq_64.c
21172 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21173 u64 estack_top, estack_bottom;
21174 u64 curbase = (u64)task_stack_page(current);
21175
21176 - if (user_mode_vm(regs))
21177 + if (user_mode(regs))
21178 return;
21179
21180 if (regs->sp >= curbase + sizeof(struct thread_info) +
21181 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21182 index dc1404b..bbc43e7 100644
21183 --- a/arch/x86/kernel/kdebugfs.c
21184 +++ b/arch/x86/kernel/kdebugfs.c
21185 @@ -27,7 +27,7 @@ struct setup_data_node {
21186 u32 len;
21187 };
21188
21189 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21190 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21191 size_t count, loff_t *ppos)
21192 {
21193 struct setup_data_node *node = file->private_data;
21194 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21195 index 836f832..a8bda67 100644
21196 --- a/arch/x86/kernel/kgdb.c
21197 +++ b/arch/x86/kernel/kgdb.c
21198 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21199 #ifdef CONFIG_X86_32
21200 switch (regno) {
21201 case GDB_SS:
21202 - if (!user_mode_vm(regs))
21203 + if (!user_mode(regs))
21204 *(unsigned long *)mem = __KERNEL_DS;
21205 break;
21206 case GDB_SP:
21207 - if (!user_mode_vm(regs))
21208 + if (!user_mode(regs))
21209 *(unsigned long *)mem = kernel_stack_pointer(regs);
21210 break;
21211 case GDB_GS:
21212 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21213 bp->attr.bp_addr = breakinfo[breakno].addr;
21214 bp->attr.bp_len = breakinfo[breakno].len;
21215 bp->attr.bp_type = breakinfo[breakno].type;
21216 - info->address = breakinfo[breakno].addr;
21217 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21218 + info->address = ktla_ktva(breakinfo[breakno].addr);
21219 + else
21220 + info->address = breakinfo[breakno].addr;
21221 info->len = breakinfo[breakno].len;
21222 info->type = breakinfo[breakno].type;
21223 val = arch_install_hw_breakpoint(bp);
21224 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21225 case 'k':
21226 /* clear the trace bit */
21227 linux_regs->flags &= ~X86_EFLAGS_TF;
21228 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21229 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21230
21231 /* set the trace bit if we're stepping */
21232 if (remcomInBuffer[0] == 's') {
21233 linux_regs->flags |= X86_EFLAGS_TF;
21234 - atomic_set(&kgdb_cpu_doing_single_step,
21235 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21236 raw_smp_processor_id());
21237 }
21238
21239 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21240
21241 switch (cmd) {
21242 case DIE_DEBUG:
21243 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21244 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21245 if (user_mode(regs))
21246 return single_step_cont(regs, args);
21247 break;
21248 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21249 #endif /* CONFIG_DEBUG_RODATA */
21250
21251 bpt->type = BP_BREAKPOINT;
21252 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21253 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21254 BREAK_INSTR_SIZE);
21255 if (err)
21256 return err;
21257 - err = probe_kernel_write((char *)bpt->bpt_addr,
21258 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21259 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21260 #ifdef CONFIG_DEBUG_RODATA
21261 if (!err)
21262 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21263 return -EBUSY;
21264 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21265 BREAK_INSTR_SIZE);
21266 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21267 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21268 if (err)
21269 return err;
21270 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21271 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21272 if (mutex_is_locked(&text_mutex))
21273 goto knl_write;
21274 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21275 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21276 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21277 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21278 goto knl_write;
21279 return err;
21280 knl_write:
21281 #endif /* CONFIG_DEBUG_RODATA */
21282 - return probe_kernel_write((char *)bpt->bpt_addr,
21283 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21284 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21285 }
21286
21287 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21288 index 211bce4..6e2580a 100644
21289 --- a/arch/x86/kernel/kprobes/core.c
21290 +++ b/arch/x86/kernel/kprobes/core.c
21291 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21292 s32 raddr;
21293 } __packed *insn;
21294
21295 - insn = (struct __arch_relative_insn *)from;
21296 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21297 +
21298 + pax_open_kernel();
21299 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21300 insn->op = op;
21301 + pax_close_kernel();
21302 }
21303
21304 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21305 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21306 kprobe_opcode_t opcode;
21307 kprobe_opcode_t *orig_opcodes = opcodes;
21308
21309 - if (search_exception_tables((unsigned long)opcodes))
21310 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21311 return 0; /* Page fault may occur on this address. */
21312
21313 retry:
21314 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21315 * for the first byte, we can recover the original instruction
21316 * from it and kp->opcode.
21317 */
21318 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21319 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21320 buf[0] = kp->opcode;
21321 - return (unsigned long)buf;
21322 + return ktva_ktla((unsigned long)buf);
21323 }
21324
21325 /*
21326 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21327 /* Another subsystem puts a breakpoint, failed to recover */
21328 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21329 return 0;
21330 + pax_open_kernel();
21331 memcpy(dest, insn.kaddr, insn.length);
21332 + pax_close_kernel();
21333
21334 #ifdef CONFIG_X86_64
21335 if (insn_rip_relative(&insn)) {
21336 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21337 return 0;
21338 }
21339 disp = (u8 *) dest + insn_offset_displacement(&insn);
21340 + pax_open_kernel();
21341 *(s32 *) disp = (s32) newdisp;
21342 + pax_close_kernel();
21343 }
21344 #endif
21345 return insn.length;
21346 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21347 * nor set current_kprobe, because it doesn't use single
21348 * stepping.
21349 */
21350 - regs->ip = (unsigned long)p->ainsn.insn;
21351 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21352 preempt_enable_no_resched();
21353 return;
21354 }
21355 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21356 regs->flags &= ~X86_EFLAGS_IF;
21357 /* single step inline if the instruction is an int3 */
21358 if (p->opcode == BREAKPOINT_INSTRUCTION)
21359 - regs->ip = (unsigned long)p->addr;
21360 + regs->ip = ktla_ktva((unsigned long)p->addr);
21361 else
21362 - regs->ip = (unsigned long)p->ainsn.insn;
21363 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21364 }
21365
21366 /*
21367 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21368 setup_singlestep(p, regs, kcb, 0);
21369 return 1;
21370 }
21371 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21372 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21373 /*
21374 * The breakpoint instruction was removed right
21375 * after we hit it. Another cpu has removed
21376 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21377 " movq %rax, 152(%rsp)\n"
21378 RESTORE_REGS_STRING
21379 " popfq\n"
21380 +#ifdef KERNEXEC_PLUGIN
21381 + " btsq $63,(%rsp)\n"
21382 +#endif
21383 #else
21384 " pushf\n"
21385 SAVE_REGS_STRING
21386 @@ -779,7 +789,7 @@ static void __kprobes
21387 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21388 {
21389 unsigned long *tos = stack_addr(regs);
21390 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21391 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21392 unsigned long orig_ip = (unsigned long)p->addr;
21393 kprobe_opcode_t *insn = p->ainsn.insn;
21394
21395 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21396 struct die_args *args = data;
21397 int ret = NOTIFY_DONE;
21398
21399 - if (args->regs && user_mode_vm(args->regs))
21400 + if (args->regs && user_mode(args->regs))
21401 return ret;
21402
21403 switch (val) {
21404 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21405 index 76dc6f0..66bdfc3 100644
21406 --- a/arch/x86/kernel/kprobes/opt.c
21407 +++ b/arch/x86/kernel/kprobes/opt.c
21408 @@ -79,6 +79,7 @@ found:
21409 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21410 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21411 {
21412 + pax_open_kernel();
21413 #ifdef CONFIG_X86_64
21414 *addr++ = 0x48;
21415 *addr++ = 0xbf;
21416 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21417 *addr++ = 0xb8;
21418 #endif
21419 *(unsigned long *)addr = val;
21420 + pax_close_kernel();
21421 }
21422
21423 static void __used __kprobes kprobes_optinsn_template_holder(void)
21424 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21425 * Verify if the address gap is in 2GB range, because this uses
21426 * a relative jump.
21427 */
21428 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21429 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21430 if (abs(rel) > 0x7fffffff)
21431 return -ERANGE;
21432
21433 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21434 op->optinsn.size = ret;
21435
21436 /* Copy arch-dep-instance from template */
21437 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21438 + pax_open_kernel();
21439 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21440 + pax_close_kernel();
21441
21442 /* Set probe information */
21443 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21444
21445 /* Set probe function call */
21446 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21447 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21448
21449 /* Set returning jmp instruction at the tail of out-of-line buffer */
21450 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21451 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21452 (u8 *)op->kp.addr + op->optinsn.size);
21453
21454 flush_icache_range((unsigned long) buf,
21455 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21456 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21457
21458 /* Backup instructions which will be replaced by jump address */
21459 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21460 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21461 RELATIVE_ADDR_SIZE);
21462
21463 insn_buf[0] = RELATIVEJUMP_OPCODE;
21464 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21465 /* This kprobe is really able to run optimized path. */
21466 op = container_of(p, struct optimized_kprobe, kp);
21467 /* Detour through copied instructions */
21468 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21469 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21470 if (!reenter)
21471 reset_current_kprobe();
21472 preempt_enable_no_resched();
21473 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21474 index cd6d9a5..16245a4 100644
21475 --- a/arch/x86/kernel/kvm.c
21476 +++ b/arch/x86/kernel/kvm.c
21477 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21478 return NOTIFY_OK;
21479 }
21480
21481 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21482 +static struct notifier_block kvm_cpu_notifier = {
21483 .notifier_call = kvm_cpu_notify,
21484 };
21485 #endif
21486 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21487 index ebc9873..1b9724b 100644
21488 --- a/arch/x86/kernel/ldt.c
21489 +++ b/arch/x86/kernel/ldt.c
21490 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21491 if (reload) {
21492 #ifdef CONFIG_SMP
21493 preempt_disable();
21494 - load_LDT(pc);
21495 + load_LDT_nolock(pc);
21496 if (!cpumask_equal(mm_cpumask(current->mm),
21497 cpumask_of(smp_processor_id())))
21498 smp_call_function(flush_ldt, current->mm, 1);
21499 preempt_enable();
21500 #else
21501 - load_LDT(pc);
21502 + load_LDT_nolock(pc);
21503 #endif
21504 }
21505 if (oldsize) {
21506 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21507 return err;
21508
21509 for (i = 0; i < old->size; i++)
21510 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21511 + write_ldt_entry(new->ldt, i, old->ldt + i);
21512 return 0;
21513 }
21514
21515 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21516 retval = copy_ldt(&mm->context, &old_mm->context);
21517 mutex_unlock(&old_mm->context.lock);
21518 }
21519 +
21520 + if (tsk == current) {
21521 + mm->context.vdso = 0;
21522 +
21523 +#ifdef CONFIG_X86_32
21524 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21525 + mm->context.user_cs_base = 0UL;
21526 + mm->context.user_cs_limit = ~0UL;
21527 +
21528 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21529 + cpus_clear(mm->context.cpu_user_cs_mask);
21530 +#endif
21531 +
21532 +#endif
21533 +#endif
21534 +
21535 + }
21536 +
21537 return retval;
21538 }
21539
21540 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21541 }
21542 }
21543
21544 +#ifdef CONFIG_PAX_SEGMEXEC
21545 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21546 + error = -EINVAL;
21547 + goto out_unlock;
21548 + }
21549 +#endif
21550 +
21551 fill_ldt(&ldt, &ldt_info);
21552 if (oldmode)
21553 ldt.avl = 0;
21554 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21555 index 5b19e4d..6476a76 100644
21556 --- a/arch/x86/kernel/machine_kexec_32.c
21557 +++ b/arch/x86/kernel/machine_kexec_32.c
21558 @@ -26,7 +26,7 @@
21559 #include <asm/cacheflush.h>
21560 #include <asm/debugreg.h>
21561
21562 -static void set_idt(void *newidt, __u16 limit)
21563 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21564 {
21565 struct desc_ptr curidt;
21566
21567 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21568 }
21569
21570
21571 -static void set_gdt(void *newgdt, __u16 limit)
21572 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21573 {
21574 struct desc_ptr curgdt;
21575
21576 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21577 }
21578
21579 control_page = page_address(image->control_code_page);
21580 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21581 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21582
21583 relocate_kernel_ptr = control_page;
21584 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21585 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21586 index 22db92b..d546bec 100644
21587 --- a/arch/x86/kernel/microcode_core.c
21588 +++ b/arch/x86/kernel/microcode_core.c
21589 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21590 return NOTIFY_OK;
21591 }
21592
21593 -static struct notifier_block __refdata mc_cpu_notifier = {
21594 +static struct notifier_block mc_cpu_notifier = {
21595 .notifier_call = mc_cpu_callback,
21596 };
21597
21598 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21599 index 5fb2ceb..3ae90bb 100644
21600 --- a/arch/x86/kernel/microcode_intel.c
21601 +++ b/arch/x86/kernel/microcode_intel.c
21602 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21603
21604 static int get_ucode_user(void *to, const void *from, size_t n)
21605 {
21606 - return copy_from_user(to, from, n);
21607 + return copy_from_user(to, (const void __force_user *)from, n);
21608 }
21609
21610 static enum ucode_state
21611 request_microcode_user(int cpu, const void __user *buf, size_t size)
21612 {
21613 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21614 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21615 }
21616
21617 static void microcode_fini_cpu(int cpu)
21618 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21619 index 216a4d7..228255a 100644
21620 --- a/arch/x86/kernel/module.c
21621 +++ b/arch/x86/kernel/module.c
21622 @@ -43,15 +43,60 @@ do { \
21623 } while (0)
21624 #endif
21625
21626 -void *module_alloc(unsigned long size)
21627 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21628 {
21629 - if (PAGE_ALIGN(size) > MODULES_LEN)
21630 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21631 return NULL;
21632 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21633 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21634 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21635 -1, __builtin_return_address(0));
21636 }
21637
21638 +void *module_alloc(unsigned long size)
21639 +{
21640 +
21641 +#ifdef CONFIG_PAX_KERNEXEC
21642 + return __module_alloc(size, PAGE_KERNEL);
21643 +#else
21644 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21645 +#endif
21646 +
21647 +}
21648 +
21649 +#ifdef CONFIG_PAX_KERNEXEC
21650 +#ifdef CONFIG_X86_32
21651 +void *module_alloc_exec(unsigned long size)
21652 +{
21653 + struct vm_struct *area;
21654 +
21655 + if (size == 0)
21656 + return NULL;
21657 +
21658 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21659 + return area ? area->addr : NULL;
21660 +}
21661 +EXPORT_SYMBOL(module_alloc_exec);
21662 +
21663 +void module_free_exec(struct module *mod, void *module_region)
21664 +{
21665 + vunmap(module_region);
21666 +}
21667 +EXPORT_SYMBOL(module_free_exec);
21668 +#else
21669 +void module_free_exec(struct module *mod, void *module_region)
21670 +{
21671 + module_free(mod, module_region);
21672 +}
21673 +EXPORT_SYMBOL(module_free_exec);
21674 +
21675 +void *module_alloc_exec(unsigned long size)
21676 +{
21677 + return __module_alloc(size, PAGE_KERNEL_RX);
21678 +}
21679 +EXPORT_SYMBOL(module_alloc_exec);
21680 +#endif
21681 +#endif
21682 +
21683 #ifdef CONFIG_X86_32
21684 int apply_relocate(Elf32_Shdr *sechdrs,
21685 const char *strtab,
21686 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21687 unsigned int i;
21688 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21689 Elf32_Sym *sym;
21690 - uint32_t *location;
21691 + uint32_t *plocation, location;
21692
21693 DEBUGP("Applying relocate section %u to %u\n",
21694 relsec, sechdrs[relsec].sh_info);
21695 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21696 /* This is where to make the change */
21697 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21698 - + rel[i].r_offset;
21699 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21700 + location = (uint32_t)plocation;
21701 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21702 + plocation = ktla_ktva((void *)plocation);
21703 /* This is the symbol it is referring to. Note that all
21704 undefined symbols have been resolved. */
21705 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21706 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21707 switch (ELF32_R_TYPE(rel[i].r_info)) {
21708 case R_386_32:
21709 /* We add the value into the location given */
21710 - *location += sym->st_value;
21711 + pax_open_kernel();
21712 + *plocation += sym->st_value;
21713 + pax_close_kernel();
21714 break;
21715 case R_386_PC32:
21716 /* Add the value, subtract its position */
21717 - *location += sym->st_value - (uint32_t)location;
21718 + pax_open_kernel();
21719 + *plocation += sym->st_value - location;
21720 + pax_close_kernel();
21721 break;
21722 default:
21723 pr_err("%s: Unknown relocation: %u\n",
21724 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21725 case R_X86_64_NONE:
21726 break;
21727 case R_X86_64_64:
21728 + pax_open_kernel();
21729 *(u64 *)loc = val;
21730 + pax_close_kernel();
21731 break;
21732 case R_X86_64_32:
21733 + pax_open_kernel();
21734 *(u32 *)loc = val;
21735 + pax_close_kernel();
21736 if (val != *(u32 *)loc)
21737 goto overflow;
21738 break;
21739 case R_X86_64_32S:
21740 + pax_open_kernel();
21741 *(s32 *)loc = val;
21742 + pax_close_kernel();
21743 if ((s64)val != *(s32 *)loc)
21744 goto overflow;
21745 break;
21746 case R_X86_64_PC32:
21747 val -= (u64)loc;
21748 + pax_open_kernel();
21749 *(u32 *)loc = val;
21750 + pax_close_kernel();
21751 +
21752 #if 0
21753 if ((s64)val != *(s32 *)loc)
21754 goto overflow;
21755 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21756 index ce13049..e2e9c3c 100644
21757 --- a/arch/x86/kernel/msr.c
21758 +++ b/arch/x86/kernel/msr.c
21759 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21760 return notifier_from_errno(err);
21761 }
21762
21763 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21764 +static struct notifier_block msr_class_cpu_notifier = {
21765 .notifier_call = msr_class_cpu_callback,
21766 };
21767
21768 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21769 index 6030805..2d33f21 100644
21770 --- a/arch/x86/kernel/nmi.c
21771 +++ b/arch/x86/kernel/nmi.c
21772 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21773 return handled;
21774 }
21775
21776 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21777 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21778 {
21779 struct nmi_desc *desc = nmi_to_desc(type);
21780 unsigned long flags;
21781 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21782 * event confuses some handlers (kdump uses this flag)
21783 */
21784 if (action->flags & NMI_FLAG_FIRST)
21785 - list_add_rcu(&action->list, &desc->head);
21786 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21787 else
21788 - list_add_tail_rcu(&action->list, &desc->head);
21789 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21790
21791 spin_unlock_irqrestore(&desc->lock, flags);
21792 return 0;
21793 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21794 if (!strcmp(n->name, name)) {
21795 WARN(in_nmi(),
21796 "Trying to free NMI (%s) from NMI context!\n", n->name);
21797 - list_del_rcu(&n->list);
21798 + pax_list_del_rcu((struct list_head *)&n->list);
21799 break;
21800 }
21801 }
21802 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21803 dotraplinkage notrace __kprobes void
21804 do_nmi(struct pt_regs *regs, long error_code)
21805 {
21806 +
21807 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21808 + if (!user_mode(regs)) {
21809 + unsigned long cs = regs->cs & 0xFFFF;
21810 + unsigned long ip = ktva_ktla(regs->ip);
21811 +
21812 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21813 + regs->ip = ip;
21814 + }
21815 +#endif
21816 +
21817 nmi_nesting_preprocess(regs);
21818
21819 nmi_enter();
21820 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21821 index 6d9582e..f746287 100644
21822 --- a/arch/x86/kernel/nmi_selftest.c
21823 +++ b/arch/x86/kernel/nmi_selftest.c
21824 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21825 {
21826 /* trap all the unknown NMIs we may generate */
21827 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21828 - __initdata);
21829 + __initconst);
21830 }
21831
21832 static void __init cleanup_nmi_testsuite(void)
21833 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21834 unsigned long timeout;
21835
21836 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21837 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21838 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21839 nmi_fail = FAILURE;
21840 return;
21841 }
21842 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21843 index 676b8c7..870ba04 100644
21844 --- a/arch/x86/kernel/paravirt-spinlocks.c
21845 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21846 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21847 arch_spin_lock(lock);
21848 }
21849
21850 -struct pv_lock_ops pv_lock_ops = {
21851 +struct pv_lock_ops pv_lock_ops __read_only = {
21852 #ifdef CONFIG_SMP
21853 .spin_is_locked = __ticket_spin_is_locked,
21854 .spin_is_contended = __ticket_spin_is_contended,
21855 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21856 index cd6de64..27c6af0 100644
21857 --- a/arch/x86/kernel/paravirt.c
21858 +++ b/arch/x86/kernel/paravirt.c
21859 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21860 {
21861 return x;
21862 }
21863 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21864 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21865 +#endif
21866
21867 void __init default_banner(void)
21868 {
21869 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21870 if (opfunc == NULL)
21871 /* If there's no function, patch it with a ud2a (BUG) */
21872 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21873 - else if (opfunc == _paravirt_nop)
21874 + else if (opfunc == (void *)_paravirt_nop)
21875 /* If the operation is a nop, then nop the callsite */
21876 ret = paravirt_patch_nop();
21877
21878 /* identity functions just return their single argument */
21879 - else if (opfunc == _paravirt_ident_32)
21880 + else if (opfunc == (void *)_paravirt_ident_32)
21881 ret = paravirt_patch_ident_32(insnbuf, len);
21882 - else if (opfunc == _paravirt_ident_64)
21883 + else if (opfunc == (void *)_paravirt_ident_64)
21884 ret = paravirt_patch_ident_64(insnbuf, len);
21885 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21886 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21887 + ret = paravirt_patch_ident_64(insnbuf, len);
21888 +#endif
21889
21890 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21891 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21892 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21893 if (insn_len > len || start == NULL)
21894 insn_len = len;
21895 else
21896 - memcpy(insnbuf, start, insn_len);
21897 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21898
21899 return insn_len;
21900 }
21901 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21902 return this_cpu_read(paravirt_lazy_mode);
21903 }
21904
21905 -struct pv_info pv_info = {
21906 +struct pv_info pv_info __read_only = {
21907 .name = "bare hardware",
21908 .paravirt_enabled = 0,
21909 .kernel_rpl = 0,
21910 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21911 #endif
21912 };
21913
21914 -struct pv_init_ops pv_init_ops = {
21915 +struct pv_init_ops pv_init_ops __read_only = {
21916 .patch = native_patch,
21917 };
21918
21919 -struct pv_time_ops pv_time_ops = {
21920 +struct pv_time_ops pv_time_ops __read_only = {
21921 .sched_clock = native_sched_clock,
21922 .steal_clock = native_steal_clock,
21923 };
21924
21925 -struct pv_irq_ops pv_irq_ops = {
21926 +struct pv_irq_ops pv_irq_ops __read_only = {
21927 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21928 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21929 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21930 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21931 #endif
21932 };
21933
21934 -struct pv_cpu_ops pv_cpu_ops = {
21935 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21936 .cpuid = native_cpuid,
21937 .get_debugreg = native_get_debugreg,
21938 .set_debugreg = native_set_debugreg,
21939 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21940 .end_context_switch = paravirt_nop,
21941 };
21942
21943 -struct pv_apic_ops pv_apic_ops = {
21944 +struct pv_apic_ops pv_apic_ops __read_only= {
21945 #ifdef CONFIG_X86_LOCAL_APIC
21946 .startup_ipi_hook = paravirt_nop,
21947 #endif
21948 };
21949
21950 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21951 +#ifdef CONFIG_X86_32
21952 +#ifdef CONFIG_X86_PAE
21953 +/* 64-bit pagetable entries */
21954 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21955 +#else
21956 /* 32-bit pagetable entries */
21957 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21958 +#endif
21959 #else
21960 /* 64-bit pagetable entries */
21961 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21962 #endif
21963
21964 -struct pv_mmu_ops pv_mmu_ops = {
21965 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21966
21967 .read_cr2 = native_read_cr2,
21968 .write_cr2 = native_write_cr2,
21969 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21970 .make_pud = PTE_IDENT,
21971
21972 .set_pgd = native_set_pgd,
21973 + .set_pgd_batched = native_set_pgd_batched,
21974 #endif
21975 #endif /* PAGETABLE_LEVELS >= 3 */
21976
21977 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21978 },
21979
21980 .set_fixmap = native_set_fixmap,
21981 +
21982 +#ifdef CONFIG_PAX_KERNEXEC
21983 + .pax_open_kernel = native_pax_open_kernel,
21984 + .pax_close_kernel = native_pax_close_kernel,
21985 +#endif
21986 +
21987 };
21988
21989 EXPORT_SYMBOL_GPL(pv_time_ops);
21990 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21991 index 299d493..2ccb0ee 100644
21992 --- a/arch/x86/kernel/pci-calgary_64.c
21993 +++ b/arch/x86/kernel/pci-calgary_64.c
21994 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21995 tce_space = be64_to_cpu(readq(target));
21996 tce_space = tce_space & TAR_SW_BITS;
21997
21998 - tce_space = tce_space & (~specified_table_size);
21999 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22000 info->tce_space = (u64 *)__va(tce_space);
22001 }
22002 }
22003 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22004 index 35ccf75..7a15747 100644
22005 --- a/arch/x86/kernel/pci-iommu_table.c
22006 +++ b/arch/x86/kernel/pci-iommu_table.c
22007 @@ -2,7 +2,7 @@
22008 #include <asm/iommu_table.h>
22009 #include <linux/string.h>
22010 #include <linux/kallsyms.h>
22011 -
22012 +#include <linux/sched.h>
22013
22014 #define DEBUG 1
22015
22016 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22017 index 6c483ba..d10ce2f 100644
22018 --- a/arch/x86/kernel/pci-swiotlb.c
22019 +++ b/arch/x86/kernel/pci-swiotlb.c
22020 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22021 void *vaddr, dma_addr_t dma_addr,
22022 struct dma_attrs *attrs)
22023 {
22024 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22025 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22026 }
22027
22028 static struct dma_map_ops swiotlb_dma_ops = {
22029 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22030 index 81a5f5e..20f8b58 100644
22031 --- a/arch/x86/kernel/process.c
22032 +++ b/arch/x86/kernel/process.c
22033 @@ -36,7 +36,8 @@
22034 * section. Since TSS's are completely CPU-local, we want them
22035 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22036 */
22037 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22038 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22039 +EXPORT_SYMBOL(init_tss);
22040
22041 #ifdef CONFIG_X86_64
22042 static DEFINE_PER_CPU(unsigned char, is_idle);
22043 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22044 task_xstate_cachep =
22045 kmem_cache_create("task_xstate", xstate_size,
22046 __alignof__(union thread_xstate),
22047 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22048 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22049 }
22050
22051 /*
22052 @@ -105,7 +106,7 @@ void exit_thread(void)
22053 unsigned long *bp = t->io_bitmap_ptr;
22054
22055 if (bp) {
22056 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22057 + struct tss_struct *tss = init_tss + get_cpu();
22058
22059 t->io_bitmap_ptr = NULL;
22060 clear_thread_flag(TIF_IO_BITMAP);
22061 @@ -125,6 +126,9 @@ void flush_thread(void)
22062 {
22063 struct task_struct *tsk = current;
22064
22065 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22066 + loadsegment(gs, 0);
22067 +#endif
22068 flush_ptrace_hw_breakpoint(tsk);
22069 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22070 drop_init_fpu(tsk);
22071 @@ -271,7 +275,7 @@ static void __exit_idle(void)
22072 void exit_idle(void)
22073 {
22074 /* idle loop has pid 0 */
22075 - if (current->pid)
22076 + if (task_pid_nr(current))
22077 return;
22078 __exit_idle();
22079 }
22080 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
22081 return ret;
22082 }
22083 #endif
22084 -void stop_this_cpu(void *dummy)
22085 +__noreturn void stop_this_cpu(void *dummy)
22086 {
22087 local_irq_disable();
22088 /*
22089 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
22090 }
22091 early_param("idle", idle_setup);
22092
22093 -unsigned long arch_align_stack(unsigned long sp)
22094 +#ifdef CONFIG_PAX_RANDKSTACK
22095 +void pax_randomize_kstack(struct pt_regs *regs)
22096 {
22097 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22098 - sp -= get_random_int() % 8192;
22099 - return sp & ~0xf;
22100 -}
22101 + struct thread_struct *thread = &current->thread;
22102 + unsigned long time;
22103
22104 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22105 -{
22106 - unsigned long range_end = mm->brk + 0x02000000;
22107 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22108 -}
22109 + if (!randomize_va_space)
22110 + return;
22111 +
22112 + if (v8086_mode(regs))
22113 + return;
22114
22115 + rdtscl(time);
22116 +
22117 + /* P4 seems to return a 0 LSB, ignore it */
22118 +#ifdef CONFIG_MPENTIUM4
22119 + time &= 0x3EUL;
22120 + time <<= 2;
22121 +#elif defined(CONFIG_X86_64)
22122 + time &= 0xFUL;
22123 + time <<= 4;
22124 +#else
22125 + time &= 0x1FUL;
22126 + time <<= 3;
22127 +#endif
22128 +
22129 + thread->sp0 ^= time;
22130 + load_sp0(init_tss + smp_processor_id(), thread);
22131 +
22132 +#ifdef CONFIG_X86_64
22133 + this_cpu_write(kernel_stack, thread->sp0);
22134 +#endif
22135 +}
22136 +#endif
22137 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22138 index 7305f7d..22f73d6 100644
22139 --- a/arch/x86/kernel/process_32.c
22140 +++ b/arch/x86/kernel/process_32.c
22141 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22142 unsigned long thread_saved_pc(struct task_struct *tsk)
22143 {
22144 return ((unsigned long *)tsk->thread.sp)[3];
22145 +//XXX return tsk->thread.eip;
22146 }
22147
22148 void __show_regs(struct pt_regs *regs, int all)
22149 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
22150 unsigned long sp;
22151 unsigned short ss, gs;
22152
22153 - if (user_mode_vm(regs)) {
22154 + if (user_mode(regs)) {
22155 sp = regs->sp;
22156 ss = regs->ss & 0xffff;
22157 - gs = get_user_gs(regs);
22158 } else {
22159 sp = kernel_stack_pointer(regs);
22160 savesegment(ss, ss);
22161 - savesegment(gs, gs);
22162 }
22163 + gs = get_user_gs(regs);
22164
22165 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22166 (u16)regs->cs, regs->ip, regs->flags,
22167 - smp_processor_id());
22168 + raw_smp_processor_id());
22169 print_symbol("EIP is at %s\n", regs->ip);
22170
22171 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22172 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
22173 int copy_thread(unsigned long clone_flags, unsigned long sp,
22174 unsigned long arg, struct task_struct *p)
22175 {
22176 - struct pt_regs *childregs = task_pt_regs(p);
22177 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22178 struct task_struct *tsk;
22179 int err;
22180
22181 p->thread.sp = (unsigned long) childregs;
22182 p->thread.sp0 = (unsigned long) (childregs+1);
22183 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22184
22185 if (unlikely(p->flags & PF_KTHREAD)) {
22186 /* kernel thread */
22187 memset(childregs, 0, sizeof(struct pt_regs));
22188 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22189 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22190 - childregs->ds = __USER_DS;
22191 - childregs->es = __USER_DS;
22192 + savesegment(gs, childregs->gs);
22193 + childregs->ds = __KERNEL_DS;
22194 + childregs->es = __KERNEL_DS;
22195 childregs->fs = __KERNEL_PERCPU;
22196 childregs->bx = sp; /* function */
22197 childregs->bp = arg;
22198 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22199 struct thread_struct *prev = &prev_p->thread,
22200 *next = &next_p->thread;
22201 int cpu = smp_processor_id();
22202 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22203 + struct tss_struct *tss = init_tss + cpu;
22204 fpu_switch_t fpu;
22205
22206 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22207 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22208 */
22209 lazy_save_gs(prev->gs);
22210
22211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22212 + __set_fs(task_thread_info(next_p)->addr_limit);
22213 +#endif
22214 +
22215 /*
22216 * Load the per-thread Thread-Local Storage descriptor.
22217 */
22218 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22219 */
22220 arch_end_context_switch(next_p);
22221
22222 + this_cpu_write(current_task, next_p);
22223 + this_cpu_write(current_tinfo, &next_p->tinfo);
22224 +
22225 /*
22226 * Restore %gs if needed (which is common)
22227 */
22228 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22229
22230 switch_fpu_finish(next_p, fpu);
22231
22232 - this_cpu_write(current_task, next_p);
22233 -
22234 return prev_p;
22235 }
22236
22237 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
22238 } while (count++ < 16);
22239 return 0;
22240 }
22241 -
22242 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22243 index 355ae06..4530766 100644
22244 --- a/arch/x86/kernel/process_64.c
22245 +++ b/arch/x86/kernel/process_64.c
22246 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22247 struct pt_regs *childregs;
22248 struct task_struct *me = current;
22249
22250 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22251 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22252 childregs = task_pt_regs(p);
22253 p->thread.sp = (unsigned long) childregs;
22254 p->thread.usersp = me->thread.usersp;
22255 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22256 set_tsk_thread_flag(p, TIF_FORK);
22257 p->fpu_counter = 0;
22258 p->thread.io_bitmap_ptr = NULL;
22259 @@ -273,7 +274,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22260 struct thread_struct *prev = &prev_p->thread;
22261 struct thread_struct *next = &next_p->thread;
22262 int cpu = smp_processor_id();
22263 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22264 + struct tss_struct *tss = init_tss + cpu;
22265 unsigned fsindex, gsindex;
22266 fpu_switch_t fpu;
22267
22268 @@ -355,10 +356,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22269 prev->usersp = this_cpu_read(old_rsp);
22270 this_cpu_write(old_rsp, next->usersp);
22271 this_cpu_write(current_task, next_p);
22272 + this_cpu_write(current_tinfo, &next_p->tinfo);
22273
22274 - this_cpu_write(kernel_stack,
22275 - (unsigned long)task_stack_page(next_p) +
22276 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22277 + this_cpu_write(kernel_stack, next->sp0);
22278
22279 /*
22280 * Now maybe reload the debug registers and handle I/O bitmaps
22281 @@ -427,12 +427,11 @@ unsigned long get_wchan(struct task_struct *p)
22282 if (!p || p == current || p->state == TASK_RUNNING)
22283 return 0;
22284 stack = (unsigned long)task_stack_page(p);
22285 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22286 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22287 return 0;
22288 fp = *(u64 *)(p->thread.sp);
22289 do {
22290 - if (fp < (unsigned long)stack ||
22291 - fp >= (unsigned long)stack+THREAD_SIZE)
22292 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22293 return 0;
22294 ip = *(u64 *)(fp+8);
22295 if (!in_sched_functions(ip))
22296 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22297 index 29a8120..a50b5ee 100644
22298 --- a/arch/x86/kernel/ptrace.c
22299 +++ b/arch/x86/kernel/ptrace.c
22300 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22301 {
22302 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22303 unsigned long sp = (unsigned long)&regs->sp;
22304 - struct thread_info *tinfo;
22305
22306 - if (context == (sp & ~(THREAD_SIZE - 1)))
22307 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22308 return sp;
22309
22310 - tinfo = (struct thread_info *)context;
22311 - if (tinfo->previous_esp)
22312 - return tinfo->previous_esp;
22313 + sp = *(unsigned long *)context;
22314 + if (sp)
22315 + return sp;
22316
22317 return (unsigned long)regs;
22318 }
22319 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22320 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22321 {
22322 int i;
22323 - int dr7 = 0;
22324 + unsigned long dr7 = 0;
22325 struct arch_hw_breakpoint *info;
22326
22327 for (i = 0; i < HBP_NUM; i++) {
22328 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22329 unsigned long addr, unsigned long data)
22330 {
22331 int ret;
22332 - unsigned long __user *datap = (unsigned long __user *)data;
22333 + unsigned long __user *datap = (__force unsigned long __user *)data;
22334
22335 switch (request) {
22336 /* read the word at location addr in the USER area. */
22337 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22338 if ((int) addr < 0)
22339 return -EIO;
22340 ret = do_get_thread_area(child, addr,
22341 - (struct user_desc __user *)data);
22342 + (__force struct user_desc __user *) data);
22343 break;
22344
22345 case PTRACE_SET_THREAD_AREA:
22346 if ((int) addr < 0)
22347 return -EIO;
22348 ret = do_set_thread_area(child, addr,
22349 - (struct user_desc __user *)data, 0);
22350 + (__force struct user_desc __user *) data, 0);
22351 break;
22352 #endif
22353
22354 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22355
22356 #ifdef CONFIG_X86_64
22357
22358 -static struct user_regset x86_64_regsets[] __read_mostly = {
22359 +static user_regset_no_const x86_64_regsets[] __read_only = {
22360 [REGSET_GENERAL] = {
22361 .core_note_type = NT_PRSTATUS,
22362 .n = sizeof(struct user_regs_struct) / sizeof(long),
22363 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22364 #endif /* CONFIG_X86_64 */
22365
22366 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22367 -static struct user_regset x86_32_regsets[] __read_mostly = {
22368 +static user_regset_no_const x86_32_regsets[] __read_only = {
22369 [REGSET_GENERAL] = {
22370 .core_note_type = NT_PRSTATUS,
22371 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22372 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22373 */
22374 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22375
22376 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22377 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22378 {
22379 #ifdef CONFIG_X86_64
22380 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22381 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22382 memset(info, 0, sizeof(*info));
22383 info->si_signo = SIGTRAP;
22384 info->si_code = si_code;
22385 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22386 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22387 }
22388
22389 void user_single_step_siginfo(struct task_struct *tsk,
22390 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22391 # define IS_IA32 0
22392 #endif
22393
22394 +#ifdef CONFIG_GRKERNSEC_SETXID
22395 +extern void gr_delayed_cred_worker(void);
22396 +#endif
22397 +
22398 /*
22399 * We must return the syscall number to actually look up in the table.
22400 * This can be -1L to skip running any syscall at all.
22401 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22402
22403 user_exit();
22404
22405 +#ifdef CONFIG_GRKERNSEC_SETXID
22406 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22407 + gr_delayed_cred_worker();
22408 +#endif
22409 +
22410 /*
22411 * If we stepped into a sysenter/syscall insn, it trapped in
22412 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22413 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22414 */
22415 user_exit();
22416
22417 +#ifdef CONFIG_GRKERNSEC_SETXID
22418 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22419 + gr_delayed_cred_worker();
22420 +#endif
22421 +
22422 audit_syscall_exit(regs);
22423
22424 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22425 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22426 index 2cb9470..ff1fd80 100644
22427 --- a/arch/x86/kernel/pvclock.c
22428 +++ b/arch/x86/kernel/pvclock.c
22429 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22430 return pv_tsc_khz;
22431 }
22432
22433 -static atomic64_t last_value = ATOMIC64_INIT(0);
22434 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22435
22436 void pvclock_resume(void)
22437 {
22438 - atomic64_set(&last_value, 0);
22439 + atomic64_set_unchecked(&last_value, 0);
22440 }
22441
22442 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22443 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22444 * updating at the same time, and one of them could be slightly behind,
22445 * making the assumption that last_value always go forward fail to hold.
22446 */
22447 - last = atomic64_read(&last_value);
22448 + last = atomic64_read_unchecked(&last_value);
22449 do {
22450 if (ret < last)
22451 return last;
22452 - last = atomic64_cmpxchg(&last_value, last, ret);
22453 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22454 } while (unlikely(last != ret));
22455
22456 return ret;
22457 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22458 index 76fa1e9..abf09ea 100644
22459 --- a/arch/x86/kernel/reboot.c
22460 +++ b/arch/x86/kernel/reboot.c
22461 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22462 EXPORT_SYMBOL(pm_power_off);
22463
22464 static const struct desc_ptr no_idt = {};
22465 -static int reboot_mode;
22466 +static unsigned short reboot_mode;
22467 enum reboot_type reboot_type = BOOT_ACPI;
22468 int reboot_force;
22469
22470 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22471
22472 void __noreturn machine_real_restart(unsigned int type)
22473 {
22474 +
22475 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22476 + struct desc_struct *gdt;
22477 +#endif
22478 +
22479 local_irq_disable();
22480
22481 /*
22482 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22483
22484 /* Jump to the identity-mapped low memory code */
22485 #ifdef CONFIG_X86_32
22486 - asm volatile("jmpl *%0" : :
22487 +
22488 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22489 + gdt = get_cpu_gdt_table(smp_processor_id());
22490 + pax_open_kernel();
22491 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22492 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22493 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22494 + loadsegment(ds, __KERNEL_DS);
22495 + loadsegment(es, __KERNEL_DS);
22496 + loadsegment(ss, __KERNEL_DS);
22497 +#endif
22498 +#ifdef CONFIG_PAX_KERNEXEC
22499 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22500 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22501 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22502 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22503 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22504 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22505 +#endif
22506 + pax_close_kernel();
22507 +#endif
22508 +
22509 + asm volatile("ljmpl *%0" : :
22510 "rm" (real_mode_header->machine_real_restart_asm),
22511 "a" (type));
22512 #else
22513 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22514 * try to force a triple fault and then cycle between hitting the keyboard
22515 * controller and doing that
22516 */
22517 -static void native_machine_emergency_restart(void)
22518 +static void __noreturn native_machine_emergency_restart(void)
22519 {
22520 int i;
22521 int attempt = 0;
22522 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22523 #endif
22524 }
22525
22526 -static void __machine_emergency_restart(int emergency)
22527 +static void __noreturn __machine_emergency_restart(int emergency)
22528 {
22529 reboot_emergency = emergency;
22530 machine_ops.emergency_restart();
22531 }
22532
22533 -static void native_machine_restart(char *__unused)
22534 +static void __noreturn native_machine_restart(char *__unused)
22535 {
22536 pr_notice("machine restart\n");
22537
22538 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22539 __machine_emergency_restart(0);
22540 }
22541
22542 -static void native_machine_halt(void)
22543 +static void __noreturn native_machine_halt(void)
22544 {
22545 /* Stop other cpus and apics */
22546 machine_shutdown();
22547 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22548 stop_this_cpu(NULL);
22549 }
22550
22551 -static void native_machine_power_off(void)
22552 +static void __noreturn native_machine_power_off(void)
22553 {
22554 if (pm_power_off) {
22555 if (!reboot_force)
22556 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22557 }
22558 /* A fallback in case there is no PM info available */
22559 tboot_shutdown(TB_SHUTDOWN_HALT);
22560 + unreachable();
22561 }
22562
22563 -struct machine_ops machine_ops = {
22564 +struct machine_ops machine_ops __read_only = {
22565 .power_off = native_machine_power_off,
22566 .shutdown = native_machine_shutdown,
22567 .emergency_restart = native_machine_emergency_restart,
22568 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22569 index f2bb9c9..bed145d7 100644
22570 --- a/arch/x86/kernel/relocate_kernel_64.S
22571 +++ b/arch/x86/kernel/relocate_kernel_64.S
22572 @@ -11,6 +11,7 @@
22573 #include <asm/kexec.h>
22574 #include <asm/processor-flags.h>
22575 #include <asm/pgtable_types.h>
22576 +#include <asm/alternative-asm.h>
22577
22578 /*
22579 * Must be relocatable PIC code callable as a C function
22580 @@ -167,6 +168,7 @@ identity_mapped:
22581 xorq %r14, %r14
22582 xorq %r15, %r15
22583
22584 + pax_force_retaddr 0, 1
22585 ret
22586
22587 1:
22588 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22589 index 56f7fcf..fa229f4 100644
22590 --- a/arch/x86/kernel/setup.c
22591 +++ b/arch/x86/kernel/setup.c
22592 @@ -110,6 +110,7 @@
22593 #include <asm/mce.h>
22594 #include <asm/alternative.h>
22595 #include <asm/prom.h>
22596 +#include <asm/boot.h>
22597
22598 /*
22599 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22600 @@ -444,7 +445,7 @@ static void __init parse_setup_data(void)
22601
22602 switch (data->type) {
22603 case SETUP_E820_EXT:
22604 - parse_e820_ext(data);
22605 + parse_e820_ext((struct setup_data __force_kernel *)data);
22606 break;
22607 case SETUP_DTB:
22608 add_dtb(pa_data);
22609 @@ -771,7 +772,7 @@ static void __init trim_bios_range(void)
22610 * area (640->1Mb) as ram even though it is not.
22611 * take them out.
22612 */
22613 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22614 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22615
22616 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22617 }
22618 @@ -779,7 +780,7 @@ static void __init trim_bios_range(void)
22619 /* called before trim_bios_range() to spare extra sanitize */
22620 static void __init e820_add_kernel_range(void)
22621 {
22622 - u64 start = __pa_symbol(_text);
22623 + u64 start = __pa_symbol(ktla_ktva(_text));
22624 u64 size = __pa_symbol(_end) - start;
22625
22626 /*
22627 @@ -841,8 +842,12 @@ static void __init trim_low_memory_range(void)
22628
22629 void __init setup_arch(char **cmdline_p)
22630 {
22631 +#ifdef CONFIG_X86_32
22632 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22633 +#else
22634 memblock_reserve(__pa_symbol(_text),
22635 (unsigned long)__bss_stop - (unsigned long)_text);
22636 +#endif
22637
22638 early_reserve_initrd();
22639
22640 @@ -934,14 +939,14 @@ void __init setup_arch(char **cmdline_p)
22641
22642 if (!boot_params.hdr.root_flags)
22643 root_mountflags &= ~MS_RDONLY;
22644 - init_mm.start_code = (unsigned long) _text;
22645 - init_mm.end_code = (unsigned long) _etext;
22646 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22647 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22648 init_mm.end_data = (unsigned long) _edata;
22649 init_mm.brk = _brk_end;
22650
22651 - code_resource.start = __pa_symbol(_text);
22652 - code_resource.end = __pa_symbol(_etext)-1;
22653 - data_resource.start = __pa_symbol(_etext);
22654 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22655 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22656 + data_resource.start = __pa_symbol(_sdata);
22657 data_resource.end = __pa_symbol(_edata)-1;
22658 bss_resource.start = __pa_symbol(__bss_start);
22659 bss_resource.end = __pa_symbol(__bss_stop)-1;
22660 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22661 index 5cdff03..80fa283 100644
22662 --- a/arch/x86/kernel/setup_percpu.c
22663 +++ b/arch/x86/kernel/setup_percpu.c
22664 @@ -21,19 +21,17 @@
22665 #include <asm/cpu.h>
22666 #include <asm/stackprotector.h>
22667
22668 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22669 +#ifdef CONFIG_SMP
22670 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22671 EXPORT_PER_CPU_SYMBOL(cpu_number);
22672 +#endif
22673
22674 -#ifdef CONFIG_X86_64
22675 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22676 -#else
22677 -#define BOOT_PERCPU_OFFSET 0
22678 -#endif
22679
22680 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22681 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22682
22683 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22684 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22685 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22686 };
22687 EXPORT_SYMBOL(__per_cpu_offset);
22688 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22689 {
22690 #ifdef CONFIG_NEED_MULTIPLE_NODES
22691 pg_data_t *last = NULL;
22692 - unsigned int cpu;
22693 + int cpu;
22694
22695 for_each_possible_cpu(cpu) {
22696 int node = early_cpu_to_node(cpu);
22697 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22698 {
22699 #ifdef CONFIG_X86_32
22700 struct desc_struct gdt;
22701 + unsigned long base = per_cpu_offset(cpu);
22702
22703 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22704 - 0x2 | DESCTYPE_S, 0x8);
22705 - gdt.s = 1;
22706 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22707 + 0x83 | DESCTYPE_S, 0xC);
22708 write_gdt_entry(get_cpu_gdt_table(cpu),
22709 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22710 #endif
22711 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22712 /* alrighty, percpu areas up and running */
22713 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22714 for_each_possible_cpu(cpu) {
22715 +#ifdef CONFIG_CC_STACKPROTECTOR
22716 +#ifdef CONFIG_X86_32
22717 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22718 +#endif
22719 +#endif
22720 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22721 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22722 per_cpu(cpu_number, cpu) = cpu;
22723 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22724 */
22725 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22726 #endif
22727 +#ifdef CONFIG_CC_STACKPROTECTOR
22728 +#ifdef CONFIG_X86_32
22729 + if (!cpu)
22730 + per_cpu(stack_canary.canary, cpu) = canary;
22731 +#endif
22732 +#endif
22733 /*
22734 * Up to this point, the boot CPU has been using .init.data
22735 * area. Reload any changed state for the boot CPU.
22736 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22737 index 6956299..f20beae 100644
22738 --- a/arch/x86/kernel/signal.c
22739 +++ b/arch/x86/kernel/signal.c
22740 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22741 * Align the stack pointer according to the i386 ABI,
22742 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22743 */
22744 - sp = ((sp + 4) & -16ul) - 4;
22745 + sp = ((sp - 12) & -16ul) - 4;
22746 #else /* !CONFIG_X86_32 */
22747 sp = round_down(sp, 16) - 8;
22748 #endif
22749 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22750 }
22751
22752 if (current->mm->context.vdso)
22753 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22754 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22755 else
22756 - restorer = &frame->retcode;
22757 + restorer = (void __user *)&frame->retcode;
22758 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22759 restorer = ksig->ka.sa.sa_restorer;
22760
22761 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22762 * reasons and because gdb uses it as a signature to notice
22763 * signal handler stack frames.
22764 */
22765 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22766 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22767
22768 if (err)
22769 return -EFAULT;
22770 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22771 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22772
22773 /* Set up to return from userspace. */
22774 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22775 + if (current->mm->context.vdso)
22776 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22777 + else
22778 + restorer = (void __user *)&frame->retcode;
22779 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22780 restorer = ksig->ka.sa.sa_restorer;
22781 put_user_ex(restorer, &frame->pretcode);
22782 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22783 * reasons and because gdb uses it as a signature to notice
22784 * signal handler stack frames.
22785 */
22786 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22787 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22788 } put_user_catch(err);
22789
22790 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22791 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22792 {
22793 int usig = signr_convert(ksig->sig);
22794 sigset_t *set = sigmask_to_save();
22795 - compat_sigset_t *cset = (compat_sigset_t *) set;
22796 + sigset_t sigcopy;
22797 + compat_sigset_t *cset;
22798 +
22799 + sigcopy = *set;
22800 +
22801 + cset = (compat_sigset_t *) &sigcopy;
22802
22803 /* Set up the stack frame */
22804 if (is_ia32_frame()) {
22805 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22806 } else if (is_x32_frame()) {
22807 return x32_setup_rt_frame(ksig, cset, regs);
22808 } else {
22809 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22810 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22811 }
22812 }
22813
22814 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22815 index 48d2b7d..90d328a 100644
22816 --- a/arch/x86/kernel/smp.c
22817 +++ b/arch/x86/kernel/smp.c
22818 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22819
22820 __setup("nonmi_ipi", nonmi_ipi_setup);
22821
22822 -struct smp_ops smp_ops = {
22823 +struct smp_ops smp_ops __read_only = {
22824 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22825 .smp_prepare_cpus = native_smp_prepare_cpus,
22826 .smp_cpus_done = native_smp_cpus_done,
22827 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22828 index bfd348e..4816ad8 100644
22829 --- a/arch/x86/kernel/smpboot.c
22830 +++ b/arch/x86/kernel/smpboot.c
22831 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22832 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22833 (THREAD_SIZE + task_stack_page(idle))) - 1);
22834 per_cpu(current_task, cpu) = idle;
22835 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22836
22837 #ifdef CONFIG_X86_32
22838 /* Stack for startup_32 can be just as for start_secondary onwards */
22839 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22840 #else
22841 clear_tsk_thread_flag(idle, TIF_FORK);
22842 initial_gs = per_cpu_offset(cpu);
22843 - per_cpu(kernel_stack, cpu) =
22844 - (unsigned long)task_stack_page(idle) -
22845 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22846 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22847 #endif
22848 +
22849 + pax_open_kernel();
22850 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22851 + pax_close_kernel();
22852 +
22853 initial_code = (unsigned long)start_secondary;
22854 stack_start = idle->thread.sp;
22855
22856 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22857 /* the FPU context is blank, nobody can own it */
22858 __cpu_disable_lazy_restore(cpu);
22859
22860 +#ifdef CONFIG_PAX_PER_CPU_PGD
22861 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22862 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22863 + KERNEL_PGD_PTRS);
22864 +#endif
22865 +
22866 + /* the FPU context is blank, nobody can own it */
22867 + __cpu_disable_lazy_restore(cpu);
22868 +
22869 err = do_boot_cpu(apicid, cpu, tidle);
22870 if (err) {
22871 pr_debug("do_boot_cpu failed %d\n", err);
22872 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22873 index 9b4d51d..5d28b58 100644
22874 --- a/arch/x86/kernel/step.c
22875 +++ b/arch/x86/kernel/step.c
22876 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22877 struct desc_struct *desc;
22878 unsigned long base;
22879
22880 - seg &= ~7UL;
22881 + seg >>= 3;
22882
22883 mutex_lock(&child->mm->context.lock);
22884 - if (unlikely((seg >> 3) >= child->mm->context.size))
22885 + if (unlikely(seg >= child->mm->context.size))
22886 addr = -1L; /* bogus selector, access would fault */
22887 else {
22888 desc = child->mm->context.ldt + seg;
22889 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22890 addr += base;
22891 }
22892 mutex_unlock(&child->mm->context.lock);
22893 - }
22894 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22895 + addr = ktla_ktva(addr);
22896
22897 return addr;
22898 }
22899 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22900 unsigned char opcode[15];
22901 unsigned long addr = convert_ip_to_linear(child, regs);
22902
22903 + if (addr == -EINVAL)
22904 + return 0;
22905 +
22906 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22907 for (i = 0; i < copied; i++) {
22908 switch (opcode[i]) {
22909 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22910 new file mode 100644
22911 index 0000000..5877189
22912 --- /dev/null
22913 +++ b/arch/x86/kernel/sys_i386_32.c
22914 @@ -0,0 +1,189 @@
22915 +/*
22916 + * This file contains various random system calls that
22917 + * have a non-standard calling sequence on the Linux/i386
22918 + * platform.
22919 + */
22920 +
22921 +#include <linux/errno.h>
22922 +#include <linux/sched.h>
22923 +#include <linux/mm.h>
22924 +#include <linux/fs.h>
22925 +#include <linux/smp.h>
22926 +#include <linux/sem.h>
22927 +#include <linux/msg.h>
22928 +#include <linux/shm.h>
22929 +#include <linux/stat.h>
22930 +#include <linux/syscalls.h>
22931 +#include <linux/mman.h>
22932 +#include <linux/file.h>
22933 +#include <linux/utsname.h>
22934 +#include <linux/ipc.h>
22935 +#include <linux/elf.h>
22936 +
22937 +#include <linux/uaccess.h>
22938 +#include <linux/unistd.h>
22939 +
22940 +#include <asm/syscalls.h>
22941 +
22942 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22943 +{
22944 + unsigned long pax_task_size = TASK_SIZE;
22945 +
22946 +#ifdef CONFIG_PAX_SEGMEXEC
22947 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22948 + pax_task_size = SEGMEXEC_TASK_SIZE;
22949 +#endif
22950 +
22951 + if (flags & MAP_FIXED)
22952 + if (len > pax_task_size || addr > pax_task_size - len)
22953 + return -EINVAL;
22954 +
22955 + return 0;
22956 +}
22957 +
22958 +/*
22959 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
22960 + */
22961 +static unsigned long get_align_mask(void)
22962 +{
22963 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
22964 + return 0;
22965 +
22966 + if (!(current->flags & PF_RANDOMIZE))
22967 + return 0;
22968 +
22969 + return va_align.mask;
22970 +}
22971 +
22972 +unsigned long
22973 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22974 + unsigned long len, unsigned long pgoff, unsigned long flags)
22975 +{
22976 + struct mm_struct *mm = current->mm;
22977 + struct vm_area_struct *vma;
22978 + unsigned long pax_task_size = TASK_SIZE;
22979 + struct vm_unmapped_area_info info;
22980 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22981 +
22982 +#ifdef CONFIG_PAX_SEGMEXEC
22983 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22984 + pax_task_size = SEGMEXEC_TASK_SIZE;
22985 +#endif
22986 +
22987 + pax_task_size -= PAGE_SIZE;
22988 +
22989 + if (len > pax_task_size)
22990 + return -ENOMEM;
22991 +
22992 + if (flags & MAP_FIXED)
22993 + return addr;
22994 +
22995 +#ifdef CONFIG_PAX_RANDMMAP
22996 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22997 +#endif
22998 +
22999 + if (addr) {
23000 + addr = PAGE_ALIGN(addr);
23001 + if (pax_task_size - len >= addr) {
23002 + vma = find_vma(mm, addr);
23003 + if (check_heap_stack_gap(vma, addr, len, offset))
23004 + return addr;
23005 + }
23006 + }
23007 +
23008 + info.flags = 0;
23009 + info.length = len;
23010 + info.align_mask = filp ? get_align_mask() : 0;
23011 + info.align_offset = pgoff << PAGE_SHIFT;
23012 + info.threadstack_offset = offset;
23013 +
23014 +#ifdef CONFIG_PAX_PAGEEXEC
23015 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
23016 + info.low_limit = 0x00110000UL;
23017 + info.high_limit = mm->start_code;
23018 +
23019 +#ifdef CONFIG_PAX_RANDMMAP
23020 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23021 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
23022 +#endif
23023 +
23024 + if (info.low_limit < info.high_limit) {
23025 + addr = vm_unmapped_area(&info);
23026 + if (!IS_ERR_VALUE(addr))
23027 + return addr;
23028 + }
23029 + } else
23030 +#endif
23031 +
23032 + info.low_limit = mm->mmap_base;
23033 + info.high_limit = pax_task_size;
23034 +
23035 + return vm_unmapped_area(&info);
23036 +}
23037 +
23038 +unsigned long
23039 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23040 + const unsigned long len, const unsigned long pgoff,
23041 + const unsigned long flags)
23042 +{
23043 + struct vm_area_struct *vma;
23044 + struct mm_struct *mm = current->mm;
23045 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23046 + struct vm_unmapped_area_info info;
23047 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23048 +
23049 +#ifdef CONFIG_PAX_SEGMEXEC
23050 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23051 + pax_task_size = SEGMEXEC_TASK_SIZE;
23052 +#endif
23053 +
23054 + pax_task_size -= PAGE_SIZE;
23055 +
23056 + /* requested length too big for entire address space */
23057 + if (len > pax_task_size)
23058 + return -ENOMEM;
23059 +
23060 + if (flags & MAP_FIXED)
23061 + return addr;
23062 +
23063 +#ifdef CONFIG_PAX_PAGEEXEC
23064 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23065 + goto bottomup;
23066 +#endif
23067 +
23068 +#ifdef CONFIG_PAX_RANDMMAP
23069 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23070 +#endif
23071 +
23072 + /* requesting a specific address */
23073 + if (addr) {
23074 + addr = PAGE_ALIGN(addr);
23075 + if (pax_task_size - len >= addr) {
23076 + vma = find_vma(mm, addr);
23077 + if (check_heap_stack_gap(vma, addr, len, offset))
23078 + return addr;
23079 + }
23080 + }
23081 +
23082 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23083 + info.length = len;
23084 + info.low_limit = PAGE_SIZE;
23085 + info.high_limit = mm->mmap_base;
23086 + info.align_mask = filp ? get_align_mask() : 0;
23087 + info.align_offset = pgoff << PAGE_SHIFT;
23088 + info.threadstack_offset = offset;
23089 +
23090 + addr = vm_unmapped_area(&info);
23091 + if (!(addr & ~PAGE_MASK))
23092 + return addr;
23093 + VM_BUG_ON(addr != -ENOMEM);
23094 +
23095 +bottomup:
23096 + /*
23097 + * A failed mmap() very likely causes application failure,
23098 + * so fall back to the bottom-up function here. This scenario
23099 + * can happen with large stack limits and large mmap()
23100 + * allocations.
23101 + */
23102 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23103 +}
23104 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23105 index dbded5a..ace2781 100644
23106 --- a/arch/x86/kernel/sys_x86_64.c
23107 +++ b/arch/x86/kernel/sys_x86_64.c
23108 @@ -81,8 +81,8 @@ out:
23109 return error;
23110 }
23111
23112 -static void find_start_end(unsigned long flags, unsigned long *begin,
23113 - unsigned long *end)
23114 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23115 + unsigned long *begin, unsigned long *end)
23116 {
23117 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23118 unsigned long new_begin;
23119 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23120 *begin = new_begin;
23121 }
23122 } else {
23123 - *begin = TASK_UNMAPPED_BASE;
23124 + *begin = mm->mmap_base;
23125 *end = TASK_SIZE;
23126 }
23127 }
23128 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23129 struct vm_area_struct *vma;
23130 struct vm_unmapped_area_info info;
23131 unsigned long begin, end;
23132 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23133
23134 if (flags & MAP_FIXED)
23135 return addr;
23136
23137 - find_start_end(flags, &begin, &end);
23138 + find_start_end(mm, flags, &begin, &end);
23139
23140 if (len > end)
23141 return -ENOMEM;
23142
23143 +#ifdef CONFIG_PAX_RANDMMAP
23144 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23145 +#endif
23146 +
23147 if (addr) {
23148 addr = PAGE_ALIGN(addr);
23149 vma = find_vma(mm, addr);
23150 - if (end - len >= addr &&
23151 - (!vma || addr + len <= vma->vm_start))
23152 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23153 return addr;
23154 }
23155
23156 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23157 info.high_limit = end;
23158 info.align_mask = filp ? get_align_mask() : 0;
23159 info.align_offset = pgoff << PAGE_SHIFT;
23160 + info.threadstack_offset = offset;
23161 return vm_unmapped_area(&info);
23162 }
23163
23164 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23165 struct mm_struct *mm = current->mm;
23166 unsigned long addr = addr0;
23167 struct vm_unmapped_area_info info;
23168 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23169
23170 /* requested length too big for entire address space */
23171 if (len > TASK_SIZE)
23172 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23173 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23174 goto bottomup;
23175
23176 +#ifdef CONFIG_PAX_RANDMMAP
23177 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23178 +#endif
23179 +
23180 /* requesting a specific address */
23181 if (addr) {
23182 addr = PAGE_ALIGN(addr);
23183 vma = find_vma(mm, addr);
23184 - if (TASK_SIZE - len >= addr &&
23185 - (!vma || addr + len <= vma->vm_start))
23186 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23187 return addr;
23188 }
23189
23190 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23191 info.high_limit = mm->mmap_base;
23192 info.align_mask = filp ? get_align_mask() : 0;
23193 info.align_offset = pgoff << PAGE_SHIFT;
23194 + info.threadstack_offset = offset;
23195 addr = vm_unmapped_area(&info);
23196 if (!(addr & ~PAGE_MASK))
23197 return addr;
23198 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23199 index f84fe00..f41d9f1 100644
23200 --- a/arch/x86/kernel/tboot.c
23201 +++ b/arch/x86/kernel/tboot.c
23202 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23203
23204 void tboot_shutdown(u32 shutdown_type)
23205 {
23206 - void (*shutdown)(void);
23207 + void (* __noreturn shutdown)(void);
23208
23209 if (!tboot_enabled())
23210 return;
23211 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23212
23213 switch_to_tboot_pt();
23214
23215 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23216 + shutdown = (void *)tboot->shutdown_entry;
23217 shutdown();
23218
23219 /* should not reach here */
23220 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23221 return 0;
23222 }
23223
23224 -static atomic_t ap_wfs_count;
23225 +static atomic_unchecked_t ap_wfs_count;
23226
23227 static int tboot_wait_for_aps(int num_aps)
23228 {
23229 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23230 {
23231 switch (action) {
23232 case CPU_DYING:
23233 - atomic_inc(&ap_wfs_count);
23234 + atomic_inc_unchecked(&ap_wfs_count);
23235 if (num_online_cpus() == 1)
23236 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23237 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23238 return NOTIFY_BAD;
23239 break;
23240 }
23241 return NOTIFY_OK;
23242 }
23243
23244 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23245 +static struct notifier_block tboot_cpu_notifier =
23246 {
23247 .notifier_call = tboot_cpu_callback,
23248 };
23249 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23250
23251 tboot_create_trampoline();
23252
23253 - atomic_set(&ap_wfs_count, 0);
23254 + atomic_set_unchecked(&ap_wfs_count, 0);
23255 register_hotcpu_notifier(&tboot_cpu_notifier);
23256
23257 acpi_os_set_prepare_sleep(&tboot_sleep);
23258 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23259 index 24d3c91..d06b473 100644
23260 --- a/arch/x86/kernel/time.c
23261 +++ b/arch/x86/kernel/time.c
23262 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23263 {
23264 unsigned long pc = instruction_pointer(regs);
23265
23266 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23267 + if (!user_mode(regs) && in_lock_functions(pc)) {
23268 #ifdef CONFIG_FRAME_POINTER
23269 - return *(unsigned long *)(regs->bp + sizeof(long));
23270 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23271 #else
23272 unsigned long *sp =
23273 (unsigned long *)kernel_stack_pointer(regs);
23274 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23275 * or above a saved flags. Eflags has bits 22-31 zero,
23276 * kernel addresses don't.
23277 */
23278 +
23279 +#ifdef CONFIG_PAX_KERNEXEC
23280 + return ktla_ktva(sp[0]);
23281 +#else
23282 if (sp[0] >> 22)
23283 return sp[0];
23284 if (sp[1] >> 22)
23285 return sp[1];
23286 #endif
23287 +
23288 +#endif
23289 }
23290 return pc;
23291 }
23292 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23293 index f7fec09..9991981 100644
23294 --- a/arch/x86/kernel/tls.c
23295 +++ b/arch/x86/kernel/tls.c
23296 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23297 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23298 return -EINVAL;
23299
23300 +#ifdef CONFIG_PAX_SEGMEXEC
23301 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23302 + return -EINVAL;
23303 +#endif
23304 +
23305 set_tls_desc(p, idx, &info, 1);
23306
23307 return 0;
23308 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23309
23310 if (kbuf)
23311 info = kbuf;
23312 - else if (__copy_from_user(infobuf, ubuf, count))
23313 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23314 return -EFAULT;
23315 else
23316 info = infobuf;
23317 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23318 index 772e2a8..bad5bf6 100644
23319 --- a/arch/x86/kernel/traps.c
23320 +++ b/arch/x86/kernel/traps.c
23321 @@ -68,12 +68,6 @@
23322 #include <asm/setup.h>
23323
23324 asmlinkage int system_call(void);
23325 -
23326 -/*
23327 - * The IDT has to be page-aligned to simplify the Pentium
23328 - * F0 0F bug workaround.
23329 - */
23330 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23331 #endif
23332
23333 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23334 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23335 }
23336
23337 static int __kprobes
23338 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23339 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23340 struct pt_regs *regs, long error_code)
23341 {
23342 #ifdef CONFIG_X86_32
23343 - if (regs->flags & X86_VM_MASK) {
23344 + if (v8086_mode(regs)) {
23345 /*
23346 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23347 * On nmi (interrupt 2), do_trap should not be called.
23348 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23349 return -1;
23350 }
23351 #endif
23352 - if (!user_mode(regs)) {
23353 + if (!user_mode_novm(regs)) {
23354 if (!fixup_exception(regs)) {
23355 tsk->thread.error_code = error_code;
23356 tsk->thread.trap_nr = trapnr;
23357 +
23358 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23359 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23360 + str = "PAX: suspicious stack segment fault";
23361 +#endif
23362 +
23363 die(str, regs, error_code);
23364 }
23365 +
23366 +#ifdef CONFIG_PAX_REFCOUNT
23367 + if (trapnr == 4)
23368 + pax_report_refcount_overflow(regs);
23369 +#endif
23370 +
23371 return 0;
23372 }
23373
23374 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23375 }
23376
23377 static void __kprobes
23378 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23379 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23380 long error_code, siginfo_t *info)
23381 {
23382 struct task_struct *tsk = current;
23383 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23384 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23385 printk_ratelimit()) {
23386 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23387 - tsk->comm, tsk->pid, str,
23388 + tsk->comm, task_pid_nr(tsk), str,
23389 regs->ip, regs->sp, error_code);
23390 print_vma_addr(" in ", regs->ip);
23391 pr_cont("\n");
23392 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23393 conditional_sti(regs);
23394
23395 #ifdef CONFIG_X86_32
23396 - if (regs->flags & X86_VM_MASK) {
23397 + if (v8086_mode(regs)) {
23398 local_irq_enable();
23399 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23400 goto exit;
23401 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23402 #endif
23403
23404 tsk = current;
23405 - if (!user_mode(regs)) {
23406 + if (!user_mode_novm(regs)) {
23407 if (fixup_exception(regs))
23408 goto exit;
23409
23410 tsk->thread.error_code = error_code;
23411 tsk->thread.trap_nr = X86_TRAP_GP;
23412 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23413 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23414 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23415 +
23416 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23417 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23418 + die("PAX: suspicious general protection fault", regs, error_code);
23419 + else
23420 +#endif
23421 +
23422 die("general protection fault", regs, error_code);
23423 + }
23424 goto exit;
23425 }
23426
23427 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23428 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23429 + struct mm_struct *mm = tsk->mm;
23430 + unsigned long limit;
23431 +
23432 + down_write(&mm->mmap_sem);
23433 + limit = mm->context.user_cs_limit;
23434 + if (limit < TASK_SIZE) {
23435 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23436 + up_write(&mm->mmap_sem);
23437 + return;
23438 + }
23439 + up_write(&mm->mmap_sem);
23440 + }
23441 +#endif
23442 +
23443 tsk->thread.error_code = error_code;
23444 tsk->thread.trap_nr = X86_TRAP_GP;
23445
23446 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23447 /* It's safe to allow irq's after DR6 has been saved */
23448 preempt_conditional_sti(regs);
23449
23450 - if (regs->flags & X86_VM_MASK) {
23451 + if (v8086_mode(regs)) {
23452 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23453 X86_TRAP_DB);
23454 preempt_conditional_cli(regs);
23455 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23456 * We already checked v86 mode above, so we can check for kernel mode
23457 * by just checking the CPL of CS.
23458 */
23459 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23460 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23461 tsk->thread.debugreg6 &= ~DR_STEP;
23462 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23463 regs->flags &= ~X86_EFLAGS_TF;
23464 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23465 return;
23466 conditional_sti(regs);
23467
23468 - if (!user_mode_vm(regs))
23469 + if (!user_mode(regs))
23470 {
23471 if (!fixup_exception(regs)) {
23472 task->thread.error_code = error_code;
23473 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23474 index 2ed8459..7cf329f 100644
23475 --- a/arch/x86/kernel/uprobes.c
23476 +++ b/arch/x86/kernel/uprobes.c
23477 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23478 int ret = NOTIFY_DONE;
23479
23480 /* We are only interested in userspace traps */
23481 - if (regs && !user_mode_vm(regs))
23482 + if (regs && !user_mode(regs))
23483 return NOTIFY_DONE;
23484
23485 switch (val) {
23486 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
23487
23488 if (ncopied != rasize) {
23489 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
23490 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
23491 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
23492
23493 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
23494 }
23495 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23496 index b9242ba..50c5edd 100644
23497 --- a/arch/x86/kernel/verify_cpu.S
23498 +++ b/arch/x86/kernel/verify_cpu.S
23499 @@ -20,6 +20,7 @@
23500 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23501 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23502 * arch/x86/kernel/head_32.S: processor startup
23503 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23504 *
23505 * verify_cpu, returns the status of longmode and SSE in register %eax.
23506 * 0: Success 1: Failure
23507 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23508 index e8edcf5..27f9344 100644
23509 --- a/arch/x86/kernel/vm86_32.c
23510 +++ b/arch/x86/kernel/vm86_32.c
23511 @@ -44,6 +44,7 @@
23512 #include <linux/ptrace.h>
23513 #include <linux/audit.h>
23514 #include <linux/stddef.h>
23515 +#include <linux/grsecurity.h>
23516
23517 #include <asm/uaccess.h>
23518 #include <asm/io.h>
23519 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23520 do_exit(SIGSEGV);
23521 }
23522
23523 - tss = &per_cpu(init_tss, get_cpu());
23524 + tss = init_tss + get_cpu();
23525 current->thread.sp0 = current->thread.saved_sp0;
23526 current->thread.sysenter_cs = __KERNEL_CS;
23527 load_sp0(tss, &current->thread);
23528 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23529
23530 if (tsk->thread.saved_sp0)
23531 return -EPERM;
23532 +
23533 +#ifdef CONFIG_GRKERNSEC_VM86
23534 + if (!capable(CAP_SYS_RAWIO)) {
23535 + gr_handle_vm86();
23536 + return -EPERM;
23537 + }
23538 +#endif
23539 +
23540 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23541 offsetof(struct kernel_vm86_struct, vm86plus) -
23542 sizeof(info.regs));
23543 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23544 int tmp;
23545 struct vm86plus_struct __user *v86;
23546
23547 +#ifdef CONFIG_GRKERNSEC_VM86
23548 + if (!capable(CAP_SYS_RAWIO)) {
23549 + gr_handle_vm86();
23550 + return -EPERM;
23551 + }
23552 +#endif
23553 +
23554 tsk = current;
23555 switch (cmd) {
23556 case VM86_REQUEST_IRQ:
23557 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23558 tsk->thread.saved_fs = info->regs32->fs;
23559 tsk->thread.saved_gs = get_user_gs(info->regs32);
23560
23561 - tss = &per_cpu(init_tss, get_cpu());
23562 + tss = init_tss + get_cpu();
23563 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23564 if (cpu_has_sep)
23565 tsk->thread.sysenter_cs = 0;
23566 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23567 goto cannot_handle;
23568 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23569 goto cannot_handle;
23570 - intr_ptr = (unsigned long __user *) (i << 2);
23571 + intr_ptr = (__force unsigned long __user *) (i << 2);
23572 if (get_user(segoffs, intr_ptr))
23573 goto cannot_handle;
23574 if ((segoffs >> 16) == BIOSSEG)
23575 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23576 index 10c4f30..57377c2 100644
23577 --- a/arch/x86/kernel/vmlinux.lds.S
23578 +++ b/arch/x86/kernel/vmlinux.lds.S
23579 @@ -26,6 +26,13 @@
23580 #include <asm/page_types.h>
23581 #include <asm/cache.h>
23582 #include <asm/boot.h>
23583 +#include <asm/segment.h>
23584 +
23585 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23586 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23587 +#else
23588 +#define __KERNEL_TEXT_OFFSET 0
23589 +#endif
23590
23591 #undef i386 /* in case the preprocessor is a 32bit one */
23592
23593 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23594
23595 PHDRS {
23596 text PT_LOAD FLAGS(5); /* R_E */
23597 +#ifdef CONFIG_X86_32
23598 + module PT_LOAD FLAGS(5); /* R_E */
23599 +#endif
23600 +#ifdef CONFIG_XEN
23601 + rodata PT_LOAD FLAGS(5); /* R_E */
23602 +#else
23603 + rodata PT_LOAD FLAGS(4); /* R__ */
23604 +#endif
23605 data PT_LOAD FLAGS(6); /* RW_ */
23606 -#ifdef CONFIG_X86_64
23607 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23608 #ifdef CONFIG_SMP
23609 percpu PT_LOAD FLAGS(6); /* RW_ */
23610 #endif
23611 + text.init PT_LOAD FLAGS(5); /* R_E */
23612 + text.exit PT_LOAD FLAGS(5); /* R_E */
23613 init PT_LOAD FLAGS(7); /* RWE */
23614 -#endif
23615 note PT_NOTE FLAGS(0); /* ___ */
23616 }
23617
23618 SECTIONS
23619 {
23620 #ifdef CONFIG_X86_32
23621 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23622 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23623 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23624 #else
23625 - . = __START_KERNEL;
23626 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23627 + . = __START_KERNEL;
23628 #endif
23629
23630 /* Text and read-only data */
23631 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23632 - _text = .;
23633 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23634 /* bootstrapping code */
23635 +#ifdef CONFIG_X86_32
23636 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23637 +#else
23638 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23639 +#endif
23640 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23641 + _text = .;
23642 HEAD_TEXT
23643 . = ALIGN(8);
23644 _stext = .;
23645 @@ -104,13 +124,48 @@ SECTIONS
23646 IRQENTRY_TEXT
23647 *(.fixup)
23648 *(.gnu.warning)
23649 - /* End of text section */
23650 - _etext = .;
23651 } :text = 0x9090
23652
23653 - NOTES :text :note
23654 + . += __KERNEL_TEXT_OFFSET;
23655
23656 - EXCEPTION_TABLE(16) :text = 0x9090
23657 +#ifdef CONFIG_X86_32
23658 + . = ALIGN(PAGE_SIZE);
23659 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23660 +
23661 +#ifdef CONFIG_PAX_KERNEXEC
23662 + MODULES_EXEC_VADDR = .;
23663 + BYTE(0)
23664 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23665 + . = ALIGN(HPAGE_SIZE) - 1;
23666 + MODULES_EXEC_END = .;
23667 +#endif
23668 +
23669 + } :module
23670 +#endif
23671 +
23672 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23673 + /* End of text section */
23674 + BYTE(0)
23675 + _etext = . - __KERNEL_TEXT_OFFSET;
23676 + }
23677 +
23678 +#ifdef CONFIG_X86_32
23679 + . = ALIGN(PAGE_SIZE);
23680 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23681 + *(.idt)
23682 + . = ALIGN(PAGE_SIZE);
23683 + *(.empty_zero_page)
23684 + *(.initial_pg_fixmap)
23685 + *(.initial_pg_pmd)
23686 + *(.initial_page_table)
23687 + *(.swapper_pg_dir)
23688 + } :rodata
23689 +#endif
23690 +
23691 + . = ALIGN(PAGE_SIZE);
23692 + NOTES :rodata :note
23693 +
23694 + EXCEPTION_TABLE(16) :rodata
23695
23696 #if defined(CONFIG_DEBUG_RODATA)
23697 /* .text should occupy whole number of pages */
23698 @@ -122,16 +177,20 @@ SECTIONS
23699
23700 /* Data */
23701 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23702 +
23703 +#ifdef CONFIG_PAX_KERNEXEC
23704 + . = ALIGN(HPAGE_SIZE);
23705 +#else
23706 + . = ALIGN(PAGE_SIZE);
23707 +#endif
23708 +
23709 /* Start of data section */
23710 _sdata = .;
23711
23712 /* init_task */
23713 INIT_TASK_DATA(THREAD_SIZE)
23714
23715 -#ifdef CONFIG_X86_32
23716 - /* 32 bit has nosave before _edata */
23717 NOSAVE_DATA
23718 -#endif
23719
23720 PAGE_ALIGNED_DATA(PAGE_SIZE)
23721
23722 @@ -172,12 +231,19 @@ SECTIONS
23723 #endif /* CONFIG_X86_64 */
23724
23725 /* Init code and data - will be freed after init */
23726 - . = ALIGN(PAGE_SIZE);
23727 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23728 + BYTE(0)
23729 +
23730 +#ifdef CONFIG_PAX_KERNEXEC
23731 + . = ALIGN(HPAGE_SIZE);
23732 +#else
23733 + . = ALIGN(PAGE_SIZE);
23734 +#endif
23735 +
23736 __init_begin = .; /* paired with __init_end */
23737 - }
23738 + } :init.begin
23739
23740 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23741 +#ifdef CONFIG_SMP
23742 /*
23743 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23744 * output PHDR, so the next output section - .init.text - should
23745 @@ -186,12 +252,27 @@ SECTIONS
23746 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23747 #endif
23748
23749 - INIT_TEXT_SECTION(PAGE_SIZE)
23750 -#ifdef CONFIG_X86_64
23751 - :init
23752 -#endif
23753 + . = ALIGN(PAGE_SIZE);
23754 + init_begin = .;
23755 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23756 + VMLINUX_SYMBOL(_sinittext) = .;
23757 + INIT_TEXT
23758 + VMLINUX_SYMBOL(_einittext) = .;
23759 + . = ALIGN(PAGE_SIZE);
23760 + } :text.init
23761
23762 - INIT_DATA_SECTION(16)
23763 + /*
23764 + * .exit.text is discard at runtime, not link time, to deal with
23765 + * references from .altinstructions and .eh_frame
23766 + */
23767 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23768 + EXIT_TEXT
23769 + . = ALIGN(16);
23770 + } :text.exit
23771 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23772 +
23773 + . = ALIGN(PAGE_SIZE);
23774 + INIT_DATA_SECTION(16) :init
23775
23776 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23777 __x86_cpu_dev_start = .;
23778 @@ -253,19 +334,12 @@ SECTIONS
23779 }
23780
23781 . = ALIGN(8);
23782 - /*
23783 - * .exit.text is discard at runtime, not link time, to deal with
23784 - * references from .altinstructions and .eh_frame
23785 - */
23786 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23787 - EXIT_TEXT
23788 - }
23789
23790 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23791 EXIT_DATA
23792 }
23793
23794 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23795 +#ifndef CONFIG_SMP
23796 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23797 #endif
23798
23799 @@ -284,16 +358,10 @@ SECTIONS
23800 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23801 __smp_locks = .;
23802 *(.smp_locks)
23803 - . = ALIGN(PAGE_SIZE);
23804 __smp_locks_end = .;
23805 + . = ALIGN(PAGE_SIZE);
23806 }
23807
23808 -#ifdef CONFIG_X86_64
23809 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23810 - NOSAVE_DATA
23811 - }
23812 -#endif
23813 -
23814 /* BSS */
23815 . = ALIGN(PAGE_SIZE);
23816 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23817 @@ -309,6 +377,7 @@ SECTIONS
23818 __brk_base = .;
23819 . += 64 * 1024; /* 64k alignment slop space */
23820 *(.brk_reservation) /* areas brk users have reserved */
23821 + . = ALIGN(HPAGE_SIZE);
23822 __brk_limit = .;
23823 }
23824
23825 @@ -335,13 +404,12 @@ SECTIONS
23826 * for the boot processor.
23827 */
23828 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23829 -INIT_PER_CPU(gdt_page);
23830 INIT_PER_CPU(irq_stack_union);
23831
23832 /*
23833 * Build-time check on the image size:
23834 */
23835 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23836 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23837 "kernel image bigger than KERNEL_IMAGE_SIZE");
23838
23839 #ifdef CONFIG_SMP
23840 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23841 index 9a907a6..f83f921 100644
23842 --- a/arch/x86/kernel/vsyscall_64.c
23843 +++ b/arch/x86/kernel/vsyscall_64.c
23844 @@ -56,15 +56,13 @@
23845 DEFINE_VVAR(int, vgetcpu_mode);
23846 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23847
23848 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23849 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23850
23851 static int __init vsyscall_setup(char *str)
23852 {
23853 if (str) {
23854 if (!strcmp("emulate", str))
23855 vsyscall_mode = EMULATE;
23856 - else if (!strcmp("native", str))
23857 - vsyscall_mode = NATIVE;
23858 else if (!strcmp("none", str))
23859 vsyscall_mode = NONE;
23860 else
23861 @@ -323,8 +321,7 @@ do_ret:
23862 return true;
23863
23864 sigsegv:
23865 - force_sig(SIGSEGV, current);
23866 - return true;
23867 + do_group_exit(SIGKILL);
23868 }
23869
23870 /*
23871 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23872 extern char __vvar_page;
23873 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23874
23875 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23876 - vsyscall_mode == NATIVE
23877 - ? PAGE_KERNEL_VSYSCALL
23878 - : PAGE_KERNEL_VVAR);
23879 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23880 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23881 (unsigned long)VSYSCALL_START);
23882
23883 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23884 index b014d94..6d6ca7b 100644
23885 --- a/arch/x86/kernel/x8664_ksyms_64.c
23886 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23887 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23888 EXPORT_SYMBOL(copy_user_generic_unrolled);
23889 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23890 EXPORT_SYMBOL(__copy_user_nocache);
23891 -EXPORT_SYMBOL(_copy_from_user);
23892 -EXPORT_SYMBOL(_copy_to_user);
23893
23894 EXPORT_SYMBOL(copy_page);
23895 EXPORT_SYMBOL(clear_page);
23896 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23897 index 45a14db..075bb9b 100644
23898 --- a/arch/x86/kernel/x86_init.c
23899 +++ b/arch/x86/kernel/x86_init.c
23900 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23901 },
23902 };
23903
23904 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23905 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23906 .early_percpu_clock_init = x86_init_noop,
23907 .setup_percpu_clockev = setup_secondary_APIC_clock,
23908 };
23909 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23910 static void default_nmi_init(void) { };
23911 static int default_i8042_detect(void) { return 1; };
23912
23913 -struct x86_platform_ops x86_platform = {
23914 +struct x86_platform_ops x86_platform __read_only = {
23915 .calibrate_tsc = native_calibrate_tsc,
23916 .get_wallclock = mach_get_cmos_time,
23917 .set_wallclock = mach_set_rtc_mmss,
23918 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23919 };
23920
23921 EXPORT_SYMBOL_GPL(x86_platform);
23922 -struct x86_msi_ops x86_msi = {
23923 +struct x86_msi_ops x86_msi __read_only = {
23924 .setup_msi_irqs = native_setup_msi_irqs,
23925 .compose_msi_msg = native_compose_msi_msg,
23926 .teardown_msi_irq = native_teardown_msi_irq,
23927 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23928 .setup_hpet_msi = default_setup_hpet_msi,
23929 };
23930
23931 -struct x86_io_apic_ops x86_io_apic_ops = {
23932 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23933 .init = native_io_apic_init_mappings,
23934 .read = native_io_apic_read,
23935 .write = native_io_apic_write,
23936 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23937 index ada87a3..afea76d 100644
23938 --- a/arch/x86/kernel/xsave.c
23939 +++ b/arch/x86/kernel/xsave.c
23940 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23941 {
23942 int err;
23943
23944 + buf = (struct xsave_struct __user *)____m(buf);
23945 if (use_xsave())
23946 err = xsave_user(buf);
23947 else if (use_fxsr())
23948 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23949 */
23950 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23951 {
23952 + buf = (void __user *)____m(buf);
23953 if (use_xsave()) {
23954 if ((unsigned long)buf % 64 || fx_only) {
23955 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23956 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23957 index a20ecb5..d0e2194 100644
23958 --- a/arch/x86/kvm/cpuid.c
23959 +++ b/arch/x86/kvm/cpuid.c
23960 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23961 struct kvm_cpuid2 *cpuid,
23962 struct kvm_cpuid_entry2 __user *entries)
23963 {
23964 - int r;
23965 + int r, i;
23966
23967 r = -E2BIG;
23968 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23969 goto out;
23970 r = -EFAULT;
23971 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23972 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23973 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23974 goto out;
23975 + for (i = 0; i < cpuid->nent; ++i) {
23976 + struct kvm_cpuid_entry2 cpuid_entry;
23977 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23978 + goto out;
23979 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23980 + }
23981 vcpu->arch.cpuid_nent = cpuid->nent;
23982 kvm_apic_set_version(vcpu);
23983 kvm_x86_ops->cpuid_update(vcpu);
23984 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23985 struct kvm_cpuid2 *cpuid,
23986 struct kvm_cpuid_entry2 __user *entries)
23987 {
23988 - int r;
23989 + int r, i;
23990
23991 r = -E2BIG;
23992 if (cpuid->nent < vcpu->arch.cpuid_nent)
23993 goto out;
23994 r = -EFAULT;
23995 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23996 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23997 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23998 goto out;
23999 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24000 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24001 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24002 + goto out;
24003 + }
24004 return 0;
24005
24006 out:
24007 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24008 index 5953dce..f11a7d2 100644
24009 --- a/arch/x86/kvm/emulate.c
24010 +++ b/arch/x86/kvm/emulate.c
24011 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24012
24013 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24014 do { \
24015 + unsigned long _tmp; \
24016 __asm__ __volatile__ ( \
24017 _PRE_EFLAGS("0", "4", "2") \
24018 _op _suffix " %"_x"3,%1; " \
24019 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24020 /* Raw emulation: instruction has two explicit operands. */
24021 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24022 do { \
24023 - unsigned long _tmp; \
24024 - \
24025 switch ((ctxt)->dst.bytes) { \
24026 case 2: \
24027 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24028 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24029
24030 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24031 do { \
24032 - unsigned long _tmp; \
24033 switch ((ctxt)->dst.bytes) { \
24034 case 1: \
24035 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24036 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24037 index 0eee2c8..94a32c3 100644
24038 --- a/arch/x86/kvm/lapic.c
24039 +++ b/arch/x86/kvm/lapic.c
24040 @@ -55,7 +55,7 @@
24041 #define APIC_BUS_CYCLE_NS 1
24042
24043 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24044 -#define apic_debug(fmt, arg...)
24045 +#define apic_debug(fmt, arg...) do {} while (0)
24046
24047 #define APIC_LVT_NUM 6
24048 /* 14 is the version for Xeon and Pentium 8.4.8*/
24049 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24050 index da20860..d19fdf5 100644
24051 --- a/arch/x86/kvm/paging_tmpl.h
24052 +++ b/arch/x86/kvm/paging_tmpl.h
24053 @@ -208,7 +208,7 @@ retry_walk:
24054 if (unlikely(kvm_is_error_hva(host_addr)))
24055 goto error;
24056
24057 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24058 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24059 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24060 goto error;
24061 walker->ptep_user[walker->level - 1] = ptep_user;
24062 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24063 index a14a6ea..dc86cf0 100644
24064 --- a/arch/x86/kvm/svm.c
24065 +++ b/arch/x86/kvm/svm.c
24066 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24067 int cpu = raw_smp_processor_id();
24068
24069 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24070 +
24071 + pax_open_kernel();
24072 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24073 + pax_close_kernel();
24074 +
24075 load_TR_desc();
24076 }
24077
24078 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24079 #endif
24080 #endif
24081
24082 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24083 + __set_fs(current_thread_info()->addr_limit);
24084 +#endif
24085 +
24086 reload_tss(vcpu);
24087
24088 local_irq_disable();
24089 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24090 index 260a919..65ddd76 100644
24091 --- a/arch/x86/kvm/vmx.c
24092 +++ b/arch/x86/kvm/vmx.c
24093 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24094 #endif
24095 }
24096
24097 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24098 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24099 {
24100 vmcs_writel(field, vmcs_readl(field) & ~mask);
24101 }
24102
24103 -static void vmcs_set_bits(unsigned long field, u32 mask)
24104 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24105 {
24106 vmcs_writel(field, vmcs_readl(field) | mask);
24107 }
24108 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
24109 struct desc_struct *descs;
24110
24111 descs = (void *)gdt->address;
24112 +
24113 + pax_open_kernel();
24114 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24115 + pax_close_kernel();
24116 +
24117 load_TR_desc();
24118 }
24119
24120 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24121 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24122 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24123
24124 +#ifdef CONFIG_PAX_PER_CPU_PGD
24125 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24126 +#endif
24127 +
24128 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24129 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24130 vmx->loaded_vmcs->cpu = cpu;
24131 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
24132 if (!cpu_has_vmx_flexpriority())
24133 flexpriority_enabled = 0;
24134
24135 - if (!cpu_has_vmx_tpr_shadow())
24136 - kvm_x86_ops->update_cr8_intercept = NULL;
24137 + if (!cpu_has_vmx_tpr_shadow()) {
24138 + pax_open_kernel();
24139 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24140 + pax_close_kernel();
24141 + }
24142
24143 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24144 kvm_disable_largepages();
24145 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
24146 if (!cpu_has_vmx_apicv())
24147 enable_apicv = 0;
24148
24149 + pax_open_kernel();
24150 if (enable_apicv)
24151 - kvm_x86_ops->update_cr8_intercept = NULL;
24152 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24153 else {
24154 - kvm_x86_ops->hwapic_irr_update = NULL;
24155 - kvm_x86_ops->deliver_posted_interrupt = NULL;
24156 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24157 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24158 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
24159 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24160 }
24161 + pax_close_kernel();
24162
24163 if (nested)
24164 nested_vmx_setup_ctls_msrs();
24165 @@ -4069,7 +4082,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24166
24167 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24168 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24169 +
24170 +#ifndef CONFIG_PAX_PER_CPU_PGD
24171 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24172 +#endif
24173
24174 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24175 #ifdef CONFIG_X86_64
24176 @@ -4091,7 +4107,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24177 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24178 vmx->host_idt_base = dt.address;
24179
24180 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24181 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24182
24183 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24184 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24185 @@ -7023,6 +7039,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24186 "jmp 2f \n\t"
24187 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24188 "2: "
24189 +
24190 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24191 + "ljmp %[cs],$3f\n\t"
24192 + "3: "
24193 +#endif
24194 +
24195 /* Save guest registers, load host registers, keep flags */
24196 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24197 "pop %0 \n\t"
24198 @@ -7075,6 +7097,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24199 #endif
24200 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24201 [wordsize]"i"(sizeof(ulong))
24202 +
24203 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24204 + ,[cs]"i"(__KERNEL_CS)
24205 +#endif
24206 +
24207 : "cc", "memory"
24208 #ifdef CONFIG_X86_64
24209 , "rax", "rbx", "rdi", "rsi"
24210 @@ -7088,7 +7115,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24211 if (debugctlmsr)
24212 update_debugctlmsr(debugctlmsr);
24213
24214 -#ifndef CONFIG_X86_64
24215 +#ifdef CONFIG_X86_32
24216 /*
24217 * The sysexit path does not restore ds/es, so we must set them to
24218 * a reasonable value ourselves.
24219 @@ -7097,8 +7124,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24220 * may be executed in interrupt context, which saves and restore segments
24221 * around it, nullifying its effect.
24222 */
24223 - loadsegment(ds, __USER_DS);
24224 - loadsegment(es, __USER_DS);
24225 + loadsegment(ds, __KERNEL_DS);
24226 + loadsegment(es, __KERNEL_DS);
24227 + loadsegment(ss, __KERNEL_DS);
24228 +
24229 +#ifdef CONFIG_PAX_KERNEXEC
24230 + loadsegment(fs, __KERNEL_PERCPU);
24231 +#endif
24232 +
24233 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24234 + __set_fs(current_thread_info()->addr_limit);
24235 +#endif
24236 +
24237 #endif
24238
24239 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24240 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24241 index e8ba99c..ee9d7d9 100644
24242 --- a/arch/x86/kvm/x86.c
24243 +++ b/arch/x86/kvm/x86.c
24244 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24245 {
24246 struct kvm *kvm = vcpu->kvm;
24247 int lm = is_long_mode(vcpu);
24248 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24249 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24250 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24251 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24252 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24253 : kvm->arch.xen_hvm_config.blob_size_32;
24254 u32 page_num = data & ~PAGE_MASK;
24255 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24256 if (n < msr_list.nmsrs)
24257 goto out;
24258 r = -EFAULT;
24259 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24260 + goto out;
24261 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24262 num_msrs_to_save * sizeof(u32)))
24263 goto out;
24264 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24265 };
24266 #endif
24267
24268 -int kvm_arch_init(void *opaque)
24269 +int kvm_arch_init(const void *opaque)
24270 {
24271 int r;
24272 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24273 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24274 index 7114c63..a1018fc 100644
24275 --- a/arch/x86/lguest/boot.c
24276 +++ b/arch/x86/lguest/boot.c
24277 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24278 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24279 * Launcher to reboot us.
24280 */
24281 -static void lguest_restart(char *reason)
24282 +static __noreturn void lguest_restart(char *reason)
24283 {
24284 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24285 + BUG();
24286 }
24287
24288 /*G:050
24289 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24290 index 00933d5..3a64af9 100644
24291 --- a/arch/x86/lib/atomic64_386_32.S
24292 +++ b/arch/x86/lib/atomic64_386_32.S
24293 @@ -48,6 +48,10 @@ BEGIN(read)
24294 movl (v), %eax
24295 movl 4(v), %edx
24296 RET_ENDP
24297 +BEGIN(read_unchecked)
24298 + movl (v), %eax
24299 + movl 4(v), %edx
24300 +RET_ENDP
24301 #undef v
24302
24303 #define v %esi
24304 @@ -55,6 +59,10 @@ BEGIN(set)
24305 movl %ebx, (v)
24306 movl %ecx, 4(v)
24307 RET_ENDP
24308 +BEGIN(set_unchecked)
24309 + movl %ebx, (v)
24310 + movl %ecx, 4(v)
24311 +RET_ENDP
24312 #undef v
24313
24314 #define v %esi
24315 @@ -70,6 +78,20 @@ RET_ENDP
24316 BEGIN(add)
24317 addl %eax, (v)
24318 adcl %edx, 4(v)
24319 +
24320 +#ifdef CONFIG_PAX_REFCOUNT
24321 + jno 0f
24322 + subl %eax, (v)
24323 + sbbl %edx, 4(v)
24324 + int $4
24325 +0:
24326 + _ASM_EXTABLE(0b, 0b)
24327 +#endif
24328 +
24329 +RET_ENDP
24330 +BEGIN(add_unchecked)
24331 + addl %eax, (v)
24332 + adcl %edx, 4(v)
24333 RET_ENDP
24334 #undef v
24335
24336 @@ -77,6 +99,24 @@ RET_ENDP
24337 BEGIN(add_return)
24338 addl (v), %eax
24339 adcl 4(v), %edx
24340 +
24341 +#ifdef CONFIG_PAX_REFCOUNT
24342 + into
24343 +1234:
24344 + _ASM_EXTABLE(1234b, 2f)
24345 +#endif
24346 +
24347 + movl %eax, (v)
24348 + movl %edx, 4(v)
24349 +
24350 +#ifdef CONFIG_PAX_REFCOUNT
24351 +2:
24352 +#endif
24353 +
24354 +RET_ENDP
24355 +BEGIN(add_return_unchecked)
24356 + addl (v), %eax
24357 + adcl 4(v), %edx
24358 movl %eax, (v)
24359 movl %edx, 4(v)
24360 RET_ENDP
24361 @@ -86,6 +126,20 @@ RET_ENDP
24362 BEGIN(sub)
24363 subl %eax, (v)
24364 sbbl %edx, 4(v)
24365 +
24366 +#ifdef CONFIG_PAX_REFCOUNT
24367 + jno 0f
24368 + addl %eax, (v)
24369 + adcl %edx, 4(v)
24370 + int $4
24371 +0:
24372 + _ASM_EXTABLE(0b, 0b)
24373 +#endif
24374 +
24375 +RET_ENDP
24376 +BEGIN(sub_unchecked)
24377 + subl %eax, (v)
24378 + sbbl %edx, 4(v)
24379 RET_ENDP
24380 #undef v
24381
24382 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24383 sbbl $0, %edx
24384 addl (v), %eax
24385 adcl 4(v), %edx
24386 +
24387 +#ifdef CONFIG_PAX_REFCOUNT
24388 + into
24389 +1234:
24390 + _ASM_EXTABLE(1234b, 2f)
24391 +#endif
24392 +
24393 + movl %eax, (v)
24394 + movl %edx, 4(v)
24395 +
24396 +#ifdef CONFIG_PAX_REFCOUNT
24397 +2:
24398 +#endif
24399 +
24400 +RET_ENDP
24401 +BEGIN(sub_return_unchecked)
24402 + negl %edx
24403 + negl %eax
24404 + sbbl $0, %edx
24405 + addl (v), %eax
24406 + adcl 4(v), %edx
24407 movl %eax, (v)
24408 movl %edx, 4(v)
24409 RET_ENDP
24410 @@ -105,6 +180,20 @@ RET_ENDP
24411 BEGIN(inc)
24412 addl $1, (v)
24413 adcl $0, 4(v)
24414 +
24415 +#ifdef CONFIG_PAX_REFCOUNT
24416 + jno 0f
24417 + subl $1, (v)
24418 + sbbl $0, 4(v)
24419 + int $4
24420 +0:
24421 + _ASM_EXTABLE(0b, 0b)
24422 +#endif
24423 +
24424 +RET_ENDP
24425 +BEGIN(inc_unchecked)
24426 + addl $1, (v)
24427 + adcl $0, 4(v)
24428 RET_ENDP
24429 #undef v
24430
24431 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24432 movl 4(v), %edx
24433 addl $1, %eax
24434 adcl $0, %edx
24435 +
24436 +#ifdef CONFIG_PAX_REFCOUNT
24437 + into
24438 +1234:
24439 + _ASM_EXTABLE(1234b, 2f)
24440 +#endif
24441 +
24442 + movl %eax, (v)
24443 + movl %edx, 4(v)
24444 +
24445 +#ifdef CONFIG_PAX_REFCOUNT
24446 +2:
24447 +#endif
24448 +
24449 +RET_ENDP
24450 +BEGIN(inc_return_unchecked)
24451 + movl (v), %eax
24452 + movl 4(v), %edx
24453 + addl $1, %eax
24454 + adcl $0, %edx
24455 movl %eax, (v)
24456 movl %edx, 4(v)
24457 RET_ENDP
24458 @@ -123,6 +232,20 @@ RET_ENDP
24459 BEGIN(dec)
24460 subl $1, (v)
24461 sbbl $0, 4(v)
24462 +
24463 +#ifdef CONFIG_PAX_REFCOUNT
24464 + jno 0f
24465 + addl $1, (v)
24466 + adcl $0, 4(v)
24467 + int $4
24468 +0:
24469 + _ASM_EXTABLE(0b, 0b)
24470 +#endif
24471 +
24472 +RET_ENDP
24473 +BEGIN(dec_unchecked)
24474 + subl $1, (v)
24475 + sbbl $0, 4(v)
24476 RET_ENDP
24477 #undef v
24478
24479 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24480 movl 4(v), %edx
24481 subl $1, %eax
24482 sbbl $0, %edx
24483 +
24484 +#ifdef CONFIG_PAX_REFCOUNT
24485 + into
24486 +1234:
24487 + _ASM_EXTABLE(1234b, 2f)
24488 +#endif
24489 +
24490 + movl %eax, (v)
24491 + movl %edx, 4(v)
24492 +
24493 +#ifdef CONFIG_PAX_REFCOUNT
24494 +2:
24495 +#endif
24496 +
24497 +RET_ENDP
24498 +BEGIN(dec_return_unchecked)
24499 + movl (v), %eax
24500 + movl 4(v), %edx
24501 + subl $1, %eax
24502 + sbbl $0, %edx
24503 movl %eax, (v)
24504 movl %edx, 4(v)
24505 RET_ENDP
24506 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24507 adcl %edx, %edi
24508 addl (v), %eax
24509 adcl 4(v), %edx
24510 +
24511 +#ifdef CONFIG_PAX_REFCOUNT
24512 + into
24513 +1234:
24514 + _ASM_EXTABLE(1234b, 2f)
24515 +#endif
24516 +
24517 cmpl %eax, %ecx
24518 je 3f
24519 1:
24520 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24521 1:
24522 addl $1, %eax
24523 adcl $0, %edx
24524 +
24525 +#ifdef CONFIG_PAX_REFCOUNT
24526 + into
24527 +1234:
24528 + _ASM_EXTABLE(1234b, 2f)
24529 +#endif
24530 +
24531 movl %eax, (v)
24532 movl %edx, 4(v)
24533 movl $1, %eax
24534 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24535 movl 4(v), %edx
24536 subl $1, %eax
24537 sbbl $0, %edx
24538 +
24539 +#ifdef CONFIG_PAX_REFCOUNT
24540 + into
24541 +1234:
24542 + _ASM_EXTABLE(1234b, 1f)
24543 +#endif
24544 +
24545 js 1f
24546 movl %eax, (v)
24547 movl %edx, 4(v)
24548 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24549 index f5cc9eb..51fa319 100644
24550 --- a/arch/x86/lib/atomic64_cx8_32.S
24551 +++ b/arch/x86/lib/atomic64_cx8_32.S
24552 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24553 CFI_STARTPROC
24554
24555 read64 %ecx
24556 + pax_force_retaddr
24557 ret
24558 CFI_ENDPROC
24559 ENDPROC(atomic64_read_cx8)
24560
24561 +ENTRY(atomic64_read_unchecked_cx8)
24562 + CFI_STARTPROC
24563 +
24564 + read64 %ecx
24565 + pax_force_retaddr
24566 + ret
24567 + CFI_ENDPROC
24568 +ENDPROC(atomic64_read_unchecked_cx8)
24569 +
24570 ENTRY(atomic64_set_cx8)
24571 CFI_STARTPROC
24572
24573 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24574 cmpxchg8b (%esi)
24575 jne 1b
24576
24577 + pax_force_retaddr
24578 ret
24579 CFI_ENDPROC
24580 ENDPROC(atomic64_set_cx8)
24581
24582 +ENTRY(atomic64_set_unchecked_cx8)
24583 + CFI_STARTPROC
24584 +
24585 +1:
24586 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24587 + * are atomic on 586 and newer */
24588 + cmpxchg8b (%esi)
24589 + jne 1b
24590 +
24591 + pax_force_retaddr
24592 + ret
24593 + CFI_ENDPROC
24594 +ENDPROC(atomic64_set_unchecked_cx8)
24595 +
24596 ENTRY(atomic64_xchg_cx8)
24597 CFI_STARTPROC
24598
24599 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24600 cmpxchg8b (%esi)
24601 jne 1b
24602
24603 + pax_force_retaddr
24604 ret
24605 CFI_ENDPROC
24606 ENDPROC(atomic64_xchg_cx8)
24607
24608 -.macro addsub_return func ins insc
24609 -ENTRY(atomic64_\func\()_return_cx8)
24610 +.macro addsub_return func ins insc unchecked=""
24611 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24612 CFI_STARTPROC
24613 SAVE ebp
24614 SAVE ebx
24615 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24616 movl %edx, %ecx
24617 \ins\()l %esi, %ebx
24618 \insc\()l %edi, %ecx
24619 +
24620 +.ifb \unchecked
24621 +#ifdef CONFIG_PAX_REFCOUNT
24622 + into
24623 +2:
24624 + _ASM_EXTABLE(2b, 3f)
24625 +#endif
24626 +.endif
24627 +
24628 LOCK_PREFIX
24629 cmpxchg8b (%ebp)
24630 jne 1b
24631 -
24632 -10:
24633 movl %ebx, %eax
24634 movl %ecx, %edx
24635 +
24636 +.ifb \unchecked
24637 +#ifdef CONFIG_PAX_REFCOUNT
24638 +3:
24639 +#endif
24640 +.endif
24641 +
24642 RESTORE edi
24643 RESTORE esi
24644 RESTORE ebx
24645 RESTORE ebp
24646 + pax_force_retaddr
24647 ret
24648 CFI_ENDPROC
24649 -ENDPROC(atomic64_\func\()_return_cx8)
24650 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24651 .endm
24652
24653 addsub_return add add adc
24654 addsub_return sub sub sbb
24655 +addsub_return add add adc _unchecked
24656 +addsub_return sub sub sbb _unchecked
24657
24658 -.macro incdec_return func ins insc
24659 -ENTRY(atomic64_\func\()_return_cx8)
24660 +.macro incdec_return func ins insc unchecked=""
24661 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24662 CFI_STARTPROC
24663 SAVE ebx
24664
24665 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24666 movl %edx, %ecx
24667 \ins\()l $1, %ebx
24668 \insc\()l $0, %ecx
24669 +
24670 +.ifb \unchecked
24671 +#ifdef CONFIG_PAX_REFCOUNT
24672 + into
24673 +2:
24674 + _ASM_EXTABLE(2b, 3f)
24675 +#endif
24676 +.endif
24677 +
24678 LOCK_PREFIX
24679 cmpxchg8b (%esi)
24680 jne 1b
24681
24682 -10:
24683 movl %ebx, %eax
24684 movl %ecx, %edx
24685 +
24686 +.ifb \unchecked
24687 +#ifdef CONFIG_PAX_REFCOUNT
24688 +3:
24689 +#endif
24690 +.endif
24691 +
24692 RESTORE ebx
24693 + pax_force_retaddr
24694 ret
24695 CFI_ENDPROC
24696 -ENDPROC(atomic64_\func\()_return_cx8)
24697 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24698 .endm
24699
24700 incdec_return inc add adc
24701 incdec_return dec sub sbb
24702 +incdec_return inc add adc _unchecked
24703 +incdec_return dec sub sbb _unchecked
24704
24705 ENTRY(atomic64_dec_if_positive_cx8)
24706 CFI_STARTPROC
24707 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24708 movl %edx, %ecx
24709 subl $1, %ebx
24710 sbb $0, %ecx
24711 +
24712 +#ifdef CONFIG_PAX_REFCOUNT
24713 + into
24714 +1234:
24715 + _ASM_EXTABLE(1234b, 2f)
24716 +#endif
24717 +
24718 js 2f
24719 LOCK_PREFIX
24720 cmpxchg8b (%esi)
24721 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24722 movl %ebx, %eax
24723 movl %ecx, %edx
24724 RESTORE ebx
24725 + pax_force_retaddr
24726 ret
24727 CFI_ENDPROC
24728 ENDPROC(atomic64_dec_if_positive_cx8)
24729 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24730 movl %edx, %ecx
24731 addl %ebp, %ebx
24732 adcl %edi, %ecx
24733 +
24734 +#ifdef CONFIG_PAX_REFCOUNT
24735 + into
24736 +1234:
24737 + _ASM_EXTABLE(1234b, 3f)
24738 +#endif
24739 +
24740 LOCK_PREFIX
24741 cmpxchg8b (%esi)
24742 jne 1b
24743 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24744 CFI_ADJUST_CFA_OFFSET -8
24745 RESTORE ebx
24746 RESTORE ebp
24747 + pax_force_retaddr
24748 ret
24749 4:
24750 cmpl %edx, 4(%esp)
24751 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24752 xorl %ecx, %ecx
24753 addl $1, %ebx
24754 adcl %edx, %ecx
24755 +
24756 +#ifdef CONFIG_PAX_REFCOUNT
24757 + into
24758 +1234:
24759 + _ASM_EXTABLE(1234b, 3f)
24760 +#endif
24761 +
24762 LOCK_PREFIX
24763 cmpxchg8b (%esi)
24764 jne 1b
24765 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24766 movl $1, %eax
24767 3:
24768 RESTORE ebx
24769 + pax_force_retaddr
24770 ret
24771 CFI_ENDPROC
24772 ENDPROC(atomic64_inc_not_zero_cx8)
24773 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24774 index e78b8ee..7e173a8 100644
24775 --- a/arch/x86/lib/checksum_32.S
24776 +++ b/arch/x86/lib/checksum_32.S
24777 @@ -29,7 +29,8 @@
24778 #include <asm/dwarf2.h>
24779 #include <asm/errno.h>
24780 #include <asm/asm.h>
24781 -
24782 +#include <asm/segment.h>
24783 +
24784 /*
24785 * computes a partial checksum, e.g. for TCP/UDP fragments
24786 */
24787 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24788
24789 #define ARGBASE 16
24790 #define FP 12
24791 -
24792 -ENTRY(csum_partial_copy_generic)
24793 +
24794 +ENTRY(csum_partial_copy_generic_to_user)
24795 CFI_STARTPROC
24796 +
24797 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24798 + pushl_cfi %gs
24799 + popl_cfi %es
24800 + jmp csum_partial_copy_generic
24801 +#endif
24802 +
24803 +ENTRY(csum_partial_copy_generic_from_user)
24804 +
24805 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24806 + pushl_cfi %gs
24807 + popl_cfi %ds
24808 +#endif
24809 +
24810 +ENTRY(csum_partial_copy_generic)
24811 subl $4,%esp
24812 CFI_ADJUST_CFA_OFFSET 4
24813 pushl_cfi %edi
24814 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24815 jmp 4f
24816 SRC(1: movw (%esi), %bx )
24817 addl $2, %esi
24818 -DST( movw %bx, (%edi) )
24819 +DST( movw %bx, %es:(%edi) )
24820 addl $2, %edi
24821 addw %bx, %ax
24822 adcl $0, %eax
24823 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24824 SRC(1: movl (%esi), %ebx )
24825 SRC( movl 4(%esi), %edx )
24826 adcl %ebx, %eax
24827 -DST( movl %ebx, (%edi) )
24828 +DST( movl %ebx, %es:(%edi) )
24829 adcl %edx, %eax
24830 -DST( movl %edx, 4(%edi) )
24831 +DST( movl %edx, %es:4(%edi) )
24832
24833 SRC( movl 8(%esi), %ebx )
24834 SRC( movl 12(%esi), %edx )
24835 adcl %ebx, %eax
24836 -DST( movl %ebx, 8(%edi) )
24837 +DST( movl %ebx, %es:8(%edi) )
24838 adcl %edx, %eax
24839 -DST( movl %edx, 12(%edi) )
24840 +DST( movl %edx, %es:12(%edi) )
24841
24842 SRC( movl 16(%esi), %ebx )
24843 SRC( movl 20(%esi), %edx )
24844 adcl %ebx, %eax
24845 -DST( movl %ebx, 16(%edi) )
24846 +DST( movl %ebx, %es:16(%edi) )
24847 adcl %edx, %eax
24848 -DST( movl %edx, 20(%edi) )
24849 +DST( movl %edx, %es:20(%edi) )
24850
24851 SRC( movl 24(%esi), %ebx )
24852 SRC( movl 28(%esi), %edx )
24853 adcl %ebx, %eax
24854 -DST( movl %ebx, 24(%edi) )
24855 +DST( movl %ebx, %es:24(%edi) )
24856 adcl %edx, %eax
24857 -DST( movl %edx, 28(%edi) )
24858 +DST( movl %edx, %es:28(%edi) )
24859
24860 lea 32(%esi), %esi
24861 lea 32(%edi), %edi
24862 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24863 shrl $2, %edx # This clears CF
24864 SRC(3: movl (%esi), %ebx )
24865 adcl %ebx, %eax
24866 -DST( movl %ebx, (%edi) )
24867 +DST( movl %ebx, %es:(%edi) )
24868 lea 4(%esi), %esi
24869 lea 4(%edi), %edi
24870 dec %edx
24871 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24872 jb 5f
24873 SRC( movw (%esi), %cx )
24874 leal 2(%esi), %esi
24875 -DST( movw %cx, (%edi) )
24876 +DST( movw %cx, %es:(%edi) )
24877 leal 2(%edi), %edi
24878 je 6f
24879 shll $16,%ecx
24880 SRC(5: movb (%esi), %cl )
24881 -DST( movb %cl, (%edi) )
24882 +DST( movb %cl, %es:(%edi) )
24883 6: addl %ecx, %eax
24884 adcl $0, %eax
24885 7:
24886 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24887
24888 6001:
24889 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24890 - movl $-EFAULT, (%ebx)
24891 + movl $-EFAULT, %ss:(%ebx)
24892
24893 # zero the complete destination - computing the rest
24894 # is too much work
24895 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24896
24897 6002:
24898 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24899 - movl $-EFAULT,(%ebx)
24900 + movl $-EFAULT,%ss:(%ebx)
24901 jmp 5000b
24902
24903 .previous
24904
24905 + pushl_cfi %ss
24906 + popl_cfi %ds
24907 + pushl_cfi %ss
24908 + popl_cfi %es
24909 popl_cfi %ebx
24910 CFI_RESTORE ebx
24911 popl_cfi %esi
24912 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24913 popl_cfi %ecx # equivalent to addl $4,%esp
24914 ret
24915 CFI_ENDPROC
24916 -ENDPROC(csum_partial_copy_generic)
24917 +ENDPROC(csum_partial_copy_generic_to_user)
24918
24919 #else
24920
24921 /* Version for PentiumII/PPro */
24922
24923 #define ROUND1(x) \
24924 + nop; nop; nop; \
24925 SRC(movl x(%esi), %ebx ) ; \
24926 addl %ebx, %eax ; \
24927 - DST(movl %ebx, x(%edi) ) ;
24928 + DST(movl %ebx, %es:x(%edi)) ;
24929
24930 #define ROUND(x) \
24931 + nop; nop; nop; \
24932 SRC(movl x(%esi), %ebx ) ; \
24933 adcl %ebx, %eax ; \
24934 - DST(movl %ebx, x(%edi) ) ;
24935 + DST(movl %ebx, %es:x(%edi)) ;
24936
24937 #define ARGBASE 12
24938 -
24939 -ENTRY(csum_partial_copy_generic)
24940 +
24941 +ENTRY(csum_partial_copy_generic_to_user)
24942 CFI_STARTPROC
24943 +
24944 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24945 + pushl_cfi %gs
24946 + popl_cfi %es
24947 + jmp csum_partial_copy_generic
24948 +#endif
24949 +
24950 +ENTRY(csum_partial_copy_generic_from_user)
24951 +
24952 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24953 + pushl_cfi %gs
24954 + popl_cfi %ds
24955 +#endif
24956 +
24957 +ENTRY(csum_partial_copy_generic)
24958 pushl_cfi %ebx
24959 CFI_REL_OFFSET ebx, 0
24960 pushl_cfi %edi
24961 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24962 subl %ebx, %edi
24963 lea -1(%esi),%edx
24964 andl $-32,%edx
24965 - lea 3f(%ebx,%ebx), %ebx
24966 + lea 3f(%ebx,%ebx,2), %ebx
24967 testl %esi, %esi
24968 jmp *%ebx
24969 1: addl $64,%esi
24970 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24971 jb 5f
24972 SRC( movw (%esi), %dx )
24973 leal 2(%esi), %esi
24974 -DST( movw %dx, (%edi) )
24975 +DST( movw %dx, %es:(%edi) )
24976 leal 2(%edi), %edi
24977 je 6f
24978 shll $16,%edx
24979 5:
24980 SRC( movb (%esi), %dl )
24981 -DST( movb %dl, (%edi) )
24982 +DST( movb %dl, %es:(%edi) )
24983 6: addl %edx, %eax
24984 adcl $0, %eax
24985 7:
24986 .section .fixup, "ax"
24987 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24988 - movl $-EFAULT, (%ebx)
24989 + movl $-EFAULT, %ss:(%ebx)
24990 # zero the complete destination (computing the rest is too much work)
24991 movl ARGBASE+8(%esp),%edi # dst
24992 movl ARGBASE+12(%esp),%ecx # len
24993 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24994 rep; stosb
24995 jmp 7b
24996 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24997 - movl $-EFAULT, (%ebx)
24998 + movl $-EFAULT, %ss:(%ebx)
24999 jmp 7b
25000 .previous
25001
25002 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25003 + pushl_cfi %ss
25004 + popl_cfi %ds
25005 + pushl_cfi %ss
25006 + popl_cfi %es
25007 +#endif
25008 +
25009 popl_cfi %esi
25010 CFI_RESTORE esi
25011 popl_cfi %edi
25012 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25013 CFI_RESTORE ebx
25014 ret
25015 CFI_ENDPROC
25016 -ENDPROC(csum_partial_copy_generic)
25017 +ENDPROC(csum_partial_copy_generic_to_user)
25018
25019 #undef ROUND
25020 #undef ROUND1
25021 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25022 index f2145cf..cea889d 100644
25023 --- a/arch/x86/lib/clear_page_64.S
25024 +++ b/arch/x86/lib/clear_page_64.S
25025 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25026 movl $4096/8,%ecx
25027 xorl %eax,%eax
25028 rep stosq
25029 + pax_force_retaddr
25030 ret
25031 CFI_ENDPROC
25032 ENDPROC(clear_page_c)
25033 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25034 movl $4096,%ecx
25035 xorl %eax,%eax
25036 rep stosb
25037 + pax_force_retaddr
25038 ret
25039 CFI_ENDPROC
25040 ENDPROC(clear_page_c_e)
25041 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25042 leaq 64(%rdi),%rdi
25043 jnz .Lloop
25044 nop
25045 + pax_force_retaddr
25046 ret
25047 CFI_ENDPROC
25048 .Lclear_page_end:
25049 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25050
25051 #include <asm/cpufeature.h>
25052
25053 - .section .altinstr_replacement,"ax"
25054 + .section .altinstr_replacement,"a"
25055 1: .byte 0xeb /* jmp <disp8> */
25056 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25057 2: .byte 0xeb /* jmp <disp8> */
25058 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25059 index 1e572c5..2a162cd 100644
25060 --- a/arch/x86/lib/cmpxchg16b_emu.S
25061 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25062 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25063
25064 popf
25065 mov $1, %al
25066 + pax_force_retaddr
25067 ret
25068
25069 not_same:
25070 popf
25071 xor %al,%al
25072 + pax_force_retaddr
25073 ret
25074
25075 CFI_ENDPROC
25076 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25077 index 176cca6..1166c50 100644
25078 --- a/arch/x86/lib/copy_page_64.S
25079 +++ b/arch/x86/lib/copy_page_64.S
25080 @@ -9,6 +9,7 @@ copy_page_rep:
25081 CFI_STARTPROC
25082 movl $4096/8, %ecx
25083 rep movsq
25084 + pax_force_retaddr
25085 ret
25086 CFI_ENDPROC
25087 ENDPROC(copy_page_rep)
25088 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25089
25090 ENTRY(copy_page)
25091 CFI_STARTPROC
25092 - subq $2*8, %rsp
25093 - CFI_ADJUST_CFA_OFFSET 2*8
25094 + subq $3*8, %rsp
25095 + CFI_ADJUST_CFA_OFFSET 3*8
25096 movq %rbx, (%rsp)
25097 CFI_REL_OFFSET rbx, 0
25098 movq %r12, 1*8(%rsp)
25099 CFI_REL_OFFSET r12, 1*8
25100 + movq %r13, 2*8(%rsp)
25101 + CFI_REL_OFFSET r13, 2*8
25102
25103 movl $(4096/64)-5, %ecx
25104 .p2align 4
25105 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25106 movq 0x8*2(%rsi), %rdx
25107 movq 0x8*3(%rsi), %r8
25108 movq 0x8*4(%rsi), %r9
25109 - movq 0x8*5(%rsi), %r10
25110 + movq 0x8*5(%rsi), %r13
25111 movq 0x8*6(%rsi), %r11
25112 movq 0x8*7(%rsi), %r12
25113
25114 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25115 movq %rdx, 0x8*2(%rdi)
25116 movq %r8, 0x8*3(%rdi)
25117 movq %r9, 0x8*4(%rdi)
25118 - movq %r10, 0x8*5(%rdi)
25119 + movq %r13, 0x8*5(%rdi)
25120 movq %r11, 0x8*6(%rdi)
25121 movq %r12, 0x8*7(%rdi)
25122
25123 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25124 movq 0x8*2(%rsi), %rdx
25125 movq 0x8*3(%rsi), %r8
25126 movq 0x8*4(%rsi), %r9
25127 - movq 0x8*5(%rsi), %r10
25128 + movq 0x8*5(%rsi), %r13
25129 movq 0x8*6(%rsi), %r11
25130 movq 0x8*7(%rsi), %r12
25131
25132 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25133 movq %rdx, 0x8*2(%rdi)
25134 movq %r8, 0x8*3(%rdi)
25135 movq %r9, 0x8*4(%rdi)
25136 - movq %r10, 0x8*5(%rdi)
25137 + movq %r13, 0x8*5(%rdi)
25138 movq %r11, 0x8*6(%rdi)
25139 movq %r12, 0x8*7(%rdi)
25140
25141 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25142 CFI_RESTORE rbx
25143 movq 1*8(%rsp), %r12
25144 CFI_RESTORE r12
25145 - addq $2*8, %rsp
25146 - CFI_ADJUST_CFA_OFFSET -2*8
25147 + movq 2*8(%rsp), %r13
25148 + CFI_RESTORE r13
25149 + addq $3*8, %rsp
25150 + CFI_ADJUST_CFA_OFFSET -3*8
25151 + pax_force_retaddr
25152 ret
25153 .Lcopy_page_end:
25154 CFI_ENDPROC
25155 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25156
25157 #include <asm/cpufeature.h>
25158
25159 - .section .altinstr_replacement,"ax"
25160 + .section .altinstr_replacement,"a"
25161 1: .byte 0xeb /* jmp <disp8> */
25162 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25163 2:
25164 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25165 index a30ca15..d25fab6 100644
25166 --- a/arch/x86/lib/copy_user_64.S
25167 +++ b/arch/x86/lib/copy_user_64.S
25168 @@ -18,6 +18,7 @@
25169 #include <asm/alternative-asm.h>
25170 #include <asm/asm.h>
25171 #include <asm/smap.h>
25172 +#include <asm/pgtable.h>
25173
25174 /*
25175 * By placing feature2 after feature1 in altinstructions section, we logically
25176 @@ -31,7 +32,7 @@
25177 .byte 0xe9 /* 32bit jump */
25178 .long \orig-1f /* by default jump to orig */
25179 1:
25180 - .section .altinstr_replacement,"ax"
25181 + .section .altinstr_replacement,"a"
25182 2: .byte 0xe9 /* near jump with 32bit immediate */
25183 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25184 3: .byte 0xe9 /* near jump with 32bit immediate */
25185 @@ -70,47 +71,20 @@
25186 #endif
25187 .endm
25188
25189 -/* Standard copy_to_user with segment limit checking */
25190 -ENTRY(_copy_to_user)
25191 - CFI_STARTPROC
25192 - GET_THREAD_INFO(%rax)
25193 - movq %rdi,%rcx
25194 - addq %rdx,%rcx
25195 - jc bad_to_user
25196 - cmpq TI_addr_limit(%rax),%rcx
25197 - ja bad_to_user
25198 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25199 - copy_user_generic_unrolled,copy_user_generic_string, \
25200 - copy_user_enhanced_fast_string
25201 - CFI_ENDPROC
25202 -ENDPROC(_copy_to_user)
25203 -
25204 -/* Standard copy_from_user with segment limit checking */
25205 -ENTRY(_copy_from_user)
25206 - CFI_STARTPROC
25207 - GET_THREAD_INFO(%rax)
25208 - movq %rsi,%rcx
25209 - addq %rdx,%rcx
25210 - jc bad_from_user
25211 - cmpq TI_addr_limit(%rax),%rcx
25212 - ja bad_from_user
25213 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25214 - copy_user_generic_unrolled,copy_user_generic_string, \
25215 - copy_user_enhanced_fast_string
25216 - CFI_ENDPROC
25217 -ENDPROC(_copy_from_user)
25218 -
25219 .section .fixup,"ax"
25220 /* must zero dest */
25221 ENTRY(bad_from_user)
25222 bad_from_user:
25223 CFI_STARTPROC
25224 + testl %edx,%edx
25225 + js bad_to_user
25226 movl %edx,%ecx
25227 xorl %eax,%eax
25228 rep
25229 stosb
25230 bad_to_user:
25231 movl %edx,%eax
25232 + pax_force_retaddr
25233 ret
25234 CFI_ENDPROC
25235 ENDPROC(bad_from_user)
25236 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25237 jz 17f
25238 1: movq (%rsi),%r8
25239 2: movq 1*8(%rsi),%r9
25240 -3: movq 2*8(%rsi),%r10
25241 +3: movq 2*8(%rsi),%rax
25242 4: movq 3*8(%rsi),%r11
25243 5: movq %r8,(%rdi)
25244 6: movq %r9,1*8(%rdi)
25245 -7: movq %r10,2*8(%rdi)
25246 +7: movq %rax,2*8(%rdi)
25247 8: movq %r11,3*8(%rdi)
25248 9: movq 4*8(%rsi),%r8
25249 10: movq 5*8(%rsi),%r9
25250 -11: movq 6*8(%rsi),%r10
25251 +11: movq 6*8(%rsi),%rax
25252 12: movq 7*8(%rsi),%r11
25253 13: movq %r8,4*8(%rdi)
25254 14: movq %r9,5*8(%rdi)
25255 -15: movq %r10,6*8(%rdi)
25256 +15: movq %rax,6*8(%rdi)
25257 16: movq %r11,7*8(%rdi)
25258 leaq 64(%rsi),%rsi
25259 leaq 64(%rdi),%rdi
25260 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25261 jnz 21b
25262 23: xor %eax,%eax
25263 ASM_CLAC
25264 + pax_force_retaddr
25265 ret
25266
25267 .section .fixup,"ax"
25268 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25269 movsb
25270 4: xorl %eax,%eax
25271 ASM_CLAC
25272 + pax_force_retaddr
25273 ret
25274
25275 .section .fixup,"ax"
25276 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25277 movsb
25278 2: xorl %eax,%eax
25279 ASM_CLAC
25280 + pax_force_retaddr
25281 ret
25282
25283 .section .fixup,"ax"
25284 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25285 index 6a4f43c..f08b4a2 100644
25286 --- a/arch/x86/lib/copy_user_nocache_64.S
25287 +++ b/arch/x86/lib/copy_user_nocache_64.S
25288 @@ -8,6 +8,7 @@
25289
25290 #include <linux/linkage.h>
25291 #include <asm/dwarf2.h>
25292 +#include <asm/alternative-asm.h>
25293
25294 #define FIX_ALIGNMENT 1
25295
25296 @@ -16,6 +17,7 @@
25297 #include <asm/thread_info.h>
25298 #include <asm/asm.h>
25299 #include <asm/smap.h>
25300 +#include <asm/pgtable.h>
25301
25302 .macro ALIGN_DESTINATION
25303 #ifdef FIX_ALIGNMENT
25304 @@ -49,6 +51,15 @@
25305 */
25306 ENTRY(__copy_user_nocache)
25307 CFI_STARTPROC
25308 +
25309 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25310 + mov pax_user_shadow_base,%rcx
25311 + cmp %rcx,%rsi
25312 + jae 1f
25313 + add %rcx,%rsi
25314 +1:
25315 +#endif
25316 +
25317 ASM_STAC
25318 cmpl $8,%edx
25319 jb 20f /* less then 8 bytes, go to byte copy loop */
25320 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25321 jz 17f
25322 1: movq (%rsi),%r8
25323 2: movq 1*8(%rsi),%r9
25324 -3: movq 2*8(%rsi),%r10
25325 +3: movq 2*8(%rsi),%rax
25326 4: movq 3*8(%rsi),%r11
25327 5: movnti %r8,(%rdi)
25328 6: movnti %r9,1*8(%rdi)
25329 -7: movnti %r10,2*8(%rdi)
25330 +7: movnti %rax,2*8(%rdi)
25331 8: movnti %r11,3*8(%rdi)
25332 9: movq 4*8(%rsi),%r8
25333 10: movq 5*8(%rsi),%r9
25334 -11: movq 6*8(%rsi),%r10
25335 +11: movq 6*8(%rsi),%rax
25336 12: movq 7*8(%rsi),%r11
25337 13: movnti %r8,4*8(%rdi)
25338 14: movnti %r9,5*8(%rdi)
25339 -15: movnti %r10,6*8(%rdi)
25340 +15: movnti %rax,6*8(%rdi)
25341 16: movnti %r11,7*8(%rdi)
25342 leaq 64(%rsi),%rsi
25343 leaq 64(%rdi),%rdi
25344 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25345 23: xorl %eax,%eax
25346 ASM_CLAC
25347 sfence
25348 + pax_force_retaddr
25349 ret
25350
25351 .section .fixup,"ax"
25352 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25353 index 2419d5f..953ee51 100644
25354 --- a/arch/x86/lib/csum-copy_64.S
25355 +++ b/arch/x86/lib/csum-copy_64.S
25356 @@ -9,6 +9,7 @@
25357 #include <asm/dwarf2.h>
25358 #include <asm/errno.h>
25359 #include <asm/asm.h>
25360 +#include <asm/alternative-asm.h>
25361
25362 /*
25363 * Checksum copy with exception handling.
25364 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25365 CFI_RESTORE rbp
25366 addq $7*8, %rsp
25367 CFI_ADJUST_CFA_OFFSET -7*8
25368 + pax_force_retaddr 0, 1
25369 ret
25370 CFI_RESTORE_STATE
25371
25372 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25373 index 25b7ae8..169fafc 100644
25374 --- a/arch/x86/lib/csum-wrappers_64.c
25375 +++ b/arch/x86/lib/csum-wrappers_64.c
25376 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25377 len -= 2;
25378 }
25379 }
25380 - isum = csum_partial_copy_generic((__force const void *)src,
25381 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25382 dst, len, isum, errp, NULL);
25383 if (unlikely(*errp))
25384 goto out_err;
25385 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25386 }
25387
25388 *errp = 0;
25389 - return csum_partial_copy_generic(src, (void __force *)dst,
25390 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25391 len, isum, NULL, errp);
25392 }
25393 EXPORT_SYMBOL(csum_partial_copy_to_user);
25394 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25395 index a451235..79fb5cf 100644
25396 --- a/arch/x86/lib/getuser.S
25397 +++ b/arch/x86/lib/getuser.S
25398 @@ -33,17 +33,40 @@
25399 #include <asm/thread_info.h>
25400 #include <asm/asm.h>
25401 #include <asm/smap.h>
25402 +#include <asm/segment.h>
25403 +#include <asm/pgtable.h>
25404 +#include <asm/alternative-asm.h>
25405 +
25406 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25407 +#define __copyuser_seg gs;
25408 +#else
25409 +#define __copyuser_seg
25410 +#endif
25411
25412 .text
25413 ENTRY(__get_user_1)
25414 CFI_STARTPROC
25415 +
25416 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25417 GET_THREAD_INFO(%_ASM_DX)
25418 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25419 jae bad_get_user
25420 ASM_STAC
25421 -1: movzbl (%_ASM_AX),%edx
25422 +
25423 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25424 + mov pax_user_shadow_base,%_ASM_DX
25425 + cmp %_ASM_DX,%_ASM_AX
25426 + jae 1234f
25427 + add %_ASM_DX,%_ASM_AX
25428 +1234:
25429 +#endif
25430 +
25431 +#endif
25432 +
25433 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25434 xor %eax,%eax
25435 ASM_CLAC
25436 + pax_force_retaddr
25437 ret
25438 CFI_ENDPROC
25439 ENDPROC(__get_user_1)
25440 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25441 ENTRY(__get_user_2)
25442 CFI_STARTPROC
25443 add $1,%_ASM_AX
25444 +
25445 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25446 jc bad_get_user
25447 GET_THREAD_INFO(%_ASM_DX)
25448 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25449 jae bad_get_user
25450 ASM_STAC
25451 -2: movzwl -1(%_ASM_AX),%edx
25452 +
25453 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25454 + mov pax_user_shadow_base,%_ASM_DX
25455 + cmp %_ASM_DX,%_ASM_AX
25456 + jae 1234f
25457 + add %_ASM_DX,%_ASM_AX
25458 +1234:
25459 +#endif
25460 +
25461 +#endif
25462 +
25463 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25464 xor %eax,%eax
25465 ASM_CLAC
25466 + pax_force_retaddr
25467 ret
25468 CFI_ENDPROC
25469 ENDPROC(__get_user_2)
25470 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25471 ENTRY(__get_user_4)
25472 CFI_STARTPROC
25473 add $3,%_ASM_AX
25474 +
25475 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25476 jc bad_get_user
25477 GET_THREAD_INFO(%_ASM_DX)
25478 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25479 jae bad_get_user
25480 ASM_STAC
25481 -3: movl -3(%_ASM_AX),%edx
25482 +
25483 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25484 + mov pax_user_shadow_base,%_ASM_DX
25485 + cmp %_ASM_DX,%_ASM_AX
25486 + jae 1234f
25487 + add %_ASM_DX,%_ASM_AX
25488 +1234:
25489 +#endif
25490 +
25491 +#endif
25492 +
25493 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25494 xor %eax,%eax
25495 ASM_CLAC
25496 + pax_force_retaddr
25497 ret
25498 CFI_ENDPROC
25499 ENDPROC(__get_user_4)
25500 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25501 GET_THREAD_INFO(%_ASM_DX)
25502 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25503 jae bad_get_user
25504 +
25505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25506 + mov pax_user_shadow_base,%_ASM_DX
25507 + cmp %_ASM_DX,%_ASM_AX
25508 + jae 1234f
25509 + add %_ASM_DX,%_ASM_AX
25510 +1234:
25511 +#endif
25512 +
25513 ASM_STAC
25514 4: movq -7(%_ASM_AX),%rdx
25515 xor %eax,%eax
25516 ASM_CLAC
25517 + pax_force_retaddr
25518 ret
25519 #else
25520 add $7,%_ASM_AX
25521 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25522 5: movl -3(%_ASM_AX),%ecx
25523 xor %eax,%eax
25524 ASM_CLAC
25525 + pax_force_retaddr
25526 ret
25527 #endif
25528 CFI_ENDPROC
25529 @@ -113,6 +175,7 @@ bad_get_user:
25530 xor %edx,%edx
25531 mov $(-EFAULT),%_ASM_AX
25532 ASM_CLAC
25533 + pax_force_retaddr
25534 ret
25535 CFI_ENDPROC
25536 END(bad_get_user)
25537 @@ -124,6 +187,7 @@ bad_get_user_8:
25538 xor %ecx,%ecx
25539 mov $(-EFAULT),%_ASM_AX
25540 ASM_CLAC
25541 + pax_force_retaddr
25542 ret
25543 CFI_ENDPROC
25544 END(bad_get_user_8)
25545 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25546 index 54fcffe..7be149e 100644
25547 --- a/arch/x86/lib/insn.c
25548 +++ b/arch/x86/lib/insn.c
25549 @@ -20,8 +20,10 @@
25550
25551 #ifdef __KERNEL__
25552 #include <linux/string.h>
25553 +#include <asm/pgtable_types.h>
25554 #else
25555 #include <string.h>
25556 +#define ktla_ktva(addr) addr
25557 #endif
25558 #include <asm/inat.h>
25559 #include <asm/insn.h>
25560 @@ -53,8 +55,8 @@
25561 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25562 {
25563 memset(insn, 0, sizeof(*insn));
25564 - insn->kaddr = kaddr;
25565 - insn->next_byte = kaddr;
25566 + insn->kaddr = ktla_ktva(kaddr);
25567 + insn->next_byte = ktla_ktva(kaddr);
25568 insn->x86_64 = x86_64 ? 1 : 0;
25569 insn->opnd_bytes = 4;
25570 if (x86_64)
25571 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25572 index 05a95e7..326f2fa 100644
25573 --- a/arch/x86/lib/iomap_copy_64.S
25574 +++ b/arch/x86/lib/iomap_copy_64.S
25575 @@ -17,6 +17,7 @@
25576
25577 #include <linux/linkage.h>
25578 #include <asm/dwarf2.h>
25579 +#include <asm/alternative-asm.h>
25580
25581 /*
25582 * override generic version in lib/iomap_copy.c
25583 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25584 CFI_STARTPROC
25585 movl %edx,%ecx
25586 rep movsd
25587 + pax_force_retaddr
25588 ret
25589 CFI_ENDPROC
25590 ENDPROC(__iowrite32_copy)
25591 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25592 index 56313a3..aa84a79 100644
25593 --- a/arch/x86/lib/memcpy_64.S
25594 +++ b/arch/x86/lib/memcpy_64.S
25595 @@ -33,6 +33,7 @@
25596 rep movsq
25597 movl %edx, %ecx
25598 rep movsb
25599 + pax_force_retaddr
25600 ret
25601 .Lmemcpy_e:
25602 .previous
25603 @@ -49,6 +50,7 @@
25604 movq %rdi, %rax
25605 movq %rdx, %rcx
25606 rep movsb
25607 + pax_force_retaddr
25608 ret
25609 .Lmemcpy_e_e:
25610 .previous
25611 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25612 */
25613 movq 0*8(%rsi), %r8
25614 movq 1*8(%rsi), %r9
25615 - movq 2*8(%rsi), %r10
25616 + movq 2*8(%rsi), %rcx
25617 movq 3*8(%rsi), %r11
25618 leaq 4*8(%rsi), %rsi
25619
25620 movq %r8, 0*8(%rdi)
25621 movq %r9, 1*8(%rdi)
25622 - movq %r10, 2*8(%rdi)
25623 + movq %rcx, 2*8(%rdi)
25624 movq %r11, 3*8(%rdi)
25625 leaq 4*8(%rdi), %rdi
25626 jae .Lcopy_forward_loop
25627 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25628 subq $0x20, %rdx
25629 movq -1*8(%rsi), %r8
25630 movq -2*8(%rsi), %r9
25631 - movq -3*8(%rsi), %r10
25632 + movq -3*8(%rsi), %rcx
25633 movq -4*8(%rsi), %r11
25634 leaq -4*8(%rsi), %rsi
25635 movq %r8, -1*8(%rdi)
25636 movq %r9, -2*8(%rdi)
25637 - movq %r10, -3*8(%rdi)
25638 + movq %rcx, -3*8(%rdi)
25639 movq %r11, -4*8(%rdi)
25640 leaq -4*8(%rdi), %rdi
25641 jae .Lcopy_backward_loop
25642 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25643 */
25644 movq 0*8(%rsi), %r8
25645 movq 1*8(%rsi), %r9
25646 - movq -2*8(%rsi, %rdx), %r10
25647 + movq -2*8(%rsi, %rdx), %rcx
25648 movq -1*8(%rsi, %rdx), %r11
25649 movq %r8, 0*8(%rdi)
25650 movq %r9, 1*8(%rdi)
25651 - movq %r10, -2*8(%rdi, %rdx)
25652 + movq %rcx, -2*8(%rdi, %rdx)
25653 movq %r11, -1*8(%rdi, %rdx)
25654 + pax_force_retaddr
25655 retq
25656 .p2align 4
25657 .Lless_16bytes:
25658 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25659 movq -1*8(%rsi, %rdx), %r9
25660 movq %r8, 0*8(%rdi)
25661 movq %r9, -1*8(%rdi, %rdx)
25662 + pax_force_retaddr
25663 retq
25664 .p2align 4
25665 .Lless_8bytes:
25666 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25667 movl -4(%rsi, %rdx), %r8d
25668 movl %ecx, (%rdi)
25669 movl %r8d, -4(%rdi, %rdx)
25670 + pax_force_retaddr
25671 retq
25672 .p2align 4
25673 .Lless_3bytes:
25674 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25675 movb %cl, (%rdi)
25676
25677 .Lend:
25678 + pax_force_retaddr
25679 retq
25680 CFI_ENDPROC
25681 ENDPROC(memcpy)
25682 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25683 index 65268a6..c9518d1 100644
25684 --- a/arch/x86/lib/memmove_64.S
25685 +++ b/arch/x86/lib/memmove_64.S
25686 @@ -61,13 +61,13 @@ ENTRY(memmove)
25687 5:
25688 sub $0x20, %rdx
25689 movq 0*8(%rsi), %r11
25690 - movq 1*8(%rsi), %r10
25691 + movq 1*8(%rsi), %rcx
25692 movq 2*8(%rsi), %r9
25693 movq 3*8(%rsi), %r8
25694 leaq 4*8(%rsi), %rsi
25695
25696 movq %r11, 0*8(%rdi)
25697 - movq %r10, 1*8(%rdi)
25698 + movq %rcx, 1*8(%rdi)
25699 movq %r9, 2*8(%rdi)
25700 movq %r8, 3*8(%rdi)
25701 leaq 4*8(%rdi), %rdi
25702 @@ -81,10 +81,10 @@ ENTRY(memmove)
25703 4:
25704 movq %rdx, %rcx
25705 movq -8(%rsi, %rdx), %r11
25706 - lea -8(%rdi, %rdx), %r10
25707 + lea -8(%rdi, %rdx), %r9
25708 shrq $3, %rcx
25709 rep movsq
25710 - movq %r11, (%r10)
25711 + movq %r11, (%r9)
25712 jmp 13f
25713 .Lmemmove_end_forward:
25714
25715 @@ -95,14 +95,14 @@ ENTRY(memmove)
25716 7:
25717 movq %rdx, %rcx
25718 movq (%rsi), %r11
25719 - movq %rdi, %r10
25720 + movq %rdi, %r9
25721 leaq -8(%rsi, %rdx), %rsi
25722 leaq -8(%rdi, %rdx), %rdi
25723 shrq $3, %rcx
25724 std
25725 rep movsq
25726 cld
25727 - movq %r11, (%r10)
25728 + movq %r11, (%r9)
25729 jmp 13f
25730
25731 /*
25732 @@ -127,13 +127,13 @@ ENTRY(memmove)
25733 8:
25734 subq $0x20, %rdx
25735 movq -1*8(%rsi), %r11
25736 - movq -2*8(%rsi), %r10
25737 + movq -2*8(%rsi), %rcx
25738 movq -3*8(%rsi), %r9
25739 movq -4*8(%rsi), %r8
25740 leaq -4*8(%rsi), %rsi
25741
25742 movq %r11, -1*8(%rdi)
25743 - movq %r10, -2*8(%rdi)
25744 + movq %rcx, -2*8(%rdi)
25745 movq %r9, -3*8(%rdi)
25746 movq %r8, -4*8(%rdi)
25747 leaq -4*8(%rdi), %rdi
25748 @@ -151,11 +151,11 @@ ENTRY(memmove)
25749 * Move data from 16 bytes to 31 bytes.
25750 */
25751 movq 0*8(%rsi), %r11
25752 - movq 1*8(%rsi), %r10
25753 + movq 1*8(%rsi), %rcx
25754 movq -2*8(%rsi, %rdx), %r9
25755 movq -1*8(%rsi, %rdx), %r8
25756 movq %r11, 0*8(%rdi)
25757 - movq %r10, 1*8(%rdi)
25758 + movq %rcx, 1*8(%rdi)
25759 movq %r9, -2*8(%rdi, %rdx)
25760 movq %r8, -1*8(%rdi, %rdx)
25761 jmp 13f
25762 @@ -167,9 +167,9 @@ ENTRY(memmove)
25763 * Move data from 8 bytes to 15 bytes.
25764 */
25765 movq 0*8(%rsi), %r11
25766 - movq -1*8(%rsi, %rdx), %r10
25767 + movq -1*8(%rsi, %rdx), %r9
25768 movq %r11, 0*8(%rdi)
25769 - movq %r10, -1*8(%rdi, %rdx)
25770 + movq %r9, -1*8(%rdi, %rdx)
25771 jmp 13f
25772 10:
25773 cmpq $4, %rdx
25774 @@ -178,9 +178,9 @@ ENTRY(memmove)
25775 * Move data from 4 bytes to 7 bytes.
25776 */
25777 movl (%rsi), %r11d
25778 - movl -4(%rsi, %rdx), %r10d
25779 + movl -4(%rsi, %rdx), %r9d
25780 movl %r11d, (%rdi)
25781 - movl %r10d, -4(%rdi, %rdx)
25782 + movl %r9d, -4(%rdi, %rdx)
25783 jmp 13f
25784 11:
25785 cmp $2, %rdx
25786 @@ -189,9 +189,9 @@ ENTRY(memmove)
25787 * Move data from 2 bytes to 3 bytes.
25788 */
25789 movw (%rsi), %r11w
25790 - movw -2(%rsi, %rdx), %r10w
25791 + movw -2(%rsi, %rdx), %r9w
25792 movw %r11w, (%rdi)
25793 - movw %r10w, -2(%rdi, %rdx)
25794 + movw %r9w, -2(%rdi, %rdx)
25795 jmp 13f
25796 12:
25797 cmp $1, %rdx
25798 @@ -202,6 +202,7 @@ ENTRY(memmove)
25799 movb (%rsi), %r11b
25800 movb %r11b, (%rdi)
25801 13:
25802 + pax_force_retaddr
25803 retq
25804 CFI_ENDPROC
25805
25806 @@ -210,6 +211,7 @@ ENTRY(memmove)
25807 /* Forward moving data. */
25808 movq %rdx, %rcx
25809 rep movsb
25810 + pax_force_retaddr
25811 retq
25812 .Lmemmove_end_forward_efs:
25813 .previous
25814 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25815 index 2dcb380..963660a 100644
25816 --- a/arch/x86/lib/memset_64.S
25817 +++ b/arch/x86/lib/memset_64.S
25818 @@ -30,6 +30,7 @@
25819 movl %edx,%ecx
25820 rep stosb
25821 movq %r9,%rax
25822 + pax_force_retaddr
25823 ret
25824 .Lmemset_e:
25825 .previous
25826 @@ -52,6 +53,7 @@
25827 movq %rdx,%rcx
25828 rep stosb
25829 movq %r9,%rax
25830 + pax_force_retaddr
25831 ret
25832 .Lmemset_e_e:
25833 .previous
25834 @@ -59,7 +61,7 @@
25835 ENTRY(memset)
25836 ENTRY(__memset)
25837 CFI_STARTPROC
25838 - movq %rdi,%r10
25839 + movq %rdi,%r11
25840
25841 /* expand byte value */
25842 movzbl %sil,%ecx
25843 @@ -117,7 +119,8 @@ ENTRY(__memset)
25844 jnz .Lloop_1
25845
25846 .Lende:
25847 - movq %r10,%rax
25848 + movq %r11,%rax
25849 + pax_force_retaddr
25850 ret
25851
25852 CFI_RESTORE_STATE
25853 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25854 index c9f2d9b..e7fd2c0 100644
25855 --- a/arch/x86/lib/mmx_32.c
25856 +++ b/arch/x86/lib/mmx_32.c
25857 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25858 {
25859 void *p;
25860 int i;
25861 + unsigned long cr0;
25862
25863 if (unlikely(in_interrupt()))
25864 return __memcpy(to, from, len);
25865 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25866 kernel_fpu_begin();
25867
25868 __asm__ __volatile__ (
25869 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25870 - " prefetch 64(%0)\n"
25871 - " prefetch 128(%0)\n"
25872 - " prefetch 192(%0)\n"
25873 - " prefetch 256(%0)\n"
25874 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25875 + " prefetch 64(%1)\n"
25876 + " prefetch 128(%1)\n"
25877 + " prefetch 192(%1)\n"
25878 + " prefetch 256(%1)\n"
25879 "2: \n"
25880 ".section .fixup, \"ax\"\n"
25881 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25882 + "3: \n"
25883 +
25884 +#ifdef CONFIG_PAX_KERNEXEC
25885 + " movl %%cr0, %0\n"
25886 + " movl %0, %%eax\n"
25887 + " andl $0xFFFEFFFF, %%eax\n"
25888 + " movl %%eax, %%cr0\n"
25889 +#endif
25890 +
25891 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25892 +
25893 +#ifdef CONFIG_PAX_KERNEXEC
25894 + " movl %0, %%cr0\n"
25895 +#endif
25896 +
25897 " jmp 2b\n"
25898 ".previous\n"
25899 _ASM_EXTABLE(1b, 3b)
25900 - : : "r" (from));
25901 + : "=&r" (cr0) : "r" (from) : "ax");
25902
25903 for ( ; i > 5; i--) {
25904 __asm__ __volatile__ (
25905 - "1: prefetch 320(%0)\n"
25906 - "2: movq (%0), %%mm0\n"
25907 - " movq 8(%0), %%mm1\n"
25908 - " movq 16(%0), %%mm2\n"
25909 - " movq 24(%0), %%mm3\n"
25910 - " movq %%mm0, (%1)\n"
25911 - " movq %%mm1, 8(%1)\n"
25912 - " movq %%mm2, 16(%1)\n"
25913 - " movq %%mm3, 24(%1)\n"
25914 - " movq 32(%0), %%mm0\n"
25915 - " movq 40(%0), %%mm1\n"
25916 - " movq 48(%0), %%mm2\n"
25917 - " movq 56(%0), %%mm3\n"
25918 - " movq %%mm0, 32(%1)\n"
25919 - " movq %%mm1, 40(%1)\n"
25920 - " movq %%mm2, 48(%1)\n"
25921 - " movq %%mm3, 56(%1)\n"
25922 + "1: prefetch 320(%1)\n"
25923 + "2: movq (%1), %%mm0\n"
25924 + " movq 8(%1), %%mm1\n"
25925 + " movq 16(%1), %%mm2\n"
25926 + " movq 24(%1), %%mm3\n"
25927 + " movq %%mm0, (%2)\n"
25928 + " movq %%mm1, 8(%2)\n"
25929 + " movq %%mm2, 16(%2)\n"
25930 + " movq %%mm3, 24(%2)\n"
25931 + " movq 32(%1), %%mm0\n"
25932 + " movq 40(%1), %%mm1\n"
25933 + " movq 48(%1), %%mm2\n"
25934 + " movq 56(%1), %%mm3\n"
25935 + " movq %%mm0, 32(%2)\n"
25936 + " movq %%mm1, 40(%2)\n"
25937 + " movq %%mm2, 48(%2)\n"
25938 + " movq %%mm3, 56(%2)\n"
25939 ".section .fixup, \"ax\"\n"
25940 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25941 + "3:\n"
25942 +
25943 +#ifdef CONFIG_PAX_KERNEXEC
25944 + " movl %%cr0, %0\n"
25945 + " movl %0, %%eax\n"
25946 + " andl $0xFFFEFFFF, %%eax\n"
25947 + " movl %%eax, %%cr0\n"
25948 +#endif
25949 +
25950 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25951 +
25952 +#ifdef CONFIG_PAX_KERNEXEC
25953 + " movl %0, %%cr0\n"
25954 +#endif
25955 +
25956 " jmp 2b\n"
25957 ".previous\n"
25958 _ASM_EXTABLE(1b, 3b)
25959 - : : "r" (from), "r" (to) : "memory");
25960 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25961
25962 from += 64;
25963 to += 64;
25964 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25965 static void fast_copy_page(void *to, void *from)
25966 {
25967 int i;
25968 + unsigned long cr0;
25969
25970 kernel_fpu_begin();
25971
25972 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25973 * but that is for later. -AV
25974 */
25975 __asm__ __volatile__(
25976 - "1: prefetch (%0)\n"
25977 - " prefetch 64(%0)\n"
25978 - " prefetch 128(%0)\n"
25979 - " prefetch 192(%0)\n"
25980 - " prefetch 256(%0)\n"
25981 + "1: prefetch (%1)\n"
25982 + " prefetch 64(%1)\n"
25983 + " prefetch 128(%1)\n"
25984 + " prefetch 192(%1)\n"
25985 + " prefetch 256(%1)\n"
25986 "2: \n"
25987 ".section .fixup, \"ax\"\n"
25988 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25989 + "3: \n"
25990 +
25991 +#ifdef CONFIG_PAX_KERNEXEC
25992 + " movl %%cr0, %0\n"
25993 + " movl %0, %%eax\n"
25994 + " andl $0xFFFEFFFF, %%eax\n"
25995 + " movl %%eax, %%cr0\n"
25996 +#endif
25997 +
25998 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25999 +
26000 +#ifdef CONFIG_PAX_KERNEXEC
26001 + " movl %0, %%cr0\n"
26002 +#endif
26003 +
26004 " jmp 2b\n"
26005 ".previous\n"
26006 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26007 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26008
26009 for (i = 0; i < (4096-320)/64; i++) {
26010 __asm__ __volatile__ (
26011 - "1: prefetch 320(%0)\n"
26012 - "2: movq (%0), %%mm0\n"
26013 - " movntq %%mm0, (%1)\n"
26014 - " movq 8(%0), %%mm1\n"
26015 - " movntq %%mm1, 8(%1)\n"
26016 - " movq 16(%0), %%mm2\n"
26017 - " movntq %%mm2, 16(%1)\n"
26018 - " movq 24(%0), %%mm3\n"
26019 - " movntq %%mm3, 24(%1)\n"
26020 - " movq 32(%0), %%mm4\n"
26021 - " movntq %%mm4, 32(%1)\n"
26022 - " movq 40(%0), %%mm5\n"
26023 - " movntq %%mm5, 40(%1)\n"
26024 - " movq 48(%0), %%mm6\n"
26025 - " movntq %%mm6, 48(%1)\n"
26026 - " movq 56(%0), %%mm7\n"
26027 - " movntq %%mm7, 56(%1)\n"
26028 + "1: prefetch 320(%1)\n"
26029 + "2: movq (%1), %%mm0\n"
26030 + " movntq %%mm0, (%2)\n"
26031 + " movq 8(%1), %%mm1\n"
26032 + " movntq %%mm1, 8(%2)\n"
26033 + " movq 16(%1), %%mm2\n"
26034 + " movntq %%mm2, 16(%2)\n"
26035 + " movq 24(%1), %%mm3\n"
26036 + " movntq %%mm3, 24(%2)\n"
26037 + " movq 32(%1), %%mm4\n"
26038 + " movntq %%mm4, 32(%2)\n"
26039 + " movq 40(%1), %%mm5\n"
26040 + " movntq %%mm5, 40(%2)\n"
26041 + " movq 48(%1), %%mm6\n"
26042 + " movntq %%mm6, 48(%2)\n"
26043 + " movq 56(%1), %%mm7\n"
26044 + " movntq %%mm7, 56(%2)\n"
26045 ".section .fixup, \"ax\"\n"
26046 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26047 + "3:\n"
26048 +
26049 +#ifdef CONFIG_PAX_KERNEXEC
26050 + " movl %%cr0, %0\n"
26051 + " movl %0, %%eax\n"
26052 + " andl $0xFFFEFFFF, %%eax\n"
26053 + " movl %%eax, %%cr0\n"
26054 +#endif
26055 +
26056 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26057 +
26058 +#ifdef CONFIG_PAX_KERNEXEC
26059 + " movl %0, %%cr0\n"
26060 +#endif
26061 +
26062 " jmp 2b\n"
26063 ".previous\n"
26064 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26065 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26066
26067 from += 64;
26068 to += 64;
26069 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26070 static void fast_copy_page(void *to, void *from)
26071 {
26072 int i;
26073 + unsigned long cr0;
26074
26075 kernel_fpu_begin();
26076
26077 __asm__ __volatile__ (
26078 - "1: prefetch (%0)\n"
26079 - " prefetch 64(%0)\n"
26080 - " prefetch 128(%0)\n"
26081 - " prefetch 192(%0)\n"
26082 - " prefetch 256(%0)\n"
26083 + "1: prefetch (%1)\n"
26084 + " prefetch 64(%1)\n"
26085 + " prefetch 128(%1)\n"
26086 + " prefetch 192(%1)\n"
26087 + " prefetch 256(%1)\n"
26088 "2: \n"
26089 ".section .fixup, \"ax\"\n"
26090 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26091 + "3: \n"
26092 +
26093 +#ifdef CONFIG_PAX_KERNEXEC
26094 + " movl %%cr0, %0\n"
26095 + " movl %0, %%eax\n"
26096 + " andl $0xFFFEFFFF, %%eax\n"
26097 + " movl %%eax, %%cr0\n"
26098 +#endif
26099 +
26100 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26101 +
26102 +#ifdef CONFIG_PAX_KERNEXEC
26103 + " movl %0, %%cr0\n"
26104 +#endif
26105 +
26106 " jmp 2b\n"
26107 ".previous\n"
26108 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26109 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26110
26111 for (i = 0; i < 4096/64; i++) {
26112 __asm__ __volatile__ (
26113 - "1: prefetch 320(%0)\n"
26114 - "2: movq (%0), %%mm0\n"
26115 - " movq 8(%0), %%mm1\n"
26116 - " movq 16(%0), %%mm2\n"
26117 - " movq 24(%0), %%mm3\n"
26118 - " movq %%mm0, (%1)\n"
26119 - " movq %%mm1, 8(%1)\n"
26120 - " movq %%mm2, 16(%1)\n"
26121 - " movq %%mm3, 24(%1)\n"
26122 - " movq 32(%0), %%mm0\n"
26123 - " movq 40(%0), %%mm1\n"
26124 - " movq 48(%0), %%mm2\n"
26125 - " movq 56(%0), %%mm3\n"
26126 - " movq %%mm0, 32(%1)\n"
26127 - " movq %%mm1, 40(%1)\n"
26128 - " movq %%mm2, 48(%1)\n"
26129 - " movq %%mm3, 56(%1)\n"
26130 + "1: prefetch 320(%1)\n"
26131 + "2: movq (%1), %%mm0\n"
26132 + " movq 8(%1), %%mm1\n"
26133 + " movq 16(%1), %%mm2\n"
26134 + " movq 24(%1), %%mm3\n"
26135 + " movq %%mm0, (%2)\n"
26136 + " movq %%mm1, 8(%2)\n"
26137 + " movq %%mm2, 16(%2)\n"
26138 + " movq %%mm3, 24(%2)\n"
26139 + " movq 32(%1), %%mm0\n"
26140 + " movq 40(%1), %%mm1\n"
26141 + " movq 48(%1), %%mm2\n"
26142 + " movq 56(%1), %%mm3\n"
26143 + " movq %%mm0, 32(%2)\n"
26144 + " movq %%mm1, 40(%2)\n"
26145 + " movq %%mm2, 48(%2)\n"
26146 + " movq %%mm3, 56(%2)\n"
26147 ".section .fixup, \"ax\"\n"
26148 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26149 + "3:\n"
26150 +
26151 +#ifdef CONFIG_PAX_KERNEXEC
26152 + " movl %%cr0, %0\n"
26153 + " movl %0, %%eax\n"
26154 + " andl $0xFFFEFFFF, %%eax\n"
26155 + " movl %%eax, %%cr0\n"
26156 +#endif
26157 +
26158 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26159 +
26160 +#ifdef CONFIG_PAX_KERNEXEC
26161 + " movl %0, %%cr0\n"
26162 +#endif
26163 +
26164 " jmp 2b\n"
26165 ".previous\n"
26166 _ASM_EXTABLE(1b, 3b)
26167 - : : "r" (from), "r" (to) : "memory");
26168 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26169
26170 from += 64;
26171 to += 64;
26172 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26173 index f6d13ee..aca5f0b 100644
26174 --- a/arch/x86/lib/msr-reg.S
26175 +++ b/arch/x86/lib/msr-reg.S
26176 @@ -3,6 +3,7 @@
26177 #include <asm/dwarf2.h>
26178 #include <asm/asm.h>
26179 #include <asm/msr.h>
26180 +#include <asm/alternative-asm.h>
26181
26182 #ifdef CONFIG_X86_64
26183 /*
26184 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26185 CFI_STARTPROC
26186 pushq_cfi %rbx
26187 pushq_cfi %rbp
26188 - movq %rdi, %r10 /* Save pointer */
26189 + movq %rdi, %r9 /* Save pointer */
26190 xorl %r11d, %r11d /* Return value */
26191 movl (%rdi), %eax
26192 movl 4(%rdi), %ecx
26193 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26194 movl 28(%rdi), %edi
26195 CFI_REMEMBER_STATE
26196 1: \op
26197 -2: movl %eax, (%r10)
26198 +2: movl %eax, (%r9)
26199 movl %r11d, %eax /* Return value */
26200 - movl %ecx, 4(%r10)
26201 - movl %edx, 8(%r10)
26202 - movl %ebx, 12(%r10)
26203 - movl %ebp, 20(%r10)
26204 - movl %esi, 24(%r10)
26205 - movl %edi, 28(%r10)
26206 + movl %ecx, 4(%r9)
26207 + movl %edx, 8(%r9)
26208 + movl %ebx, 12(%r9)
26209 + movl %ebp, 20(%r9)
26210 + movl %esi, 24(%r9)
26211 + movl %edi, 28(%r9)
26212 popq_cfi %rbp
26213 popq_cfi %rbx
26214 + pax_force_retaddr
26215 ret
26216 3:
26217 CFI_RESTORE_STATE
26218 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26219 index fc6ba17..d4d989d 100644
26220 --- a/arch/x86/lib/putuser.S
26221 +++ b/arch/x86/lib/putuser.S
26222 @@ -16,7 +16,9 @@
26223 #include <asm/errno.h>
26224 #include <asm/asm.h>
26225 #include <asm/smap.h>
26226 -
26227 +#include <asm/segment.h>
26228 +#include <asm/pgtable.h>
26229 +#include <asm/alternative-asm.h>
26230
26231 /*
26232 * __put_user_X
26233 @@ -30,57 +32,125 @@
26234 * as they get called from within inline assembly.
26235 */
26236
26237 -#define ENTER CFI_STARTPROC ; \
26238 - GET_THREAD_INFO(%_ASM_BX)
26239 -#define EXIT ASM_CLAC ; \
26240 - ret ; \
26241 +#define ENTER CFI_STARTPROC
26242 +#define EXIT ASM_CLAC ; \
26243 + pax_force_retaddr ; \
26244 + ret ; \
26245 CFI_ENDPROC
26246
26247 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26248 +#define _DEST %_ASM_CX,%_ASM_BX
26249 +#else
26250 +#define _DEST %_ASM_CX
26251 +#endif
26252 +
26253 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26254 +#define __copyuser_seg gs;
26255 +#else
26256 +#define __copyuser_seg
26257 +#endif
26258 +
26259 .text
26260 ENTRY(__put_user_1)
26261 ENTER
26262 +
26263 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26264 + GET_THREAD_INFO(%_ASM_BX)
26265 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26266 jae bad_put_user
26267 ASM_STAC
26268 -1: movb %al,(%_ASM_CX)
26269 +
26270 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26271 + mov pax_user_shadow_base,%_ASM_BX
26272 + cmp %_ASM_BX,%_ASM_CX
26273 + jb 1234f
26274 + xor %ebx,%ebx
26275 +1234:
26276 +#endif
26277 +
26278 +#endif
26279 +
26280 +1: __copyuser_seg movb %al,(_DEST)
26281 xor %eax,%eax
26282 EXIT
26283 ENDPROC(__put_user_1)
26284
26285 ENTRY(__put_user_2)
26286 ENTER
26287 +
26288 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26289 + GET_THREAD_INFO(%_ASM_BX)
26290 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26291 sub $1,%_ASM_BX
26292 cmp %_ASM_BX,%_ASM_CX
26293 jae bad_put_user
26294 ASM_STAC
26295 -2: movw %ax,(%_ASM_CX)
26296 +
26297 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26298 + mov pax_user_shadow_base,%_ASM_BX
26299 + cmp %_ASM_BX,%_ASM_CX
26300 + jb 1234f
26301 + xor %ebx,%ebx
26302 +1234:
26303 +#endif
26304 +
26305 +#endif
26306 +
26307 +2: __copyuser_seg movw %ax,(_DEST)
26308 xor %eax,%eax
26309 EXIT
26310 ENDPROC(__put_user_2)
26311
26312 ENTRY(__put_user_4)
26313 ENTER
26314 +
26315 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26316 + GET_THREAD_INFO(%_ASM_BX)
26317 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26318 sub $3,%_ASM_BX
26319 cmp %_ASM_BX,%_ASM_CX
26320 jae bad_put_user
26321 ASM_STAC
26322 -3: movl %eax,(%_ASM_CX)
26323 +
26324 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26325 + mov pax_user_shadow_base,%_ASM_BX
26326 + cmp %_ASM_BX,%_ASM_CX
26327 + jb 1234f
26328 + xor %ebx,%ebx
26329 +1234:
26330 +#endif
26331 +
26332 +#endif
26333 +
26334 +3: __copyuser_seg movl %eax,(_DEST)
26335 xor %eax,%eax
26336 EXIT
26337 ENDPROC(__put_user_4)
26338
26339 ENTRY(__put_user_8)
26340 ENTER
26341 +
26342 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26343 + GET_THREAD_INFO(%_ASM_BX)
26344 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26345 sub $7,%_ASM_BX
26346 cmp %_ASM_BX,%_ASM_CX
26347 jae bad_put_user
26348 ASM_STAC
26349 -4: mov %_ASM_AX,(%_ASM_CX)
26350 +
26351 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26352 + mov pax_user_shadow_base,%_ASM_BX
26353 + cmp %_ASM_BX,%_ASM_CX
26354 + jb 1234f
26355 + xor %ebx,%ebx
26356 +1234:
26357 +#endif
26358 +
26359 +#endif
26360 +
26361 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26362 #ifdef CONFIG_X86_32
26363 -5: movl %edx,4(%_ASM_CX)
26364 +5: __copyuser_seg movl %edx,4(_DEST)
26365 #endif
26366 xor %eax,%eax
26367 EXIT
26368 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26369 index 1cad221..de671ee 100644
26370 --- a/arch/x86/lib/rwlock.S
26371 +++ b/arch/x86/lib/rwlock.S
26372 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26373 FRAME
26374 0: LOCK_PREFIX
26375 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26376 +
26377 +#ifdef CONFIG_PAX_REFCOUNT
26378 + jno 1234f
26379 + LOCK_PREFIX
26380 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26381 + int $4
26382 +1234:
26383 + _ASM_EXTABLE(1234b, 1234b)
26384 +#endif
26385 +
26386 1: rep; nop
26387 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26388 jne 1b
26389 LOCK_PREFIX
26390 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26391 +
26392 +#ifdef CONFIG_PAX_REFCOUNT
26393 + jno 1234f
26394 + LOCK_PREFIX
26395 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26396 + int $4
26397 +1234:
26398 + _ASM_EXTABLE(1234b, 1234b)
26399 +#endif
26400 +
26401 jnz 0b
26402 ENDFRAME
26403 + pax_force_retaddr
26404 ret
26405 CFI_ENDPROC
26406 END(__write_lock_failed)
26407 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26408 FRAME
26409 0: LOCK_PREFIX
26410 READ_LOCK_SIZE(inc) (%__lock_ptr)
26411 +
26412 +#ifdef CONFIG_PAX_REFCOUNT
26413 + jno 1234f
26414 + LOCK_PREFIX
26415 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26416 + int $4
26417 +1234:
26418 + _ASM_EXTABLE(1234b, 1234b)
26419 +#endif
26420 +
26421 1: rep; nop
26422 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26423 js 1b
26424 LOCK_PREFIX
26425 READ_LOCK_SIZE(dec) (%__lock_ptr)
26426 +
26427 +#ifdef CONFIG_PAX_REFCOUNT
26428 + jno 1234f
26429 + LOCK_PREFIX
26430 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26431 + int $4
26432 +1234:
26433 + _ASM_EXTABLE(1234b, 1234b)
26434 +#endif
26435 +
26436 js 0b
26437 ENDFRAME
26438 + pax_force_retaddr
26439 ret
26440 CFI_ENDPROC
26441 END(__read_lock_failed)
26442 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26443 index 5dff5f0..cadebf4 100644
26444 --- a/arch/x86/lib/rwsem.S
26445 +++ b/arch/x86/lib/rwsem.S
26446 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26447 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26448 CFI_RESTORE __ASM_REG(dx)
26449 restore_common_regs
26450 + pax_force_retaddr
26451 ret
26452 CFI_ENDPROC
26453 ENDPROC(call_rwsem_down_read_failed)
26454 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26455 movq %rax,%rdi
26456 call rwsem_down_write_failed
26457 restore_common_regs
26458 + pax_force_retaddr
26459 ret
26460 CFI_ENDPROC
26461 ENDPROC(call_rwsem_down_write_failed)
26462 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26463 movq %rax,%rdi
26464 call rwsem_wake
26465 restore_common_regs
26466 -1: ret
26467 +1: pax_force_retaddr
26468 + ret
26469 CFI_ENDPROC
26470 ENDPROC(call_rwsem_wake)
26471
26472 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26473 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26474 CFI_RESTORE __ASM_REG(dx)
26475 restore_common_regs
26476 + pax_force_retaddr
26477 ret
26478 CFI_ENDPROC
26479 ENDPROC(call_rwsem_downgrade_wake)
26480 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26481 index a63efd6..ccecad8 100644
26482 --- a/arch/x86/lib/thunk_64.S
26483 +++ b/arch/x86/lib/thunk_64.S
26484 @@ -8,6 +8,7 @@
26485 #include <linux/linkage.h>
26486 #include <asm/dwarf2.h>
26487 #include <asm/calling.h>
26488 +#include <asm/alternative-asm.h>
26489
26490 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26491 .macro THUNK name, func, put_ret_addr_in_rdi=0
26492 @@ -41,5 +42,6 @@
26493 SAVE_ARGS
26494 restore:
26495 RESTORE_ARGS
26496 + pax_force_retaddr
26497 ret
26498 CFI_ENDPROC
26499 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26500 index 3eb18ac..6890bc3 100644
26501 --- a/arch/x86/lib/usercopy_32.c
26502 +++ b/arch/x86/lib/usercopy_32.c
26503 @@ -42,11 +42,13 @@ do { \
26504 int __d0; \
26505 might_fault(); \
26506 __asm__ __volatile__( \
26507 + __COPYUSER_SET_ES \
26508 ASM_STAC "\n" \
26509 "0: rep; stosl\n" \
26510 " movl %2,%0\n" \
26511 "1: rep; stosb\n" \
26512 "2: " ASM_CLAC "\n" \
26513 + __COPYUSER_RESTORE_ES \
26514 ".section .fixup,\"ax\"\n" \
26515 "3: lea 0(%2,%0,4),%0\n" \
26516 " jmp 2b\n" \
26517 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26518
26519 #ifdef CONFIG_X86_INTEL_USERCOPY
26520 static unsigned long
26521 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26522 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26523 {
26524 int d0, d1;
26525 __asm__ __volatile__(
26526 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26527 " .align 2,0x90\n"
26528 "3: movl 0(%4), %%eax\n"
26529 "4: movl 4(%4), %%edx\n"
26530 - "5: movl %%eax, 0(%3)\n"
26531 - "6: movl %%edx, 4(%3)\n"
26532 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26533 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26534 "7: movl 8(%4), %%eax\n"
26535 "8: movl 12(%4),%%edx\n"
26536 - "9: movl %%eax, 8(%3)\n"
26537 - "10: movl %%edx, 12(%3)\n"
26538 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26539 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26540 "11: movl 16(%4), %%eax\n"
26541 "12: movl 20(%4), %%edx\n"
26542 - "13: movl %%eax, 16(%3)\n"
26543 - "14: movl %%edx, 20(%3)\n"
26544 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26545 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26546 "15: movl 24(%4), %%eax\n"
26547 "16: movl 28(%4), %%edx\n"
26548 - "17: movl %%eax, 24(%3)\n"
26549 - "18: movl %%edx, 28(%3)\n"
26550 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26551 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26552 "19: movl 32(%4), %%eax\n"
26553 "20: movl 36(%4), %%edx\n"
26554 - "21: movl %%eax, 32(%3)\n"
26555 - "22: movl %%edx, 36(%3)\n"
26556 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26557 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26558 "23: movl 40(%4), %%eax\n"
26559 "24: movl 44(%4), %%edx\n"
26560 - "25: movl %%eax, 40(%3)\n"
26561 - "26: movl %%edx, 44(%3)\n"
26562 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26563 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26564 "27: movl 48(%4), %%eax\n"
26565 "28: movl 52(%4), %%edx\n"
26566 - "29: movl %%eax, 48(%3)\n"
26567 - "30: movl %%edx, 52(%3)\n"
26568 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26569 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26570 "31: movl 56(%4), %%eax\n"
26571 "32: movl 60(%4), %%edx\n"
26572 - "33: movl %%eax, 56(%3)\n"
26573 - "34: movl %%edx, 60(%3)\n"
26574 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26575 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26576 " addl $-64, %0\n"
26577 " addl $64, %4\n"
26578 " addl $64, %3\n"
26579 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26580 " shrl $2, %0\n"
26581 " andl $3, %%eax\n"
26582 " cld\n"
26583 + __COPYUSER_SET_ES
26584 "99: rep; movsl\n"
26585 "36: movl %%eax, %0\n"
26586 "37: rep; movsb\n"
26587 "100:\n"
26588 + __COPYUSER_RESTORE_ES
26589 ".section .fixup,\"ax\"\n"
26590 "101: lea 0(%%eax,%0,4),%0\n"
26591 " jmp 100b\n"
26592 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26593 }
26594
26595 static unsigned long
26596 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26597 +{
26598 + int d0, d1;
26599 + __asm__ __volatile__(
26600 + " .align 2,0x90\n"
26601 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26602 + " cmpl $67, %0\n"
26603 + " jbe 3f\n"
26604 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26605 + " .align 2,0x90\n"
26606 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26607 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26608 + "5: movl %%eax, 0(%3)\n"
26609 + "6: movl %%edx, 4(%3)\n"
26610 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26611 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26612 + "9: movl %%eax, 8(%3)\n"
26613 + "10: movl %%edx, 12(%3)\n"
26614 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26615 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26616 + "13: movl %%eax, 16(%3)\n"
26617 + "14: movl %%edx, 20(%3)\n"
26618 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26619 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26620 + "17: movl %%eax, 24(%3)\n"
26621 + "18: movl %%edx, 28(%3)\n"
26622 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26623 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26624 + "21: movl %%eax, 32(%3)\n"
26625 + "22: movl %%edx, 36(%3)\n"
26626 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26627 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26628 + "25: movl %%eax, 40(%3)\n"
26629 + "26: movl %%edx, 44(%3)\n"
26630 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26631 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26632 + "29: movl %%eax, 48(%3)\n"
26633 + "30: movl %%edx, 52(%3)\n"
26634 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26635 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26636 + "33: movl %%eax, 56(%3)\n"
26637 + "34: movl %%edx, 60(%3)\n"
26638 + " addl $-64, %0\n"
26639 + " addl $64, %4\n"
26640 + " addl $64, %3\n"
26641 + " cmpl $63, %0\n"
26642 + " ja 1b\n"
26643 + "35: movl %0, %%eax\n"
26644 + " shrl $2, %0\n"
26645 + " andl $3, %%eax\n"
26646 + " cld\n"
26647 + "99: rep; "__copyuser_seg" movsl\n"
26648 + "36: movl %%eax, %0\n"
26649 + "37: rep; "__copyuser_seg" movsb\n"
26650 + "100:\n"
26651 + ".section .fixup,\"ax\"\n"
26652 + "101: lea 0(%%eax,%0,4),%0\n"
26653 + " jmp 100b\n"
26654 + ".previous\n"
26655 + _ASM_EXTABLE(1b,100b)
26656 + _ASM_EXTABLE(2b,100b)
26657 + _ASM_EXTABLE(3b,100b)
26658 + _ASM_EXTABLE(4b,100b)
26659 + _ASM_EXTABLE(5b,100b)
26660 + _ASM_EXTABLE(6b,100b)
26661 + _ASM_EXTABLE(7b,100b)
26662 + _ASM_EXTABLE(8b,100b)
26663 + _ASM_EXTABLE(9b,100b)
26664 + _ASM_EXTABLE(10b,100b)
26665 + _ASM_EXTABLE(11b,100b)
26666 + _ASM_EXTABLE(12b,100b)
26667 + _ASM_EXTABLE(13b,100b)
26668 + _ASM_EXTABLE(14b,100b)
26669 + _ASM_EXTABLE(15b,100b)
26670 + _ASM_EXTABLE(16b,100b)
26671 + _ASM_EXTABLE(17b,100b)
26672 + _ASM_EXTABLE(18b,100b)
26673 + _ASM_EXTABLE(19b,100b)
26674 + _ASM_EXTABLE(20b,100b)
26675 + _ASM_EXTABLE(21b,100b)
26676 + _ASM_EXTABLE(22b,100b)
26677 + _ASM_EXTABLE(23b,100b)
26678 + _ASM_EXTABLE(24b,100b)
26679 + _ASM_EXTABLE(25b,100b)
26680 + _ASM_EXTABLE(26b,100b)
26681 + _ASM_EXTABLE(27b,100b)
26682 + _ASM_EXTABLE(28b,100b)
26683 + _ASM_EXTABLE(29b,100b)
26684 + _ASM_EXTABLE(30b,100b)
26685 + _ASM_EXTABLE(31b,100b)
26686 + _ASM_EXTABLE(32b,100b)
26687 + _ASM_EXTABLE(33b,100b)
26688 + _ASM_EXTABLE(34b,100b)
26689 + _ASM_EXTABLE(35b,100b)
26690 + _ASM_EXTABLE(36b,100b)
26691 + _ASM_EXTABLE(37b,100b)
26692 + _ASM_EXTABLE(99b,101b)
26693 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26694 + : "1"(to), "2"(from), "0"(size)
26695 + : "eax", "edx", "memory");
26696 + return size;
26697 +}
26698 +
26699 +static unsigned long __size_overflow(3)
26700 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26701 {
26702 int d0, d1;
26703 __asm__ __volatile__(
26704 " .align 2,0x90\n"
26705 - "0: movl 32(%4), %%eax\n"
26706 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26707 " cmpl $67, %0\n"
26708 " jbe 2f\n"
26709 - "1: movl 64(%4), %%eax\n"
26710 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26711 " .align 2,0x90\n"
26712 - "2: movl 0(%4), %%eax\n"
26713 - "21: movl 4(%4), %%edx\n"
26714 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26715 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26716 " movl %%eax, 0(%3)\n"
26717 " movl %%edx, 4(%3)\n"
26718 - "3: movl 8(%4), %%eax\n"
26719 - "31: movl 12(%4),%%edx\n"
26720 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26721 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26722 " movl %%eax, 8(%3)\n"
26723 " movl %%edx, 12(%3)\n"
26724 - "4: movl 16(%4), %%eax\n"
26725 - "41: movl 20(%4), %%edx\n"
26726 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26727 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26728 " movl %%eax, 16(%3)\n"
26729 " movl %%edx, 20(%3)\n"
26730 - "10: movl 24(%4), %%eax\n"
26731 - "51: movl 28(%4), %%edx\n"
26732 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26733 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26734 " movl %%eax, 24(%3)\n"
26735 " movl %%edx, 28(%3)\n"
26736 - "11: movl 32(%4), %%eax\n"
26737 - "61: movl 36(%4), %%edx\n"
26738 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26739 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26740 " movl %%eax, 32(%3)\n"
26741 " movl %%edx, 36(%3)\n"
26742 - "12: movl 40(%4), %%eax\n"
26743 - "71: movl 44(%4), %%edx\n"
26744 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26745 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26746 " movl %%eax, 40(%3)\n"
26747 " movl %%edx, 44(%3)\n"
26748 - "13: movl 48(%4), %%eax\n"
26749 - "81: movl 52(%4), %%edx\n"
26750 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26751 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26752 " movl %%eax, 48(%3)\n"
26753 " movl %%edx, 52(%3)\n"
26754 - "14: movl 56(%4), %%eax\n"
26755 - "91: movl 60(%4), %%edx\n"
26756 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26757 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26758 " movl %%eax, 56(%3)\n"
26759 " movl %%edx, 60(%3)\n"
26760 " addl $-64, %0\n"
26761 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26762 " shrl $2, %0\n"
26763 " andl $3, %%eax\n"
26764 " cld\n"
26765 - "6: rep; movsl\n"
26766 + "6: rep; "__copyuser_seg" movsl\n"
26767 " movl %%eax,%0\n"
26768 - "7: rep; movsb\n"
26769 + "7: rep; "__copyuser_seg" movsb\n"
26770 "8:\n"
26771 ".section .fixup,\"ax\"\n"
26772 "9: lea 0(%%eax,%0,4),%0\n"
26773 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26774 * hyoshiok@miraclelinux.com
26775 */
26776
26777 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26778 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26779 const void __user *from, unsigned long size)
26780 {
26781 int d0, d1;
26782
26783 __asm__ __volatile__(
26784 " .align 2,0x90\n"
26785 - "0: movl 32(%4), %%eax\n"
26786 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26787 " cmpl $67, %0\n"
26788 " jbe 2f\n"
26789 - "1: movl 64(%4), %%eax\n"
26790 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26791 " .align 2,0x90\n"
26792 - "2: movl 0(%4), %%eax\n"
26793 - "21: movl 4(%4), %%edx\n"
26794 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26795 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26796 " movnti %%eax, 0(%3)\n"
26797 " movnti %%edx, 4(%3)\n"
26798 - "3: movl 8(%4), %%eax\n"
26799 - "31: movl 12(%4),%%edx\n"
26800 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26801 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26802 " movnti %%eax, 8(%3)\n"
26803 " movnti %%edx, 12(%3)\n"
26804 - "4: movl 16(%4), %%eax\n"
26805 - "41: movl 20(%4), %%edx\n"
26806 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26807 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26808 " movnti %%eax, 16(%3)\n"
26809 " movnti %%edx, 20(%3)\n"
26810 - "10: movl 24(%4), %%eax\n"
26811 - "51: movl 28(%4), %%edx\n"
26812 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26813 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26814 " movnti %%eax, 24(%3)\n"
26815 " movnti %%edx, 28(%3)\n"
26816 - "11: movl 32(%4), %%eax\n"
26817 - "61: movl 36(%4), %%edx\n"
26818 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26819 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26820 " movnti %%eax, 32(%3)\n"
26821 " movnti %%edx, 36(%3)\n"
26822 - "12: movl 40(%4), %%eax\n"
26823 - "71: movl 44(%4), %%edx\n"
26824 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26825 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26826 " movnti %%eax, 40(%3)\n"
26827 " movnti %%edx, 44(%3)\n"
26828 - "13: movl 48(%4), %%eax\n"
26829 - "81: movl 52(%4), %%edx\n"
26830 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26831 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26832 " movnti %%eax, 48(%3)\n"
26833 " movnti %%edx, 52(%3)\n"
26834 - "14: movl 56(%4), %%eax\n"
26835 - "91: movl 60(%4), %%edx\n"
26836 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26837 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26838 " movnti %%eax, 56(%3)\n"
26839 " movnti %%edx, 60(%3)\n"
26840 " addl $-64, %0\n"
26841 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26842 " shrl $2, %0\n"
26843 " andl $3, %%eax\n"
26844 " cld\n"
26845 - "6: rep; movsl\n"
26846 + "6: rep; "__copyuser_seg" movsl\n"
26847 " movl %%eax,%0\n"
26848 - "7: rep; movsb\n"
26849 + "7: rep; "__copyuser_seg" movsb\n"
26850 "8:\n"
26851 ".section .fixup,\"ax\"\n"
26852 "9: lea 0(%%eax,%0,4),%0\n"
26853 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26854 return size;
26855 }
26856
26857 -static unsigned long __copy_user_intel_nocache(void *to,
26858 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26859 const void __user *from, unsigned long size)
26860 {
26861 int d0, d1;
26862
26863 __asm__ __volatile__(
26864 " .align 2,0x90\n"
26865 - "0: movl 32(%4), %%eax\n"
26866 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26867 " cmpl $67, %0\n"
26868 " jbe 2f\n"
26869 - "1: movl 64(%4), %%eax\n"
26870 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26871 " .align 2,0x90\n"
26872 - "2: movl 0(%4), %%eax\n"
26873 - "21: movl 4(%4), %%edx\n"
26874 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26875 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26876 " movnti %%eax, 0(%3)\n"
26877 " movnti %%edx, 4(%3)\n"
26878 - "3: movl 8(%4), %%eax\n"
26879 - "31: movl 12(%4),%%edx\n"
26880 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26881 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26882 " movnti %%eax, 8(%3)\n"
26883 " movnti %%edx, 12(%3)\n"
26884 - "4: movl 16(%4), %%eax\n"
26885 - "41: movl 20(%4), %%edx\n"
26886 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26887 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26888 " movnti %%eax, 16(%3)\n"
26889 " movnti %%edx, 20(%3)\n"
26890 - "10: movl 24(%4), %%eax\n"
26891 - "51: movl 28(%4), %%edx\n"
26892 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26893 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26894 " movnti %%eax, 24(%3)\n"
26895 " movnti %%edx, 28(%3)\n"
26896 - "11: movl 32(%4), %%eax\n"
26897 - "61: movl 36(%4), %%edx\n"
26898 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26899 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26900 " movnti %%eax, 32(%3)\n"
26901 " movnti %%edx, 36(%3)\n"
26902 - "12: movl 40(%4), %%eax\n"
26903 - "71: movl 44(%4), %%edx\n"
26904 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26905 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26906 " movnti %%eax, 40(%3)\n"
26907 " movnti %%edx, 44(%3)\n"
26908 - "13: movl 48(%4), %%eax\n"
26909 - "81: movl 52(%4), %%edx\n"
26910 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26911 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26912 " movnti %%eax, 48(%3)\n"
26913 " movnti %%edx, 52(%3)\n"
26914 - "14: movl 56(%4), %%eax\n"
26915 - "91: movl 60(%4), %%edx\n"
26916 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26917 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26918 " movnti %%eax, 56(%3)\n"
26919 " movnti %%edx, 60(%3)\n"
26920 " addl $-64, %0\n"
26921 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26922 " shrl $2, %0\n"
26923 " andl $3, %%eax\n"
26924 " cld\n"
26925 - "6: rep; movsl\n"
26926 + "6: rep; "__copyuser_seg" movsl\n"
26927 " movl %%eax,%0\n"
26928 - "7: rep; movsb\n"
26929 + "7: rep; "__copyuser_seg" movsb\n"
26930 "8:\n"
26931 ".section .fixup,\"ax\"\n"
26932 "9: lea 0(%%eax,%0,4),%0\n"
26933 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26934 */
26935 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26936 unsigned long size);
26937 -unsigned long __copy_user_intel(void __user *to, const void *from,
26938 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26939 + unsigned long size);
26940 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26941 unsigned long size);
26942 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26943 const void __user *from, unsigned long size);
26944 #endif /* CONFIG_X86_INTEL_USERCOPY */
26945
26946 /* Generic arbitrary sized copy. */
26947 -#define __copy_user(to, from, size) \
26948 +#define __copy_user(to, from, size, prefix, set, restore) \
26949 do { \
26950 int __d0, __d1, __d2; \
26951 __asm__ __volatile__( \
26952 + set \
26953 " cmp $7,%0\n" \
26954 " jbe 1f\n" \
26955 " movl %1,%0\n" \
26956 " negl %0\n" \
26957 " andl $7,%0\n" \
26958 " subl %0,%3\n" \
26959 - "4: rep; movsb\n" \
26960 + "4: rep; "prefix"movsb\n" \
26961 " movl %3,%0\n" \
26962 " shrl $2,%0\n" \
26963 " andl $3,%3\n" \
26964 " .align 2,0x90\n" \
26965 - "0: rep; movsl\n" \
26966 + "0: rep; "prefix"movsl\n" \
26967 " movl %3,%0\n" \
26968 - "1: rep; movsb\n" \
26969 + "1: rep; "prefix"movsb\n" \
26970 "2:\n" \
26971 + restore \
26972 ".section .fixup,\"ax\"\n" \
26973 "5: addl %3,%0\n" \
26974 " jmp 2b\n" \
26975 @@ -538,14 +650,14 @@ do { \
26976 " negl %0\n" \
26977 " andl $7,%0\n" \
26978 " subl %0,%3\n" \
26979 - "4: rep; movsb\n" \
26980 + "4: rep; "__copyuser_seg"movsb\n" \
26981 " movl %3,%0\n" \
26982 " shrl $2,%0\n" \
26983 " andl $3,%3\n" \
26984 " .align 2,0x90\n" \
26985 - "0: rep; movsl\n" \
26986 + "0: rep; "__copyuser_seg"movsl\n" \
26987 " movl %3,%0\n" \
26988 - "1: rep; movsb\n" \
26989 + "1: rep; "__copyuser_seg"movsb\n" \
26990 "2:\n" \
26991 ".section .fixup,\"ax\"\n" \
26992 "5: addl %3,%0\n" \
26993 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26994 {
26995 stac();
26996 if (movsl_is_ok(to, from, n))
26997 - __copy_user(to, from, n);
26998 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26999 else
27000 - n = __copy_user_intel(to, from, n);
27001 + n = __generic_copy_to_user_intel(to, from, n);
27002 clac();
27003 return n;
27004 }
27005 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27006 {
27007 stac();
27008 if (movsl_is_ok(to, from, n))
27009 - __copy_user(to, from, n);
27010 + __copy_user(to, from, n, __copyuser_seg, "", "");
27011 else
27012 - n = __copy_user_intel((void __user *)to,
27013 - (const void *)from, n);
27014 + n = __generic_copy_from_user_intel(to, from, n);
27015 clac();
27016 return n;
27017 }
27018 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27019 if (n > 64 && cpu_has_xmm2)
27020 n = __copy_user_intel_nocache(to, from, n);
27021 else
27022 - __copy_user(to, from, n);
27023 + __copy_user(to, from, n, __copyuser_seg, "", "");
27024 #else
27025 - __copy_user(to, from, n);
27026 + __copy_user(to, from, n, __copyuser_seg, "", "");
27027 #endif
27028 clac();
27029 return n;
27030 }
27031 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27032
27033 -/**
27034 - * copy_to_user: - Copy a block of data into user space.
27035 - * @to: Destination address, in user space.
27036 - * @from: Source address, in kernel space.
27037 - * @n: Number of bytes to copy.
27038 - *
27039 - * Context: User context only. This function may sleep.
27040 - *
27041 - * Copy data from kernel space to user space.
27042 - *
27043 - * Returns number of bytes that could not be copied.
27044 - * On success, this will be zero.
27045 - */
27046 -unsigned long
27047 -copy_to_user(void __user *to, const void *from, unsigned long n)
27048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27049 +void __set_fs(mm_segment_t x)
27050 {
27051 - if (access_ok(VERIFY_WRITE, to, n))
27052 - n = __copy_to_user(to, from, n);
27053 - return n;
27054 + switch (x.seg) {
27055 + case 0:
27056 + loadsegment(gs, 0);
27057 + break;
27058 + case TASK_SIZE_MAX:
27059 + loadsegment(gs, __USER_DS);
27060 + break;
27061 + case -1UL:
27062 + loadsegment(gs, __KERNEL_DS);
27063 + break;
27064 + default:
27065 + BUG();
27066 + }
27067 }
27068 -EXPORT_SYMBOL(copy_to_user);
27069 +EXPORT_SYMBOL(__set_fs);
27070
27071 -/**
27072 - * copy_from_user: - Copy a block of data from user space.
27073 - * @to: Destination address, in kernel space.
27074 - * @from: Source address, in user space.
27075 - * @n: Number of bytes to copy.
27076 - *
27077 - * Context: User context only. This function may sleep.
27078 - *
27079 - * Copy data from user space to kernel space.
27080 - *
27081 - * Returns number of bytes that could not be copied.
27082 - * On success, this will be zero.
27083 - *
27084 - * If some data could not be copied, this function will pad the copied
27085 - * data to the requested size using zero bytes.
27086 - */
27087 -unsigned long
27088 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27089 +void set_fs(mm_segment_t x)
27090 {
27091 - if (access_ok(VERIFY_READ, from, n))
27092 - n = __copy_from_user(to, from, n);
27093 - else
27094 - memset(to, 0, n);
27095 - return n;
27096 + current_thread_info()->addr_limit = x;
27097 + __set_fs(x);
27098 }
27099 -EXPORT_SYMBOL(_copy_from_user);
27100 +EXPORT_SYMBOL(set_fs);
27101 +#endif
27102 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27103 index 906fea3..5646695 100644
27104 --- a/arch/x86/lib/usercopy_64.c
27105 +++ b/arch/x86/lib/usercopy_64.c
27106 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27107 _ASM_EXTABLE(0b,3b)
27108 _ASM_EXTABLE(1b,2b)
27109 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27110 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27111 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27112 [zero] "r" (0UL), [eight] "r" (8UL));
27113 clac();
27114 return size;
27115 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27116 }
27117 EXPORT_SYMBOL(clear_user);
27118
27119 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27120 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27121 {
27122 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27123 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27124 - }
27125 - return len;
27126 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27127 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27128 + return len;
27129 }
27130 EXPORT_SYMBOL(copy_in_user);
27131
27132 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27133 * it is not necessary to optimize tail handling.
27134 */
27135 unsigned long
27136 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27137 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27138 {
27139 char c;
27140 unsigned zero_len;
27141 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27142 index 903ec1e..c4166b2 100644
27143 --- a/arch/x86/mm/extable.c
27144 +++ b/arch/x86/mm/extable.c
27145 @@ -6,12 +6,24 @@
27146 static inline unsigned long
27147 ex_insn_addr(const struct exception_table_entry *x)
27148 {
27149 - return (unsigned long)&x->insn + x->insn;
27150 + unsigned long reloc = 0;
27151 +
27152 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27153 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27154 +#endif
27155 +
27156 + return (unsigned long)&x->insn + x->insn + reloc;
27157 }
27158 static inline unsigned long
27159 ex_fixup_addr(const struct exception_table_entry *x)
27160 {
27161 - return (unsigned long)&x->fixup + x->fixup;
27162 + unsigned long reloc = 0;
27163 +
27164 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27165 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27166 +#endif
27167 +
27168 + return (unsigned long)&x->fixup + x->fixup + reloc;
27169 }
27170
27171 int fixup_exception(struct pt_regs *regs)
27172 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27173 unsigned long new_ip;
27174
27175 #ifdef CONFIG_PNPBIOS
27176 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27177 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27178 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27179 extern u32 pnp_bios_is_utter_crap;
27180 pnp_bios_is_utter_crap = 1;
27181 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27182 i += 4;
27183 p->fixup -= i;
27184 i += 4;
27185 +
27186 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27187 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27188 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27189 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27190 +#endif
27191 +
27192 }
27193 }
27194
27195 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27196 index 654be4a..d36985f 100644
27197 --- a/arch/x86/mm/fault.c
27198 +++ b/arch/x86/mm/fault.c
27199 @@ -14,11 +14,18 @@
27200 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27201 #include <linux/prefetch.h> /* prefetchw */
27202 #include <linux/context_tracking.h> /* exception_enter(), ... */
27203 +#include <linux/unistd.h>
27204 +#include <linux/compiler.h>
27205
27206 #include <asm/traps.h> /* dotraplinkage, ... */
27207 #include <asm/pgalloc.h> /* pgd_*(), ... */
27208 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27209 #include <asm/fixmap.h> /* VSYSCALL_START */
27210 +#include <asm/tlbflush.h>
27211 +
27212 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27213 +#include <asm/stacktrace.h>
27214 +#endif
27215
27216 /*
27217 * Page fault error code bits:
27218 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27219 int ret = 0;
27220
27221 /* kprobe_running() needs smp_processor_id() */
27222 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27223 + if (kprobes_built_in() && !user_mode(regs)) {
27224 preempt_disable();
27225 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27226 ret = 1;
27227 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27228 return !instr_lo || (instr_lo>>1) == 1;
27229 case 0x00:
27230 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27231 - if (probe_kernel_address(instr, opcode))
27232 + if (user_mode(regs)) {
27233 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27234 + return 0;
27235 + } else if (probe_kernel_address(instr, opcode))
27236 return 0;
27237
27238 *prefetch = (instr_lo == 0xF) &&
27239 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27240 while (instr < max_instr) {
27241 unsigned char opcode;
27242
27243 - if (probe_kernel_address(instr, opcode))
27244 + if (user_mode(regs)) {
27245 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27246 + break;
27247 + } else if (probe_kernel_address(instr, opcode))
27248 break;
27249
27250 instr++;
27251 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27252 force_sig_info(si_signo, &info, tsk);
27253 }
27254
27255 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27256 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27257 +#endif
27258 +
27259 +#ifdef CONFIG_PAX_EMUTRAMP
27260 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27261 +#endif
27262 +
27263 +#ifdef CONFIG_PAX_PAGEEXEC
27264 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27265 +{
27266 + pgd_t *pgd;
27267 + pud_t *pud;
27268 + pmd_t *pmd;
27269 +
27270 + pgd = pgd_offset(mm, address);
27271 + if (!pgd_present(*pgd))
27272 + return NULL;
27273 + pud = pud_offset(pgd, address);
27274 + if (!pud_present(*pud))
27275 + return NULL;
27276 + pmd = pmd_offset(pud, address);
27277 + if (!pmd_present(*pmd))
27278 + return NULL;
27279 + return pmd;
27280 +}
27281 +#endif
27282 +
27283 DEFINE_SPINLOCK(pgd_lock);
27284 LIST_HEAD(pgd_list);
27285
27286 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27287 for (address = VMALLOC_START & PMD_MASK;
27288 address >= TASK_SIZE && address < FIXADDR_TOP;
27289 address += PMD_SIZE) {
27290 +
27291 +#ifdef CONFIG_PAX_PER_CPU_PGD
27292 + unsigned long cpu;
27293 +#else
27294 struct page *page;
27295 +#endif
27296
27297 spin_lock(&pgd_lock);
27298 +
27299 +#ifdef CONFIG_PAX_PER_CPU_PGD
27300 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27301 + pgd_t *pgd = get_cpu_pgd(cpu);
27302 + pmd_t *ret;
27303 +#else
27304 list_for_each_entry(page, &pgd_list, lru) {
27305 + pgd_t *pgd;
27306 spinlock_t *pgt_lock;
27307 pmd_t *ret;
27308
27309 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27310 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27311
27312 spin_lock(pgt_lock);
27313 - ret = vmalloc_sync_one(page_address(page), address);
27314 + pgd = page_address(page);
27315 +#endif
27316 +
27317 + ret = vmalloc_sync_one(pgd, address);
27318 +
27319 +#ifndef CONFIG_PAX_PER_CPU_PGD
27320 spin_unlock(pgt_lock);
27321 +#endif
27322
27323 if (!ret)
27324 break;
27325 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27326 * an interrupt in the middle of a task switch..
27327 */
27328 pgd_paddr = read_cr3();
27329 +
27330 +#ifdef CONFIG_PAX_PER_CPU_PGD
27331 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27332 +#endif
27333 +
27334 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27335 if (!pmd_k)
27336 return -1;
27337 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27338 * happen within a race in page table update. In the later
27339 * case just flush:
27340 */
27341 +
27342 +#ifdef CONFIG_PAX_PER_CPU_PGD
27343 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27344 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27345 +#else
27346 pgd = pgd_offset(current->active_mm, address);
27347 +#endif
27348 +
27349 pgd_ref = pgd_offset_k(address);
27350 if (pgd_none(*pgd_ref))
27351 return -1;
27352 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27353 static int is_errata100(struct pt_regs *regs, unsigned long address)
27354 {
27355 #ifdef CONFIG_X86_64
27356 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27357 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27358 return 1;
27359 #endif
27360 return 0;
27361 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27362 }
27363
27364 static const char nx_warning[] = KERN_CRIT
27365 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27366 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27367
27368 static void
27369 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27370 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27371 if (!oops_may_print())
27372 return;
27373
27374 - if (error_code & PF_INSTR) {
27375 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27376 unsigned int level;
27377
27378 pte_t *pte = lookup_address(address, &level);
27379
27380 if (pte && pte_present(*pte) && !pte_exec(*pte))
27381 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27382 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27383 }
27384
27385 +#ifdef CONFIG_PAX_KERNEXEC
27386 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27387 + if (current->signal->curr_ip)
27388 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27389 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27390 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27391 + else
27392 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27393 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27394 + }
27395 +#endif
27396 +
27397 printk(KERN_ALERT "BUG: unable to handle kernel ");
27398 if (address < PAGE_SIZE)
27399 printk(KERN_CONT "NULL pointer dereference");
27400 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27401 return;
27402 }
27403 #endif
27404 +
27405 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27406 + if (pax_is_fetch_fault(regs, error_code, address)) {
27407 +
27408 +#ifdef CONFIG_PAX_EMUTRAMP
27409 + switch (pax_handle_fetch_fault(regs)) {
27410 + case 2:
27411 + return;
27412 + }
27413 +#endif
27414 +
27415 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27416 + do_group_exit(SIGKILL);
27417 + }
27418 +#endif
27419 +
27420 /* Kernel addresses are always protection faults: */
27421 if (address >= TASK_SIZE)
27422 error_code |= PF_PROT;
27423 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27424 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27425 printk(KERN_ERR
27426 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27427 - tsk->comm, tsk->pid, address);
27428 + tsk->comm, task_pid_nr(tsk), address);
27429 code = BUS_MCEERR_AR;
27430 }
27431 #endif
27432 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27433 return 1;
27434 }
27435
27436 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27437 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27438 +{
27439 + pte_t *pte;
27440 + pmd_t *pmd;
27441 + spinlock_t *ptl;
27442 + unsigned char pte_mask;
27443 +
27444 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27445 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27446 + return 0;
27447 +
27448 + /* PaX: it's our fault, let's handle it if we can */
27449 +
27450 + /* PaX: take a look at read faults before acquiring any locks */
27451 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27452 + /* instruction fetch attempt from a protected page in user mode */
27453 + up_read(&mm->mmap_sem);
27454 +
27455 +#ifdef CONFIG_PAX_EMUTRAMP
27456 + switch (pax_handle_fetch_fault(regs)) {
27457 + case 2:
27458 + return 1;
27459 + }
27460 +#endif
27461 +
27462 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27463 + do_group_exit(SIGKILL);
27464 + }
27465 +
27466 + pmd = pax_get_pmd(mm, address);
27467 + if (unlikely(!pmd))
27468 + return 0;
27469 +
27470 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27471 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27472 + pte_unmap_unlock(pte, ptl);
27473 + return 0;
27474 + }
27475 +
27476 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27477 + /* write attempt to a protected page in user mode */
27478 + pte_unmap_unlock(pte, ptl);
27479 + return 0;
27480 + }
27481 +
27482 +#ifdef CONFIG_SMP
27483 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27484 +#else
27485 + if (likely(address > get_limit(regs->cs)))
27486 +#endif
27487 + {
27488 + set_pte(pte, pte_mkread(*pte));
27489 + __flush_tlb_one(address);
27490 + pte_unmap_unlock(pte, ptl);
27491 + up_read(&mm->mmap_sem);
27492 + return 1;
27493 + }
27494 +
27495 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27496 +
27497 + /*
27498 + * PaX: fill DTLB with user rights and retry
27499 + */
27500 + __asm__ __volatile__ (
27501 + "orb %2,(%1)\n"
27502 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27503 +/*
27504 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27505 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27506 + * page fault when examined during a TLB load attempt. this is true not only
27507 + * for PTEs holding a non-present entry but also present entries that will
27508 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27509 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27510 + * for our target pages since their PTEs are simply not in the TLBs at all.
27511 +
27512 + * the best thing in omitting it is that we gain around 15-20% speed in the
27513 + * fast path of the page fault handler and can get rid of tracing since we
27514 + * can no longer flush unintended entries.
27515 + */
27516 + "invlpg (%0)\n"
27517 +#endif
27518 + __copyuser_seg"testb $0,(%0)\n"
27519 + "xorb %3,(%1)\n"
27520 + :
27521 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27522 + : "memory", "cc");
27523 + pte_unmap_unlock(pte, ptl);
27524 + up_read(&mm->mmap_sem);
27525 + return 1;
27526 +}
27527 +#endif
27528 +
27529 /*
27530 * Handle a spurious fault caused by a stale TLB entry.
27531 *
27532 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27533 static inline int
27534 access_error(unsigned long error_code, struct vm_area_struct *vma)
27535 {
27536 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27537 + return 1;
27538 +
27539 if (error_code & PF_WRITE) {
27540 /* write, present and write, not present: */
27541 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27542 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27543 if (error_code & PF_USER)
27544 return false;
27545
27546 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27547 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27548 return false;
27549
27550 return true;
27551 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27552 {
27553 struct vm_area_struct *vma;
27554 struct task_struct *tsk;
27555 - unsigned long address;
27556 struct mm_struct *mm;
27557 int fault;
27558 int write = error_code & PF_WRITE;
27559 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27560 (write ? FAULT_FLAG_WRITE : 0);
27561
27562 - tsk = current;
27563 - mm = tsk->mm;
27564 -
27565 /* Get the faulting address: */
27566 - address = read_cr2();
27567 + unsigned long address = read_cr2();
27568 +
27569 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27570 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27571 + if (!search_exception_tables(regs->ip)) {
27572 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27573 + bad_area_nosemaphore(regs, error_code, address);
27574 + return;
27575 + }
27576 + if (address < pax_user_shadow_base) {
27577 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27578 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27579 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27580 + } else
27581 + address -= pax_user_shadow_base;
27582 + }
27583 +#endif
27584 +
27585 + tsk = current;
27586 + mm = tsk->mm;
27587
27588 /*
27589 * Detect and handle instructions that would cause a page fault for
27590 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27591 * User-mode registers count as a user access even for any
27592 * potential system fault or CPU buglet:
27593 */
27594 - if (user_mode_vm(regs)) {
27595 + if (user_mode(regs)) {
27596 local_irq_enable();
27597 error_code |= PF_USER;
27598 } else {
27599 @@ -1142,6 +1352,11 @@ retry:
27600 might_sleep();
27601 }
27602
27603 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27604 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27605 + return;
27606 +#endif
27607 +
27608 vma = find_vma(mm, address);
27609 if (unlikely(!vma)) {
27610 bad_area(regs, error_code, address);
27611 @@ -1153,18 +1368,24 @@ retry:
27612 bad_area(regs, error_code, address);
27613 return;
27614 }
27615 - if (error_code & PF_USER) {
27616 - /*
27617 - * Accessing the stack below %sp is always a bug.
27618 - * The large cushion allows instructions like enter
27619 - * and pusha to work. ("enter $65535, $31" pushes
27620 - * 32 pointers and then decrements %sp by 65535.)
27621 - */
27622 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27623 - bad_area(regs, error_code, address);
27624 - return;
27625 - }
27626 + /*
27627 + * Accessing the stack below %sp is always a bug.
27628 + * The large cushion allows instructions like enter
27629 + * and pusha to work. ("enter $65535, $31" pushes
27630 + * 32 pointers and then decrements %sp by 65535.)
27631 + */
27632 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27633 + bad_area(regs, error_code, address);
27634 + return;
27635 }
27636 +
27637 +#ifdef CONFIG_PAX_SEGMEXEC
27638 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27639 + bad_area(regs, error_code, address);
27640 + return;
27641 + }
27642 +#endif
27643 +
27644 if (unlikely(expand_stack(vma, address))) {
27645 bad_area(regs, error_code, address);
27646 return;
27647 @@ -1230,3 +1451,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27648 __do_page_fault(regs, error_code);
27649 exception_exit(prev_state);
27650 }
27651 +
27652 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27653 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27654 +{
27655 + struct mm_struct *mm = current->mm;
27656 + unsigned long ip = regs->ip;
27657 +
27658 + if (v8086_mode(regs))
27659 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27660 +
27661 +#ifdef CONFIG_PAX_PAGEEXEC
27662 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27663 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27664 + return true;
27665 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27666 + return true;
27667 + return false;
27668 + }
27669 +#endif
27670 +
27671 +#ifdef CONFIG_PAX_SEGMEXEC
27672 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27673 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27674 + return true;
27675 + return false;
27676 + }
27677 +#endif
27678 +
27679 + return false;
27680 +}
27681 +#endif
27682 +
27683 +#ifdef CONFIG_PAX_EMUTRAMP
27684 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27685 +{
27686 + int err;
27687 +
27688 + do { /* PaX: libffi trampoline emulation */
27689 + unsigned char mov, jmp;
27690 + unsigned int addr1, addr2;
27691 +
27692 +#ifdef CONFIG_X86_64
27693 + if ((regs->ip + 9) >> 32)
27694 + break;
27695 +#endif
27696 +
27697 + err = get_user(mov, (unsigned char __user *)regs->ip);
27698 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27699 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27700 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27701 +
27702 + if (err)
27703 + break;
27704 +
27705 + if (mov == 0xB8 && jmp == 0xE9) {
27706 + regs->ax = addr1;
27707 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27708 + return 2;
27709 + }
27710 + } while (0);
27711 +
27712 + do { /* PaX: gcc trampoline emulation #1 */
27713 + unsigned char mov1, mov2;
27714 + unsigned short jmp;
27715 + unsigned int addr1, addr2;
27716 +
27717 +#ifdef CONFIG_X86_64
27718 + if ((regs->ip + 11) >> 32)
27719 + break;
27720 +#endif
27721 +
27722 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27723 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27724 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27725 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27726 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27727 +
27728 + if (err)
27729 + break;
27730 +
27731 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27732 + regs->cx = addr1;
27733 + regs->ax = addr2;
27734 + regs->ip = addr2;
27735 + return 2;
27736 + }
27737 + } while (0);
27738 +
27739 + do { /* PaX: gcc trampoline emulation #2 */
27740 + unsigned char mov, jmp;
27741 + unsigned int addr1, addr2;
27742 +
27743 +#ifdef CONFIG_X86_64
27744 + if ((regs->ip + 9) >> 32)
27745 + break;
27746 +#endif
27747 +
27748 + err = get_user(mov, (unsigned char __user *)regs->ip);
27749 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27750 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27751 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27752 +
27753 + if (err)
27754 + break;
27755 +
27756 + if (mov == 0xB9 && jmp == 0xE9) {
27757 + regs->cx = addr1;
27758 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27759 + return 2;
27760 + }
27761 + } while (0);
27762 +
27763 + return 1; /* PaX in action */
27764 +}
27765 +
27766 +#ifdef CONFIG_X86_64
27767 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27768 +{
27769 + int err;
27770 +
27771 + do { /* PaX: libffi trampoline emulation */
27772 + unsigned short mov1, mov2, jmp1;
27773 + unsigned char stcclc, jmp2;
27774 + unsigned long addr1, addr2;
27775 +
27776 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27777 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27778 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27779 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27780 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27781 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27782 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27783 +
27784 + if (err)
27785 + break;
27786 +
27787 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27788 + regs->r11 = addr1;
27789 + regs->r10 = addr2;
27790 + if (stcclc == 0xF8)
27791 + regs->flags &= ~X86_EFLAGS_CF;
27792 + else
27793 + regs->flags |= X86_EFLAGS_CF;
27794 + regs->ip = addr1;
27795 + return 2;
27796 + }
27797 + } while (0);
27798 +
27799 + do { /* PaX: gcc trampoline emulation #1 */
27800 + unsigned short mov1, mov2, jmp1;
27801 + unsigned char jmp2;
27802 + unsigned int addr1;
27803 + unsigned long addr2;
27804 +
27805 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27806 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27807 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27808 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27809 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27810 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27811 +
27812 + if (err)
27813 + break;
27814 +
27815 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27816 + regs->r11 = addr1;
27817 + regs->r10 = addr2;
27818 + regs->ip = addr1;
27819 + return 2;
27820 + }
27821 + } while (0);
27822 +
27823 + do { /* PaX: gcc trampoline emulation #2 */
27824 + unsigned short mov1, mov2, jmp1;
27825 + unsigned char jmp2;
27826 + unsigned long addr1, addr2;
27827 +
27828 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27829 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27830 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27831 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27832 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27833 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27834 +
27835 + if (err)
27836 + break;
27837 +
27838 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27839 + regs->r11 = addr1;
27840 + regs->r10 = addr2;
27841 + regs->ip = addr1;
27842 + return 2;
27843 + }
27844 + } while (0);
27845 +
27846 + return 1; /* PaX in action */
27847 +}
27848 +#endif
27849 +
27850 +/*
27851 + * PaX: decide what to do with offenders (regs->ip = fault address)
27852 + *
27853 + * returns 1 when task should be killed
27854 + * 2 when gcc trampoline was detected
27855 + */
27856 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27857 +{
27858 + if (v8086_mode(regs))
27859 + return 1;
27860 +
27861 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27862 + return 1;
27863 +
27864 +#ifdef CONFIG_X86_32
27865 + return pax_handle_fetch_fault_32(regs);
27866 +#else
27867 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27868 + return pax_handle_fetch_fault_32(regs);
27869 + else
27870 + return pax_handle_fetch_fault_64(regs);
27871 +#endif
27872 +}
27873 +#endif
27874 +
27875 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27876 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27877 +{
27878 + long i;
27879 +
27880 + printk(KERN_ERR "PAX: bytes at PC: ");
27881 + for (i = 0; i < 20; i++) {
27882 + unsigned char c;
27883 + if (get_user(c, (unsigned char __force_user *)pc+i))
27884 + printk(KERN_CONT "?? ");
27885 + else
27886 + printk(KERN_CONT "%02x ", c);
27887 + }
27888 + printk("\n");
27889 +
27890 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27891 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27892 + unsigned long c;
27893 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27894 +#ifdef CONFIG_X86_32
27895 + printk(KERN_CONT "???????? ");
27896 +#else
27897 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27898 + printk(KERN_CONT "???????? ???????? ");
27899 + else
27900 + printk(KERN_CONT "???????????????? ");
27901 +#endif
27902 + } else {
27903 +#ifdef CONFIG_X86_64
27904 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27905 + printk(KERN_CONT "%08x ", (unsigned int)c);
27906 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27907 + } else
27908 +#endif
27909 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27910 + }
27911 + }
27912 + printk("\n");
27913 +}
27914 +#endif
27915 +
27916 +/**
27917 + * probe_kernel_write(): safely attempt to write to a location
27918 + * @dst: address to write to
27919 + * @src: pointer to the data that shall be written
27920 + * @size: size of the data chunk
27921 + *
27922 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27923 + * happens, handle that and return -EFAULT.
27924 + */
27925 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27926 +{
27927 + long ret;
27928 + mm_segment_t old_fs = get_fs();
27929 +
27930 + set_fs(KERNEL_DS);
27931 + pagefault_disable();
27932 + pax_open_kernel();
27933 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27934 + pax_close_kernel();
27935 + pagefault_enable();
27936 + set_fs(old_fs);
27937 +
27938 + return ret ? -EFAULT : 0;
27939 +}
27940 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27941 index dd74e46..7d26398 100644
27942 --- a/arch/x86/mm/gup.c
27943 +++ b/arch/x86/mm/gup.c
27944 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27945 addr = start;
27946 len = (unsigned long) nr_pages << PAGE_SHIFT;
27947 end = start + len;
27948 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27949 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27950 (void __user *)start, len)))
27951 return 0;
27952
27953 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27954 index 252b8f5..4dcfdc1 100644
27955 --- a/arch/x86/mm/highmem_32.c
27956 +++ b/arch/x86/mm/highmem_32.c
27957 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27958 idx = type + KM_TYPE_NR*smp_processor_id();
27959 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27960 BUG_ON(!pte_none(*(kmap_pte-idx)));
27961 +
27962 + pax_open_kernel();
27963 set_pte(kmap_pte-idx, mk_pte(page, prot));
27964 + pax_close_kernel();
27965 +
27966 arch_flush_lazy_mmu_mode();
27967
27968 return (void *)vaddr;
27969 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27970 index ae1aa71..d9bea75 100644
27971 --- a/arch/x86/mm/hugetlbpage.c
27972 +++ b/arch/x86/mm/hugetlbpage.c
27973 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27974 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27975 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27976 unsigned long addr, unsigned long len,
27977 - unsigned long pgoff, unsigned long flags)
27978 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27979 {
27980 struct hstate *h = hstate_file(file);
27981 struct vm_unmapped_area_info info;
27982 -
27983 +
27984 info.flags = 0;
27985 info.length = len;
27986 info.low_limit = TASK_UNMAPPED_BASE;
27987 +
27988 +#ifdef CONFIG_PAX_RANDMMAP
27989 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27990 + info.low_limit += current->mm->delta_mmap;
27991 +#endif
27992 +
27993 info.high_limit = TASK_SIZE;
27994 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27995 info.align_offset = 0;
27996 + info.threadstack_offset = offset;
27997 return vm_unmapped_area(&info);
27998 }
27999
28000 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28001 unsigned long addr0, unsigned long len,
28002 - unsigned long pgoff, unsigned long flags)
28003 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28004 {
28005 struct hstate *h = hstate_file(file);
28006 struct vm_unmapped_area_info info;
28007 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28008 info.high_limit = current->mm->mmap_base;
28009 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28010 info.align_offset = 0;
28011 + info.threadstack_offset = offset;
28012 addr = vm_unmapped_area(&info);
28013
28014 /*
28015 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28016 VM_BUG_ON(addr != -ENOMEM);
28017 info.flags = 0;
28018 info.low_limit = TASK_UNMAPPED_BASE;
28019 +
28020 +#ifdef CONFIG_PAX_RANDMMAP
28021 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28022 + info.low_limit += current->mm->delta_mmap;
28023 +#endif
28024 +
28025 info.high_limit = TASK_SIZE;
28026 addr = vm_unmapped_area(&info);
28027 }
28028 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28029 struct hstate *h = hstate_file(file);
28030 struct mm_struct *mm = current->mm;
28031 struct vm_area_struct *vma;
28032 + unsigned long pax_task_size = TASK_SIZE;
28033 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28034
28035 if (len & ~huge_page_mask(h))
28036 return -EINVAL;
28037 - if (len > TASK_SIZE)
28038 +
28039 +#ifdef CONFIG_PAX_SEGMEXEC
28040 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28041 + pax_task_size = SEGMEXEC_TASK_SIZE;
28042 +#endif
28043 +
28044 + pax_task_size -= PAGE_SIZE;
28045 +
28046 + if (len > pax_task_size)
28047 return -ENOMEM;
28048
28049 if (flags & MAP_FIXED) {
28050 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28051 return addr;
28052 }
28053
28054 +#ifdef CONFIG_PAX_RANDMMAP
28055 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28056 +#endif
28057 +
28058 if (addr) {
28059 addr = ALIGN(addr, huge_page_size(h));
28060 vma = find_vma(mm, addr);
28061 - if (TASK_SIZE - len >= addr &&
28062 - (!vma || addr + len <= vma->vm_start))
28063 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28064 return addr;
28065 }
28066 if (mm->get_unmapped_area == arch_get_unmapped_area)
28067 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28068 - pgoff, flags);
28069 + pgoff, flags, offset);
28070 else
28071 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28072 - pgoff, flags);
28073 + pgoff, flags, offset);
28074 }
28075
28076 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28077 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28078 index 1f34e92..d252637 100644
28079 --- a/arch/x86/mm/init.c
28080 +++ b/arch/x86/mm/init.c
28081 @@ -4,6 +4,7 @@
28082 #include <linux/swap.h>
28083 #include <linux/memblock.h>
28084 #include <linux/bootmem.h> /* for max_low_pfn */
28085 +#include <linux/tboot.h>
28086
28087 #include <asm/cacheflush.h>
28088 #include <asm/e820.h>
28089 @@ -17,6 +18,8 @@
28090 #include <asm/proto.h>
28091 #include <asm/dma.h> /* for MAX_DMA_PFN */
28092 #include <asm/microcode.h>
28093 +#include <asm/desc.h>
28094 +#include <asm/bios_ebda.h>
28095
28096 #include "mm_internal.h"
28097
28098 @@ -465,7 +468,15 @@ void __init init_mem_mapping(void)
28099 early_ioremap_page_table_range_init();
28100 #endif
28101
28102 +#ifdef CONFIG_PAX_PER_CPU_PGD
28103 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28104 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28105 + KERNEL_PGD_PTRS);
28106 + load_cr3(get_cpu_pgd(0));
28107 +#else
28108 load_cr3(swapper_pg_dir);
28109 +#endif
28110 +
28111 __flush_tlb_all();
28112
28113 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
28114 @@ -481,10 +492,40 @@ void __init init_mem_mapping(void)
28115 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28116 * mmio resources as well as potential bios/acpi data regions.
28117 */
28118 +
28119 +#ifdef CONFIG_GRKERNSEC_KMEM
28120 +static unsigned int ebda_start __read_only;
28121 +static unsigned int ebda_end __read_only;
28122 +#endif
28123 +
28124 int devmem_is_allowed(unsigned long pagenr)
28125 {
28126 - if (pagenr < 256)
28127 +#ifdef CONFIG_GRKERNSEC_KMEM
28128 + /* allow BDA */
28129 + if (!pagenr)
28130 return 1;
28131 + /* allow EBDA */
28132 + if (pagenr >= ebda_start && pagenr < ebda_end)
28133 + return 1;
28134 + /* if tboot is in use, allow access to its hardcoded serial log range */
28135 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28136 + return 1;
28137 +#else
28138 + if (!pagenr)
28139 + return 1;
28140 +#ifdef CONFIG_VM86
28141 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28142 + return 1;
28143 +#endif
28144 +#endif
28145 +
28146 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28147 + return 1;
28148 +#ifdef CONFIG_GRKERNSEC_KMEM
28149 + /* throw out everything else below 1MB */
28150 + if (pagenr <= 256)
28151 + return 0;
28152 +#endif
28153 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28154 return 0;
28155 if (!page_is_ram(pagenr))
28156 @@ -538,8 +579,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28157 #endif
28158 }
28159
28160 +#ifdef CONFIG_GRKERNSEC_KMEM
28161 +static inline void gr_init_ebda(void)
28162 +{
28163 + unsigned int ebda_addr;
28164 + unsigned int ebda_size = 0;
28165 +
28166 + ebda_addr = get_bios_ebda();
28167 + if (ebda_addr) {
28168 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28169 + ebda_size <<= 10;
28170 + }
28171 + if (ebda_addr && ebda_size) {
28172 + ebda_start = ebda_addr >> PAGE_SHIFT;
28173 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28174 + } else {
28175 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28176 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28177 + }
28178 +}
28179 +#else
28180 +static inline void gr_init_ebda(void) { }
28181 +#endif
28182 +
28183 void free_initmem(void)
28184 {
28185 +#ifdef CONFIG_PAX_KERNEXEC
28186 +#ifdef CONFIG_X86_32
28187 + /* PaX: limit KERNEL_CS to actual size */
28188 + unsigned long addr, limit;
28189 + struct desc_struct d;
28190 + int cpu;
28191 +#else
28192 + pgd_t *pgd;
28193 + pud_t *pud;
28194 + pmd_t *pmd;
28195 + unsigned long addr, end;
28196 +#endif
28197 +#endif
28198 +
28199 + gr_init_ebda();
28200 +
28201 +#ifdef CONFIG_PAX_KERNEXEC
28202 +#ifdef CONFIG_X86_32
28203 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28204 + limit = (limit - 1UL) >> PAGE_SHIFT;
28205 +
28206 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28207 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28208 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28209 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28210 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28211 + }
28212 +
28213 + /* PaX: make KERNEL_CS read-only */
28214 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28215 + if (!paravirt_enabled())
28216 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28217 +/*
28218 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28219 + pgd = pgd_offset_k(addr);
28220 + pud = pud_offset(pgd, addr);
28221 + pmd = pmd_offset(pud, addr);
28222 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28223 + }
28224 +*/
28225 +#ifdef CONFIG_X86_PAE
28226 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28227 +/*
28228 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28229 + pgd = pgd_offset_k(addr);
28230 + pud = pud_offset(pgd, addr);
28231 + pmd = pmd_offset(pud, addr);
28232 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28233 + }
28234 +*/
28235 +#endif
28236 +
28237 +#ifdef CONFIG_MODULES
28238 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28239 +#endif
28240 +
28241 +#else
28242 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28243 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28244 + pgd = pgd_offset_k(addr);
28245 + pud = pud_offset(pgd, addr);
28246 + pmd = pmd_offset(pud, addr);
28247 + if (!pmd_present(*pmd))
28248 + continue;
28249 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28250 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28251 + else
28252 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28253 + }
28254 +
28255 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28256 + end = addr + KERNEL_IMAGE_SIZE;
28257 + for (; addr < end; addr += PMD_SIZE) {
28258 + pgd = pgd_offset_k(addr);
28259 + pud = pud_offset(pgd, addr);
28260 + pmd = pmd_offset(pud, addr);
28261 + if (!pmd_present(*pmd))
28262 + continue;
28263 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28264 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28265 + }
28266 +#endif
28267 +
28268 + flush_tlb_all();
28269 +#endif
28270 +
28271 free_init_pages("unused kernel memory",
28272 (unsigned long)(&__init_begin),
28273 (unsigned long)(&__init_end));
28274 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28275 index 3ac7e31..89611b7 100644
28276 --- a/arch/x86/mm/init_32.c
28277 +++ b/arch/x86/mm/init_32.c
28278 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28279 bool __read_mostly __vmalloc_start_set = false;
28280
28281 /*
28282 - * Creates a middle page table and puts a pointer to it in the
28283 - * given global directory entry. This only returns the gd entry
28284 - * in non-PAE compilation mode, since the middle layer is folded.
28285 - */
28286 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28287 -{
28288 - pud_t *pud;
28289 - pmd_t *pmd_table;
28290 -
28291 -#ifdef CONFIG_X86_PAE
28292 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28293 - pmd_table = (pmd_t *)alloc_low_page();
28294 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28295 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28296 - pud = pud_offset(pgd, 0);
28297 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28298 -
28299 - return pmd_table;
28300 - }
28301 -#endif
28302 - pud = pud_offset(pgd, 0);
28303 - pmd_table = pmd_offset(pud, 0);
28304 -
28305 - return pmd_table;
28306 -}
28307 -
28308 -/*
28309 * Create a page table and place a pointer to it in a middle page
28310 * directory entry:
28311 */
28312 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28313 pte_t *page_table = (pte_t *)alloc_low_page();
28314
28315 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28316 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28317 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28318 +#else
28319 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28320 +#endif
28321 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28322 }
28323
28324 return pte_offset_kernel(pmd, 0);
28325 }
28326
28327 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28328 +{
28329 + pud_t *pud;
28330 + pmd_t *pmd_table;
28331 +
28332 + pud = pud_offset(pgd, 0);
28333 + pmd_table = pmd_offset(pud, 0);
28334 +
28335 + return pmd_table;
28336 +}
28337 +
28338 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28339 {
28340 int pgd_idx = pgd_index(vaddr);
28341 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28342 int pgd_idx, pmd_idx;
28343 unsigned long vaddr;
28344 pgd_t *pgd;
28345 + pud_t *pud;
28346 pmd_t *pmd;
28347 pte_t *pte = NULL;
28348 unsigned long count = page_table_range_init_count(start, end);
28349 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28350 pgd = pgd_base + pgd_idx;
28351
28352 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28353 - pmd = one_md_table_init(pgd);
28354 - pmd = pmd + pmd_index(vaddr);
28355 + pud = pud_offset(pgd, vaddr);
28356 + pmd = pmd_offset(pud, vaddr);
28357 +
28358 +#ifdef CONFIG_X86_PAE
28359 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28360 +#endif
28361 +
28362 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28363 pmd++, pmd_idx++) {
28364 pte = page_table_kmap_check(one_page_table_init(pmd),
28365 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28366 }
28367 }
28368
28369 -static inline int is_kernel_text(unsigned long addr)
28370 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28371 {
28372 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28373 - return 1;
28374 - return 0;
28375 + if ((start > ktla_ktva((unsigned long)_etext) ||
28376 + end <= ktla_ktva((unsigned long)_stext)) &&
28377 + (start > ktla_ktva((unsigned long)_einittext) ||
28378 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28379 +
28380 +#ifdef CONFIG_ACPI_SLEEP
28381 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28382 +#endif
28383 +
28384 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28385 + return 0;
28386 + return 1;
28387 }
28388
28389 /*
28390 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28391 unsigned long last_map_addr = end;
28392 unsigned long start_pfn, end_pfn;
28393 pgd_t *pgd_base = swapper_pg_dir;
28394 - int pgd_idx, pmd_idx, pte_ofs;
28395 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28396 unsigned long pfn;
28397 pgd_t *pgd;
28398 + pud_t *pud;
28399 pmd_t *pmd;
28400 pte_t *pte;
28401 unsigned pages_2m, pages_4k;
28402 @@ -291,8 +295,13 @@ repeat:
28403 pfn = start_pfn;
28404 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28405 pgd = pgd_base + pgd_idx;
28406 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28407 - pmd = one_md_table_init(pgd);
28408 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28409 + pud = pud_offset(pgd, 0);
28410 + pmd = pmd_offset(pud, 0);
28411 +
28412 +#ifdef CONFIG_X86_PAE
28413 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28414 +#endif
28415
28416 if (pfn >= end_pfn)
28417 continue;
28418 @@ -304,14 +313,13 @@ repeat:
28419 #endif
28420 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28421 pmd++, pmd_idx++) {
28422 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28423 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28424
28425 /*
28426 * Map with big pages if possible, otherwise
28427 * create normal page tables:
28428 */
28429 if (use_pse) {
28430 - unsigned int addr2;
28431 pgprot_t prot = PAGE_KERNEL_LARGE;
28432 /*
28433 * first pass will use the same initial
28434 @@ -322,11 +330,7 @@ repeat:
28435 _PAGE_PSE);
28436
28437 pfn &= PMD_MASK >> PAGE_SHIFT;
28438 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28439 - PAGE_OFFSET + PAGE_SIZE-1;
28440 -
28441 - if (is_kernel_text(addr) ||
28442 - is_kernel_text(addr2))
28443 + if (is_kernel_text(address, address + PMD_SIZE))
28444 prot = PAGE_KERNEL_LARGE_EXEC;
28445
28446 pages_2m++;
28447 @@ -343,7 +347,7 @@ repeat:
28448 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28449 pte += pte_ofs;
28450 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28451 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28452 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28453 pgprot_t prot = PAGE_KERNEL;
28454 /*
28455 * first pass will use the same initial
28456 @@ -351,7 +355,7 @@ repeat:
28457 */
28458 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28459
28460 - if (is_kernel_text(addr))
28461 + if (is_kernel_text(address, address + PAGE_SIZE))
28462 prot = PAGE_KERNEL_EXEC;
28463
28464 pages_4k++;
28465 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
28466
28467 pud = pud_offset(pgd, va);
28468 pmd = pmd_offset(pud, va);
28469 - if (!pmd_present(*pmd))
28470 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28471 break;
28472
28473 /* should not be large page here */
28474 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
28475
28476 static void __init pagetable_init(void)
28477 {
28478 - pgd_t *pgd_base = swapper_pg_dir;
28479 -
28480 - permanent_kmaps_init(pgd_base);
28481 + permanent_kmaps_init(swapper_pg_dir);
28482 }
28483
28484 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28485 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28486 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28487
28488 /* user-defined highmem size */
28489 @@ -772,7 +774,7 @@ void __init mem_init(void)
28490 after_bootmem = 1;
28491
28492 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28493 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28494 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28495 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28496
28497 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28498 @@ -813,10 +815,10 @@ void __init mem_init(void)
28499 ((unsigned long)&__init_end -
28500 (unsigned long)&__init_begin) >> 10,
28501
28502 - (unsigned long)&_etext, (unsigned long)&_edata,
28503 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28504 + (unsigned long)&_sdata, (unsigned long)&_edata,
28505 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28506
28507 - (unsigned long)&_text, (unsigned long)&_etext,
28508 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28509 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28510
28511 /*
28512 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
28513 if (!kernel_set_to_readonly)
28514 return;
28515
28516 + start = ktla_ktva(start);
28517 pr_debug("Set kernel text: %lx - %lx for read write\n",
28518 start, start+size);
28519
28520 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
28521 if (!kernel_set_to_readonly)
28522 return;
28523
28524 + start = ktla_ktva(start);
28525 pr_debug("Set kernel text: %lx - %lx for read only\n",
28526 start, start+size);
28527
28528 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
28529 unsigned long start = PFN_ALIGN(_text);
28530 unsigned long size = PFN_ALIGN(_etext) - start;
28531
28532 + start = ktla_ktva(start);
28533 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28534 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28535 size >> 10);
28536 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28537 index bb00c46..f31d2f0 100644
28538 --- a/arch/x86/mm/init_64.c
28539 +++ b/arch/x86/mm/init_64.c
28540 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28541 * around without checking the pgd every time.
28542 */
28543
28544 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28545 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28546 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28547
28548 int force_personality32;
28549 @@ -184,12 +184,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28550
28551 for (address = start; address <= end; address += PGDIR_SIZE) {
28552 const pgd_t *pgd_ref = pgd_offset_k(address);
28553 +
28554 +#ifdef CONFIG_PAX_PER_CPU_PGD
28555 + unsigned long cpu;
28556 +#else
28557 struct page *page;
28558 +#endif
28559
28560 if (pgd_none(*pgd_ref))
28561 continue;
28562
28563 spin_lock(&pgd_lock);
28564 +
28565 +#ifdef CONFIG_PAX_PER_CPU_PGD
28566 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28567 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28568 +#else
28569 list_for_each_entry(page, &pgd_list, lru) {
28570 pgd_t *pgd;
28571 spinlock_t *pgt_lock;
28572 @@ -198,6 +208,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28573 /* the pgt_lock only for Xen */
28574 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28575 spin_lock(pgt_lock);
28576 +#endif
28577
28578 if (pgd_none(*pgd))
28579 set_pgd(pgd, *pgd_ref);
28580 @@ -205,7 +216,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28581 BUG_ON(pgd_page_vaddr(*pgd)
28582 != pgd_page_vaddr(*pgd_ref));
28583
28584 +#ifndef CONFIG_PAX_PER_CPU_PGD
28585 spin_unlock(pgt_lock);
28586 +#endif
28587 +
28588 }
28589 spin_unlock(&pgd_lock);
28590 }
28591 @@ -238,7 +252,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28592 {
28593 if (pgd_none(*pgd)) {
28594 pud_t *pud = (pud_t *)spp_getpage();
28595 - pgd_populate(&init_mm, pgd, pud);
28596 + pgd_populate_kernel(&init_mm, pgd, pud);
28597 if (pud != pud_offset(pgd, 0))
28598 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28599 pud, pud_offset(pgd, 0));
28600 @@ -250,7 +264,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28601 {
28602 if (pud_none(*pud)) {
28603 pmd_t *pmd = (pmd_t *) spp_getpage();
28604 - pud_populate(&init_mm, pud, pmd);
28605 + pud_populate_kernel(&init_mm, pud, pmd);
28606 if (pmd != pmd_offset(pud, 0))
28607 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28608 pmd, pmd_offset(pud, 0));
28609 @@ -279,7 +293,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28610 pmd = fill_pmd(pud, vaddr);
28611 pte = fill_pte(pmd, vaddr);
28612
28613 + pax_open_kernel();
28614 set_pte(pte, new_pte);
28615 + pax_close_kernel();
28616
28617 /*
28618 * It's enough to flush this one mapping.
28619 @@ -338,14 +354,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28620 pgd = pgd_offset_k((unsigned long)__va(phys));
28621 if (pgd_none(*pgd)) {
28622 pud = (pud_t *) spp_getpage();
28623 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28624 - _PAGE_USER));
28625 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28626 }
28627 pud = pud_offset(pgd, (unsigned long)__va(phys));
28628 if (pud_none(*pud)) {
28629 pmd = (pmd_t *) spp_getpage();
28630 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28631 - _PAGE_USER));
28632 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28633 }
28634 pmd = pmd_offset(pud, phys);
28635 BUG_ON(!pmd_none(*pmd));
28636 @@ -586,7 +600,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28637 prot);
28638
28639 spin_lock(&init_mm.page_table_lock);
28640 - pud_populate(&init_mm, pud, pmd);
28641 + pud_populate_kernel(&init_mm, pud, pmd);
28642 spin_unlock(&init_mm.page_table_lock);
28643 }
28644 __flush_tlb_all();
28645 @@ -627,7 +641,7 @@ kernel_physical_mapping_init(unsigned long start,
28646 page_size_mask);
28647
28648 spin_lock(&init_mm.page_table_lock);
28649 - pgd_populate(&init_mm, pgd, pud);
28650 + pgd_populate_kernel(&init_mm, pgd, pud);
28651 spin_unlock(&init_mm.page_table_lock);
28652 pgd_changed = true;
28653 }
28654 @@ -1221,8 +1235,8 @@ int kern_addr_valid(unsigned long addr)
28655 static struct vm_area_struct gate_vma = {
28656 .vm_start = VSYSCALL_START,
28657 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28658 - .vm_page_prot = PAGE_READONLY_EXEC,
28659 - .vm_flags = VM_READ | VM_EXEC
28660 + .vm_page_prot = PAGE_READONLY,
28661 + .vm_flags = VM_READ
28662 };
28663
28664 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28665 @@ -1256,7 +1270,7 @@ int in_gate_area_no_mm(unsigned long addr)
28666
28667 const char *arch_vma_name(struct vm_area_struct *vma)
28668 {
28669 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28670 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28671 return "[vdso]";
28672 if (vma == &gate_vma)
28673 return "[vsyscall]";
28674 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28675 index 7b179b4..6bd17777 100644
28676 --- a/arch/x86/mm/iomap_32.c
28677 +++ b/arch/x86/mm/iomap_32.c
28678 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28679 type = kmap_atomic_idx_push();
28680 idx = type + KM_TYPE_NR * smp_processor_id();
28681 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28682 +
28683 + pax_open_kernel();
28684 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28685 + pax_close_kernel();
28686 +
28687 arch_flush_lazy_mmu_mode();
28688
28689 return (void *)vaddr;
28690 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28691 index 9a1e658..da003f3 100644
28692 --- a/arch/x86/mm/ioremap.c
28693 +++ b/arch/x86/mm/ioremap.c
28694 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28695 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28696 int is_ram = page_is_ram(pfn);
28697
28698 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28699 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28700 return NULL;
28701 WARN_ON_ONCE(is_ram);
28702 }
28703 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28704 *
28705 * Caller must ensure there is only one unmapping for the same pointer.
28706 */
28707 -void iounmap(volatile void __iomem *addr)
28708 +void iounmap(const volatile void __iomem *addr)
28709 {
28710 struct vm_struct *p, *o;
28711
28712 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28713
28714 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28715 if (page_is_ram(start >> PAGE_SHIFT))
28716 +#ifdef CONFIG_HIGHMEM
28717 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28718 +#endif
28719 return __va(phys);
28720
28721 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28722 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28723 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28724 {
28725 if (page_is_ram(phys >> PAGE_SHIFT))
28726 +#ifdef CONFIG_HIGHMEM
28727 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28728 +#endif
28729 return;
28730
28731 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28732 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
28733 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28734
28735 static __initdata int after_paging_init;
28736 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28737 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28738
28739 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28740 {
28741 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
28742 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28743
28744 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28745 - memset(bm_pte, 0, sizeof(bm_pte));
28746 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28747 + pmd_populate_user(&init_mm, pmd, bm_pte);
28748
28749 /*
28750 * The boot-ioremap range spans multiple pmds, for which
28751 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28752 index d87dd6d..bf3fa66 100644
28753 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28754 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28755 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28756 * memory (e.g. tracked pages)? For now, we need this to avoid
28757 * invoking kmemcheck for PnP BIOS calls.
28758 */
28759 - if (regs->flags & X86_VM_MASK)
28760 + if (v8086_mode(regs))
28761 return false;
28762 - if (regs->cs != __KERNEL_CS)
28763 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28764 return false;
28765
28766 pte = kmemcheck_pte_lookup(address);
28767 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28768 index 845df68..1d8d29f 100644
28769 --- a/arch/x86/mm/mmap.c
28770 +++ b/arch/x86/mm/mmap.c
28771 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28772 * Leave an at least ~128 MB hole with possible stack randomization.
28773 */
28774 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28775 -#define MAX_GAP (TASK_SIZE/6*5)
28776 +#define MAX_GAP (pax_task_size/6*5)
28777
28778 static int mmap_is_legacy(void)
28779 {
28780 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28781 return rnd << PAGE_SHIFT;
28782 }
28783
28784 -static unsigned long mmap_base(void)
28785 +static unsigned long mmap_base(struct mm_struct *mm)
28786 {
28787 unsigned long gap = rlimit(RLIMIT_STACK);
28788 + unsigned long pax_task_size = TASK_SIZE;
28789 +
28790 +#ifdef CONFIG_PAX_SEGMEXEC
28791 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28792 + pax_task_size = SEGMEXEC_TASK_SIZE;
28793 +#endif
28794
28795 if (gap < MIN_GAP)
28796 gap = MIN_GAP;
28797 else if (gap > MAX_GAP)
28798 gap = MAX_GAP;
28799
28800 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28801 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28802 }
28803
28804 /*
28805 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28806 * does, but not when emulating X86_32
28807 */
28808 -static unsigned long mmap_legacy_base(void)
28809 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28810 {
28811 - if (mmap_is_ia32())
28812 + if (mmap_is_ia32()) {
28813 +
28814 +#ifdef CONFIG_PAX_SEGMEXEC
28815 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28816 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28817 + else
28818 +#endif
28819 +
28820 return TASK_UNMAPPED_BASE;
28821 - else
28822 + } else
28823 return TASK_UNMAPPED_BASE + mmap_rnd();
28824 }
28825
28826 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28827 void arch_pick_mmap_layout(struct mm_struct *mm)
28828 {
28829 if (mmap_is_legacy()) {
28830 - mm->mmap_base = mmap_legacy_base();
28831 + mm->mmap_base = mmap_legacy_base(mm);
28832 +
28833 +#ifdef CONFIG_PAX_RANDMMAP
28834 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28835 + mm->mmap_base += mm->delta_mmap;
28836 +#endif
28837 +
28838 mm->get_unmapped_area = arch_get_unmapped_area;
28839 mm->unmap_area = arch_unmap_area;
28840 } else {
28841 - mm->mmap_base = mmap_base();
28842 + mm->mmap_base = mmap_base(mm);
28843 +
28844 +#ifdef CONFIG_PAX_RANDMMAP
28845 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28846 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28847 +#endif
28848 +
28849 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28850 mm->unmap_area = arch_unmap_area_topdown;
28851 }
28852 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28853 index dc0b727..f612039 100644
28854 --- a/arch/x86/mm/mmio-mod.c
28855 +++ b/arch/x86/mm/mmio-mod.c
28856 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28857 break;
28858 default:
28859 {
28860 - unsigned char *ip = (unsigned char *)instptr;
28861 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28862 my_trace->opcode = MMIO_UNKNOWN_OP;
28863 my_trace->width = 0;
28864 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28865 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28866 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28867 void __iomem *addr)
28868 {
28869 - static atomic_t next_id;
28870 + static atomic_unchecked_t next_id;
28871 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28872 /* These are page-unaligned. */
28873 struct mmiotrace_map map = {
28874 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28875 .private = trace
28876 },
28877 .phys = offset,
28878 - .id = atomic_inc_return(&next_id)
28879 + .id = atomic_inc_return_unchecked(&next_id)
28880 };
28881 map.map_id = trace->id;
28882
28883 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28884 ioremap_trace_core(offset, size, addr);
28885 }
28886
28887 -static void iounmap_trace_core(volatile void __iomem *addr)
28888 +static void iounmap_trace_core(const volatile void __iomem *addr)
28889 {
28890 struct mmiotrace_map map = {
28891 .phys = 0,
28892 @@ -328,7 +328,7 @@ not_enabled:
28893 }
28894 }
28895
28896 -void mmiotrace_iounmap(volatile void __iomem *addr)
28897 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28898 {
28899 might_sleep();
28900 if (is_enabled()) /* recheck and proper locking in *_core() */
28901 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28902 index a71c4e2..301ae44 100644
28903 --- a/arch/x86/mm/numa.c
28904 +++ b/arch/x86/mm/numa.c
28905 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28906 return true;
28907 }
28908
28909 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28910 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28911 {
28912 unsigned long uninitialized_var(pfn_align);
28913 int i, nid;
28914 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28915 index d0b1773..4c3327c 100644
28916 --- a/arch/x86/mm/pageattr-test.c
28917 +++ b/arch/x86/mm/pageattr-test.c
28918 @@ -36,7 +36,7 @@ enum {
28919
28920 static int pte_testbit(pte_t pte)
28921 {
28922 - return pte_flags(pte) & _PAGE_UNUSED1;
28923 + return pte_flags(pte) & _PAGE_CPA_TEST;
28924 }
28925
28926 struct split_state {
28927 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28928 index bb32480..aef8278 100644
28929 --- a/arch/x86/mm/pageattr.c
28930 +++ b/arch/x86/mm/pageattr.c
28931 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28932 */
28933 #ifdef CONFIG_PCI_BIOS
28934 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28935 - pgprot_val(forbidden) |= _PAGE_NX;
28936 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28937 #endif
28938
28939 /*
28940 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28941 * Does not cover __inittext since that is gone later on. On
28942 * 64bit we do not enforce !NX on the low mapping
28943 */
28944 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28945 - pgprot_val(forbidden) |= _PAGE_NX;
28946 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28947 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28948
28949 +#ifdef CONFIG_DEBUG_RODATA
28950 /*
28951 * The .rodata section needs to be read-only. Using the pfn
28952 * catches all aliases.
28953 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28954 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28955 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28956 pgprot_val(forbidden) |= _PAGE_RW;
28957 +#endif
28958
28959 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28960 /*
28961 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28962 }
28963 #endif
28964
28965 +#ifdef CONFIG_PAX_KERNEXEC
28966 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28967 + pgprot_val(forbidden) |= _PAGE_RW;
28968 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28969 + }
28970 +#endif
28971 +
28972 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28973
28974 return prot;
28975 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28976 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28977 {
28978 /* change init_mm */
28979 + pax_open_kernel();
28980 set_pte_atomic(kpte, pte);
28981 +
28982 #ifdef CONFIG_X86_32
28983 if (!SHARED_KERNEL_PMD) {
28984 +
28985 +#ifdef CONFIG_PAX_PER_CPU_PGD
28986 + unsigned long cpu;
28987 +#else
28988 struct page *page;
28989 +#endif
28990
28991 +#ifdef CONFIG_PAX_PER_CPU_PGD
28992 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28993 + pgd_t *pgd = get_cpu_pgd(cpu);
28994 +#else
28995 list_for_each_entry(page, &pgd_list, lru) {
28996 - pgd_t *pgd;
28997 + pgd_t *pgd = (pgd_t *)page_address(page);
28998 +#endif
28999 +
29000 pud_t *pud;
29001 pmd_t *pmd;
29002
29003 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29004 + pgd += pgd_index(address);
29005 pud = pud_offset(pgd, address);
29006 pmd = pmd_offset(pud, address);
29007 set_pte_atomic((pte_t *)pmd, pte);
29008 }
29009 }
29010 #endif
29011 + pax_close_kernel();
29012 }
29013
29014 static int
29015 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29016 index 6574388..87e9bef 100644
29017 --- a/arch/x86/mm/pat.c
29018 +++ b/arch/x86/mm/pat.c
29019 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29020
29021 if (!entry) {
29022 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29023 - current->comm, current->pid, start, end - 1);
29024 + current->comm, task_pid_nr(current), start, end - 1);
29025 return -EINVAL;
29026 }
29027
29028 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29029
29030 while (cursor < to) {
29031 if (!devmem_is_allowed(pfn)) {
29032 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29033 - current->comm, from, to - 1);
29034 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29035 + current->comm, from, to - 1, cursor);
29036 return 0;
29037 }
29038 cursor += PAGE_SIZE;
29039 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29040 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29041 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29042 "for [mem %#010Lx-%#010Lx]\n",
29043 - current->comm, current->pid,
29044 + current->comm, task_pid_nr(current),
29045 cattr_name(flags),
29046 base, (unsigned long long)(base + size-1));
29047 return -EINVAL;
29048 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29049 flags = lookup_memtype(paddr);
29050 if (want_flags != flags) {
29051 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29052 - current->comm, current->pid,
29053 + current->comm, task_pid_nr(current),
29054 cattr_name(want_flags),
29055 (unsigned long long)paddr,
29056 (unsigned long long)(paddr + size - 1),
29057 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29058 free_memtype(paddr, paddr + size);
29059 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29060 " for [mem %#010Lx-%#010Lx], got %s\n",
29061 - current->comm, current->pid,
29062 + current->comm, task_pid_nr(current),
29063 cattr_name(want_flags),
29064 (unsigned long long)paddr,
29065 (unsigned long long)(paddr + size - 1),
29066 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
29067 index 415f6c4..d319983 100644
29068 --- a/arch/x86/mm/pat_rbtree.c
29069 +++ b/arch/x86/mm/pat_rbtree.c
29070 @@ -160,7 +160,7 @@ success:
29071
29072 failure:
29073 printk(KERN_INFO "%s:%d conflicting memory types "
29074 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
29075 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
29076 end, cattr_name(found_type), cattr_name(match->type));
29077 return -EBUSY;
29078 }
29079 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29080 index 9f0614d..92ae64a 100644
29081 --- a/arch/x86/mm/pf_in.c
29082 +++ b/arch/x86/mm/pf_in.c
29083 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29084 int i;
29085 enum reason_type rv = OTHERS;
29086
29087 - p = (unsigned char *)ins_addr;
29088 + p = (unsigned char *)ktla_ktva(ins_addr);
29089 p += skip_prefix(p, &prf);
29090 p += get_opcode(p, &opcode);
29091
29092 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29093 struct prefix_bits prf;
29094 int i;
29095
29096 - p = (unsigned char *)ins_addr;
29097 + p = (unsigned char *)ktla_ktva(ins_addr);
29098 p += skip_prefix(p, &prf);
29099 p += get_opcode(p, &opcode);
29100
29101 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29102 struct prefix_bits prf;
29103 int i;
29104
29105 - p = (unsigned char *)ins_addr;
29106 + p = (unsigned char *)ktla_ktva(ins_addr);
29107 p += skip_prefix(p, &prf);
29108 p += get_opcode(p, &opcode);
29109
29110 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29111 struct prefix_bits prf;
29112 int i;
29113
29114 - p = (unsigned char *)ins_addr;
29115 + p = (unsigned char *)ktla_ktva(ins_addr);
29116 p += skip_prefix(p, &prf);
29117 p += get_opcode(p, &opcode);
29118 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29119 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29120 struct prefix_bits prf;
29121 int i;
29122
29123 - p = (unsigned char *)ins_addr;
29124 + p = (unsigned char *)ktla_ktva(ins_addr);
29125 p += skip_prefix(p, &prf);
29126 p += get_opcode(p, &opcode);
29127 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29128 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29129 index 17fda6a..489c74a 100644
29130 --- a/arch/x86/mm/pgtable.c
29131 +++ b/arch/x86/mm/pgtable.c
29132 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29133 list_del(&page->lru);
29134 }
29135
29136 -#define UNSHARED_PTRS_PER_PGD \
29137 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29138 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29139 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29140
29141 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29142 +{
29143 + unsigned int count = USER_PGD_PTRS;
29144
29145 + while (count--)
29146 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29147 +}
29148 +#endif
29149 +
29150 +#ifdef CONFIG_PAX_PER_CPU_PGD
29151 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29152 +{
29153 + unsigned int count = USER_PGD_PTRS;
29154 +
29155 + while (count--) {
29156 + pgd_t pgd;
29157 +
29158 +#ifdef CONFIG_X86_64
29159 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29160 +#else
29161 + pgd = *src++;
29162 +#endif
29163 +
29164 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29165 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29166 +#endif
29167 +
29168 + *dst++ = pgd;
29169 + }
29170 +
29171 +}
29172 +#endif
29173 +
29174 +#ifdef CONFIG_X86_64
29175 +#define pxd_t pud_t
29176 +#define pyd_t pgd_t
29177 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29178 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29179 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29180 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29181 +#define PYD_SIZE PGDIR_SIZE
29182 +#else
29183 +#define pxd_t pmd_t
29184 +#define pyd_t pud_t
29185 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29186 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29187 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29188 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29189 +#define PYD_SIZE PUD_SIZE
29190 +#endif
29191 +
29192 +#ifdef CONFIG_PAX_PER_CPU_PGD
29193 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29194 +static inline void pgd_dtor(pgd_t *pgd) {}
29195 +#else
29196 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29197 {
29198 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29199 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29200 pgd_list_del(pgd);
29201 spin_unlock(&pgd_lock);
29202 }
29203 +#endif
29204
29205 /*
29206 * List of all pgd's needed for non-PAE so it can invalidate entries
29207 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29208 * -- nyc
29209 */
29210
29211 -#ifdef CONFIG_X86_PAE
29212 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29213 /*
29214 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29215 * updating the top-level pagetable entries to guarantee the
29216 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29217 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29218 * and initialize the kernel pmds here.
29219 */
29220 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29221 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29222
29223 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29224 {
29225 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29226 */
29227 flush_tlb_mm(mm);
29228 }
29229 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29230 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29231 #else /* !CONFIG_X86_PAE */
29232
29233 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29234 -#define PREALLOCATED_PMDS 0
29235 +#define PREALLOCATED_PXDS 0
29236
29237 #endif /* CONFIG_X86_PAE */
29238
29239 -static void free_pmds(pmd_t *pmds[])
29240 +static void free_pxds(pxd_t *pxds[])
29241 {
29242 int i;
29243
29244 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29245 - if (pmds[i])
29246 - free_page((unsigned long)pmds[i]);
29247 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29248 + if (pxds[i])
29249 + free_page((unsigned long)pxds[i]);
29250 }
29251
29252 -static int preallocate_pmds(pmd_t *pmds[])
29253 +static int preallocate_pxds(pxd_t *pxds[])
29254 {
29255 int i;
29256 bool failed = false;
29257
29258 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29259 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29260 - if (pmd == NULL)
29261 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29262 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29263 + if (pxd == NULL)
29264 failed = true;
29265 - pmds[i] = pmd;
29266 + pxds[i] = pxd;
29267 }
29268
29269 if (failed) {
29270 - free_pmds(pmds);
29271 + free_pxds(pxds);
29272 return -ENOMEM;
29273 }
29274
29275 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29276 * preallocate which never got a corresponding vma will need to be
29277 * freed manually.
29278 */
29279 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29280 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29281 {
29282 int i;
29283
29284 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29285 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29286 pgd_t pgd = pgdp[i];
29287
29288 if (pgd_val(pgd) != 0) {
29289 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29290 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29291
29292 - pgdp[i] = native_make_pgd(0);
29293 + set_pgd(pgdp + i, native_make_pgd(0));
29294
29295 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29296 - pmd_free(mm, pmd);
29297 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29298 + pxd_free(mm, pxd);
29299 }
29300 }
29301 }
29302
29303 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29304 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29305 {
29306 - pud_t *pud;
29307 + pyd_t *pyd;
29308 unsigned long addr;
29309 int i;
29310
29311 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29312 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29313 return;
29314
29315 - pud = pud_offset(pgd, 0);
29316 +#ifdef CONFIG_X86_64
29317 + pyd = pyd_offset(mm, 0L);
29318 +#else
29319 + pyd = pyd_offset(pgd, 0L);
29320 +#endif
29321
29322 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29323 - i++, pud++, addr += PUD_SIZE) {
29324 - pmd_t *pmd = pmds[i];
29325 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29326 + i++, pyd++, addr += PYD_SIZE) {
29327 + pxd_t *pxd = pxds[i];
29328
29329 if (i >= KERNEL_PGD_BOUNDARY)
29330 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29331 - sizeof(pmd_t) * PTRS_PER_PMD);
29332 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29333 + sizeof(pxd_t) * PTRS_PER_PMD);
29334
29335 - pud_populate(mm, pud, pmd);
29336 + pyd_populate(mm, pyd, pxd);
29337 }
29338 }
29339
29340 pgd_t *pgd_alloc(struct mm_struct *mm)
29341 {
29342 pgd_t *pgd;
29343 - pmd_t *pmds[PREALLOCATED_PMDS];
29344 + pxd_t *pxds[PREALLOCATED_PXDS];
29345
29346 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29347
29348 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29349
29350 mm->pgd = pgd;
29351
29352 - if (preallocate_pmds(pmds) != 0)
29353 + if (preallocate_pxds(pxds) != 0)
29354 goto out_free_pgd;
29355
29356 if (paravirt_pgd_alloc(mm) != 0)
29357 - goto out_free_pmds;
29358 + goto out_free_pxds;
29359
29360 /*
29361 * Make sure that pre-populating the pmds is atomic with
29362 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29363 spin_lock(&pgd_lock);
29364
29365 pgd_ctor(mm, pgd);
29366 - pgd_prepopulate_pmd(mm, pgd, pmds);
29367 + pgd_prepopulate_pxd(mm, pgd, pxds);
29368
29369 spin_unlock(&pgd_lock);
29370
29371 return pgd;
29372
29373 -out_free_pmds:
29374 - free_pmds(pmds);
29375 +out_free_pxds:
29376 + free_pxds(pxds);
29377 out_free_pgd:
29378 free_page((unsigned long)pgd);
29379 out:
29380 @@ -302,7 +363,7 @@ out:
29381
29382 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29383 {
29384 - pgd_mop_up_pmds(mm, pgd);
29385 + pgd_mop_up_pxds(mm, pgd);
29386 pgd_dtor(pgd);
29387 paravirt_pgd_free(mm, pgd);
29388 free_page((unsigned long)pgd);
29389 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29390 index a69bcb8..19068ab 100644
29391 --- a/arch/x86/mm/pgtable_32.c
29392 +++ b/arch/x86/mm/pgtable_32.c
29393 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29394 return;
29395 }
29396 pte = pte_offset_kernel(pmd, vaddr);
29397 +
29398 + pax_open_kernel();
29399 if (pte_val(pteval))
29400 set_pte_at(&init_mm, vaddr, pte, pteval);
29401 else
29402 pte_clear(&init_mm, vaddr, pte);
29403 + pax_close_kernel();
29404
29405 /*
29406 * It's enough to flush this one mapping.
29407 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29408 index e666cbb..61788c45 100644
29409 --- a/arch/x86/mm/physaddr.c
29410 +++ b/arch/x86/mm/physaddr.c
29411 @@ -10,7 +10,7 @@
29412 #ifdef CONFIG_X86_64
29413
29414 #ifdef CONFIG_DEBUG_VIRTUAL
29415 -unsigned long __phys_addr(unsigned long x)
29416 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29417 {
29418 unsigned long y = x - __START_KERNEL_map;
29419
29420 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29421 #else
29422
29423 #ifdef CONFIG_DEBUG_VIRTUAL
29424 -unsigned long __phys_addr(unsigned long x)
29425 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29426 {
29427 unsigned long phys_addr = x - PAGE_OFFSET;
29428 /* VMALLOC_* aren't constants */
29429 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29430 index 410531d..0f16030 100644
29431 --- a/arch/x86/mm/setup_nx.c
29432 +++ b/arch/x86/mm/setup_nx.c
29433 @@ -5,8 +5,10 @@
29434 #include <asm/pgtable.h>
29435 #include <asm/proto.h>
29436
29437 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29438 static int disable_nx __cpuinitdata;
29439
29440 +#ifndef CONFIG_PAX_PAGEEXEC
29441 /*
29442 * noexec = on|off
29443 *
29444 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29445 return 0;
29446 }
29447 early_param("noexec", noexec_setup);
29448 +#endif
29449 +
29450 +#endif
29451
29452 void __cpuinit x86_configure_nx(void)
29453 {
29454 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29455 if (cpu_has_nx && !disable_nx)
29456 __supported_pte_mask |= _PAGE_NX;
29457 else
29458 +#endif
29459 __supported_pte_mask &= ~_PAGE_NX;
29460 }
29461
29462 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29463 index 282375f..e03a98f 100644
29464 --- a/arch/x86/mm/tlb.c
29465 +++ b/arch/x86/mm/tlb.c
29466 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29467 BUG();
29468 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29469 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29470 +
29471 +#ifndef CONFIG_PAX_PER_CPU_PGD
29472 load_cr3(swapper_pg_dir);
29473 +#endif
29474 +
29475 }
29476 }
29477 EXPORT_SYMBOL_GPL(leave_mm);
29478 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29479 index 877b9a1..a8ecf42 100644
29480 --- a/arch/x86/net/bpf_jit.S
29481 +++ b/arch/x86/net/bpf_jit.S
29482 @@ -9,6 +9,7 @@
29483 */
29484 #include <linux/linkage.h>
29485 #include <asm/dwarf2.h>
29486 +#include <asm/alternative-asm.h>
29487
29488 /*
29489 * Calling convention :
29490 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29491 jle bpf_slow_path_word
29492 mov (SKBDATA,%rsi),%eax
29493 bswap %eax /* ntohl() */
29494 + pax_force_retaddr
29495 ret
29496
29497 sk_load_half:
29498 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29499 jle bpf_slow_path_half
29500 movzwl (SKBDATA,%rsi),%eax
29501 rol $8,%ax # ntohs()
29502 + pax_force_retaddr
29503 ret
29504
29505 sk_load_byte:
29506 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29507 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29508 jle bpf_slow_path_byte
29509 movzbl (SKBDATA,%rsi),%eax
29510 + pax_force_retaddr
29511 ret
29512
29513 /**
29514 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29515 movzbl (SKBDATA,%rsi),%ebx
29516 and $15,%bl
29517 shl $2,%bl
29518 + pax_force_retaddr
29519 ret
29520
29521 /* rsi contains offset and can be scratched */
29522 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29523 js bpf_error
29524 mov -12(%rbp),%eax
29525 bswap %eax
29526 + pax_force_retaddr
29527 ret
29528
29529 bpf_slow_path_half:
29530 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29531 mov -12(%rbp),%ax
29532 rol $8,%ax
29533 movzwl %ax,%eax
29534 + pax_force_retaddr
29535 ret
29536
29537 bpf_slow_path_byte:
29538 bpf_slow_path_common(1)
29539 js bpf_error
29540 movzbl -12(%rbp),%eax
29541 + pax_force_retaddr
29542 ret
29543
29544 bpf_slow_path_byte_msh:
29545 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29546 and $15,%al
29547 shl $2,%al
29548 xchg %eax,%ebx
29549 + pax_force_retaddr
29550 ret
29551
29552 #define sk_negative_common(SIZE) \
29553 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29554 sk_negative_common(4)
29555 mov (%rax), %eax
29556 bswap %eax
29557 + pax_force_retaddr
29558 ret
29559
29560 bpf_slow_path_half_neg:
29561 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29562 mov (%rax),%ax
29563 rol $8,%ax
29564 movzwl %ax,%eax
29565 + pax_force_retaddr
29566 ret
29567
29568 bpf_slow_path_byte_neg:
29569 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29570 .globl sk_load_byte_negative_offset
29571 sk_negative_common(1)
29572 movzbl (%rax), %eax
29573 + pax_force_retaddr
29574 ret
29575
29576 bpf_slow_path_byte_msh_neg:
29577 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29578 and $15,%al
29579 shl $2,%al
29580 xchg %eax,%ebx
29581 + pax_force_retaddr
29582 ret
29583
29584 bpf_error:
29585 @@ -197,4 +210,5 @@ bpf_error:
29586 xor %eax,%eax
29587 mov -8(%rbp),%rbx
29588 leaveq
29589 + pax_force_retaddr
29590 ret
29591 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29592 index f66b540..3e88dfb 100644
29593 --- a/arch/x86/net/bpf_jit_comp.c
29594 +++ b/arch/x86/net/bpf_jit_comp.c
29595 @@ -12,6 +12,7 @@
29596 #include <linux/netdevice.h>
29597 #include <linux/filter.h>
29598 #include <linux/if_vlan.h>
29599 +#include <linux/random.h>
29600
29601 /*
29602 * Conventions :
29603 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29604 return ptr + len;
29605 }
29606
29607 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29608 +#define MAX_INSTR_CODE_SIZE 96
29609 +#else
29610 +#define MAX_INSTR_CODE_SIZE 64
29611 +#endif
29612 +
29613 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29614
29615 #define EMIT1(b1) EMIT(b1, 1)
29616 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29617 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29618 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29619 +
29620 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29621 +/* original constant will appear in ecx */
29622 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29623 +do { \
29624 + /* mov ecx, randkey */ \
29625 + EMIT1(0xb9); \
29626 + EMIT(_key, 4); \
29627 + /* xor ecx, randkey ^ off */ \
29628 + EMIT2(0x81, 0xf1); \
29629 + EMIT((_key) ^ (_off), 4); \
29630 +} while (0)
29631 +
29632 +#define EMIT1_off32(b1, _off) \
29633 +do { \
29634 + switch (b1) { \
29635 + case 0x05: /* add eax, imm32 */ \
29636 + case 0x2d: /* sub eax, imm32 */ \
29637 + case 0x25: /* and eax, imm32 */ \
29638 + case 0x0d: /* or eax, imm32 */ \
29639 + case 0xb8: /* mov eax, imm32 */ \
29640 + case 0x35: /* xor eax, imm32 */ \
29641 + case 0x3d: /* cmp eax, imm32 */ \
29642 + case 0xa9: /* test eax, imm32 */ \
29643 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29644 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29645 + break; \
29646 + case 0xbb: /* mov ebx, imm32 */ \
29647 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29648 + /* mov ebx, ecx */ \
29649 + EMIT2(0x89, 0xcb); \
29650 + break; \
29651 + case 0xbe: /* mov esi, imm32 */ \
29652 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29653 + /* mov esi, ecx */ \
29654 + EMIT2(0x89, 0xce); \
29655 + break; \
29656 + case 0xe8: /* call rel imm32, always to known funcs */ \
29657 + EMIT1(b1); \
29658 + EMIT(_off, 4); \
29659 + break; \
29660 + case 0xe9: /* jmp rel imm32 */ \
29661 + EMIT1(b1); \
29662 + EMIT(_off, 4); \
29663 + /* prevent fall-through, we're not called if off = 0 */ \
29664 + EMIT(0xcccccccc, 4); \
29665 + EMIT(0xcccccccc, 4); \
29666 + break; \
29667 + default: \
29668 + BUILD_BUG(); \
29669 + } \
29670 +} while (0)
29671 +
29672 +#define EMIT2_off32(b1, b2, _off) \
29673 +do { \
29674 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29675 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29676 + EMIT(randkey, 4); \
29677 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29678 + EMIT((_off) - randkey, 4); \
29679 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29680 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29681 + /* imul eax, ecx */ \
29682 + EMIT3(0x0f, 0xaf, 0xc1); \
29683 + } else { \
29684 + BUILD_BUG(); \
29685 + } \
29686 +} while (0)
29687 +#else
29688 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29689 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29690 +#endif
29691
29692 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29693 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29694 @@ -90,6 +168,24 @@ do { \
29695 #define X86_JBE 0x76
29696 #define X86_JA 0x77
29697
29698 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29699 +#define APPEND_FLOW_VERIFY() \
29700 +do { \
29701 + /* mov ecx, randkey */ \
29702 + EMIT1(0xb9); \
29703 + EMIT(randkey, 4); \
29704 + /* cmp ecx, randkey */ \
29705 + EMIT2(0x81, 0xf9); \
29706 + EMIT(randkey, 4); \
29707 + /* jz after 8 int 3s */ \
29708 + EMIT2(0x74, 0x08); \
29709 + EMIT(0xcccccccc, 4); \
29710 + EMIT(0xcccccccc, 4); \
29711 +} while (0)
29712 +#else
29713 +#define APPEND_FLOW_VERIFY() do { } while (0)
29714 +#endif
29715 +
29716 #define EMIT_COND_JMP(op, offset) \
29717 do { \
29718 if (is_near(offset)) \
29719 @@ -97,6 +193,7 @@ do { \
29720 else { \
29721 EMIT2(0x0f, op + 0x10); \
29722 EMIT(offset, 4); /* jxx .+off32 */ \
29723 + APPEND_FLOW_VERIFY(); \
29724 } \
29725 } while (0)
29726
29727 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29728 set_fs(old_fs);
29729 }
29730
29731 +struct bpf_jit_work {
29732 + struct work_struct work;
29733 + void *image;
29734 +};
29735 +
29736 #define CHOOSE_LOAD_FUNC(K, func) \
29737 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29738
29739 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29740
29741 void bpf_jit_compile(struct sk_filter *fp)
29742 {
29743 - u8 temp[64];
29744 + u8 temp[MAX_INSTR_CODE_SIZE];
29745 u8 *prog;
29746 unsigned int proglen, oldproglen = 0;
29747 int ilen, i;
29748 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29749 unsigned int *addrs;
29750 const struct sock_filter *filter = fp->insns;
29751 int flen = fp->len;
29752 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29753 + unsigned int randkey;
29754 +#endif
29755
29756 if (!bpf_jit_enable)
29757 return;
29758 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29759 if (addrs == NULL)
29760 return;
29761
29762 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29763 + if (!fp->work)
29764 + goto out;
29765 +
29766 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29767 + randkey = get_random_int();
29768 +#endif
29769 +
29770 /* Before first pass, make a rough estimation of addrs[]
29771 - * each bpf instruction is translated to less than 64 bytes
29772 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29773 */
29774 for (proglen = 0, i = 0; i < flen; i++) {
29775 - proglen += 64;
29776 + proglen += MAX_INSTR_CODE_SIZE;
29777 addrs[i] = proglen;
29778 }
29779 cleanup_addr = proglen; /* epilogue address */
29780 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29781 case BPF_S_ALU_MUL_K: /* A *= K */
29782 if (is_imm8(K))
29783 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29784 - else {
29785 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29786 - EMIT(K, 4);
29787 - }
29788 + else
29789 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29790 break;
29791 case BPF_S_ALU_DIV_X: /* A /= X; */
29792 seen |= SEEN_XREG;
29793 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29794 break;
29795 case BPF_S_ALU_MOD_K: /* A %= K; */
29796 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29797 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29798 + DILUTE_CONST_SEQUENCE(K, randkey);
29799 +#else
29800 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29801 +#endif
29802 EMIT2(0xf7, 0xf1); /* div %ecx */
29803 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29804 break;
29805 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29806 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29807 + DILUTE_CONST_SEQUENCE(K, randkey);
29808 + // imul rax, rcx
29809 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29810 +#else
29811 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29812 EMIT(K, 4);
29813 +#endif
29814 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29815 break;
29816 case BPF_S_ALU_AND_X:
29817 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29818 if (is_imm8(K)) {
29819 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29820 } else {
29821 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29822 - EMIT(K, 4);
29823 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29824 }
29825 } else {
29826 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29827 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29828 break;
29829 default:
29830 /* hmm, too complex filter, give up with jit compiler */
29831 - goto out;
29832 + goto error;
29833 }
29834 ilen = prog - temp;
29835 if (image) {
29836 if (unlikely(proglen + ilen > oldproglen)) {
29837 pr_err("bpb_jit_compile fatal error\n");
29838 - kfree(addrs);
29839 - module_free(NULL, image);
29840 - return;
29841 + module_free_exec(NULL, image);
29842 + goto error;
29843 }
29844 + pax_open_kernel();
29845 memcpy(image + proglen, temp, ilen);
29846 + pax_close_kernel();
29847 }
29848 proglen += ilen;
29849 addrs[i] = proglen;
29850 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29851 break;
29852 }
29853 if (proglen == oldproglen) {
29854 - image = module_alloc(max_t(unsigned int,
29855 - proglen,
29856 - sizeof(struct work_struct)));
29857 + image = module_alloc_exec(proglen);
29858 if (!image)
29859 - goto out;
29860 + goto error;
29861 }
29862 oldproglen = proglen;
29863 }
29864 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29865 if (image) {
29866 bpf_flush_icache(image, image + proglen);
29867 fp->bpf_func = (void *)image;
29868 - }
29869 + } else
29870 +error:
29871 + kfree(fp->work);
29872 +
29873 out:
29874 kfree(addrs);
29875 return;
29876 @@ -740,18 +862,20 @@ out:
29877
29878 static void jit_free_defer(struct work_struct *arg)
29879 {
29880 - module_free(NULL, arg);
29881 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29882 + kfree(arg);
29883 }
29884
29885 /* run from softirq, we must use a work_struct to call
29886 - * module_free() from process context
29887 + * module_free_exec() from process context
29888 */
29889 void bpf_jit_free(struct sk_filter *fp)
29890 {
29891 if (fp->bpf_func != sk_run_filter) {
29892 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29893 + struct work_struct *work = &fp->work->work;
29894
29895 INIT_WORK(work, jit_free_defer);
29896 + fp->work->image = fp->bpf_func;
29897 schedule_work(work);
29898 }
29899 }
29900 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29901 index d6aa6e8..266395a 100644
29902 --- a/arch/x86/oprofile/backtrace.c
29903 +++ b/arch/x86/oprofile/backtrace.c
29904 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29905 struct stack_frame_ia32 *fp;
29906 unsigned long bytes;
29907
29908 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29909 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29910 if (bytes != sizeof(bufhead))
29911 return NULL;
29912
29913 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29914 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29915
29916 oprofile_add_trace(bufhead[0].return_address);
29917
29918 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29919 struct stack_frame bufhead[2];
29920 unsigned long bytes;
29921
29922 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29923 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29924 if (bytes != sizeof(bufhead))
29925 return NULL;
29926
29927 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29928 {
29929 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29930
29931 - if (!user_mode_vm(regs)) {
29932 + if (!user_mode(regs)) {
29933 unsigned long stack = kernel_stack_pointer(regs);
29934 if (depth)
29935 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29936 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29937 index 48768df..ba9143c 100644
29938 --- a/arch/x86/oprofile/nmi_int.c
29939 +++ b/arch/x86/oprofile/nmi_int.c
29940 @@ -23,6 +23,7 @@
29941 #include <asm/nmi.h>
29942 #include <asm/msr.h>
29943 #include <asm/apic.h>
29944 +#include <asm/pgtable.h>
29945
29946 #include "op_counter.h"
29947 #include "op_x86_model.h"
29948 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29949 if (ret)
29950 return ret;
29951
29952 - if (!model->num_virt_counters)
29953 - model->num_virt_counters = model->num_counters;
29954 + if (!model->num_virt_counters) {
29955 + pax_open_kernel();
29956 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29957 + pax_close_kernel();
29958 + }
29959
29960 mux_init(ops);
29961
29962 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29963 index b2b9443..be58856 100644
29964 --- a/arch/x86/oprofile/op_model_amd.c
29965 +++ b/arch/x86/oprofile/op_model_amd.c
29966 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29967 num_counters = AMD64_NUM_COUNTERS;
29968 }
29969
29970 - op_amd_spec.num_counters = num_counters;
29971 - op_amd_spec.num_controls = num_counters;
29972 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29973 + pax_open_kernel();
29974 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29975 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29976 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29977 + pax_close_kernel();
29978
29979 return 0;
29980 }
29981 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29982 index d90528e..0127e2b 100644
29983 --- a/arch/x86/oprofile/op_model_ppro.c
29984 +++ b/arch/x86/oprofile/op_model_ppro.c
29985 @@ -19,6 +19,7 @@
29986 #include <asm/msr.h>
29987 #include <asm/apic.h>
29988 #include <asm/nmi.h>
29989 +#include <asm/pgtable.h>
29990
29991 #include "op_x86_model.h"
29992 #include "op_counter.h"
29993 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29994
29995 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29996
29997 - op_arch_perfmon_spec.num_counters = num_counters;
29998 - op_arch_perfmon_spec.num_controls = num_counters;
29999 + pax_open_kernel();
30000 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30001 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30002 + pax_close_kernel();
30003 }
30004
30005 static int arch_perfmon_init(struct oprofile_operations *ignore)
30006 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30007 index 71e8a67..6a313bb 100644
30008 --- a/arch/x86/oprofile/op_x86_model.h
30009 +++ b/arch/x86/oprofile/op_x86_model.h
30010 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30011 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30012 struct op_msrs const * const msrs);
30013 #endif
30014 -};
30015 +} __do_const;
30016
30017 struct op_counter_config;
30018
30019 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30020 index e9e6ed5..e47ae67 100644
30021 --- a/arch/x86/pci/amd_bus.c
30022 +++ b/arch/x86/pci/amd_bus.c
30023 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30024 return NOTIFY_OK;
30025 }
30026
30027 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30028 +static struct notifier_block amd_cpu_notifier = {
30029 .notifier_call = amd_cpu_notify,
30030 };
30031
30032 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30033 index 372e9b8..e775a6c 100644
30034 --- a/arch/x86/pci/irq.c
30035 +++ b/arch/x86/pci/irq.c
30036 @@ -50,7 +50,7 @@ struct irq_router {
30037 struct irq_router_handler {
30038 u16 vendor;
30039 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30040 -};
30041 +} __do_const;
30042
30043 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30044 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30045 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30046 return 0;
30047 }
30048
30049 -static __initdata struct irq_router_handler pirq_routers[] = {
30050 +static __initconst const struct irq_router_handler pirq_routers[] = {
30051 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30052 { PCI_VENDOR_ID_AL, ali_router_probe },
30053 { PCI_VENDOR_ID_ITE, ite_router_probe },
30054 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30055 static void __init pirq_find_router(struct irq_router *r)
30056 {
30057 struct irq_routing_table *rt = pirq_table;
30058 - struct irq_router_handler *h;
30059 + const struct irq_router_handler *h;
30060
30061 #ifdef CONFIG_PCI_BIOS
30062 if (!rt->signature) {
30063 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30064 return 0;
30065 }
30066
30067 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30068 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30069 {
30070 .callback = fix_broken_hp_bios_irq9,
30071 .ident = "HP Pavilion N5400 Series Laptop",
30072 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30073 index 6eb18c4..20d83de 100644
30074 --- a/arch/x86/pci/mrst.c
30075 +++ b/arch/x86/pci/mrst.c
30076 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30077 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30078 pci_mmcfg_late_init();
30079 pcibios_enable_irq = mrst_pci_irq_enable;
30080 - pci_root_ops = pci_mrst_ops;
30081 + pax_open_kernel();
30082 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30083 + pax_close_kernel();
30084 pci_soc_mode = 1;
30085 /* Continue with standard init */
30086 return 1;
30087 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30088 index c77b24a..c979855 100644
30089 --- a/arch/x86/pci/pcbios.c
30090 +++ b/arch/x86/pci/pcbios.c
30091 @@ -79,7 +79,7 @@ union bios32 {
30092 static struct {
30093 unsigned long address;
30094 unsigned short segment;
30095 -} bios32_indirect = { 0, __KERNEL_CS };
30096 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30097
30098 /*
30099 * Returns the entry point for the given service, NULL on error
30100 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30101 unsigned long length; /* %ecx */
30102 unsigned long entry; /* %edx */
30103 unsigned long flags;
30104 + struct desc_struct d, *gdt;
30105
30106 local_irq_save(flags);
30107 - __asm__("lcall *(%%edi); cld"
30108 +
30109 + gdt = get_cpu_gdt_table(smp_processor_id());
30110 +
30111 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30112 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30113 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30114 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30115 +
30116 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30117 : "=a" (return_code),
30118 "=b" (address),
30119 "=c" (length),
30120 "=d" (entry)
30121 : "0" (service),
30122 "1" (0),
30123 - "D" (&bios32_indirect));
30124 + "D" (&bios32_indirect),
30125 + "r"(__PCIBIOS_DS)
30126 + : "memory");
30127 +
30128 + pax_open_kernel();
30129 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30130 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30131 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30132 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30133 + pax_close_kernel();
30134 +
30135 local_irq_restore(flags);
30136
30137 switch (return_code) {
30138 - case 0:
30139 - return address + entry;
30140 - case 0x80: /* Not present */
30141 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30142 - return 0;
30143 - default: /* Shouldn't happen */
30144 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30145 - service, return_code);
30146 + case 0: {
30147 + int cpu;
30148 + unsigned char flags;
30149 +
30150 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30151 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30152 + printk(KERN_WARNING "bios32_service: not valid\n");
30153 return 0;
30154 + }
30155 + address = address + PAGE_OFFSET;
30156 + length += 16UL; /* some BIOSs underreport this... */
30157 + flags = 4;
30158 + if (length >= 64*1024*1024) {
30159 + length >>= PAGE_SHIFT;
30160 + flags |= 8;
30161 + }
30162 +
30163 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30164 + gdt = get_cpu_gdt_table(cpu);
30165 + pack_descriptor(&d, address, length, 0x9b, flags);
30166 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30167 + pack_descriptor(&d, address, length, 0x93, flags);
30168 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30169 + }
30170 + return entry;
30171 + }
30172 + case 0x80: /* Not present */
30173 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30174 + return 0;
30175 + default: /* Shouldn't happen */
30176 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30177 + service, return_code);
30178 + return 0;
30179 }
30180 }
30181
30182 static struct {
30183 unsigned long address;
30184 unsigned short segment;
30185 -} pci_indirect = { 0, __KERNEL_CS };
30186 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30187
30188 -static int pci_bios_present;
30189 +static int pci_bios_present __read_only;
30190
30191 static int check_pcibios(void)
30192 {
30193 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30194 unsigned long flags, pcibios_entry;
30195
30196 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30197 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30198 + pci_indirect.address = pcibios_entry;
30199
30200 local_irq_save(flags);
30201 - __asm__(
30202 - "lcall *(%%edi); cld\n\t"
30203 + __asm__("movw %w6, %%ds\n\t"
30204 + "lcall *%%ss:(%%edi); cld\n\t"
30205 + "push %%ss\n\t"
30206 + "pop %%ds\n\t"
30207 "jc 1f\n\t"
30208 "xor %%ah, %%ah\n"
30209 "1:"
30210 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30211 "=b" (ebx),
30212 "=c" (ecx)
30213 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30214 - "D" (&pci_indirect)
30215 + "D" (&pci_indirect),
30216 + "r" (__PCIBIOS_DS)
30217 : "memory");
30218 local_irq_restore(flags);
30219
30220 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30221
30222 switch (len) {
30223 case 1:
30224 - __asm__("lcall *(%%esi); cld\n\t"
30225 + __asm__("movw %w6, %%ds\n\t"
30226 + "lcall *%%ss:(%%esi); cld\n\t"
30227 + "push %%ss\n\t"
30228 + "pop %%ds\n\t"
30229 "jc 1f\n\t"
30230 "xor %%ah, %%ah\n"
30231 "1:"
30232 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30233 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30234 "b" (bx),
30235 "D" ((long)reg),
30236 - "S" (&pci_indirect));
30237 + "S" (&pci_indirect),
30238 + "r" (__PCIBIOS_DS));
30239 /*
30240 * Zero-extend the result beyond 8 bits, do not trust the
30241 * BIOS having done it:
30242 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30243 *value &= 0xff;
30244 break;
30245 case 2:
30246 - __asm__("lcall *(%%esi); cld\n\t"
30247 + __asm__("movw %w6, %%ds\n\t"
30248 + "lcall *%%ss:(%%esi); cld\n\t"
30249 + "push %%ss\n\t"
30250 + "pop %%ds\n\t"
30251 "jc 1f\n\t"
30252 "xor %%ah, %%ah\n"
30253 "1:"
30254 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30255 : "1" (PCIBIOS_READ_CONFIG_WORD),
30256 "b" (bx),
30257 "D" ((long)reg),
30258 - "S" (&pci_indirect));
30259 + "S" (&pci_indirect),
30260 + "r" (__PCIBIOS_DS));
30261 /*
30262 * Zero-extend the result beyond 16 bits, do not trust the
30263 * BIOS having done it:
30264 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30265 *value &= 0xffff;
30266 break;
30267 case 4:
30268 - __asm__("lcall *(%%esi); cld\n\t"
30269 + __asm__("movw %w6, %%ds\n\t"
30270 + "lcall *%%ss:(%%esi); cld\n\t"
30271 + "push %%ss\n\t"
30272 + "pop %%ds\n\t"
30273 "jc 1f\n\t"
30274 "xor %%ah, %%ah\n"
30275 "1:"
30276 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30277 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30278 "b" (bx),
30279 "D" ((long)reg),
30280 - "S" (&pci_indirect));
30281 + "S" (&pci_indirect),
30282 + "r" (__PCIBIOS_DS));
30283 break;
30284 }
30285
30286 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30287
30288 switch (len) {
30289 case 1:
30290 - __asm__("lcall *(%%esi); cld\n\t"
30291 + __asm__("movw %w6, %%ds\n\t"
30292 + "lcall *%%ss:(%%esi); cld\n\t"
30293 + "push %%ss\n\t"
30294 + "pop %%ds\n\t"
30295 "jc 1f\n\t"
30296 "xor %%ah, %%ah\n"
30297 "1:"
30298 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30299 "c" (value),
30300 "b" (bx),
30301 "D" ((long)reg),
30302 - "S" (&pci_indirect));
30303 + "S" (&pci_indirect),
30304 + "r" (__PCIBIOS_DS));
30305 break;
30306 case 2:
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 @@ -277,10 +342,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 4:
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 @@ -289,7 +358,8 @@ 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 }
30341
30342 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30343
30344 DBG("PCI: Fetching IRQ routing table... ");
30345 __asm__("push %%es\n\t"
30346 + "movw %w8, %%ds\n\t"
30347 "push %%ds\n\t"
30348 "pop %%es\n\t"
30349 - "lcall *(%%esi); cld\n\t"
30350 + "lcall *%%ss:(%%esi); cld\n\t"
30351 "pop %%es\n\t"
30352 + "push %%ss\n\t"
30353 + "pop %%ds\n"
30354 "jc 1f\n\t"
30355 "xor %%ah, %%ah\n"
30356 "1:"
30357 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30358 "1" (0),
30359 "D" ((long) &opt),
30360 "S" (&pci_indirect),
30361 - "m" (opt)
30362 + "m" (opt),
30363 + "r" (__PCIBIOS_DS)
30364 : "memory");
30365 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30366 if (ret & 0xff00)
30367 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30368 {
30369 int ret;
30370
30371 - __asm__("lcall *(%%esi); cld\n\t"
30372 + __asm__("movw %w5, %%ds\n\t"
30373 + "lcall *%%ss:(%%esi); cld\n\t"
30374 + "push %%ss\n\t"
30375 + "pop %%ds\n"
30376 "jc 1f\n\t"
30377 "xor %%ah, %%ah\n"
30378 "1:"
30379 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30380 : "0" (PCIBIOS_SET_PCI_HW_INT),
30381 "b" ((dev->bus->number << 8) | dev->devfn),
30382 "c" ((irq << 8) | (pin + 10)),
30383 - "S" (&pci_indirect));
30384 + "S" (&pci_indirect),
30385 + "r" (__PCIBIOS_DS));
30386 return !(ret & 0xff00);
30387 }
30388 EXPORT_SYMBOL(pcibios_set_irq_routing);
30389 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30390 index 40e4469..0592924 100644
30391 --- a/arch/x86/platform/efi/efi_32.c
30392 +++ b/arch/x86/platform/efi/efi_32.c
30393 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30394 {
30395 struct desc_ptr gdt_descr;
30396
30397 +#ifdef CONFIG_PAX_KERNEXEC
30398 + struct desc_struct d;
30399 +#endif
30400 +
30401 local_irq_save(efi_rt_eflags);
30402
30403 load_cr3(initial_page_table);
30404 __flush_tlb_all();
30405
30406 +#ifdef CONFIG_PAX_KERNEXEC
30407 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30408 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30409 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30410 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30411 +#endif
30412 +
30413 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30414 gdt_descr.size = GDT_SIZE - 1;
30415 load_gdt(&gdt_descr);
30416 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
30417 {
30418 struct desc_ptr gdt_descr;
30419
30420 +#ifdef CONFIG_PAX_KERNEXEC
30421 + struct desc_struct d;
30422 +
30423 + memset(&d, 0, sizeof d);
30424 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30425 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30426 +#endif
30427 +
30428 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30429 gdt_descr.size = GDT_SIZE - 1;
30430 load_gdt(&gdt_descr);
30431
30432 +#ifdef CONFIG_PAX_PER_CPU_PGD
30433 + load_cr3(get_cpu_pgd(smp_processor_id()));
30434 +#else
30435 load_cr3(swapper_pg_dir);
30436 +#endif
30437 +
30438 __flush_tlb_all();
30439
30440 local_irq_restore(efi_rt_eflags);
30441 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
30442 index 39a0e7f1..ecc2f1e 100644
30443 --- a/arch/x86/platform/efi/efi_64.c
30444 +++ b/arch/x86/platform/efi/efi_64.c
30445 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
30446 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
30447 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
30448 }
30449 +
30450 +#ifdef CONFIG_PAX_PER_CPU_PGD
30451 + load_cr3(swapper_pg_dir);
30452 +#endif
30453 +
30454 __flush_tlb_all();
30455 }
30456
30457 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
30458 for (pgd = 0; pgd < n_pgds; pgd++)
30459 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
30460 kfree(save_pgd);
30461 +
30462 +#ifdef CONFIG_PAX_PER_CPU_PGD
30463 + load_cr3(get_cpu_pgd(smp_processor_id()));
30464 +#endif
30465 +
30466 __flush_tlb_all();
30467 local_irq_restore(efi_flags);
30468 early_code_mapping_set_exec(0);
30469 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30470 index fbe66e6..eae5e38 100644
30471 --- a/arch/x86/platform/efi/efi_stub_32.S
30472 +++ b/arch/x86/platform/efi/efi_stub_32.S
30473 @@ -6,7 +6,9 @@
30474 */
30475
30476 #include <linux/linkage.h>
30477 +#include <linux/init.h>
30478 #include <asm/page_types.h>
30479 +#include <asm/segment.h>
30480
30481 /*
30482 * efi_call_phys(void *, ...) is a function with variable parameters.
30483 @@ -20,7 +22,7 @@
30484 * service functions will comply with gcc calling convention, too.
30485 */
30486
30487 -.text
30488 +__INIT
30489 ENTRY(efi_call_phys)
30490 /*
30491 * 0. The function can only be called in Linux kernel. So CS has been
30492 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30493 * The mapping of lower virtual memory has been created in prelog and
30494 * epilog.
30495 */
30496 - movl $1f, %edx
30497 - subl $__PAGE_OFFSET, %edx
30498 - jmp *%edx
30499 +#ifdef CONFIG_PAX_KERNEXEC
30500 + movl $(__KERNEXEC_EFI_DS), %edx
30501 + mov %edx, %ds
30502 + mov %edx, %es
30503 + mov %edx, %ss
30504 + addl $2f,(1f)
30505 + ljmp *(1f)
30506 +
30507 +__INITDATA
30508 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30509 +.previous
30510 +
30511 +2:
30512 + subl $2b,(1b)
30513 +#else
30514 + jmp 1f-__PAGE_OFFSET
30515 1:
30516 +#endif
30517
30518 /*
30519 * 2. Now on the top of stack is the return
30520 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30521 * parameter 2, ..., param n. To make things easy, we save the return
30522 * address of efi_call_phys in a global variable.
30523 */
30524 - popl %edx
30525 - movl %edx, saved_return_addr
30526 - /* get the function pointer into ECX*/
30527 - popl %ecx
30528 - movl %ecx, efi_rt_function_ptr
30529 - movl $2f, %edx
30530 - subl $__PAGE_OFFSET, %edx
30531 - pushl %edx
30532 + popl (saved_return_addr)
30533 + popl (efi_rt_function_ptr)
30534
30535 /*
30536 * 3. Clear PG bit in %CR0.
30537 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30538 /*
30539 * 5. Call the physical function.
30540 */
30541 - jmp *%ecx
30542 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30543
30544 -2:
30545 /*
30546 * 6. After EFI runtime service returns, control will return to
30547 * following instruction. We'd better readjust stack pointer first.
30548 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30549 movl %cr0, %edx
30550 orl $0x80000000, %edx
30551 movl %edx, %cr0
30552 - jmp 1f
30553 -1:
30554 +
30555 /*
30556 * 8. Now restore the virtual mode from flat mode by
30557 * adding EIP with PAGE_OFFSET.
30558 */
30559 - movl $1f, %edx
30560 - jmp *%edx
30561 +#ifdef CONFIG_PAX_KERNEXEC
30562 + movl $(__KERNEL_DS), %edx
30563 + mov %edx, %ds
30564 + mov %edx, %es
30565 + mov %edx, %ss
30566 + ljmp $(__KERNEL_CS),$1f
30567 +#else
30568 + jmp 1f+__PAGE_OFFSET
30569 +#endif
30570 1:
30571
30572 /*
30573 * 9. Balance the stack. And because EAX contain the return value,
30574 * we'd better not clobber it.
30575 */
30576 - leal efi_rt_function_ptr, %edx
30577 - movl (%edx), %ecx
30578 - pushl %ecx
30579 + pushl (efi_rt_function_ptr)
30580
30581 /*
30582 - * 10. Push the saved return address onto the stack and return.
30583 + * 10. Return to the saved return address.
30584 */
30585 - leal saved_return_addr, %edx
30586 - movl (%edx), %ecx
30587 - pushl %ecx
30588 - ret
30589 + jmpl *(saved_return_addr)
30590 ENDPROC(efi_call_phys)
30591 .previous
30592
30593 -.data
30594 +__INITDATA
30595 saved_return_addr:
30596 .long 0
30597 efi_rt_function_ptr:
30598 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30599 index 4c07cca..2c8427d 100644
30600 --- a/arch/x86/platform/efi/efi_stub_64.S
30601 +++ b/arch/x86/platform/efi/efi_stub_64.S
30602 @@ -7,6 +7,7 @@
30603 */
30604
30605 #include <linux/linkage.h>
30606 +#include <asm/alternative-asm.h>
30607
30608 #define SAVE_XMM \
30609 mov %rsp, %rax; \
30610 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30611 call *%rdi
30612 addq $32, %rsp
30613 RESTORE_XMM
30614 + pax_force_retaddr 0, 1
30615 ret
30616 ENDPROC(efi_call0)
30617
30618 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30619 call *%rdi
30620 addq $32, %rsp
30621 RESTORE_XMM
30622 + pax_force_retaddr 0, 1
30623 ret
30624 ENDPROC(efi_call1)
30625
30626 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30627 call *%rdi
30628 addq $32, %rsp
30629 RESTORE_XMM
30630 + pax_force_retaddr 0, 1
30631 ret
30632 ENDPROC(efi_call2)
30633
30634 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30635 call *%rdi
30636 addq $32, %rsp
30637 RESTORE_XMM
30638 + pax_force_retaddr 0, 1
30639 ret
30640 ENDPROC(efi_call3)
30641
30642 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30643 call *%rdi
30644 addq $32, %rsp
30645 RESTORE_XMM
30646 + pax_force_retaddr 0, 1
30647 ret
30648 ENDPROC(efi_call4)
30649
30650 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30651 call *%rdi
30652 addq $48, %rsp
30653 RESTORE_XMM
30654 + pax_force_retaddr 0, 1
30655 ret
30656 ENDPROC(efi_call5)
30657
30658 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30659 call *%rdi
30660 addq $48, %rsp
30661 RESTORE_XMM
30662 + pax_force_retaddr 0, 1
30663 ret
30664 ENDPROC(efi_call6)
30665 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30666 index a0a0a43..a48e233 100644
30667 --- a/arch/x86/platform/mrst/mrst.c
30668 +++ b/arch/x86/platform/mrst/mrst.c
30669 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30670 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30671 int sfi_mrtc_num;
30672
30673 -static void mrst_power_off(void)
30674 +static __noreturn void mrst_power_off(void)
30675 {
30676 + BUG();
30677 }
30678
30679 -static void mrst_reboot(void)
30680 +static __noreturn void mrst_reboot(void)
30681 {
30682 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30683 + BUG();
30684 }
30685
30686 /* parse all the mtimer info to a static mtimer array */
30687 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30688 index d6ee929..3637cb5 100644
30689 --- a/arch/x86/platform/olpc/olpc_dt.c
30690 +++ b/arch/x86/platform/olpc/olpc_dt.c
30691 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30692 return res;
30693 }
30694
30695 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30696 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30697 .nextprop = olpc_dt_nextprop,
30698 .getproplen = olpc_dt_getproplen,
30699 .getproperty = olpc_dt_getproperty,
30700 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30701 index 1cf5b30..fd45732 100644
30702 --- a/arch/x86/power/cpu.c
30703 +++ b/arch/x86/power/cpu.c
30704 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
30705 static void fix_processor_context(void)
30706 {
30707 int cpu = smp_processor_id();
30708 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30709 -#ifdef CONFIG_X86_64
30710 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
30711 - tss_desc tss;
30712 -#endif
30713 + struct tss_struct *t = init_tss + cpu;
30714 +
30715 set_tss_desc(cpu, t); /*
30716 * This just modifies memory; should not be
30717 * necessary. But... This is necessary, because
30718 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
30719 */
30720
30721 #ifdef CONFIG_X86_64
30722 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
30723 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
30724 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
30725 -
30726 syscall_init(); /* This sets MSR_*STAR and related */
30727 #endif
30728 load_TR_desc(); /* This does ltr */
30729 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30730 index a44f457..9140171 100644
30731 --- a/arch/x86/realmode/init.c
30732 +++ b/arch/x86/realmode/init.c
30733 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30734 __va(real_mode_header->trampoline_header);
30735
30736 #ifdef CONFIG_X86_32
30737 - trampoline_header->start = __pa_symbol(startup_32_smp);
30738 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30739 +
30740 +#ifdef CONFIG_PAX_KERNEXEC
30741 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30742 +#endif
30743 +
30744 + trampoline_header->boot_cs = __BOOT_CS;
30745 trampoline_header->gdt_limit = __BOOT_DS + 7;
30746 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30747 #else
30748 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30749 *trampoline_cr4_features = read_cr4();
30750
30751 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30752 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30753 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30754 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30755 #endif
30756 }
30757 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30758 index 8869287..d577672 100644
30759 --- a/arch/x86/realmode/rm/Makefile
30760 +++ b/arch/x86/realmode/rm/Makefile
30761 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30762 $(call cc-option, -fno-unit-at-a-time)) \
30763 $(call cc-option, -fno-stack-protector) \
30764 $(call cc-option, -mpreferred-stack-boundary=2)
30765 +ifdef CONSTIFY_PLUGIN
30766 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30767 +endif
30768 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30769 GCOV_PROFILE := n
30770 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30771 index a28221d..93c40f1 100644
30772 --- a/arch/x86/realmode/rm/header.S
30773 +++ b/arch/x86/realmode/rm/header.S
30774 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30775 #endif
30776 /* APM/BIOS reboot */
30777 .long pa_machine_real_restart_asm
30778 -#ifdef CONFIG_X86_64
30779 +#ifdef CONFIG_X86_32
30780 + .long __KERNEL_CS
30781 +#else
30782 .long __KERNEL32_CS
30783 #endif
30784 END(real_mode_header)
30785 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30786 index c1b2791..f9e31c7 100644
30787 --- a/arch/x86/realmode/rm/trampoline_32.S
30788 +++ b/arch/x86/realmode/rm/trampoline_32.S
30789 @@ -25,6 +25,12 @@
30790 #include <asm/page_types.h>
30791 #include "realmode.h"
30792
30793 +#ifdef CONFIG_PAX_KERNEXEC
30794 +#define ta(X) (X)
30795 +#else
30796 +#define ta(X) (pa_ ## X)
30797 +#endif
30798 +
30799 .text
30800 .code16
30801
30802 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30803
30804 cli # We should be safe anyway
30805
30806 - movl tr_start, %eax # where we need to go
30807 -
30808 movl $0xA5A5A5A5, trampoline_status
30809 # write marker for master knows we're running
30810
30811 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30812 movw $1, %dx # protected mode (PE) bit
30813 lmsw %dx # into protected mode
30814
30815 - ljmpl $__BOOT_CS, $pa_startup_32
30816 + ljmpl *(trampoline_header)
30817
30818 .section ".text32","ax"
30819 .code32
30820 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30821 .balign 8
30822 GLOBAL(trampoline_header)
30823 tr_start: .space 4
30824 - tr_gdt_pad: .space 2
30825 + tr_boot_cs: .space 2
30826 tr_gdt: .space 6
30827 END(trampoline_header)
30828
30829 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30830 index bb360dc..3e5945f 100644
30831 --- a/arch/x86/realmode/rm/trampoline_64.S
30832 +++ b/arch/x86/realmode/rm/trampoline_64.S
30833 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30834 wrmsr
30835
30836 # Enable paging and in turn activate Long Mode
30837 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30838 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30839 movl %eax, %cr0
30840
30841 /*
30842 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
30843 index e812034..c747134 100644
30844 --- a/arch/x86/tools/Makefile
30845 +++ b/arch/x86/tools/Makefile
30846 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
30847
30848 $(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
30849
30850 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
30851 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
30852 hostprogs-y += relocs
30853 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
30854 relocs: $(obj)/relocs
30855 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30856 index f7bab68..b6d9886 100644
30857 --- a/arch/x86/tools/relocs.c
30858 +++ b/arch/x86/tools/relocs.c
30859 @@ -1,5 +1,7 @@
30860 /* This is included from relocs_32/64.c */
30861
30862 +#include "../../../include/generated/autoconf.h"
30863 +
30864 #define ElfW(type) _ElfW(ELF_BITS, type)
30865 #define _ElfW(bits, type) __ElfW(bits, type)
30866 #define __ElfW(bits, type) Elf##bits##_##type
30867 @@ -11,6 +13,7 @@
30868 #define Elf_Sym ElfW(Sym)
30869
30870 static Elf_Ehdr ehdr;
30871 +static Elf_Phdr *phdr;
30872
30873 struct relocs {
30874 uint32_t *offset;
30875 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
30876 }
30877 }
30878
30879 +static void read_phdrs(FILE *fp)
30880 +{
30881 + unsigned int i;
30882 +
30883 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
30884 + if (!phdr) {
30885 + die("Unable to allocate %d program headers\n",
30886 + ehdr.e_phnum);
30887 + }
30888 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30889 + die("Seek to %d failed: %s\n",
30890 + ehdr.e_phoff, strerror(errno));
30891 + }
30892 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30893 + die("Cannot read ELF program headers: %s\n",
30894 + strerror(errno));
30895 + }
30896 + for(i = 0; i < ehdr.e_phnum; i++) {
30897 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
30898 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
30899 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
30900 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
30901 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
30902 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
30903 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
30904 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
30905 + }
30906 +
30907 +}
30908 +
30909 static void read_shdrs(FILE *fp)
30910 {
30911 - int i;
30912 + unsigned int i;
30913 Elf_Shdr shdr;
30914
30915 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30916 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
30917
30918 static void read_strtabs(FILE *fp)
30919 {
30920 - int i;
30921 + unsigned int i;
30922 for (i = 0; i < ehdr.e_shnum; i++) {
30923 struct section *sec = &secs[i];
30924 if (sec->shdr.sh_type != SHT_STRTAB) {
30925 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
30926
30927 static void read_symtabs(FILE *fp)
30928 {
30929 - int i,j;
30930 + unsigned int i,j;
30931 for (i = 0; i < ehdr.e_shnum; i++) {
30932 struct section *sec = &secs[i];
30933 if (sec->shdr.sh_type != SHT_SYMTAB) {
30934 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
30935 }
30936
30937
30938 -static void read_relocs(FILE *fp)
30939 +static void read_relocs(FILE *fp, int use_real_mode)
30940 {
30941 - int i,j;
30942 + unsigned int i,j;
30943 + uint32_t base;
30944 +
30945 for (i = 0; i < ehdr.e_shnum; i++) {
30946 struct section *sec = &secs[i];
30947 if (sec->shdr.sh_type != SHT_REL_TYPE) {
30948 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
30949 die("Cannot read symbol table: %s\n",
30950 strerror(errno));
30951 }
30952 + base = 0;
30953 +
30954 +#ifdef CONFIG_X86_32
30955 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30956 + if (phdr[j].p_type != PT_LOAD )
30957 + continue;
30958 + 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)
30959 + continue;
30960 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30961 + break;
30962 + }
30963 +#endif
30964 +
30965 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
30966 Elf_Rel *rel = &sec->reltab[j];
30967 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
30968 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
30969 rel->r_info = elf_xword_to_cpu(rel->r_info);
30970 #if (SHT_REL_TYPE == SHT_RELA)
30971 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
30972 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
30973
30974 static void print_absolute_symbols(void)
30975 {
30976 - int i;
30977 + unsigned int i;
30978 const char *format;
30979
30980 if (ELF_BITS == 64)
30981 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
30982 for (i = 0; i < ehdr.e_shnum; i++) {
30983 struct section *sec = &secs[i];
30984 char *sym_strtab;
30985 - int j;
30986 + unsigned int j;
30987
30988 if (sec->shdr.sh_type != SHT_SYMTAB) {
30989 continue;
30990 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
30991
30992 static void print_absolute_relocs(void)
30993 {
30994 - int i, printed = 0;
30995 + unsigned int i, printed = 0;
30996 const char *format;
30997
30998 if (ELF_BITS == 64)
30999 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
31000 struct section *sec_applies, *sec_symtab;
31001 char *sym_strtab;
31002 Elf_Sym *sh_symtab;
31003 - int j;
31004 + unsigned int j;
31005 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31006 continue;
31007 }
31008 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
31009 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
31010 Elf_Sym *sym, const char *symname))
31011 {
31012 - int i;
31013 + unsigned int i;
31014 /* Walk through the relocations */
31015 for (i = 0; i < ehdr.e_shnum; i++) {
31016 char *sym_strtab;
31017 Elf_Sym *sh_symtab;
31018 struct section *sec_applies, *sec_symtab;
31019 - int j;
31020 + unsigned int j;
31021 struct section *sec = &secs[i];
31022
31023 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31024 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31025 {
31026 unsigned r_type = ELF32_R_TYPE(rel->r_info);
31027 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
31028 + char *sym_strtab = sec->link->link->strtab;
31029 +
31030 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31031 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31032 + return 0;
31033 +
31034 +#ifdef CONFIG_PAX_KERNEXEC
31035 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31036 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31037 + return 0;
31038 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31039 + return 0;
31040 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31041 + return 0;
31042 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31043 + return 0;
31044 +#endif
31045
31046 switch (r_type) {
31047 case R_386_NONE:
31048 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
31049
31050 static void emit_relocs(int as_text, int use_real_mode)
31051 {
31052 - int i;
31053 + unsigned int i;
31054 int (*write_reloc)(uint32_t, FILE *) = write32;
31055 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31056 const char *symname);
31057 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
31058 {
31059 regex_init(use_real_mode);
31060 read_ehdr(fp);
31061 + read_phdrs(fp);
31062 read_shdrs(fp);
31063 read_strtabs(fp);
31064 read_symtabs(fp);
31065 - read_relocs(fp);
31066 + read_relocs(fp, use_real_mode);
31067 if (ELF_BITS == 64)
31068 percpu_init();
31069 if (show_absolute_syms) {
31070 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
31071 index 80ffa5b..a33bd15 100644
31072 --- a/arch/x86/um/tls_32.c
31073 +++ b/arch/x86/um/tls_32.c
31074 @@ -260,7 +260,7 @@ out:
31075 if (unlikely(task == current &&
31076 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
31077 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
31078 - "without flushed TLS.", current->pid);
31079 + "without flushed TLS.", task_pid_nr(current));
31080 }
31081
31082 return 0;
31083 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31084 index fd14be1..e3c79c0 100644
31085 --- a/arch/x86/vdso/Makefile
31086 +++ b/arch/x86/vdso/Makefile
31087 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31088 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31089 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31090
31091 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31092 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31093 GCOV_PROFILE := n
31094
31095 #
31096 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31097 index 0faad64..39ef157 100644
31098 --- a/arch/x86/vdso/vdso32-setup.c
31099 +++ b/arch/x86/vdso/vdso32-setup.c
31100 @@ -25,6 +25,7 @@
31101 #include <asm/tlbflush.h>
31102 #include <asm/vdso.h>
31103 #include <asm/proto.h>
31104 +#include <asm/mman.h>
31105
31106 enum {
31107 VDSO_DISABLED = 0,
31108 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31109 void enable_sep_cpu(void)
31110 {
31111 int cpu = get_cpu();
31112 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31113 + struct tss_struct *tss = init_tss + cpu;
31114
31115 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31116 put_cpu();
31117 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31118 gate_vma.vm_start = FIXADDR_USER_START;
31119 gate_vma.vm_end = FIXADDR_USER_END;
31120 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31121 - gate_vma.vm_page_prot = __P101;
31122 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31123
31124 return 0;
31125 }
31126 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31127 if (compat)
31128 addr = VDSO_HIGH_BASE;
31129 else {
31130 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31131 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31132 if (IS_ERR_VALUE(addr)) {
31133 ret = addr;
31134 goto up_fail;
31135 }
31136 }
31137
31138 - current->mm->context.vdso = (void *)addr;
31139 + current->mm->context.vdso = addr;
31140
31141 if (compat_uses_vma || !compat) {
31142 /*
31143 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31144 }
31145
31146 current_thread_info()->sysenter_return =
31147 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31148 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31149
31150 up_fail:
31151 if (ret)
31152 - current->mm->context.vdso = NULL;
31153 + current->mm->context.vdso = 0;
31154
31155 up_write(&mm->mmap_sem);
31156
31157 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31158
31159 const char *arch_vma_name(struct vm_area_struct *vma)
31160 {
31161 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31162 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31163 return "[vdso]";
31164 +
31165 +#ifdef CONFIG_PAX_SEGMEXEC
31166 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31167 + return "[vdso]";
31168 +#endif
31169 +
31170 return NULL;
31171 }
31172
31173 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31174 * Check to see if the corresponding task was created in compat vdso
31175 * mode.
31176 */
31177 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31178 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31179 return &gate_vma;
31180 return NULL;
31181 }
31182 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31183 index 431e875..cbb23f3 100644
31184 --- a/arch/x86/vdso/vma.c
31185 +++ b/arch/x86/vdso/vma.c
31186 @@ -16,8 +16,6 @@
31187 #include <asm/vdso.h>
31188 #include <asm/page.h>
31189
31190 -unsigned int __read_mostly vdso_enabled = 1;
31191 -
31192 extern char vdso_start[], vdso_end[];
31193 extern unsigned short vdso_sync_cpuid;
31194
31195 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31196 * unaligned here as a result of stack start randomization.
31197 */
31198 addr = PAGE_ALIGN(addr);
31199 - addr = align_vdso_addr(addr);
31200
31201 return addr;
31202 }
31203 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31204 unsigned size)
31205 {
31206 struct mm_struct *mm = current->mm;
31207 - unsigned long addr;
31208 + unsigned long addr = 0;
31209 int ret;
31210
31211 - if (!vdso_enabled)
31212 - return 0;
31213 -
31214 down_write(&mm->mmap_sem);
31215 +
31216 +#ifdef CONFIG_PAX_RANDMMAP
31217 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31218 +#endif
31219 +
31220 addr = vdso_addr(mm->start_stack, size);
31221 + addr = align_vdso_addr(addr);
31222 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31223 if (IS_ERR_VALUE(addr)) {
31224 ret = addr;
31225 goto up_fail;
31226 }
31227
31228 - current->mm->context.vdso = (void *)addr;
31229 + mm->context.vdso = addr;
31230
31231 ret = install_special_mapping(mm, addr, size,
31232 VM_READ|VM_EXEC|
31233 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31234 pages);
31235 - if (ret) {
31236 - current->mm->context.vdso = NULL;
31237 - goto up_fail;
31238 - }
31239 + if (ret)
31240 + mm->context.vdso = 0;
31241
31242 up_fail:
31243 up_write(&mm->mmap_sem);
31244 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31245 vdsox32_size);
31246 }
31247 #endif
31248 -
31249 -static __init int vdso_setup(char *s)
31250 -{
31251 - vdso_enabled = simple_strtoul(s, NULL, 0);
31252 - return 0;
31253 -}
31254 -__setup("vdso=", vdso_setup);
31255 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31256 index a492be2..08678da 100644
31257 --- a/arch/x86/xen/enlighten.c
31258 +++ b/arch/x86/xen/enlighten.c
31259 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31260
31261 struct shared_info xen_dummy_shared_info;
31262
31263 -void *xen_initial_gdt;
31264 -
31265 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31266 __read_mostly int xen_have_vector_callback;
31267 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31268 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31269 {
31270 unsigned long va = dtr->address;
31271 unsigned int size = dtr->size + 1;
31272 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31273 - unsigned long frames[pages];
31274 + unsigned long frames[65536 / PAGE_SIZE];
31275 int f;
31276
31277 /*
31278 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31279 {
31280 unsigned long va = dtr->address;
31281 unsigned int size = dtr->size + 1;
31282 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31283 - unsigned long frames[pages];
31284 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31285 int f;
31286
31287 /*
31288 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31289 * 8-byte entries, or 16 4k pages..
31290 */
31291
31292 - BUG_ON(size > 65536);
31293 + BUG_ON(size > GDT_SIZE);
31294 BUG_ON(va & ~PAGE_MASK);
31295
31296 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31297 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31298 return 0;
31299 }
31300
31301 -static void set_xen_basic_apic_ops(void)
31302 +static void __init set_xen_basic_apic_ops(void)
31303 {
31304 apic->read = xen_apic_read;
31305 apic->write = xen_apic_write;
31306 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31307 #endif
31308 };
31309
31310 -static void xen_reboot(int reason)
31311 +static __noreturn void xen_reboot(int reason)
31312 {
31313 struct sched_shutdown r = { .reason = reason };
31314
31315 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31316 - BUG();
31317 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31318 + BUG();
31319 }
31320
31321 -static void xen_restart(char *msg)
31322 +static __noreturn void xen_restart(char *msg)
31323 {
31324 xen_reboot(SHUTDOWN_reboot);
31325 }
31326
31327 -static void xen_emergency_restart(void)
31328 +static __noreturn void xen_emergency_restart(void)
31329 {
31330 xen_reboot(SHUTDOWN_reboot);
31331 }
31332
31333 -static void xen_machine_halt(void)
31334 +static __noreturn void xen_machine_halt(void)
31335 {
31336 xen_reboot(SHUTDOWN_poweroff);
31337 }
31338
31339 -static void xen_machine_power_off(void)
31340 +static __noreturn void xen_machine_power_off(void)
31341 {
31342 if (pm_power_off)
31343 pm_power_off();
31344 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
31345 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31346
31347 /* Work out if we support NX */
31348 - x86_configure_nx();
31349 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31350 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31351 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31352 + unsigned l, h;
31353 +
31354 + __supported_pte_mask |= _PAGE_NX;
31355 + rdmsr(MSR_EFER, l, h);
31356 + l |= EFER_NX;
31357 + wrmsr(MSR_EFER, l, h);
31358 + }
31359 +#endif
31360
31361 xen_setup_features();
31362
31363 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
31364
31365 machine_ops = xen_machine_ops;
31366
31367 - /*
31368 - * The only reliable way to retain the initial address of the
31369 - * percpu gdt_page is to remember it here, so we can go and
31370 - * mark it RW later, when the initial percpu area is freed.
31371 - */
31372 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31373 -
31374 xen_smp_init();
31375
31376 #ifdef CONFIG_ACPI_NUMA
31377 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31378 return NOTIFY_OK;
31379 }
31380
31381 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31382 +static struct notifier_block xen_hvm_cpu_notifier = {
31383 .notifier_call = xen_hvm_cpu_notify,
31384 };
31385
31386 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31387 index fdc3ba2..3daee39 100644
31388 --- a/arch/x86/xen/mmu.c
31389 +++ b/arch/x86/xen/mmu.c
31390 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31391 /* L3_k[510] -> level2_kernel_pgt
31392 * L3_i[511] -> level2_fixmap_pgt */
31393 convert_pfn_mfn(level3_kernel_pgt);
31394 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31395 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31396 + convert_pfn_mfn(level3_vmemmap_pgt);
31397
31398 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31399 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31400 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31401 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31402 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31403 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31404 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31405 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31406 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31407 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31408 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31409 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31410 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31411 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31412
31413 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
31414 pv_mmu_ops.set_pud = xen_set_pud;
31415 #if PAGETABLE_LEVELS == 4
31416 pv_mmu_ops.set_pgd = xen_set_pgd;
31417 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31418 #endif
31419
31420 /* This will work as long as patching hasn't happened yet
31421 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31422 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31423 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31424 .set_pgd = xen_set_pgd_hyper,
31425 + .set_pgd_batched = xen_set_pgd_hyper,
31426
31427 .alloc_pud = xen_alloc_pmd_init,
31428 .release_pud = xen_release_pmd_init,
31429 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31430 index d99cae8..18401e1 100644
31431 --- a/arch/x86/xen/smp.c
31432 +++ b/arch/x86/xen/smp.c
31433 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31434 {
31435 BUG_ON(smp_processor_id() != 0);
31436 native_smp_prepare_boot_cpu();
31437 -
31438 - /* We've switched to the "real" per-cpu gdt, so make sure the
31439 - old memory can be recycled */
31440 - make_lowmem_page_readwrite(xen_initial_gdt);
31441 -
31442 xen_filter_cpu_maps();
31443 xen_setup_vcpu_info_placement();
31444 }
31445 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31446 ctxt->user_regs.ss = __KERNEL_DS;
31447 #ifdef CONFIG_X86_32
31448 ctxt->user_regs.fs = __KERNEL_PERCPU;
31449 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31450 + savesegment(gs, ctxt->user_regs.gs);
31451 #else
31452 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31453 #endif
31454 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31455
31456 {
31457 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31458 - ctxt->user_regs.ds = __USER_DS;
31459 - ctxt->user_regs.es = __USER_DS;
31460 + ctxt->user_regs.ds = __KERNEL_DS;
31461 + ctxt->user_regs.es = __KERNEL_DS;
31462
31463 xen_copy_trap_info(ctxt->trap_ctxt);
31464
31465 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31466 int rc;
31467
31468 per_cpu(current_task, cpu) = idle;
31469 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31470 #ifdef CONFIG_X86_32
31471 irq_ctx_init(cpu);
31472 #else
31473 clear_tsk_thread_flag(idle, TIF_FORK);
31474 - per_cpu(kernel_stack, cpu) =
31475 - (unsigned long)task_stack_page(idle) -
31476 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31477 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31478 #endif
31479 xen_setup_runstate_info(cpu);
31480 xen_setup_timer(cpu);
31481 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31482
31483 void __init xen_smp_init(void)
31484 {
31485 - smp_ops = xen_smp_ops;
31486 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31487 xen_fill_possible_map();
31488 xen_init_spinlocks();
31489 }
31490 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31491 index 33ca6e4..0ded929 100644
31492 --- a/arch/x86/xen/xen-asm_32.S
31493 +++ b/arch/x86/xen/xen-asm_32.S
31494 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31495 ESP_OFFSET=4 # bytes pushed onto stack
31496
31497 /*
31498 - * Store vcpu_info pointer for easy access. Do it this way to
31499 - * avoid having to reload %fs
31500 + * Store vcpu_info pointer for easy access.
31501 */
31502 #ifdef CONFIG_SMP
31503 - GET_THREAD_INFO(%eax)
31504 - movl %ss:TI_cpu(%eax), %eax
31505 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31506 - mov %ss:xen_vcpu(%eax), %eax
31507 + push %fs
31508 + mov $(__KERNEL_PERCPU), %eax
31509 + mov %eax, %fs
31510 + mov PER_CPU_VAR(xen_vcpu), %eax
31511 + pop %fs
31512 #else
31513 movl %ss:xen_vcpu, %eax
31514 #endif
31515 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31516 index 7faed58..ba4427c 100644
31517 --- a/arch/x86/xen/xen-head.S
31518 +++ b/arch/x86/xen/xen-head.S
31519 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31520 #ifdef CONFIG_X86_32
31521 mov %esi,xen_start_info
31522 mov $init_thread_union+THREAD_SIZE,%esp
31523 +#ifdef CONFIG_SMP
31524 + movl $cpu_gdt_table,%edi
31525 + movl $__per_cpu_load,%eax
31526 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31527 + rorl $16,%eax
31528 + movb %al,__KERNEL_PERCPU + 4(%edi)
31529 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31530 + movl $__per_cpu_end - 1,%eax
31531 + subl $__per_cpu_start,%eax
31532 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31533 +#endif
31534 #else
31535 mov %rsi,xen_start_info
31536 mov $init_thread_union+THREAD_SIZE,%rsp
31537 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31538 index a95b417..b6dbd0b 100644
31539 --- a/arch/x86/xen/xen-ops.h
31540 +++ b/arch/x86/xen/xen-ops.h
31541 @@ -10,8 +10,6 @@
31542 extern const char xen_hypervisor_callback[];
31543 extern const char xen_failsafe_callback[];
31544
31545 -extern void *xen_initial_gdt;
31546 -
31547 struct trap_info;
31548 void xen_copy_trap_info(struct trap_info *traps);
31549
31550 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31551 index 525bd3d..ef888b1 100644
31552 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31553 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31554 @@ -119,9 +119,9 @@
31555 ----------------------------------------------------------------------*/
31556
31557 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31558 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31559 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31560 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31561 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31562
31563 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31564 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31565 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31566 index 2f33760..835e50a 100644
31567 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31568 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31569 @@ -11,6 +11,7 @@
31570 #ifndef _XTENSA_CORE_H
31571 #define _XTENSA_CORE_H
31572
31573 +#include <linux/const.h>
31574
31575 /****************************************************************************
31576 Parameters Useful for Any Code, USER or PRIVILEGED
31577 @@ -112,9 +113,9 @@
31578 ----------------------------------------------------------------------*/
31579
31580 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31581 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31582 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31583 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31584 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31585
31586 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31587 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31588 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31589 index af00795..2bb8105 100644
31590 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31591 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31592 @@ -11,6 +11,7 @@
31593 #ifndef _XTENSA_CORE_CONFIGURATION_H
31594 #define _XTENSA_CORE_CONFIGURATION_H
31595
31596 +#include <linux/const.h>
31597
31598 /****************************************************************************
31599 Parameters Useful for Any Code, USER or PRIVILEGED
31600 @@ -118,9 +119,9 @@
31601 ----------------------------------------------------------------------*/
31602
31603 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31604 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31605 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31606 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31607 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31608
31609 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31610 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31611 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31612 index 58916af..eb9dbcf6 100644
31613 --- a/block/blk-iopoll.c
31614 +++ b/block/blk-iopoll.c
31615 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31616 }
31617 EXPORT_SYMBOL(blk_iopoll_complete);
31618
31619 -static void blk_iopoll_softirq(struct softirq_action *h)
31620 +static void blk_iopoll_softirq(void)
31621 {
31622 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31623 int rearm = 0, budget = blk_iopoll_budget;
31624 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31625 return NOTIFY_OK;
31626 }
31627
31628 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31629 +static struct notifier_block blk_iopoll_cpu_notifier = {
31630 .notifier_call = blk_iopoll_cpu_notify,
31631 };
31632
31633 diff --git a/block/blk-map.c b/block/blk-map.c
31634 index 623e1cd..ca1e109 100644
31635 --- a/block/blk-map.c
31636 +++ b/block/blk-map.c
31637 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31638 if (!len || !kbuf)
31639 return -EINVAL;
31640
31641 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31642 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31643 if (do_copy)
31644 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31645 else
31646 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31647 index 467c8de..f3628c5 100644
31648 --- a/block/blk-softirq.c
31649 +++ b/block/blk-softirq.c
31650 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31651 * Softirq action handler - move entries to local list and loop over them
31652 * while passing them to the queue registered handler.
31653 */
31654 -static void blk_done_softirq(struct softirq_action *h)
31655 +static void blk_done_softirq(void)
31656 {
31657 struct list_head *cpu_list, local_list;
31658
31659 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31660 return NOTIFY_OK;
31661 }
31662
31663 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31664 +static struct notifier_block blk_cpu_notifier = {
31665 .notifier_call = blk_cpu_notify,
31666 };
31667
31668 diff --git a/block/bsg.c b/block/bsg.c
31669 index 420a5a9..23834aa 100644
31670 --- a/block/bsg.c
31671 +++ b/block/bsg.c
31672 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31673 struct sg_io_v4 *hdr, struct bsg_device *bd,
31674 fmode_t has_write_perm)
31675 {
31676 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31677 + unsigned char *cmdptr;
31678 +
31679 if (hdr->request_len > BLK_MAX_CDB) {
31680 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31681 if (!rq->cmd)
31682 return -ENOMEM;
31683 - }
31684 + cmdptr = rq->cmd;
31685 + } else
31686 + cmdptr = tmpcmd;
31687
31688 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31689 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31690 hdr->request_len))
31691 return -EFAULT;
31692
31693 + if (cmdptr != rq->cmd)
31694 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31695 +
31696 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31697 if (blk_verify_command(rq->cmd, has_write_perm))
31698 return -EPERM;
31699 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31700 index 7c668c8..db3521c 100644
31701 --- a/block/compat_ioctl.c
31702 +++ b/block/compat_ioctl.c
31703 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31704 err |= __get_user(f->spec1, &uf->spec1);
31705 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31706 err |= __get_user(name, &uf->name);
31707 - f->name = compat_ptr(name);
31708 + f->name = (void __force_kernel *)compat_ptr(name);
31709 if (err) {
31710 err = -EFAULT;
31711 goto out;
31712 diff --git a/block/genhd.c b/block/genhd.c
31713 index 20625ee..10aa34d 100644
31714 --- a/block/genhd.c
31715 +++ b/block/genhd.c
31716 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31717
31718 /*
31719 * Register device numbers dev..(dev+range-1)
31720 - * range must be nonzero
31721 + * Noop if @range is zero.
31722 * The hash chain is sorted on range, so that subranges can override.
31723 */
31724 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31725 struct kobject *(*probe)(dev_t, int *, void *),
31726 int (*lock)(dev_t, void *), void *data)
31727 {
31728 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31729 + if (range)
31730 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31731 }
31732
31733 EXPORT_SYMBOL(blk_register_region);
31734
31735 +/* undo blk_register_region(), noop if @range is zero */
31736 void blk_unregister_region(dev_t devt, unsigned long range)
31737 {
31738 - kobj_unmap(bdev_map, devt, range);
31739 + if (range)
31740 + kobj_unmap(bdev_map, devt, range);
31741 }
31742
31743 EXPORT_SYMBOL(blk_unregister_region);
31744 @@ -512,7 +515,7 @@ static void register_disk(struct gendisk *disk)
31745
31746 ddev->parent = disk->driverfs_dev;
31747
31748 - dev_set_name(ddev, disk->disk_name);
31749 + dev_set_name(ddev, "%s", disk->disk_name);
31750
31751 /* delay uevents, until we scanned partition table */
31752 dev_set_uevent_suppress(ddev, 1);
31753 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31754 index c85fc89..51e690b 100644
31755 --- a/block/partitions/efi.c
31756 +++ b/block/partitions/efi.c
31757 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31758 if (!gpt)
31759 return NULL;
31760
31761 + if (!le32_to_cpu(gpt->num_partition_entries))
31762 + return NULL;
31763 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31764 + if (!pte)
31765 + return NULL;
31766 +
31767 count = le32_to_cpu(gpt->num_partition_entries) *
31768 le32_to_cpu(gpt->sizeof_partition_entry);
31769 - if (!count)
31770 - return NULL;
31771 - pte = kmalloc(count, GFP_KERNEL);
31772 - if (!pte)
31773 - return NULL;
31774 -
31775 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31776 (u8 *) pte,
31777 count) < count) {
31778 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31779 index a5ffcc9..3cedc9c 100644
31780 --- a/block/scsi_ioctl.c
31781 +++ b/block/scsi_ioctl.c
31782 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
31783 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31784 struct sg_io_hdr *hdr, fmode_t mode)
31785 {
31786 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31787 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31788 + unsigned char *cmdptr;
31789 +
31790 + if (rq->cmd != rq->__cmd)
31791 + cmdptr = rq->cmd;
31792 + else
31793 + cmdptr = tmpcmd;
31794 +
31795 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31796 return -EFAULT;
31797 +
31798 + if (cmdptr != rq->cmd)
31799 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31800 +
31801 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31802 return -EPERM;
31803
31804 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31805 int err;
31806 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31807 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31808 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31809 + unsigned char *cmdptr;
31810
31811 if (!sic)
31812 return -EINVAL;
31813 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31814 */
31815 err = -EFAULT;
31816 rq->cmd_len = cmdlen;
31817 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31818 +
31819 + if (rq->cmd != rq->__cmd)
31820 + cmdptr = rq->cmd;
31821 + else
31822 + cmdptr = tmpcmd;
31823 +
31824 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31825 goto error;
31826
31827 + if (rq->cmd != cmdptr)
31828 + memcpy(rq->cmd, cmdptr, cmdlen);
31829 +
31830 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31831 goto error;
31832
31833 diff --git a/crypto/algapi.c b/crypto/algapi.c
31834 index 6149a6e..55ed50d 100644
31835 --- a/crypto/algapi.c
31836 +++ b/crypto/algapi.c
31837 @@ -495,7 +495,7 @@ static struct crypto_template *__crypto_lookup_template(const char *name)
31838
31839 struct crypto_template *crypto_lookup_template(const char *name)
31840 {
31841 - return try_then_request_module(__crypto_lookup_template(name), name);
31842 + return try_then_request_module(__crypto_lookup_template(name), "%s", name);
31843 }
31844 EXPORT_SYMBOL_GPL(crypto_lookup_template);
31845
31846 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31847 index 7bdd61b..afec999 100644
31848 --- a/crypto/cryptd.c
31849 +++ b/crypto/cryptd.c
31850 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31851
31852 struct cryptd_blkcipher_request_ctx {
31853 crypto_completion_t complete;
31854 -};
31855 +} __no_const;
31856
31857 struct cryptd_hash_ctx {
31858 struct crypto_shash *child;
31859 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31860
31861 struct cryptd_aead_request_ctx {
31862 crypto_completion_t complete;
31863 -};
31864 +} __no_const;
31865
31866 static void cryptd_queue_worker(struct work_struct *work);
31867
31868 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31869 index b2c99dc..476c9fb 100644
31870 --- a/crypto/pcrypt.c
31871 +++ b/crypto/pcrypt.c
31872 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31873 int ret;
31874
31875 pinst->kobj.kset = pcrypt_kset;
31876 - ret = kobject_add(&pinst->kobj, NULL, name);
31877 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31878 if (!ret)
31879 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31880
31881 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31882
31883 get_online_cpus();
31884
31885 - pcrypt->wq = alloc_workqueue(name,
31886 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31887 + pcrypt->wq = alloc_workqueue("%s",
31888 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31889 if (!pcrypt->wq)
31890 goto err;
31891
31892 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31893 index f220d64..d359ad6 100644
31894 --- a/drivers/acpi/apei/apei-internal.h
31895 +++ b/drivers/acpi/apei/apei-internal.h
31896 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31897 struct apei_exec_ins_type {
31898 u32 flags;
31899 apei_exec_ins_func_t run;
31900 -};
31901 +} __do_const;
31902
31903 struct apei_exec_context {
31904 u32 ip;
31905 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31906 index 33dc6a0..4b24b47 100644
31907 --- a/drivers/acpi/apei/cper.c
31908 +++ b/drivers/acpi/apei/cper.c
31909 @@ -39,12 +39,12 @@
31910 */
31911 u64 cper_next_record_id(void)
31912 {
31913 - static atomic64_t seq;
31914 + static atomic64_unchecked_t seq;
31915
31916 - if (!atomic64_read(&seq))
31917 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31918 + if (!atomic64_read_unchecked(&seq))
31919 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31920
31921 - return atomic64_inc_return(&seq);
31922 + return atomic64_inc_return_unchecked(&seq);
31923 }
31924 EXPORT_SYMBOL_GPL(cper_next_record_id);
31925
31926 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31927 index be60399..778b33e8 100644
31928 --- a/drivers/acpi/bgrt.c
31929 +++ b/drivers/acpi/bgrt.c
31930 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31931 return -ENODEV;
31932
31933 sysfs_bin_attr_init(&image_attr);
31934 - image_attr.private = bgrt_image;
31935 - image_attr.size = bgrt_image_size;
31936 + pax_open_kernel();
31937 + *(void **)&image_attr.private = bgrt_image;
31938 + *(size_t *)&image_attr.size = bgrt_image_size;
31939 + pax_close_kernel();
31940
31941 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31942 if (!bgrt_kobj)
31943 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31944 index cb96296..b81293b 100644
31945 --- a/drivers/acpi/blacklist.c
31946 +++ b/drivers/acpi/blacklist.c
31947 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31948 u32 is_critical_error;
31949 };
31950
31951 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31952 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31953
31954 /*
31955 * POLICY: If *anything* doesn't work, put it on the blacklist.
31956 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31957 return 0;
31958 }
31959
31960 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31961 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31962 {
31963 .callback = dmi_disable_osi_vista,
31964 .ident = "Fujitsu Siemens",
31965 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31966 index 7586544..636a2f0 100644
31967 --- a/drivers/acpi/ec_sys.c
31968 +++ b/drivers/acpi/ec_sys.c
31969 @@ -12,6 +12,7 @@
31970 #include <linux/acpi.h>
31971 #include <linux/debugfs.h>
31972 #include <linux/module.h>
31973 +#include <linux/uaccess.h>
31974 #include "internal.h"
31975
31976 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31977 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31978 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31979 */
31980 unsigned int size = EC_SPACE_SIZE;
31981 - u8 *data = (u8 *) buf;
31982 + u8 data;
31983 loff_t init_off = *off;
31984 int err = 0;
31985
31986 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31987 size = count;
31988
31989 while (size) {
31990 - err = ec_read(*off, &data[*off - init_off]);
31991 + err = ec_read(*off, &data);
31992 if (err)
31993 return err;
31994 + if (put_user(data, &buf[*off - init_off]))
31995 + return -EFAULT;
31996 *off += 1;
31997 size--;
31998 }
31999 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32000
32001 unsigned int size = count;
32002 loff_t init_off = *off;
32003 - u8 *data = (u8 *) buf;
32004 int err = 0;
32005
32006 if (*off >= EC_SPACE_SIZE)
32007 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32008 }
32009
32010 while (size) {
32011 - u8 byte_write = data[*off - init_off];
32012 + u8 byte_write;
32013 + if (get_user(byte_write, &buf[*off - init_off]))
32014 + return -EFAULT;
32015 err = ec_write(*off, byte_write);
32016 if (err)
32017 return err;
32018 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32019 index eb133c7..f571552 100644
32020 --- a/drivers/acpi/processor_idle.c
32021 +++ b/drivers/acpi/processor_idle.c
32022 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32023 {
32024 int i, count = CPUIDLE_DRIVER_STATE_START;
32025 struct acpi_processor_cx *cx;
32026 - struct cpuidle_state *state;
32027 + cpuidle_state_no_const *state;
32028 struct cpuidle_driver *drv = &acpi_idle_driver;
32029
32030 if (!pr->flags.power_setup_done)
32031 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32032 index fcae5fa..e9f71ea 100644
32033 --- a/drivers/acpi/sysfs.c
32034 +++ b/drivers/acpi/sysfs.c
32035 @@ -423,11 +423,11 @@ static u32 num_counters;
32036 static struct attribute **all_attrs;
32037 static u32 acpi_gpe_count;
32038
32039 -static struct attribute_group interrupt_stats_attr_group = {
32040 +static attribute_group_no_const interrupt_stats_attr_group = {
32041 .name = "interrupts",
32042 };
32043
32044 -static struct kobj_attribute *counter_attrs;
32045 +static kobj_attribute_no_const *counter_attrs;
32046
32047 static void delete_gpe_attr_array(void)
32048 {
32049 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32050 index a70ff15..f1ff44e 100644
32051 --- a/drivers/ata/libahci.c
32052 +++ b/drivers/ata/libahci.c
32053 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32054 }
32055 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32056
32057 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32058 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32059 struct ata_taskfile *tf, int is_cmd, u16 flags,
32060 unsigned long timeout_msec)
32061 {
32062 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32063 index adf002a..39bb8f9 100644
32064 --- a/drivers/ata/libata-core.c
32065 +++ b/drivers/ata/libata-core.c
32066 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32067 struct ata_port *ap;
32068 unsigned int tag;
32069
32070 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32071 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32072 ap = qc->ap;
32073
32074 qc->flags = 0;
32075 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32076 struct ata_port *ap;
32077 struct ata_link *link;
32078
32079 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32080 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32081 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32082 ap = qc->ap;
32083 link = qc->dev->link;
32084 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32085 return;
32086
32087 spin_lock(&lock);
32088 + pax_open_kernel();
32089
32090 for (cur = ops->inherits; cur; cur = cur->inherits) {
32091 void **inherit = (void **)cur;
32092 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32093 if (IS_ERR(*pp))
32094 *pp = NULL;
32095
32096 - ops->inherits = NULL;
32097 + *(struct ata_port_operations **)&ops->inherits = NULL;
32098
32099 + pax_close_kernel();
32100 spin_unlock(&lock);
32101 }
32102
32103 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32104 index 7638121..357a965 100644
32105 --- a/drivers/ata/pata_arasan_cf.c
32106 +++ b/drivers/ata/pata_arasan_cf.c
32107 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32108 /* Handle platform specific quirks */
32109 if (quirk) {
32110 if (quirk & CF_BROKEN_PIO) {
32111 - ap->ops->set_piomode = NULL;
32112 + pax_open_kernel();
32113 + *(void **)&ap->ops->set_piomode = NULL;
32114 + pax_close_kernel();
32115 ap->pio_mask = 0;
32116 }
32117 if (quirk & CF_BROKEN_MWDMA)
32118 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32119 index f9b983a..887b9d8 100644
32120 --- a/drivers/atm/adummy.c
32121 +++ b/drivers/atm/adummy.c
32122 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32123 vcc->pop(vcc, skb);
32124 else
32125 dev_kfree_skb_any(skb);
32126 - atomic_inc(&vcc->stats->tx);
32127 + atomic_inc_unchecked(&vcc->stats->tx);
32128
32129 return 0;
32130 }
32131 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32132 index 77a7480d..05cde58 100644
32133 --- a/drivers/atm/ambassador.c
32134 +++ b/drivers/atm/ambassador.c
32135 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32136 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32137
32138 // VC layer stats
32139 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32140 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32141
32142 // free the descriptor
32143 kfree (tx_descr);
32144 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32145 dump_skb ("<<<", vc, skb);
32146
32147 // VC layer stats
32148 - atomic_inc(&atm_vcc->stats->rx);
32149 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32150 __net_timestamp(skb);
32151 // end of our responsibility
32152 atm_vcc->push (atm_vcc, skb);
32153 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32154 } else {
32155 PRINTK (KERN_INFO, "dropped over-size frame");
32156 // should we count this?
32157 - atomic_inc(&atm_vcc->stats->rx_drop);
32158 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32159 }
32160
32161 } else {
32162 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32163 }
32164
32165 if (check_area (skb->data, skb->len)) {
32166 - atomic_inc(&atm_vcc->stats->tx_err);
32167 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32168 return -ENOMEM; // ?
32169 }
32170
32171 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32172 index 0e3f8f9..765a7a5 100644
32173 --- a/drivers/atm/atmtcp.c
32174 +++ b/drivers/atm/atmtcp.c
32175 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32176 if (vcc->pop) vcc->pop(vcc,skb);
32177 else dev_kfree_skb(skb);
32178 if (dev_data) return 0;
32179 - atomic_inc(&vcc->stats->tx_err);
32180 + atomic_inc_unchecked(&vcc->stats->tx_err);
32181 return -ENOLINK;
32182 }
32183 size = skb->len+sizeof(struct atmtcp_hdr);
32184 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32185 if (!new_skb) {
32186 if (vcc->pop) vcc->pop(vcc,skb);
32187 else dev_kfree_skb(skb);
32188 - atomic_inc(&vcc->stats->tx_err);
32189 + atomic_inc_unchecked(&vcc->stats->tx_err);
32190 return -ENOBUFS;
32191 }
32192 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32193 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32194 if (vcc->pop) vcc->pop(vcc,skb);
32195 else dev_kfree_skb(skb);
32196 out_vcc->push(out_vcc,new_skb);
32197 - atomic_inc(&vcc->stats->tx);
32198 - atomic_inc(&out_vcc->stats->rx);
32199 + atomic_inc_unchecked(&vcc->stats->tx);
32200 + atomic_inc_unchecked(&out_vcc->stats->rx);
32201 return 0;
32202 }
32203
32204 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32205 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32206 read_unlock(&vcc_sklist_lock);
32207 if (!out_vcc) {
32208 - atomic_inc(&vcc->stats->tx_err);
32209 + atomic_inc_unchecked(&vcc->stats->tx_err);
32210 goto done;
32211 }
32212 skb_pull(skb,sizeof(struct atmtcp_hdr));
32213 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32214 __net_timestamp(new_skb);
32215 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32216 out_vcc->push(out_vcc,new_skb);
32217 - atomic_inc(&vcc->stats->tx);
32218 - atomic_inc(&out_vcc->stats->rx);
32219 + atomic_inc_unchecked(&vcc->stats->tx);
32220 + atomic_inc_unchecked(&out_vcc->stats->rx);
32221 done:
32222 if (vcc->pop) vcc->pop(vcc,skb);
32223 else dev_kfree_skb(skb);
32224 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32225 index b1955ba..b179940 100644
32226 --- a/drivers/atm/eni.c
32227 +++ b/drivers/atm/eni.c
32228 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32229 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32230 vcc->dev->number);
32231 length = 0;
32232 - atomic_inc(&vcc->stats->rx_err);
32233 + atomic_inc_unchecked(&vcc->stats->rx_err);
32234 }
32235 else {
32236 length = ATM_CELL_SIZE-1; /* no HEC */
32237 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32238 size);
32239 }
32240 eff = length = 0;
32241 - atomic_inc(&vcc->stats->rx_err);
32242 + atomic_inc_unchecked(&vcc->stats->rx_err);
32243 }
32244 else {
32245 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32246 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32247 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32248 vcc->dev->number,vcc->vci,length,size << 2,descr);
32249 length = eff = 0;
32250 - atomic_inc(&vcc->stats->rx_err);
32251 + atomic_inc_unchecked(&vcc->stats->rx_err);
32252 }
32253 }
32254 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32255 @@ -767,7 +767,7 @@ rx_dequeued++;
32256 vcc->push(vcc,skb);
32257 pushed++;
32258 }
32259 - atomic_inc(&vcc->stats->rx);
32260 + atomic_inc_unchecked(&vcc->stats->rx);
32261 }
32262 wake_up(&eni_dev->rx_wait);
32263 }
32264 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32265 PCI_DMA_TODEVICE);
32266 if (vcc->pop) vcc->pop(vcc,skb);
32267 else dev_kfree_skb_irq(skb);
32268 - atomic_inc(&vcc->stats->tx);
32269 + atomic_inc_unchecked(&vcc->stats->tx);
32270 wake_up(&eni_dev->tx_wait);
32271 dma_complete++;
32272 }
32273 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32274 index b41c948..a002b17 100644
32275 --- a/drivers/atm/firestream.c
32276 +++ b/drivers/atm/firestream.c
32277 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32278 }
32279 }
32280
32281 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32282 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32283
32284 fs_dprintk (FS_DEBUG_TXMEM, "i");
32285 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32286 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32287 #endif
32288 skb_put (skb, qe->p1 & 0xffff);
32289 ATM_SKB(skb)->vcc = atm_vcc;
32290 - atomic_inc(&atm_vcc->stats->rx);
32291 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32292 __net_timestamp(skb);
32293 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32294 atm_vcc->push (atm_vcc, skb);
32295 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32296 kfree (pe);
32297 }
32298 if (atm_vcc)
32299 - atomic_inc(&atm_vcc->stats->rx_drop);
32300 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32301 break;
32302 case 0x1f: /* Reassembly abort: no buffers. */
32303 /* Silently increment error counter. */
32304 if (atm_vcc)
32305 - atomic_inc(&atm_vcc->stats->rx_drop);
32306 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32307 break;
32308 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32309 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32310 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32311 index 204814e..cede831 100644
32312 --- a/drivers/atm/fore200e.c
32313 +++ b/drivers/atm/fore200e.c
32314 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32315 #endif
32316 /* check error condition */
32317 if (*entry->status & STATUS_ERROR)
32318 - atomic_inc(&vcc->stats->tx_err);
32319 + atomic_inc_unchecked(&vcc->stats->tx_err);
32320 else
32321 - atomic_inc(&vcc->stats->tx);
32322 + atomic_inc_unchecked(&vcc->stats->tx);
32323 }
32324 }
32325
32326 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32327 if (skb == NULL) {
32328 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32329
32330 - atomic_inc(&vcc->stats->rx_drop);
32331 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32332 return -ENOMEM;
32333 }
32334
32335 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32336
32337 dev_kfree_skb_any(skb);
32338
32339 - atomic_inc(&vcc->stats->rx_drop);
32340 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32341 return -ENOMEM;
32342 }
32343
32344 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32345
32346 vcc->push(vcc, skb);
32347 - atomic_inc(&vcc->stats->rx);
32348 + atomic_inc_unchecked(&vcc->stats->rx);
32349
32350 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32351
32352 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32353 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32354 fore200e->atm_dev->number,
32355 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32356 - atomic_inc(&vcc->stats->rx_err);
32357 + atomic_inc_unchecked(&vcc->stats->rx_err);
32358 }
32359 }
32360
32361 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32362 goto retry_here;
32363 }
32364
32365 - atomic_inc(&vcc->stats->tx_err);
32366 + atomic_inc_unchecked(&vcc->stats->tx_err);
32367
32368 fore200e->tx_sat++;
32369 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32370 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32371 index 507362a..a845e57 100644
32372 --- a/drivers/atm/he.c
32373 +++ b/drivers/atm/he.c
32374 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32375
32376 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32377 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32378 - atomic_inc(&vcc->stats->rx_drop);
32379 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32380 goto return_host_buffers;
32381 }
32382
32383 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32384 RBRQ_LEN_ERR(he_dev->rbrq_head)
32385 ? "LEN_ERR" : "",
32386 vcc->vpi, vcc->vci);
32387 - atomic_inc(&vcc->stats->rx_err);
32388 + atomic_inc_unchecked(&vcc->stats->rx_err);
32389 goto return_host_buffers;
32390 }
32391
32392 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32393 vcc->push(vcc, skb);
32394 spin_lock(&he_dev->global_lock);
32395
32396 - atomic_inc(&vcc->stats->rx);
32397 + atomic_inc_unchecked(&vcc->stats->rx);
32398
32399 return_host_buffers:
32400 ++pdus_assembled;
32401 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32402 tpd->vcc->pop(tpd->vcc, tpd->skb);
32403 else
32404 dev_kfree_skb_any(tpd->skb);
32405 - atomic_inc(&tpd->vcc->stats->tx_err);
32406 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32407 }
32408 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32409 return;
32410 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32411 vcc->pop(vcc, skb);
32412 else
32413 dev_kfree_skb_any(skb);
32414 - atomic_inc(&vcc->stats->tx_err);
32415 + atomic_inc_unchecked(&vcc->stats->tx_err);
32416 return -EINVAL;
32417 }
32418
32419 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32420 vcc->pop(vcc, skb);
32421 else
32422 dev_kfree_skb_any(skb);
32423 - atomic_inc(&vcc->stats->tx_err);
32424 + atomic_inc_unchecked(&vcc->stats->tx_err);
32425 return -EINVAL;
32426 }
32427 #endif
32428 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32429 vcc->pop(vcc, skb);
32430 else
32431 dev_kfree_skb_any(skb);
32432 - atomic_inc(&vcc->stats->tx_err);
32433 + atomic_inc_unchecked(&vcc->stats->tx_err);
32434 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32435 return -ENOMEM;
32436 }
32437 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32438 vcc->pop(vcc, skb);
32439 else
32440 dev_kfree_skb_any(skb);
32441 - atomic_inc(&vcc->stats->tx_err);
32442 + atomic_inc_unchecked(&vcc->stats->tx_err);
32443 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32444 return -ENOMEM;
32445 }
32446 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32447 __enqueue_tpd(he_dev, tpd, cid);
32448 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32449
32450 - atomic_inc(&vcc->stats->tx);
32451 + atomic_inc_unchecked(&vcc->stats->tx);
32452
32453 return 0;
32454 }
32455 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32456 index 1dc0519..1aadaf7 100644
32457 --- a/drivers/atm/horizon.c
32458 +++ b/drivers/atm/horizon.c
32459 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32460 {
32461 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32462 // VC layer stats
32463 - atomic_inc(&vcc->stats->rx);
32464 + atomic_inc_unchecked(&vcc->stats->rx);
32465 __net_timestamp(skb);
32466 // end of our responsibility
32467 vcc->push (vcc, skb);
32468 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32469 dev->tx_iovec = NULL;
32470
32471 // VC layer stats
32472 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32473 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32474
32475 // free the skb
32476 hrz_kfree_skb (skb);
32477 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32478 index 272f009..a18ba55 100644
32479 --- a/drivers/atm/idt77252.c
32480 +++ b/drivers/atm/idt77252.c
32481 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32482 else
32483 dev_kfree_skb(skb);
32484
32485 - atomic_inc(&vcc->stats->tx);
32486 + atomic_inc_unchecked(&vcc->stats->tx);
32487 }
32488
32489 atomic_dec(&scq->used);
32490 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32491 if ((sb = dev_alloc_skb(64)) == NULL) {
32492 printk("%s: Can't allocate buffers for aal0.\n",
32493 card->name);
32494 - atomic_add(i, &vcc->stats->rx_drop);
32495 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32496 break;
32497 }
32498 if (!atm_charge(vcc, sb->truesize)) {
32499 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32500 card->name);
32501 - atomic_add(i - 1, &vcc->stats->rx_drop);
32502 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32503 dev_kfree_skb(sb);
32504 break;
32505 }
32506 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32507 ATM_SKB(sb)->vcc = vcc;
32508 __net_timestamp(sb);
32509 vcc->push(vcc, sb);
32510 - atomic_inc(&vcc->stats->rx);
32511 + atomic_inc_unchecked(&vcc->stats->rx);
32512
32513 cell += ATM_CELL_PAYLOAD;
32514 }
32515 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32516 "(CDC: %08x)\n",
32517 card->name, len, rpp->len, readl(SAR_REG_CDC));
32518 recycle_rx_pool_skb(card, rpp);
32519 - atomic_inc(&vcc->stats->rx_err);
32520 + atomic_inc_unchecked(&vcc->stats->rx_err);
32521 return;
32522 }
32523 if (stat & SAR_RSQE_CRC) {
32524 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32525 recycle_rx_pool_skb(card, rpp);
32526 - atomic_inc(&vcc->stats->rx_err);
32527 + atomic_inc_unchecked(&vcc->stats->rx_err);
32528 return;
32529 }
32530 if (skb_queue_len(&rpp->queue) > 1) {
32531 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32532 RXPRINTK("%s: Can't alloc RX skb.\n",
32533 card->name);
32534 recycle_rx_pool_skb(card, rpp);
32535 - atomic_inc(&vcc->stats->rx_err);
32536 + atomic_inc_unchecked(&vcc->stats->rx_err);
32537 return;
32538 }
32539 if (!atm_charge(vcc, skb->truesize)) {
32540 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32541 __net_timestamp(skb);
32542
32543 vcc->push(vcc, skb);
32544 - atomic_inc(&vcc->stats->rx);
32545 + atomic_inc_unchecked(&vcc->stats->rx);
32546
32547 return;
32548 }
32549 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32550 __net_timestamp(skb);
32551
32552 vcc->push(vcc, skb);
32553 - atomic_inc(&vcc->stats->rx);
32554 + atomic_inc_unchecked(&vcc->stats->rx);
32555
32556 if (skb->truesize > SAR_FB_SIZE_3)
32557 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32558 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32559 if (vcc->qos.aal != ATM_AAL0) {
32560 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32561 card->name, vpi, vci);
32562 - atomic_inc(&vcc->stats->rx_drop);
32563 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32564 goto drop;
32565 }
32566
32567 if ((sb = dev_alloc_skb(64)) == NULL) {
32568 printk("%s: Can't allocate buffers for AAL0.\n",
32569 card->name);
32570 - atomic_inc(&vcc->stats->rx_err);
32571 + atomic_inc_unchecked(&vcc->stats->rx_err);
32572 goto drop;
32573 }
32574
32575 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32576 ATM_SKB(sb)->vcc = vcc;
32577 __net_timestamp(sb);
32578 vcc->push(vcc, sb);
32579 - atomic_inc(&vcc->stats->rx);
32580 + atomic_inc_unchecked(&vcc->stats->rx);
32581
32582 drop:
32583 skb_pull(queue, 64);
32584 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32585
32586 if (vc == NULL) {
32587 printk("%s: NULL connection in send().\n", card->name);
32588 - atomic_inc(&vcc->stats->tx_err);
32589 + atomic_inc_unchecked(&vcc->stats->tx_err);
32590 dev_kfree_skb(skb);
32591 return -EINVAL;
32592 }
32593 if (!test_bit(VCF_TX, &vc->flags)) {
32594 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32595 - atomic_inc(&vcc->stats->tx_err);
32596 + atomic_inc_unchecked(&vcc->stats->tx_err);
32597 dev_kfree_skb(skb);
32598 return -EINVAL;
32599 }
32600 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32601 break;
32602 default:
32603 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32604 - atomic_inc(&vcc->stats->tx_err);
32605 + atomic_inc_unchecked(&vcc->stats->tx_err);
32606 dev_kfree_skb(skb);
32607 return -EINVAL;
32608 }
32609
32610 if (skb_shinfo(skb)->nr_frags != 0) {
32611 printk("%s: No scatter-gather yet.\n", card->name);
32612 - atomic_inc(&vcc->stats->tx_err);
32613 + atomic_inc_unchecked(&vcc->stats->tx_err);
32614 dev_kfree_skb(skb);
32615 return -EINVAL;
32616 }
32617 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32618
32619 err = queue_skb(card, vc, skb, oam);
32620 if (err) {
32621 - atomic_inc(&vcc->stats->tx_err);
32622 + atomic_inc_unchecked(&vcc->stats->tx_err);
32623 dev_kfree_skb(skb);
32624 return err;
32625 }
32626 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32627 skb = dev_alloc_skb(64);
32628 if (!skb) {
32629 printk("%s: Out of memory in send_oam().\n", card->name);
32630 - atomic_inc(&vcc->stats->tx_err);
32631 + atomic_inc_unchecked(&vcc->stats->tx_err);
32632 return -ENOMEM;
32633 }
32634 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32635 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32636 index 4217f29..88f547a 100644
32637 --- a/drivers/atm/iphase.c
32638 +++ b/drivers/atm/iphase.c
32639 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32640 status = (u_short) (buf_desc_ptr->desc_mode);
32641 if (status & (RX_CER | RX_PTE | RX_OFL))
32642 {
32643 - atomic_inc(&vcc->stats->rx_err);
32644 + atomic_inc_unchecked(&vcc->stats->rx_err);
32645 IF_ERR(printk("IA: bad packet, dropping it");)
32646 if (status & RX_CER) {
32647 IF_ERR(printk(" cause: packet CRC error\n");)
32648 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32649 len = dma_addr - buf_addr;
32650 if (len > iadev->rx_buf_sz) {
32651 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32652 - atomic_inc(&vcc->stats->rx_err);
32653 + atomic_inc_unchecked(&vcc->stats->rx_err);
32654 goto out_free_desc;
32655 }
32656
32657 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32658 ia_vcc = INPH_IA_VCC(vcc);
32659 if (ia_vcc == NULL)
32660 {
32661 - atomic_inc(&vcc->stats->rx_err);
32662 + atomic_inc_unchecked(&vcc->stats->rx_err);
32663 atm_return(vcc, skb->truesize);
32664 dev_kfree_skb_any(skb);
32665 goto INCR_DLE;
32666 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32667 if ((length > iadev->rx_buf_sz) || (length >
32668 (skb->len - sizeof(struct cpcs_trailer))))
32669 {
32670 - atomic_inc(&vcc->stats->rx_err);
32671 + atomic_inc_unchecked(&vcc->stats->rx_err);
32672 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32673 length, skb->len);)
32674 atm_return(vcc, skb->truesize);
32675 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32676
32677 IF_RX(printk("rx_dle_intr: skb push");)
32678 vcc->push(vcc,skb);
32679 - atomic_inc(&vcc->stats->rx);
32680 + atomic_inc_unchecked(&vcc->stats->rx);
32681 iadev->rx_pkt_cnt++;
32682 }
32683 INCR_DLE:
32684 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32685 {
32686 struct k_sonet_stats *stats;
32687 stats = &PRIV(_ia_dev[board])->sonet_stats;
32688 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32689 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32690 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32691 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32692 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32693 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32694 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32695 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32696 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32697 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32698 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32699 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32700 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32701 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32702 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32703 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32704 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32705 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32706 }
32707 ia_cmds.status = 0;
32708 break;
32709 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32710 if ((desc == 0) || (desc > iadev->num_tx_desc))
32711 {
32712 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32713 - atomic_inc(&vcc->stats->tx);
32714 + atomic_inc_unchecked(&vcc->stats->tx);
32715 if (vcc->pop)
32716 vcc->pop(vcc, skb);
32717 else
32718 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32719 ATM_DESC(skb) = vcc->vci;
32720 skb_queue_tail(&iadev->tx_dma_q, skb);
32721
32722 - atomic_inc(&vcc->stats->tx);
32723 + atomic_inc_unchecked(&vcc->stats->tx);
32724 iadev->tx_pkt_cnt++;
32725 /* Increment transaction counter */
32726 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32727
32728 #if 0
32729 /* add flow control logic */
32730 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32731 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32732 if (iavcc->vc_desc_cnt > 10) {
32733 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32734 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32735 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32736 index fa7d701..1e404c7 100644
32737 --- a/drivers/atm/lanai.c
32738 +++ b/drivers/atm/lanai.c
32739 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32740 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32741 lanai_endtx(lanai, lvcc);
32742 lanai_free_skb(lvcc->tx.atmvcc, skb);
32743 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32744 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32745 }
32746
32747 /* Try to fill the buffer - don't call unless there is backlog */
32748 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32749 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32750 __net_timestamp(skb);
32751 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32752 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32753 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32754 out:
32755 lvcc->rx.buf.ptr = end;
32756 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32757 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32758 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32759 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32760 lanai->stats.service_rxnotaal5++;
32761 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32762 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32763 return 0;
32764 }
32765 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32766 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32767 int bytes;
32768 read_unlock(&vcc_sklist_lock);
32769 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32770 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32771 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32772 lvcc->stats.x.aal5.service_trash++;
32773 bytes = (SERVICE_GET_END(s) * 16) -
32774 (((unsigned long) lvcc->rx.buf.ptr) -
32775 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32776 }
32777 if (s & SERVICE_STREAM) {
32778 read_unlock(&vcc_sklist_lock);
32779 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32780 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32781 lvcc->stats.x.aal5.service_stream++;
32782 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32783 "PDU on VCI %d!\n", lanai->number, vci);
32784 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32785 return 0;
32786 }
32787 DPRINTK("got rx crc error on vci %d\n", vci);
32788 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32789 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32790 lvcc->stats.x.aal5.service_rxcrc++;
32791 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32792 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32793 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32794 index 6587dc2..149833d 100644
32795 --- a/drivers/atm/nicstar.c
32796 +++ b/drivers/atm/nicstar.c
32797 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32798 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32799 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32800 card->index);
32801 - atomic_inc(&vcc->stats->tx_err);
32802 + atomic_inc_unchecked(&vcc->stats->tx_err);
32803 dev_kfree_skb_any(skb);
32804 return -EINVAL;
32805 }
32806 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32807 if (!vc->tx) {
32808 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32809 card->index);
32810 - atomic_inc(&vcc->stats->tx_err);
32811 + atomic_inc_unchecked(&vcc->stats->tx_err);
32812 dev_kfree_skb_any(skb);
32813 return -EINVAL;
32814 }
32815 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32816 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32817 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32818 card->index);
32819 - atomic_inc(&vcc->stats->tx_err);
32820 + atomic_inc_unchecked(&vcc->stats->tx_err);
32821 dev_kfree_skb_any(skb);
32822 return -EINVAL;
32823 }
32824
32825 if (skb_shinfo(skb)->nr_frags != 0) {
32826 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32827 - atomic_inc(&vcc->stats->tx_err);
32828 + atomic_inc_unchecked(&vcc->stats->tx_err);
32829 dev_kfree_skb_any(skb);
32830 return -EINVAL;
32831 }
32832 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32833 }
32834
32835 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32836 - atomic_inc(&vcc->stats->tx_err);
32837 + atomic_inc_unchecked(&vcc->stats->tx_err);
32838 dev_kfree_skb_any(skb);
32839 return -EIO;
32840 }
32841 - atomic_inc(&vcc->stats->tx);
32842 + atomic_inc_unchecked(&vcc->stats->tx);
32843
32844 return 0;
32845 }
32846 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32847 printk
32848 ("nicstar%d: Can't allocate buffers for aal0.\n",
32849 card->index);
32850 - atomic_add(i, &vcc->stats->rx_drop);
32851 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32852 break;
32853 }
32854 if (!atm_charge(vcc, sb->truesize)) {
32855 RXPRINTK
32856 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32857 card->index);
32858 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32859 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32860 dev_kfree_skb_any(sb);
32861 break;
32862 }
32863 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32864 ATM_SKB(sb)->vcc = vcc;
32865 __net_timestamp(sb);
32866 vcc->push(vcc, sb);
32867 - atomic_inc(&vcc->stats->rx);
32868 + atomic_inc_unchecked(&vcc->stats->rx);
32869 cell += ATM_CELL_PAYLOAD;
32870 }
32871
32872 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32873 if (iovb == NULL) {
32874 printk("nicstar%d: Out of iovec buffers.\n",
32875 card->index);
32876 - atomic_inc(&vcc->stats->rx_drop);
32877 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32878 recycle_rx_buf(card, skb);
32879 return;
32880 }
32881 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32882 small or large buffer itself. */
32883 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32884 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32885 - atomic_inc(&vcc->stats->rx_err);
32886 + atomic_inc_unchecked(&vcc->stats->rx_err);
32887 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32888 NS_MAX_IOVECS);
32889 NS_PRV_IOVCNT(iovb) = 0;
32890 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32891 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32892 card->index);
32893 which_list(card, skb);
32894 - atomic_inc(&vcc->stats->rx_err);
32895 + atomic_inc_unchecked(&vcc->stats->rx_err);
32896 recycle_rx_buf(card, skb);
32897 vc->rx_iov = NULL;
32898 recycle_iov_buf(card, iovb);
32899 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32900 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32901 card->index);
32902 which_list(card, skb);
32903 - atomic_inc(&vcc->stats->rx_err);
32904 + atomic_inc_unchecked(&vcc->stats->rx_err);
32905 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32906 NS_PRV_IOVCNT(iovb));
32907 vc->rx_iov = NULL;
32908 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32909 printk(" - PDU size mismatch.\n");
32910 else
32911 printk(".\n");
32912 - atomic_inc(&vcc->stats->rx_err);
32913 + atomic_inc_unchecked(&vcc->stats->rx_err);
32914 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32915 NS_PRV_IOVCNT(iovb));
32916 vc->rx_iov = NULL;
32917 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32918 /* skb points to a small buffer */
32919 if (!atm_charge(vcc, skb->truesize)) {
32920 push_rxbufs(card, skb);
32921 - atomic_inc(&vcc->stats->rx_drop);
32922 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32923 } else {
32924 skb_put(skb, len);
32925 dequeue_sm_buf(card, skb);
32926 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32927 ATM_SKB(skb)->vcc = vcc;
32928 __net_timestamp(skb);
32929 vcc->push(vcc, skb);
32930 - atomic_inc(&vcc->stats->rx);
32931 + atomic_inc_unchecked(&vcc->stats->rx);
32932 }
32933 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32934 struct sk_buff *sb;
32935 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32936 if (len <= NS_SMBUFSIZE) {
32937 if (!atm_charge(vcc, sb->truesize)) {
32938 push_rxbufs(card, sb);
32939 - atomic_inc(&vcc->stats->rx_drop);
32940 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32941 } else {
32942 skb_put(sb, len);
32943 dequeue_sm_buf(card, sb);
32944 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32945 ATM_SKB(sb)->vcc = vcc;
32946 __net_timestamp(sb);
32947 vcc->push(vcc, sb);
32948 - atomic_inc(&vcc->stats->rx);
32949 + atomic_inc_unchecked(&vcc->stats->rx);
32950 }
32951
32952 push_rxbufs(card, skb);
32953 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32954
32955 if (!atm_charge(vcc, skb->truesize)) {
32956 push_rxbufs(card, skb);
32957 - atomic_inc(&vcc->stats->rx_drop);
32958 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32959 } else {
32960 dequeue_lg_buf(card, skb);
32961 #ifdef NS_USE_DESTRUCTORS
32962 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32963 ATM_SKB(skb)->vcc = vcc;
32964 __net_timestamp(skb);
32965 vcc->push(vcc, skb);
32966 - atomic_inc(&vcc->stats->rx);
32967 + atomic_inc_unchecked(&vcc->stats->rx);
32968 }
32969
32970 push_rxbufs(card, sb);
32971 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32972 printk
32973 ("nicstar%d: Out of huge buffers.\n",
32974 card->index);
32975 - atomic_inc(&vcc->stats->rx_drop);
32976 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32977 recycle_iovec_rx_bufs(card,
32978 (struct iovec *)
32979 iovb->data,
32980 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32981 card->hbpool.count++;
32982 } else
32983 dev_kfree_skb_any(hb);
32984 - atomic_inc(&vcc->stats->rx_drop);
32985 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32986 } else {
32987 /* Copy the small buffer to the huge buffer */
32988 sb = (struct sk_buff *)iov->iov_base;
32989 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32990 #endif /* NS_USE_DESTRUCTORS */
32991 __net_timestamp(hb);
32992 vcc->push(vcc, hb);
32993 - atomic_inc(&vcc->stats->rx);
32994 + atomic_inc_unchecked(&vcc->stats->rx);
32995 }
32996 }
32997
32998 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32999 index 32784d1..4a8434a 100644
33000 --- a/drivers/atm/solos-pci.c
33001 +++ b/drivers/atm/solos-pci.c
33002 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33003 }
33004 atm_charge(vcc, skb->truesize);
33005 vcc->push(vcc, skb);
33006 - atomic_inc(&vcc->stats->rx);
33007 + atomic_inc_unchecked(&vcc->stats->rx);
33008 break;
33009
33010 case PKT_STATUS:
33011 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33012 vcc = SKB_CB(oldskb)->vcc;
33013
33014 if (vcc) {
33015 - atomic_inc(&vcc->stats->tx);
33016 + atomic_inc_unchecked(&vcc->stats->tx);
33017 solos_pop(vcc, oldskb);
33018 } else {
33019 dev_kfree_skb_irq(oldskb);
33020 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33021 index 0215934..ce9f5b1 100644
33022 --- a/drivers/atm/suni.c
33023 +++ b/drivers/atm/suni.c
33024 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33025
33026
33027 #define ADD_LIMITED(s,v) \
33028 - atomic_add((v),&stats->s); \
33029 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33030 + atomic_add_unchecked((v),&stats->s); \
33031 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33032
33033
33034 static void suni_hz(unsigned long from_timer)
33035 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33036 index 5120a96..e2572bd 100644
33037 --- a/drivers/atm/uPD98402.c
33038 +++ b/drivers/atm/uPD98402.c
33039 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33040 struct sonet_stats tmp;
33041 int error = 0;
33042
33043 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33044 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33045 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33046 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33047 if (zero && !error) {
33048 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33049
33050
33051 #define ADD_LIMITED(s,v) \
33052 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33053 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33054 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33055 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33056 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33057 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33058
33059
33060 static void stat_event(struct atm_dev *dev)
33061 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33062 if (reason & uPD98402_INT_PFM) stat_event(dev);
33063 if (reason & uPD98402_INT_PCO) {
33064 (void) GET(PCOCR); /* clear interrupt cause */
33065 - atomic_add(GET(HECCT),
33066 + atomic_add_unchecked(GET(HECCT),
33067 &PRIV(dev)->sonet_stats.uncorr_hcs);
33068 }
33069 if ((reason & uPD98402_INT_RFO) &&
33070 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33071 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33072 uPD98402_INT_LOS),PIMR); /* enable them */
33073 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33074 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33075 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33076 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33077 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33078 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33079 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33080 return 0;
33081 }
33082
33083 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33084 index 969c3c2..9b72956 100644
33085 --- a/drivers/atm/zatm.c
33086 +++ b/drivers/atm/zatm.c
33087 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33088 }
33089 if (!size) {
33090 dev_kfree_skb_irq(skb);
33091 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33092 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33093 continue;
33094 }
33095 if (!atm_charge(vcc,skb->truesize)) {
33096 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33097 skb->len = size;
33098 ATM_SKB(skb)->vcc = vcc;
33099 vcc->push(vcc,skb);
33100 - atomic_inc(&vcc->stats->rx);
33101 + atomic_inc_unchecked(&vcc->stats->rx);
33102 }
33103 zout(pos & 0xffff,MTA(mbx));
33104 #if 0 /* probably a stupid idea */
33105 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33106 skb_queue_head(&zatm_vcc->backlog,skb);
33107 break;
33108 }
33109 - atomic_inc(&vcc->stats->tx);
33110 + atomic_inc_unchecked(&vcc->stats->tx);
33111 wake_up(&zatm_vcc->tx_wait);
33112 }
33113
33114 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33115 index d78b204..ecc1929 100644
33116 --- a/drivers/base/attribute_container.c
33117 +++ b/drivers/base/attribute_container.c
33118 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33119 ic->classdev.parent = get_device(dev);
33120 ic->classdev.class = cont->class;
33121 cont->class->dev_release = attribute_container_release;
33122 - dev_set_name(&ic->classdev, dev_name(dev));
33123 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33124 if (fn)
33125 fn(cont, dev, &ic->classdev);
33126 else
33127 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33128 index d414331..b4dd4ba 100644
33129 --- a/drivers/base/bus.c
33130 +++ b/drivers/base/bus.c
33131 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33132 return -EINVAL;
33133
33134 mutex_lock(&subsys->p->mutex);
33135 - list_add_tail(&sif->node, &subsys->p->interfaces);
33136 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33137 if (sif->add_dev) {
33138 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33139 while ((dev = subsys_dev_iter_next(&iter)))
33140 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33141 subsys = sif->subsys;
33142
33143 mutex_lock(&subsys->p->mutex);
33144 - list_del_init(&sif->node);
33145 + pax_list_del_init((struct list_head *)&sif->node);
33146 if (sif->remove_dev) {
33147 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33148 while ((dev = subsys_dev_iter_next(&iter)))
33149 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33150 index 7413d06..79155fa 100644
33151 --- a/drivers/base/devtmpfs.c
33152 +++ b/drivers/base/devtmpfs.c
33153 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
33154 if (!thread)
33155 return 0;
33156
33157 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33158 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33159 if (err)
33160 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33161 else
33162 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
33163 *err = sys_unshare(CLONE_NEWNS);
33164 if (*err)
33165 goto out;
33166 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33167 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33168 if (*err)
33169 goto out;
33170 - sys_chdir("/.."); /* will traverse into overmounted root */
33171 - sys_chroot(".");
33172 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33173 + sys_chroot((char __force_user *)".");
33174 complete(&setup_done);
33175 while (1) {
33176 spin_lock(&req_lock);
33177 diff --git a/drivers/base/node.c b/drivers/base/node.c
33178 index 7616a77c..8f57f51 100644
33179 --- a/drivers/base/node.c
33180 +++ b/drivers/base/node.c
33181 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33182 struct node_attr {
33183 struct device_attribute attr;
33184 enum node_states state;
33185 -};
33186 +} __do_const;
33187
33188 static ssize_t show_node_state(struct device *dev,
33189 struct device_attribute *attr, char *buf)
33190 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33191 index 7072404..76dcebd 100644
33192 --- a/drivers/base/power/domain.c
33193 +++ b/drivers/base/power/domain.c
33194 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33195 {
33196 struct cpuidle_driver *cpuidle_drv;
33197 struct gpd_cpu_data *cpu_data;
33198 - struct cpuidle_state *idle_state;
33199 + cpuidle_state_no_const *idle_state;
33200 int ret = 0;
33201
33202 if (IS_ERR_OR_NULL(genpd) || state < 0)
33203 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33204 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33205 {
33206 struct gpd_cpu_data *cpu_data;
33207 - struct cpuidle_state *idle_state;
33208 + cpuidle_state_no_const *idle_state;
33209 int ret = 0;
33210
33211 if (IS_ERR_OR_NULL(genpd))
33212 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33213 index a53ebd2..8f73eeb 100644
33214 --- a/drivers/base/power/sysfs.c
33215 +++ b/drivers/base/power/sysfs.c
33216 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33217 return -EIO;
33218 }
33219 }
33220 - return sprintf(buf, p);
33221 + return sprintf(buf, "%s", p);
33222 }
33223
33224 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33225 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33226 index 79715e7..df06b3b 100644
33227 --- a/drivers/base/power/wakeup.c
33228 +++ b/drivers/base/power/wakeup.c
33229 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33230 * They need to be modified together atomically, so it's better to use one
33231 * atomic variable to hold them both.
33232 */
33233 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33234 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33235
33236 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33237 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33238
33239 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33240 {
33241 - unsigned int comb = atomic_read(&combined_event_count);
33242 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33243
33244 *cnt = (comb >> IN_PROGRESS_BITS);
33245 *inpr = comb & MAX_IN_PROGRESS;
33246 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33247 ws->start_prevent_time = ws->last_time;
33248
33249 /* Increment the counter of events in progress. */
33250 - cec = atomic_inc_return(&combined_event_count);
33251 + cec = atomic_inc_return_unchecked(&combined_event_count);
33252
33253 trace_wakeup_source_activate(ws->name, cec);
33254 }
33255 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33256 * Increment the counter of registered wakeup events and decrement the
33257 * couter of wakeup events in progress simultaneously.
33258 */
33259 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33260 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33261 trace_wakeup_source_deactivate(ws->name, cec);
33262
33263 split_counters(&cnt, &inpr);
33264 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33265 index e8d11b6..7b1b36f 100644
33266 --- a/drivers/base/syscore.c
33267 +++ b/drivers/base/syscore.c
33268 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33269 void register_syscore_ops(struct syscore_ops *ops)
33270 {
33271 mutex_lock(&syscore_ops_lock);
33272 - list_add_tail(&ops->node, &syscore_ops_list);
33273 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33274 mutex_unlock(&syscore_ops_lock);
33275 }
33276 EXPORT_SYMBOL_GPL(register_syscore_ops);
33277 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33278 void unregister_syscore_ops(struct syscore_ops *ops)
33279 {
33280 mutex_lock(&syscore_ops_lock);
33281 - list_del(&ops->node);
33282 + pax_list_del((struct list_head *)&ops->node);
33283 mutex_unlock(&syscore_ops_lock);
33284 }
33285 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33286 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33287 index 62b6c2c..4a11354 100644
33288 --- a/drivers/block/cciss.c
33289 +++ b/drivers/block/cciss.c
33290 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33291 int err;
33292 u32 cp;
33293
33294 + memset(&arg64, 0, sizeof(arg64));
33295 +
33296 err = 0;
33297 err |=
33298 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33299 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
33300 while (!list_empty(&h->reqQ)) {
33301 c = list_entry(h->reqQ.next, CommandList_struct, list);
33302 /* can't do anything if fifo is full */
33303 - if ((h->access.fifo_full(h))) {
33304 + if ((h->access->fifo_full(h))) {
33305 dev_warn(&h->pdev->dev, "fifo full\n");
33306 break;
33307 }
33308 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
33309 h->Qdepth--;
33310
33311 /* Tell the controller execute command */
33312 - h->access.submit_command(h, c);
33313 + h->access->submit_command(h, c);
33314
33315 /* Put job onto the completed Q */
33316 addQ(&h->cmpQ, c);
33317 @@ -3446,17 +3448,17 @@ startio:
33318
33319 static inline unsigned long get_next_completion(ctlr_info_t *h)
33320 {
33321 - return h->access.command_completed(h);
33322 + return h->access->command_completed(h);
33323 }
33324
33325 static inline int interrupt_pending(ctlr_info_t *h)
33326 {
33327 - return h->access.intr_pending(h);
33328 + return h->access->intr_pending(h);
33329 }
33330
33331 static inline long interrupt_not_for_us(ctlr_info_t *h)
33332 {
33333 - return ((h->access.intr_pending(h) == 0) ||
33334 + return ((h->access->intr_pending(h) == 0) ||
33335 (h->interrupts_enabled == 0));
33336 }
33337
33338 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
33339 u32 a;
33340
33341 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33342 - return h->access.command_completed(h);
33343 + return h->access->command_completed(h);
33344
33345 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33346 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33347 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33348 trans_support & CFGTBL_Trans_use_short_tags);
33349
33350 /* Change the access methods to the performant access methods */
33351 - h->access = SA5_performant_access;
33352 + h->access = &SA5_performant_access;
33353 h->transMethod = CFGTBL_Trans_Performant;
33354
33355 return;
33356 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33357 if (prod_index < 0)
33358 return -ENODEV;
33359 h->product_name = products[prod_index].product_name;
33360 - h->access = *(products[prod_index].access);
33361 + h->access = products[prod_index].access;
33362
33363 if (cciss_board_disabled(h)) {
33364 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33365 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
33366 }
33367
33368 /* make sure the board interrupts are off */
33369 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33370 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33371 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33372 if (rc)
33373 goto clean2;
33374 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
33375 * fake ones to scoop up any residual completions.
33376 */
33377 spin_lock_irqsave(&h->lock, flags);
33378 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33379 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33380 spin_unlock_irqrestore(&h->lock, flags);
33381 free_irq(h->intr[h->intr_mode], h);
33382 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33383 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
33384 dev_info(&h->pdev->dev, "Board READY.\n");
33385 dev_info(&h->pdev->dev,
33386 "Waiting for stale completions to drain.\n");
33387 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33388 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33389 msleep(10000);
33390 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33391 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33392
33393 rc = controller_reset_failed(h->cfgtable);
33394 if (rc)
33395 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
33396 cciss_scsi_setup(h);
33397
33398 /* Turn the interrupts on so we can service requests */
33399 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33400 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33401
33402 /* Get the firmware version */
33403 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33404 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33405 kfree(flush_buf);
33406 if (return_code != IO_OK)
33407 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33408 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33409 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33410 free_irq(h->intr[h->intr_mode], h);
33411 }
33412
33413 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33414 index 7fda30e..eb5dfe0 100644
33415 --- a/drivers/block/cciss.h
33416 +++ b/drivers/block/cciss.h
33417 @@ -101,7 +101,7 @@ struct ctlr_info
33418 /* information about each logical volume */
33419 drive_info_struct *drv[CISS_MAX_LUN];
33420
33421 - struct access_method access;
33422 + struct access_method *access;
33423
33424 /* queue and queue Info */
33425 struct list_head reqQ;
33426 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33427 index 639d26b..fd6ad1f 100644
33428 --- a/drivers/block/cpqarray.c
33429 +++ b/drivers/block/cpqarray.c
33430 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33431 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33432 goto Enomem4;
33433 }
33434 - hba[i]->access.set_intr_mask(hba[i], 0);
33435 + hba[i]->access->set_intr_mask(hba[i], 0);
33436 if (request_irq(hba[i]->intr, do_ida_intr,
33437 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33438 {
33439 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33440 add_timer(&hba[i]->timer);
33441
33442 /* Enable IRQ now that spinlock and rate limit timer are set up */
33443 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33444 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33445
33446 for(j=0; j<NWD; j++) {
33447 struct gendisk *disk = ida_gendisk[i][j];
33448 @@ -694,7 +694,7 @@ DBGINFO(
33449 for(i=0; i<NR_PRODUCTS; i++) {
33450 if (board_id == products[i].board_id) {
33451 c->product_name = products[i].product_name;
33452 - c->access = *(products[i].access);
33453 + c->access = products[i].access;
33454 break;
33455 }
33456 }
33457 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33458 hba[ctlr]->intr = intr;
33459 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33460 hba[ctlr]->product_name = products[j].product_name;
33461 - hba[ctlr]->access = *(products[j].access);
33462 + hba[ctlr]->access = products[j].access;
33463 hba[ctlr]->ctlr = ctlr;
33464 hba[ctlr]->board_id = board_id;
33465 hba[ctlr]->pci_dev = NULL; /* not PCI */
33466 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
33467
33468 while((c = h->reqQ) != NULL) {
33469 /* Can't do anything if we're busy */
33470 - if (h->access.fifo_full(h) == 0)
33471 + if (h->access->fifo_full(h) == 0)
33472 return;
33473
33474 /* Get the first entry from the request Q */
33475 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
33476 h->Qdepth--;
33477
33478 /* Tell the controller to do our bidding */
33479 - h->access.submit_command(h, c);
33480 + h->access->submit_command(h, c);
33481
33482 /* Get onto the completion Q */
33483 addQ(&h->cmpQ, c);
33484 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33485 unsigned long flags;
33486 __u32 a,a1;
33487
33488 - istat = h->access.intr_pending(h);
33489 + istat = h->access->intr_pending(h);
33490 /* Is this interrupt for us? */
33491 if (istat == 0)
33492 return IRQ_NONE;
33493 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33494 */
33495 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33496 if (istat & FIFO_NOT_EMPTY) {
33497 - while((a = h->access.command_completed(h))) {
33498 + while((a = h->access->command_completed(h))) {
33499 a1 = a; a &= ~3;
33500 if ((c = h->cmpQ) == NULL)
33501 {
33502 @@ -1193,6 +1193,7 @@ out_passthru:
33503 ida_pci_info_struct pciinfo;
33504
33505 if (!arg) return -EINVAL;
33506 + memset(&pciinfo, 0, sizeof(pciinfo));
33507 pciinfo.bus = host->pci_dev->bus->number;
33508 pciinfo.dev_fn = host->pci_dev->devfn;
33509 pciinfo.board_id = host->board_id;
33510 @@ -1447,11 +1448,11 @@ static int sendcmd(
33511 /*
33512 * Disable interrupt
33513 */
33514 - info_p->access.set_intr_mask(info_p, 0);
33515 + info_p->access->set_intr_mask(info_p, 0);
33516 /* Make sure there is room in the command FIFO */
33517 /* Actually it should be completely empty at this time. */
33518 for (i = 200000; i > 0; i--) {
33519 - temp = info_p->access.fifo_full(info_p);
33520 + temp = info_p->access->fifo_full(info_p);
33521 if (temp != 0) {
33522 break;
33523 }
33524 @@ -1464,7 +1465,7 @@ DBG(
33525 /*
33526 * Send the cmd
33527 */
33528 - info_p->access.submit_command(info_p, c);
33529 + info_p->access->submit_command(info_p, c);
33530 complete = pollcomplete(ctlr);
33531
33532 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33533 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33534 * we check the new geometry. Then turn interrupts back on when
33535 * we're done.
33536 */
33537 - host->access.set_intr_mask(host, 0);
33538 + host->access->set_intr_mask(host, 0);
33539 getgeometry(ctlr);
33540 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33541 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33542
33543 for(i=0; i<NWD; i++) {
33544 struct gendisk *disk = ida_gendisk[ctlr][i];
33545 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
33546 /* Wait (up to 2 seconds) for a command to complete */
33547
33548 for (i = 200000; i > 0; i--) {
33549 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33550 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33551 if (done == 0) {
33552 udelay(10); /* a short fixed delay */
33553 } else
33554 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33555 index be73e9d..7fbf140 100644
33556 --- a/drivers/block/cpqarray.h
33557 +++ b/drivers/block/cpqarray.h
33558 @@ -99,7 +99,7 @@ struct ctlr_info {
33559 drv_info_t drv[NWD];
33560 struct proc_dir_entry *proc;
33561
33562 - struct access_method access;
33563 + struct access_method *access;
33564
33565 cmdlist_t *reqQ;
33566 cmdlist_t *cmpQ;
33567 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33568 index f943aac..99bfd19 100644
33569 --- a/drivers/block/drbd/drbd_int.h
33570 +++ b/drivers/block/drbd/drbd_int.h
33571 @@ -582,7 +582,7 @@ struct drbd_epoch {
33572 struct drbd_tconn *tconn;
33573 struct list_head list;
33574 unsigned int barrier_nr;
33575 - atomic_t epoch_size; /* increased on every request added. */
33576 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33577 atomic_t active; /* increased on every req. added, and dec on every finished. */
33578 unsigned long flags;
33579 };
33580 @@ -1021,7 +1021,7 @@ struct drbd_conf {
33581 unsigned int al_tr_number;
33582 int al_tr_cycle;
33583 wait_queue_head_t seq_wait;
33584 - atomic_t packet_seq;
33585 + atomic_unchecked_t packet_seq;
33586 unsigned int peer_seq;
33587 spinlock_t peer_seq_lock;
33588 unsigned int minor;
33589 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33590 char __user *uoptval;
33591 int err;
33592
33593 - uoptval = (char __user __force *)optval;
33594 + uoptval = (char __force_user *)optval;
33595
33596 set_fs(KERNEL_DS);
33597 if (level == SOL_SOCKET)
33598 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33599 index a5dca6a..bb27967 100644
33600 --- a/drivers/block/drbd/drbd_main.c
33601 +++ b/drivers/block/drbd/drbd_main.c
33602 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33603 p->sector = sector;
33604 p->block_id = block_id;
33605 p->blksize = blksize;
33606 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33607 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33608 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33609 }
33610
33611 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33612 return -EIO;
33613 p->sector = cpu_to_be64(req->i.sector);
33614 p->block_id = (unsigned long)req;
33615 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33616 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33617 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33618 if (mdev->state.conn >= C_SYNC_SOURCE &&
33619 mdev->state.conn <= C_PAUSED_SYNC_T)
33620 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33621 {
33622 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33623
33624 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33625 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33626 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33627 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33628 kfree(tconn->current_epoch);
33629
33630 idr_destroy(&tconn->volumes);
33631 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33632 index 4222aff..1f79506 100644
33633 --- a/drivers/block/drbd/drbd_receiver.c
33634 +++ b/drivers/block/drbd/drbd_receiver.c
33635 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
33636 {
33637 int err;
33638
33639 - atomic_set(&mdev->packet_seq, 0);
33640 + atomic_set_unchecked(&mdev->packet_seq, 0);
33641 mdev->peer_seq = 0;
33642
33643 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33644 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33645 do {
33646 next_epoch = NULL;
33647
33648 - epoch_size = atomic_read(&epoch->epoch_size);
33649 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33650
33651 switch (ev & ~EV_CLEANUP) {
33652 case EV_PUT:
33653 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33654 rv = FE_DESTROYED;
33655 } else {
33656 epoch->flags = 0;
33657 - atomic_set(&epoch->epoch_size, 0);
33658 + atomic_set_unchecked(&epoch->epoch_size, 0);
33659 /* atomic_set(&epoch->active, 0); is already zero */
33660 if (rv == FE_STILL_LIVE)
33661 rv = FE_RECYCLED;
33662 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33663 conn_wait_active_ee_empty(tconn);
33664 drbd_flush(tconn);
33665
33666 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33667 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33668 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33669 if (epoch)
33670 break;
33671 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33672 }
33673
33674 epoch->flags = 0;
33675 - atomic_set(&epoch->epoch_size, 0);
33676 + atomic_set_unchecked(&epoch->epoch_size, 0);
33677 atomic_set(&epoch->active, 0);
33678
33679 spin_lock(&tconn->epoch_lock);
33680 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33681 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33682 list_add(&epoch->list, &tconn->current_epoch->list);
33683 tconn->current_epoch = epoch;
33684 tconn->epochs++;
33685 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33686
33687 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33688 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33689 - atomic_inc(&tconn->current_epoch->epoch_size);
33690 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33691 err2 = drbd_drain_block(mdev, pi->size);
33692 if (!err)
33693 err = err2;
33694 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33695
33696 spin_lock(&tconn->epoch_lock);
33697 peer_req->epoch = tconn->current_epoch;
33698 - atomic_inc(&peer_req->epoch->epoch_size);
33699 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33700 atomic_inc(&peer_req->epoch->active);
33701 spin_unlock(&tconn->epoch_lock);
33702
33703 @@ -4347,7 +4347,7 @@ struct data_cmd {
33704 int expect_payload;
33705 size_t pkt_size;
33706 int (*fn)(struct drbd_tconn *, struct packet_info *);
33707 -};
33708 +} __do_const;
33709
33710 static struct data_cmd drbd_cmd_handler[] = {
33711 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33712 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33713 if (!list_empty(&tconn->current_epoch->list))
33714 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33715 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33716 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33717 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33718 tconn->send.seen_any_write_yet = false;
33719
33720 conn_info(tconn, "Connection closed\n");
33721 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33722 struct asender_cmd {
33723 size_t pkt_size;
33724 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33725 -};
33726 +} __do_const;
33727
33728 static struct asender_cmd asender_tbl[] = {
33729 [P_PING] = { 0, got_Ping },
33730 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33731 index d92d50f..a7e9d97 100644
33732 --- a/drivers/block/loop.c
33733 +++ b/drivers/block/loop.c
33734 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
33735
33736 file_start_write(file);
33737 set_fs(get_ds());
33738 - bw = file->f_op->write(file, buf, len, &pos);
33739 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33740 set_fs(old_fs);
33741 file_end_write(file);
33742 if (likely(bw == len))
33743 diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
33744 index 037288e..00f80b3 100644
33745 --- a/drivers/block/nbd.c
33746 +++ b/drivers/block/nbd.c
33747 @@ -714,7 +714,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
33748 else
33749 blk_queue_flush(nbd->disk->queue, 0);
33750
33751 - thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name);
33752 + thread = kthread_create(nbd_thread, nbd, "%s", nbd->disk->disk_name);
33753 if (IS_ERR(thread)) {
33754 mutex_lock(&nbd->tx_lock);
33755 return PTR_ERR(thread);
33756 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33757 index f5d0ea1..c62380a 100644
33758 --- a/drivers/block/pktcdvd.c
33759 +++ b/drivers/block/pktcdvd.c
33760 @@ -84,7 +84,7 @@
33761 #define MAX_SPEED 0xffff
33762
33763 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
33764 - ~(sector_t)((pd)->settings.size - 1))
33765 + ~(sector_t)((pd)->settings.size - 1UL))
33766
33767 static DEFINE_MUTEX(pktcdvd_mutex);
33768 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33769 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33770 index d620b44..d7538c2 100644
33771 --- a/drivers/cdrom/cdrom.c
33772 +++ b/drivers/cdrom/cdrom.c
33773 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33774 ENSURE(reset, CDC_RESET);
33775 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33776 cdi->mc_flags = 0;
33777 - cdo->n_minors = 0;
33778 cdi->options = CDO_USE_FFLAGS;
33779
33780 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33781 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33782 else
33783 cdi->cdda_method = CDDA_OLD;
33784
33785 - if (!cdo->generic_packet)
33786 - cdo->generic_packet = cdrom_dummy_generic_packet;
33787 + if (!cdo->generic_packet) {
33788 + pax_open_kernel();
33789 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33790 + pax_close_kernel();
33791 + }
33792
33793 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33794 mutex_lock(&cdrom_mutex);
33795 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33796 if (cdi->exit)
33797 cdi->exit(cdi);
33798
33799 - cdi->ops->n_minors--;
33800 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33801 }
33802
33803 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33804 */
33805 nr = nframes;
33806 do {
33807 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33808 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33809 if (cgc.buffer)
33810 break;
33811
33812 @@ -2882,7 +2883,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
33813 if (lba < 0)
33814 return -EINVAL;
33815
33816 - cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
33817 + cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
33818 if (cgc->buffer == NULL)
33819 return -ENOMEM;
33820
33821 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33822 struct cdrom_device_info *cdi;
33823 int ret;
33824
33825 - ret = scnprintf(info + *pos, max_size - *pos, header);
33826 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33827 if (!ret)
33828 return 1;
33829
33830 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33831 index 4afcb65..a68a32d 100644
33832 --- a/drivers/cdrom/gdrom.c
33833 +++ b/drivers/cdrom/gdrom.c
33834 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33835 .audio_ioctl = gdrom_audio_ioctl,
33836 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33837 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33838 - .n_minors = 1,
33839 };
33840
33841 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33842 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33843 index 3bb6fa3..34013fb 100644
33844 --- a/drivers/char/Kconfig
33845 +++ b/drivers/char/Kconfig
33846 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33847
33848 config DEVKMEM
33849 bool "/dev/kmem virtual device support"
33850 - default y
33851 + default n
33852 + depends on !GRKERNSEC_KMEM
33853 help
33854 Say Y here if you want to support the /dev/kmem device. The
33855 /dev/kmem device is rarely used, but can be used for certain
33856 @@ -582,6 +583,7 @@ config DEVPORT
33857 bool
33858 depends on !M68K
33859 depends on ISA || PCI
33860 + depends on !GRKERNSEC_KMEM
33861 default y
33862
33863 source "drivers/s390/char/Kconfig"
33864 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33865 index a48e05b..6bac831 100644
33866 --- a/drivers/char/agp/compat_ioctl.c
33867 +++ b/drivers/char/agp/compat_ioctl.c
33868 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33869 return -ENOMEM;
33870 }
33871
33872 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33873 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33874 sizeof(*usegment) * ureserve.seg_count)) {
33875 kfree(usegment);
33876 kfree(ksegment);
33877 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33878 index 2e04433..771f2cc 100644
33879 --- a/drivers/char/agp/frontend.c
33880 +++ b/drivers/char/agp/frontend.c
33881 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33882 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33883 return -EFAULT;
33884
33885 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33886 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33887 return -EFAULT;
33888
33889 client = agp_find_client_by_pid(reserve.pid);
33890 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33891 if (segment == NULL)
33892 return -ENOMEM;
33893
33894 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33895 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33896 sizeof(struct agp_segment) * reserve.seg_count)) {
33897 kfree(segment);
33898 return -EFAULT;
33899 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33900 index 4f94375..413694e 100644
33901 --- a/drivers/char/genrtc.c
33902 +++ b/drivers/char/genrtc.c
33903 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
33904 switch (cmd) {
33905
33906 case RTC_PLL_GET:
33907 + memset(&pll, 0, sizeof(pll));
33908 if (get_rtc_pll(&pll))
33909 return -EINVAL;
33910 else
33911 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33912 index d784650..e8bfd69 100644
33913 --- a/drivers/char/hpet.c
33914 +++ b/drivers/char/hpet.c
33915 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33916 }
33917
33918 static int
33919 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33920 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33921 struct hpet_info *info)
33922 {
33923 struct hpet_timer __iomem *timer;
33924 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33925 index 86fe45c..c0ea948 100644
33926 --- a/drivers/char/hw_random/intel-rng.c
33927 +++ b/drivers/char/hw_random/intel-rng.c
33928 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33929
33930 if (no_fwh_detect)
33931 return -ENODEV;
33932 - printk(warning);
33933 + printk("%s", warning);
33934 return -EBUSY;
33935 }
33936
33937 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33938 index 4445fa1..7c6de37 100644
33939 --- a/drivers/char/ipmi/ipmi_msghandler.c
33940 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33941 @@ -420,7 +420,7 @@ struct ipmi_smi {
33942 struct proc_dir_entry *proc_dir;
33943 char proc_dir_name[10];
33944
33945 - atomic_t stats[IPMI_NUM_STATS];
33946 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33947
33948 /*
33949 * run_to_completion duplicate of smb_info, smi_info
33950 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33951
33952
33953 #define ipmi_inc_stat(intf, stat) \
33954 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33955 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33956 #define ipmi_get_stat(intf, stat) \
33957 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33958 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33959
33960 static int is_lan_addr(struct ipmi_addr *addr)
33961 {
33962 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33963 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33964 init_waitqueue_head(&intf->waitq);
33965 for (i = 0; i < IPMI_NUM_STATS; i++)
33966 - atomic_set(&intf->stats[i], 0);
33967 + atomic_set_unchecked(&intf->stats[i], 0);
33968
33969 intf->proc_dir = NULL;
33970
33971 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33972 index af4b23f..79806fc 100644
33973 --- a/drivers/char/ipmi/ipmi_si_intf.c
33974 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33975 @@ -275,7 +275,7 @@ struct smi_info {
33976 unsigned char slave_addr;
33977
33978 /* Counters and things for the proc filesystem. */
33979 - atomic_t stats[SI_NUM_STATS];
33980 + atomic_unchecked_t stats[SI_NUM_STATS];
33981
33982 struct task_struct *thread;
33983
33984 @@ -284,9 +284,9 @@ struct smi_info {
33985 };
33986
33987 #define smi_inc_stat(smi, stat) \
33988 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33989 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33990 #define smi_get_stat(smi, stat) \
33991 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33992 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33993
33994 #define SI_MAX_PARMS 4
33995
33996 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
33997 atomic_set(&new_smi->req_events, 0);
33998 new_smi->run_to_completion = 0;
33999 for (i = 0; i < SI_NUM_STATS; i++)
34000 - atomic_set(&new_smi->stats[i], 0);
34001 + atomic_set_unchecked(&new_smi->stats[i], 0);
34002
34003 new_smi->interrupt_disabled = 1;
34004 atomic_set(&new_smi->stop_operation, 0);
34005 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34006 index 1ccbe94..6ad651a 100644
34007 --- a/drivers/char/mem.c
34008 +++ b/drivers/char/mem.c
34009 @@ -18,6 +18,7 @@
34010 #include <linux/raw.h>
34011 #include <linux/tty.h>
34012 #include <linux/capability.h>
34013 +#include <linux/security.h>
34014 #include <linux/ptrace.h>
34015 #include <linux/device.h>
34016 #include <linux/highmem.h>
34017 @@ -38,6 +39,10 @@
34018
34019 #define DEVPORT_MINOR 4
34020
34021 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34022 +extern const struct file_operations grsec_fops;
34023 +#endif
34024 +
34025 static inline unsigned long size_inside_page(unsigned long start,
34026 unsigned long size)
34027 {
34028 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34029
34030 while (cursor < to) {
34031 if (!devmem_is_allowed(pfn)) {
34032 +#ifdef CONFIG_GRKERNSEC_KMEM
34033 + gr_handle_mem_readwrite(from, to);
34034 +#else
34035 printk(KERN_INFO
34036 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34037 current->comm, from, to);
34038 +#endif
34039 return 0;
34040 }
34041 cursor += PAGE_SIZE;
34042 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34043 }
34044 return 1;
34045 }
34046 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34047 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34048 +{
34049 + return 0;
34050 +}
34051 #else
34052 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34053 {
34054 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34055
34056 while (count > 0) {
34057 unsigned long remaining;
34058 + char *temp;
34059
34060 sz = size_inside_page(p, count);
34061
34062 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34063 if (!ptr)
34064 return -EFAULT;
34065
34066 - remaining = copy_to_user(buf, ptr, sz);
34067 +#ifdef CONFIG_PAX_USERCOPY
34068 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34069 + if (!temp) {
34070 + unxlate_dev_mem_ptr(p, ptr);
34071 + return -ENOMEM;
34072 + }
34073 + memcpy(temp, ptr, sz);
34074 +#else
34075 + temp = ptr;
34076 +#endif
34077 +
34078 + remaining = copy_to_user(buf, temp, sz);
34079 +
34080 +#ifdef CONFIG_PAX_USERCOPY
34081 + kfree(temp);
34082 +#endif
34083 +
34084 unxlate_dev_mem_ptr(p, ptr);
34085 if (remaining)
34086 return -EFAULT;
34087 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34088 else
34089 csize = count;
34090
34091 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34092 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34093 if (rc < 0)
34094 return rc;
34095 buf += csize;
34096 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34097 size_t count, loff_t *ppos)
34098 {
34099 unsigned long p = *ppos;
34100 - ssize_t low_count, read, sz;
34101 + ssize_t low_count, read, sz, err = 0;
34102 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34103 - int err = 0;
34104
34105 read = 0;
34106 if (p < (unsigned long) high_memory) {
34107 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34108 }
34109 #endif
34110 while (low_count > 0) {
34111 + char *temp;
34112 +
34113 sz = size_inside_page(p, low_count);
34114
34115 /*
34116 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34117 */
34118 kbuf = xlate_dev_kmem_ptr((char *)p);
34119
34120 - if (copy_to_user(buf, kbuf, sz))
34121 +#ifdef CONFIG_PAX_USERCOPY
34122 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34123 + if (!temp)
34124 + return -ENOMEM;
34125 + memcpy(temp, kbuf, sz);
34126 +#else
34127 + temp = kbuf;
34128 +#endif
34129 +
34130 + err = copy_to_user(buf, temp, sz);
34131 +
34132 +#ifdef CONFIG_PAX_USERCOPY
34133 + kfree(temp);
34134 +#endif
34135 +
34136 + if (err)
34137 return -EFAULT;
34138 buf += sz;
34139 p += sz;
34140 @@ -869,6 +916,9 @@ static const struct memdev {
34141 #ifdef CONFIG_CRASH_DUMP
34142 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34143 #endif
34144 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34145 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34146 +#endif
34147 };
34148
34149 static int memory_open(struct inode *inode, struct file *filp)
34150 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
34151 continue;
34152
34153 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34154 - NULL, devlist[minor].name);
34155 + NULL, "%s", devlist[minor].name);
34156 }
34157
34158 return tty_init();
34159 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34160 index c689697..04e6d6a2 100644
34161 --- a/drivers/char/mwave/tp3780i.c
34162 +++ b/drivers/char/mwave/tp3780i.c
34163 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34164 PRINTK_2(TRACE_TP3780I,
34165 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34166
34167 + memset(pAbilities, 0, sizeof(*pAbilities));
34168 /* fill out standard constant fields */
34169 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34170 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34171 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34172 index 9df78e2..01ba9ae 100644
34173 --- a/drivers/char/nvram.c
34174 +++ b/drivers/char/nvram.c
34175 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34176
34177 spin_unlock_irq(&rtc_lock);
34178
34179 - if (copy_to_user(buf, contents, tmp - contents))
34180 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34181 return -EFAULT;
34182
34183 *ppos = i;
34184 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34185 index 5c5cc00..ac9edb7 100644
34186 --- a/drivers/char/pcmcia/synclink_cs.c
34187 +++ b/drivers/char/pcmcia/synclink_cs.c
34188 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34189
34190 if (debug_level >= DEBUG_LEVEL_INFO)
34191 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34192 - __FILE__, __LINE__, info->device_name, port->count);
34193 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34194
34195 - WARN_ON(!port->count);
34196 + WARN_ON(!atomic_read(&port->count));
34197
34198 if (tty_port_close_start(port, tty, filp) == 0)
34199 goto cleanup;
34200 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34201 cleanup:
34202 if (debug_level >= DEBUG_LEVEL_INFO)
34203 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34204 - tty->driver->name, port->count);
34205 + tty->driver->name, atomic_read(&port->count));
34206 }
34207
34208 /* Wait until the transmitter is empty.
34209 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34210
34211 if (debug_level >= DEBUG_LEVEL_INFO)
34212 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34213 - __FILE__, __LINE__, tty->driver->name, port->count);
34214 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34215
34216 /* If port is closing, signal caller to try again */
34217 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34218 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34219 goto cleanup;
34220 }
34221 spin_lock(&port->lock);
34222 - port->count++;
34223 + atomic_inc(&port->count);
34224 spin_unlock(&port->lock);
34225 spin_unlock_irqrestore(&info->netlock, flags);
34226
34227 - if (port->count == 1) {
34228 + if (atomic_read(&port->count) == 1) {
34229 /* 1st open on this device, init hardware */
34230 retval = startup(info, tty);
34231 if (retval < 0)
34232 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34233 unsigned short new_crctype;
34234
34235 /* return error if TTY interface open */
34236 - if (info->port.count)
34237 + if (atomic_read(&info->port.count))
34238 return -EBUSY;
34239
34240 switch (encoding)
34241 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34242
34243 /* arbitrate between network and tty opens */
34244 spin_lock_irqsave(&info->netlock, flags);
34245 - if (info->port.count != 0 || info->netcount != 0) {
34246 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34247 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34248 spin_unlock_irqrestore(&info->netlock, flags);
34249 return -EBUSY;
34250 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34251 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34252
34253 /* return error if TTY interface open */
34254 - if (info->port.count)
34255 + if (atomic_read(&info->port.count))
34256 return -EBUSY;
34257
34258 if (cmd != SIOCWANDEV)
34259 diff --git a/drivers/char/random.c b/drivers/char/random.c
34260 index 35487e8..dac8bd1 100644
34261 --- a/drivers/char/random.c
34262 +++ b/drivers/char/random.c
34263 @@ -272,8 +272,13 @@
34264 /*
34265 * Configuration information
34266 */
34267 +#ifdef CONFIG_GRKERNSEC_RANDNET
34268 +#define INPUT_POOL_WORDS 512
34269 +#define OUTPUT_POOL_WORDS 128
34270 +#else
34271 #define INPUT_POOL_WORDS 128
34272 #define OUTPUT_POOL_WORDS 32
34273 +#endif
34274 #define SEC_XFER_SIZE 512
34275 #define EXTRACT_SIZE 10
34276
34277 @@ -313,10 +318,17 @@ static struct poolinfo {
34278 int poolwords;
34279 int tap1, tap2, tap3, tap4, tap5;
34280 } poolinfo_table[] = {
34281 +#ifdef CONFIG_GRKERNSEC_RANDNET
34282 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34283 + { 512, 411, 308, 208, 104, 1 },
34284 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34285 + { 128, 103, 76, 51, 25, 1 },
34286 +#else
34287 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34288 { 128, 103, 76, 51, 25, 1 },
34289 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34290 { 32, 26, 20, 14, 7, 1 },
34291 +#endif
34292 #if 0
34293 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34294 { 2048, 1638, 1231, 819, 411, 1 },
34295 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34296 input_rotate += i ? 7 : 14;
34297 }
34298
34299 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34300 - ACCESS_ONCE(r->add_ptr) = i;
34301 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34302 + ACCESS_ONCE_RW(r->add_ptr) = i;
34303 smp_wmb();
34304
34305 if (out)
34306 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34307
34308 extract_buf(r, tmp);
34309 i = min_t(int, nbytes, EXTRACT_SIZE);
34310 - if (copy_to_user(buf, tmp, i)) {
34311 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34312 ret = -EFAULT;
34313 break;
34314 }
34315 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34316 #include <linux/sysctl.h>
34317
34318 static int min_read_thresh = 8, min_write_thresh;
34319 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34320 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34321 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34322 static char sysctl_bootid[16];
34323
34324 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34325 static int proc_do_uuid(ctl_table *table, int write,
34326 void __user *buffer, size_t *lenp, loff_t *ppos)
34327 {
34328 - ctl_table fake_table;
34329 + ctl_table_no_const fake_table;
34330 unsigned char buf[64], tmp_uuid[16], *uuid;
34331
34332 uuid = table->data;
34333 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34334 index bf2349db..5456d53 100644
34335 --- a/drivers/char/sonypi.c
34336 +++ b/drivers/char/sonypi.c
34337 @@ -54,6 +54,7 @@
34338
34339 #include <asm/uaccess.h>
34340 #include <asm/io.h>
34341 +#include <asm/local.h>
34342
34343 #include <linux/sonypi.h>
34344
34345 @@ -490,7 +491,7 @@ static struct sonypi_device {
34346 spinlock_t fifo_lock;
34347 wait_queue_head_t fifo_proc_list;
34348 struct fasync_struct *fifo_async;
34349 - int open_count;
34350 + local_t open_count;
34351 int model;
34352 struct input_dev *input_jog_dev;
34353 struct input_dev *input_key_dev;
34354 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34355 static int sonypi_misc_release(struct inode *inode, struct file *file)
34356 {
34357 mutex_lock(&sonypi_device.lock);
34358 - sonypi_device.open_count--;
34359 + local_dec(&sonypi_device.open_count);
34360 mutex_unlock(&sonypi_device.lock);
34361 return 0;
34362 }
34363 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34364 {
34365 mutex_lock(&sonypi_device.lock);
34366 /* Flush input queue on first open */
34367 - if (!sonypi_device.open_count)
34368 + if (!local_read(&sonypi_device.open_count))
34369 kfifo_reset(&sonypi_device.fifo);
34370 - sonypi_device.open_count++;
34371 + local_inc(&sonypi_device.open_count);
34372 mutex_unlock(&sonypi_device.lock);
34373
34374 return 0;
34375 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34376 index 64420b3..5c40b56 100644
34377 --- a/drivers/char/tpm/tpm_acpi.c
34378 +++ b/drivers/char/tpm/tpm_acpi.c
34379 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34380 virt = acpi_os_map_memory(start, len);
34381 if (!virt) {
34382 kfree(log->bios_event_log);
34383 + log->bios_event_log = NULL;
34384 printk("%s: ERROR - Unable to map memory\n", __func__);
34385 return -EIO;
34386 }
34387
34388 - memcpy_fromio(log->bios_event_log, virt, len);
34389 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34390
34391 acpi_os_unmap_memory(virt, len);
34392 return 0;
34393 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34394 index 84ddc55..1d32f1e 100644
34395 --- a/drivers/char/tpm/tpm_eventlog.c
34396 +++ b/drivers/char/tpm/tpm_eventlog.c
34397 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34398 event = addr;
34399
34400 if ((event->event_type == 0 && event->event_size == 0) ||
34401 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34402 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34403 return NULL;
34404
34405 return addr;
34406 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34407 return NULL;
34408
34409 if ((event->event_type == 0 && event->event_size == 0) ||
34410 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34411 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34412 return NULL;
34413
34414 (*pos)++;
34415 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34416 int i;
34417
34418 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34419 - seq_putc(m, data[i]);
34420 + if (!seq_putc(m, data[i]))
34421 + return -EFAULT;
34422
34423 return 0;
34424 }
34425 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34426 index 1b456fe..2510242 100644
34427 --- a/drivers/char/virtio_console.c
34428 +++ b/drivers/char/virtio_console.c
34429 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34430 if (to_user) {
34431 ssize_t ret;
34432
34433 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34434 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34435 if (ret)
34436 return -EFAULT;
34437 } else {
34438 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34439 if (!port_has_data(port) && !port->host_connected)
34440 return 0;
34441
34442 - return fill_readbuf(port, ubuf, count, true);
34443 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34444 }
34445
34446 static int wait_port_writable(struct port *port, bool nonblock)
34447 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
34448 index a33f46f..a720eed 100644
34449 --- a/drivers/clk/clk-composite.c
34450 +++ b/drivers/clk/clk-composite.c
34451 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
34452 struct clk *clk;
34453 struct clk_init_data init;
34454 struct clk_composite *composite;
34455 - struct clk_ops *clk_composite_ops;
34456 + clk_ops_no_const *clk_composite_ops;
34457
34458 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
34459 if (!composite) {
34460 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34461 index a2b2541..bc1e7ff 100644
34462 --- a/drivers/clocksource/arm_arch_timer.c
34463 +++ b/drivers/clocksource/arm_arch_timer.c
34464 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34465 return NOTIFY_OK;
34466 }
34467
34468 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34469 +static struct notifier_block arch_timer_cpu_nb = {
34470 .notifier_call = arch_timer_cpu_notify,
34471 };
34472
34473 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34474 index ade7513..069445f 100644
34475 --- a/drivers/clocksource/metag_generic.c
34476 +++ b/drivers/clocksource/metag_generic.c
34477 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34478 return NOTIFY_OK;
34479 }
34480
34481 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34482 +static struct notifier_block arch_timer_cpu_nb = {
34483 .notifier_call = arch_timer_cpu_notify,
34484 };
34485
34486 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34487 index edc089e..bc7c0bc 100644
34488 --- a/drivers/cpufreq/acpi-cpufreq.c
34489 +++ b/drivers/cpufreq/acpi-cpufreq.c
34490 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34491 return sprintf(buf, "%u\n", boost_enabled);
34492 }
34493
34494 -static struct global_attr global_boost = __ATTR(boost, 0644,
34495 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34496 show_global_boost,
34497 store_global_boost);
34498
34499 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34500 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34501 per_cpu(acfreq_data, cpu) = data;
34502
34503 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34504 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34505 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34506 + pax_open_kernel();
34507 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34508 + pax_close_kernel();
34509 + }
34510
34511 result = acpi_processor_register_performance(data->acpi_data, cpu);
34512 if (result)
34513 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34514 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34515 break;
34516 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34517 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34518 + pax_open_kernel();
34519 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34520 + pax_close_kernel();
34521 policy->cur = get_cur_freq_on_cpu(cpu);
34522 break;
34523 default:
34524 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34525 acpi_processor_notify_smm(THIS_MODULE);
34526
34527 /* Check for APERF/MPERF support in hardware */
34528 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34529 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34530 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34531 + pax_open_kernel();
34532 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34533 + pax_close_kernel();
34534 + }
34535
34536 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34537 for (i = 0; i < perf->state_count; i++)
34538 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34539 index 2d53f47..eb3803e 100644
34540 --- a/drivers/cpufreq/cpufreq.c
34541 +++ b/drivers/cpufreq/cpufreq.c
34542 @@ -1851,7 +1851,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34543 return NOTIFY_OK;
34544 }
34545
34546 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34547 +static struct notifier_block cpufreq_cpu_notifier = {
34548 .notifier_call = cpufreq_cpu_callback,
34549 };
34550
34551 @@ -1883,8 +1883,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34552
34553 pr_debug("trying to register driver %s\n", driver_data->name);
34554
34555 - if (driver_data->setpolicy)
34556 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34557 + if (driver_data->setpolicy) {
34558 + pax_open_kernel();
34559 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34560 + pax_close_kernel();
34561 + }
34562
34563 write_lock_irqsave(&cpufreq_driver_lock, flags);
34564 if (cpufreq_driver) {
34565 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34566 index dc9b72e..11c0302 100644
34567 --- a/drivers/cpufreq/cpufreq_governor.c
34568 +++ b/drivers/cpufreq/cpufreq_governor.c
34569 @@ -238,7 +238,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34570 struct dbs_data *dbs_data;
34571 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34572 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34573 - struct od_ops *od_ops = NULL;
34574 + const struct od_ops *od_ops = NULL;
34575 struct od_dbs_tuners *od_tuners = NULL;
34576 struct cs_dbs_tuners *cs_tuners = NULL;
34577 struct cpu_dbs_common_info *cpu_cdbs;
34578 @@ -301,7 +301,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34579
34580 if ((cdata->governor == GOV_CONSERVATIVE) &&
34581 (!policy->governor->initialized)) {
34582 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34583 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34584
34585 cpufreq_register_notifier(cs_ops->notifier_block,
34586 CPUFREQ_TRANSITION_NOTIFIER);
34587 @@ -318,7 +318,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34588
34589 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
34590 (policy->governor->initialized == 1)) {
34591 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34592 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34593
34594 cpufreq_unregister_notifier(cs_ops->notifier_block,
34595 CPUFREQ_TRANSITION_NOTIFIER);
34596 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34597 index e16a961..0e68927 100644
34598 --- a/drivers/cpufreq/cpufreq_governor.h
34599 +++ b/drivers/cpufreq/cpufreq_governor.h
34600 @@ -204,7 +204,7 @@ struct common_dbs_data {
34601 void (*exit)(struct dbs_data *dbs_data);
34602
34603 /* Governor specific ops, see below */
34604 - void *gov_ops;
34605 + const void *gov_ops;
34606 };
34607
34608 /* Governer Per policy data */
34609 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
34610 index 93eb5cb..f8ab572 100644
34611 --- a/drivers/cpufreq/cpufreq_ondemand.c
34612 +++ b/drivers/cpufreq/cpufreq_ondemand.c
34613 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
34614 (struct cpufreq_policy *, unsigned int, unsigned int),
34615 unsigned int powersave_bias)
34616 {
34617 - od_ops.powersave_bias_target = f;
34618 + pax_open_kernel();
34619 + *(void **)&od_ops.powersave_bias_target = f;
34620 + pax_close_kernel();
34621 od_set_powersave_bias(powersave_bias);
34622 }
34623 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
34624
34625 void od_unregister_powersave_bias_handler(void)
34626 {
34627 - od_ops.powersave_bias_target = generic_powersave_bias_target;
34628 + pax_open_kernel();
34629 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
34630 + pax_close_kernel();
34631 od_set_powersave_bias(0);
34632 }
34633 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
34634 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34635 index fb65dec..b88254d 100644
34636 --- a/drivers/cpufreq/cpufreq_stats.c
34637 +++ b/drivers/cpufreq/cpufreq_stats.c
34638 @@ -366,7 +366,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34639 }
34640
34641 /* priority=1 so this will get called before cpufreq_remove_dev */
34642 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34643 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34644 .notifier_call = cpufreq_stat_cpu_callback,
34645 .priority = 1,
34646 };
34647 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34648 index 421ef37..e708530c 100644
34649 --- a/drivers/cpufreq/p4-clockmod.c
34650 +++ b/drivers/cpufreq/p4-clockmod.c
34651 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34652 case 0x0F: /* Core Duo */
34653 case 0x16: /* Celeron Core */
34654 case 0x1C: /* Atom */
34655 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34656 + pax_open_kernel();
34657 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34658 + pax_close_kernel();
34659 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34660 case 0x0D: /* Pentium M (Dothan) */
34661 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34662 + pax_open_kernel();
34663 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34664 + pax_close_kernel();
34665 /* fall through */
34666 case 0x09: /* Pentium M (Banias) */
34667 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34668 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34669
34670 /* on P-4s, the TSC runs with constant frequency independent whether
34671 * throttling is active or not. */
34672 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34673 + pax_open_kernel();
34674 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34675 + pax_close_kernel();
34676
34677 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34678 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34679 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
34680 index c71ee14..7c2e183 100644
34681 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
34682 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
34683 @@ -18,14 +18,12 @@
34684 #include <asm/head.h>
34685 #include <asm/timer.h>
34686
34687 -static struct cpufreq_driver *cpufreq_us3_driver;
34688 -
34689 struct us3_freq_percpu_info {
34690 struct cpufreq_frequency_table table[4];
34691 };
34692
34693 /* Indexed by cpu number. */
34694 -static struct us3_freq_percpu_info *us3_freq_table;
34695 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
34696
34697 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
34698 * in the Safari config register.
34699 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
34700
34701 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
34702 {
34703 - if (cpufreq_us3_driver)
34704 - us3_set_cpu_divider_index(policy, 0);
34705 + us3_set_cpu_divider_index(policy->cpu, 0);
34706
34707 return 0;
34708 }
34709
34710 +static int __init us3_freq_init(void);
34711 +static void __exit us3_freq_exit(void);
34712 +
34713 +static struct cpufreq_driver cpufreq_us3_driver = {
34714 + .init = us3_freq_cpu_init,
34715 + .verify = us3_freq_verify,
34716 + .target = us3_freq_target,
34717 + .get = us3_freq_get,
34718 + .exit = us3_freq_cpu_exit,
34719 + .owner = THIS_MODULE,
34720 + .name = "UltraSPARC-III",
34721 +
34722 +};
34723 +
34724 static int __init us3_freq_init(void)
34725 {
34726 unsigned long manuf, impl, ver;
34727 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
34728 (impl == CHEETAH_IMPL ||
34729 impl == CHEETAH_PLUS_IMPL ||
34730 impl == JAGUAR_IMPL ||
34731 - impl == PANTHER_IMPL)) {
34732 - struct cpufreq_driver *driver;
34733 -
34734 - ret = -ENOMEM;
34735 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
34736 - if (!driver)
34737 - goto err_out;
34738 -
34739 - us3_freq_table = kzalloc(
34740 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
34741 - GFP_KERNEL);
34742 - if (!us3_freq_table)
34743 - goto err_out;
34744 -
34745 - driver->init = us3_freq_cpu_init;
34746 - driver->verify = us3_freq_verify;
34747 - driver->target = us3_freq_target;
34748 - driver->get = us3_freq_get;
34749 - driver->exit = us3_freq_cpu_exit;
34750 - driver->owner = THIS_MODULE,
34751 - strcpy(driver->name, "UltraSPARC-III");
34752 -
34753 - cpufreq_us3_driver = driver;
34754 - ret = cpufreq_register_driver(driver);
34755 - if (ret)
34756 - goto err_out;
34757 -
34758 - return 0;
34759 -
34760 -err_out:
34761 - if (driver) {
34762 - kfree(driver);
34763 - cpufreq_us3_driver = NULL;
34764 - }
34765 - kfree(us3_freq_table);
34766 - us3_freq_table = NULL;
34767 - return ret;
34768 - }
34769 + impl == PANTHER_IMPL))
34770 + return cpufreq_register_driver(&cpufreq_us3_driver);
34771
34772 return -ENODEV;
34773 }
34774
34775 static void __exit us3_freq_exit(void)
34776 {
34777 - if (cpufreq_us3_driver) {
34778 - cpufreq_unregister_driver(cpufreq_us3_driver);
34779 - kfree(cpufreq_us3_driver);
34780 - cpufreq_us3_driver = NULL;
34781 - kfree(us3_freq_table);
34782 - us3_freq_table = NULL;
34783 - }
34784 + cpufreq_unregister_driver(&cpufreq_us3_driver);
34785 }
34786
34787 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
34788 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34789 index 618e6f4..e89d915 100644
34790 --- a/drivers/cpufreq/speedstep-centrino.c
34791 +++ b/drivers/cpufreq/speedstep-centrino.c
34792 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34793 !cpu_has(cpu, X86_FEATURE_EST))
34794 return -ENODEV;
34795
34796 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34797 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34798 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34799 + pax_open_kernel();
34800 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34801 + pax_close_kernel();
34802 + }
34803
34804 if (policy->cpu != 0)
34805 return -ENODEV;
34806 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34807 index c3a93fe..e808f24 100644
34808 --- a/drivers/cpuidle/cpuidle.c
34809 +++ b/drivers/cpuidle/cpuidle.c
34810 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
34811
34812 static void poll_idle_init(struct cpuidle_driver *drv)
34813 {
34814 - struct cpuidle_state *state = &drv->states[0];
34815 + cpuidle_state_no_const *state = &drv->states[0];
34816
34817 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34818 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34819 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34820 index ea2f8e7..70ac501 100644
34821 --- a/drivers/cpuidle/governor.c
34822 +++ b/drivers/cpuidle/governor.c
34823 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34824 mutex_lock(&cpuidle_lock);
34825 if (__cpuidle_find_governor(gov->name) == NULL) {
34826 ret = 0;
34827 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34828 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34829 if (!cpuidle_curr_governor ||
34830 cpuidle_curr_governor->rating < gov->rating)
34831 cpuidle_switch_governor(gov);
34832 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34833 new_gov = cpuidle_replace_governor(gov->rating);
34834 cpuidle_switch_governor(new_gov);
34835 }
34836 - list_del(&gov->governor_list);
34837 + pax_list_del((struct list_head *)&gov->governor_list);
34838 mutex_unlock(&cpuidle_lock);
34839 }
34840
34841 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34842 index 428754a..8bdf9cc 100644
34843 --- a/drivers/cpuidle/sysfs.c
34844 +++ b/drivers/cpuidle/sysfs.c
34845 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34846 NULL
34847 };
34848
34849 -static struct attribute_group cpuidle_attr_group = {
34850 +static attribute_group_no_const cpuidle_attr_group = {
34851 .attrs = cpuidle_default_attrs,
34852 .name = "cpuidle",
34853 };
34854 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34855 index 3b36797..db0b0c0 100644
34856 --- a/drivers/devfreq/devfreq.c
34857 +++ b/drivers/devfreq/devfreq.c
34858 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34859 GFP_KERNEL);
34860 devfreq->last_stat_updated = jiffies;
34861
34862 - dev_set_name(&devfreq->dev, dev_name(dev));
34863 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34864 err = device_register(&devfreq->dev);
34865 if (err) {
34866 put_device(&devfreq->dev);
34867 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34868 goto err_out;
34869 }
34870
34871 - list_add(&governor->node, &devfreq_governor_list);
34872 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34873
34874 list_for_each_entry(devfreq, &devfreq_list, node) {
34875 int ret = 0;
34876 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34877 }
34878 }
34879
34880 - list_del(&governor->node);
34881 + pax_list_del((struct list_head *)&governor->node);
34882 err_out:
34883 mutex_unlock(&devfreq_list_lock);
34884
34885 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34886 index b70709b..1d8d02a 100644
34887 --- a/drivers/dma/sh/shdma.c
34888 +++ b/drivers/dma/sh/shdma.c
34889 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34890 return ret;
34891 }
34892
34893 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34894 +static struct notifier_block sh_dmae_nmi_notifier = {
34895 .notifier_call = sh_dmae_nmi_handler,
34896
34897 /* Run before NMI debug handler and KGDB */
34898 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34899 index 67610a6..30f8a11 100644
34900 --- a/drivers/edac/edac_mc_sysfs.c
34901 +++ b/drivers/edac/edac_mc_sysfs.c
34902 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
34903 struct dev_ch_attribute {
34904 struct device_attribute attr;
34905 int channel;
34906 -};
34907 +} __do_const;
34908
34909 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34910 struct dev_ch_attribute dev_attr_legacy_##_name = \
34911 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34912 }
34913
34914 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34915 + pax_open_kernel();
34916 if (mci->get_sdram_scrub_rate) {
34917 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34918 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34919 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34920 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34921 }
34922 if (mci->set_sdram_scrub_rate) {
34923 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34924 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34925 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34926 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34927 }
34928 + pax_close_kernel();
34929 err = device_create_file(&mci->dev,
34930 &dev_attr_sdram_scrub_rate);
34931 if (err) {
34932 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34933 index e8658e4..22746d6 100644
34934 --- a/drivers/edac/edac_pci_sysfs.c
34935 +++ b/drivers/edac/edac_pci_sysfs.c
34936 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34937 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34938 static int edac_pci_poll_msec = 1000; /* one second workq period */
34939
34940 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34941 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34942 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34943 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34944
34945 static struct kobject *edac_pci_top_main_kobj;
34946 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34947 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34948 void *value;
34949 ssize_t(*show) (void *, char *);
34950 ssize_t(*store) (void *, const char *, size_t);
34951 -};
34952 +} __do_const;
34953
34954 /* Set of show/store abstract level functions for PCI Parity object */
34955 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34956 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34957 edac_printk(KERN_CRIT, EDAC_PCI,
34958 "Signaled System Error on %s\n",
34959 pci_name(dev));
34960 - atomic_inc(&pci_nonparity_count);
34961 + atomic_inc_unchecked(&pci_nonparity_count);
34962 }
34963
34964 if (status & (PCI_STATUS_PARITY)) {
34965 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34966 "Master Data Parity Error on %s\n",
34967 pci_name(dev));
34968
34969 - atomic_inc(&pci_parity_count);
34970 + atomic_inc_unchecked(&pci_parity_count);
34971 }
34972
34973 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34974 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34975 "Detected Parity Error on %s\n",
34976 pci_name(dev));
34977
34978 - atomic_inc(&pci_parity_count);
34979 + atomic_inc_unchecked(&pci_parity_count);
34980 }
34981 }
34982
34983 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34984 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34985 "Signaled System Error on %s\n",
34986 pci_name(dev));
34987 - atomic_inc(&pci_nonparity_count);
34988 + atomic_inc_unchecked(&pci_nonparity_count);
34989 }
34990
34991 if (status & (PCI_STATUS_PARITY)) {
34992 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34993 "Master Data Parity Error on "
34994 "%s\n", pci_name(dev));
34995
34996 - atomic_inc(&pci_parity_count);
34997 + atomic_inc_unchecked(&pci_parity_count);
34998 }
34999
35000 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35001 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35002 "Detected Parity Error on %s\n",
35003 pci_name(dev));
35004
35005 - atomic_inc(&pci_parity_count);
35006 + atomic_inc_unchecked(&pci_parity_count);
35007 }
35008 }
35009 }
35010 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
35011 if (!check_pci_errors)
35012 return;
35013
35014 - before_count = atomic_read(&pci_parity_count);
35015 + before_count = atomic_read_unchecked(&pci_parity_count);
35016
35017 /* scan all PCI devices looking for a Parity Error on devices and
35018 * bridges.
35019 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
35020 /* Only if operator has selected panic on PCI Error */
35021 if (edac_pci_get_panic_on_pe()) {
35022 /* If the count is different 'after' from 'before' */
35023 - if (before_count != atomic_read(&pci_parity_count))
35024 + if (before_count != atomic_read_unchecked(&pci_parity_count))
35025 panic("EDAC: PCI Parity Error");
35026 }
35027 }
35028 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
35029 index 51b7e3a..aa8a3e8 100644
35030 --- a/drivers/edac/mce_amd.h
35031 +++ b/drivers/edac/mce_amd.h
35032 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
35033 bool (*mc0_mce)(u16, u8);
35034 bool (*mc1_mce)(u16, u8);
35035 bool (*mc2_mce)(u16, u8);
35036 -};
35037 +} __no_const;
35038
35039 void amd_report_gart_errors(bool);
35040 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35041 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35042 index 57ea7f4..789e3c3 100644
35043 --- a/drivers/firewire/core-card.c
35044 +++ b/drivers/firewire/core-card.c
35045 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35046
35047 void fw_core_remove_card(struct fw_card *card)
35048 {
35049 - struct fw_card_driver dummy_driver = dummy_driver_template;
35050 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35051
35052 card->driver->update_phy_reg(card, 4,
35053 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35054 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35055 index 664a6ff..af13580 100644
35056 --- a/drivers/firewire/core-device.c
35057 +++ b/drivers/firewire/core-device.c
35058 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35059 struct config_rom_attribute {
35060 struct device_attribute attr;
35061 u32 key;
35062 -};
35063 +} __do_const;
35064
35065 static ssize_t show_immediate(struct device *dev,
35066 struct device_attribute *dattr, char *buf)
35067 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35068 index 28a94c7..58da63a 100644
35069 --- a/drivers/firewire/core-transaction.c
35070 +++ b/drivers/firewire/core-transaction.c
35071 @@ -38,6 +38,7 @@
35072 #include <linux/timer.h>
35073 #include <linux/types.h>
35074 #include <linux/workqueue.h>
35075 +#include <linux/sched.h>
35076
35077 #include <asm/byteorder.h>
35078
35079 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35080 index 515a42c..5ecf3ba 100644
35081 --- a/drivers/firewire/core.h
35082 +++ b/drivers/firewire/core.h
35083 @@ -111,6 +111,7 @@ struct fw_card_driver {
35084
35085 int (*stop_iso)(struct fw_iso_context *ctx);
35086 };
35087 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35088
35089 void fw_card_initialize(struct fw_card *card,
35090 const struct fw_card_driver *driver, struct device *device);
35091 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35092 index 94a58a0..f5eba42 100644
35093 --- a/drivers/firmware/dmi-id.c
35094 +++ b/drivers/firmware/dmi-id.c
35095 @@ -16,7 +16,7 @@
35096 struct dmi_device_attribute{
35097 struct device_attribute dev_attr;
35098 int field;
35099 -};
35100 +} __do_const;
35101 #define to_dmi_dev_attr(_dev_attr) \
35102 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35103
35104 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35105 index b95159b..841ae55 100644
35106 --- a/drivers/firmware/dmi_scan.c
35107 +++ b/drivers/firmware/dmi_scan.c
35108 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
35109 }
35110 }
35111 else {
35112 - /*
35113 - * no iounmap() for that ioremap(); it would be a no-op, but
35114 - * it's so early in setup that sucker gets confused into doing
35115 - * what it shouldn't if we actually call it.
35116 - */
35117 p = dmi_ioremap(0xF0000, 0x10000);
35118 if (p == NULL)
35119 goto error;
35120 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35121 if (buf == NULL)
35122 return -1;
35123
35124 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35125 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35126
35127 iounmap(buf);
35128 return 0;
35129 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
35130 index 5145fa3..0d3babd 100644
35131 --- a/drivers/firmware/efi/efi.c
35132 +++ b/drivers/firmware/efi/efi.c
35133 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
35134 };
35135
35136 static struct efivars generic_efivars;
35137 -static struct efivar_operations generic_ops;
35138 +static efivar_operations_no_const generic_ops __read_only;
35139
35140 static int generic_ops_register(void)
35141 {
35142 - generic_ops.get_variable = efi.get_variable;
35143 - generic_ops.set_variable = efi.set_variable;
35144 - generic_ops.get_next_variable = efi.get_next_variable;
35145 - generic_ops.query_variable_store = efi_query_variable_store;
35146 + pax_open_kernel();
35147 + *(void **)&generic_ops.get_variable = efi.get_variable;
35148 + *(void **)&generic_ops.set_variable = efi.set_variable;
35149 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
35150 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
35151 + pax_close_kernel();
35152
35153 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
35154 }
35155 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
35156 index 8bd1bb6..c48b0c6 100644
35157 --- a/drivers/firmware/efi/efivars.c
35158 +++ b/drivers/firmware/efi/efivars.c
35159 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
35160 static int
35161 create_efivars_bin_attributes(void)
35162 {
35163 - struct bin_attribute *attr;
35164 + bin_attribute_no_const *attr;
35165 int error;
35166
35167 /* new_var */
35168 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35169 index 2a90ba6..07f3733 100644
35170 --- a/drivers/firmware/google/memconsole.c
35171 +++ b/drivers/firmware/google/memconsole.c
35172 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35173 if (!found_memconsole())
35174 return -ENODEV;
35175
35176 - memconsole_bin_attr.size = memconsole_length;
35177 + pax_open_kernel();
35178 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35179 + pax_close_kernel();
35180
35181 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35182
35183 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35184 index e16d932..f0206ef 100644
35185 --- a/drivers/gpio/gpio-ich.c
35186 +++ b/drivers/gpio/gpio-ich.c
35187 @@ -69,7 +69,7 @@ struct ichx_desc {
35188 /* Some chipsets have quirks, let these use their own request/get */
35189 int (*request)(struct gpio_chip *chip, unsigned offset);
35190 int (*get)(struct gpio_chip *chip, unsigned offset);
35191 -};
35192 +} __do_const;
35193
35194 static struct {
35195 spinlock_t lock;
35196 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35197 index 9902732..64b62dd 100644
35198 --- a/drivers/gpio/gpio-vr41xx.c
35199 +++ b/drivers/gpio/gpio-vr41xx.c
35200 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35201 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35202 maskl, pendl, maskh, pendh);
35203
35204 - atomic_inc(&irq_err_count);
35205 + atomic_inc_unchecked(&irq_err_count);
35206
35207 return -EINVAL;
35208 }
35209 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35210 index ed1334e..ee0dd42 100644
35211 --- a/drivers/gpu/drm/drm_crtc_helper.c
35212 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35213 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35214 struct drm_crtc *tmp;
35215 int crtc_mask = 1;
35216
35217 - WARN(!crtc, "checking null crtc?\n");
35218 + BUG_ON(!crtc);
35219
35220 dev = crtc->dev;
35221
35222 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35223 index 9cc247f..36aa285 100644
35224 --- a/drivers/gpu/drm/drm_drv.c
35225 +++ b/drivers/gpu/drm/drm_drv.c
35226 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35227 /**
35228 * Copy and IOCTL return string to user space
35229 */
35230 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35231 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35232 {
35233 int len;
35234
35235 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35236 struct drm_file *file_priv = filp->private_data;
35237 struct drm_device *dev;
35238 const struct drm_ioctl_desc *ioctl = NULL;
35239 - drm_ioctl_t *func;
35240 + drm_ioctl_no_const_t func;
35241 unsigned int nr = DRM_IOCTL_NR(cmd);
35242 int retcode = -EINVAL;
35243 char stack_kdata[128];
35244 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35245 return -ENODEV;
35246
35247 atomic_inc(&dev->ioctl_count);
35248 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35249 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35250 ++file_priv->ioctl_count;
35251
35252 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
35253 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35254 index 429e07d..e681a2c 100644
35255 --- a/drivers/gpu/drm/drm_fops.c
35256 +++ b/drivers/gpu/drm/drm_fops.c
35257 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35258 }
35259
35260 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35261 - atomic_set(&dev->counts[i], 0);
35262 + atomic_set_unchecked(&dev->counts[i], 0);
35263
35264 dev->sigdata.lock = NULL;
35265
35266 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35267 if (drm_device_is_unplugged(dev))
35268 return -ENODEV;
35269
35270 - if (!dev->open_count++)
35271 + if (local_inc_return(&dev->open_count) == 1)
35272 need_setup = 1;
35273 mutex_lock(&dev->struct_mutex);
35274 old_imapping = inode->i_mapping;
35275 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35276 retcode = drm_open_helper(inode, filp, dev);
35277 if (retcode)
35278 goto err_undo;
35279 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35280 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35281 if (need_setup) {
35282 retcode = drm_setup(dev);
35283 if (retcode)
35284 @@ -166,7 +166,7 @@ err_undo:
35285 iput(container_of(dev->dev_mapping, struct inode, i_data));
35286 dev->dev_mapping = old_mapping;
35287 mutex_unlock(&dev->struct_mutex);
35288 - dev->open_count--;
35289 + local_dec(&dev->open_count);
35290 return retcode;
35291 }
35292 EXPORT_SYMBOL(drm_open);
35293 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35294
35295 mutex_lock(&drm_global_mutex);
35296
35297 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35298 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35299
35300 if (dev->driver->preclose)
35301 dev->driver->preclose(dev, file_priv);
35302 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35303 * Begin inline drm_release
35304 */
35305
35306 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35307 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35308 task_pid_nr(current),
35309 (long)old_encode_dev(file_priv->minor->device),
35310 - dev->open_count);
35311 + local_read(&dev->open_count));
35312
35313 /* Release any auth tokens that might point to this file_priv,
35314 (do that under the drm_global_mutex) */
35315 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35316 * End inline drm_release
35317 */
35318
35319 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35320 - if (!--dev->open_count) {
35321 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35322 + if (local_dec_and_test(&dev->open_count)) {
35323 if (atomic_read(&dev->ioctl_count)) {
35324 DRM_ERROR("Device busy: %d\n",
35325 atomic_read(&dev->ioctl_count));
35326 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35327 index f731116..629842c 100644
35328 --- a/drivers/gpu/drm/drm_global.c
35329 +++ b/drivers/gpu/drm/drm_global.c
35330 @@ -36,7 +36,7 @@
35331 struct drm_global_item {
35332 struct mutex mutex;
35333 void *object;
35334 - int refcount;
35335 + atomic_t refcount;
35336 };
35337
35338 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35339 @@ -49,7 +49,7 @@ void drm_global_init(void)
35340 struct drm_global_item *item = &glob[i];
35341 mutex_init(&item->mutex);
35342 item->object = NULL;
35343 - item->refcount = 0;
35344 + atomic_set(&item->refcount, 0);
35345 }
35346 }
35347
35348 @@ -59,7 +59,7 @@ void drm_global_release(void)
35349 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35350 struct drm_global_item *item = &glob[i];
35351 BUG_ON(item->object != NULL);
35352 - BUG_ON(item->refcount != 0);
35353 + BUG_ON(atomic_read(&item->refcount) != 0);
35354 }
35355 }
35356
35357 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35358 void *object;
35359
35360 mutex_lock(&item->mutex);
35361 - if (item->refcount == 0) {
35362 + if (atomic_read(&item->refcount) == 0) {
35363 item->object = kzalloc(ref->size, GFP_KERNEL);
35364 if (unlikely(item->object == NULL)) {
35365 ret = -ENOMEM;
35366 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35367 goto out_err;
35368
35369 }
35370 - ++item->refcount;
35371 + atomic_inc(&item->refcount);
35372 ref->object = item->object;
35373 object = item->object;
35374 mutex_unlock(&item->mutex);
35375 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35376 struct drm_global_item *item = &glob[ref->global_type];
35377
35378 mutex_lock(&item->mutex);
35379 - BUG_ON(item->refcount == 0);
35380 + BUG_ON(atomic_read(&item->refcount) == 0);
35381 BUG_ON(ref->object != item->object);
35382 - if (--item->refcount == 0) {
35383 + if (atomic_dec_and_test(&item->refcount)) {
35384 ref->release(ref);
35385 item->object = NULL;
35386 }
35387 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35388 index d4b20ce..77a8d41 100644
35389 --- a/drivers/gpu/drm/drm_info.c
35390 +++ b/drivers/gpu/drm/drm_info.c
35391 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35392 struct drm_local_map *map;
35393 struct drm_map_list *r_list;
35394
35395 - /* Hardcoded from _DRM_FRAME_BUFFER,
35396 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35397 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35398 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35399 + static const char * const types[] = {
35400 + [_DRM_FRAME_BUFFER] = "FB",
35401 + [_DRM_REGISTERS] = "REG",
35402 + [_DRM_SHM] = "SHM",
35403 + [_DRM_AGP] = "AGP",
35404 + [_DRM_SCATTER_GATHER] = "SG",
35405 + [_DRM_CONSISTENT] = "PCI",
35406 + [_DRM_GEM] = "GEM" };
35407 const char *type;
35408 int i;
35409
35410 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35411 map = r_list->map;
35412 if (!map)
35413 continue;
35414 - if (map->type < 0 || map->type > 5)
35415 + if (map->type >= ARRAY_SIZE(types))
35416 type = "??";
35417 else
35418 type = types[map->type];
35419 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35420 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35421 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35422 vma->vm_flags & VM_IO ? 'i' : '-',
35423 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35424 + 0);
35425 +#else
35426 vma->vm_pgoff);
35427 +#endif
35428
35429 #if defined(__i386__)
35430 pgprot = pgprot_val(vma->vm_page_prot);
35431 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35432 index 2f4c434..dd12cd2 100644
35433 --- a/drivers/gpu/drm/drm_ioc32.c
35434 +++ b/drivers/gpu/drm/drm_ioc32.c
35435 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35436 request = compat_alloc_user_space(nbytes);
35437 if (!access_ok(VERIFY_WRITE, request, nbytes))
35438 return -EFAULT;
35439 - list = (struct drm_buf_desc *) (request + 1);
35440 + list = (struct drm_buf_desc __user *) (request + 1);
35441
35442 if (__put_user(count, &request->count)
35443 || __put_user(list, &request->list))
35444 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35445 request = compat_alloc_user_space(nbytes);
35446 if (!access_ok(VERIFY_WRITE, request, nbytes))
35447 return -EFAULT;
35448 - list = (struct drm_buf_pub *) (request + 1);
35449 + list = (struct drm_buf_pub __user *) (request + 1);
35450
35451 if (__put_user(count, &request->count)
35452 || __put_user(list, &request->list))
35453 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35454 return 0;
35455 }
35456
35457 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35458 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35459 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35460 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35461 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35462 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35463 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35464 {
35465 unsigned int nr = DRM_IOCTL_NR(cmd);
35466 - drm_ioctl_compat_t *fn;
35467 int ret;
35468
35469 /* Assume that ioctls without an explicit compat routine will just
35470 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35471 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35472 return drm_ioctl(filp, cmd, arg);
35473
35474 - fn = drm_compat_ioctls[nr];
35475 -
35476 - if (fn != NULL)
35477 - ret = (*fn) (filp, cmd, arg);
35478 + if (drm_compat_ioctls[nr] != NULL)
35479 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35480 else
35481 ret = drm_ioctl(filp, cmd, arg);
35482
35483 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35484 index e77bd8b..1571b85 100644
35485 --- a/drivers/gpu/drm/drm_ioctl.c
35486 +++ b/drivers/gpu/drm/drm_ioctl.c
35487 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35488 stats->data[i].value =
35489 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35490 else
35491 - stats->data[i].value = atomic_read(&dev->counts[i]);
35492 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35493 stats->data[i].type = dev->types[i];
35494 }
35495
35496 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35497 index d752c96..fe08455 100644
35498 --- a/drivers/gpu/drm/drm_lock.c
35499 +++ b/drivers/gpu/drm/drm_lock.c
35500 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35501 if (drm_lock_take(&master->lock, lock->context)) {
35502 master->lock.file_priv = file_priv;
35503 master->lock.lock_time = jiffies;
35504 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35505 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35506 break; /* Got lock */
35507 }
35508
35509 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35510 return -EINVAL;
35511 }
35512
35513 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35514 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35515
35516 if (drm_lock_free(&master->lock, lock->context)) {
35517 /* FIXME: Should really bail out here. */
35518 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35519 index 16f3ec5..b28f9ca 100644
35520 --- a/drivers/gpu/drm/drm_stub.c
35521 +++ b/drivers/gpu/drm/drm_stub.c
35522 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35523
35524 drm_device_set_unplugged(dev);
35525
35526 - if (dev->open_count == 0) {
35527 + if (local_read(&dev->open_count) == 0) {
35528 drm_put_dev(dev);
35529 }
35530 mutex_unlock(&drm_global_mutex);
35531 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35532 index 0229665..f61329c 100644
35533 --- a/drivers/gpu/drm/drm_sysfs.c
35534 +++ b/drivers/gpu/drm/drm_sysfs.c
35535 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35536 int drm_sysfs_device_add(struct drm_minor *minor)
35537 {
35538 int err;
35539 - char *minor_str;
35540 + const char *minor_str;
35541
35542 minor->kdev.parent = minor->dev->dev;
35543
35544 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35545 index 004ecdf..db1f6e0 100644
35546 --- a/drivers/gpu/drm/i810/i810_dma.c
35547 +++ b/drivers/gpu/drm/i810/i810_dma.c
35548 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35549 dma->buflist[vertex->idx],
35550 vertex->discard, vertex->used);
35551
35552 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35553 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35554 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35555 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35556 sarea_priv->last_enqueue = dev_priv->counter - 1;
35557 sarea_priv->last_dispatch = (int)hw_status[5];
35558
35559 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35560 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35561 mc->last_render);
35562
35563 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35564 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35565 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35566 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35567 sarea_priv->last_enqueue = dev_priv->counter - 1;
35568 sarea_priv->last_dispatch = (int)hw_status[5];
35569
35570 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35571 index 6e0acad..93c8289 100644
35572 --- a/drivers/gpu/drm/i810/i810_drv.h
35573 +++ b/drivers/gpu/drm/i810/i810_drv.h
35574 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35575 int page_flipping;
35576
35577 wait_queue_head_t irq_queue;
35578 - atomic_t irq_received;
35579 - atomic_t irq_emitted;
35580 + atomic_unchecked_t irq_received;
35581 + atomic_unchecked_t irq_emitted;
35582
35583 int front_offset;
35584 } drm_i810_private_t;
35585 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35586 index e913d32..4d9b351 100644
35587 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35588 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35589 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35590 I915_READ(GTIMR));
35591 }
35592 seq_printf(m, "Interrupts received: %d\n",
35593 - atomic_read(&dev_priv->irq_received));
35594 + atomic_read_unchecked(&dev_priv->irq_received));
35595 for_each_ring(ring, dev_priv, i) {
35596 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35597 seq_printf(m,
35598 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35599 index 3b315ba..aac280f 100644
35600 --- a/drivers/gpu/drm/i915/i915_dma.c
35601 +++ b/drivers/gpu/drm/i915/i915_dma.c
35602 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35603 bool can_switch;
35604
35605 spin_lock(&dev->count_lock);
35606 - can_switch = (dev->open_count == 0);
35607 + can_switch = (local_read(&dev->open_count) == 0);
35608 spin_unlock(&dev->count_lock);
35609 return can_switch;
35610 }
35611 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35612 index 9669a0b..bb65176 100644
35613 --- a/drivers/gpu/drm/i915/i915_drv.h
35614 +++ b/drivers/gpu/drm/i915/i915_drv.h
35615 @@ -915,7 +915,7 @@ typedef struct drm_i915_private {
35616 drm_dma_handle_t *status_page_dmah;
35617 struct resource mch_res;
35618
35619 - atomic_t irq_received;
35620 + atomic_unchecked_t irq_received;
35621
35622 /* protects the irq masks */
35623 spinlock_t irq_lock;
35624 @@ -1811,7 +1811,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35625 struct drm_i915_private *dev_priv, unsigned port);
35626 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35627 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35628 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35629 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35630 {
35631 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35632 }
35633 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35634 index 117ce38..eefd237 100644
35635 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35636 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35637 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35638
35639 static int
35640 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35641 - int count)
35642 + unsigned int count)
35643 {
35644 - int i;
35645 + unsigned int i;
35646 int relocs_total = 0;
35647 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35648
35649 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35650 index 3c59584..500f2e9 100644
35651 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35652 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35653 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35654 (unsigned long)request);
35655 }
35656
35657 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35658 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35659 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35660 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35661 [DRM_I915_GETPARAM] = compat_i915_getparam,
35662 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35663 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35664 {
35665 unsigned int nr = DRM_IOCTL_NR(cmd);
35666 - drm_ioctl_compat_t *fn = NULL;
35667 int ret;
35668
35669 if (nr < DRM_COMMAND_BASE)
35670 return drm_compat_ioctl(filp, cmd, arg);
35671
35672 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35673 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35674 -
35675 - if (fn != NULL)
35676 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35677 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35678 ret = (*fn) (filp, cmd, arg);
35679 - else
35680 + } else
35681 ret = drm_ioctl(filp, cmd, arg);
35682
35683 return ret;
35684 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35685 index 0aa2ef0..77c03d0 100644
35686 --- a/drivers/gpu/drm/i915/i915_irq.c
35687 +++ b/drivers/gpu/drm/i915/i915_irq.c
35688 @@ -679,7 +679,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35689 int pipe;
35690 u32 pipe_stats[I915_MAX_PIPES];
35691
35692 - atomic_inc(&dev_priv->irq_received);
35693 + atomic_inc_unchecked(&dev_priv->irq_received);
35694
35695 while (true) {
35696 iir = I915_READ(VLV_IIR);
35697 @@ -844,7 +844,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35698 irqreturn_t ret = IRQ_NONE;
35699 int i;
35700
35701 - atomic_inc(&dev_priv->irq_received);
35702 + atomic_inc_unchecked(&dev_priv->irq_received);
35703
35704 /* disable master interrupt before clearing iir */
35705 de_ier = I915_READ(DEIER);
35706 @@ -934,7 +934,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35707 int ret = IRQ_NONE;
35708 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35709
35710 - atomic_inc(&dev_priv->irq_received);
35711 + atomic_inc_unchecked(&dev_priv->irq_received);
35712
35713 /* disable master interrupt before clearing iir */
35714 de_ier = I915_READ(DEIER);
35715 @@ -2098,7 +2098,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35716 {
35717 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35718
35719 - atomic_set(&dev_priv->irq_received, 0);
35720 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35721
35722 I915_WRITE(HWSTAM, 0xeffe);
35723
35724 @@ -2133,7 +2133,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35725 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35726 int pipe;
35727
35728 - atomic_set(&dev_priv->irq_received, 0);
35729 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35730
35731 /* VLV magic */
35732 I915_WRITE(VLV_IMR, 0);
35733 @@ -2420,7 +2420,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35734 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35735 int pipe;
35736
35737 - atomic_set(&dev_priv->irq_received, 0);
35738 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35739
35740 for_each_pipe(pipe)
35741 I915_WRITE(PIPESTAT(pipe), 0);
35742 @@ -2499,7 +2499,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35743 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35744 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35745
35746 - atomic_inc(&dev_priv->irq_received);
35747 + atomic_inc_unchecked(&dev_priv->irq_received);
35748
35749 iir = I915_READ16(IIR);
35750 if (iir == 0)
35751 @@ -2574,7 +2574,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35752 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35753 int pipe;
35754
35755 - atomic_set(&dev_priv->irq_received, 0);
35756 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35757
35758 if (I915_HAS_HOTPLUG(dev)) {
35759 I915_WRITE(PORT_HOTPLUG_EN, 0);
35760 @@ -2673,7 +2673,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35761 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35762 int pipe, ret = IRQ_NONE;
35763
35764 - atomic_inc(&dev_priv->irq_received);
35765 + atomic_inc_unchecked(&dev_priv->irq_received);
35766
35767 iir = I915_READ(IIR);
35768 do {
35769 @@ -2800,7 +2800,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35770 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35771 int pipe;
35772
35773 - atomic_set(&dev_priv->irq_received, 0);
35774 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35775
35776 I915_WRITE(PORT_HOTPLUG_EN, 0);
35777 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35778 @@ -2907,7 +2907,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35779 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35780 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35781
35782 - atomic_inc(&dev_priv->irq_received);
35783 + atomic_inc_unchecked(&dev_priv->irq_received);
35784
35785 iir = I915_READ(IIR);
35786
35787 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35788 index 56746dc..b5a214f 100644
35789 --- a/drivers/gpu/drm/i915/intel_display.c
35790 +++ b/drivers/gpu/drm/i915/intel_display.c
35791 @@ -8919,13 +8919,13 @@ struct intel_quirk {
35792 int subsystem_vendor;
35793 int subsystem_device;
35794 void (*hook)(struct drm_device *dev);
35795 -};
35796 +} __do_const;
35797
35798 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35799 struct intel_dmi_quirk {
35800 void (*hook)(struct drm_device *dev);
35801 const struct dmi_system_id (*dmi_id_list)[];
35802 -};
35803 +} __do_const;
35804
35805 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35806 {
35807 @@ -8933,18 +8933,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35808 return 1;
35809 }
35810
35811 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35812 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35813 {
35814 - .dmi_id_list = &(const struct dmi_system_id[]) {
35815 - {
35816 - .callback = intel_dmi_reverse_brightness,
35817 - .ident = "NCR Corporation",
35818 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35819 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35820 - },
35821 - },
35822 - { } /* terminating entry */
35823 + .callback = intel_dmi_reverse_brightness,
35824 + .ident = "NCR Corporation",
35825 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35826 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35827 },
35828 + },
35829 + { } /* terminating entry */
35830 +};
35831 +
35832 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35833 + {
35834 + .dmi_id_list = &intel_dmi_quirks_table,
35835 .hook = quirk_invert_brightness,
35836 },
35837 };
35838 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35839 index 54558a0..2d97005 100644
35840 --- a/drivers/gpu/drm/mga/mga_drv.h
35841 +++ b/drivers/gpu/drm/mga/mga_drv.h
35842 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35843 u32 clear_cmd;
35844 u32 maccess;
35845
35846 - atomic_t vbl_received; /**< Number of vblanks received. */
35847 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35848 wait_queue_head_t fence_queue;
35849 - atomic_t last_fence_retired;
35850 + atomic_unchecked_t last_fence_retired;
35851 u32 next_fence_to_post;
35852
35853 unsigned int fb_cpp;
35854 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35855 index 709e90d..89a1c0d 100644
35856 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35857 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35858 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35859 return 0;
35860 }
35861
35862 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35863 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35864 [DRM_MGA_INIT] = compat_mga_init,
35865 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35866 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35867 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35868 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35869 {
35870 unsigned int nr = DRM_IOCTL_NR(cmd);
35871 - drm_ioctl_compat_t *fn = NULL;
35872 int ret;
35873
35874 if (nr < DRM_COMMAND_BASE)
35875 return drm_compat_ioctl(filp, cmd, arg);
35876
35877 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35878 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35879 -
35880 - if (fn != NULL)
35881 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35882 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35883 ret = (*fn) (filp, cmd, arg);
35884 - else
35885 + } else
35886 ret = drm_ioctl(filp, cmd, arg);
35887
35888 return ret;
35889 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35890 index 598c281..60d590e 100644
35891 --- a/drivers/gpu/drm/mga/mga_irq.c
35892 +++ b/drivers/gpu/drm/mga/mga_irq.c
35893 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35894 if (crtc != 0)
35895 return 0;
35896
35897 - return atomic_read(&dev_priv->vbl_received);
35898 + return atomic_read_unchecked(&dev_priv->vbl_received);
35899 }
35900
35901
35902 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35903 /* VBLANK interrupt */
35904 if (status & MGA_VLINEPEN) {
35905 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35906 - atomic_inc(&dev_priv->vbl_received);
35907 + atomic_inc_unchecked(&dev_priv->vbl_received);
35908 drm_handle_vblank(dev, 0);
35909 handled = 1;
35910 }
35911 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35912 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35913 MGA_WRITE(MGA_PRIMEND, prim_end);
35914
35915 - atomic_inc(&dev_priv->last_fence_retired);
35916 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35917 DRM_WAKEUP(&dev_priv->fence_queue);
35918 handled = 1;
35919 }
35920 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35921 * using fences.
35922 */
35923 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35924 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35925 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35926 - *sequence) <= (1 << 23)));
35927
35928 *sequence = cur_fence;
35929 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35930 index 6aa2137..fe8dc55 100644
35931 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35932 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35933 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35934 struct bit_table {
35935 const char id;
35936 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35937 -};
35938 +} __no_const;
35939
35940 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35941
35942 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35943 index f2b30f8..d0f9a95 100644
35944 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35945 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35946 @@ -92,7 +92,7 @@ struct nouveau_drm {
35947 struct drm_global_reference mem_global_ref;
35948 struct ttm_bo_global_ref bo_global_ref;
35949 struct ttm_bo_device bdev;
35950 - atomic_t validate_sequence;
35951 + atomic_unchecked_t validate_sequence;
35952 int (*move)(struct nouveau_channel *,
35953 struct ttm_buffer_object *,
35954 struct ttm_mem_reg *, struct ttm_mem_reg *);
35955 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35956 index b4b4d0c..b7edc15 100644
35957 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35958 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35959 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35960 int ret, i;
35961 struct nouveau_bo *res_bo = NULL;
35962
35963 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35964 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35965 retry:
35966 if (++trycnt > 100000) {
35967 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35968 @@ -359,7 +359,7 @@ retry:
35969 if (ret) {
35970 validate_fini(op, NULL);
35971 if (unlikely(ret == -EAGAIN)) {
35972 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35973 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35974 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35975 sequence);
35976 if (!ret)
35977 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35978 index 08214bc..9208577 100644
35979 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35980 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35981 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35982 unsigned long arg)
35983 {
35984 unsigned int nr = DRM_IOCTL_NR(cmd);
35985 - drm_ioctl_compat_t *fn = NULL;
35986 + drm_ioctl_compat_t fn = NULL;
35987 int ret;
35988
35989 if (nr < DRM_COMMAND_BASE)
35990 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35991 index 25d3495..d81aaf6 100644
35992 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35993 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35994 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35995 bool can_switch;
35996
35997 spin_lock(&dev->count_lock);
35998 - can_switch = (dev->open_count == 0);
35999 + can_switch = (local_read(&dev->open_count) == 0);
36000 spin_unlock(&dev->count_lock);
36001 return can_switch;
36002 }
36003 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
36004 index 489cb8c..0b8d0d3 100644
36005 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
36006 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
36007 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
36008 }
36009 }
36010
36011 -static struct vm_operations_struct qxl_ttm_vm_ops;
36012 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
36013 static const struct vm_operations_struct *ttm_vm_ops;
36014
36015 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36016 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
36017 return r;
36018 if (unlikely(ttm_vm_ops == NULL)) {
36019 ttm_vm_ops = vma->vm_ops;
36020 + pax_open_kernel();
36021 qxl_ttm_vm_ops = *ttm_vm_ops;
36022 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
36023 + pax_close_kernel();
36024 }
36025 vma->vm_ops = &qxl_ttm_vm_ops;
36026 return 0;
36027 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
36028 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
36029 {
36030 #if defined(CONFIG_DEBUG_FS)
36031 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
36032 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
36033 - unsigned i;
36034 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
36035 + {
36036 + .name = "qxl_mem_mm",
36037 + .show = &qxl_mm_dump_table,
36038 + },
36039 + {
36040 + .name = "qxl_surf_mm",
36041 + .show = &qxl_mm_dump_table,
36042 + }
36043 + };
36044
36045 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
36046 - if (i == 0)
36047 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
36048 - else
36049 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
36050 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
36051 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
36052 - qxl_mem_types_list[i].driver_features = 0;
36053 - if (i == 0)
36054 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36055 - else
36056 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36057 + pax_open_kernel();
36058 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36059 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36060 + pax_close_kernel();
36061
36062 - }
36063 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
36064 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
36065 #else
36066 return 0;
36067 #endif
36068 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36069 index d4660cf..70dbe65 100644
36070 --- a/drivers/gpu/drm/r128/r128_cce.c
36071 +++ b/drivers/gpu/drm/r128/r128_cce.c
36072 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36073
36074 /* GH: Simple idle check.
36075 */
36076 - atomic_set(&dev_priv->idle_count, 0);
36077 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36078
36079 /* We don't support anything other than bus-mastering ring mode,
36080 * but the ring can be in either AGP or PCI space for the ring
36081 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36082 index 930c71b..499aded 100644
36083 --- a/drivers/gpu/drm/r128/r128_drv.h
36084 +++ b/drivers/gpu/drm/r128/r128_drv.h
36085 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36086 int is_pci;
36087 unsigned long cce_buffers_offset;
36088
36089 - atomic_t idle_count;
36090 + atomic_unchecked_t idle_count;
36091
36092 int page_flipping;
36093 int current_page;
36094 u32 crtc_offset;
36095 u32 crtc_offset_cntl;
36096
36097 - atomic_t vbl_received;
36098 + atomic_unchecked_t vbl_received;
36099
36100 u32 color_fmt;
36101 unsigned int front_offset;
36102 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36103 index a954c54..9cc595c 100644
36104 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36105 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36106 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36107 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36108 }
36109
36110 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36111 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36112 [DRM_R128_INIT] = compat_r128_init,
36113 [DRM_R128_DEPTH] = compat_r128_depth,
36114 [DRM_R128_STIPPLE] = compat_r128_stipple,
36115 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36116 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36117 {
36118 unsigned int nr = DRM_IOCTL_NR(cmd);
36119 - drm_ioctl_compat_t *fn = NULL;
36120 int ret;
36121
36122 if (nr < DRM_COMMAND_BASE)
36123 return drm_compat_ioctl(filp, cmd, arg);
36124
36125 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36126 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36127 -
36128 - if (fn != NULL)
36129 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36130 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36131 ret = (*fn) (filp, cmd, arg);
36132 - else
36133 + } else
36134 ret = drm_ioctl(filp, cmd, arg);
36135
36136 return ret;
36137 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36138 index 2ea4f09..d391371 100644
36139 --- a/drivers/gpu/drm/r128/r128_irq.c
36140 +++ b/drivers/gpu/drm/r128/r128_irq.c
36141 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36142 if (crtc != 0)
36143 return 0;
36144
36145 - return atomic_read(&dev_priv->vbl_received);
36146 + return atomic_read_unchecked(&dev_priv->vbl_received);
36147 }
36148
36149 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36150 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36151 /* VBLANK interrupt */
36152 if (status & R128_CRTC_VBLANK_INT) {
36153 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36154 - atomic_inc(&dev_priv->vbl_received);
36155 + atomic_inc_unchecked(&dev_priv->vbl_received);
36156 drm_handle_vblank(dev, 0);
36157 return IRQ_HANDLED;
36158 }
36159 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36160 index 19bb7e6..de7e2a2 100644
36161 --- a/drivers/gpu/drm/r128/r128_state.c
36162 +++ b/drivers/gpu/drm/r128/r128_state.c
36163 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36164
36165 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36166 {
36167 - if (atomic_read(&dev_priv->idle_count) == 0)
36168 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36169 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36170 else
36171 - atomic_set(&dev_priv->idle_count, 0);
36172 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36173 }
36174
36175 #endif
36176 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36177 index 5a82b6b..9e69c73 100644
36178 --- a/drivers/gpu/drm/radeon/mkregtable.c
36179 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36180 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36181 regex_t mask_rex;
36182 regmatch_t match[4];
36183 char buf[1024];
36184 - size_t end;
36185 + long end;
36186 int len;
36187 int done = 0;
36188 int r;
36189 unsigned o;
36190 struct offset *offset;
36191 char last_reg_s[10];
36192 - int last_reg;
36193 + unsigned long last_reg;
36194
36195 if (regcomp
36196 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36197 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36198 index b0dc0b6..a9bfe9c 100644
36199 --- a/drivers/gpu/drm/radeon/radeon_device.c
36200 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36201 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36202 bool can_switch;
36203
36204 spin_lock(&dev->count_lock);
36205 - can_switch = (dev->open_count == 0);
36206 + can_switch = (local_read(&dev->open_count) == 0);
36207 spin_unlock(&dev->count_lock);
36208 return can_switch;
36209 }
36210 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36211 index b369d42..8dd04eb 100644
36212 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36213 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36214 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
36215
36216 /* SW interrupt */
36217 wait_queue_head_t swi_queue;
36218 - atomic_t swi_emitted;
36219 + atomic_unchecked_t swi_emitted;
36220 int vblank_crtc;
36221 uint32_t irq_enable_reg;
36222 uint32_t r500_disp_irq_reg;
36223 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36224 index c180df8..5fd8186 100644
36225 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36226 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36227 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36228 request = compat_alloc_user_space(sizeof(*request));
36229 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36230 || __put_user(req32.param, &request->param)
36231 - || __put_user((void __user *)(unsigned long)req32.value,
36232 + || __put_user((unsigned long)req32.value,
36233 &request->value))
36234 return -EFAULT;
36235
36236 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36237 #define compat_radeon_cp_setparam NULL
36238 #endif /* X86_64 || IA64 */
36239
36240 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36241 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36242 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36243 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36244 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36245 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36246 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36247 {
36248 unsigned int nr = DRM_IOCTL_NR(cmd);
36249 - drm_ioctl_compat_t *fn = NULL;
36250 int ret;
36251
36252 if (nr < DRM_COMMAND_BASE)
36253 return drm_compat_ioctl(filp, cmd, arg);
36254
36255 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36256 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36257 -
36258 - if (fn != NULL)
36259 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36260 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36261 ret = (*fn) (filp, cmd, arg);
36262 - else
36263 + } else
36264 ret = drm_ioctl(filp, cmd, arg);
36265
36266 return ret;
36267 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36268 index 8d68e97..9dcfed8 100644
36269 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36270 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36271 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36272 unsigned int ret;
36273 RING_LOCALS;
36274
36275 - atomic_inc(&dev_priv->swi_emitted);
36276 - ret = atomic_read(&dev_priv->swi_emitted);
36277 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36278 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36279
36280 BEGIN_RING(4);
36281 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36282 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36283 drm_radeon_private_t *dev_priv =
36284 (drm_radeon_private_t *) dev->dev_private;
36285
36286 - atomic_set(&dev_priv->swi_emitted, 0);
36287 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36288 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36289
36290 dev->max_vblank_count = 0x001fffff;
36291 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36292 index 4d20910..6726b6d 100644
36293 --- a/drivers/gpu/drm/radeon/radeon_state.c
36294 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36295 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36296 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36297 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36298
36299 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36300 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36301 sarea_priv->nbox * sizeof(depth_boxes[0])))
36302 return -EFAULT;
36303
36304 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36305 {
36306 drm_radeon_private_t *dev_priv = dev->dev_private;
36307 drm_radeon_getparam_t *param = data;
36308 - int value;
36309 + int value = 0;
36310
36311 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36312
36313 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36314 index 6c0ce89..57a2529 100644
36315 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36316 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36317 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36318 man->size = size >> PAGE_SHIFT;
36319 }
36320
36321 -static struct vm_operations_struct radeon_ttm_vm_ops;
36322 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36323 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36324
36325 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36326 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36327 }
36328 if (unlikely(ttm_vm_ops == NULL)) {
36329 ttm_vm_ops = vma->vm_ops;
36330 + pax_open_kernel();
36331 radeon_ttm_vm_ops = *ttm_vm_ops;
36332 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36333 + pax_close_kernel();
36334 }
36335 vma->vm_ops = &radeon_ttm_vm_ops;
36336 return 0;
36337 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
36338 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36339 {
36340 #if defined(CONFIG_DEBUG_FS)
36341 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
36342 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
36343 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
36344 + {
36345 + .name = "radeon_vram_mm",
36346 + .show = &radeon_mm_dump_table,
36347 + },
36348 + {
36349 + .name = "radeon_gtt_mm",
36350 + .show = &radeon_mm_dump_table,
36351 + },
36352 + {
36353 + .name = "ttm_page_pool",
36354 + .show = &ttm_page_alloc_debugfs,
36355 + },
36356 + {
36357 + .name = "ttm_dma_page_pool",
36358 + .show = &ttm_dma_page_alloc_debugfs,
36359 + },
36360 + };
36361 unsigned i;
36362
36363 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
36364 - if (i == 0)
36365 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36366 - else
36367 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36368 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36369 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36370 - radeon_mem_types_list[i].driver_features = 0;
36371 - if (i == 0)
36372 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36373 - else
36374 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36375 -
36376 - }
36377 - /* Add ttm page pool to debugfs */
36378 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36379 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36380 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36381 - radeon_mem_types_list[i].driver_features = 0;
36382 - radeon_mem_types_list[i++].data = NULL;
36383 + pax_open_kernel();
36384 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36385 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36386 + pax_close_kernel();
36387 #ifdef CONFIG_SWIOTLB
36388 - if (swiotlb_nr_tbl()) {
36389 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36390 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36391 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36392 - radeon_mem_types_list[i].driver_features = 0;
36393 - radeon_mem_types_list[i++].data = NULL;
36394 - }
36395 + if (swiotlb_nr_tbl())
36396 + i++;
36397 #endif
36398 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36399
36400 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36401 index 55880d5..9e95342 100644
36402 --- a/drivers/gpu/drm/radeon/rs690.c
36403 +++ b/drivers/gpu/drm/radeon/rs690.c
36404 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36405 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36406 rdev->pm.sideport_bandwidth.full)
36407 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36408 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36409 + read_delay_latency.full = dfixed_const(800 * 1000);
36410 read_delay_latency.full = dfixed_div(read_delay_latency,
36411 rdev->pm.igp_sideport_mclk);
36412 + a.full = dfixed_const(370);
36413 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36414 } else {
36415 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36416 rdev->pm.k8_bandwidth.full)
36417 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36418 index dbc2def..0a9f710 100644
36419 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36420 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36421 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36422 zone->glob = glob;
36423 glob->zone_kernel = zone;
36424 ret = kobject_init_and_add(
36425 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36426 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36427 if (unlikely(ret != 0)) {
36428 kobject_put(&zone->kobj);
36429 return ret;
36430 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36431 zone->glob = glob;
36432 glob->zone_dma32 = zone;
36433 ret = kobject_init_and_add(
36434 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36435 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36436 if (unlikely(ret != 0)) {
36437 kobject_put(&zone->kobj);
36438 return ret;
36439 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36440 index bd2a3b4..122d9ad 100644
36441 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36442 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36443 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36444 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36445 struct shrink_control *sc)
36446 {
36447 - static atomic_t start_pool = ATOMIC_INIT(0);
36448 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36449 unsigned i;
36450 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36451 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36452 struct ttm_page_pool *pool;
36453 int shrink_pages = sc->nr_to_scan;
36454
36455 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36456 index dc0c065..58a0782 100644
36457 --- a/drivers/gpu/drm/udl/udl_fb.c
36458 +++ b/drivers/gpu/drm/udl/udl_fb.c
36459 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36460 fb_deferred_io_cleanup(info);
36461 kfree(info->fbdefio);
36462 info->fbdefio = NULL;
36463 - info->fbops->fb_mmap = udl_fb_mmap;
36464 }
36465
36466 pr_warn("released /dev/fb%d user=%d count=%d\n",
36467 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36468 index 893a650..6190d3b 100644
36469 --- a/drivers/gpu/drm/via/via_drv.h
36470 +++ b/drivers/gpu/drm/via/via_drv.h
36471 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36472 typedef uint32_t maskarray_t[5];
36473
36474 typedef struct drm_via_irq {
36475 - atomic_t irq_received;
36476 + atomic_unchecked_t irq_received;
36477 uint32_t pending_mask;
36478 uint32_t enable_mask;
36479 wait_queue_head_t irq_queue;
36480 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36481 struct timeval last_vblank;
36482 int last_vblank_valid;
36483 unsigned usec_per_vblank;
36484 - atomic_t vbl_received;
36485 + atomic_unchecked_t vbl_received;
36486 drm_via_state_t hc_state;
36487 char pci_buf[VIA_PCI_BUF_SIZE];
36488 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36489 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36490 index ac98964..5dbf512 100644
36491 --- a/drivers/gpu/drm/via/via_irq.c
36492 +++ b/drivers/gpu/drm/via/via_irq.c
36493 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36494 if (crtc != 0)
36495 return 0;
36496
36497 - return atomic_read(&dev_priv->vbl_received);
36498 + return atomic_read_unchecked(&dev_priv->vbl_received);
36499 }
36500
36501 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36502 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36503
36504 status = VIA_READ(VIA_REG_INTERRUPT);
36505 if (status & VIA_IRQ_VBLANK_PENDING) {
36506 - atomic_inc(&dev_priv->vbl_received);
36507 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36508 + atomic_inc_unchecked(&dev_priv->vbl_received);
36509 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36510 do_gettimeofday(&cur_vblank);
36511 if (dev_priv->last_vblank_valid) {
36512 dev_priv->usec_per_vblank =
36513 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36514 dev_priv->last_vblank = cur_vblank;
36515 dev_priv->last_vblank_valid = 1;
36516 }
36517 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36518 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36519 DRM_DEBUG("US per vblank is: %u\n",
36520 dev_priv->usec_per_vblank);
36521 }
36522 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36523
36524 for (i = 0; i < dev_priv->num_irqs; ++i) {
36525 if (status & cur_irq->pending_mask) {
36526 - atomic_inc(&cur_irq->irq_received);
36527 + atomic_inc_unchecked(&cur_irq->irq_received);
36528 DRM_WAKEUP(&cur_irq->irq_queue);
36529 handled = 1;
36530 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36531 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36532 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36533 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36534 masks[irq][4]));
36535 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36536 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36537 } else {
36538 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36539 (((cur_irq_sequence =
36540 - atomic_read(&cur_irq->irq_received)) -
36541 + atomic_read_unchecked(&cur_irq->irq_received)) -
36542 *sequence) <= (1 << 23)));
36543 }
36544 *sequence = cur_irq_sequence;
36545 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36546 }
36547
36548 for (i = 0; i < dev_priv->num_irqs; ++i) {
36549 - atomic_set(&cur_irq->irq_received, 0);
36550 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36551 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36552 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36553 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36554 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36555 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36556 case VIA_IRQ_RELATIVE:
36557 irqwait->request.sequence +=
36558 - atomic_read(&cur_irq->irq_received);
36559 + atomic_read_unchecked(&cur_irq->irq_received);
36560 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36561 case VIA_IRQ_ABSOLUTE:
36562 break;
36563 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36564 index 13aeda7..4a952d1 100644
36565 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36566 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36567 @@ -290,7 +290,7 @@ struct vmw_private {
36568 * Fencing and IRQs.
36569 */
36570
36571 - atomic_t marker_seq;
36572 + atomic_unchecked_t marker_seq;
36573 wait_queue_head_t fence_queue;
36574 wait_queue_head_t fifo_queue;
36575 int fence_queue_waiters; /* Protected by hw_mutex */
36576 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36577 index 3eb1486..0a47ee9 100644
36578 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36579 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36580 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36581 (unsigned int) min,
36582 (unsigned int) fifo->capabilities);
36583
36584 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36585 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36586 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36587 vmw_marker_queue_init(&fifo->marker_queue);
36588 return vmw_fifo_send_fence(dev_priv, &dummy);
36589 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36590 if (reserveable)
36591 iowrite32(bytes, fifo_mem +
36592 SVGA_FIFO_RESERVED);
36593 - return fifo_mem + (next_cmd >> 2);
36594 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36595 } else {
36596 need_bounce = true;
36597 }
36598 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36599
36600 fm = vmw_fifo_reserve(dev_priv, bytes);
36601 if (unlikely(fm == NULL)) {
36602 - *seqno = atomic_read(&dev_priv->marker_seq);
36603 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36604 ret = -ENOMEM;
36605 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36606 false, 3*HZ);
36607 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36608 }
36609
36610 do {
36611 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36612 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36613 } while (*seqno == 0);
36614
36615 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36616 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36617 index c509d40..3b640c3 100644
36618 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36619 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36620 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36621 int ret;
36622
36623 num_clips = arg->num_clips;
36624 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36625 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36626
36627 if (unlikely(num_clips == 0))
36628 return 0;
36629 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36630 int ret;
36631
36632 num_clips = arg->num_clips;
36633 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36634 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36635
36636 if (unlikely(num_clips == 0))
36637 return 0;
36638 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36639 index 4640adb..e1384ed 100644
36640 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36641 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36642 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36643 * emitted. Then the fence is stale and signaled.
36644 */
36645
36646 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36647 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36648 > VMW_FENCE_WRAP);
36649
36650 return ret;
36651 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36652
36653 if (fifo_idle)
36654 down_read(&fifo_state->rwsem);
36655 - signal_seq = atomic_read(&dev_priv->marker_seq);
36656 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36657 ret = 0;
36658
36659 for (;;) {
36660 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36661 index 8a8725c2..afed796 100644
36662 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36663 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36664 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36665 while (!vmw_lag_lt(queue, us)) {
36666 spin_lock(&queue->lock);
36667 if (list_empty(&queue->head))
36668 - seqno = atomic_read(&dev_priv->marker_seq);
36669 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36670 else {
36671 marker = list_first_entry(&queue->head,
36672 struct vmw_marker, head);
36673 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36674 index 264f550..f92dd8c 100644
36675 --- a/drivers/hid/hid-core.c
36676 +++ b/drivers/hid/hid-core.c
36677 @@ -2269,7 +2269,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36678
36679 int hid_add_device(struct hid_device *hdev)
36680 {
36681 - static atomic_t id = ATOMIC_INIT(0);
36682 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36683 int ret;
36684
36685 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36686 @@ -2303,7 +2303,7 @@ int hid_add_device(struct hid_device *hdev)
36687 /* XXX hack, any other cleaner solution after the driver core
36688 * is converted to allow more than 20 bytes as the device name? */
36689 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36690 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36691 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36692
36693 hid_debug_register(hdev, dev_name(&hdev->dev));
36694 ret = device_add(&hdev->dev);
36695 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36696 index 90124ff..3761764 100644
36697 --- a/drivers/hid/hid-wiimote-debug.c
36698 +++ b/drivers/hid/hid-wiimote-debug.c
36699 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36700 else if (size == 0)
36701 return -EIO;
36702
36703 - if (copy_to_user(u, buf, size))
36704 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36705 return -EFAULT;
36706
36707 *off += size;
36708 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36709 index 0b122f8..b1d8160 100644
36710 --- a/drivers/hv/channel.c
36711 +++ b/drivers/hv/channel.c
36712 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36713 int ret = 0;
36714 int t;
36715
36716 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36717 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36718 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36719 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36720
36721 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36722 if (ret)
36723 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36724 index ae49237..380d4c9 100644
36725 --- a/drivers/hv/hv.c
36726 +++ b/drivers/hv/hv.c
36727 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36728 u64 output_address = (output) ? virt_to_phys(output) : 0;
36729 u32 output_address_hi = output_address >> 32;
36730 u32 output_address_lo = output_address & 0xFFFFFFFF;
36731 - void *hypercall_page = hv_context.hypercall_page;
36732 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36733
36734 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36735 "=a"(hv_status_lo) : "d" (control_hi),
36736 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36737 index 12f2f9e..679603c 100644
36738 --- a/drivers/hv/hyperv_vmbus.h
36739 +++ b/drivers/hv/hyperv_vmbus.h
36740 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36741 struct vmbus_connection {
36742 enum vmbus_connect_state conn_state;
36743
36744 - atomic_t next_gpadl_handle;
36745 + atomic_unchecked_t next_gpadl_handle;
36746
36747 /*
36748 * Represents channel interrupts. Each bit position represents a
36749 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36750 index bf421e0..ce2c897 100644
36751 --- a/drivers/hv/vmbus_drv.c
36752 +++ b/drivers/hv/vmbus_drv.c
36753 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36754 {
36755 int ret = 0;
36756
36757 - static atomic_t device_num = ATOMIC_INIT(0);
36758 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36759
36760 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36761 - atomic_inc_return(&device_num));
36762 + atomic_inc_return_unchecked(&device_num));
36763
36764 child_device_obj->device.bus = &hv_bus;
36765 child_device_obj->device.parent = &hv_acpi_dev->dev;
36766 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36767 index 6351aba..dc4aaf4 100644
36768 --- a/drivers/hwmon/acpi_power_meter.c
36769 +++ b/drivers/hwmon/acpi_power_meter.c
36770 @@ -117,7 +117,7 @@ struct sensor_template {
36771 struct device_attribute *devattr,
36772 const char *buf, size_t count);
36773 int index;
36774 -};
36775 +} __do_const;
36776
36777 /* Averaging interval */
36778 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36779 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36780 struct sensor_template *attrs)
36781 {
36782 struct device *dev = &resource->acpi_dev->dev;
36783 - struct sensor_device_attribute *sensors =
36784 + sensor_device_attribute_no_const *sensors =
36785 &resource->sensors[resource->num_sensors];
36786 int res = 0;
36787
36788 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36789 index 62c2e32..8f2859a 100644
36790 --- a/drivers/hwmon/applesmc.c
36791 +++ b/drivers/hwmon/applesmc.c
36792 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36793 {
36794 struct applesmc_node_group *grp;
36795 struct applesmc_dev_attr *node;
36796 - struct attribute *attr;
36797 + attribute_no_const *attr;
36798 int ret, i;
36799
36800 for (grp = groups; grp->format; grp++) {
36801 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36802 index b25c643..a13460d 100644
36803 --- a/drivers/hwmon/asus_atk0110.c
36804 +++ b/drivers/hwmon/asus_atk0110.c
36805 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36806 struct atk_sensor_data {
36807 struct list_head list;
36808 struct atk_data *data;
36809 - struct device_attribute label_attr;
36810 - struct device_attribute input_attr;
36811 - struct device_attribute limit1_attr;
36812 - struct device_attribute limit2_attr;
36813 + device_attribute_no_const label_attr;
36814 + device_attribute_no_const input_attr;
36815 + device_attribute_no_const limit1_attr;
36816 + device_attribute_no_const limit2_attr;
36817 char label_attr_name[ATTR_NAME_SIZE];
36818 char input_attr_name[ATTR_NAME_SIZE];
36819 char limit1_attr_name[ATTR_NAME_SIZE];
36820 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36821 static struct device_attribute atk_name_attr =
36822 __ATTR(name, 0444, atk_name_show, NULL);
36823
36824 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36825 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36826 sysfs_show_func show)
36827 {
36828 sysfs_attr_init(&attr->attr);
36829 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36830 index 658ce3a..0d0c2f3 100644
36831 --- a/drivers/hwmon/coretemp.c
36832 +++ b/drivers/hwmon/coretemp.c
36833 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36834 return NOTIFY_OK;
36835 }
36836
36837 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36838 +static struct notifier_block coretemp_cpu_notifier = {
36839 .notifier_call = coretemp_cpu_callback,
36840 };
36841
36842 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36843 index 1429f6e..ee03d59 100644
36844 --- a/drivers/hwmon/ibmaem.c
36845 +++ b/drivers/hwmon/ibmaem.c
36846 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
36847 struct aem_rw_sensor_template *rw)
36848 {
36849 struct device *dev = &data->pdev->dev;
36850 - struct sensor_device_attribute *sensors = data->sensors;
36851 + sensor_device_attribute_no_const *sensors = data->sensors;
36852 int err;
36853
36854 /* Set up read-only sensors */
36855 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
36856 index 52b77af..aed1ddf 100644
36857 --- a/drivers/hwmon/iio_hwmon.c
36858 +++ b/drivers/hwmon/iio_hwmon.c
36859 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
36860 {
36861 struct device *dev = &pdev->dev;
36862 struct iio_hwmon_state *st;
36863 - struct sensor_device_attribute *a;
36864 + sensor_device_attribute_no_const *a;
36865 int ret, i;
36866 int in_i = 1, temp_i = 1, curr_i = 1;
36867 enum iio_chan_type type;
36868 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36869 index 9add6092..ee7ba3f 100644
36870 --- a/drivers/hwmon/pmbus/pmbus_core.c
36871 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36872 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36873 return 0;
36874 }
36875
36876 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36877 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36878 const char *name,
36879 umode_t mode,
36880 ssize_t (*show)(struct device *dev,
36881 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36882 dev_attr->store = store;
36883 }
36884
36885 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36886 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36887 const char *name,
36888 umode_t mode,
36889 ssize_t (*show)(struct device *dev,
36890 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36891 u16 reg, u8 mask)
36892 {
36893 struct pmbus_boolean *boolean;
36894 - struct sensor_device_attribute *a;
36895 + sensor_device_attribute_no_const *a;
36896
36897 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36898 if (!boolean)
36899 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36900 bool update, bool readonly)
36901 {
36902 struct pmbus_sensor *sensor;
36903 - struct device_attribute *a;
36904 + device_attribute_no_const *a;
36905
36906 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36907 if (!sensor)
36908 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36909 const char *lstring, int index)
36910 {
36911 struct pmbus_label *label;
36912 - struct device_attribute *a;
36913 + device_attribute_no_const *a;
36914
36915 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36916 if (!label)
36917 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36918 index 2507f90..1645765 100644
36919 --- a/drivers/hwmon/sht15.c
36920 +++ b/drivers/hwmon/sht15.c
36921 @@ -169,7 +169,7 @@ struct sht15_data {
36922 int supply_uv;
36923 bool supply_uv_valid;
36924 struct work_struct update_supply_work;
36925 - atomic_t interrupt_handled;
36926 + atomic_unchecked_t interrupt_handled;
36927 };
36928
36929 /**
36930 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36931 ret = gpio_direction_input(data->pdata->gpio_data);
36932 if (ret)
36933 return ret;
36934 - atomic_set(&data->interrupt_handled, 0);
36935 + atomic_set_unchecked(&data->interrupt_handled, 0);
36936
36937 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36938 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36939 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36940 /* Only relevant if the interrupt hasn't occurred. */
36941 - if (!atomic_read(&data->interrupt_handled))
36942 + if (!atomic_read_unchecked(&data->interrupt_handled))
36943 schedule_work(&data->read_work);
36944 }
36945 ret = wait_event_timeout(data->wait_queue,
36946 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36947
36948 /* First disable the interrupt */
36949 disable_irq_nosync(irq);
36950 - atomic_inc(&data->interrupt_handled);
36951 + atomic_inc_unchecked(&data->interrupt_handled);
36952 /* Then schedule a reading work struct */
36953 if (data->state != SHT15_READING_NOTHING)
36954 schedule_work(&data->read_work);
36955 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36956 * If not, then start the interrupt again - care here as could
36957 * have gone low in meantime so verify it hasn't!
36958 */
36959 - atomic_set(&data->interrupt_handled, 0);
36960 + atomic_set_unchecked(&data->interrupt_handled, 0);
36961 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36962 /* If still not occurred or another handler was scheduled */
36963 if (gpio_get_value(data->pdata->gpio_data)
36964 - || atomic_read(&data->interrupt_handled))
36965 + || atomic_read_unchecked(&data->interrupt_handled))
36966 return;
36967 }
36968
36969 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36970 index 76f157b..9c0db1b 100644
36971 --- a/drivers/hwmon/via-cputemp.c
36972 +++ b/drivers/hwmon/via-cputemp.c
36973 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36974 return NOTIFY_OK;
36975 }
36976
36977 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36978 +static struct notifier_block via_cputemp_cpu_notifier = {
36979 .notifier_call = via_cputemp_cpu_callback,
36980 };
36981
36982 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36983 index 07f01ac..d79ad3d 100644
36984 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36985 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36986 @@ -43,7 +43,7 @@
36987 extern struct i2c_adapter amd756_smbus;
36988
36989 static struct i2c_adapter *s4882_adapter;
36990 -static struct i2c_algorithm *s4882_algo;
36991 +static i2c_algorithm_no_const *s4882_algo;
36992
36993 /* Wrapper access functions for multiplexed SMBus */
36994 static DEFINE_MUTEX(amd756_lock);
36995 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36996 index 2ca268d..c6acbdf 100644
36997 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36998 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36999 @@ -41,7 +41,7 @@
37000 extern struct i2c_adapter *nforce2_smbus;
37001
37002 static struct i2c_adapter *s4985_adapter;
37003 -static struct i2c_algorithm *s4985_algo;
37004 +static i2c_algorithm_no_const *s4985_algo;
37005
37006 /* Wrapper access functions for multiplexed SMBus */
37007 static DEFINE_MUTEX(nforce2_lock);
37008 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
37009 index c3ccdea..5b3dc1a 100644
37010 --- a/drivers/i2c/i2c-dev.c
37011 +++ b/drivers/i2c/i2c-dev.c
37012 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
37013 break;
37014 }
37015
37016 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
37017 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
37018 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
37019 if (IS_ERR(rdwr_pa[i].buf)) {
37020 res = PTR_ERR(rdwr_pa[i].buf);
37021 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
37022 index 2ff6204..218c16e 100644
37023 --- a/drivers/ide/ide-cd.c
37024 +++ b/drivers/ide/ide-cd.c
37025 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
37026 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
37027 if ((unsigned long)buf & alignment
37028 || blk_rq_bytes(rq) & q->dma_pad_mask
37029 - || object_is_on_stack(buf))
37030 + || object_starts_on_stack(buf))
37031 drive->dma = 0;
37032 }
37033 }
37034 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37035 index e145931..08bfc59 100644
37036 --- a/drivers/iio/industrialio-core.c
37037 +++ b/drivers/iio/industrialio-core.c
37038 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37039 }
37040
37041 static
37042 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37043 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37044 const char *postfix,
37045 struct iio_chan_spec const *chan,
37046 ssize_t (*readfunc)(struct device *dev,
37047 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37048 index 784b97c..c9ceadf 100644
37049 --- a/drivers/infiniband/core/cm.c
37050 +++ b/drivers/infiniband/core/cm.c
37051 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37052
37053 struct cm_counter_group {
37054 struct kobject obj;
37055 - atomic_long_t counter[CM_ATTR_COUNT];
37056 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37057 };
37058
37059 struct cm_counter_attribute {
37060 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37061 struct ib_mad_send_buf *msg = NULL;
37062 int ret;
37063
37064 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37065 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37066 counter[CM_REQ_COUNTER]);
37067
37068 /* Quick state check to discard duplicate REQs. */
37069 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37070 if (!cm_id_priv)
37071 return;
37072
37073 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37074 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37075 counter[CM_REP_COUNTER]);
37076 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37077 if (ret)
37078 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
37079 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37080 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37081 spin_unlock_irq(&cm_id_priv->lock);
37082 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37083 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37084 counter[CM_RTU_COUNTER]);
37085 goto out;
37086 }
37087 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
37088 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37089 dreq_msg->local_comm_id);
37090 if (!cm_id_priv) {
37091 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37092 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37093 counter[CM_DREQ_COUNTER]);
37094 cm_issue_drep(work->port, work->mad_recv_wc);
37095 return -EINVAL;
37096 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
37097 case IB_CM_MRA_REP_RCVD:
37098 break;
37099 case IB_CM_TIMEWAIT:
37100 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37101 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37102 counter[CM_DREQ_COUNTER]);
37103 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37104 goto unlock;
37105 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
37106 cm_free_msg(msg);
37107 goto deref;
37108 case IB_CM_DREQ_RCVD:
37109 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37110 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37111 counter[CM_DREQ_COUNTER]);
37112 goto unlock;
37113 default:
37114 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
37115 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37116 cm_id_priv->msg, timeout)) {
37117 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37118 - atomic_long_inc(&work->port->
37119 + atomic_long_inc_unchecked(&work->port->
37120 counter_group[CM_RECV_DUPLICATES].
37121 counter[CM_MRA_COUNTER]);
37122 goto out;
37123 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
37124 break;
37125 case IB_CM_MRA_REQ_RCVD:
37126 case IB_CM_MRA_REP_RCVD:
37127 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37128 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37129 counter[CM_MRA_COUNTER]);
37130 /* fall through */
37131 default:
37132 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
37133 case IB_CM_LAP_IDLE:
37134 break;
37135 case IB_CM_MRA_LAP_SENT:
37136 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37137 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37138 counter[CM_LAP_COUNTER]);
37139 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37140 goto unlock;
37141 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
37142 cm_free_msg(msg);
37143 goto deref;
37144 case IB_CM_LAP_RCVD:
37145 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37146 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37147 counter[CM_LAP_COUNTER]);
37148 goto unlock;
37149 default:
37150 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37151 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37152 if (cur_cm_id_priv) {
37153 spin_unlock_irq(&cm.lock);
37154 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37155 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37156 counter[CM_SIDR_REQ_COUNTER]);
37157 goto out; /* Duplicate message. */
37158 }
37159 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37160 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37161 msg->retries = 1;
37162
37163 - atomic_long_add(1 + msg->retries,
37164 + atomic_long_add_unchecked(1 + msg->retries,
37165 &port->counter_group[CM_XMIT].counter[attr_index]);
37166 if (msg->retries)
37167 - atomic_long_add(msg->retries,
37168 + atomic_long_add_unchecked(msg->retries,
37169 &port->counter_group[CM_XMIT_RETRIES].
37170 counter[attr_index]);
37171
37172 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37173 }
37174
37175 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37176 - atomic_long_inc(&port->counter_group[CM_RECV].
37177 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37178 counter[attr_id - CM_ATTR_ID_OFFSET]);
37179
37180 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37181 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37182 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37183
37184 return sprintf(buf, "%ld\n",
37185 - atomic_long_read(&group->counter[cm_attr->index]));
37186 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37187 }
37188
37189 static const struct sysfs_ops cm_counter_ops = {
37190 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37191 index 9f5ad7c..588cd84 100644
37192 --- a/drivers/infiniband/core/fmr_pool.c
37193 +++ b/drivers/infiniband/core/fmr_pool.c
37194 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37195
37196 struct task_struct *thread;
37197
37198 - atomic_t req_ser;
37199 - atomic_t flush_ser;
37200 + atomic_unchecked_t req_ser;
37201 + atomic_unchecked_t flush_ser;
37202
37203 wait_queue_head_t force_wait;
37204 };
37205 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37206 struct ib_fmr_pool *pool = pool_ptr;
37207
37208 do {
37209 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37210 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37211 ib_fmr_batch_release(pool);
37212
37213 - atomic_inc(&pool->flush_ser);
37214 + atomic_inc_unchecked(&pool->flush_ser);
37215 wake_up_interruptible(&pool->force_wait);
37216
37217 if (pool->flush_function)
37218 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37219 }
37220
37221 set_current_state(TASK_INTERRUPTIBLE);
37222 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37223 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37224 !kthread_should_stop())
37225 schedule();
37226 __set_current_state(TASK_RUNNING);
37227 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37228 pool->dirty_watermark = params->dirty_watermark;
37229 pool->dirty_len = 0;
37230 spin_lock_init(&pool->pool_lock);
37231 - atomic_set(&pool->req_ser, 0);
37232 - atomic_set(&pool->flush_ser, 0);
37233 + atomic_set_unchecked(&pool->req_ser, 0);
37234 + atomic_set_unchecked(&pool->flush_ser, 0);
37235 init_waitqueue_head(&pool->force_wait);
37236
37237 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37238 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37239 }
37240 spin_unlock_irq(&pool->pool_lock);
37241
37242 - serial = atomic_inc_return(&pool->req_ser);
37243 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37244 wake_up_process(pool->thread);
37245
37246 if (wait_event_interruptible(pool->force_wait,
37247 - atomic_read(&pool->flush_ser) - serial >= 0))
37248 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37249 return -EINTR;
37250
37251 return 0;
37252 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37253 } else {
37254 list_add_tail(&fmr->list, &pool->dirty_list);
37255 if (++pool->dirty_len >= pool->dirty_watermark) {
37256 - atomic_inc(&pool->req_ser);
37257 + atomic_inc_unchecked(&pool->req_ser);
37258 wake_up_process(pool->thread);
37259 }
37260 }
37261 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37262 index 4cb8eb2..146bf60 100644
37263 --- a/drivers/infiniband/hw/cxgb4/mem.c
37264 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37265 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37266 int err;
37267 struct fw_ri_tpte tpt;
37268 u32 stag_idx;
37269 - static atomic_t key;
37270 + static atomic_unchecked_t key;
37271
37272 if (c4iw_fatal_error(rdev))
37273 return -EIO;
37274 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37275 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37276 rdev->stats.stag.max = rdev->stats.stag.cur;
37277 mutex_unlock(&rdev->stats.lock);
37278 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37279 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37280 }
37281 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37282 __func__, stag_state, type, pdid, stag_idx);
37283 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37284 index 79b3dbc..96e5fcc 100644
37285 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37286 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37287 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37288 struct ib_atomic_eth *ateth;
37289 struct ipath_ack_entry *e;
37290 u64 vaddr;
37291 - atomic64_t *maddr;
37292 + atomic64_unchecked_t *maddr;
37293 u64 sdata;
37294 u32 rkey;
37295 u8 next;
37296 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37297 IB_ACCESS_REMOTE_ATOMIC)))
37298 goto nack_acc_unlck;
37299 /* Perform atomic OP and save result. */
37300 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37301 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37302 sdata = be64_to_cpu(ateth->swap_data);
37303 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37304 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37305 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37306 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37307 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37308 be64_to_cpu(ateth->compare_data),
37309 sdata);
37310 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37311 index 1f95bba..9530f87 100644
37312 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37313 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37314 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37315 unsigned long flags;
37316 struct ib_wc wc;
37317 u64 sdata;
37318 - atomic64_t *maddr;
37319 + atomic64_unchecked_t *maddr;
37320 enum ib_wc_status send_status;
37321
37322 /*
37323 @@ -382,11 +382,11 @@ again:
37324 IB_ACCESS_REMOTE_ATOMIC)))
37325 goto acc_err;
37326 /* Perform atomic OP and save result. */
37327 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37328 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37329 sdata = wqe->wr.wr.atomic.compare_add;
37330 *(u64 *) sqp->s_sge.sge.vaddr =
37331 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37332 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37333 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37334 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37335 sdata, wqe->wr.wr.atomic.swap);
37336 goto send_comp;
37337 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37338 index 9d3e5c1..d9afe4a 100644
37339 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37340 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37341 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37342 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37343 }
37344
37345 -int mthca_QUERY_FW(struct mthca_dev *dev)
37346 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37347 {
37348 struct mthca_mailbox *mailbox;
37349 u32 *outbox;
37350 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37351 index ed9a989..e0c5871 100644
37352 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37353 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37354 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37355 return key;
37356 }
37357
37358 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37359 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37360 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37361 {
37362 struct mthca_mailbox *mailbox;
37363 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37364 index 4291410..d2ab1fb 100644
37365 --- a/drivers/infiniband/hw/nes/nes.c
37366 +++ b/drivers/infiniband/hw/nes/nes.c
37367 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37368 LIST_HEAD(nes_adapter_list);
37369 static LIST_HEAD(nes_dev_list);
37370
37371 -atomic_t qps_destroyed;
37372 +atomic_unchecked_t qps_destroyed;
37373
37374 static unsigned int ee_flsh_adapter;
37375 static unsigned int sysfs_nonidx_addr;
37376 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37377 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37378 struct nes_adapter *nesadapter = nesdev->nesadapter;
37379
37380 - atomic_inc(&qps_destroyed);
37381 + atomic_inc_unchecked(&qps_destroyed);
37382
37383 /* Free the control structures */
37384
37385 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37386 index 33cc589..3bd6538 100644
37387 --- a/drivers/infiniband/hw/nes/nes.h
37388 +++ b/drivers/infiniband/hw/nes/nes.h
37389 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37390 extern unsigned int wqm_quanta;
37391 extern struct list_head nes_adapter_list;
37392
37393 -extern atomic_t cm_connects;
37394 -extern atomic_t cm_accepts;
37395 -extern atomic_t cm_disconnects;
37396 -extern atomic_t cm_closes;
37397 -extern atomic_t cm_connecteds;
37398 -extern atomic_t cm_connect_reqs;
37399 -extern atomic_t cm_rejects;
37400 -extern atomic_t mod_qp_timouts;
37401 -extern atomic_t qps_created;
37402 -extern atomic_t qps_destroyed;
37403 -extern atomic_t sw_qps_destroyed;
37404 +extern atomic_unchecked_t cm_connects;
37405 +extern atomic_unchecked_t cm_accepts;
37406 +extern atomic_unchecked_t cm_disconnects;
37407 +extern atomic_unchecked_t cm_closes;
37408 +extern atomic_unchecked_t cm_connecteds;
37409 +extern atomic_unchecked_t cm_connect_reqs;
37410 +extern atomic_unchecked_t cm_rejects;
37411 +extern atomic_unchecked_t mod_qp_timouts;
37412 +extern atomic_unchecked_t qps_created;
37413 +extern atomic_unchecked_t qps_destroyed;
37414 +extern atomic_unchecked_t sw_qps_destroyed;
37415 extern u32 mh_detected;
37416 extern u32 mh_pauses_sent;
37417 extern u32 cm_packets_sent;
37418 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37419 extern u32 cm_packets_received;
37420 extern u32 cm_packets_dropped;
37421 extern u32 cm_packets_retrans;
37422 -extern atomic_t cm_listens_created;
37423 -extern atomic_t cm_listens_destroyed;
37424 +extern atomic_unchecked_t cm_listens_created;
37425 +extern atomic_unchecked_t cm_listens_destroyed;
37426 extern u32 cm_backlog_drops;
37427 -extern atomic_t cm_loopbacks;
37428 -extern atomic_t cm_nodes_created;
37429 -extern atomic_t cm_nodes_destroyed;
37430 -extern atomic_t cm_accel_dropped_pkts;
37431 -extern atomic_t cm_resets_recvd;
37432 -extern atomic_t pau_qps_created;
37433 -extern atomic_t pau_qps_destroyed;
37434 +extern atomic_unchecked_t cm_loopbacks;
37435 +extern atomic_unchecked_t cm_nodes_created;
37436 +extern atomic_unchecked_t cm_nodes_destroyed;
37437 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37438 +extern atomic_unchecked_t cm_resets_recvd;
37439 +extern atomic_unchecked_t pau_qps_created;
37440 +extern atomic_unchecked_t pau_qps_destroyed;
37441
37442 extern u32 int_mod_timer_init;
37443 extern u32 int_mod_cq_depth_256;
37444 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37445 index 24b9f1a..00fd004 100644
37446 --- a/drivers/infiniband/hw/nes/nes_cm.c
37447 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37448 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37449 u32 cm_packets_retrans;
37450 u32 cm_packets_created;
37451 u32 cm_packets_received;
37452 -atomic_t cm_listens_created;
37453 -atomic_t cm_listens_destroyed;
37454 +atomic_unchecked_t cm_listens_created;
37455 +atomic_unchecked_t cm_listens_destroyed;
37456 u32 cm_backlog_drops;
37457 -atomic_t cm_loopbacks;
37458 -atomic_t cm_nodes_created;
37459 -atomic_t cm_nodes_destroyed;
37460 -atomic_t cm_accel_dropped_pkts;
37461 -atomic_t cm_resets_recvd;
37462 +atomic_unchecked_t cm_loopbacks;
37463 +atomic_unchecked_t cm_nodes_created;
37464 +atomic_unchecked_t cm_nodes_destroyed;
37465 +atomic_unchecked_t cm_accel_dropped_pkts;
37466 +atomic_unchecked_t cm_resets_recvd;
37467
37468 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37469 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37470 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37471
37472 static struct nes_cm_core *g_cm_core;
37473
37474 -atomic_t cm_connects;
37475 -atomic_t cm_accepts;
37476 -atomic_t cm_disconnects;
37477 -atomic_t cm_closes;
37478 -atomic_t cm_connecteds;
37479 -atomic_t cm_connect_reqs;
37480 -atomic_t cm_rejects;
37481 +atomic_unchecked_t cm_connects;
37482 +atomic_unchecked_t cm_accepts;
37483 +atomic_unchecked_t cm_disconnects;
37484 +atomic_unchecked_t cm_closes;
37485 +atomic_unchecked_t cm_connecteds;
37486 +atomic_unchecked_t cm_connect_reqs;
37487 +atomic_unchecked_t cm_rejects;
37488
37489 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37490 {
37491 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37492 kfree(listener);
37493 listener = NULL;
37494 ret = 0;
37495 - atomic_inc(&cm_listens_destroyed);
37496 + atomic_inc_unchecked(&cm_listens_destroyed);
37497 } else {
37498 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37499 }
37500 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37501 cm_node->rem_mac);
37502
37503 add_hte_node(cm_core, cm_node);
37504 - atomic_inc(&cm_nodes_created);
37505 + atomic_inc_unchecked(&cm_nodes_created);
37506
37507 return cm_node;
37508 }
37509 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37510 }
37511
37512 atomic_dec(&cm_core->node_cnt);
37513 - atomic_inc(&cm_nodes_destroyed);
37514 + atomic_inc_unchecked(&cm_nodes_destroyed);
37515 nesqp = cm_node->nesqp;
37516 if (nesqp) {
37517 nesqp->cm_node = NULL;
37518 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37519
37520 static void drop_packet(struct sk_buff *skb)
37521 {
37522 - atomic_inc(&cm_accel_dropped_pkts);
37523 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37524 dev_kfree_skb_any(skb);
37525 }
37526
37527 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37528 {
37529
37530 int reset = 0; /* whether to send reset in case of err.. */
37531 - atomic_inc(&cm_resets_recvd);
37532 + atomic_inc_unchecked(&cm_resets_recvd);
37533 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37534 " refcnt=%d\n", cm_node, cm_node->state,
37535 atomic_read(&cm_node->ref_count));
37536 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37537 rem_ref_cm_node(cm_node->cm_core, cm_node);
37538 return NULL;
37539 }
37540 - atomic_inc(&cm_loopbacks);
37541 + atomic_inc_unchecked(&cm_loopbacks);
37542 loopbackremotenode->loopbackpartner = cm_node;
37543 loopbackremotenode->tcp_cntxt.rcv_wscale =
37544 NES_CM_DEFAULT_RCV_WND_SCALE;
37545 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37546 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37547 else {
37548 rem_ref_cm_node(cm_core, cm_node);
37549 - atomic_inc(&cm_accel_dropped_pkts);
37550 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37551 dev_kfree_skb_any(skb);
37552 }
37553 break;
37554 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37555
37556 if ((cm_id) && (cm_id->event_handler)) {
37557 if (issue_disconn) {
37558 - atomic_inc(&cm_disconnects);
37559 + atomic_inc_unchecked(&cm_disconnects);
37560 cm_event.event = IW_CM_EVENT_DISCONNECT;
37561 cm_event.status = disconn_status;
37562 cm_event.local_addr = cm_id->local_addr;
37563 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37564 }
37565
37566 if (issue_close) {
37567 - atomic_inc(&cm_closes);
37568 + atomic_inc_unchecked(&cm_closes);
37569 nes_disconnect(nesqp, 1);
37570
37571 cm_id->provider_data = nesqp;
37572 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37573
37574 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37575 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37576 - atomic_inc(&cm_accepts);
37577 + atomic_inc_unchecked(&cm_accepts);
37578
37579 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37580 netdev_refcnt_read(nesvnic->netdev));
37581 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37582 struct nes_cm_core *cm_core;
37583 u8 *start_buff;
37584
37585 - atomic_inc(&cm_rejects);
37586 + atomic_inc_unchecked(&cm_rejects);
37587 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37588 loopback = cm_node->loopbackpartner;
37589 cm_core = cm_node->cm_core;
37590 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37591 ntohl(cm_id->local_addr.sin_addr.s_addr),
37592 ntohs(cm_id->local_addr.sin_port));
37593
37594 - atomic_inc(&cm_connects);
37595 + atomic_inc_unchecked(&cm_connects);
37596 nesqp->active_conn = 1;
37597
37598 /* cache the cm_id in the qp */
37599 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37600 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37601 return err;
37602 }
37603 - atomic_inc(&cm_listens_created);
37604 + atomic_inc_unchecked(&cm_listens_created);
37605 }
37606
37607 cm_id->add_ref(cm_id);
37608 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37609
37610 if (nesqp->destroyed)
37611 return;
37612 - atomic_inc(&cm_connecteds);
37613 + atomic_inc_unchecked(&cm_connecteds);
37614 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37615 " local port 0x%04X. jiffies = %lu.\n",
37616 nesqp->hwqp.qp_id,
37617 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37618
37619 cm_id->add_ref(cm_id);
37620 ret = cm_id->event_handler(cm_id, &cm_event);
37621 - atomic_inc(&cm_closes);
37622 + atomic_inc_unchecked(&cm_closes);
37623 cm_event.event = IW_CM_EVENT_CLOSE;
37624 cm_event.status = 0;
37625 cm_event.provider_data = cm_id->provider_data;
37626 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37627 return;
37628 cm_id = cm_node->cm_id;
37629
37630 - atomic_inc(&cm_connect_reqs);
37631 + atomic_inc_unchecked(&cm_connect_reqs);
37632 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37633 cm_node, cm_id, jiffies);
37634
37635 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37636 return;
37637 cm_id = cm_node->cm_id;
37638
37639 - atomic_inc(&cm_connect_reqs);
37640 + atomic_inc_unchecked(&cm_connect_reqs);
37641 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37642 cm_node, cm_id, jiffies);
37643
37644 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37645 index 4166452..fc952c3 100644
37646 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37647 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37648 @@ -40,8 +40,8 @@
37649 #include "nes.h"
37650 #include "nes_mgt.h"
37651
37652 -atomic_t pau_qps_created;
37653 -atomic_t pau_qps_destroyed;
37654 +atomic_unchecked_t pau_qps_created;
37655 +atomic_unchecked_t pau_qps_destroyed;
37656
37657 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37658 {
37659 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37660 {
37661 struct sk_buff *skb;
37662 unsigned long flags;
37663 - atomic_inc(&pau_qps_destroyed);
37664 + atomic_inc_unchecked(&pau_qps_destroyed);
37665
37666 /* Free packets that have not yet been forwarded */
37667 /* Lock is acquired by skb_dequeue when removing the skb */
37668 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37669 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37670 skb_queue_head_init(&nesqp->pau_list);
37671 spin_lock_init(&nesqp->pau_lock);
37672 - atomic_inc(&pau_qps_created);
37673 + atomic_inc_unchecked(&pau_qps_created);
37674 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37675 }
37676
37677 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37678 index 49eb511..a774366 100644
37679 --- a/drivers/infiniband/hw/nes/nes_nic.c
37680 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37681 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37682 target_stat_values[++index] = mh_detected;
37683 target_stat_values[++index] = mh_pauses_sent;
37684 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37685 - target_stat_values[++index] = atomic_read(&cm_connects);
37686 - target_stat_values[++index] = atomic_read(&cm_accepts);
37687 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37688 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37689 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37690 - target_stat_values[++index] = atomic_read(&cm_rejects);
37691 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37692 - target_stat_values[++index] = atomic_read(&qps_created);
37693 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37694 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37695 - target_stat_values[++index] = atomic_read(&cm_closes);
37696 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37697 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37698 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37699 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37700 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37701 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37702 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37703 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37704 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37705 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37706 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37707 target_stat_values[++index] = cm_packets_sent;
37708 target_stat_values[++index] = cm_packets_bounced;
37709 target_stat_values[++index] = cm_packets_created;
37710 target_stat_values[++index] = cm_packets_received;
37711 target_stat_values[++index] = cm_packets_dropped;
37712 target_stat_values[++index] = cm_packets_retrans;
37713 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37714 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37715 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37716 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37717 target_stat_values[++index] = cm_backlog_drops;
37718 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37719 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37720 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37721 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37722 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37723 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37724 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37725 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37726 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37727 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37728 target_stat_values[++index] = nesadapter->free_4kpbl;
37729 target_stat_values[++index] = nesadapter->free_256pbl;
37730 target_stat_values[++index] = int_mod_timer_init;
37731 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37732 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37733 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37734 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37735 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37736 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37737 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37738 }
37739
37740 /**
37741 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37742 index 8f67fe2..8960859 100644
37743 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37744 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37745 @@ -46,9 +46,9 @@
37746
37747 #include <rdma/ib_umem.h>
37748
37749 -atomic_t mod_qp_timouts;
37750 -atomic_t qps_created;
37751 -atomic_t sw_qps_destroyed;
37752 +atomic_unchecked_t mod_qp_timouts;
37753 +atomic_unchecked_t qps_created;
37754 +atomic_unchecked_t sw_qps_destroyed;
37755
37756 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37757
37758 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37759 if (init_attr->create_flags)
37760 return ERR_PTR(-EINVAL);
37761
37762 - atomic_inc(&qps_created);
37763 + atomic_inc_unchecked(&qps_created);
37764 switch (init_attr->qp_type) {
37765 case IB_QPT_RC:
37766 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37767 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37768 struct iw_cm_event cm_event;
37769 int ret = 0;
37770
37771 - atomic_inc(&sw_qps_destroyed);
37772 + atomic_inc_unchecked(&sw_qps_destroyed);
37773 nesqp->destroyed = 1;
37774
37775 /* Blow away the connection if it exists. */
37776 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37777 index 4d11575..3e890e5 100644
37778 --- a/drivers/infiniband/hw/qib/qib.h
37779 +++ b/drivers/infiniband/hw/qib/qib.h
37780 @@ -51,6 +51,7 @@
37781 #include <linux/completion.h>
37782 #include <linux/kref.h>
37783 #include <linux/sched.h>
37784 +#include <linux/slab.h>
37785
37786 #include "qib_common.h"
37787 #include "qib_verbs.h"
37788 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37789 index da739d9..da1c7f4 100644
37790 --- a/drivers/input/gameport/gameport.c
37791 +++ b/drivers/input/gameport/gameport.c
37792 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37793 */
37794 static void gameport_init_port(struct gameport *gameport)
37795 {
37796 - static atomic_t gameport_no = ATOMIC_INIT(0);
37797 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37798
37799 __module_get(THIS_MODULE);
37800
37801 mutex_init(&gameport->drv_mutex);
37802 device_initialize(&gameport->dev);
37803 dev_set_name(&gameport->dev, "gameport%lu",
37804 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37805 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37806 gameport->dev.bus = &gameport_bus;
37807 gameport->dev.release = gameport_release_port;
37808 if (gameport->parent)
37809 diff --git a/drivers/input/input.c b/drivers/input/input.c
37810 index c044699..174d71a 100644
37811 --- a/drivers/input/input.c
37812 +++ b/drivers/input/input.c
37813 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37814 */
37815 int input_register_device(struct input_dev *dev)
37816 {
37817 - static atomic_t input_no = ATOMIC_INIT(0);
37818 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37819 struct input_devres *devres = NULL;
37820 struct input_handler *handler;
37821 unsigned int packet_size;
37822 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37823 dev->setkeycode = input_default_setkeycode;
37824
37825 dev_set_name(&dev->dev, "input%ld",
37826 - (unsigned long) atomic_inc_return(&input_no) - 1);
37827 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37828
37829 error = device_add(&dev->dev);
37830 if (error)
37831 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37832 index 04c69af..5f92d00 100644
37833 --- a/drivers/input/joystick/sidewinder.c
37834 +++ b/drivers/input/joystick/sidewinder.c
37835 @@ -30,6 +30,7 @@
37836 #include <linux/kernel.h>
37837 #include <linux/module.h>
37838 #include <linux/slab.h>
37839 +#include <linux/sched.h>
37840 #include <linux/init.h>
37841 #include <linux/input.h>
37842 #include <linux/gameport.h>
37843 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37844 index fa061d4..4a6957c 100644
37845 --- a/drivers/input/joystick/xpad.c
37846 +++ b/drivers/input/joystick/xpad.c
37847 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37848
37849 static int xpad_led_probe(struct usb_xpad *xpad)
37850 {
37851 - static atomic_t led_seq = ATOMIC_INIT(0);
37852 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37853 long led_no;
37854 struct xpad_led *led;
37855 struct led_classdev *led_cdev;
37856 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37857 if (!led)
37858 return -ENOMEM;
37859
37860 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37861 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37862
37863 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37864 led->xpad = xpad;
37865 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37866 index 2f0b39d..7370f13 100644
37867 --- a/drivers/input/mouse/psmouse.h
37868 +++ b/drivers/input/mouse/psmouse.h
37869 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37870 ssize_t (*set)(struct psmouse *psmouse, void *data,
37871 const char *buf, size_t count);
37872 bool protect;
37873 -};
37874 +} __do_const;
37875 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37876
37877 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37878 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37879 index 4c842c3..590b0bf 100644
37880 --- a/drivers/input/mousedev.c
37881 +++ b/drivers/input/mousedev.c
37882 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37883
37884 spin_unlock_irq(&client->packet_lock);
37885
37886 - if (copy_to_user(buffer, data, count))
37887 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37888 return -EFAULT;
37889
37890 return count;
37891 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37892 index 25fc597..558bf3b3 100644
37893 --- a/drivers/input/serio/serio.c
37894 +++ b/drivers/input/serio/serio.c
37895 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37896 */
37897 static void serio_init_port(struct serio *serio)
37898 {
37899 - static atomic_t serio_no = ATOMIC_INIT(0);
37900 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37901
37902 __module_get(THIS_MODULE);
37903
37904 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37905 mutex_init(&serio->drv_mutex);
37906 device_initialize(&serio->dev);
37907 dev_set_name(&serio->dev, "serio%ld",
37908 - (long)atomic_inc_return(&serio_no) - 1);
37909 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37910 serio->dev.bus = &serio_bus;
37911 serio->dev.release = serio_release_port;
37912 serio->dev.groups = serio_device_attr_groups;
37913 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37914 index d8f98b1..f62a640 100644
37915 --- a/drivers/iommu/iommu.c
37916 +++ b/drivers/iommu/iommu.c
37917 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
37918 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37919 {
37920 bus_register_notifier(bus, &iommu_bus_nb);
37921 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37922 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37923 }
37924
37925 /**
37926 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37927 index dcfea4e..f4226b2 100644
37928 --- a/drivers/iommu/irq_remapping.c
37929 +++ b/drivers/iommu/irq_remapping.c
37930 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37931 void panic_if_irq_remap(const char *msg)
37932 {
37933 if (irq_remapping_enabled)
37934 - panic(msg);
37935 + panic("%s", msg);
37936 }
37937
37938 static void ir_ack_apic_edge(struct irq_data *data)
37939 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37940
37941 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37942 {
37943 - chip->irq_print_chip = ir_print_prefix;
37944 - chip->irq_ack = ir_ack_apic_edge;
37945 - chip->irq_eoi = ir_ack_apic_level;
37946 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37947 + pax_open_kernel();
37948 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37949 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37950 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37951 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37952 + pax_close_kernel();
37953 }
37954
37955 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37956 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37957 index 19ceaa6..3625818 100644
37958 --- a/drivers/irqchip/irq-gic.c
37959 +++ b/drivers/irqchip/irq-gic.c
37960 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37961 * Supported arch specific GIC irq extension.
37962 * Default make them NULL.
37963 */
37964 -struct irq_chip gic_arch_extn = {
37965 +irq_chip_no_const gic_arch_extn = {
37966 .irq_eoi = NULL,
37967 .irq_mask = NULL,
37968 .irq_unmask = NULL,
37969 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37970 chained_irq_exit(chip, desc);
37971 }
37972
37973 -static struct irq_chip gic_chip = {
37974 +static irq_chip_no_const gic_chip __read_only = {
37975 .name = "GIC",
37976 .irq_mask = gic_mask_irq,
37977 .irq_unmask = gic_unmask_irq,
37978 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37979 index ac6f72b..81150f2 100644
37980 --- a/drivers/isdn/capi/capi.c
37981 +++ b/drivers/isdn/capi/capi.c
37982 @@ -81,8 +81,8 @@ struct capiminor {
37983
37984 struct capi20_appl *ap;
37985 u32 ncci;
37986 - atomic_t datahandle;
37987 - atomic_t msgid;
37988 + atomic_unchecked_t datahandle;
37989 + atomic_unchecked_t msgid;
37990
37991 struct tty_port port;
37992 int ttyinstop;
37993 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37994 capimsg_setu16(s, 2, mp->ap->applid);
37995 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37996 capimsg_setu8 (s, 5, CAPI_RESP);
37997 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37998 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37999 capimsg_setu32(s, 8, mp->ncci);
38000 capimsg_setu16(s, 12, datahandle);
38001 }
38002 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
38003 mp->outbytes -= len;
38004 spin_unlock_bh(&mp->outlock);
38005
38006 - datahandle = atomic_inc_return(&mp->datahandle);
38007 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
38008 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
38009 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38010 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38011 capimsg_setu16(skb->data, 2, mp->ap->applid);
38012 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
38013 capimsg_setu8 (skb->data, 5, CAPI_REQ);
38014 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
38015 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
38016 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
38017 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
38018 capimsg_setu16(skb->data, 16, len); /* Data length */
38019 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
38020 index 600c79b..3752bab 100644
38021 --- a/drivers/isdn/gigaset/interface.c
38022 +++ b/drivers/isdn/gigaset/interface.c
38023 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
38024 }
38025 tty->driver_data = cs;
38026
38027 - ++cs->port.count;
38028 + atomic_inc(&cs->port.count);
38029
38030 - if (cs->port.count == 1) {
38031 + if (atomic_read(&cs->port.count) == 1) {
38032 tty_port_tty_set(&cs->port, tty);
38033 cs->port.low_latency = 1;
38034 }
38035 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38036
38037 if (!cs->connected)
38038 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38039 - else if (!cs->port.count)
38040 + else if (!atomic_read(&cs->port.count))
38041 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38042 - else if (!--cs->port.count)
38043 + else if (!atomic_dec_return(&cs->port.count))
38044 tty_port_tty_set(&cs->port, NULL);
38045
38046 mutex_unlock(&cs->mutex);
38047 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38048 index 4d9b195..455075c 100644
38049 --- a/drivers/isdn/hardware/avm/b1.c
38050 +++ b/drivers/isdn/hardware/avm/b1.c
38051 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38052 }
38053 if (left) {
38054 if (t4file->user) {
38055 - if (copy_from_user(buf, dp, left))
38056 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38057 return -EFAULT;
38058 } else {
38059 memcpy(buf, dp, left);
38060 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38061 }
38062 if (left) {
38063 if (config->user) {
38064 - if (copy_from_user(buf, dp, left))
38065 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38066 return -EFAULT;
38067 } else {
38068 memcpy(buf, dp, left);
38069 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38070 index 3c5f249..5fac4d0 100644
38071 --- a/drivers/isdn/i4l/isdn_tty.c
38072 +++ b/drivers/isdn/i4l/isdn_tty.c
38073 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38074
38075 #ifdef ISDN_DEBUG_MODEM_OPEN
38076 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38077 - port->count);
38078 + atomic_read(&port->count));
38079 #endif
38080 - port->count++;
38081 + atomic_inc(&port->count);
38082 port->tty = tty;
38083 /*
38084 * Start up serial port
38085 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38086 #endif
38087 return;
38088 }
38089 - if ((tty->count == 1) && (port->count != 1)) {
38090 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38091 /*
38092 * Uh, oh. tty->count is 1, which means that the tty
38093 * structure will be freed. Info->count should always
38094 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38095 * serial port won't be shutdown.
38096 */
38097 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38098 - "info->count is %d\n", port->count);
38099 - port->count = 1;
38100 + "info->count is %d\n", atomic_read(&port->count));
38101 + atomic_set(&port->count, 1);
38102 }
38103 - if (--port->count < 0) {
38104 + if (atomic_dec_return(&port->count) < 0) {
38105 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38106 - info->line, port->count);
38107 - port->count = 0;
38108 + info->line, atomic_read(&port->count));
38109 + atomic_set(&port->count, 0);
38110 }
38111 - if (port->count) {
38112 + if (atomic_read(&port->count)) {
38113 #ifdef ISDN_DEBUG_MODEM_OPEN
38114 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38115 #endif
38116 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38117 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38118 return;
38119 isdn_tty_shutdown(info);
38120 - port->count = 0;
38121 + atomic_set(&port->count, 0);
38122 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38123 port->tty = NULL;
38124 wake_up_interruptible(&port->open_wait);
38125 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38126 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38127 modem_info *info = &dev->mdm.info[i];
38128
38129 - if (info->port.count == 0)
38130 + if (atomic_read(&info->port.count) == 0)
38131 continue;
38132 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38133 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38134 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38135 index e74df7c..03a03ba 100644
38136 --- a/drivers/isdn/icn/icn.c
38137 +++ b/drivers/isdn/icn/icn.c
38138 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38139 if (count > len)
38140 count = len;
38141 if (user) {
38142 - if (copy_from_user(msg, buf, count))
38143 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38144 return -EFAULT;
38145 } else
38146 memcpy(msg, buf, count);
38147 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38148 index 6a8405d..0bd1c7e 100644
38149 --- a/drivers/leds/leds-clevo-mail.c
38150 +++ b/drivers/leds/leds-clevo-mail.c
38151 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38152 * detected as working, but in reality it is not) as low as
38153 * possible.
38154 */
38155 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38156 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38157 {
38158 .callback = clevo_mail_led_dmi_callback,
38159 .ident = "Clevo D410J",
38160 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38161 index 64e204e..c6bf189 100644
38162 --- a/drivers/leds/leds-ss4200.c
38163 +++ b/drivers/leds/leds-ss4200.c
38164 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38165 * detected as working, but in reality it is not) as low as
38166 * possible.
38167 */
38168 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38169 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38170 {
38171 .callback = ss4200_led_dmi_callback,
38172 .ident = "Intel SS4200-E",
38173 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38174 index 0bf1e4e..b4bf44e 100644
38175 --- a/drivers/lguest/core.c
38176 +++ b/drivers/lguest/core.c
38177 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
38178 * The end address needs +1 because __get_vm_area allocates an
38179 * extra guard page, so we need space for that.
38180 */
38181 +
38182 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38183 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38184 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
38185 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38186 +#else
38187 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38188 VM_ALLOC, switcher_addr, switcher_addr
38189 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38190 +#endif
38191 +
38192 if (!switcher_vma) {
38193 err = -ENOMEM;
38194 printk("lguest: could not map switcher pages high\n");
38195 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
38196 * Now the Switcher is mapped at the right address, we can't fail!
38197 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38198 */
38199 - memcpy(switcher_vma->addr, start_switcher_text,
38200 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38201 end_switcher_text - start_switcher_text);
38202
38203 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38204 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38205 index 5b9ac32..2ef4f26 100644
38206 --- a/drivers/lguest/page_tables.c
38207 +++ b/drivers/lguest/page_tables.c
38208 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38209 /*:*/
38210
38211 #ifdef CONFIG_X86_PAE
38212 -static void release_pmd(pmd_t *spmd)
38213 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38214 {
38215 /* If the entry's not present, there's nothing to release. */
38216 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38217 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38218 index f0a3347..f6608b2 100644
38219 --- a/drivers/lguest/x86/core.c
38220 +++ b/drivers/lguest/x86/core.c
38221 @@ -59,7 +59,7 @@ static struct {
38222 /* Offset from where switcher.S was compiled to where we've copied it */
38223 static unsigned long switcher_offset(void)
38224 {
38225 - return switcher_addr - (unsigned long)start_switcher_text;
38226 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
38227 }
38228
38229 /* This cpu's struct lguest_pages (after the Switcher text page) */
38230 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38231 * These copies are pretty cheap, so we do them unconditionally: */
38232 /* Save the current Host top-level page directory.
38233 */
38234 +
38235 +#ifdef CONFIG_PAX_PER_CPU_PGD
38236 + pages->state.host_cr3 = read_cr3();
38237 +#else
38238 pages->state.host_cr3 = __pa(current->mm->pgd);
38239 +#endif
38240 +
38241 /*
38242 * Set up the Guest's page tables to see this CPU's pages (and no
38243 * other CPU's pages).
38244 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
38245 * compiled-in switcher code and the high-mapped copy we just made.
38246 */
38247 for (i = 0; i < IDT_ENTRIES; i++)
38248 - default_idt_entries[i] += switcher_offset();
38249 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38250
38251 /*
38252 * Set up the Switcher's per-cpu areas.
38253 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
38254 * it will be undisturbed when we switch. To change %cs and jump we
38255 * need this structure to feed to Intel's "lcall" instruction.
38256 */
38257 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38258 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38259 lguest_entry.segment = LGUEST_CS;
38260
38261 /*
38262 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38263 index 40634b0..4f5855e 100644
38264 --- a/drivers/lguest/x86/switcher_32.S
38265 +++ b/drivers/lguest/x86/switcher_32.S
38266 @@ -87,6 +87,7 @@
38267 #include <asm/page.h>
38268 #include <asm/segment.h>
38269 #include <asm/lguest.h>
38270 +#include <asm/processor-flags.h>
38271
38272 // We mark the start of the code to copy
38273 // It's placed in .text tho it's never run here
38274 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38275 // Changes type when we load it: damn Intel!
38276 // For after we switch over our page tables
38277 // That entry will be read-only: we'd crash.
38278 +
38279 +#ifdef CONFIG_PAX_KERNEXEC
38280 + mov %cr0, %edx
38281 + xor $X86_CR0_WP, %edx
38282 + mov %edx, %cr0
38283 +#endif
38284 +
38285 movl $(GDT_ENTRY_TSS*8), %edx
38286 ltr %dx
38287
38288 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38289 // Let's clear it again for our return.
38290 // The GDT descriptor of the Host
38291 // Points to the table after two "size" bytes
38292 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38293 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38294 // Clear "used" from type field (byte 5, bit 2)
38295 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38296 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38297 +
38298 +#ifdef CONFIG_PAX_KERNEXEC
38299 + mov %cr0, %eax
38300 + xor $X86_CR0_WP, %eax
38301 + mov %eax, %cr0
38302 +#endif
38303
38304 // Once our page table's switched, the Guest is live!
38305 // The Host fades as we run this final step.
38306 @@ -295,13 +309,12 @@ deliver_to_host:
38307 // I consulted gcc, and it gave
38308 // These instructions, which I gladly credit:
38309 leal (%edx,%ebx,8), %eax
38310 - movzwl (%eax),%edx
38311 - movl 4(%eax), %eax
38312 - xorw %ax, %ax
38313 - orl %eax, %edx
38314 + movl 4(%eax), %edx
38315 + movw (%eax), %dx
38316 // Now the address of the handler's in %edx
38317 // We call it now: its "iret" drops us home.
38318 - jmp *%edx
38319 + ljmp $__KERNEL_CS, $1f
38320 +1: jmp *%edx
38321
38322 // Every interrupt can come to us here
38323 // But we must truly tell each apart.
38324 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
38325 index 0003992..854bbce 100644
38326 --- a/drivers/md/bcache/closure.h
38327 +++ b/drivers/md/bcache/closure.h
38328 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
38329 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
38330 struct workqueue_struct *wq)
38331 {
38332 - BUG_ON(object_is_on_stack(cl));
38333 + BUG_ON(object_starts_on_stack(cl));
38334 closure_set_ip(cl);
38335 cl->fn = fn;
38336 cl->wq = wq;
38337 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38338 index 5a2c754..0fa55db 100644
38339 --- a/drivers/md/bitmap.c
38340 +++ b/drivers/md/bitmap.c
38341 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38342 chunk_kb ? "KB" : "B");
38343 if (bitmap->storage.file) {
38344 seq_printf(seq, ", file: ");
38345 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38346 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38347 }
38348
38349 seq_printf(seq, "\n");
38350 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38351 index aa04f02..2a1309e 100644
38352 --- a/drivers/md/dm-ioctl.c
38353 +++ b/drivers/md/dm-ioctl.c
38354 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38355 cmd == DM_LIST_VERSIONS_CMD)
38356 return 0;
38357
38358 - if ((cmd == DM_DEV_CREATE_CMD)) {
38359 + if (cmd == DM_DEV_CREATE_CMD) {
38360 if (!*param->name) {
38361 DMWARN("name not supplied when creating device");
38362 return -EINVAL;
38363 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38364 index 699b5be..eac0a15 100644
38365 --- a/drivers/md/dm-raid1.c
38366 +++ b/drivers/md/dm-raid1.c
38367 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38368
38369 struct mirror {
38370 struct mirror_set *ms;
38371 - atomic_t error_count;
38372 + atomic_unchecked_t error_count;
38373 unsigned long error_type;
38374 struct dm_dev *dev;
38375 sector_t offset;
38376 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38377 struct mirror *m;
38378
38379 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38380 - if (!atomic_read(&m->error_count))
38381 + if (!atomic_read_unchecked(&m->error_count))
38382 return m;
38383
38384 return NULL;
38385 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38386 * simple way to tell if a device has encountered
38387 * errors.
38388 */
38389 - atomic_inc(&m->error_count);
38390 + atomic_inc_unchecked(&m->error_count);
38391
38392 if (test_and_set_bit(error_type, &m->error_type))
38393 return;
38394 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38395 struct mirror *m = get_default_mirror(ms);
38396
38397 do {
38398 - if (likely(!atomic_read(&m->error_count)))
38399 + if (likely(!atomic_read_unchecked(&m->error_count)))
38400 return m;
38401
38402 if (m-- == ms->mirror)
38403 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38404 {
38405 struct mirror *default_mirror = get_default_mirror(m->ms);
38406
38407 - return !atomic_read(&default_mirror->error_count);
38408 + return !atomic_read_unchecked(&default_mirror->error_count);
38409 }
38410
38411 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38412 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38413 */
38414 if (likely(region_in_sync(ms, region, 1)))
38415 m = choose_mirror(ms, bio->bi_sector);
38416 - else if (m && atomic_read(&m->error_count))
38417 + else if (m && atomic_read_unchecked(&m->error_count))
38418 m = NULL;
38419
38420 if (likely(m))
38421 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38422 }
38423
38424 ms->mirror[mirror].ms = ms;
38425 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38426 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38427 ms->mirror[mirror].error_type = 0;
38428 ms->mirror[mirror].offset = offset;
38429
38430 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38431 */
38432 static char device_status_char(struct mirror *m)
38433 {
38434 - if (!atomic_read(&(m->error_count)))
38435 + if (!atomic_read_unchecked(&(m->error_count)))
38436 return 'A';
38437
38438 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38439 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38440 index d907ca6..cfb8384 100644
38441 --- a/drivers/md/dm-stripe.c
38442 +++ b/drivers/md/dm-stripe.c
38443 @@ -20,7 +20,7 @@ struct stripe {
38444 struct dm_dev *dev;
38445 sector_t physical_start;
38446
38447 - atomic_t error_count;
38448 + atomic_unchecked_t error_count;
38449 };
38450
38451 struct stripe_c {
38452 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38453 kfree(sc);
38454 return r;
38455 }
38456 - atomic_set(&(sc->stripe[i].error_count), 0);
38457 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38458 }
38459
38460 ti->private = sc;
38461 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38462 DMEMIT("%d ", sc->stripes);
38463 for (i = 0; i < sc->stripes; i++) {
38464 DMEMIT("%s ", sc->stripe[i].dev->name);
38465 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38466 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38467 'D' : 'A';
38468 }
38469 buffer[i] = '\0';
38470 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38471 */
38472 for (i = 0; i < sc->stripes; i++)
38473 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38474 - atomic_inc(&(sc->stripe[i].error_count));
38475 - if (atomic_read(&(sc->stripe[i].error_count)) <
38476 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38477 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38478 DM_IO_ERROR_THRESHOLD)
38479 schedule_work(&sc->trigger_event);
38480 }
38481 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38482 index 1ff252a..ee384c1 100644
38483 --- a/drivers/md/dm-table.c
38484 +++ b/drivers/md/dm-table.c
38485 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38486 if (!dev_size)
38487 return 0;
38488
38489 - if ((start >= dev_size) || (start + len > dev_size)) {
38490 + if ((start >= dev_size) || (len > dev_size - start)) {
38491 DMWARN("%s: %s too small for target: "
38492 "start=%llu, len=%llu, dev_size=%llu",
38493 dm_device_name(ti->table->md), bdevname(bdev, b),
38494 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38495 index 60bce43..9b997d0 100644
38496 --- a/drivers/md/dm-thin-metadata.c
38497 +++ b/drivers/md/dm-thin-metadata.c
38498 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38499 {
38500 pmd->info.tm = pmd->tm;
38501 pmd->info.levels = 2;
38502 - pmd->info.value_type.context = pmd->data_sm;
38503 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38504 pmd->info.value_type.size = sizeof(__le64);
38505 pmd->info.value_type.inc = data_block_inc;
38506 pmd->info.value_type.dec = data_block_dec;
38507 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38508
38509 pmd->bl_info.tm = pmd->tm;
38510 pmd->bl_info.levels = 1;
38511 - pmd->bl_info.value_type.context = pmd->data_sm;
38512 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38513 pmd->bl_info.value_type.size = sizeof(__le64);
38514 pmd->bl_info.value_type.inc = data_block_inc;
38515 pmd->bl_info.value_type.dec = data_block_dec;
38516 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38517 index d5370a9..8761bbc 100644
38518 --- a/drivers/md/dm.c
38519 +++ b/drivers/md/dm.c
38520 @@ -169,9 +169,9 @@ struct mapped_device {
38521 /*
38522 * Event handling.
38523 */
38524 - atomic_t event_nr;
38525 + atomic_unchecked_t event_nr;
38526 wait_queue_head_t eventq;
38527 - atomic_t uevent_seq;
38528 + atomic_unchecked_t uevent_seq;
38529 struct list_head uevent_list;
38530 spinlock_t uevent_lock; /* Protect access to uevent_list */
38531
38532 @@ -1877,8 +1877,8 @@ static struct mapped_device *alloc_dev(int minor)
38533 rwlock_init(&md->map_lock);
38534 atomic_set(&md->holders, 1);
38535 atomic_set(&md->open_count, 0);
38536 - atomic_set(&md->event_nr, 0);
38537 - atomic_set(&md->uevent_seq, 0);
38538 + atomic_set_unchecked(&md->event_nr, 0);
38539 + atomic_set_unchecked(&md->uevent_seq, 0);
38540 INIT_LIST_HEAD(&md->uevent_list);
38541 spin_lock_init(&md->uevent_lock);
38542
38543 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38544
38545 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38546
38547 - atomic_inc(&md->event_nr);
38548 + atomic_inc_unchecked(&md->event_nr);
38549 wake_up(&md->eventq);
38550 }
38551
38552 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38553
38554 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38555 {
38556 - return atomic_add_return(1, &md->uevent_seq);
38557 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38558 }
38559
38560 uint32_t dm_get_event_nr(struct mapped_device *md)
38561 {
38562 - return atomic_read(&md->event_nr);
38563 + return atomic_read_unchecked(&md->event_nr);
38564 }
38565
38566 int dm_wait_event(struct mapped_device *md, int event_nr)
38567 {
38568 return wait_event_interruptible(md->eventq,
38569 - (event_nr != atomic_read(&md->event_nr)));
38570 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38571 }
38572
38573 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38574 diff --git a/drivers/md/md.c b/drivers/md/md.c
38575 index 9b82377..6b6922d 100644
38576 --- a/drivers/md/md.c
38577 +++ b/drivers/md/md.c
38578 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38579 * start build, activate spare
38580 */
38581 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38582 -static atomic_t md_event_count;
38583 +static atomic_unchecked_t md_event_count;
38584 void md_new_event(struct mddev *mddev)
38585 {
38586 - atomic_inc(&md_event_count);
38587 + atomic_inc_unchecked(&md_event_count);
38588 wake_up(&md_event_waiters);
38589 }
38590 EXPORT_SYMBOL_GPL(md_new_event);
38591 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38592 */
38593 static void md_new_event_inintr(struct mddev *mddev)
38594 {
38595 - atomic_inc(&md_event_count);
38596 + atomic_inc_unchecked(&md_event_count);
38597 wake_up(&md_event_waiters);
38598 }
38599
38600 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38601 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38602 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38603 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38604 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38605 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38606
38607 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38608 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38609 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38610 else
38611 sb->resync_offset = cpu_to_le64(0);
38612
38613 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38614 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38615
38616 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38617 sb->size = cpu_to_le64(mddev->dev_sectors);
38618 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38619 static ssize_t
38620 errors_show(struct md_rdev *rdev, char *page)
38621 {
38622 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38623 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38624 }
38625
38626 static ssize_t
38627 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38628 char *e;
38629 unsigned long n = simple_strtoul(buf, &e, 10);
38630 if (*buf && (*e == 0 || *e == '\n')) {
38631 - atomic_set(&rdev->corrected_errors, n);
38632 + atomic_set_unchecked(&rdev->corrected_errors, n);
38633 return len;
38634 }
38635 return -EINVAL;
38636 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
38637 rdev->sb_loaded = 0;
38638 rdev->bb_page = NULL;
38639 atomic_set(&rdev->nr_pending, 0);
38640 - atomic_set(&rdev->read_errors, 0);
38641 - atomic_set(&rdev->corrected_errors, 0);
38642 + atomic_set_unchecked(&rdev->read_errors, 0);
38643 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38644
38645 INIT_LIST_HEAD(&rdev->same_set);
38646 init_waitqueue_head(&rdev->blocked_wait);
38647 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38648
38649 spin_unlock(&pers_lock);
38650 seq_printf(seq, "\n");
38651 - seq->poll_event = atomic_read(&md_event_count);
38652 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38653 return 0;
38654 }
38655 if (v == (void*)2) {
38656 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38657 return error;
38658
38659 seq = file->private_data;
38660 - seq->poll_event = atomic_read(&md_event_count);
38661 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38662 return error;
38663 }
38664
38665 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38666 /* always allow read */
38667 mask = POLLIN | POLLRDNORM;
38668
38669 - if (seq->poll_event != atomic_read(&md_event_count))
38670 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38671 mask |= POLLERR | POLLPRI;
38672 return mask;
38673 }
38674 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38675 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38676 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38677 (int)part_stat_read(&disk->part0, sectors[1]) -
38678 - atomic_read(&disk->sync_io);
38679 + atomic_read_unchecked(&disk->sync_io);
38680 /* sync IO will cause sync_io to increase before the disk_stats
38681 * as sync_io is counted when a request starts, and
38682 * disk_stats is counted when it completes.
38683 diff --git a/drivers/md/md.h b/drivers/md/md.h
38684 index 653f992b6..6af6c40 100644
38685 --- a/drivers/md/md.h
38686 +++ b/drivers/md/md.h
38687 @@ -94,13 +94,13 @@ struct md_rdev {
38688 * only maintained for arrays that
38689 * support hot removal
38690 */
38691 - atomic_t read_errors; /* number of consecutive read errors that
38692 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38693 * we have tried to ignore.
38694 */
38695 struct timespec last_read_error; /* monotonic time since our
38696 * last read error
38697 */
38698 - atomic_t corrected_errors; /* number of corrected read errors,
38699 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38700 * for reporting to userspace and storing
38701 * in superblock.
38702 */
38703 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38704
38705 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38706 {
38707 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38708 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38709 }
38710
38711 struct md_personality
38712 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38713 index 3e6d115..ffecdeb 100644
38714 --- a/drivers/md/persistent-data/dm-space-map.h
38715 +++ b/drivers/md/persistent-data/dm-space-map.h
38716 @@ -71,6 +71,7 @@ struct dm_space_map {
38717 dm_sm_threshold_fn fn,
38718 void *context);
38719 };
38720 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38721
38722 /*----------------------------------------------------------------*/
38723
38724 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38725 index 6e17f81..140f717 100644
38726 --- a/drivers/md/raid1.c
38727 +++ b/drivers/md/raid1.c
38728 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38729 if (r1_sync_page_io(rdev, sect, s,
38730 bio->bi_io_vec[idx].bv_page,
38731 READ) != 0)
38732 - atomic_add(s, &rdev->corrected_errors);
38733 + atomic_add_unchecked(s, &rdev->corrected_errors);
38734 }
38735 sectors -= s;
38736 sect += s;
38737 @@ -2042,7 +2042,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38738 test_bit(In_sync, &rdev->flags)) {
38739 if (r1_sync_page_io(rdev, sect, s,
38740 conf->tmppage, READ)) {
38741 - atomic_add(s, &rdev->corrected_errors);
38742 + atomic_add_unchecked(s, &rdev->corrected_errors);
38743 printk(KERN_INFO
38744 "md/raid1:%s: read error corrected "
38745 "(%d sectors at %llu on %s)\n",
38746 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38747 index 6ddae25..514caa9 100644
38748 --- a/drivers/md/raid10.c
38749 +++ b/drivers/md/raid10.c
38750 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
38751 /* The write handler will notice the lack of
38752 * R10BIO_Uptodate and record any errors etc
38753 */
38754 - atomic_add(r10_bio->sectors,
38755 + atomic_add_unchecked(r10_bio->sectors,
38756 &conf->mirrors[d].rdev->corrected_errors);
38757
38758 /* for reconstruct, we always reschedule after a read.
38759 @@ -2286,7 +2286,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38760 {
38761 struct timespec cur_time_mon;
38762 unsigned long hours_since_last;
38763 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38764 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38765
38766 ktime_get_ts(&cur_time_mon);
38767
38768 @@ -2308,9 +2308,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38769 * overflowing the shift of read_errors by hours_since_last.
38770 */
38771 if (hours_since_last >= 8 * sizeof(read_errors))
38772 - atomic_set(&rdev->read_errors, 0);
38773 + atomic_set_unchecked(&rdev->read_errors, 0);
38774 else
38775 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38776 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38777 }
38778
38779 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38780 @@ -2364,8 +2364,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38781 return;
38782
38783 check_decay_read_errors(mddev, rdev);
38784 - atomic_inc(&rdev->read_errors);
38785 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38786 + atomic_inc_unchecked(&rdev->read_errors);
38787 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38788 char b[BDEVNAME_SIZE];
38789 bdevname(rdev->bdev, b);
38790
38791 @@ -2373,7 +2373,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38792 "md/raid10:%s: %s: Raid device exceeded "
38793 "read_error threshold [cur %d:max %d]\n",
38794 mdname(mddev), b,
38795 - atomic_read(&rdev->read_errors), max_read_errors);
38796 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38797 printk(KERN_NOTICE
38798 "md/raid10:%s: %s: Failing raid device\n",
38799 mdname(mddev), b);
38800 @@ -2528,7 +2528,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38801 sect +
38802 choose_data_offset(r10_bio, rdev)),
38803 bdevname(rdev->bdev, b));
38804 - atomic_add(s, &rdev->corrected_errors);
38805 + atomic_add_unchecked(s, &rdev->corrected_errors);
38806 }
38807
38808 rdev_dec_pending(rdev, mddev);
38809 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38810 index 05e4a10..48fbe37 100644
38811 --- a/drivers/md/raid5.c
38812 +++ b/drivers/md/raid5.c
38813 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38814 mdname(conf->mddev), STRIPE_SECTORS,
38815 (unsigned long long)s,
38816 bdevname(rdev->bdev, b));
38817 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38818 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38819 clear_bit(R5_ReadError, &sh->dev[i].flags);
38820 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38821 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38822 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38823
38824 - if (atomic_read(&rdev->read_errors))
38825 - atomic_set(&rdev->read_errors, 0);
38826 + if (atomic_read_unchecked(&rdev->read_errors))
38827 + atomic_set_unchecked(&rdev->read_errors, 0);
38828 } else {
38829 const char *bdn = bdevname(rdev->bdev, b);
38830 int retry = 0;
38831 int set_bad = 0;
38832
38833 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38834 - atomic_inc(&rdev->read_errors);
38835 + atomic_inc_unchecked(&rdev->read_errors);
38836 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38837 printk_ratelimited(
38838 KERN_WARNING
38839 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38840 mdname(conf->mddev),
38841 (unsigned long long)s,
38842 bdn);
38843 - } else if (atomic_read(&rdev->read_errors)
38844 + } else if (atomic_read_unchecked(&rdev->read_errors)
38845 > conf->max_nr_stripes)
38846 printk(KERN_WARNING
38847 "md/raid:%s: Too many read errors, failing device %s.\n",
38848 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38849 index 401ef64..836e563 100644
38850 --- a/drivers/media/dvb-core/dvbdev.c
38851 +++ b/drivers/media/dvb-core/dvbdev.c
38852 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38853 const struct dvb_device *template, void *priv, int type)
38854 {
38855 struct dvb_device *dvbdev;
38856 - struct file_operations *dvbdevfops;
38857 + file_operations_no_const *dvbdevfops;
38858 struct device *clsdev;
38859 int minor;
38860 int id;
38861 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38862 index 9b6c3bb..baeb5c7 100644
38863 --- a/drivers/media/dvb-frontends/dib3000.h
38864 +++ b/drivers/media/dvb-frontends/dib3000.h
38865 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38866 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38867 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38868 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38869 -};
38870 +} __no_const;
38871
38872 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38873 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38874 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38875 index c7a9be1..683f6f8 100644
38876 --- a/drivers/media/pci/cx88/cx88-video.c
38877 +++ b/drivers/media/pci/cx88/cx88-video.c
38878 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38879
38880 /* ------------------------------------------------------------------ */
38881
38882 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38883 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38884 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38885 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38886 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38887 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38888
38889 module_param_array(video_nr, int, NULL, 0444);
38890 module_param_array(vbi_nr, int, NULL, 0444);
38891 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38892 index d338b19..aae4f9e 100644
38893 --- a/drivers/media/platform/omap/omap_vout.c
38894 +++ b/drivers/media/platform/omap/omap_vout.c
38895 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38896 OMAP_VIDEO2,
38897 };
38898
38899 -static struct videobuf_queue_ops video_vbq_ops;
38900 /* Variables configurable through module params*/
38901 static u32 video1_numbuffers = 3;
38902 static u32 video2_numbuffers = 3;
38903 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
38904 {
38905 struct videobuf_queue *q;
38906 struct omap_vout_device *vout = NULL;
38907 + static struct videobuf_queue_ops video_vbq_ops = {
38908 + .buf_setup = omap_vout_buffer_setup,
38909 + .buf_prepare = omap_vout_buffer_prepare,
38910 + .buf_release = omap_vout_buffer_release,
38911 + .buf_queue = omap_vout_buffer_queue,
38912 + };
38913
38914 vout = video_drvdata(file);
38915 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38916 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
38917 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38918
38919 q = &vout->vbq;
38920 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38921 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38922 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38923 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38924 spin_lock_init(&vout->vbq_lock);
38925
38926 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38927 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38928 index 04e6490..2df65bf 100644
38929 --- a/drivers/media/platform/s5p-tv/mixer.h
38930 +++ b/drivers/media/platform/s5p-tv/mixer.h
38931 @@ -156,7 +156,7 @@ struct mxr_layer {
38932 /** layer index (unique identifier) */
38933 int idx;
38934 /** callbacks for layer methods */
38935 - struct mxr_layer_ops ops;
38936 + struct mxr_layer_ops *ops;
38937 /** format array */
38938 const struct mxr_format **fmt_array;
38939 /** size of format array */
38940 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38941 index b93a21f..2535195 100644
38942 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38943 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38944 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38945 {
38946 struct mxr_layer *layer;
38947 int ret;
38948 - struct mxr_layer_ops ops = {
38949 + static struct mxr_layer_ops ops = {
38950 .release = mxr_graph_layer_release,
38951 .buffer_set = mxr_graph_buffer_set,
38952 .stream_set = mxr_graph_stream_set,
38953 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38954 index b713403..53cb5ad 100644
38955 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38956 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38957 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38958 layer->update_buf = next;
38959 }
38960
38961 - layer->ops.buffer_set(layer, layer->update_buf);
38962 + layer->ops->buffer_set(layer, layer->update_buf);
38963
38964 if (done && done != layer->shadow_buf)
38965 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38966 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38967 index ef0efdf..8c78eb6 100644
38968 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38969 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38970 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38971 layer->geo.src.height = layer->geo.src.full_height;
38972
38973 mxr_geometry_dump(mdev, &layer->geo);
38974 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38975 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38976 mxr_geometry_dump(mdev, &layer->geo);
38977 }
38978
38979 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38980 layer->geo.dst.full_width = mbus_fmt.width;
38981 layer->geo.dst.full_height = mbus_fmt.height;
38982 layer->geo.dst.field = mbus_fmt.field;
38983 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38984 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38985
38986 mxr_geometry_dump(mdev, &layer->geo);
38987 }
38988 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38989 /* set source size to highest accepted value */
38990 geo->src.full_width = max(geo->dst.full_width, pix->width);
38991 geo->src.full_height = max(geo->dst.full_height, pix->height);
38992 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38993 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38994 mxr_geometry_dump(mdev, &layer->geo);
38995 /* set cropping to total visible screen */
38996 geo->src.width = pix->width;
38997 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38998 geo->src.x_offset = 0;
38999 geo->src.y_offset = 0;
39000 /* assure consistency of geometry */
39001 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39002 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39003 mxr_geometry_dump(mdev, &layer->geo);
39004 /* set full size to lowest possible value */
39005 geo->src.full_width = 0;
39006 geo->src.full_height = 0;
39007 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39008 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39009 mxr_geometry_dump(mdev, &layer->geo);
39010
39011 /* returning results */
39012 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
39013 target->width = s->r.width;
39014 target->height = s->r.height;
39015
39016 - layer->ops.fix_geometry(layer, stage, s->flags);
39017 + layer->ops->fix_geometry(layer, stage, s->flags);
39018
39019 /* retrieve update selection rectangle */
39020 res.left = target->x_offset;
39021 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
39022 mxr_output_get(mdev);
39023
39024 mxr_layer_update_output(layer);
39025 - layer->ops.format_set(layer);
39026 + layer->ops->format_set(layer);
39027 /* enabling layer in hardware */
39028 spin_lock_irqsave(&layer->enq_slock, flags);
39029 layer->state = MXR_LAYER_STREAMING;
39030 spin_unlock_irqrestore(&layer->enq_slock, flags);
39031
39032 - layer->ops.stream_set(layer, MXR_ENABLE);
39033 + layer->ops->stream_set(layer, MXR_ENABLE);
39034 mxr_streamer_get(mdev);
39035
39036 return 0;
39037 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
39038 spin_unlock_irqrestore(&layer->enq_slock, flags);
39039
39040 /* disabling layer in hardware */
39041 - layer->ops.stream_set(layer, MXR_DISABLE);
39042 + layer->ops->stream_set(layer, MXR_DISABLE);
39043 /* remove one streamer */
39044 mxr_streamer_put(mdev);
39045 /* allow changes in output configuration */
39046 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39047
39048 void mxr_layer_release(struct mxr_layer *layer)
39049 {
39050 - if (layer->ops.release)
39051 - layer->ops.release(layer);
39052 + if (layer->ops->release)
39053 + layer->ops->release(layer);
39054 }
39055
39056 void mxr_base_layer_release(struct mxr_layer *layer)
39057 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39058
39059 layer->mdev = mdev;
39060 layer->idx = idx;
39061 - layer->ops = *ops;
39062 + layer->ops = ops;
39063
39064 spin_lock_init(&layer->enq_slock);
39065 INIT_LIST_HEAD(&layer->enq_list);
39066 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39067 index 3d13a63..da31bf1 100644
39068 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39069 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39070 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39071 {
39072 struct mxr_layer *layer;
39073 int ret;
39074 - struct mxr_layer_ops ops = {
39075 + static struct mxr_layer_ops ops = {
39076 .release = mxr_vp_layer_release,
39077 .buffer_set = mxr_vp_buffer_set,
39078 .stream_set = mxr_vp_stream_set,
39079 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39080 index 545c04c..a14bded 100644
39081 --- a/drivers/media/radio/radio-cadet.c
39082 +++ b/drivers/media/radio/radio-cadet.c
39083 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39084 unsigned char readbuf[RDS_BUFFER];
39085 int i = 0;
39086
39087 + if (count > RDS_BUFFER)
39088 + return -EFAULT;
39089 mutex_lock(&dev->lock);
39090 if (dev->rdsstat == 0)
39091 cadet_start_rds(dev);
39092 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39093 while (i < count && dev->rdsin != dev->rdsout)
39094 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39095
39096 - if (i && copy_to_user(data, readbuf, i))
39097 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39098 i = -EFAULT;
39099 unlock:
39100 mutex_unlock(&dev->lock);
39101 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39102 index 3940bb0..fb3952a 100644
39103 --- a/drivers/media/usb/dvb-usb/cxusb.c
39104 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39105 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39106
39107 struct dib0700_adapter_state {
39108 int (*set_param_save) (struct dvb_frontend *);
39109 -};
39110 +} __no_const;
39111
39112 static int dib7070_set_param_override(struct dvb_frontend *fe)
39113 {
39114 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39115 index 6e237b6..dc25556 100644
39116 --- a/drivers/media/usb/dvb-usb/dw2102.c
39117 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39118 @@ -118,7 +118,7 @@ struct su3000_state {
39119
39120 struct s6x0_state {
39121 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39122 -};
39123 +} __no_const;
39124
39125 /* debug */
39126 static int dvb_usb_dw2102_debug;
39127 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39128 index f129551..ecf6514 100644
39129 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39130 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39131 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
39132 __u32 reserved;
39133 };
39134
39135 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39136 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39137 enum v4l2_memory memory)
39138 {
39139 void __user *up_pln;
39140 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39141 return 0;
39142 }
39143
39144 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39145 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39146 enum v4l2_memory memory)
39147 {
39148 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
39149 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
39150 put_user(kp->start_block, &up->start_block) ||
39151 put_user(kp->blocks, &up->blocks) ||
39152 put_user(tmp, &up->edid) ||
39153 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
39154 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
39155 return -EFAULT;
39156 return 0;
39157 }
39158 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39159 index 7658586..1079260 100644
39160 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39161 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39162 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
39163 struct file *file, void *fh, void *p);
39164 } u;
39165 void (*debug)(const void *arg, bool write_only);
39166 -};
39167 +} __do_const;
39168 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39169
39170 /* This control needs a priority check */
39171 #define INFO_FL_PRIO (1 << 0)
39172 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
39173 struct video_device *vfd = video_devdata(file);
39174 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39175 bool write_only = false;
39176 - struct v4l2_ioctl_info default_info;
39177 + v4l2_ioctl_info_no_const default_info;
39178 const struct v4l2_ioctl_info *info;
39179 void *fh = file->private_data;
39180 struct v4l2_fh *vfh = NULL;
39181 @@ -2251,7 +2252,7 @@ done:
39182 }
39183
39184 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39185 - void * __user *user_ptr, void ***kernel_ptr)
39186 + void __user **user_ptr, void ***kernel_ptr)
39187 {
39188 int ret = 0;
39189
39190 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39191 ret = -EINVAL;
39192 break;
39193 }
39194 - *user_ptr = (void __user *)buf->m.planes;
39195 + *user_ptr = (void __force_user *)buf->m.planes;
39196 *kernel_ptr = (void *)&buf->m.planes;
39197 *array_size = sizeof(struct v4l2_plane) * buf->length;
39198 ret = 1;
39199 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39200 ret = -EINVAL;
39201 break;
39202 }
39203 - *user_ptr = (void __user *)ctrls->controls;
39204 + *user_ptr = (void __force_user *)ctrls->controls;
39205 *kernel_ptr = (void *)&ctrls->controls;
39206 *array_size = sizeof(struct v4l2_ext_control)
39207 * ctrls->count;
39208 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39209 index 767ff4d..c69d259 100644
39210 --- a/drivers/message/fusion/mptbase.c
39211 +++ b/drivers/message/fusion/mptbase.c
39212 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39213 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39214 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39215
39216 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39217 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39218 +#else
39219 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39220 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39221 +#endif
39222 +
39223 /*
39224 * Rounding UP to nearest 4-kB boundary here...
39225 */
39226 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39227 ioc->facts.GlobalCredits);
39228
39229 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39230 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39231 + NULL, NULL);
39232 +#else
39233 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39234 +#endif
39235 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39236 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39237 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39238 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39239 index dd239bd..689c4f7 100644
39240 --- a/drivers/message/fusion/mptsas.c
39241 +++ b/drivers/message/fusion/mptsas.c
39242 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39243 return 0;
39244 }
39245
39246 +static inline void
39247 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39248 +{
39249 + if (phy_info->port_details) {
39250 + phy_info->port_details->rphy = rphy;
39251 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39252 + ioc->name, rphy));
39253 + }
39254 +
39255 + if (rphy) {
39256 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39257 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39258 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39259 + ioc->name, rphy, rphy->dev.release));
39260 + }
39261 +}
39262 +
39263 /* no mutex */
39264 static void
39265 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39266 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39267 return NULL;
39268 }
39269
39270 -static inline void
39271 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39272 -{
39273 - if (phy_info->port_details) {
39274 - phy_info->port_details->rphy = rphy;
39275 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39276 - ioc->name, rphy));
39277 - }
39278 -
39279 - if (rphy) {
39280 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39281 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39282 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39283 - ioc->name, rphy, rphy->dev.release));
39284 - }
39285 -}
39286 -
39287 static inline struct sas_port *
39288 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39289 {
39290 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39291 index 727819c..ad74694 100644
39292 --- a/drivers/message/fusion/mptscsih.c
39293 +++ b/drivers/message/fusion/mptscsih.c
39294 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39295
39296 h = shost_priv(SChost);
39297
39298 - if (h) {
39299 - if (h->info_kbuf == NULL)
39300 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39301 - return h->info_kbuf;
39302 - h->info_kbuf[0] = '\0';
39303 + if (!h)
39304 + return NULL;
39305
39306 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39307 - h->info_kbuf[size-1] = '\0';
39308 - }
39309 + if (h->info_kbuf == NULL)
39310 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39311 + return h->info_kbuf;
39312 + h->info_kbuf[0] = '\0';
39313 +
39314 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39315 + h->info_kbuf[size-1] = '\0';
39316
39317 return h->info_kbuf;
39318 }
39319 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39320 index b7d87cd..9890039 100644
39321 --- a/drivers/message/i2o/i2o_proc.c
39322 +++ b/drivers/message/i2o/i2o_proc.c
39323 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39324 "Array Controller Device"
39325 };
39326
39327 -static char *chtostr(char *tmp, u8 *chars, int n)
39328 -{
39329 - tmp[0] = 0;
39330 - return strncat(tmp, (char *)chars, n);
39331 -}
39332 -
39333 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39334 char *group)
39335 {
39336 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39337 } *result;
39338
39339 i2o_exec_execute_ddm_table ddm_table;
39340 - char tmp[28 + 1];
39341
39342 result = kmalloc(sizeof(*result), GFP_KERNEL);
39343 if (!result)
39344 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39345
39346 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39347 seq_printf(seq, "%-#8x", ddm_table.module_id);
39348 - seq_printf(seq, "%-29s",
39349 - chtostr(tmp, ddm_table.module_name_version, 28));
39350 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39351 seq_printf(seq, "%9d ", ddm_table.data_size);
39352 seq_printf(seq, "%8d", ddm_table.code_size);
39353
39354 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39355
39356 i2o_driver_result_table *result;
39357 i2o_driver_store_table *dst;
39358 - char tmp[28 + 1];
39359
39360 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39361 if (result == NULL)
39362 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39363
39364 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39365 seq_printf(seq, "%-#8x", dst->module_id);
39366 - seq_printf(seq, "%-29s",
39367 - chtostr(tmp, dst->module_name_version, 28));
39368 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39369 + seq_printf(seq, "%-.28s", dst->module_name_version);
39370 + seq_printf(seq, "%-.8s", dst->date);
39371 seq_printf(seq, "%8d ", dst->module_size);
39372 seq_printf(seq, "%8d ", dst->mpb_size);
39373 seq_printf(seq, "0x%04x", dst->module_flags);
39374 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39375 // == (allow) 512d bytes (max)
39376 static u16 *work16 = (u16 *) work32;
39377 int token;
39378 - char tmp[16 + 1];
39379
39380 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39381
39382 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39383 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39384 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39385 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39386 - seq_printf(seq, "Vendor info : %s\n",
39387 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39388 - seq_printf(seq, "Product info : %s\n",
39389 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39390 - seq_printf(seq, "Description : %s\n",
39391 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39392 - seq_printf(seq, "Product rev. : %s\n",
39393 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39394 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39395 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39396 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39397 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39398
39399 seq_printf(seq, "Serial number : ");
39400 print_serial_number(seq, (u8 *) (work32 + 16),
39401 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39402 u8 pad[256]; // allow up to 256 byte (max) serial number
39403 } result;
39404
39405 - char tmp[24 + 1];
39406 -
39407 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39408
39409 if (token < 0) {
39410 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39411 }
39412
39413 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39414 - seq_printf(seq, "Module name : %s\n",
39415 - chtostr(tmp, result.module_name, 24));
39416 - seq_printf(seq, "Module revision : %s\n",
39417 - chtostr(tmp, result.module_rev, 8));
39418 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39419 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39420
39421 seq_printf(seq, "Serial number : ");
39422 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39423 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39424 u8 instance_number[4];
39425 } result;
39426
39427 - char tmp[64 + 1];
39428 -
39429 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39430
39431 if (token < 0) {
39432 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39433 return 0;
39434 }
39435
39436 - seq_printf(seq, "Device name : %s\n",
39437 - chtostr(tmp, result.device_name, 64));
39438 - seq_printf(seq, "Service name : %s\n",
39439 - chtostr(tmp, result.service_name, 64));
39440 - seq_printf(seq, "Physical name : %s\n",
39441 - chtostr(tmp, result.physical_location, 64));
39442 - seq_printf(seq, "Instance number : %s\n",
39443 - chtostr(tmp, result.instance_number, 4));
39444 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39445 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39446 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39447 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39448
39449 return 0;
39450 }
39451 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39452 index a8c08f3..155fe3d 100644
39453 --- a/drivers/message/i2o/iop.c
39454 +++ b/drivers/message/i2o/iop.c
39455 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39456
39457 spin_lock_irqsave(&c->context_list_lock, flags);
39458
39459 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39460 - atomic_inc(&c->context_list_counter);
39461 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39462 + atomic_inc_unchecked(&c->context_list_counter);
39463
39464 - entry->context = atomic_read(&c->context_list_counter);
39465 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39466
39467 list_add(&entry->list, &c->context_list);
39468
39469 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39470
39471 #if BITS_PER_LONG == 64
39472 spin_lock_init(&c->context_list_lock);
39473 - atomic_set(&c->context_list_counter, 0);
39474 + atomic_set_unchecked(&c->context_list_counter, 0);
39475 INIT_LIST_HEAD(&c->context_list);
39476 #endif
39477
39478 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39479 index 45ece11..8efa218 100644
39480 --- a/drivers/mfd/janz-cmodio.c
39481 +++ b/drivers/mfd/janz-cmodio.c
39482 @@ -13,6 +13,7 @@
39483
39484 #include <linux/kernel.h>
39485 #include <linux/module.h>
39486 +#include <linux/slab.h>
39487 #include <linux/init.h>
39488 #include <linux/pci.h>
39489 #include <linux/interrupt.h>
39490 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39491 index a5f9888..1c0ed56 100644
39492 --- a/drivers/mfd/twl4030-irq.c
39493 +++ b/drivers/mfd/twl4030-irq.c
39494 @@ -35,6 +35,7 @@
39495 #include <linux/of.h>
39496 #include <linux/irqdomain.h>
39497 #include <linux/i2c/twl.h>
39498 +#include <asm/pgtable.h>
39499
39500 #include "twl-core.h"
39501
39502 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39503 * Install an irq handler for each of the SIH modules;
39504 * clone dummy irq_chip since PIH can't *do* anything
39505 */
39506 - twl4030_irq_chip = dummy_irq_chip;
39507 - twl4030_irq_chip.name = "twl4030";
39508 + pax_open_kernel();
39509 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39510 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39511
39512 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39513 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39514 + pax_close_kernel();
39515
39516 for (i = irq_base; i < irq_end; i++) {
39517 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39518 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39519 index 277a8db..0e0b754 100644
39520 --- a/drivers/mfd/twl6030-irq.c
39521 +++ b/drivers/mfd/twl6030-irq.c
39522 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39523 * install an irq handler for each of the modules;
39524 * clone dummy irq_chip since PIH can't *do* anything
39525 */
39526 - twl6030_irq_chip = dummy_irq_chip;
39527 - twl6030_irq_chip.name = "twl6030";
39528 - twl6030_irq_chip.irq_set_type = NULL;
39529 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39530 + pax_open_kernel();
39531 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39532 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39533 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39534 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39535 + pax_close_kernel();
39536
39537 for (i = irq_base; i < irq_end; i++) {
39538 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39539 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39540 index f32550a..e3e52a2 100644
39541 --- a/drivers/misc/c2port/core.c
39542 +++ b/drivers/misc/c2port/core.c
39543 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39544 mutex_init(&c2dev->mutex);
39545
39546 /* Create binary file */
39547 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39548 + pax_open_kernel();
39549 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39550 + pax_close_kernel();
39551 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39552 if (unlikely(ret))
39553 goto error_device_create_bin_file;
39554 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39555 index 36f5d52..32311c3 100644
39556 --- a/drivers/misc/kgdbts.c
39557 +++ b/drivers/misc/kgdbts.c
39558 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39559 char before[BREAK_INSTR_SIZE];
39560 char after[BREAK_INSTR_SIZE];
39561
39562 - probe_kernel_read(before, (char *)kgdbts_break_test,
39563 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39564 BREAK_INSTR_SIZE);
39565 init_simple_test();
39566 ts.tst = plant_and_detach_test;
39567 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39568 /* Activate test with initial breakpoint */
39569 if (!is_early)
39570 kgdb_breakpoint();
39571 - probe_kernel_read(after, (char *)kgdbts_break_test,
39572 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39573 BREAK_INSTR_SIZE);
39574 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39575 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39576 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39577 index 4cd4a3d..b48cbc7 100644
39578 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39579 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39580 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39581 * the lid is closed. This leads to interrupts as soon as a little move
39582 * is done.
39583 */
39584 - atomic_inc(&lis3->count);
39585 + atomic_inc_unchecked(&lis3->count);
39586
39587 wake_up_interruptible(&lis3->misc_wait);
39588 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39589 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39590 if (lis3->pm_dev)
39591 pm_runtime_get_sync(lis3->pm_dev);
39592
39593 - atomic_set(&lis3->count, 0);
39594 + atomic_set_unchecked(&lis3->count, 0);
39595 return 0;
39596 }
39597
39598 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39599 add_wait_queue(&lis3->misc_wait, &wait);
39600 while (true) {
39601 set_current_state(TASK_INTERRUPTIBLE);
39602 - data = atomic_xchg(&lis3->count, 0);
39603 + data = atomic_xchg_unchecked(&lis3->count, 0);
39604 if (data)
39605 break;
39606
39607 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39608 struct lis3lv02d, miscdev);
39609
39610 poll_wait(file, &lis3->misc_wait, wait);
39611 - if (atomic_read(&lis3->count))
39612 + if (atomic_read_unchecked(&lis3->count))
39613 return POLLIN | POLLRDNORM;
39614 return 0;
39615 }
39616 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39617 index c439c82..1f20f57 100644
39618 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39619 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39620 @@ -297,7 +297,7 @@ struct lis3lv02d {
39621 struct input_polled_dev *idev; /* input device */
39622 struct platform_device *pdev; /* platform device */
39623 struct regulator_bulk_data regulators[2];
39624 - atomic_t count; /* interrupt count after last read */
39625 + atomic_unchecked_t count; /* interrupt count after last read */
39626 union axis_conversion ac; /* hw -> logical axis */
39627 int mapped_btns[3];
39628
39629 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39630 index 2f30bad..c4c13d0 100644
39631 --- a/drivers/misc/sgi-gru/gruhandles.c
39632 +++ b/drivers/misc/sgi-gru/gruhandles.c
39633 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39634 unsigned long nsec;
39635
39636 nsec = CLKS2NSEC(clks);
39637 - atomic_long_inc(&mcs_op_statistics[op].count);
39638 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39639 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39640 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39641 if (mcs_op_statistics[op].max < nsec)
39642 mcs_op_statistics[op].max = nsec;
39643 }
39644 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39645 index 797d796..ae8f01e 100644
39646 --- a/drivers/misc/sgi-gru/gruprocfs.c
39647 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39648 @@ -32,9 +32,9 @@
39649
39650 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39651
39652 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39653 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39654 {
39655 - unsigned long val = atomic_long_read(v);
39656 + unsigned long val = atomic_long_read_unchecked(v);
39657
39658 seq_printf(s, "%16lu %s\n", val, id);
39659 }
39660 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39661
39662 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39663 for (op = 0; op < mcsop_last; op++) {
39664 - count = atomic_long_read(&mcs_op_statistics[op].count);
39665 - total = atomic_long_read(&mcs_op_statistics[op].total);
39666 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39667 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39668 max = mcs_op_statistics[op].max;
39669 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39670 count ? total / count : 0, max);
39671 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39672 index 5c3ce24..4915ccb 100644
39673 --- a/drivers/misc/sgi-gru/grutables.h
39674 +++ b/drivers/misc/sgi-gru/grutables.h
39675 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39676 * GRU statistics.
39677 */
39678 struct gru_stats_s {
39679 - atomic_long_t vdata_alloc;
39680 - atomic_long_t vdata_free;
39681 - atomic_long_t gts_alloc;
39682 - atomic_long_t gts_free;
39683 - atomic_long_t gms_alloc;
39684 - atomic_long_t gms_free;
39685 - atomic_long_t gts_double_allocate;
39686 - atomic_long_t assign_context;
39687 - atomic_long_t assign_context_failed;
39688 - atomic_long_t free_context;
39689 - atomic_long_t load_user_context;
39690 - atomic_long_t load_kernel_context;
39691 - atomic_long_t lock_kernel_context;
39692 - atomic_long_t unlock_kernel_context;
39693 - atomic_long_t steal_user_context;
39694 - atomic_long_t steal_kernel_context;
39695 - atomic_long_t steal_context_failed;
39696 - atomic_long_t nopfn;
39697 - atomic_long_t asid_new;
39698 - atomic_long_t asid_next;
39699 - atomic_long_t asid_wrap;
39700 - atomic_long_t asid_reuse;
39701 - atomic_long_t intr;
39702 - atomic_long_t intr_cbr;
39703 - atomic_long_t intr_tfh;
39704 - atomic_long_t intr_spurious;
39705 - atomic_long_t intr_mm_lock_failed;
39706 - atomic_long_t call_os;
39707 - atomic_long_t call_os_wait_queue;
39708 - atomic_long_t user_flush_tlb;
39709 - atomic_long_t user_unload_context;
39710 - atomic_long_t user_exception;
39711 - atomic_long_t set_context_option;
39712 - atomic_long_t check_context_retarget_intr;
39713 - atomic_long_t check_context_unload;
39714 - atomic_long_t tlb_dropin;
39715 - atomic_long_t tlb_preload_page;
39716 - atomic_long_t tlb_dropin_fail_no_asid;
39717 - atomic_long_t tlb_dropin_fail_upm;
39718 - atomic_long_t tlb_dropin_fail_invalid;
39719 - atomic_long_t tlb_dropin_fail_range_active;
39720 - atomic_long_t tlb_dropin_fail_idle;
39721 - atomic_long_t tlb_dropin_fail_fmm;
39722 - atomic_long_t tlb_dropin_fail_no_exception;
39723 - atomic_long_t tfh_stale_on_fault;
39724 - atomic_long_t mmu_invalidate_range;
39725 - atomic_long_t mmu_invalidate_page;
39726 - atomic_long_t flush_tlb;
39727 - atomic_long_t flush_tlb_gru;
39728 - atomic_long_t flush_tlb_gru_tgh;
39729 - atomic_long_t flush_tlb_gru_zero_asid;
39730 + atomic_long_unchecked_t vdata_alloc;
39731 + atomic_long_unchecked_t vdata_free;
39732 + atomic_long_unchecked_t gts_alloc;
39733 + atomic_long_unchecked_t gts_free;
39734 + atomic_long_unchecked_t gms_alloc;
39735 + atomic_long_unchecked_t gms_free;
39736 + atomic_long_unchecked_t gts_double_allocate;
39737 + atomic_long_unchecked_t assign_context;
39738 + atomic_long_unchecked_t assign_context_failed;
39739 + atomic_long_unchecked_t free_context;
39740 + atomic_long_unchecked_t load_user_context;
39741 + atomic_long_unchecked_t load_kernel_context;
39742 + atomic_long_unchecked_t lock_kernel_context;
39743 + atomic_long_unchecked_t unlock_kernel_context;
39744 + atomic_long_unchecked_t steal_user_context;
39745 + atomic_long_unchecked_t steal_kernel_context;
39746 + atomic_long_unchecked_t steal_context_failed;
39747 + atomic_long_unchecked_t nopfn;
39748 + atomic_long_unchecked_t asid_new;
39749 + atomic_long_unchecked_t asid_next;
39750 + atomic_long_unchecked_t asid_wrap;
39751 + atomic_long_unchecked_t asid_reuse;
39752 + atomic_long_unchecked_t intr;
39753 + atomic_long_unchecked_t intr_cbr;
39754 + atomic_long_unchecked_t intr_tfh;
39755 + atomic_long_unchecked_t intr_spurious;
39756 + atomic_long_unchecked_t intr_mm_lock_failed;
39757 + atomic_long_unchecked_t call_os;
39758 + atomic_long_unchecked_t call_os_wait_queue;
39759 + atomic_long_unchecked_t user_flush_tlb;
39760 + atomic_long_unchecked_t user_unload_context;
39761 + atomic_long_unchecked_t user_exception;
39762 + atomic_long_unchecked_t set_context_option;
39763 + atomic_long_unchecked_t check_context_retarget_intr;
39764 + atomic_long_unchecked_t check_context_unload;
39765 + atomic_long_unchecked_t tlb_dropin;
39766 + atomic_long_unchecked_t tlb_preload_page;
39767 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39768 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39769 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39770 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39771 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39772 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39773 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39774 + atomic_long_unchecked_t tfh_stale_on_fault;
39775 + atomic_long_unchecked_t mmu_invalidate_range;
39776 + atomic_long_unchecked_t mmu_invalidate_page;
39777 + atomic_long_unchecked_t flush_tlb;
39778 + atomic_long_unchecked_t flush_tlb_gru;
39779 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39780 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39781
39782 - atomic_long_t copy_gpa;
39783 - atomic_long_t read_gpa;
39784 + atomic_long_unchecked_t copy_gpa;
39785 + atomic_long_unchecked_t read_gpa;
39786
39787 - atomic_long_t mesq_receive;
39788 - atomic_long_t mesq_receive_none;
39789 - atomic_long_t mesq_send;
39790 - atomic_long_t mesq_send_failed;
39791 - atomic_long_t mesq_noop;
39792 - atomic_long_t mesq_send_unexpected_error;
39793 - atomic_long_t mesq_send_lb_overflow;
39794 - atomic_long_t mesq_send_qlimit_reached;
39795 - atomic_long_t mesq_send_amo_nacked;
39796 - atomic_long_t mesq_send_put_nacked;
39797 - atomic_long_t mesq_page_overflow;
39798 - atomic_long_t mesq_qf_locked;
39799 - atomic_long_t mesq_qf_noop_not_full;
39800 - atomic_long_t mesq_qf_switch_head_failed;
39801 - atomic_long_t mesq_qf_unexpected_error;
39802 - atomic_long_t mesq_noop_unexpected_error;
39803 - atomic_long_t mesq_noop_lb_overflow;
39804 - atomic_long_t mesq_noop_qlimit_reached;
39805 - atomic_long_t mesq_noop_amo_nacked;
39806 - atomic_long_t mesq_noop_put_nacked;
39807 - atomic_long_t mesq_noop_page_overflow;
39808 + atomic_long_unchecked_t mesq_receive;
39809 + atomic_long_unchecked_t mesq_receive_none;
39810 + atomic_long_unchecked_t mesq_send;
39811 + atomic_long_unchecked_t mesq_send_failed;
39812 + atomic_long_unchecked_t mesq_noop;
39813 + atomic_long_unchecked_t mesq_send_unexpected_error;
39814 + atomic_long_unchecked_t mesq_send_lb_overflow;
39815 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39816 + atomic_long_unchecked_t mesq_send_amo_nacked;
39817 + atomic_long_unchecked_t mesq_send_put_nacked;
39818 + atomic_long_unchecked_t mesq_page_overflow;
39819 + atomic_long_unchecked_t mesq_qf_locked;
39820 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39821 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39822 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39823 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39824 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39825 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39826 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39827 + atomic_long_unchecked_t mesq_noop_put_nacked;
39828 + atomic_long_unchecked_t mesq_noop_page_overflow;
39829
39830 };
39831
39832 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39833 tghop_invalidate, mcsop_last};
39834
39835 struct mcs_op_statistic {
39836 - atomic_long_t count;
39837 - atomic_long_t total;
39838 + atomic_long_unchecked_t count;
39839 + atomic_long_unchecked_t total;
39840 unsigned long max;
39841 };
39842
39843 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39844
39845 #define STAT(id) do { \
39846 if (gru_options & OPT_STATS) \
39847 - atomic_long_inc(&gru_stats.id); \
39848 + atomic_long_inc_unchecked(&gru_stats.id); \
39849 } while (0)
39850
39851 #ifdef CONFIG_SGI_GRU_DEBUG
39852 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39853 index c862cd4..0d176fe 100644
39854 --- a/drivers/misc/sgi-xp/xp.h
39855 +++ b/drivers/misc/sgi-xp/xp.h
39856 @@ -288,7 +288,7 @@ struct xpc_interface {
39857 xpc_notify_func, void *);
39858 void (*received) (short, int, void *);
39859 enum xp_retval (*partid_to_nasids) (short, void *);
39860 -};
39861 +} __no_const;
39862
39863 extern struct xpc_interface xpc_interface;
39864
39865 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39866 index b94d5f7..7f494c5 100644
39867 --- a/drivers/misc/sgi-xp/xpc.h
39868 +++ b/drivers/misc/sgi-xp/xpc.h
39869 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39870 void (*received_payload) (struct xpc_channel *, void *);
39871 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39872 };
39873 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39874
39875 /* struct xpc_partition act_state values (for XPC HB) */
39876
39877 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39878 /* found in xpc_main.c */
39879 extern struct device *xpc_part;
39880 extern struct device *xpc_chan;
39881 -extern struct xpc_arch_operations xpc_arch_ops;
39882 +extern xpc_arch_operations_no_const xpc_arch_ops;
39883 extern int xpc_disengage_timelimit;
39884 extern int xpc_disengage_timedout;
39885 extern int xpc_activate_IRQ_rcvd;
39886 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39887 index d971817..33bdca5 100644
39888 --- a/drivers/misc/sgi-xp/xpc_main.c
39889 +++ b/drivers/misc/sgi-xp/xpc_main.c
39890 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39891 .notifier_call = xpc_system_die,
39892 };
39893
39894 -struct xpc_arch_operations xpc_arch_ops;
39895 +xpc_arch_operations_no_const xpc_arch_ops;
39896
39897 /*
39898 * Timer function to enforce the timelimit on the partition disengage.
39899 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39900
39901 if (((die_args->trapnr == X86_TRAP_MF) ||
39902 (die_args->trapnr == X86_TRAP_XF)) &&
39903 - !user_mode_vm(die_args->regs))
39904 + !user_mode(die_args->regs))
39905 xpc_die_deactivate();
39906
39907 break;
39908 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39909 index 49f04bc..65660c2 100644
39910 --- a/drivers/mmc/core/mmc_ops.c
39911 +++ b/drivers/mmc/core/mmc_ops.c
39912 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39913 void *data_buf;
39914 int is_on_stack;
39915
39916 - is_on_stack = object_is_on_stack(buf);
39917 + is_on_stack = object_starts_on_stack(buf);
39918 if (is_on_stack) {
39919 /*
39920 * dma onto stack is unsafe/nonportable, but callers to this
39921 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39922 index 0b74189..818358f 100644
39923 --- a/drivers/mmc/host/dw_mmc.h
39924 +++ b/drivers/mmc/host/dw_mmc.h
39925 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
39926 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
39927 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
39928 int (*parse_dt)(struct dw_mci *host);
39929 -};
39930 +} __do_const;
39931 #endif /* _DW_MMC_H_ */
39932 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39933 index c6f6246..60760a8 100644
39934 --- a/drivers/mmc/host/sdhci-s3c.c
39935 +++ b/drivers/mmc/host/sdhci-s3c.c
39936 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39937 * we can use overriding functions instead of default.
39938 */
39939 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39940 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39941 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39942 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39943 + pax_open_kernel();
39944 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39945 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39946 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39947 + pax_close_kernel();
39948 }
39949
39950 /* It supports additional host capabilities if needed */
39951 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39952 index 0c8bb6b..6f35deb 100644
39953 --- a/drivers/mtd/nand/denali.c
39954 +++ b/drivers/mtd/nand/denali.c
39955 @@ -24,6 +24,7 @@
39956 #include <linux/slab.h>
39957 #include <linux/mtd/mtd.h>
39958 #include <linux/module.h>
39959 +#include <linux/slab.h>
39960
39961 #include "denali.h"
39962
39963 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39964 index 51b9d6a..52af9a7 100644
39965 --- a/drivers/mtd/nftlmount.c
39966 +++ b/drivers/mtd/nftlmount.c
39967 @@ -24,6 +24,7 @@
39968 #include <asm/errno.h>
39969 #include <linux/delay.h>
39970 #include <linux/slab.h>
39971 +#include <linux/sched.h>
39972 #include <linux/mtd/mtd.h>
39973 #include <linux/mtd/nand.h>
39974 #include <linux/mtd/nftl.h>
39975 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39976 index f9d5615..99dd95f 100644
39977 --- a/drivers/mtd/sm_ftl.c
39978 +++ b/drivers/mtd/sm_ftl.c
39979 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39980 #define SM_CIS_VENDOR_OFFSET 0x59
39981 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39982 {
39983 - struct attribute_group *attr_group;
39984 + attribute_group_no_const *attr_group;
39985 struct attribute **attributes;
39986 struct sm_sysfs_attribute *vendor_attribute;
39987
39988 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39989 index f975696..4597e21 100644
39990 --- a/drivers/net/bonding/bond_main.c
39991 +++ b/drivers/net/bonding/bond_main.c
39992 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
39993 return tx_queues;
39994 }
39995
39996 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39997 +static struct rtnl_link_ops bond_link_ops = {
39998 .kind = "bond",
39999 .priv_size = sizeof(struct bonding),
40000 .setup = bond_setup,
40001 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
40002
40003 bond_destroy_debugfs();
40004
40005 - rtnl_link_unregister(&bond_link_ops);
40006 unregister_pernet_subsys(&bond_net_ops);
40007 + rtnl_link_unregister(&bond_link_ops);
40008
40009 #ifdef CONFIG_NET_POLL_CONTROLLER
40010 /*
40011 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
40012 index e1d2643..7f4133b 100644
40013 --- a/drivers/net/ethernet/8390/ax88796.c
40014 +++ b/drivers/net/ethernet/8390/ax88796.c
40015 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
40016 if (ax->plat->reg_offsets)
40017 ei_local->reg_offset = ax->plat->reg_offsets;
40018 else {
40019 + resource_size_t _mem_size = mem_size;
40020 + do_div(_mem_size, 0x18);
40021 ei_local->reg_offset = ax->reg_offsets;
40022 for (ret = 0; ret < 0x18; ret++)
40023 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
40024 + ax->reg_offsets[ret] = _mem_size * ret;
40025 }
40026
40027 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
40028 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40029 index 151675d..0139a9d 100644
40030 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40031 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40032 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40033 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40034 {
40035 /* RX_MODE controlling object */
40036 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40037 + bnx2x_init_rx_mode_obj(bp);
40038
40039 /* multicast configuration controlling object */
40040 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40041 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40042 index ce1a916..10b52b0 100644
40043 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40044 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40045 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
40046 struct bnx2x *bp = netdev_priv(dev);
40047
40048 /* Use the ethtool_dump "flag" field as the dump preset index */
40049 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
40050 + return -EINVAL;
40051 +
40052 bp->dump_preset_idx = val->flag;
40053 return 0;
40054 }
40055 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
40056 struct bnx2x *bp = netdev_priv(dev);
40057 struct dump_header dump_hdr = {0};
40058
40059 - memset(p, 0, dump->len);
40060 -
40061 /* Disable parity attentions as long as following dump may
40062 * cause false alarms by reading never written registers. We
40063 * will re-enable parity attentions right after the dump.
40064 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40065 index b4c9dea..2a9927f 100644
40066 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40067 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40068 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
40069 bp->min_msix_vec_cnt = 2;
40070 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
40071
40072 + bp->dump_preset_idx = 1;
40073 +
40074 return rc;
40075 }
40076
40077 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40078 index 32a9609..0b1c53a 100644
40079 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40080 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40081 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40082 return rc;
40083 }
40084
40085 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40086 - struct bnx2x_rx_mode_obj *o)
40087 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40088 {
40089 if (CHIP_IS_E1x(bp)) {
40090 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40091 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40092 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40093 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40094 } else {
40095 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40096 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40097 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40098 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40099 }
40100 }
40101
40102 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40103 index 43c00bc..dd1d03d 100644
40104 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40105 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40106 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40107
40108 /********************* RX MODE ****************/
40109
40110 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40111 - struct bnx2x_rx_mode_obj *o);
40112 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40113
40114 /**
40115 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40116 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40117 index ff6e30e..87e8452 100644
40118 --- a/drivers/net/ethernet/broadcom/tg3.h
40119 +++ b/drivers/net/ethernet/broadcom/tg3.h
40120 @@ -147,6 +147,7 @@
40121 #define CHIPREV_ID_5750_A0 0x4000
40122 #define CHIPREV_ID_5750_A1 0x4001
40123 #define CHIPREV_ID_5750_A3 0x4003
40124 +#define CHIPREV_ID_5750_C1 0x4201
40125 #define CHIPREV_ID_5750_C2 0x4202
40126 #define CHIPREV_ID_5752_A0_HW 0x5000
40127 #define CHIPREV_ID_5752_A0 0x6000
40128 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40129 index 71497e8..b650951 100644
40130 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40131 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40132 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
40133 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
40134 t3_read_reg(adapter, A_PCIE_PEX_ERR));
40135
40136 + rtnl_lock();
40137 t3_resume_ports(adapter);
40138 + rtnl_unlock();
40139 }
40140
40141 static const struct pci_error_handlers t3_err_handler = {
40142 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40143 index 8cffcdf..aadf043 100644
40144 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40145 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40146 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40147 */
40148 struct l2t_skb_cb {
40149 arp_failure_handler_func arp_failure_handler;
40150 -};
40151 +} __no_const;
40152
40153 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40154
40155 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40156 index 4c83003..2a2a5b9 100644
40157 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40158 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40159 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40160 for (i=0; i<ETH_ALEN; i++) {
40161 tmp.addr[i] = dev->dev_addr[i];
40162 }
40163 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40164 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40165 break;
40166
40167 case DE4X5_SET_HWADDR: /* Set the hardware address */
40168 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40169 spin_lock_irqsave(&lp->lock, flags);
40170 memcpy(&statbuf, &lp->pktStats, ioc->len);
40171 spin_unlock_irqrestore(&lp->lock, flags);
40172 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40173 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40174 return -EFAULT;
40175 break;
40176 }
40177 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40178 index a0b4be5..d8cb082 100644
40179 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40180 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40181 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40182
40183 if (wrapped)
40184 newacc += 65536;
40185 - ACCESS_ONCE(*acc) = newacc;
40186 + ACCESS_ONCE_RW(*acc) = newacc;
40187 }
40188
40189 void populate_erx_stats(struct be_adapter *adapter,
40190 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40191 index 21b85fb..b49e5fc 100644
40192 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40193 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40194 @@ -31,6 +31,8 @@
40195 #include <linux/netdevice.h>
40196 #include <linux/phy.h>
40197 #include <linux/platform_device.h>
40198 +#include <linux/interrupt.h>
40199 +#include <linux/irqreturn.h>
40200 #include <net/ip.h>
40201
40202 #include "ftgmac100.h"
40203 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40204 index a6eda8d..935d273 100644
40205 --- a/drivers/net/ethernet/faraday/ftmac100.c
40206 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40207 @@ -31,6 +31,8 @@
40208 #include <linux/module.h>
40209 #include <linux/netdevice.h>
40210 #include <linux/platform_device.h>
40211 +#include <linux/interrupt.h>
40212 +#include <linux/irqreturn.h>
40213
40214 #include "ftmac100.h"
40215
40216 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40217 index 331987d..3be1135 100644
40218 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40219 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40220 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40221 }
40222
40223 /* update the base incval used to calculate frequency adjustment */
40224 - ACCESS_ONCE(adapter->base_incval) = incval;
40225 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40226 smp_mb();
40227
40228 /* need lock to prevent incorrect read while modifying cyclecounter */
40229 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40230 index fbe5363..266b4e3 100644
40231 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40232 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40233 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40234 struct __vxge_hw_fifo *fifo;
40235 struct vxge_hw_fifo_config *config;
40236 u32 txdl_size, txdl_per_memblock;
40237 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40238 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40239 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40240 + };
40241 +
40242 struct __vxge_hw_virtualpath *vpath;
40243
40244 if ((vp == NULL) || (attr == NULL)) {
40245 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40246 goto exit;
40247 }
40248
40249 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40250 -
40251 fifo->mempool =
40252 __vxge_hw_mempool_create(vpath->hldev,
40253 fifo->config->memblock_size,
40254 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40255 index 5e7fb1d..f8d1810 100644
40256 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40257 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40258 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40259 op_mode = QLC_83XX_DEFAULT_OPMODE;
40260
40261 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40262 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40263 + pax_open_kernel();
40264 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40265 + pax_close_kernel();
40266 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40267 } else {
40268 return -EIO;
40269 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40270 index b0c3de9..fc5857e 100644
40271 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40272 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40273 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40274 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40275 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40276 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40277 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40278 + pax_open_kernel();
40279 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40280 + pax_close_kernel();
40281 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40282 ahw->op_mode = QLCNIC_PRIV_FUNC;
40283 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40284 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40285 + pax_open_kernel();
40286 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40287 + pax_close_kernel();
40288 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40289 ahw->op_mode = QLCNIC_MGMT_FUNC;
40290 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40291 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40292 + pax_open_kernel();
40293 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40294 + pax_close_kernel();
40295 } else {
40296 return -EIO;
40297 }
40298 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40299 index 393f961..d343034 100644
40300 --- a/drivers/net/ethernet/realtek/r8169.c
40301 +++ b/drivers/net/ethernet/realtek/r8169.c
40302 @@ -753,22 +753,22 @@ struct rtl8169_private {
40303 struct mdio_ops {
40304 void (*write)(struct rtl8169_private *, int, int);
40305 int (*read)(struct rtl8169_private *, int);
40306 - } mdio_ops;
40307 + } __no_const mdio_ops;
40308
40309 struct pll_power_ops {
40310 void (*down)(struct rtl8169_private *);
40311 void (*up)(struct rtl8169_private *);
40312 - } pll_power_ops;
40313 + } __no_const pll_power_ops;
40314
40315 struct jumbo_ops {
40316 void (*enable)(struct rtl8169_private *);
40317 void (*disable)(struct rtl8169_private *);
40318 - } jumbo_ops;
40319 + } __no_const jumbo_ops;
40320
40321 struct csi_ops {
40322 void (*write)(struct rtl8169_private *, int, int);
40323 u32 (*read)(struct rtl8169_private *, int);
40324 - } csi_ops;
40325 + } __no_const csi_ops;
40326
40327 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40328 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40329 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40330 index 9a95abf..36df7f9 100644
40331 --- a/drivers/net/ethernet/sfc/ptp.c
40332 +++ b/drivers/net/ethernet/sfc/ptp.c
40333 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40334 (u32)((u64)ptp->start.dma_addr >> 32));
40335
40336 /* Clear flag that signals MC ready */
40337 - ACCESS_ONCE(*start) = 0;
40338 + ACCESS_ONCE_RW(*start) = 0;
40339 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40340 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40341
40342 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40343 index 50617c5..b13724c 100644
40344 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40345 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40346 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40347
40348 writel(value, ioaddr + MMC_CNTRL);
40349
40350 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40351 - MMC_CNTRL, value);
40352 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40353 +// MMC_CNTRL, value);
40354 }
40355
40356 /* To mask all all interrupts.*/
40357 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40358 index e6fe0d8..2b7d752 100644
40359 --- a/drivers/net/hyperv/hyperv_net.h
40360 +++ b/drivers/net/hyperv/hyperv_net.h
40361 @@ -101,7 +101,7 @@ struct rndis_device {
40362
40363 enum rndis_device_state state;
40364 bool link_state;
40365 - atomic_t new_req_id;
40366 + atomic_unchecked_t new_req_id;
40367
40368 spinlock_t request_lock;
40369 struct list_head req_list;
40370 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40371 index 0775f0a..d4fb316 100644
40372 --- a/drivers/net/hyperv/rndis_filter.c
40373 +++ b/drivers/net/hyperv/rndis_filter.c
40374 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40375 * template
40376 */
40377 set = &rndis_msg->msg.set_req;
40378 - set->req_id = atomic_inc_return(&dev->new_req_id);
40379 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40380
40381 /* Add to the request list */
40382 spin_lock_irqsave(&dev->request_lock, flags);
40383 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40384
40385 /* Setup the rndis set */
40386 halt = &request->request_msg.msg.halt_req;
40387 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40388 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40389
40390 /* Ignore return since this msg is optional. */
40391 rndis_filter_send_request(dev, request);
40392 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40393 index bf0d55e..82bcfbd1 100644
40394 --- a/drivers/net/ieee802154/fakehard.c
40395 +++ b/drivers/net/ieee802154/fakehard.c
40396 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40397 phy->transmit_power = 0xbf;
40398
40399 dev->netdev_ops = &fake_ops;
40400 - dev->ml_priv = &fake_mlme;
40401 + dev->ml_priv = (void *)&fake_mlme;
40402
40403 priv = netdev_priv(dev);
40404 priv->phy = phy;
40405 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40406 index 6e91931..2b0ebe7 100644
40407 --- a/drivers/net/macvlan.c
40408 +++ b/drivers/net/macvlan.c
40409 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40410 int macvlan_link_register(struct rtnl_link_ops *ops)
40411 {
40412 /* common fields */
40413 - ops->priv_size = sizeof(struct macvlan_dev);
40414 - ops->validate = macvlan_validate;
40415 - ops->maxtype = IFLA_MACVLAN_MAX;
40416 - ops->policy = macvlan_policy;
40417 - ops->changelink = macvlan_changelink;
40418 - ops->get_size = macvlan_get_size;
40419 - ops->fill_info = macvlan_fill_info;
40420 + pax_open_kernel();
40421 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40422 + *(void **)&ops->validate = macvlan_validate;
40423 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40424 + *(const void **)&ops->policy = macvlan_policy;
40425 + *(void **)&ops->changelink = macvlan_changelink;
40426 + *(void **)&ops->get_size = macvlan_get_size;
40427 + *(void **)&ops->fill_info = macvlan_fill_info;
40428 + pax_close_kernel();
40429
40430 return rtnl_link_register(ops);
40431 };
40432 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40433 return NOTIFY_DONE;
40434 }
40435
40436 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40437 +static struct notifier_block macvlan_notifier_block = {
40438 .notifier_call = macvlan_device_event,
40439 };
40440
40441 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40442 index b6dd6a7..5c38a02 100644
40443 --- a/drivers/net/macvtap.c
40444 +++ b/drivers/net/macvtap.c
40445 @@ -1094,7 +1094,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40446 return NOTIFY_DONE;
40447 }
40448
40449 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40450 +static struct notifier_block macvtap_notifier_block = {
40451 .notifier_call = macvtap_device_event,
40452 };
40453
40454 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40455 index daec9b0..6428fcb 100644
40456 --- a/drivers/net/phy/mdio-bitbang.c
40457 +++ b/drivers/net/phy/mdio-bitbang.c
40458 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40459 struct mdiobb_ctrl *ctrl = bus->priv;
40460
40461 module_put(ctrl->ops->owner);
40462 + mdiobus_unregister(bus);
40463 mdiobus_free(bus);
40464 }
40465 EXPORT_SYMBOL(free_mdio_bitbang);
40466 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40467 index 72ff14b..11d442d 100644
40468 --- a/drivers/net/ppp/ppp_generic.c
40469 +++ b/drivers/net/ppp/ppp_generic.c
40470 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40471 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40472 struct ppp_stats stats;
40473 struct ppp_comp_stats cstats;
40474 - char *vers;
40475
40476 switch (cmd) {
40477 case SIOCGPPPSTATS:
40478 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40479 break;
40480
40481 case SIOCGPPPVER:
40482 - vers = PPP_VERSION;
40483 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40484 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40485 break;
40486 err = 0;
40487 break;
40488 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40489 index 1252d9c..80e660b 100644
40490 --- a/drivers/net/slip/slhc.c
40491 +++ b/drivers/net/slip/slhc.c
40492 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40493 register struct tcphdr *thp;
40494 register struct iphdr *ip;
40495 register struct cstate *cs;
40496 - int len, hdrlen;
40497 + long len, hdrlen;
40498 unsigned char *cp = icp;
40499
40500 /* We've got a compressed packet; read the change byte */
40501 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40502 index b305105..8ead6df 100644
40503 --- a/drivers/net/team/team.c
40504 +++ b/drivers/net/team/team.c
40505 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
40506 return NOTIFY_DONE;
40507 }
40508
40509 -static struct notifier_block team_notifier_block __read_mostly = {
40510 +static struct notifier_block team_notifier_block = {
40511 .notifier_call = team_device_event,
40512 };
40513
40514 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40515 index 9c61f87..213609e 100644
40516 --- a/drivers/net/tun.c
40517 +++ b/drivers/net/tun.c
40518 @@ -1852,7 +1852,7 @@ unlock:
40519 }
40520
40521 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40522 - unsigned long arg, int ifreq_len)
40523 + unsigned long arg, size_t ifreq_len)
40524 {
40525 struct tun_file *tfile = file->private_data;
40526 struct tun_struct *tun;
40527 @@ -1864,6 +1864,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40528 int vnet_hdr_sz;
40529 int ret;
40530
40531 + if (ifreq_len > sizeof ifr)
40532 + return -EFAULT;
40533 +
40534 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40535 if (copy_from_user(&ifr, argp, ifreq_len))
40536 return -EFAULT;
40537 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40538 index cba1d46..f703766 100644
40539 --- a/drivers/net/usb/hso.c
40540 +++ b/drivers/net/usb/hso.c
40541 @@ -71,7 +71,7 @@
40542 #include <asm/byteorder.h>
40543 #include <linux/serial_core.h>
40544 #include <linux/serial.h>
40545 -
40546 +#include <asm/local.h>
40547
40548 #define MOD_AUTHOR "Option Wireless"
40549 #define MOD_DESCRIPTION "USB High Speed Option driver"
40550 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40551 struct urb *urb;
40552
40553 urb = serial->rx_urb[0];
40554 - if (serial->port.count > 0) {
40555 + if (atomic_read(&serial->port.count) > 0) {
40556 count = put_rxbuf_data(urb, serial);
40557 if (count == -1)
40558 return;
40559 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40560 DUMP1(urb->transfer_buffer, urb->actual_length);
40561
40562 /* Anyone listening? */
40563 - if (serial->port.count == 0)
40564 + if (atomic_read(&serial->port.count) == 0)
40565 return;
40566
40567 if (status == 0) {
40568 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40569 tty_port_tty_set(&serial->port, tty);
40570
40571 /* check for port already opened, if not set the termios */
40572 - serial->port.count++;
40573 - if (serial->port.count == 1) {
40574 + if (atomic_inc_return(&serial->port.count) == 1) {
40575 serial->rx_state = RX_IDLE;
40576 /* Force default termio settings */
40577 _hso_serial_set_termios(tty, NULL);
40578 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40579 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40580 if (result) {
40581 hso_stop_serial_device(serial->parent);
40582 - serial->port.count--;
40583 + atomic_dec(&serial->port.count);
40584 kref_put(&serial->parent->ref, hso_serial_ref_free);
40585 }
40586 } else {
40587 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40588
40589 /* reset the rts and dtr */
40590 /* do the actual close */
40591 - serial->port.count--;
40592 + atomic_dec(&serial->port.count);
40593
40594 - if (serial->port.count <= 0) {
40595 - serial->port.count = 0;
40596 + if (atomic_read(&serial->port.count) <= 0) {
40597 + atomic_set(&serial->port.count, 0);
40598 tty_port_tty_set(&serial->port, NULL);
40599 if (!usb_gone)
40600 hso_stop_serial_device(serial->parent);
40601 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40602
40603 /* the actual setup */
40604 spin_lock_irqsave(&serial->serial_lock, flags);
40605 - if (serial->port.count)
40606 + if (atomic_read(&serial->port.count))
40607 _hso_serial_set_termios(tty, old);
40608 else
40609 tty->termios = *old;
40610 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40611 D1("Pending read interrupt on port %d\n", i);
40612 spin_lock(&serial->serial_lock);
40613 if (serial->rx_state == RX_IDLE &&
40614 - serial->port.count > 0) {
40615 + atomic_read(&serial->port.count) > 0) {
40616 /* Setup and send a ctrl req read on
40617 * port i */
40618 if (!serial->rx_urb_filled[0]) {
40619 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
40620 /* Start all serial ports */
40621 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40622 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40623 - if (dev2ser(serial_table[i])->port.count) {
40624 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40625 result =
40626 hso_start_serial_device(serial_table[i], GFP_NOIO);
40627 hso_kick_transmit(dev2ser(serial_table[i]));
40628 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40629 index 57325f3..36b181f 100644
40630 --- a/drivers/net/vxlan.c
40631 +++ b/drivers/net/vxlan.c
40632 @@ -1579,7 +1579,7 @@ nla_put_failure:
40633 return -EMSGSIZE;
40634 }
40635
40636 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40637 +static struct rtnl_link_ops vxlan_link_ops = {
40638 .kind = "vxlan",
40639 .maxtype = IFLA_VXLAN_MAX,
40640 .policy = vxlan_policy,
40641 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40642 index 34c8a33..3261fdc 100644
40643 --- a/drivers/net/wireless/at76c50x-usb.c
40644 +++ b/drivers/net/wireless/at76c50x-usb.c
40645 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40646 }
40647
40648 /* Convert timeout from the DFU status to jiffies */
40649 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40650 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40651 {
40652 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40653 | (s->poll_timeout[1] << 8)
40654 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40655 index 8d78253..bebbb68 100644
40656 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40657 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40658 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40659 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40660 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40661
40662 - ACCESS_ONCE(ads->ds_link) = i->link;
40663 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40664 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40665 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40666
40667 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40668 ctl6 = SM(i->keytype, AR_EncrType);
40669 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40670
40671 if ((i->is_first || i->is_last) &&
40672 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40673 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40674 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40675 | set11nTries(i->rates, 1)
40676 | set11nTries(i->rates, 2)
40677 | set11nTries(i->rates, 3)
40678 | (i->dur_update ? AR_DurUpdateEna : 0)
40679 | SM(0, AR_BurstDur);
40680
40681 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40682 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40683 | set11nRate(i->rates, 1)
40684 | set11nRate(i->rates, 2)
40685 | set11nRate(i->rates, 3);
40686 } else {
40687 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40688 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40689 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40690 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40691 }
40692
40693 if (!i->is_first) {
40694 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40695 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40696 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40697 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40698 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40699 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40700 return;
40701 }
40702
40703 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40704 break;
40705 }
40706
40707 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40708 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40709 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40710 | SM(i->txpower, AR_XmitPower)
40711 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40712 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40713 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40714 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40715
40716 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40717 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40718 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40719 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40720
40721 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40722 return;
40723
40724 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40725 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40726 | set11nPktDurRTSCTS(i->rates, 1);
40727
40728 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40729 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40730 | set11nPktDurRTSCTS(i->rates, 3);
40731
40732 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40733 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40734 | set11nRateFlags(i->rates, 1)
40735 | set11nRateFlags(i->rates, 2)
40736 | set11nRateFlags(i->rates, 3)
40737 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40738 index 301bf72..3f5654f 100644
40739 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40740 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40741 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40742 (i->qcu << AR_TxQcuNum_S) | desc_len;
40743
40744 checksum += val;
40745 - ACCESS_ONCE(ads->info) = val;
40746 + ACCESS_ONCE_RW(ads->info) = val;
40747
40748 checksum += i->link;
40749 - ACCESS_ONCE(ads->link) = i->link;
40750 + ACCESS_ONCE_RW(ads->link) = i->link;
40751
40752 checksum += i->buf_addr[0];
40753 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40754 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40755 checksum += i->buf_addr[1];
40756 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40757 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40758 checksum += i->buf_addr[2];
40759 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40760 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40761 checksum += i->buf_addr[3];
40762 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40763 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40764
40765 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40766 - ACCESS_ONCE(ads->ctl3) = val;
40767 + ACCESS_ONCE_RW(ads->ctl3) = val;
40768 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40769 - ACCESS_ONCE(ads->ctl5) = val;
40770 + ACCESS_ONCE_RW(ads->ctl5) = val;
40771 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40772 - ACCESS_ONCE(ads->ctl7) = val;
40773 + ACCESS_ONCE_RW(ads->ctl7) = val;
40774 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40775 - ACCESS_ONCE(ads->ctl9) = val;
40776 + ACCESS_ONCE_RW(ads->ctl9) = val;
40777
40778 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40779 - ACCESS_ONCE(ads->ctl10) = checksum;
40780 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40781
40782 if (i->is_first || i->is_last) {
40783 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40784 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40785 | set11nTries(i->rates, 1)
40786 | set11nTries(i->rates, 2)
40787 | set11nTries(i->rates, 3)
40788 | (i->dur_update ? AR_DurUpdateEna : 0)
40789 | SM(0, AR_BurstDur);
40790
40791 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40792 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40793 | set11nRate(i->rates, 1)
40794 | set11nRate(i->rates, 2)
40795 | set11nRate(i->rates, 3);
40796 } else {
40797 - ACCESS_ONCE(ads->ctl13) = 0;
40798 - ACCESS_ONCE(ads->ctl14) = 0;
40799 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40800 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40801 }
40802
40803 ads->ctl20 = 0;
40804 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40805
40806 ctl17 = SM(i->keytype, AR_EncrType);
40807 if (!i->is_first) {
40808 - ACCESS_ONCE(ads->ctl11) = 0;
40809 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40810 - ACCESS_ONCE(ads->ctl15) = 0;
40811 - ACCESS_ONCE(ads->ctl16) = 0;
40812 - ACCESS_ONCE(ads->ctl17) = ctl17;
40813 - ACCESS_ONCE(ads->ctl18) = 0;
40814 - ACCESS_ONCE(ads->ctl19) = 0;
40815 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40816 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40817 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40818 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40819 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40820 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40821 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40822 return;
40823 }
40824
40825 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40826 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40827 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40828 | SM(i->txpower, AR_XmitPower)
40829 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40830 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40831 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40832 ctl12 |= SM(val, AR_PAPRDChainMask);
40833
40834 - ACCESS_ONCE(ads->ctl12) = ctl12;
40835 - ACCESS_ONCE(ads->ctl17) = ctl17;
40836 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40837 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40838
40839 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40840 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40841 | set11nPktDurRTSCTS(i->rates, 1);
40842
40843 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40844 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40845 | set11nPktDurRTSCTS(i->rates, 3);
40846
40847 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40848 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40849 | set11nRateFlags(i->rates, 1)
40850 | set11nRateFlags(i->rates, 2)
40851 | set11nRateFlags(i->rates, 3)
40852 | SM(i->rtscts_rate, AR_RTSCTSRate);
40853
40854 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40855 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40856 }
40857
40858 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40859 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40860 index ae30343..a117806 100644
40861 --- a/drivers/net/wireless/ath/ath9k/hw.h
40862 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40863 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
40864
40865 /* ANI */
40866 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40867 -};
40868 +} __no_const;
40869
40870 /**
40871 * struct ath_spec_scan - parameters for Atheros spectral scan
40872 @@ -721,7 +721,7 @@ struct ath_hw_ops {
40873 struct ath_spec_scan *param);
40874 void (*spectral_scan_trigger)(struct ath_hw *ah);
40875 void (*spectral_scan_wait)(struct ath_hw *ah);
40876 -};
40877 +} __no_const;
40878
40879 struct ath_nf_limits {
40880 s16 max;
40881 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40882 index b37a582..680835d 100644
40883 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40884 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40885 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40886 */
40887 if (il3945_mod_params.disable_hw_scan) {
40888 D_INFO("Disabling hw_scan\n");
40889 - il3945_mac_ops.hw_scan = NULL;
40890 + pax_open_kernel();
40891 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40892 + pax_close_kernel();
40893 }
40894
40895 D_INFO("*** LOAD DRIVER ***\n");
40896 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40897 index d532948..a1cb592 100644
40898 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40899 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40900 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40901 {
40902 struct iwl_priv *priv = file->private_data;
40903 char buf[64];
40904 - int buf_size;
40905 + size_t buf_size;
40906 u32 offset, len;
40907
40908 memset(buf, 0, sizeof(buf));
40909 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40910 struct iwl_priv *priv = file->private_data;
40911
40912 char buf[8];
40913 - int buf_size;
40914 + size_t buf_size;
40915 u32 reset_flag;
40916
40917 memset(buf, 0, sizeof(buf));
40918 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40919 {
40920 struct iwl_priv *priv = file->private_data;
40921 char buf[8];
40922 - int buf_size;
40923 + size_t buf_size;
40924 int ht40;
40925
40926 memset(buf, 0, sizeof(buf));
40927 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40928 {
40929 struct iwl_priv *priv = file->private_data;
40930 char buf[8];
40931 - int buf_size;
40932 + size_t buf_size;
40933 int value;
40934
40935 memset(buf, 0, sizeof(buf));
40936 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40937 {
40938 struct iwl_priv *priv = file->private_data;
40939 char buf[8];
40940 - int buf_size;
40941 + size_t buf_size;
40942 int clear;
40943
40944 memset(buf, 0, sizeof(buf));
40945 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40946 {
40947 struct iwl_priv *priv = file->private_data;
40948 char buf[8];
40949 - int buf_size;
40950 + size_t buf_size;
40951 int trace;
40952
40953 memset(buf, 0, sizeof(buf));
40954 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40955 {
40956 struct iwl_priv *priv = file->private_data;
40957 char buf[8];
40958 - int buf_size;
40959 + size_t buf_size;
40960 int missed;
40961
40962 memset(buf, 0, sizeof(buf));
40963 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40964
40965 struct iwl_priv *priv = file->private_data;
40966 char buf[8];
40967 - int buf_size;
40968 + size_t buf_size;
40969 int plcp;
40970
40971 memset(buf, 0, sizeof(buf));
40972 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40973
40974 struct iwl_priv *priv = file->private_data;
40975 char buf[8];
40976 - int buf_size;
40977 + size_t buf_size;
40978 int flush;
40979
40980 memset(buf, 0, sizeof(buf));
40981 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40982
40983 struct iwl_priv *priv = file->private_data;
40984 char buf[8];
40985 - int buf_size;
40986 + size_t buf_size;
40987 int rts;
40988
40989 if (!priv->cfg->ht_params)
40990 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40991 {
40992 struct iwl_priv *priv = file->private_data;
40993 char buf[8];
40994 - int buf_size;
40995 + size_t buf_size;
40996
40997 memset(buf, 0, sizeof(buf));
40998 buf_size = min(count, sizeof(buf) - 1);
40999 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
41000 struct iwl_priv *priv = file->private_data;
41001 u32 event_log_flag;
41002 char buf[8];
41003 - int buf_size;
41004 + size_t buf_size;
41005
41006 /* check that the interface is up */
41007 if (!iwl_is_ready(priv))
41008 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
41009 struct iwl_priv *priv = file->private_data;
41010 char buf[8];
41011 u32 calib_disabled;
41012 - int buf_size;
41013 + size_t buf_size;
41014
41015 memset(buf, 0, sizeof(buf));
41016 buf_size = min(count, sizeof(buf) - 1);
41017 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
41018 index 50ba0a4..29424e7 100644
41019 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
41020 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
41021 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
41022 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
41023
41024 char buf[8];
41025 - int buf_size;
41026 + size_t buf_size;
41027 u32 reset_flag;
41028
41029 memset(buf, 0, sizeof(buf));
41030 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
41031 {
41032 struct iwl_trans *trans = file->private_data;
41033 char buf[8];
41034 - int buf_size;
41035 + size_t buf_size;
41036 int csr;
41037
41038 memset(buf, 0, sizeof(buf));
41039 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
41040 index cb34c78..9fec0dc 100644
41041 --- a/drivers/net/wireless/mac80211_hwsim.c
41042 +++ b/drivers/net/wireless/mac80211_hwsim.c
41043 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
41044
41045 if (channels > 1) {
41046 hwsim_if_comb.num_different_channels = channels;
41047 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41048 - mac80211_hwsim_ops.cancel_hw_scan =
41049 - mac80211_hwsim_cancel_hw_scan;
41050 - mac80211_hwsim_ops.sw_scan_start = NULL;
41051 - mac80211_hwsim_ops.sw_scan_complete = NULL;
41052 - mac80211_hwsim_ops.remain_on_channel =
41053 - mac80211_hwsim_roc;
41054 - mac80211_hwsim_ops.cancel_remain_on_channel =
41055 - mac80211_hwsim_croc;
41056 - mac80211_hwsim_ops.add_chanctx =
41057 - mac80211_hwsim_add_chanctx;
41058 - mac80211_hwsim_ops.remove_chanctx =
41059 - mac80211_hwsim_remove_chanctx;
41060 - mac80211_hwsim_ops.change_chanctx =
41061 - mac80211_hwsim_change_chanctx;
41062 - mac80211_hwsim_ops.assign_vif_chanctx =
41063 - mac80211_hwsim_assign_vif_chanctx;
41064 - mac80211_hwsim_ops.unassign_vif_chanctx =
41065 - mac80211_hwsim_unassign_vif_chanctx;
41066 + pax_open_kernel();
41067 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41068 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
41069 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
41070 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
41071 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
41072 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
41073 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
41074 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
41075 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
41076 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
41077 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
41078 + pax_close_kernel();
41079 }
41080
41081 spin_lock_init(&hwsim_radio_lock);
41082 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41083 index 8169a85..7fa3b47 100644
41084 --- a/drivers/net/wireless/rndis_wlan.c
41085 +++ b/drivers/net/wireless/rndis_wlan.c
41086 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41087
41088 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41089
41090 - if (rts_threshold < 0 || rts_threshold > 2347)
41091 + if (rts_threshold > 2347)
41092 rts_threshold = 2347;
41093
41094 tmp = cpu_to_le32(rts_threshold);
41095 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41096 index 7510723..5ba37f5 100644
41097 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41098 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41099 @@ -386,7 +386,7 @@ struct rt2x00_intf {
41100 * for hardware which doesn't support hardware
41101 * sequence counting.
41102 */
41103 - atomic_t seqno;
41104 + atomic_unchecked_t seqno;
41105 };
41106
41107 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41108 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41109 index 2c12311..7b77f24 100644
41110 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41111 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41112 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41113 * sequence counter given by mac80211.
41114 */
41115 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41116 - seqno = atomic_add_return(0x10, &intf->seqno);
41117 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41118 else
41119 - seqno = atomic_read(&intf->seqno);
41120 + seqno = atomic_read_unchecked(&intf->seqno);
41121
41122 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41123 hdr->seq_ctrl |= cpu_to_le16(seqno);
41124 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41125 index e2b3d9c..67a5184 100644
41126 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41127 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41128 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41129
41130 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41131
41132 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41133 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41134 + pax_open_kernel();
41135 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41136 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41137 + pax_close_kernel();
41138
41139 wl1251_info("using dedicated interrupt line");
41140 } else {
41141 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41142 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41143 + pax_open_kernel();
41144 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41145 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41146 + pax_close_kernel();
41147
41148 wl1251_info("using SDIO interrupt");
41149 }
41150 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41151 index 1c627da..69f7d17 100644
41152 --- a/drivers/net/wireless/ti/wl12xx/main.c
41153 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41154 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41155 sizeof(wl->conf.mem));
41156
41157 /* read data preparation is only needed by wl127x */
41158 - wl->ops->prepare_read = wl127x_prepare_read;
41159 + pax_open_kernel();
41160 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41161 + pax_close_kernel();
41162
41163 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41164 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41165 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41166 sizeof(wl->conf.mem));
41167
41168 /* read data preparation is only needed by wl127x */
41169 - wl->ops->prepare_read = wl127x_prepare_read;
41170 + pax_open_kernel();
41171 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41172 + pax_close_kernel();
41173
41174 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41175 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41176 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41177 index 9fa692d..b31fee0 100644
41178 --- a/drivers/net/wireless/ti/wl18xx/main.c
41179 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41180 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41181 }
41182
41183 if (!checksum_param) {
41184 - wl18xx_ops.set_rx_csum = NULL;
41185 - wl18xx_ops.init_vif = NULL;
41186 + pax_open_kernel();
41187 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41188 + *(void **)&wl18xx_ops.init_vif = NULL;
41189 + pax_close_kernel();
41190 }
41191
41192 /* Enable 11a Band only if we have 5G antennas */
41193 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41194 index 7ef0b4a..ff65c28 100644
41195 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41196 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41197 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41198 {
41199 struct zd_usb *usb = urb->context;
41200 struct zd_usb_interrupt *intr = &usb->intr;
41201 - int len;
41202 + unsigned int len;
41203 u16 int_num;
41204
41205 ZD_ASSERT(in_interrupt());
41206 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41207 index d93b2b6..ae50401 100644
41208 --- a/drivers/oprofile/buffer_sync.c
41209 +++ b/drivers/oprofile/buffer_sync.c
41210 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41211 if (cookie == NO_COOKIE)
41212 offset = pc;
41213 if (cookie == INVALID_COOKIE) {
41214 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41215 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41216 offset = pc;
41217 }
41218 if (cookie != last_cookie) {
41219 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41220 /* add userspace sample */
41221
41222 if (!mm) {
41223 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41224 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41225 return 0;
41226 }
41227
41228 cookie = lookup_dcookie(mm, s->eip, &offset);
41229
41230 if (cookie == INVALID_COOKIE) {
41231 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41232 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41233 return 0;
41234 }
41235
41236 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41237 /* ignore backtraces if failed to add a sample */
41238 if (state == sb_bt_start) {
41239 state = sb_bt_ignore;
41240 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41241 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41242 }
41243 }
41244 release_mm(mm);
41245 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41246 index c0cc4e7..44d4e54 100644
41247 --- a/drivers/oprofile/event_buffer.c
41248 +++ b/drivers/oprofile/event_buffer.c
41249 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41250 }
41251
41252 if (buffer_pos == buffer_size) {
41253 - atomic_inc(&oprofile_stats.event_lost_overflow);
41254 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41255 return;
41256 }
41257
41258 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41259 index ed2c3ec..deda85a 100644
41260 --- a/drivers/oprofile/oprof.c
41261 +++ b/drivers/oprofile/oprof.c
41262 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41263 if (oprofile_ops.switch_events())
41264 return;
41265
41266 - atomic_inc(&oprofile_stats.multiplex_counter);
41267 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41268 start_switch_worker();
41269 }
41270
41271 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41272 index 84a208d..d61b0a1 100644
41273 --- a/drivers/oprofile/oprofile_files.c
41274 +++ b/drivers/oprofile/oprofile_files.c
41275 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41276
41277 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41278
41279 -static ssize_t timeout_read(struct file *file, char __user *buf,
41280 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41281 size_t count, loff_t *offset)
41282 {
41283 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41284 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41285 index 917d28e..d62d981 100644
41286 --- a/drivers/oprofile/oprofile_stats.c
41287 +++ b/drivers/oprofile/oprofile_stats.c
41288 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41289 cpu_buf->sample_invalid_eip = 0;
41290 }
41291
41292 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41293 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41294 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41295 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41296 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41297 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41298 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41299 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41300 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41301 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41302 }
41303
41304
41305 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41306 index 38b6fc0..b5cbfce 100644
41307 --- a/drivers/oprofile/oprofile_stats.h
41308 +++ b/drivers/oprofile/oprofile_stats.h
41309 @@ -13,11 +13,11 @@
41310 #include <linux/atomic.h>
41311
41312 struct oprofile_stat_struct {
41313 - atomic_t sample_lost_no_mm;
41314 - atomic_t sample_lost_no_mapping;
41315 - atomic_t bt_lost_no_mapping;
41316 - atomic_t event_lost_overflow;
41317 - atomic_t multiplex_counter;
41318 + atomic_unchecked_t sample_lost_no_mm;
41319 + atomic_unchecked_t sample_lost_no_mapping;
41320 + atomic_unchecked_t bt_lost_no_mapping;
41321 + atomic_unchecked_t event_lost_overflow;
41322 + atomic_unchecked_t multiplex_counter;
41323 };
41324
41325 extern struct oprofile_stat_struct oprofile_stats;
41326 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41327 index 7c12d9c..558bf3bb 100644
41328 --- a/drivers/oprofile/oprofilefs.c
41329 +++ b/drivers/oprofile/oprofilefs.c
41330 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41331
41332
41333 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41334 - char const *name, atomic_t *val)
41335 + char const *name, atomic_unchecked_t *val)
41336 {
41337 return __oprofilefs_create_file(sb, root, name,
41338 &atomic_ro_fops, 0444, val);
41339 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41340 index 93404f7..4a313d8 100644
41341 --- a/drivers/oprofile/timer_int.c
41342 +++ b/drivers/oprofile/timer_int.c
41343 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41344 return NOTIFY_OK;
41345 }
41346
41347 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41348 +static struct notifier_block oprofile_cpu_notifier = {
41349 .notifier_call = oprofile_cpu_notify,
41350 };
41351
41352 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41353 index 92ed045..62d39bd7 100644
41354 --- a/drivers/parport/procfs.c
41355 +++ b/drivers/parport/procfs.c
41356 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41357
41358 *ppos += len;
41359
41360 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41361 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41362 }
41363
41364 #ifdef CONFIG_PARPORT_1284
41365 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41366
41367 *ppos += len;
41368
41369 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41370 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41371 }
41372 #endif /* IEEE1284.3 support. */
41373
41374 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41375 index c35e8ad..fc33beb 100644
41376 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41377 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41378 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41379 goto init_cleanup;
41380 }
41381
41382 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41383 + pax_open_kernel();
41384 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41385 + pax_close_kernel();
41386 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41387
41388 return retval;
41389 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41390 index a6a71c4..c91097b 100644
41391 --- a/drivers/pci/hotplug/cpcihp_generic.c
41392 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41393 @@ -73,7 +73,6 @@ static u16 port;
41394 static unsigned int enum_bit;
41395 static u8 enum_mask;
41396
41397 -static struct cpci_hp_controller_ops generic_hpc_ops;
41398 static struct cpci_hp_controller generic_hpc;
41399
41400 static int __init validate_parameters(void)
41401 @@ -139,6 +138,10 @@ static int query_enum(void)
41402 return ((value & enum_mask) == enum_mask);
41403 }
41404
41405 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41406 + .query_enum = query_enum,
41407 +};
41408 +
41409 static int __init cpcihp_generic_init(void)
41410 {
41411 int status;
41412 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41413 pci_dev_put(dev);
41414
41415 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41416 - generic_hpc_ops.query_enum = query_enum;
41417 generic_hpc.ops = &generic_hpc_ops;
41418
41419 status = cpci_hp_register_controller(&generic_hpc);
41420 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41421 index 449b4bb..257e2e8 100644
41422 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41423 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41424 @@ -59,7 +59,6 @@
41425 /* local variables */
41426 static bool debug;
41427 static bool poll;
41428 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41429 static struct cpci_hp_controller zt5550_hpc;
41430
41431 /* Primary cPCI bus bridge device */
41432 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41433 return 0;
41434 }
41435
41436 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41437 + .query_enum = zt5550_hc_query_enum,
41438 +};
41439 +
41440 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41441 {
41442 int status;
41443 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41444 dbg("returned from zt5550_hc_config");
41445
41446 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41447 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41448 zt5550_hpc.ops = &zt5550_hpc_ops;
41449 if(!poll) {
41450 zt5550_hpc.irq = hc_dev->irq;
41451 zt5550_hpc.irq_flags = IRQF_SHARED;
41452 zt5550_hpc.dev_id = hc_dev;
41453
41454 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41455 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41456 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41457 + pax_open_kernel();
41458 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41459 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41460 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41461 + pax_open_kernel();
41462 } else {
41463 info("using ENUM# polling mode");
41464 }
41465 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41466 index 76ba8a1..20ca857 100644
41467 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41468 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41469 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41470
41471 void compaq_nvram_init (void __iomem *rom_start)
41472 {
41473 +
41474 +#ifndef CONFIG_PAX_KERNEXEC
41475 if (rom_start) {
41476 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41477 }
41478 +#endif
41479 +
41480 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41481
41482 /* initialize our int15 lock */
41483 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41484 index ec20f74..c1d961e 100644
41485 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41486 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41487 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41488 return -EINVAL;
41489 }
41490
41491 - slot->ops->owner = owner;
41492 - slot->ops->mod_name = mod_name;
41493 + pax_open_kernel();
41494 + *(struct module **)&slot->ops->owner = owner;
41495 + *(const char **)&slot->ops->mod_name = mod_name;
41496 + pax_close_kernel();
41497
41498 mutex_lock(&pci_hp_mutex);
41499 /*
41500 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41501 index 7d72c5e..edce02c 100644
41502 --- a/drivers/pci/hotplug/pciehp_core.c
41503 +++ b/drivers/pci/hotplug/pciehp_core.c
41504 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41505 struct slot *slot = ctrl->slot;
41506 struct hotplug_slot *hotplug = NULL;
41507 struct hotplug_slot_info *info = NULL;
41508 - struct hotplug_slot_ops *ops = NULL;
41509 + hotplug_slot_ops_no_const *ops = NULL;
41510 char name[SLOT_NAME_SIZE];
41511 int retval = -ENOMEM;
41512
41513 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41514 index 5b4a9d9..cd5ac1f 100644
41515 --- a/drivers/pci/pci-sysfs.c
41516 +++ b/drivers/pci/pci-sysfs.c
41517 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41518 {
41519 /* allocate attribute structure, piggyback attribute name */
41520 int name_len = write_combine ? 13 : 10;
41521 - struct bin_attribute *res_attr;
41522 + bin_attribute_no_const *res_attr;
41523 int retval;
41524
41525 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41526 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41527 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41528 {
41529 int retval;
41530 - struct bin_attribute *attr;
41531 + bin_attribute_no_const *attr;
41532
41533 /* If the device has VPD, try to expose it in sysfs. */
41534 if (dev->vpd) {
41535 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41536 {
41537 int retval;
41538 int rom_size = 0;
41539 - struct bin_attribute *attr;
41540 + bin_attribute_no_const *attr;
41541
41542 if (!sysfs_initialized)
41543 return -EACCES;
41544 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41545 index d1182c4..2a138ec 100644
41546 --- a/drivers/pci/pci.h
41547 +++ b/drivers/pci/pci.h
41548 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
41549 struct pci_vpd {
41550 unsigned int len;
41551 const struct pci_vpd_ops *ops;
41552 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41553 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41554 };
41555
41556 int pci_vpd_pci22_init(struct pci_dev *dev);
41557 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41558 index d320df6..ca9a8f6 100644
41559 --- a/drivers/pci/pcie/aspm.c
41560 +++ b/drivers/pci/pcie/aspm.c
41561 @@ -27,9 +27,9 @@
41562 #define MODULE_PARAM_PREFIX "pcie_aspm."
41563
41564 /* Note: those are not register definitions */
41565 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41566 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41567 -#define ASPM_STATE_L1 (4) /* L1 state */
41568 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41569 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41570 +#define ASPM_STATE_L1 (4U) /* L1 state */
41571 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41572 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41573
41574 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41575 index 70f10fa..cb5e917 100644
41576 --- a/drivers/pci/probe.c
41577 +++ b/drivers/pci/probe.c
41578 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41579 struct pci_bus_region region;
41580 bool bar_too_big = false, bar_disabled = false;
41581
41582 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41583 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41584
41585 /* No printks while decoding is disabled! */
41586 if (!dev->mmio_always_on) {
41587 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41588 index 0812608..b04018c4 100644
41589 --- a/drivers/pci/proc.c
41590 +++ b/drivers/pci/proc.c
41591 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41592 static int __init pci_proc_init(void)
41593 {
41594 struct pci_dev *dev = NULL;
41595 +
41596 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41597 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41598 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41599 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41600 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41601 +#endif
41602 +#else
41603 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41604 +#endif
41605 proc_create("devices", 0, proc_bus_pci_dir,
41606 &proc_bus_pci_dev_operations);
41607 proc_initialized = 1;
41608 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41609 index 3e5b4497..dcdfb70 100644
41610 --- a/drivers/platform/x86/chromeos_laptop.c
41611 +++ b/drivers/platform/x86/chromeos_laptop.c
41612 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41613 return 0;
41614 }
41615
41616 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41617 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41618 {
41619 .ident = "Samsung Series 5 550 - Touchpad",
41620 .matches = {
41621 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41622 index 6b22938..bc9700e 100644
41623 --- a/drivers/platform/x86/msi-laptop.c
41624 +++ b/drivers/platform/x86/msi-laptop.c
41625 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41626
41627 if (!quirks->ec_read_only) {
41628 /* allow userland write sysfs file */
41629 - dev_attr_bluetooth.store = store_bluetooth;
41630 - dev_attr_wlan.store = store_wlan;
41631 - dev_attr_threeg.store = store_threeg;
41632 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41633 - dev_attr_wlan.attr.mode |= S_IWUSR;
41634 - dev_attr_threeg.attr.mode |= S_IWUSR;
41635 + pax_open_kernel();
41636 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41637 + *(void **)&dev_attr_wlan.store = store_wlan;
41638 + *(void **)&dev_attr_threeg.store = store_threeg;
41639 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41640 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41641 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41642 + pax_close_kernel();
41643 }
41644
41645 /* disable hardware control by fn key */
41646 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41647 index 2ac045f..39c443d 100644
41648 --- a/drivers/platform/x86/sony-laptop.c
41649 +++ b/drivers/platform/x86/sony-laptop.c
41650 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41651 }
41652
41653 /* High speed charging function */
41654 -static struct device_attribute *hsc_handle;
41655 +static device_attribute_no_const *hsc_handle;
41656
41657 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41658 struct device_attribute *attr,
41659 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41660 index 54d31c0..3f896d3 100644
41661 --- a/drivers/platform/x86/thinkpad_acpi.c
41662 +++ b/drivers/platform/x86/thinkpad_acpi.c
41663 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41664 return 0;
41665 }
41666
41667 -void static hotkey_mask_warn_incomplete_mask(void)
41668 +static void hotkey_mask_warn_incomplete_mask(void)
41669 {
41670 /* log only what the user can fix... */
41671 const u32 wantedmask = hotkey_driver_mask &
41672 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41673 }
41674 }
41675
41676 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41677 - struct tp_nvram_state *newn,
41678 - const u32 event_mask)
41679 -{
41680 -
41681 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41682 do { \
41683 if ((event_mask & (1 << __scancode)) && \
41684 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41685 tpacpi_hotkey_send_key(__scancode); \
41686 } while (0)
41687
41688 - void issue_volchange(const unsigned int oldvol,
41689 - const unsigned int newvol)
41690 - {
41691 - unsigned int i = oldvol;
41692 +static void issue_volchange(const unsigned int oldvol,
41693 + const unsigned int newvol,
41694 + const u32 event_mask)
41695 +{
41696 + unsigned int i = oldvol;
41697
41698 - while (i > newvol) {
41699 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41700 - i--;
41701 - }
41702 - while (i < newvol) {
41703 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41704 - i++;
41705 - }
41706 + while (i > newvol) {
41707 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41708 + i--;
41709 }
41710 + while (i < newvol) {
41711 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41712 + i++;
41713 + }
41714 +}
41715
41716 - void issue_brightnesschange(const unsigned int oldbrt,
41717 - const unsigned int newbrt)
41718 - {
41719 - unsigned int i = oldbrt;
41720 +static void issue_brightnesschange(const unsigned int oldbrt,
41721 + const unsigned int newbrt,
41722 + const u32 event_mask)
41723 +{
41724 + unsigned int i = oldbrt;
41725
41726 - while (i > newbrt) {
41727 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41728 - i--;
41729 - }
41730 - while (i < newbrt) {
41731 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41732 - i++;
41733 - }
41734 + while (i > newbrt) {
41735 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41736 + i--;
41737 + }
41738 + while (i < newbrt) {
41739 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41740 + i++;
41741 }
41742 +}
41743
41744 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41745 + struct tp_nvram_state *newn,
41746 + const u32 event_mask)
41747 +{
41748 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41749 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41750 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41751 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41752 oldn->volume_level != newn->volume_level) {
41753 /* recently muted, or repeated mute keypress, or
41754 * multiple presses ending in mute */
41755 - issue_volchange(oldn->volume_level, newn->volume_level);
41756 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41757 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41758 }
41759 } else {
41760 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41761 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41762 }
41763 if (oldn->volume_level != newn->volume_level) {
41764 - issue_volchange(oldn->volume_level, newn->volume_level);
41765 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41766 } else if (oldn->volume_toggle != newn->volume_toggle) {
41767 /* repeated vol up/down keypress at end of scale ? */
41768 if (newn->volume_level == 0)
41769 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41770 /* handle brightness */
41771 if (oldn->brightness_level != newn->brightness_level) {
41772 issue_brightnesschange(oldn->brightness_level,
41773 - newn->brightness_level);
41774 + newn->brightness_level,
41775 + event_mask);
41776 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41777 /* repeated key presses that didn't change state */
41778 if (newn->brightness_level == 0)
41779 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41780 && !tp_features.bright_unkfw)
41781 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41782 }
41783 +}
41784
41785 #undef TPACPI_COMPARE_KEY
41786 #undef TPACPI_MAY_SEND_KEY
41787 -}
41788
41789 /*
41790 * Polling driver
41791 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41792 index 769d265..a3a05ca 100644
41793 --- a/drivers/pnp/pnpbios/bioscalls.c
41794 +++ b/drivers/pnp/pnpbios/bioscalls.c
41795 @@ -58,7 +58,7 @@ do { \
41796 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41797 } while(0)
41798
41799 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41800 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41801 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41802
41803 /*
41804 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41805
41806 cpu = get_cpu();
41807 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41808 +
41809 + pax_open_kernel();
41810 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41811 + pax_close_kernel();
41812
41813 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41814 spin_lock_irqsave(&pnp_bios_lock, flags);
41815 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41816 :"memory");
41817 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41818
41819 + pax_open_kernel();
41820 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41821 + pax_close_kernel();
41822 +
41823 put_cpu();
41824
41825 /* If we get here and this is set then the PnP BIOS faulted on us. */
41826 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41827 return status;
41828 }
41829
41830 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41831 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41832 {
41833 int i;
41834
41835 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41836 pnp_bios_callpoint.offset = header->fields.pm16offset;
41837 pnp_bios_callpoint.segment = PNP_CS16;
41838
41839 + pax_open_kernel();
41840 +
41841 for_each_possible_cpu(i) {
41842 struct desc_struct *gdt = get_cpu_gdt_table(i);
41843 if (!gdt)
41844 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41845 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41846 (unsigned long)__va(header->fields.pm16dseg));
41847 }
41848 +
41849 + pax_close_kernel();
41850 }
41851 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41852 index 3e6db1c..1fbbdae 100644
41853 --- a/drivers/pnp/resource.c
41854 +++ b/drivers/pnp/resource.c
41855 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41856 return 1;
41857
41858 /* check if the resource is valid */
41859 - if (*irq < 0 || *irq > 15)
41860 + if (*irq > 15)
41861 return 0;
41862
41863 /* check if the resource is reserved */
41864 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41865 return 1;
41866
41867 /* check if the resource is valid */
41868 - if (*dma < 0 || *dma == 4 || *dma > 7)
41869 + if (*dma == 4 || *dma > 7)
41870 return 0;
41871
41872 /* check if the resource is reserved */
41873 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41874 index 0c52e2a..3421ab7 100644
41875 --- a/drivers/power/pda_power.c
41876 +++ b/drivers/power/pda_power.c
41877 @@ -37,7 +37,11 @@ static int polling;
41878
41879 #if IS_ENABLED(CONFIG_USB_PHY)
41880 static struct usb_phy *transceiver;
41881 -static struct notifier_block otg_nb;
41882 +static int otg_handle_notification(struct notifier_block *nb,
41883 + unsigned long event, void *unused);
41884 +static struct notifier_block otg_nb = {
41885 + .notifier_call = otg_handle_notification
41886 +};
41887 #endif
41888
41889 static struct regulator *ac_draw;
41890 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41891
41892 #if IS_ENABLED(CONFIG_USB_PHY)
41893 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41894 - otg_nb.notifier_call = otg_handle_notification;
41895 ret = usb_register_notifier(transceiver, &otg_nb);
41896 if (ret) {
41897 dev_err(dev, "failure to register otg notifier\n");
41898 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41899 index cc439fd..8fa30df 100644
41900 --- a/drivers/power/power_supply.h
41901 +++ b/drivers/power/power_supply.h
41902 @@ -16,12 +16,12 @@ struct power_supply;
41903
41904 #ifdef CONFIG_SYSFS
41905
41906 -extern void power_supply_init_attrs(struct device_type *dev_type);
41907 +extern void power_supply_init_attrs(void);
41908 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41909
41910 #else
41911
41912 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41913 +static inline void power_supply_init_attrs(void) {}
41914 #define power_supply_uevent NULL
41915
41916 #endif /* CONFIG_SYSFS */
41917 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41918 index 1c517c3..ffa2f17 100644
41919 --- a/drivers/power/power_supply_core.c
41920 +++ b/drivers/power/power_supply_core.c
41921 @@ -24,7 +24,10 @@
41922 struct class *power_supply_class;
41923 EXPORT_SYMBOL_GPL(power_supply_class);
41924
41925 -static struct device_type power_supply_dev_type;
41926 +extern const struct attribute_group *power_supply_attr_groups[];
41927 +static struct device_type power_supply_dev_type = {
41928 + .groups = power_supply_attr_groups,
41929 +};
41930
41931 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
41932 struct power_supply *supply)
41933 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
41934 return PTR_ERR(power_supply_class);
41935
41936 power_supply_class->dev_uevent = power_supply_uevent;
41937 - power_supply_init_attrs(&power_supply_dev_type);
41938 + power_supply_init_attrs();
41939
41940 return 0;
41941 }
41942 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41943 index 29178f7..c65f324 100644
41944 --- a/drivers/power/power_supply_sysfs.c
41945 +++ b/drivers/power/power_supply_sysfs.c
41946 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41947 .is_visible = power_supply_attr_is_visible,
41948 };
41949
41950 -static const struct attribute_group *power_supply_attr_groups[] = {
41951 +const struct attribute_group *power_supply_attr_groups[] = {
41952 &power_supply_attr_group,
41953 NULL,
41954 };
41955
41956 -void power_supply_init_attrs(struct device_type *dev_type)
41957 +void power_supply_init_attrs(void)
41958 {
41959 int i;
41960
41961 - dev_type->groups = power_supply_attr_groups;
41962 -
41963 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41964 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41965 }
41966 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41967 index d428ef9..fdc0357 100644
41968 --- a/drivers/regulator/max8660.c
41969 +++ b/drivers/regulator/max8660.c
41970 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41971 max8660->shadow_regs[MAX8660_OVER1] = 5;
41972 } else {
41973 /* Otherwise devices can be toggled via software */
41974 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41975 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41976 + pax_open_kernel();
41977 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41978 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41979 + pax_close_kernel();
41980 }
41981
41982 /*
41983 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41984 index adb1414..c13e0ce 100644
41985 --- a/drivers/regulator/max8973-regulator.c
41986 +++ b/drivers/regulator/max8973-regulator.c
41987 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41988 if (!pdata->enable_ext_control) {
41989 max->desc.enable_reg = MAX8973_VOUT;
41990 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41991 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41992 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41993 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41994 + pax_open_kernel();
41995 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41996 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41997 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41998 + pax_close_kernel();
41999 }
42000
42001 max->enable_external_control = pdata->enable_ext_control;
42002 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
42003 index b716283..3cc4349 100644
42004 --- a/drivers/regulator/mc13892-regulator.c
42005 +++ b/drivers/regulator/mc13892-regulator.c
42006 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
42007 }
42008 mc13xxx_unlock(mc13892);
42009
42010 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42011 + pax_open_kernel();
42012 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42013 = mc13892_vcam_set_mode;
42014 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42015 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42016 = mc13892_vcam_get_mode;
42017 + pax_close_kernel();
42018
42019 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
42020 ARRAY_SIZE(mc13892_regulators));
42021 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
42022 index f1cb706..4c7832a 100644
42023 --- a/drivers/rtc/rtc-cmos.c
42024 +++ b/drivers/rtc/rtc-cmos.c
42025 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
42026 hpet_rtc_timer_init();
42027
42028 /* export at least the first block of NVRAM */
42029 - nvram.size = address_space - NVRAM_OFFSET;
42030 + pax_open_kernel();
42031 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
42032 + pax_close_kernel();
42033 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
42034 if (retval < 0) {
42035 dev_dbg(dev, "can't create nvram file? %d\n", retval);
42036 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
42037 index d049393..bb20be0 100644
42038 --- a/drivers/rtc/rtc-dev.c
42039 +++ b/drivers/rtc/rtc-dev.c
42040 @@ -16,6 +16,7 @@
42041 #include <linux/module.h>
42042 #include <linux/rtc.h>
42043 #include <linux/sched.h>
42044 +#include <linux/grsecurity.h>
42045 #include "rtc-core.h"
42046
42047 static dev_t rtc_devt;
42048 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
42049 if (copy_from_user(&tm, uarg, sizeof(tm)))
42050 return -EFAULT;
42051
42052 + gr_log_timechange();
42053 +
42054 return rtc_set_time(rtc, &tm);
42055
42056 case RTC_PIE_ON:
42057 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
42058 index b53992a..776df84 100644
42059 --- a/drivers/rtc/rtc-ds1307.c
42060 +++ b/drivers/rtc/rtc-ds1307.c
42061 @@ -107,7 +107,7 @@ struct ds1307 {
42062 u8 offset; /* register's offset */
42063 u8 regs[11];
42064 u16 nvram_offset;
42065 - struct bin_attribute *nvram;
42066 + bin_attribute_no_const *nvram;
42067 enum ds_type type;
42068 unsigned long flags;
42069 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
42070 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
42071 index 130f29a..6179d03 100644
42072 --- a/drivers/rtc/rtc-m48t59.c
42073 +++ b/drivers/rtc/rtc-m48t59.c
42074 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
42075 goto out;
42076 }
42077
42078 - m48t59_nvram_attr.size = pdata->offset;
42079 + pax_open_kernel();
42080 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42081 + pax_close_kernel();
42082
42083 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42084 if (ret) {
42085 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42086 index e693af6..2e525b6 100644
42087 --- a/drivers/scsi/bfa/bfa_fcpim.h
42088 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42089 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42090
42091 struct bfa_itn_s {
42092 bfa_isr_func_t isr;
42093 -};
42094 +} __no_const;
42095
42096 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42097 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42098 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42099 index 23a90e7..9cf04ee 100644
42100 --- a/drivers/scsi/bfa/bfa_ioc.h
42101 +++ b/drivers/scsi/bfa/bfa_ioc.h
42102 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42103 bfa_ioc_disable_cbfn_t disable_cbfn;
42104 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42105 bfa_ioc_reset_cbfn_t reset_cbfn;
42106 -};
42107 +} __no_const;
42108
42109 /*
42110 * IOC event notification mechanism.
42111 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42112 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42113 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42114 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42115 -};
42116 +} __no_const;
42117
42118 /*
42119 * Queue element to wait for room in request queue. FIFO order is
42120 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42121 index df0c3c7..b00e1d0 100644
42122 --- a/drivers/scsi/hosts.c
42123 +++ b/drivers/scsi/hosts.c
42124 @@ -42,7 +42,7 @@
42125 #include "scsi_logging.h"
42126
42127
42128 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42129 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42130
42131
42132 static void scsi_host_cls_release(struct device *dev)
42133 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42134 * subtract one because we increment first then return, but we need to
42135 * know what the next host number was before increment
42136 */
42137 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42138 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42139 shost->dma_channel = 0xff;
42140
42141 /* These three are default values which can be overridden */
42142 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42143 index 7f4f790..b75b92a 100644
42144 --- a/drivers/scsi/hpsa.c
42145 +++ b/drivers/scsi/hpsa.c
42146 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42147 unsigned long flags;
42148
42149 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42150 - return h->access.command_completed(h, q);
42151 + return h->access->command_completed(h, q);
42152
42153 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42154 a = rq->head[rq->current_entry];
42155 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42156 while (!list_empty(&h->reqQ)) {
42157 c = list_entry(h->reqQ.next, struct CommandList, list);
42158 /* can't do anything if fifo is full */
42159 - if ((h->access.fifo_full(h))) {
42160 + if ((h->access->fifo_full(h))) {
42161 dev_warn(&h->pdev->dev, "fifo full\n");
42162 break;
42163 }
42164 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42165
42166 /* Tell the controller execute command */
42167 spin_unlock_irqrestore(&h->lock, flags);
42168 - h->access.submit_command(h, c);
42169 + h->access->submit_command(h, c);
42170 spin_lock_irqsave(&h->lock, flags);
42171 }
42172 spin_unlock_irqrestore(&h->lock, flags);
42173 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42174
42175 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42176 {
42177 - return h->access.command_completed(h, q);
42178 + return h->access->command_completed(h, q);
42179 }
42180
42181 static inline bool interrupt_pending(struct ctlr_info *h)
42182 {
42183 - return h->access.intr_pending(h);
42184 + return h->access->intr_pending(h);
42185 }
42186
42187 static inline long interrupt_not_for_us(struct ctlr_info *h)
42188 {
42189 - return (h->access.intr_pending(h) == 0) ||
42190 + return (h->access->intr_pending(h) == 0) ||
42191 (h->interrupts_enabled == 0);
42192 }
42193
42194 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42195 if (prod_index < 0)
42196 return -ENODEV;
42197 h->product_name = products[prod_index].product_name;
42198 - h->access = *(products[prod_index].access);
42199 + h->access = products[prod_index].access;
42200
42201 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42202 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42203 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42204
42205 assert_spin_locked(&lockup_detector_lock);
42206 remove_ctlr_from_lockup_detector_list(h);
42207 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42208 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42209 spin_lock_irqsave(&h->lock, flags);
42210 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42211 spin_unlock_irqrestore(&h->lock, flags);
42212 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42213 }
42214
42215 /* make sure the board interrupts are off */
42216 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42217 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42218
42219 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42220 goto clean2;
42221 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42222 * fake ones to scoop up any residual completions.
42223 */
42224 spin_lock_irqsave(&h->lock, flags);
42225 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42226 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42227 spin_unlock_irqrestore(&h->lock, flags);
42228 free_irqs(h);
42229 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42230 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42231 dev_info(&h->pdev->dev, "Board READY.\n");
42232 dev_info(&h->pdev->dev,
42233 "Waiting for stale completions to drain.\n");
42234 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42235 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42236 msleep(10000);
42237 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42238 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42239
42240 rc = controller_reset_failed(h->cfgtable);
42241 if (rc)
42242 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42243 }
42244
42245 /* Turn the interrupts on so we can service requests */
42246 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42247 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42248
42249 hpsa_hba_inquiry(h);
42250 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42251 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42252 * To write all data in the battery backed cache to disks
42253 */
42254 hpsa_flush_cache(h);
42255 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42256 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42257 hpsa_free_irqs_and_disable_msix(h);
42258 }
42259
42260 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42261 return;
42262 }
42263 /* Change the access methods to the performant access methods */
42264 - h->access = SA5_performant_access;
42265 + h->access = &SA5_performant_access;
42266 h->transMethod = CFGTBL_Trans_Performant;
42267 }
42268
42269 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42270 index 9816479..c5d4e97 100644
42271 --- a/drivers/scsi/hpsa.h
42272 +++ b/drivers/scsi/hpsa.h
42273 @@ -79,7 +79,7 @@ struct ctlr_info {
42274 unsigned int msix_vector;
42275 unsigned int msi_vector;
42276 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42277 - struct access_method access;
42278 + struct access_method *access;
42279
42280 /* queue and queue Info */
42281 struct list_head reqQ;
42282 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42283 index 8b928c6..9c76300 100644
42284 --- a/drivers/scsi/libfc/fc_exch.c
42285 +++ b/drivers/scsi/libfc/fc_exch.c
42286 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42287 u16 pool_max_index;
42288
42289 struct {
42290 - atomic_t no_free_exch;
42291 - atomic_t no_free_exch_xid;
42292 - atomic_t xid_not_found;
42293 - atomic_t xid_busy;
42294 - atomic_t seq_not_found;
42295 - atomic_t non_bls_resp;
42296 + atomic_unchecked_t no_free_exch;
42297 + atomic_unchecked_t no_free_exch_xid;
42298 + atomic_unchecked_t xid_not_found;
42299 + atomic_unchecked_t xid_busy;
42300 + atomic_unchecked_t seq_not_found;
42301 + atomic_unchecked_t non_bls_resp;
42302 } stats;
42303 };
42304
42305 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42306 /* allocate memory for exchange */
42307 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42308 if (!ep) {
42309 - atomic_inc(&mp->stats.no_free_exch);
42310 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42311 goto out;
42312 }
42313 memset(ep, 0, sizeof(*ep));
42314 @@ -797,7 +797,7 @@ out:
42315 return ep;
42316 err:
42317 spin_unlock_bh(&pool->lock);
42318 - atomic_inc(&mp->stats.no_free_exch_xid);
42319 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42320 mempool_free(ep, mp->ep_pool);
42321 return NULL;
42322 }
42323 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42324 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42325 ep = fc_exch_find(mp, xid);
42326 if (!ep) {
42327 - atomic_inc(&mp->stats.xid_not_found);
42328 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42329 reject = FC_RJT_OX_ID;
42330 goto out;
42331 }
42332 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42333 ep = fc_exch_find(mp, xid);
42334 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42335 if (ep) {
42336 - atomic_inc(&mp->stats.xid_busy);
42337 + atomic_inc_unchecked(&mp->stats.xid_busy);
42338 reject = FC_RJT_RX_ID;
42339 goto rel;
42340 }
42341 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42342 }
42343 xid = ep->xid; /* get our XID */
42344 } else if (!ep) {
42345 - atomic_inc(&mp->stats.xid_not_found);
42346 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42347 reject = FC_RJT_RX_ID; /* XID not found */
42348 goto out;
42349 }
42350 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42351 } else {
42352 sp = &ep->seq;
42353 if (sp->id != fh->fh_seq_id) {
42354 - atomic_inc(&mp->stats.seq_not_found);
42355 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42356 if (f_ctl & FC_FC_END_SEQ) {
42357 /*
42358 * Update sequence_id based on incoming last
42359 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42360
42361 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42362 if (!ep) {
42363 - atomic_inc(&mp->stats.xid_not_found);
42364 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42365 goto out;
42366 }
42367 if (ep->esb_stat & ESB_ST_COMPLETE) {
42368 - atomic_inc(&mp->stats.xid_not_found);
42369 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42370 goto rel;
42371 }
42372 if (ep->rxid == FC_XID_UNKNOWN)
42373 ep->rxid = ntohs(fh->fh_rx_id);
42374 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42375 - atomic_inc(&mp->stats.xid_not_found);
42376 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42377 goto rel;
42378 }
42379 if (ep->did != ntoh24(fh->fh_s_id) &&
42380 ep->did != FC_FID_FLOGI) {
42381 - atomic_inc(&mp->stats.xid_not_found);
42382 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42383 goto rel;
42384 }
42385 sof = fr_sof(fp);
42386 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42387 sp->ssb_stat |= SSB_ST_RESP;
42388 sp->id = fh->fh_seq_id;
42389 } else if (sp->id != fh->fh_seq_id) {
42390 - atomic_inc(&mp->stats.seq_not_found);
42391 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42392 goto rel;
42393 }
42394
42395 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42396 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42397
42398 if (!sp)
42399 - atomic_inc(&mp->stats.xid_not_found);
42400 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42401 else
42402 - atomic_inc(&mp->stats.non_bls_resp);
42403 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42404
42405 fc_frame_free(fp);
42406 }
42407 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42408
42409 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42410 mp = ema->mp;
42411 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42412 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42413 st->fc_no_free_exch_xid +=
42414 - atomic_read(&mp->stats.no_free_exch_xid);
42415 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42416 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42417 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42418 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42419 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42420 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42421 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42422 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42423 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42424 }
42425 }
42426 EXPORT_SYMBOL(fc_exch_update_stats);
42427 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42428 index 161c98e..6d563b3 100644
42429 --- a/drivers/scsi/libsas/sas_ata.c
42430 +++ b/drivers/scsi/libsas/sas_ata.c
42431 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42432 .postreset = ata_std_postreset,
42433 .error_handler = ata_std_error_handler,
42434 .post_internal_cmd = sas_ata_post_internal,
42435 - .qc_defer = ata_std_qc_defer,
42436 + .qc_defer = ata_std_qc_defer,
42437 .qc_prep = ata_noop_qc_prep,
42438 .qc_issue = sas_ata_qc_issue,
42439 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42440 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42441 index bcc56ca..6f4174a 100644
42442 --- a/drivers/scsi/lpfc/lpfc.h
42443 +++ b/drivers/scsi/lpfc/lpfc.h
42444 @@ -431,7 +431,7 @@ struct lpfc_vport {
42445 struct dentry *debug_nodelist;
42446 struct dentry *vport_debugfs_root;
42447 struct lpfc_debugfs_trc *disc_trc;
42448 - atomic_t disc_trc_cnt;
42449 + atomic_unchecked_t disc_trc_cnt;
42450 #endif
42451 uint8_t stat_data_enabled;
42452 uint8_t stat_data_blocked;
42453 @@ -865,8 +865,8 @@ struct lpfc_hba {
42454 struct timer_list fabric_block_timer;
42455 unsigned long bit_flags;
42456 #define FABRIC_COMANDS_BLOCKED 0
42457 - atomic_t num_rsrc_err;
42458 - atomic_t num_cmd_success;
42459 + atomic_unchecked_t num_rsrc_err;
42460 + atomic_unchecked_t num_cmd_success;
42461 unsigned long last_rsrc_error_time;
42462 unsigned long last_ramp_down_time;
42463 unsigned long last_ramp_up_time;
42464 @@ -902,7 +902,7 @@ struct lpfc_hba {
42465
42466 struct dentry *debug_slow_ring_trc;
42467 struct lpfc_debugfs_trc *slow_ring_trc;
42468 - atomic_t slow_ring_trc_cnt;
42469 + atomic_unchecked_t slow_ring_trc_cnt;
42470 /* iDiag debugfs sub-directory */
42471 struct dentry *idiag_root;
42472 struct dentry *idiag_pci_cfg;
42473 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42474 index f525ecb..32549a4 100644
42475 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42476 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42477 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42478
42479 #include <linux/debugfs.h>
42480
42481 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42482 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42483 static unsigned long lpfc_debugfs_start_time = 0L;
42484
42485 /* iDiag */
42486 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42487 lpfc_debugfs_enable = 0;
42488
42489 len = 0;
42490 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42491 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42492 (lpfc_debugfs_max_disc_trc - 1);
42493 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42494 dtp = vport->disc_trc + i;
42495 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42496 lpfc_debugfs_enable = 0;
42497
42498 len = 0;
42499 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42500 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42501 (lpfc_debugfs_max_slow_ring_trc - 1);
42502 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42503 dtp = phba->slow_ring_trc + i;
42504 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42505 !vport || !vport->disc_trc)
42506 return;
42507
42508 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42509 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42510 (lpfc_debugfs_max_disc_trc - 1);
42511 dtp = vport->disc_trc + index;
42512 dtp->fmt = fmt;
42513 dtp->data1 = data1;
42514 dtp->data2 = data2;
42515 dtp->data3 = data3;
42516 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42517 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42518 dtp->jif = jiffies;
42519 #endif
42520 return;
42521 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42522 !phba || !phba->slow_ring_trc)
42523 return;
42524
42525 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42526 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42527 (lpfc_debugfs_max_slow_ring_trc - 1);
42528 dtp = phba->slow_ring_trc + index;
42529 dtp->fmt = fmt;
42530 dtp->data1 = data1;
42531 dtp->data2 = data2;
42532 dtp->data3 = data3;
42533 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42534 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42535 dtp->jif = jiffies;
42536 #endif
42537 return;
42538 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42539 "slow_ring buffer\n");
42540 goto debug_failed;
42541 }
42542 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42543 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42544 memset(phba->slow_ring_trc, 0,
42545 (sizeof(struct lpfc_debugfs_trc) *
42546 lpfc_debugfs_max_slow_ring_trc));
42547 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42548 "buffer\n");
42549 goto debug_failed;
42550 }
42551 - atomic_set(&vport->disc_trc_cnt, 0);
42552 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42553
42554 snprintf(name, sizeof(name), "discovery_trace");
42555 vport->debug_disc_trc =
42556 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42557 index cb465b2..2e7b25f 100644
42558 --- a/drivers/scsi/lpfc/lpfc_init.c
42559 +++ b/drivers/scsi/lpfc/lpfc_init.c
42560 @@ -10950,8 +10950,10 @@ lpfc_init(void)
42561 "misc_register returned with status %d", error);
42562
42563 if (lpfc_enable_npiv) {
42564 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42565 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42566 + pax_open_kernel();
42567 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42568 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42569 + pax_close_kernel();
42570 }
42571 lpfc_transport_template =
42572 fc_attach_transport(&lpfc_transport_functions);
42573 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42574 index 8523b278e..ce1d812 100644
42575 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42576 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42577 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42578 uint32_t evt_posted;
42579
42580 spin_lock_irqsave(&phba->hbalock, flags);
42581 - atomic_inc(&phba->num_rsrc_err);
42582 + atomic_inc_unchecked(&phba->num_rsrc_err);
42583 phba->last_rsrc_error_time = jiffies;
42584
42585 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42586 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42587 unsigned long flags;
42588 struct lpfc_hba *phba = vport->phba;
42589 uint32_t evt_posted;
42590 - atomic_inc(&phba->num_cmd_success);
42591 + atomic_inc_unchecked(&phba->num_cmd_success);
42592
42593 if (vport->cfg_lun_queue_depth <= queue_depth)
42594 return;
42595 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42596 unsigned long num_rsrc_err, num_cmd_success;
42597 int i;
42598
42599 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42600 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42601 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42602 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42603
42604 /*
42605 * The error and success command counters are global per
42606 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42607 }
42608 }
42609 lpfc_destroy_vport_work_array(phba, vports);
42610 - atomic_set(&phba->num_rsrc_err, 0);
42611 - atomic_set(&phba->num_cmd_success, 0);
42612 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42613 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42614 }
42615
42616 /**
42617 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42618 }
42619 }
42620 lpfc_destroy_vport_work_array(phba, vports);
42621 - atomic_set(&phba->num_rsrc_err, 0);
42622 - atomic_set(&phba->num_cmd_success, 0);
42623 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42624 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42625 }
42626
42627 /**
42628 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42629 index 8e1b737..50ff510 100644
42630 --- a/drivers/scsi/pmcraid.c
42631 +++ b/drivers/scsi/pmcraid.c
42632 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42633 res->scsi_dev = scsi_dev;
42634 scsi_dev->hostdata = res;
42635 res->change_detected = 0;
42636 - atomic_set(&res->read_failures, 0);
42637 - atomic_set(&res->write_failures, 0);
42638 + atomic_set_unchecked(&res->read_failures, 0);
42639 + atomic_set_unchecked(&res->write_failures, 0);
42640 rc = 0;
42641 }
42642 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42643 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42644
42645 /* If this was a SCSI read/write command keep count of errors */
42646 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42647 - atomic_inc(&res->read_failures);
42648 + atomic_inc_unchecked(&res->read_failures);
42649 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42650 - atomic_inc(&res->write_failures);
42651 + atomic_inc_unchecked(&res->write_failures);
42652
42653 if (!RES_IS_GSCSI(res->cfg_entry) &&
42654 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42655 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42656 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42657 * hrrq_id assigned here in queuecommand
42658 */
42659 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42660 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42661 pinstance->num_hrrq;
42662 cmd->cmd_done = pmcraid_io_done;
42663
42664 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
42665 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42666 * hrrq_id assigned here in queuecommand
42667 */
42668 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42669 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42670 pinstance->num_hrrq;
42671
42672 if (request_size) {
42673 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42674
42675 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42676 /* add resources only after host is added into system */
42677 - if (!atomic_read(&pinstance->expose_resources))
42678 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42679 return;
42680
42681 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42682 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42683 init_waitqueue_head(&pinstance->reset_wait_q);
42684
42685 atomic_set(&pinstance->outstanding_cmds, 0);
42686 - atomic_set(&pinstance->last_message_id, 0);
42687 - atomic_set(&pinstance->expose_resources, 0);
42688 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42689 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42690
42691 INIT_LIST_HEAD(&pinstance->free_res_q);
42692 INIT_LIST_HEAD(&pinstance->used_res_q);
42693 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42694 /* Schedule worker thread to handle CCN and take care of adding and
42695 * removing devices to OS
42696 */
42697 - atomic_set(&pinstance->expose_resources, 1);
42698 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42699 schedule_work(&pinstance->worker_q);
42700 return rc;
42701
42702 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42703 index e1d150f..6c6df44 100644
42704 --- a/drivers/scsi/pmcraid.h
42705 +++ b/drivers/scsi/pmcraid.h
42706 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42707 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42708
42709 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42710 - atomic_t last_message_id;
42711 + atomic_unchecked_t last_message_id;
42712
42713 /* configuration table */
42714 struct pmcraid_config_table *cfg_table;
42715 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42716 atomic_t outstanding_cmds;
42717
42718 /* should add/delete resources to mid-layer now ?*/
42719 - atomic_t expose_resources;
42720 + atomic_unchecked_t expose_resources;
42721
42722
42723
42724 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42725 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42726 };
42727 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42728 - atomic_t read_failures; /* count of failed READ commands */
42729 - atomic_t write_failures; /* count of failed WRITE commands */
42730 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42731 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42732
42733 /* To indicate add/delete/modify during CCN */
42734 u8 change_detected;
42735 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42736 index bf60c63..74d4dce 100644
42737 --- a/drivers/scsi/qla2xxx/qla_attr.c
42738 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42739 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42740 return 0;
42741 }
42742
42743 -struct fc_function_template qla2xxx_transport_functions = {
42744 +fc_function_template_no_const qla2xxx_transport_functions = {
42745
42746 .show_host_node_name = 1,
42747 .show_host_port_name = 1,
42748 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42749 .bsg_timeout = qla24xx_bsg_timeout,
42750 };
42751
42752 -struct fc_function_template qla2xxx_transport_vport_functions = {
42753 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42754
42755 .show_host_node_name = 1,
42756 .show_host_port_name = 1,
42757 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42758 index 026bfde..90c4018 100644
42759 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42760 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42761 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42762 struct device_attribute;
42763 extern struct device_attribute *qla2x00_host_attrs[];
42764 struct fc_function_template;
42765 -extern struct fc_function_template qla2xxx_transport_functions;
42766 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42767 +extern fc_function_template_no_const qla2xxx_transport_functions;
42768 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42769 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42770 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42771 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42772 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42773 index ad72c1d..afc9a98 100644
42774 --- a/drivers/scsi/qla2xxx/qla_os.c
42775 +++ b/drivers/scsi/qla2xxx/qla_os.c
42776 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42777 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42778 /* Ok, a 64bit DMA mask is applicable. */
42779 ha->flags.enable_64bit_addressing = 1;
42780 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42781 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42782 + pax_open_kernel();
42783 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42784 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42785 + pax_close_kernel();
42786 return;
42787 }
42788 }
42789 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42790 index ddf16a8..80f4dd0 100644
42791 --- a/drivers/scsi/qla4xxx/ql4_def.h
42792 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42793 @@ -291,7 +291,7 @@ struct ddb_entry {
42794 * (4000 only) */
42795 atomic_t relogin_timer; /* Max Time to wait for
42796 * relogin to complete */
42797 - atomic_t relogin_retry_count; /* Num of times relogin has been
42798 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42799 * retried */
42800 uint32_t default_time2wait; /* Default Min time between
42801 * relogins (+aens) */
42802 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42803 index 4d231c1..2892c37 100644
42804 --- a/drivers/scsi/qla4xxx/ql4_os.c
42805 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42806 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42807 */
42808 if (!iscsi_is_session_online(cls_sess)) {
42809 /* Reset retry relogin timer */
42810 - atomic_inc(&ddb_entry->relogin_retry_count);
42811 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42812 DEBUG2(ql4_printk(KERN_INFO, ha,
42813 "%s: index[%d] relogin timed out-retrying"
42814 " relogin (%d), retry (%d)\n", __func__,
42815 ddb_entry->fw_ddb_index,
42816 - atomic_read(&ddb_entry->relogin_retry_count),
42817 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42818 ddb_entry->default_time2wait + 4));
42819 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42820 atomic_set(&ddb_entry->retry_relogin_timer,
42821 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42822
42823 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42824 atomic_set(&ddb_entry->relogin_timer, 0);
42825 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42826 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42827 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42828 ddb_entry->default_relogin_timeout =
42829 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42830 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42831 index 2c0d0ec..4e8681a 100644
42832 --- a/drivers/scsi/scsi.c
42833 +++ b/drivers/scsi/scsi.c
42834 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42835 unsigned long timeout;
42836 int rtn = 0;
42837
42838 - atomic_inc(&cmd->device->iorequest_cnt);
42839 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42840
42841 /* check if the device is still usable */
42842 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42843 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42844 index 86d5220..f22c51a 100644
42845 --- a/drivers/scsi/scsi_lib.c
42846 +++ b/drivers/scsi/scsi_lib.c
42847 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42848 shost = sdev->host;
42849 scsi_init_cmd_errh(cmd);
42850 cmd->result = DID_NO_CONNECT << 16;
42851 - atomic_inc(&cmd->device->iorequest_cnt);
42852 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42853
42854 /*
42855 * SCSI request completion path will do scsi_device_unbusy(),
42856 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
42857
42858 INIT_LIST_HEAD(&cmd->eh_entry);
42859
42860 - atomic_inc(&cmd->device->iodone_cnt);
42861 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42862 if (cmd->result)
42863 - atomic_inc(&cmd->device->ioerr_cnt);
42864 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42865
42866 disposition = scsi_decide_disposition(cmd);
42867 if (disposition != SUCCESS &&
42868 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42869 index 931a7d9..0c2a754 100644
42870 --- a/drivers/scsi/scsi_sysfs.c
42871 +++ b/drivers/scsi/scsi_sysfs.c
42872 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42873 char *buf) \
42874 { \
42875 struct scsi_device *sdev = to_scsi_device(dev); \
42876 - unsigned long long count = atomic_read(&sdev->field); \
42877 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42878 return snprintf(buf, 20, "0x%llx\n", count); \
42879 } \
42880 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42881 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42882 index 84a1fdf..693b0d6 100644
42883 --- a/drivers/scsi/scsi_tgt_lib.c
42884 +++ b/drivers/scsi/scsi_tgt_lib.c
42885 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42886 int err;
42887
42888 dprintk("%lx %u\n", uaddr, len);
42889 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42890 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42891 if (err) {
42892 /*
42893 * TODO: need to fixup sg_tablesize, max_segment_size,
42894 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42895 index e106c27..11a380e 100644
42896 --- a/drivers/scsi/scsi_transport_fc.c
42897 +++ b/drivers/scsi/scsi_transport_fc.c
42898 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42899 * Netlink Infrastructure
42900 */
42901
42902 -static atomic_t fc_event_seq;
42903 +static atomic_unchecked_t fc_event_seq;
42904
42905 /**
42906 * fc_get_event_number - Obtain the next sequential FC event number
42907 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
42908 u32
42909 fc_get_event_number(void)
42910 {
42911 - return atomic_add_return(1, &fc_event_seq);
42912 + return atomic_add_return_unchecked(1, &fc_event_seq);
42913 }
42914 EXPORT_SYMBOL(fc_get_event_number);
42915
42916 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
42917 {
42918 int error;
42919
42920 - atomic_set(&fc_event_seq, 0);
42921 + atomic_set_unchecked(&fc_event_seq, 0);
42922
42923 error = transport_class_register(&fc_host_class);
42924 if (error)
42925 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42926 char *cp;
42927
42928 *val = simple_strtoul(buf, &cp, 0);
42929 - if ((*cp && (*cp != '\n')) || (*val < 0))
42930 + if (*cp && (*cp != '\n'))
42931 return -EINVAL;
42932 /*
42933 * Check for overflow; dev_loss_tmo is u32
42934 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42935 index 133926b..903000d 100644
42936 --- a/drivers/scsi/scsi_transport_iscsi.c
42937 +++ b/drivers/scsi/scsi_transport_iscsi.c
42938 @@ -80,7 +80,7 @@ struct iscsi_internal {
42939 struct transport_container session_cont;
42940 };
42941
42942 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42943 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42944 static struct workqueue_struct *iscsi_eh_timer_workq;
42945
42946 static DEFINE_IDA(iscsi_sess_ida);
42947 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42948 int err;
42949
42950 ihost = shost->shost_data;
42951 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42952 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42953
42954 if (target_id == ISCSI_MAX_TARGET) {
42955 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42956 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
42957 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42958 ISCSI_TRANSPORT_VERSION);
42959
42960 - atomic_set(&iscsi_session_nr, 0);
42961 + atomic_set_unchecked(&iscsi_session_nr, 0);
42962
42963 err = class_register(&iscsi_transport_class);
42964 if (err)
42965 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42966 index f379c7f..e8fc69c 100644
42967 --- a/drivers/scsi/scsi_transport_srp.c
42968 +++ b/drivers/scsi/scsi_transport_srp.c
42969 @@ -33,7 +33,7 @@
42970 #include "scsi_transport_srp_internal.h"
42971
42972 struct srp_host_attrs {
42973 - atomic_t next_port_id;
42974 + atomic_unchecked_t next_port_id;
42975 };
42976 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42977
42978 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42979 struct Scsi_Host *shost = dev_to_shost(dev);
42980 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42981
42982 - atomic_set(&srp_host->next_port_id, 0);
42983 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42984 return 0;
42985 }
42986
42987 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42988 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42989 rport->roles = ids->roles;
42990
42991 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42992 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42993 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42994
42995 transport_setup_device(&rport->dev);
42996 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42997 index c1c5552..1cf226c 100644
42998 --- a/drivers/scsi/sd.c
42999 +++ b/drivers/scsi/sd.c
43000 @@ -2918,7 +2918,7 @@ static int sd_probe(struct device *dev)
43001 sdkp->disk = gd;
43002 sdkp->index = index;
43003 atomic_set(&sdkp->openers, 0);
43004 - atomic_set(&sdkp->device->ioerr_cnt, 0);
43005 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
43006
43007 if (!sdp->request_queue->rq_timeout) {
43008 if (sdp->type != TYPE_MOD)
43009 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
43010 index df5e961..df6b97f 100644
43011 --- a/drivers/scsi/sg.c
43012 +++ b/drivers/scsi/sg.c
43013 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
43014 sdp->disk->disk_name,
43015 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
43016 NULL,
43017 - (char *)arg);
43018 + (char __user *)arg);
43019 case BLKTRACESTART:
43020 return blk_trace_startstop(sdp->device->request_queue, 1);
43021 case BLKTRACESTOP:
43022 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
43023 index 32b7bb1..2f1c4bd 100644
43024 --- a/drivers/spi/spi.c
43025 +++ b/drivers/spi/spi.c
43026 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
43027 EXPORT_SYMBOL_GPL(spi_bus_unlock);
43028
43029 /* portable code must never pass more than 32 bytes */
43030 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
43031 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
43032
43033 static u8 *buf;
43034
43035 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
43036 index 3675020..e80d92c 100644
43037 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
43038 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
43039 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
43040
43041 static int solo_sysfs_init(struct solo_dev *solo_dev)
43042 {
43043 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
43044 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
43045 struct device *dev = &solo_dev->dev;
43046 const char *driver;
43047 int i;
43048 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
43049 index 34afc16..ffe44dd 100644
43050 --- a/drivers/staging/octeon/ethernet-rx.c
43051 +++ b/drivers/staging/octeon/ethernet-rx.c
43052 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43053 /* Increment RX stats for virtual ports */
43054 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
43055 #ifdef CONFIG_64BIT
43056 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
43057 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
43058 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
43059 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
43060 #else
43061 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
43062 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
43063 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
43064 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
43065 #endif
43066 }
43067 netif_receive_skb(skb);
43068 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43069 dev->name);
43070 */
43071 #ifdef CONFIG_64BIT
43072 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
43073 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43074 #else
43075 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
43076 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
43077 #endif
43078 dev_kfree_skb_irq(skb);
43079 }
43080 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43081 index c3a90e7..023619a 100644
43082 --- a/drivers/staging/octeon/ethernet.c
43083 +++ b/drivers/staging/octeon/ethernet.c
43084 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43085 * since the RX tasklet also increments it.
43086 */
43087 #ifdef CONFIG_64BIT
43088 - atomic64_add(rx_status.dropped_packets,
43089 - (atomic64_t *)&priv->stats.rx_dropped);
43090 + atomic64_add_unchecked(rx_status.dropped_packets,
43091 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43092 #else
43093 - atomic_add(rx_status.dropped_packets,
43094 - (atomic_t *)&priv->stats.rx_dropped);
43095 + atomic_add_unchecked(rx_status.dropped_packets,
43096 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43097 #endif
43098 }
43099
43100 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43101 index dc23395..cf7e9b1 100644
43102 --- a/drivers/staging/rtl8712/rtl871x_io.h
43103 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43104 @@ -108,7 +108,7 @@ struct _io_ops {
43105 u8 *pmem);
43106 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43107 u8 *pmem);
43108 -};
43109 +} __no_const;
43110
43111 struct io_req {
43112 struct list_head list;
43113 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43114 index 1f5088b..0e59820 100644
43115 --- a/drivers/staging/sbe-2t3e3/netdev.c
43116 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43117 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43118 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43119
43120 if (rlen)
43121 - if (copy_to_user(data, &resp, rlen))
43122 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43123 return -EFAULT;
43124
43125 return 0;
43126 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43127 index a863a98..d272795 100644
43128 --- a/drivers/staging/usbip/vhci.h
43129 +++ b/drivers/staging/usbip/vhci.h
43130 @@ -83,7 +83,7 @@ struct vhci_hcd {
43131 unsigned resuming:1;
43132 unsigned long re_timeout;
43133
43134 - atomic_t seqnum;
43135 + atomic_unchecked_t seqnum;
43136
43137 /*
43138 * NOTE:
43139 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43140 index d7974cb..d78076b 100644
43141 --- a/drivers/staging/usbip/vhci_hcd.c
43142 +++ b/drivers/staging/usbip/vhci_hcd.c
43143 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43144
43145 spin_lock(&vdev->priv_lock);
43146
43147 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43148 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43149 if (priv->seqnum == 0xffff)
43150 dev_info(&urb->dev->dev, "seqnum max\n");
43151
43152 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43153 return -ENOMEM;
43154 }
43155
43156 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43157 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43158 if (unlink->seqnum == 0xffff)
43159 pr_info("seqnum max\n");
43160
43161 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43162 vdev->rhport = rhport;
43163 }
43164
43165 - atomic_set(&vhci->seqnum, 0);
43166 + atomic_set_unchecked(&vhci->seqnum, 0);
43167 spin_lock_init(&vhci->lock);
43168
43169 hcd->power_budget = 0; /* no limit */
43170 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43171 index d07fcb5..358e1e1 100644
43172 --- a/drivers/staging/usbip/vhci_rx.c
43173 +++ b/drivers/staging/usbip/vhci_rx.c
43174 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43175 if (!urb) {
43176 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43177 pr_info("max seqnum %d\n",
43178 - atomic_read(&the_controller->seqnum));
43179 + atomic_read_unchecked(&the_controller->seqnum));
43180 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43181 return;
43182 }
43183 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43184 index 8417c2f..ef5ebd6 100644
43185 --- a/drivers/staging/vt6655/hostap.c
43186 +++ b/drivers/staging/vt6655/hostap.c
43187 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
43188 *
43189 */
43190
43191 +static net_device_ops_no_const apdev_netdev_ops;
43192 +
43193 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43194 {
43195 PSDevice apdev_priv;
43196 struct net_device *dev = pDevice->dev;
43197 int ret;
43198 - const struct net_device_ops apdev_netdev_ops = {
43199 - .ndo_start_xmit = pDevice->tx_80211,
43200 - };
43201
43202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43203
43204 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43205 *apdev_priv = *pDevice;
43206 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43207
43208 + /* only half broken now */
43209 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43210 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43211
43212 pDevice->apdev->type = ARPHRD_IEEE80211;
43213 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43214 index c699a30..b90a5fd 100644
43215 --- a/drivers/staging/vt6656/hostap.c
43216 +++ b/drivers/staging/vt6656/hostap.c
43217 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43218 *
43219 */
43220
43221 +static net_device_ops_no_const apdev_netdev_ops;
43222 +
43223 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43224 {
43225 struct vnt_private *apdev_priv;
43226 struct net_device *dev = pDevice->dev;
43227 int ret;
43228 - const struct net_device_ops apdev_netdev_ops = {
43229 - .ndo_start_xmit = pDevice->tx_80211,
43230 - };
43231
43232 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43233
43234 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43235 *apdev_priv = *pDevice;
43236 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43237
43238 + /* only half broken now */
43239 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43240 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43241
43242 pDevice->apdev->type = ARPHRD_IEEE80211;
43243 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43244 index d7e51e4..d07eaab 100644
43245 --- a/drivers/staging/zcache/tmem.c
43246 +++ b/drivers/staging/zcache/tmem.c
43247 @@ -51,7 +51,7 @@
43248 * A tmem host implementation must use this function to register callbacks
43249 * for memory allocation.
43250 */
43251 -static struct tmem_hostops tmem_hostops;
43252 +static tmem_hostops_no_const tmem_hostops;
43253
43254 static void tmem_objnode_tree_init(void);
43255
43256 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43257 * A tmem host implementation must use this function to register
43258 * callbacks for a page-accessible memory (PAM) implementation.
43259 */
43260 -static struct tmem_pamops tmem_pamops;
43261 +static tmem_pamops_no_const tmem_pamops;
43262
43263 void tmem_register_pamops(struct tmem_pamops *m)
43264 {
43265 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43266 index d128ce2..a43980c 100644
43267 --- a/drivers/staging/zcache/tmem.h
43268 +++ b/drivers/staging/zcache/tmem.h
43269 @@ -226,6 +226,7 @@ struct tmem_pamops {
43270 int (*replace_in_obj)(void *, struct tmem_obj *);
43271 #endif
43272 };
43273 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43274 extern void tmem_register_pamops(struct tmem_pamops *m);
43275
43276 /* memory allocation methods provided by the host implementation */
43277 @@ -235,6 +236,7 @@ struct tmem_hostops {
43278 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43279 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43280 };
43281 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43282 extern void tmem_register_hostops(struct tmem_hostops *m);
43283
43284 /* core tmem accessor functions */
43285 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43286 index 4630481..c26782a 100644
43287 --- a/drivers/target/target_core_device.c
43288 +++ b/drivers/target/target_core_device.c
43289 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43290 spin_lock_init(&dev->se_port_lock);
43291 spin_lock_init(&dev->se_tmr_lock);
43292 spin_lock_init(&dev->qf_cmd_lock);
43293 - atomic_set(&dev->dev_ordered_id, 0);
43294 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43295 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43296 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43297 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43298 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43299 index 21e3158..43c6004 100644
43300 --- a/drivers/target/target_core_transport.c
43301 +++ b/drivers/target/target_core_transport.c
43302 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43303 * Used to determine when ORDERED commands should go from
43304 * Dormant to Active status.
43305 */
43306 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43307 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43308 smp_mb__after_atomic_inc();
43309 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43310 cmd->se_ordered_id, cmd->sam_task_attr,
43311 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43312 index 33f83fe..d80f8e1 100644
43313 --- a/drivers/tty/cyclades.c
43314 +++ b/drivers/tty/cyclades.c
43315 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43316 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43317 info->port.count);
43318 #endif
43319 - info->port.count++;
43320 + atomic_inc(&info->port.count);
43321 #ifdef CY_DEBUG_COUNT
43322 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43323 - current->pid, info->port.count);
43324 + current->pid, atomic_read(&info->port.count));
43325 #endif
43326
43327 /*
43328 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43329 for (j = 0; j < cy_card[i].nports; j++) {
43330 info = &cy_card[i].ports[j];
43331
43332 - if (info->port.count) {
43333 + if (atomic_read(&info->port.count)) {
43334 /* XXX is the ldisc num worth this? */
43335 struct tty_struct *tty;
43336 struct tty_ldisc *ld;
43337 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43338 index eb255e8..f637a57 100644
43339 --- a/drivers/tty/hvc/hvc_console.c
43340 +++ b/drivers/tty/hvc/hvc_console.c
43341 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43342
43343 spin_lock_irqsave(&hp->port.lock, flags);
43344 /* Check and then increment for fast path open. */
43345 - if (hp->port.count++ > 0) {
43346 + if (atomic_inc_return(&hp->port.count) > 1) {
43347 spin_unlock_irqrestore(&hp->port.lock, flags);
43348 hvc_kick();
43349 return 0;
43350 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43351
43352 spin_lock_irqsave(&hp->port.lock, flags);
43353
43354 - if (--hp->port.count == 0) {
43355 + if (atomic_dec_return(&hp->port.count) == 0) {
43356 spin_unlock_irqrestore(&hp->port.lock, flags);
43357 /* We are done with the tty pointer now. */
43358 tty_port_tty_set(&hp->port, NULL);
43359 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43360 */
43361 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43362 } else {
43363 - if (hp->port.count < 0)
43364 + if (atomic_read(&hp->port.count) < 0)
43365 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43366 - hp->vtermno, hp->port.count);
43367 + hp->vtermno, atomic_read(&hp->port.count));
43368 spin_unlock_irqrestore(&hp->port.lock, flags);
43369 }
43370 }
43371 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43372 * open->hangup case this can be called after the final close so prevent
43373 * that from happening for now.
43374 */
43375 - if (hp->port.count <= 0) {
43376 + if (atomic_read(&hp->port.count) <= 0) {
43377 spin_unlock_irqrestore(&hp->port.lock, flags);
43378 return;
43379 }
43380
43381 - hp->port.count = 0;
43382 + atomic_set(&hp->port.count, 0);
43383 spin_unlock_irqrestore(&hp->port.lock, flags);
43384 tty_port_tty_set(&hp->port, NULL);
43385
43386 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43387 return -EPIPE;
43388
43389 /* FIXME what's this (unprotected) check for? */
43390 - if (hp->port.count <= 0)
43391 + if (atomic_read(&hp->port.count) <= 0)
43392 return -EIO;
43393
43394 spin_lock_irqsave(&hp->lock, flags);
43395 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43396 index 81e939e..95ead10 100644
43397 --- a/drivers/tty/hvc/hvcs.c
43398 +++ b/drivers/tty/hvc/hvcs.c
43399 @@ -83,6 +83,7 @@
43400 #include <asm/hvcserver.h>
43401 #include <asm/uaccess.h>
43402 #include <asm/vio.h>
43403 +#include <asm/local.h>
43404
43405 /*
43406 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43407 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43408
43409 spin_lock_irqsave(&hvcsd->lock, flags);
43410
43411 - if (hvcsd->port.count > 0) {
43412 + if (atomic_read(&hvcsd->port.count) > 0) {
43413 spin_unlock_irqrestore(&hvcsd->lock, flags);
43414 printk(KERN_INFO "HVCS: vterm state unchanged. "
43415 "The hvcs device node is still in use.\n");
43416 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43417 }
43418 }
43419
43420 - hvcsd->port.count = 0;
43421 + atomic_set(&hvcsd->port.count, 0);
43422 hvcsd->port.tty = tty;
43423 tty->driver_data = hvcsd;
43424
43425 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43426 unsigned long flags;
43427
43428 spin_lock_irqsave(&hvcsd->lock, flags);
43429 - hvcsd->port.count++;
43430 + atomic_inc(&hvcsd->port.count);
43431 hvcsd->todo_mask |= HVCS_SCHED_READ;
43432 spin_unlock_irqrestore(&hvcsd->lock, flags);
43433
43434 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43435 hvcsd = tty->driver_data;
43436
43437 spin_lock_irqsave(&hvcsd->lock, flags);
43438 - if (--hvcsd->port.count == 0) {
43439 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43440
43441 vio_disable_interrupts(hvcsd->vdev);
43442
43443 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43444
43445 free_irq(irq, hvcsd);
43446 return;
43447 - } else if (hvcsd->port.count < 0) {
43448 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43449 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43450 " is missmanaged.\n",
43451 - hvcsd->vdev->unit_address, hvcsd->port.count);
43452 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43453 }
43454
43455 spin_unlock_irqrestore(&hvcsd->lock, flags);
43456 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43457
43458 spin_lock_irqsave(&hvcsd->lock, flags);
43459 /* Preserve this so that we know how many kref refs to put */
43460 - temp_open_count = hvcsd->port.count;
43461 + temp_open_count = atomic_read(&hvcsd->port.count);
43462
43463 /*
43464 * Don't kref put inside the spinlock because the destruction
43465 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43466 tty->driver_data = NULL;
43467 hvcsd->port.tty = NULL;
43468
43469 - hvcsd->port.count = 0;
43470 + atomic_set(&hvcsd->port.count, 0);
43471
43472 /* This will drop any buffered data on the floor which is OK in a hangup
43473 * scenario. */
43474 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43475 * the middle of a write operation? This is a crummy place to do this
43476 * but we want to keep it all in the spinlock.
43477 */
43478 - if (hvcsd->port.count <= 0) {
43479 + if (atomic_read(&hvcsd->port.count) <= 0) {
43480 spin_unlock_irqrestore(&hvcsd->lock, flags);
43481 return -ENODEV;
43482 }
43483 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43484 {
43485 struct hvcs_struct *hvcsd = tty->driver_data;
43486
43487 - if (!hvcsd || hvcsd->port.count <= 0)
43488 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43489 return 0;
43490
43491 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43492 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43493 index 8fd72ff..34a0bed 100644
43494 --- a/drivers/tty/ipwireless/tty.c
43495 +++ b/drivers/tty/ipwireless/tty.c
43496 @@ -29,6 +29,7 @@
43497 #include <linux/tty_driver.h>
43498 #include <linux/tty_flip.h>
43499 #include <linux/uaccess.h>
43500 +#include <asm/local.h>
43501
43502 #include "tty.h"
43503 #include "network.h"
43504 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43505 mutex_unlock(&tty->ipw_tty_mutex);
43506 return -ENODEV;
43507 }
43508 - if (tty->port.count == 0)
43509 + if (atomic_read(&tty->port.count) == 0)
43510 tty->tx_bytes_queued = 0;
43511
43512 - tty->port.count++;
43513 + atomic_inc(&tty->port.count);
43514
43515 tty->port.tty = linux_tty;
43516 linux_tty->driver_data = tty;
43517 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43518
43519 static void do_ipw_close(struct ipw_tty *tty)
43520 {
43521 - tty->port.count--;
43522 -
43523 - if (tty->port.count == 0) {
43524 + if (atomic_dec_return(&tty->port.count) == 0) {
43525 struct tty_struct *linux_tty = tty->port.tty;
43526
43527 if (linux_tty != NULL) {
43528 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43529 return;
43530
43531 mutex_lock(&tty->ipw_tty_mutex);
43532 - if (tty->port.count == 0) {
43533 + if (atomic_read(&tty->port.count) == 0) {
43534 mutex_unlock(&tty->ipw_tty_mutex);
43535 return;
43536 }
43537 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43538
43539 mutex_lock(&tty->ipw_tty_mutex);
43540
43541 - if (!tty->port.count) {
43542 + if (!atomic_read(&tty->port.count)) {
43543 mutex_unlock(&tty->ipw_tty_mutex);
43544 return;
43545 }
43546 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43547 return -ENODEV;
43548
43549 mutex_lock(&tty->ipw_tty_mutex);
43550 - if (!tty->port.count) {
43551 + if (!atomic_read(&tty->port.count)) {
43552 mutex_unlock(&tty->ipw_tty_mutex);
43553 return -EINVAL;
43554 }
43555 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43556 if (!tty)
43557 return -ENODEV;
43558
43559 - if (!tty->port.count)
43560 + if (!atomic_read(&tty->port.count))
43561 return -EINVAL;
43562
43563 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43564 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43565 if (!tty)
43566 return 0;
43567
43568 - if (!tty->port.count)
43569 + if (!atomic_read(&tty->port.count))
43570 return 0;
43571
43572 return tty->tx_bytes_queued;
43573 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43574 if (!tty)
43575 return -ENODEV;
43576
43577 - if (!tty->port.count)
43578 + if (!atomic_read(&tty->port.count))
43579 return -EINVAL;
43580
43581 return get_control_lines(tty);
43582 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43583 if (!tty)
43584 return -ENODEV;
43585
43586 - if (!tty->port.count)
43587 + if (!atomic_read(&tty->port.count))
43588 return -EINVAL;
43589
43590 return set_control_lines(tty, set, clear);
43591 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43592 if (!tty)
43593 return -ENODEV;
43594
43595 - if (!tty->port.count)
43596 + if (!atomic_read(&tty->port.count))
43597 return -EINVAL;
43598
43599 /* FIXME: Exactly how is the tty object locked here .. */
43600 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43601 * are gone */
43602 mutex_lock(&ttyj->ipw_tty_mutex);
43603 }
43604 - while (ttyj->port.count)
43605 + while (atomic_read(&ttyj->port.count))
43606 do_ipw_close(ttyj);
43607 ipwireless_disassociate_network_ttys(network,
43608 ttyj->channel_idx);
43609 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43610 index 1deaca4..c8582d4 100644
43611 --- a/drivers/tty/moxa.c
43612 +++ b/drivers/tty/moxa.c
43613 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43614 }
43615
43616 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43617 - ch->port.count++;
43618 + atomic_inc(&ch->port.count);
43619 tty->driver_data = ch;
43620 tty_port_tty_set(&ch->port, tty);
43621 mutex_lock(&ch->port.mutex);
43622 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43623 index 6422390..49003ac8 100644
43624 --- a/drivers/tty/n_gsm.c
43625 +++ b/drivers/tty/n_gsm.c
43626 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43627 spin_lock_init(&dlci->lock);
43628 mutex_init(&dlci->mutex);
43629 dlci->fifo = &dlci->_fifo;
43630 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43631 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43632 kfree(dlci);
43633 return NULL;
43634 }
43635 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43636 struct gsm_dlci *dlci = tty->driver_data;
43637 struct tty_port *port = &dlci->port;
43638
43639 - port->count++;
43640 + atomic_inc(&port->count);
43641 dlci_get(dlci);
43642 dlci_get(dlci->gsm->dlci[0]);
43643 mux_get(dlci->gsm);
43644 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43645 index 6c7fe90..9241dab 100644
43646 --- a/drivers/tty/n_tty.c
43647 +++ b/drivers/tty/n_tty.c
43648 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43649 {
43650 *ops = tty_ldisc_N_TTY;
43651 ops->owner = NULL;
43652 - ops->refcount = ops->flags = 0;
43653 + atomic_set(&ops->refcount, 0);
43654 + ops->flags = 0;
43655 }
43656 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43657 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43658 index abfd990..5ab5da9 100644
43659 --- a/drivers/tty/pty.c
43660 +++ b/drivers/tty/pty.c
43661 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
43662 panic("Couldn't register Unix98 pts driver");
43663
43664 /* Now create the /dev/ptmx special device */
43665 + pax_open_kernel();
43666 tty_default_fops(&ptmx_fops);
43667 - ptmx_fops.open = ptmx_open;
43668 + *(void **)&ptmx_fops.open = ptmx_open;
43669 + pax_close_kernel();
43670
43671 cdev_init(&ptmx_cdev, &ptmx_fops);
43672 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43673 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43674 index 354564e..fe50d9a 100644
43675 --- a/drivers/tty/rocket.c
43676 +++ b/drivers/tty/rocket.c
43677 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43678 tty->driver_data = info;
43679 tty_port_tty_set(port, tty);
43680
43681 - if (port->count++ == 0) {
43682 + if (atomic_inc_return(&port->count) == 1) {
43683 atomic_inc(&rp_num_ports_open);
43684
43685 #ifdef ROCKET_DEBUG_OPEN
43686 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43687 #endif
43688 }
43689 #ifdef ROCKET_DEBUG_OPEN
43690 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43691 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43692 #endif
43693
43694 /*
43695 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
43696 spin_unlock_irqrestore(&info->port.lock, flags);
43697 return;
43698 }
43699 - if (info->port.count)
43700 + if (atomic_read(&info->port.count))
43701 atomic_dec(&rp_num_ports_open);
43702 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43703 spin_unlock_irqrestore(&info->port.lock, flags);
43704 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43705 index 1002054..dd644a8 100644
43706 --- a/drivers/tty/serial/kgdboc.c
43707 +++ b/drivers/tty/serial/kgdboc.c
43708 @@ -24,8 +24,9 @@
43709 #define MAX_CONFIG_LEN 40
43710
43711 static struct kgdb_io kgdboc_io_ops;
43712 +static struct kgdb_io kgdboc_io_ops_console;
43713
43714 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43715 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43716 static int configured = -1;
43717
43718 static char config[MAX_CONFIG_LEN];
43719 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43720 kgdboc_unregister_kbd();
43721 if (configured == 1)
43722 kgdb_unregister_io_module(&kgdboc_io_ops);
43723 + else if (configured == 2)
43724 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43725 }
43726
43727 static int configure_kgdboc(void)
43728 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43729 int err;
43730 char *cptr = config;
43731 struct console *cons;
43732 + int is_console = 0;
43733
43734 err = kgdboc_option_setup(config);
43735 if (err || !strlen(config) || isspace(config[0]))
43736 goto noconfig;
43737
43738 err = -ENODEV;
43739 - kgdboc_io_ops.is_console = 0;
43740 kgdb_tty_driver = NULL;
43741
43742 kgdboc_use_kms = 0;
43743 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43744 int idx;
43745 if (cons->device && cons->device(cons, &idx) == p &&
43746 idx == tty_line) {
43747 - kgdboc_io_ops.is_console = 1;
43748 + is_console = 1;
43749 break;
43750 }
43751 cons = cons->next;
43752 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43753 kgdb_tty_line = tty_line;
43754
43755 do_register:
43756 - err = kgdb_register_io_module(&kgdboc_io_ops);
43757 + if (is_console) {
43758 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43759 + configured = 2;
43760 + } else {
43761 + err = kgdb_register_io_module(&kgdboc_io_ops);
43762 + configured = 1;
43763 + }
43764 if (err)
43765 goto noconfig;
43766
43767 @@ -205,8 +214,6 @@ do_register:
43768 if (err)
43769 goto nmi_con_failed;
43770
43771 - configured = 1;
43772 -
43773 return 0;
43774
43775 nmi_con_failed:
43776 @@ -223,7 +230,7 @@ noconfig:
43777 static int __init init_kgdboc(void)
43778 {
43779 /* Already configured? */
43780 - if (configured == 1)
43781 + if (configured >= 1)
43782 return 0;
43783
43784 return configure_kgdboc();
43785 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43786 if (config[len - 1] == '\n')
43787 config[len - 1] = '\0';
43788
43789 - if (configured == 1)
43790 + if (configured >= 1)
43791 cleanup_kgdboc();
43792
43793 /* Go and configure with the new params. */
43794 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43795 .post_exception = kgdboc_post_exp_handler,
43796 };
43797
43798 +static struct kgdb_io kgdboc_io_ops_console = {
43799 + .name = "kgdboc",
43800 + .read_char = kgdboc_get_char,
43801 + .write_char = kgdboc_put_char,
43802 + .pre_exception = kgdboc_pre_exp_handler,
43803 + .post_exception = kgdboc_post_exp_handler,
43804 + .is_console = 1
43805 +};
43806 +
43807 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43808 /* This is only available if kgdboc is a built in for early debugging */
43809 static int __init kgdboc_early_init(char *opt)
43810 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43811 index 0c8a9fa..234a95f 100644
43812 --- a/drivers/tty/serial/samsung.c
43813 +++ b/drivers/tty/serial/samsung.c
43814 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43815 }
43816 }
43817
43818 +static int s3c64xx_serial_startup(struct uart_port *port);
43819 static int s3c24xx_serial_startup(struct uart_port *port)
43820 {
43821 struct s3c24xx_uart_port *ourport = to_ourport(port);
43822 int ret;
43823
43824 + /* Startup sequence is different for s3c64xx and higher SoC's */
43825 + if (s3c24xx_serial_has_interrupt_mask(port))
43826 + return s3c64xx_serial_startup(port);
43827 +
43828 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43829 port->mapbase, port->membase);
43830
43831 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43832 /* setup info for port */
43833 port->dev = &platdev->dev;
43834
43835 - /* Startup sequence is different for s3c64xx and higher SoC's */
43836 - if (s3c24xx_serial_has_interrupt_mask(port))
43837 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43838 -
43839 port->uartclk = 1;
43840
43841 if (cfg->uart_flags & UPF_CONS_FLOW) {
43842 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43843 index f87dbfd..42ad4b1 100644
43844 --- a/drivers/tty/serial/serial_core.c
43845 +++ b/drivers/tty/serial/serial_core.c
43846 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43847 uart_flush_buffer(tty);
43848 uart_shutdown(tty, state);
43849 spin_lock_irqsave(&port->lock, flags);
43850 - port->count = 0;
43851 + atomic_set(&port->count, 0);
43852 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43853 spin_unlock_irqrestore(&port->lock, flags);
43854 tty_port_tty_set(port, NULL);
43855 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43856 goto end;
43857 }
43858
43859 - port->count++;
43860 + atomic_inc(&port->count);
43861 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43862 retval = -ENXIO;
43863 goto err_dec_count;
43864 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43865 /*
43866 * Make sure the device is in D0 state.
43867 */
43868 - if (port->count == 1)
43869 + if (atomic_read(&port->count) == 1)
43870 uart_change_pm(state, UART_PM_STATE_ON);
43871
43872 /*
43873 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43874 end:
43875 return retval;
43876 err_dec_count:
43877 - port->count--;
43878 + atomic_inc(&port->count);
43879 mutex_unlock(&port->mutex);
43880 goto end;
43881 }
43882 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43883 index 8eaf1ab..85c030d 100644
43884 --- a/drivers/tty/synclink.c
43885 +++ b/drivers/tty/synclink.c
43886 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43887
43888 if (debug_level >= DEBUG_LEVEL_INFO)
43889 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43890 - __FILE__,__LINE__, info->device_name, info->port.count);
43891 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43892
43893 if (tty_port_close_start(&info->port, tty, filp) == 0)
43894 goto cleanup;
43895 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43896 cleanup:
43897 if (debug_level >= DEBUG_LEVEL_INFO)
43898 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43899 - tty->driver->name, info->port.count);
43900 + tty->driver->name, atomic_read(&info->port.count));
43901
43902 } /* end of mgsl_close() */
43903
43904 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43905
43906 mgsl_flush_buffer(tty);
43907 shutdown(info);
43908 -
43909 - info->port.count = 0;
43910 +
43911 + atomic_set(&info->port.count, 0);
43912 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43913 info->port.tty = NULL;
43914
43915 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43916
43917 if (debug_level >= DEBUG_LEVEL_INFO)
43918 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43919 - __FILE__,__LINE__, tty->driver->name, port->count );
43920 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43921
43922 spin_lock_irqsave(&info->irq_spinlock, flags);
43923 if (!tty_hung_up_p(filp)) {
43924 extra_count = true;
43925 - port->count--;
43926 + atomic_dec(&port->count);
43927 }
43928 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43929 port->blocked_open++;
43930 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43931
43932 if (debug_level >= DEBUG_LEVEL_INFO)
43933 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43934 - __FILE__,__LINE__, tty->driver->name, port->count );
43935 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43936
43937 tty_unlock(tty);
43938 schedule();
43939 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43940
43941 /* FIXME: Racy on hangup during close wait */
43942 if (extra_count)
43943 - port->count++;
43944 + atomic_inc(&port->count);
43945 port->blocked_open--;
43946
43947 if (debug_level >= DEBUG_LEVEL_INFO)
43948 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43949 - __FILE__,__LINE__, tty->driver->name, port->count );
43950 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43951
43952 if (!retval)
43953 port->flags |= ASYNC_NORMAL_ACTIVE;
43954 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43955
43956 if (debug_level >= DEBUG_LEVEL_INFO)
43957 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43958 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43959 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43960
43961 /* If port is closing, signal caller to try again */
43962 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43963 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43964 spin_unlock_irqrestore(&info->netlock, flags);
43965 goto cleanup;
43966 }
43967 - info->port.count++;
43968 + atomic_inc(&info->port.count);
43969 spin_unlock_irqrestore(&info->netlock, flags);
43970
43971 - if (info->port.count == 1) {
43972 + if (atomic_read(&info->port.count) == 1) {
43973 /* 1st open on this device, init hardware */
43974 retval = startup(info);
43975 if (retval < 0)
43976 @@ -3446,8 +3446,8 @@ cleanup:
43977 if (retval) {
43978 if (tty->count == 1)
43979 info->port.tty = NULL; /* tty layer will release tty struct */
43980 - if(info->port.count)
43981 - info->port.count--;
43982 + if (atomic_read(&info->port.count))
43983 + atomic_dec(&info->port.count);
43984 }
43985
43986 return retval;
43987 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43988 unsigned short new_crctype;
43989
43990 /* return error if TTY interface open */
43991 - if (info->port.count)
43992 + if (atomic_read(&info->port.count))
43993 return -EBUSY;
43994
43995 switch (encoding)
43996 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
43997
43998 /* arbitrate between network and tty opens */
43999 spin_lock_irqsave(&info->netlock, flags);
44000 - if (info->port.count != 0 || info->netcount != 0) {
44001 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44002 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44003 spin_unlock_irqrestore(&info->netlock, flags);
44004 return -EBUSY;
44005 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44006 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44007
44008 /* return error if TTY interface open */
44009 - if (info->port.count)
44010 + if (atomic_read(&info->port.count))
44011 return -EBUSY;
44012
44013 if (cmd != SIOCWANDEV)
44014 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44015 index 1abf946..1ee34fc 100644
44016 --- a/drivers/tty/synclink_gt.c
44017 +++ b/drivers/tty/synclink_gt.c
44018 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44019 tty->driver_data = info;
44020 info->port.tty = tty;
44021
44022 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44023 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44024
44025 /* If port is closing, signal caller to try again */
44026 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44027 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44028 mutex_unlock(&info->port.mutex);
44029 goto cleanup;
44030 }
44031 - info->port.count++;
44032 + atomic_inc(&info->port.count);
44033 spin_unlock_irqrestore(&info->netlock, flags);
44034
44035 - if (info->port.count == 1) {
44036 + if (atomic_read(&info->port.count) == 1) {
44037 /* 1st open on this device, init hardware */
44038 retval = startup(info);
44039 if (retval < 0) {
44040 @@ -715,8 +715,8 @@ cleanup:
44041 if (retval) {
44042 if (tty->count == 1)
44043 info->port.tty = NULL; /* tty layer will release tty struct */
44044 - if(info->port.count)
44045 - info->port.count--;
44046 + if(atomic_read(&info->port.count))
44047 + atomic_dec(&info->port.count);
44048 }
44049
44050 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44051 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44052
44053 if (sanity_check(info, tty->name, "close"))
44054 return;
44055 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44056 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44057
44058 if (tty_port_close_start(&info->port, tty, filp) == 0)
44059 goto cleanup;
44060 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44061 tty_port_close_end(&info->port, tty);
44062 info->port.tty = NULL;
44063 cleanup:
44064 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44065 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44066 }
44067
44068 static void hangup(struct tty_struct *tty)
44069 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
44070 shutdown(info);
44071
44072 spin_lock_irqsave(&info->port.lock, flags);
44073 - info->port.count = 0;
44074 + atomic_set(&info->port.count, 0);
44075 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44076 info->port.tty = NULL;
44077 spin_unlock_irqrestore(&info->port.lock, flags);
44078 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44079 unsigned short new_crctype;
44080
44081 /* return error if TTY interface open */
44082 - if (info->port.count)
44083 + if (atomic_read(&info->port.count))
44084 return -EBUSY;
44085
44086 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44087 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
44088
44089 /* arbitrate between network and tty opens */
44090 spin_lock_irqsave(&info->netlock, flags);
44091 - if (info->port.count != 0 || info->netcount != 0) {
44092 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44093 DBGINFO(("%s hdlc_open busy\n", dev->name));
44094 spin_unlock_irqrestore(&info->netlock, flags);
44095 return -EBUSY;
44096 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44097 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44098
44099 /* return error if TTY interface open */
44100 - if (info->port.count)
44101 + if (atomic_read(&info->port.count))
44102 return -EBUSY;
44103
44104 if (cmd != SIOCWANDEV)
44105 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44106 if (port == NULL)
44107 continue;
44108 spin_lock(&port->lock);
44109 - if ((port->port.count || port->netcount) &&
44110 + if ((atomic_read(&port->port.count) || port->netcount) &&
44111 port->pending_bh && !port->bh_running &&
44112 !port->bh_requested) {
44113 DBGISR(("%s bh queued\n", port->device_name));
44114 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44115 spin_lock_irqsave(&info->lock, flags);
44116 if (!tty_hung_up_p(filp)) {
44117 extra_count = true;
44118 - port->count--;
44119 + atomic_dec(&port->count);
44120 }
44121 spin_unlock_irqrestore(&info->lock, flags);
44122 port->blocked_open++;
44123 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44124 remove_wait_queue(&port->open_wait, &wait);
44125
44126 if (extra_count)
44127 - port->count++;
44128 + atomic_inc(&port->count);
44129 port->blocked_open--;
44130
44131 if (!retval)
44132 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44133 index ff17138..e38b41e 100644
44134 --- a/drivers/tty/synclinkmp.c
44135 +++ b/drivers/tty/synclinkmp.c
44136 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44137
44138 if (debug_level >= DEBUG_LEVEL_INFO)
44139 printk("%s(%d):%s open(), old ref count = %d\n",
44140 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44141 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44142
44143 /* If port is closing, signal caller to try again */
44144 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44145 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44146 spin_unlock_irqrestore(&info->netlock, flags);
44147 goto cleanup;
44148 }
44149 - info->port.count++;
44150 + atomic_inc(&info->port.count);
44151 spin_unlock_irqrestore(&info->netlock, flags);
44152
44153 - if (info->port.count == 1) {
44154 + if (atomic_read(&info->port.count) == 1) {
44155 /* 1st open on this device, init hardware */
44156 retval = startup(info);
44157 if (retval < 0)
44158 @@ -796,8 +796,8 @@ cleanup:
44159 if (retval) {
44160 if (tty->count == 1)
44161 info->port.tty = NULL; /* tty layer will release tty struct */
44162 - if(info->port.count)
44163 - info->port.count--;
44164 + if(atomic_read(&info->port.count))
44165 + atomic_dec(&info->port.count);
44166 }
44167
44168 return retval;
44169 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44170
44171 if (debug_level >= DEBUG_LEVEL_INFO)
44172 printk("%s(%d):%s close() entry, count=%d\n",
44173 - __FILE__,__LINE__, info->device_name, info->port.count);
44174 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44175
44176 if (tty_port_close_start(&info->port, tty, filp) == 0)
44177 goto cleanup;
44178 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44179 cleanup:
44180 if (debug_level >= DEBUG_LEVEL_INFO)
44181 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44182 - tty->driver->name, info->port.count);
44183 + tty->driver->name, atomic_read(&info->port.count));
44184 }
44185
44186 /* Called by tty_hangup() when a hangup is signaled.
44187 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44188 shutdown(info);
44189
44190 spin_lock_irqsave(&info->port.lock, flags);
44191 - info->port.count = 0;
44192 + atomic_set(&info->port.count, 0);
44193 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44194 info->port.tty = NULL;
44195 spin_unlock_irqrestore(&info->port.lock, flags);
44196 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44197 unsigned short new_crctype;
44198
44199 /* return error if TTY interface open */
44200 - if (info->port.count)
44201 + if (atomic_read(&info->port.count))
44202 return -EBUSY;
44203
44204 switch (encoding)
44205 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44206
44207 /* arbitrate between network and tty opens */
44208 spin_lock_irqsave(&info->netlock, flags);
44209 - if (info->port.count != 0 || info->netcount != 0) {
44210 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44211 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44212 spin_unlock_irqrestore(&info->netlock, flags);
44213 return -EBUSY;
44214 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44215 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44216
44217 /* return error if TTY interface open */
44218 - if (info->port.count)
44219 + if (atomic_read(&info->port.count))
44220 return -EBUSY;
44221
44222 if (cmd != SIOCWANDEV)
44223 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44224 * do not request bottom half processing if the
44225 * device is not open in a normal mode.
44226 */
44227 - if ( port && (port->port.count || port->netcount) &&
44228 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44229 port->pending_bh && !port->bh_running &&
44230 !port->bh_requested ) {
44231 if ( debug_level >= DEBUG_LEVEL_ISR )
44232 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44233
44234 if (debug_level >= DEBUG_LEVEL_INFO)
44235 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44236 - __FILE__,__LINE__, tty->driver->name, port->count );
44237 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44238
44239 spin_lock_irqsave(&info->lock, flags);
44240 if (!tty_hung_up_p(filp)) {
44241 extra_count = true;
44242 - port->count--;
44243 + atomic_dec(&port->count);
44244 }
44245 spin_unlock_irqrestore(&info->lock, flags);
44246 port->blocked_open++;
44247 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44248
44249 if (debug_level >= DEBUG_LEVEL_INFO)
44250 printk("%s(%d):%s block_til_ready() count=%d\n",
44251 - __FILE__,__LINE__, tty->driver->name, port->count );
44252 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44253
44254 tty_unlock(tty);
44255 schedule();
44256 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44257 remove_wait_queue(&port->open_wait, &wait);
44258
44259 if (extra_count)
44260 - port->count++;
44261 + atomic_inc(&port->count);
44262 port->blocked_open--;
44263
44264 if (debug_level >= DEBUG_LEVEL_INFO)
44265 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44266 - __FILE__,__LINE__, tty->driver->name, port->count );
44267 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44268
44269 if (!retval)
44270 port->flags |= ASYNC_NORMAL_ACTIVE;
44271 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44272 index b51c154..17d55d1 100644
44273 --- a/drivers/tty/sysrq.c
44274 +++ b/drivers/tty/sysrq.c
44275 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44276 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44277 size_t count, loff_t *ppos)
44278 {
44279 - if (count) {
44280 + if (count && capable(CAP_SYS_ADMIN)) {
44281 char c;
44282
44283 if (get_user(c, buf))
44284 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44285 index 6464029..9ff6738 100644
44286 --- a/drivers/tty/tty_io.c
44287 +++ b/drivers/tty/tty_io.c
44288 @@ -3464,7 +3464,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44289
44290 void tty_default_fops(struct file_operations *fops)
44291 {
44292 - *fops = tty_fops;
44293 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44294 }
44295
44296 /*
44297 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44298 index 1afe192..73d2c20 100644
44299 --- a/drivers/tty/tty_ldisc.c
44300 +++ b/drivers/tty/tty_ldisc.c
44301 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44302 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44303 tty_ldiscs[disc] = new_ldisc;
44304 new_ldisc->num = disc;
44305 - new_ldisc->refcount = 0;
44306 + atomic_set(&new_ldisc->refcount, 0);
44307 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44308
44309 return ret;
44310 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
44311 return -EINVAL;
44312
44313 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44314 - if (tty_ldiscs[disc]->refcount)
44315 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44316 ret = -EBUSY;
44317 else
44318 tty_ldiscs[disc] = NULL;
44319 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44320 if (ldops) {
44321 ret = ERR_PTR(-EAGAIN);
44322 if (try_module_get(ldops->owner)) {
44323 - ldops->refcount++;
44324 + atomic_inc(&ldops->refcount);
44325 ret = ldops;
44326 }
44327 }
44328 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44329 unsigned long flags;
44330
44331 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44332 - ldops->refcount--;
44333 + atomic_dec(&ldops->refcount);
44334 module_put(ldops->owner);
44335 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44336 }
44337 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
44338 /* unreleased reader reference(s) will cause this WARN */
44339 WARN_ON(!atomic_dec_and_test(&ld->users));
44340
44341 - ld->ops->refcount--;
44342 + atomic_dec(&ld->ops->refcount);
44343 module_put(ld->ops->owner);
44344 kfree(ld);
44345 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44346 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44347 index 121aeb9..0d2c4b9 100644
44348 --- a/drivers/tty/tty_port.c
44349 +++ b/drivers/tty/tty_port.c
44350 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
44351 unsigned long flags;
44352
44353 spin_lock_irqsave(&port->lock, flags);
44354 - port->count = 0;
44355 + atomic_set(&port->count, 0);
44356 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44357 tty = port->tty;
44358 if (tty)
44359 @@ -391,7 +391,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44360 /* The port lock protects the port counts */
44361 spin_lock_irqsave(&port->lock, flags);
44362 if (!tty_hung_up_p(filp))
44363 - port->count--;
44364 + atomic_dec(&port->count);
44365 port->blocked_open++;
44366 spin_unlock_irqrestore(&port->lock, flags);
44367
44368 @@ -433,7 +433,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44369 we must not mess that up further */
44370 spin_lock_irqsave(&port->lock, flags);
44371 if (!tty_hung_up_p(filp))
44372 - port->count++;
44373 + atomic_inc(&port->count);
44374 port->blocked_open--;
44375 if (retval == 0)
44376 port->flags |= ASYNC_NORMAL_ACTIVE;
44377 @@ -467,19 +467,19 @@ int tty_port_close_start(struct tty_port *port,
44378 return 0;
44379 }
44380
44381 - if (tty->count == 1 && port->count != 1) {
44382 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44383 printk(KERN_WARNING
44384 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44385 - port->count);
44386 - port->count = 1;
44387 + atomic_read(&port->count));
44388 + atomic_set(&port->count, 1);
44389 }
44390 - if (--port->count < 0) {
44391 + if (atomic_dec_return(&port->count) < 0) {
44392 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44393 - port->count);
44394 - port->count = 0;
44395 + atomic_read(&port->count));
44396 + atomic_set(&port->count, 0);
44397 }
44398
44399 - if (port->count) {
44400 + if (atomic_read(&port->count)) {
44401 spin_unlock_irqrestore(&port->lock, flags);
44402 if (port->ops->drop)
44403 port->ops->drop(port);
44404 @@ -565,7 +565,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44405 {
44406 spin_lock_irq(&port->lock);
44407 if (!tty_hung_up_p(filp))
44408 - ++port->count;
44409 + atomic_inc(&port->count);
44410 spin_unlock_irq(&port->lock);
44411 tty_port_tty_set(port, tty);
44412
44413 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44414 index a9af1b9a..1e08e7f 100644
44415 --- a/drivers/tty/vt/keyboard.c
44416 +++ b/drivers/tty/vt/keyboard.c
44417 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44418 kbd->kbdmode == VC_OFF) &&
44419 value != KVAL(K_SAK))
44420 return; /* SAK is allowed even in raw mode */
44421 +
44422 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44423 + {
44424 + void *func = fn_handler[value];
44425 + if (func == fn_show_state || func == fn_show_ptregs ||
44426 + func == fn_show_mem)
44427 + return;
44428 + }
44429 +#endif
44430 +
44431 fn_handler[value](vc);
44432 }
44433
44434 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44435 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44436 return -EFAULT;
44437
44438 - if (!capable(CAP_SYS_TTY_CONFIG))
44439 - perm = 0;
44440 -
44441 switch (cmd) {
44442 case KDGKBENT:
44443 /* Ensure another thread doesn't free it under us */
44444 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44445 spin_unlock_irqrestore(&kbd_event_lock, flags);
44446 return put_user(val, &user_kbe->kb_value);
44447 case KDSKBENT:
44448 + if (!capable(CAP_SYS_TTY_CONFIG))
44449 + perm = 0;
44450 +
44451 if (!perm)
44452 return -EPERM;
44453 if (!i && v == K_NOSUCHMAP) {
44454 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44455 int i, j, k;
44456 int ret;
44457
44458 - if (!capable(CAP_SYS_TTY_CONFIG))
44459 - perm = 0;
44460 -
44461 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44462 if (!kbs) {
44463 ret = -ENOMEM;
44464 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44465 kfree(kbs);
44466 return ((p && *p) ? -EOVERFLOW : 0);
44467 case KDSKBSENT:
44468 + if (!capable(CAP_SYS_TTY_CONFIG))
44469 + perm = 0;
44470 +
44471 if (!perm) {
44472 ret = -EPERM;
44473 goto reterr;
44474 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44475 index b645c47..a55c182 100644
44476 --- a/drivers/uio/uio.c
44477 +++ b/drivers/uio/uio.c
44478 @@ -25,6 +25,7 @@
44479 #include <linux/kobject.h>
44480 #include <linux/cdev.h>
44481 #include <linux/uio_driver.h>
44482 +#include <asm/local.h>
44483
44484 #define UIO_MAX_DEVICES (1U << MINORBITS)
44485
44486 @@ -32,10 +33,10 @@ struct uio_device {
44487 struct module *owner;
44488 struct device *dev;
44489 int minor;
44490 - atomic_t event;
44491 + atomic_unchecked_t event;
44492 struct fasync_struct *async_queue;
44493 wait_queue_head_t wait;
44494 - int vma_count;
44495 + local_t vma_count;
44496 struct uio_info *info;
44497 struct kobject *map_dir;
44498 struct kobject *portio_dir;
44499 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44500 struct device_attribute *attr, char *buf)
44501 {
44502 struct uio_device *idev = dev_get_drvdata(dev);
44503 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44504 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44505 }
44506
44507 static struct device_attribute uio_class_attributes[] = {
44508 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44509 {
44510 struct uio_device *idev = info->uio_dev;
44511
44512 - atomic_inc(&idev->event);
44513 + atomic_inc_unchecked(&idev->event);
44514 wake_up_interruptible(&idev->wait);
44515 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44516 }
44517 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44518 }
44519
44520 listener->dev = idev;
44521 - listener->event_count = atomic_read(&idev->event);
44522 + listener->event_count = atomic_read_unchecked(&idev->event);
44523 filep->private_data = listener;
44524
44525 if (idev->info->open) {
44526 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44527 return -EIO;
44528
44529 poll_wait(filep, &idev->wait, wait);
44530 - if (listener->event_count != atomic_read(&idev->event))
44531 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44532 return POLLIN | POLLRDNORM;
44533 return 0;
44534 }
44535 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44536 do {
44537 set_current_state(TASK_INTERRUPTIBLE);
44538
44539 - event_count = atomic_read(&idev->event);
44540 + event_count = atomic_read_unchecked(&idev->event);
44541 if (event_count != listener->event_count) {
44542 if (copy_to_user(buf, &event_count, count))
44543 retval = -EFAULT;
44544 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44545 static void uio_vma_open(struct vm_area_struct *vma)
44546 {
44547 struct uio_device *idev = vma->vm_private_data;
44548 - idev->vma_count++;
44549 + local_inc(&idev->vma_count);
44550 }
44551
44552 static void uio_vma_close(struct vm_area_struct *vma)
44553 {
44554 struct uio_device *idev = vma->vm_private_data;
44555 - idev->vma_count--;
44556 + local_dec(&idev->vma_count);
44557 }
44558
44559 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44560 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44561 idev->owner = owner;
44562 idev->info = info;
44563 init_waitqueue_head(&idev->wait);
44564 - atomic_set(&idev->event, 0);
44565 + atomic_set_unchecked(&idev->event, 0);
44566
44567 ret = uio_get_minor(idev);
44568 if (ret)
44569 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44570 index 8a7eb77..c00402f 100644
44571 --- a/drivers/usb/atm/cxacru.c
44572 +++ b/drivers/usb/atm/cxacru.c
44573 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44574 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44575 if (ret < 2)
44576 return -EINVAL;
44577 - if (index < 0 || index > 0x7f)
44578 + if (index > 0x7f)
44579 return -EINVAL;
44580 pos += tmp;
44581
44582 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44583 index d3527dd..26effa2 100644
44584 --- a/drivers/usb/atm/usbatm.c
44585 +++ b/drivers/usb/atm/usbatm.c
44586 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44587 if (printk_ratelimit())
44588 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44589 __func__, vpi, vci);
44590 - atomic_inc(&vcc->stats->rx_err);
44591 + atomic_inc_unchecked(&vcc->stats->rx_err);
44592 return;
44593 }
44594
44595 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44596 if (length > ATM_MAX_AAL5_PDU) {
44597 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44598 __func__, length, vcc);
44599 - atomic_inc(&vcc->stats->rx_err);
44600 + atomic_inc_unchecked(&vcc->stats->rx_err);
44601 goto out;
44602 }
44603
44604 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44605 if (sarb->len < pdu_length) {
44606 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44607 __func__, pdu_length, sarb->len, vcc);
44608 - atomic_inc(&vcc->stats->rx_err);
44609 + atomic_inc_unchecked(&vcc->stats->rx_err);
44610 goto out;
44611 }
44612
44613 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44614 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44615 __func__, vcc);
44616 - atomic_inc(&vcc->stats->rx_err);
44617 + atomic_inc_unchecked(&vcc->stats->rx_err);
44618 goto out;
44619 }
44620
44621 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44622 if (printk_ratelimit())
44623 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44624 __func__, length);
44625 - atomic_inc(&vcc->stats->rx_drop);
44626 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44627 goto out;
44628 }
44629
44630 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44631
44632 vcc->push(vcc, skb);
44633
44634 - atomic_inc(&vcc->stats->rx);
44635 + atomic_inc_unchecked(&vcc->stats->rx);
44636 out:
44637 skb_trim(sarb, 0);
44638 }
44639 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44640 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44641
44642 usbatm_pop(vcc, skb);
44643 - atomic_inc(&vcc->stats->tx);
44644 + atomic_inc_unchecked(&vcc->stats->tx);
44645
44646 skb = skb_dequeue(&instance->sndqueue);
44647 }
44648 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44649 if (!left--)
44650 return sprintf(page,
44651 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44652 - atomic_read(&atm_dev->stats.aal5.tx),
44653 - atomic_read(&atm_dev->stats.aal5.tx_err),
44654 - atomic_read(&atm_dev->stats.aal5.rx),
44655 - atomic_read(&atm_dev->stats.aal5.rx_err),
44656 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44657 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44658 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44659 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44660 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44661 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44662
44663 if (!left--) {
44664 if (instance->disconnected)
44665 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44666 index 2a3bbdf..91d72cf 100644
44667 --- a/drivers/usb/core/devices.c
44668 +++ b/drivers/usb/core/devices.c
44669 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44670 * time it gets called.
44671 */
44672 static struct device_connect_event {
44673 - atomic_t count;
44674 + atomic_unchecked_t count;
44675 wait_queue_head_t wait;
44676 } device_event = {
44677 .count = ATOMIC_INIT(1),
44678 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44679
44680 void usbfs_conn_disc_event(void)
44681 {
44682 - atomic_add(2, &device_event.count);
44683 + atomic_add_unchecked(2, &device_event.count);
44684 wake_up(&device_event.wait);
44685 }
44686
44687 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44688
44689 poll_wait(file, &device_event.wait, wait);
44690
44691 - event_count = atomic_read(&device_event.count);
44692 + event_count = atomic_read_unchecked(&device_event.count);
44693 if (file->f_version != event_count) {
44694 file->f_version = event_count;
44695 return POLLIN | POLLRDNORM;
44696 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44697 index d53547d..6a22d02 100644
44698 --- a/drivers/usb/core/hcd.c
44699 +++ b/drivers/usb/core/hcd.c
44700 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44701 */
44702 usb_get_urb(urb);
44703 atomic_inc(&urb->use_count);
44704 - atomic_inc(&urb->dev->urbnum);
44705 + atomic_inc_unchecked(&urb->dev->urbnum);
44706 usbmon_urb_submit(&hcd->self, urb);
44707
44708 /* NOTE requirements on root-hub callers (usbfs and the hub
44709 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44710 urb->hcpriv = NULL;
44711 INIT_LIST_HEAD(&urb->urb_list);
44712 atomic_dec(&urb->use_count);
44713 - atomic_dec(&urb->dev->urbnum);
44714 + atomic_dec_unchecked(&urb->dev->urbnum);
44715 if (atomic_read(&urb->reject))
44716 wake_up(&usb_kill_urb_queue);
44717 usb_put_urb(urb);
44718 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44719 index 444d30e..f15c850 100644
44720 --- a/drivers/usb/core/message.c
44721 +++ b/drivers/usb/core/message.c
44722 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44723 * method can wait for it to complete. Since you don't have a handle on the
44724 * URB used, you can't cancel the request.
44725 */
44726 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44727 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44728 __u8 requesttype, __u16 value, __u16 index, void *data,
44729 __u16 size, int timeout)
44730 {
44731 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44732 index aa38db4..0a08682 100644
44733 --- a/drivers/usb/core/sysfs.c
44734 +++ b/drivers/usb/core/sysfs.c
44735 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44736 struct usb_device *udev;
44737
44738 udev = to_usb_device(dev);
44739 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44740 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44741 }
44742 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44743
44744 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44745 index b10da72..43aa0b2 100644
44746 --- a/drivers/usb/core/usb.c
44747 +++ b/drivers/usb/core/usb.c
44748 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44749 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44750 dev->state = USB_STATE_ATTACHED;
44751 dev->lpm_disable_count = 1;
44752 - atomic_set(&dev->urbnum, 0);
44753 + atomic_set_unchecked(&dev->urbnum, 0);
44754
44755 INIT_LIST_HEAD(&dev->ep0.urb_list);
44756 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44757 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44758 index 5e29dde..eca992f 100644
44759 --- a/drivers/usb/early/ehci-dbgp.c
44760 +++ b/drivers/usb/early/ehci-dbgp.c
44761 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44762
44763 #ifdef CONFIG_KGDB
44764 static struct kgdb_io kgdbdbgp_io_ops;
44765 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44766 +static struct kgdb_io kgdbdbgp_io_ops_console;
44767 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44768 #else
44769 #define dbgp_kgdb_mode (0)
44770 #endif
44771 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44772 .write_char = kgdbdbgp_write_char,
44773 };
44774
44775 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44776 + .name = "kgdbdbgp",
44777 + .read_char = kgdbdbgp_read_char,
44778 + .write_char = kgdbdbgp_write_char,
44779 + .is_console = 1
44780 +};
44781 +
44782 static int kgdbdbgp_wait_time;
44783
44784 static int __init kgdbdbgp_parse_config(char *str)
44785 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44786 ptr++;
44787 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44788 }
44789 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44790 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44791 + if (early_dbgp_console.index != -1)
44792 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44793 + else
44794 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44795
44796 return 0;
44797 }
44798 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44799 index b369292..9f3ba40 100644
44800 --- a/drivers/usb/gadget/u_serial.c
44801 +++ b/drivers/usb/gadget/u_serial.c
44802 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44803 spin_lock_irq(&port->port_lock);
44804
44805 /* already open? Great. */
44806 - if (port->port.count) {
44807 + if (atomic_read(&port->port.count)) {
44808 status = 0;
44809 - port->port.count++;
44810 + atomic_inc(&port->port.count);
44811
44812 /* currently opening/closing? wait ... */
44813 } else if (port->openclose) {
44814 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44815 tty->driver_data = port;
44816 port->port.tty = tty;
44817
44818 - port->port.count = 1;
44819 + atomic_set(&port->port.count, 1);
44820 port->openclose = false;
44821
44822 /* if connected, start the I/O stream */
44823 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44824
44825 spin_lock_irq(&port->port_lock);
44826
44827 - if (port->port.count != 1) {
44828 - if (port->port.count == 0)
44829 + if (atomic_read(&port->port.count) != 1) {
44830 + if (atomic_read(&port->port.count) == 0)
44831 WARN_ON(1);
44832 else
44833 - --port->port.count;
44834 + atomic_dec(&port->port.count);
44835 goto exit;
44836 }
44837
44838 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44839 * and sleep if necessary
44840 */
44841 port->openclose = true;
44842 - port->port.count = 0;
44843 + atomic_set(&port->port.count, 0);
44844
44845 gser = port->port_usb;
44846 if (gser && gser->disconnect)
44847 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44848 int cond;
44849
44850 spin_lock_irq(&port->port_lock);
44851 - cond = (port->port.count == 0) && !port->openclose;
44852 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44853 spin_unlock_irq(&port->port_lock);
44854 return cond;
44855 }
44856 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44857 /* if it's already open, start I/O ... and notify the serial
44858 * protocol about open/close status (connect/disconnect).
44859 */
44860 - if (port->port.count) {
44861 + if (atomic_read(&port->port.count)) {
44862 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44863 gs_start_io(port);
44864 if (gser->connect)
44865 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44866
44867 port->port_usb = NULL;
44868 gser->ioport = NULL;
44869 - if (port->port.count > 0 || port->openclose) {
44870 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44871 wake_up_interruptible(&port->drain_wait);
44872 if (port->port.tty)
44873 tty_hangup(port->port.tty);
44874 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44875
44876 /* finally, free any unused/unusable I/O buffers */
44877 spin_lock_irqsave(&port->port_lock, flags);
44878 - if (port->port.count == 0 && !port->openclose)
44879 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44880 gs_buf_free(&port->port_write_buf);
44881 gs_free_requests(gser->out, &port->read_pool, NULL);
44882 gs_free_requests(gser->out, &port->read_queue, NULL);
44883 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44884 index 5f3bcd3..bfca43f 100644
44885 --- a/drivers/usb/serial/console.c
44886 +++ b/drivers/usb/serial/console.c
44887 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44888
44889 info->port = port;
44890
44891 - ++port->port.count;
44892 + atomic_inc(&port->port.count);
44893 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44894 if (serial->type->set_termios) {
44895 /*
44896 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44897 }
44898 /* Now that any required fake tty operations are completed restore
44899 * the tty port count */
44900 - --port->port.count;
44901 + atomic_dec(&port->port.count);
44902 /* The console is special in terms of closing the device so
44903 * indicate this port is now acting as a system console. */
44904 port->port.console = 1;
44905 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44906 free_tty:
44907 kfree(tty);
44908 reset_open_count:
44909 - port->port.count = 0;
44910 + atomic_set(&port->port.count, 0);
44911 usb_autopm_put_interface(serial->interface);
44912 error_get_interface:
44913 usb_serial_put(serial);
44914 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44915 index 75f70f0..d467e1a 100644
44916 --- a/drivers/usb/storage/usb.h
44917 +++ b/drivers/usb/storage/usb.h
44918 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44919 __u8 useProtocol;
44920 __u8 useTransport;
44921 int (*initFunction)(struct us_data *);
44922 -};
44923 +} __do_const;
44924
44925
44926 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44927 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44928 index d6bea3e..60b250e 100644
44929 --- a/drivers/usb/wusbcore/wa-hc.h
44930 +++ b/drivers/usb/wusbcore/wa-hc.h
44931 @@ -192,7 +192,7 @@ struct wahc {
44932 struct list_head xfer_delayed_list;
44933 spinlock_t xfer_list_lock;
44934 struct work_struct xfer_work;
44935 - atomic_t xfer_id_count;
44936 + atomic_unchecked_t xfer_id_count;
44937 };
44938
44939
44940 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44941 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44942 spin_lock_init(&wa->xfer_list_lock);
44943 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44944 - atomic_set(&wa->xfer_id_count, 1);
44945 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44946 }
44947
44948 /**
44949 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44950 index 6ef94bc..1b41265 100644
44951 --- a/drivers/usb/wusbcore/wa-xfer.c
44952 +++ b/drivers/usb/wusbcore/wa-xfer.c
44953 @@ -296,7 +296,7 @@ out:
44954 */
44955 static void wa_xfer_id_init(struct wa_xfer *xfer)
44956 {
44957 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44958 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44959 }
44960
44961 /*
44962 diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
44963 index f80d3dd..8ca5ac7 100644
44964 --- a/drivers/vhost/net.c
44965 +++ b/drivers/vhost/net.c
44966 @@ -150,6 +150,11 @@ static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs)
44967 {
44968 kref_put(&ubufs->kref, vhost_net_zerocopy_done_signal);
44969 wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
44970 +}
44971 +
44972 +static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs)
44973 +{
44974 + vhost_net_ubuf_put_and_wait(ubufs);
44975 kfree(ubufs);
44976 }
44977
44978 @@ -948,7 +953,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
44979 mutex_unlock(&vq->mutex);
44980
44981 if (oldubufs) {
44982 - vhost_net_ubuf_put_and_wait(oldubufs);
44983 + vhost_net_ubuf_put_wait_and_free(oldubufs);
44984 mutex_lock(&vq->mutex);
44985 vhost_zerocopy_signal_used(n, vq);
44986 mutex_unlock(&vq->mutex);
44987 @@ -966,7 +971,7 @@ err_used:
44988 rcu_assign_pointer(vq->private_data, oldsock);
44989 vhost_net_enable_vq(n, vq);
44990 if (ubufs)
44991 - vhost_net_ubuf_put_and_wait(ubufs);
44992 + vhost_net_ubuf_put_wait_and_free(ubufs);
44993 err_ubufs:
44994 fput(sock->file);
44995 err_vq:
44996 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
44997 index 5174eba..86e764a 100644
44998 --- a/drivers/vhost/vringh.c
44999 +++ b/drivers/vhost/vringh.c
45000 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
45001
45002 static inline int putu16_kern(u16 *p, u16 val)
45003 {
45004 - ACCESS_ONCE(*p) = val;
45005 + ACCESS_ONCE_RW(*p) = val;
45006 return 0;
45007 }
45008
45009 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45010 index 8c55011..eed4ae1a 100644
45011 --- a/drivers/video/aty/aty128fb.c
45012 +++ b/drivers/video/aty/aty128fb.c
45013 @@ -149,7 +149,7 @@ enum {
45014 };
45015
45016 /* Must match above enum */
45017 -static char * const r128_family[] = {
45018 +static const char * const r128_family[] = {
45019 "AGP",
45020 "PCI",
45021 "PRO AGP",
45022 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45023 index 4f27fdc..d3537e6 100644
45024 --- a/drivers/video/aty/atyfb_base.c
45025 +++ b/drivers/video/aty/atyfb_base.c
45026 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45027 par->accel_flags = var->accel_flags; /* hack */
45028
45029 if (var->accel_flags) {
45030 - info->fbops->fb_sync = atyfb_sync;
45031 + pax_open_kernel();
45032 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45033 + pax_close_kernel();
45034 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45035 } else {
45036 - info->fbops->fb_sync = NULL;
45037 + pax_open_kernel();
45038 + *(void **)&info->fbops->fb_sync = NULL;
45039 + pax_close_kernel();
45040 info->flags |= FBINFO_HWACCEL_DISABLED;
45041 }
45042
45043 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45044 index 95ec042..e6affdd 100644
45045 --- a/drivers/video/aty/mach64_cursor.c
45046 +++ b/drivers/video/aty/mach64_cursor.c
45047 @@ -7,6 +7,7 @@
45048 #include <linux/string.h>
45049
45050 #include <asm/io.h>
45051 +#include <asm/pgtable.h>
45052
45053 #ifdef __sparc__
45054 #include <asm/fbio.h>
45055 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45056 info->sprite.buf_align = 16; /* and 64 lines tall. */
45057 info->sprite.flags = FB_PIXMAP_IO;
45058
45059 - info->fbops->fb_cursor = atyfb_cursor;
45060 + pax_open_kernel();
45061 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45062 + pax_close_kernel();
45063
45064 return 0;
45065 }
45066 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45067 index bca6ccc..252107e 100644
45068 --- a/drivers/video/backlight/kb3886_bl.c
45069 +++ b/drivers/video/backlight/kb3886_bl.c
45070 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45071 static unsigned long kb3886bl_flags;
45072 #define KB3886BL_SUSPENDED 0x01
45073
45074 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45075 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45076 {
45077 .ident = "Sahara Touch-iT",
45078 .matches = {
45079 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45080 index 900aa4e..6d49418 100644
45081 --- a/drivers/video/fb_defio.c
45082 +++ b/drivers/video/fb_defio.c
45083 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45084
45085 BUG_ON(!fbdefio);
45086 mutex_init(&fbdefio->lock);
45087 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45088 + pax_open_kernel();
45089 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45090 + pax_close_kernel();
45091 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45092 INIT_LIST_HEAD(&fbdefio->pagelist);
45093 if (fbdefio->delay == 0) /* set a default of 1 s */
45094 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45095 page->mapping = NULL;
45096 }
45097
45098 - info->fbops->fb_mmap = NULL;
45099 + *(void **)&info->fbops->fb_mmap = NULL;
45100 mutex_destroy(&fbdefio->lock);
45101 }
45102 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45103 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45104 index 5c3960d..15cf8fc 100644
45105 --- a/drivers/video/fbcmap.c
45106 +++ b/drivers/video/fbcmap.c
45107 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45108 rc = -ENODEV;
45109 goto out;
45110 }
45111 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45112 - !info->fbops->fb_setcmap)) {
45113 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45114 rc = -EINVAL;
45115 goto out1;
45116 }
45117 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45118 index 098bfc6..796841d 100644
45119 --- a/drivers/video/fbmem.c
45120 +++ b/drivers/video/fbmem.c
45121 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45122 image->dx += image->width + 8;
45123 }
45124 } else if (rotate == FB_ROTATE_UD) {
45125 - for (x = 0; x < num && image->dx >= 0; x++) {
45126 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45127 info->fbops->fb_imageblit(info, image);
45128 image->dx -= image->width + 8;
45129 }
45130 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45131 image->dy += image->height + 8;
45132 }
45133 } else if (rotate == FB_ROTATE_CCW) {
45134 - for (x = 0; x < num && image->dy >= 0; x++) {
45135 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45136 info->fbops->fb_imageblit(info, image);
45137 image->dy -= image->height + 8;
45138 }
45139 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45140 return -EFAULT;
45141 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45142 return -EINVAL;
45143 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45144 + if (con2fb.framebuffer >= FB_MAX)
45145 return -EINVAL;
45146 if (!registered_fb[con2fb.framebuffer])
45147 request_module("fb%d", con2fb.framebuffer);
45148 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45149 index 7672d2e..b56437f 100644
45150 --- a/drivers/video/i810/i810_accel.c
45151 +++ b/drivers/video/i810/i810_accel.c
45152 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45153 }
45154 }
45155 printk("ringbuffer lockup!!!\n");
45156 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45157 i810_report_error(mmio);
45158 par->dev_flags |= LOCKUP;
45159 info->pixmap.scan_align = 1;
45160 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45161 index 3c14e43..eafa544 100644
45162 --- a/drivers/video/logo/logo_linux_clut224.ppm
45163 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45164 @@ -1,1604 +1,1123 @@
45165 P3
45166 -# Standard 224-color Linux logo
45167 80 80
45168 255
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 6 6 6 6 6 6 10 10 10 10 10 10
45179 - 10 10 10 6 6 6 6 6 6 6 6 6
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 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 6 6 6 10 10 10 14 14 14
45198 - 22 22 22 26 26 26 30 30 30 34 34 34
45199 - 30 30 30 30 30 30 26 26 26 18 18 18
45200 - 14 14 14 10 10 10 6 6 6 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 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 1 0 0 1 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 6 6 6 14 14 14 26 26 26 42 42 42
45218 - 54 54 54 66 66 66 78 78 78 78 78 78
45219 - 78 78 78 74 74 74 66 66 66 54 54 54
45220 - 42 42 42 26 26 26 18 18 18 10 10 10
45221 - 6 6 6 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 1 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 10 10 10
45237 - 22 22 22 42 42 42 66 66 66 86 86 86
45238 - 66 66 66 38 38 38 38 38 38 22 22 22
45239 - 26 26 26 34 34 34 54 54 54 66 66 66
45240 - 86 86 86 70 70 70 46 46 46 26 26 26
45241 - 14 14 14 6 6 6 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 1 0 0 1 0 0 1 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 10 10 10 26 26 26
45257 - 50 50 50 82 82 82 58 58 58 6 6 6
45258 - 2 2 6 2 2 6 2 2 6 2 2 6
45259 - 2 2 6 2 2 6 2 2 6 2 2 6
45260 - 6 6 6 54 54 54 86 86 86 66 66 66
45261 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 6 6 6 22 22 22 50 50 50
45277 - 78 78 78 34 34 34 2 2 6 2 2 6
45278 - 2 2 6 2 2 6 2 2 6 2 2 6
45279 - 2 2 6 2 2 6 2 2 6 2 2 6
45280 - 2 2 6 2 2 6 6 6 6 70 70 70
45281 - 78 78 78 46 46 46 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 1 0 0 1 0 0 1 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 6 6 6 18 18 18 42 42 42 82 82 82
45297 - 26 26 26 2 2 6 2 2 6 2 2 6
45298 - 2 2 6 2 2 6 2 2 6 2 2 6
45299 - 2 2 6 2 2 6 2 2 6 14 14 14
45300 - 46 46 46 34 34 34 6 6 6 2 2 6
45301 - 42 42 42 78 78 78 42 42 42 18 18 18
45302 - 6 6 6 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 1 0 0 0 0 0 1 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 10 10 10 30 30 30 66 66 66 58 58 58
45317 - 2 2 6 2 2 6 2 2 6 2 2 6
45318 - 2 2 6 2 2 6 2 2 6 2 2 6
45319 - 2 2 6 2 2 6 2 2 6 26 26 26
45320 - 86 86 86 101 101 101 46 46 46 10 10 10
45321 - 2 2 6 58 58 58 70 70 70 34 34 34
45322 - 10 10 10 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 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 1 0 0 1 0 0 1 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 14 14 14 42 42 42 86 86 86 10 10 10
45337 - 2 2 6 2 2 6 2 2 6 2 2 6
45338 - 2 2 6 2 2 6 2 2 6 2 2 6
45339 - 2 2 6 2 2 6 2 2 6 30 30 30
45340 - 94 94 94 94 94 94 58 58 58 26 26 26
45341 - 2 2 6 6 6 6 78 78 78 54 54 54
45342 - 22 22 22 6 6 6 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 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 6 6 6
45356 - 22 22 22 62 62 62 62 62 62 2 2 6
45357 - 2 2 6 2 2 6 2 2 6 2 2 6
45358 - 2 2 6 2 2 6 2 2 6 2 2 6
45359 - 2 2 6 2 2 6 2 2 6 26 26 26
45360 - 54 54 54 38 38 38 18 18 18 10 10 10
45361 - 2 2 6 2 2 6 34 34 34 82 82 82
45362 - 38 38 38 14 14 14 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 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 1 0 0 1 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 6 6 6
45376 - 30 30 30 78 78 78 30 30 30 2 2 6
45377 - 2 2 6 2 2 6 2 2 6 2 2 6
45378 - 2 2 6 2 2 6 2 2 6 2 2 6
45379 - 2 2 6 2 2 6 2 2 6 10 10 10
45380 - 10 10 10 2 2 6 2 2 6 2 2 6
45381 - 2 2 6 2 2 6 2 2 6 78 78 78
45382 - 50 50 50 18 18 18 6 6 6 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 1 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 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 10 10 10
45396 - 38 38 38 86 86 86 14 14 14 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 2 2 6
45400 - 2 2 6 2 2 6 2 2 6 2 2 6
45401 - 2 2 6 2 2 6 2 2 6 54 54 54
45402 - 66 66 66 26 26 26 6 6 6 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 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 1 0 0 1 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 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 14 14 14
45416 - 42 42 42 82 82 82 2 2 6 2 2 6
45417 - 2 2 6 6 6 6 10 10 10 2 2 6
45418 - 2 2 6 2 2 6 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 2 2 6 6 6 6
45420 - 14 14 14 10 10 10 2 2 6 2 2 6
45421 - 2 2 6 2 2 6 2 2 6 18 18 18
45422 - 82 82 82 34 34 34 10 10 10 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 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 1 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 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 14 14 14
45436 - 46 46 46 86 86 86 2 2 6 2 2 6
45437 - 6 6 6 6 6 6 22 22 22 34 34 34
45438 - 6 6 6 2 2 6 2 2 6 2 2 6
45439 - 2 2 6 2 2 6 18 18 18 34 34 34
45440 - 10 10 10 50 50 50 22 22 22 2 2 6
45441 - 2 2 6 2 2 6 2 2 6 10 10 10
45442 - 86 86 86 42 42 42 14 14 14 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 1 0 0 1 0 0 1 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 14 14 14
45456 - 46 46 46 86 86 86 2 2 6 2 2 6
45457 - 38 38 38 116 116 116 94 94 94 22 22 22
45458 - 22 22 22 2 2 6 2 2 6 2 2 6
45459 - 14 14 14 86 86 86 138 138 138 162 162 162
45460 -154 154 154 38 38 38 26 26 26 6 6 6
45461 - 2 2 6 2 2 6 2 2 6 2 2 6
45462 - 86 86 86 46 46 46 14 14 14 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 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 14 14 14
45476 - 46 46 46 86 86 86 2 2 6 14 14 14
45477 -134 134 134 198 198 198 195 195 195 116 116 116
45478 - 10 10 10 2 2 6 2 2 6 6 6 6
45479 -101 98 89 187 187 187 210 210 210 218 218 218
45480 -214 214 214 134 134 134 14 14 14 6 6 6
45481 - 2 2 6 2 2 6 2 2 6 2 2 6
45482 - 86 86 86 50 50 50 18 18 18 6 6 6
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 1 0 0 0
45490 - 0 0 1 0 0 1 0 0 1 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 14 14 14
45496 - 46 46 46 86 86 86 2 2 6 54 54 54
45497 -218 218 218 195 195 195 226 226 226 246 246 246
45498 - 58 58 58 2 2 6 2 2 6 30 30 30
45499 -210 210 210 253 253 253 174 174 174 123 123 123
45500 -221 221 221 234 234 234 74 74 74 2 2 6
45501 - 2 2 6 2 2 6 2 2 6 2 2 6
45502 - 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 14 14 14
45516 - 46 46 46 82 82 82 2 2 6 106 106 106
45517 -170 170 170 26 26 26 86 86 86 226 226 226
45518 -123 123 123 10 10 10 14 14 14 46 46 46
45519 -231 231 231 190 190 190 6 6 6 70 70 70
45520 - 90 90 90 238 238 238 158 158 158 2 2 6
45521 - 2 2 6 2 2 6 2 2 6 2 2 6
45522 - 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 1 0 0 0
45530 - 0 0 1 0 0 1 0 0 1 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 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 14 14 14
45536 - 42 42 42 86 86 86 6 6 6 116 116 116
45537 -106 106 106 6 6 6 70 70 70 149 149 149
45538 -128 128 128 18 18 18 38 38 38 54 54 54
45539 -221 221 221 106 106 106 2 2 6 14 14 14
45540 - 46 46 46 190 190 190 198 198 198 2 2 6
45541 - 2 2 6 2 2 6 2 2 6 2 2 6
45542 - 74 74 74 62 62 62 22 22 22 6 6 6
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 1 0 0 0
45550 - 0 0 1 0 0 0 0 0 1 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 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 14 14 14
45556 - 42 42 42 94 94 94 14 14 14 101 101 101
45557 -128 128 128 2 2 6 18 18 18 116 116 116
45558 -118 98 46 121 92 8 121 92 8 98 78 10
45559 -162 162 162 106 106 106 2 2 6 2 2 6
45560 - 2 2 6 195 195 195 195 195 195 6 6 6
45561 - 2 2 6 2 2 6 2 2 6 2 2 6
45562 - 74 74 74 62 62 62 22 22 22 6 6 6
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 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 1 0 0 1
45570 - 0 0 1 0 0 0 0 0 1 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 10 10 10
45576 - 38 38 38 90 90 90 14 14 14 58 58 58
45577 -210 210 210 26 26 26 54 38 6 154 114 10
45578 -226 170 11 236 186 11 225 175 15 184 144 12
45579 -215 174 15 175 146 61 37 26 9 2 2 6
45580 - 70 70 70 246 246 246 138 138 138 2 2 6
45581 - 2 2 6 2 2 6 2 2 6 2 2 6
45582 - 70 70 70 66 66 66 26 26 26 6 6 6
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 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 10 10 10
45596 - 38 38 38 86 86 86 14 14 14 10 10 10
45597 -195 195 195 188 164 115 192 133 9 225 175 15
45598 -239 182 13 234 190 10 232 195 16 232 200 30
45599 -245 207 45 241 208 19 232 195 16 184 144 12
45600 -218 194 134 211 206 186 42 42 42 2 2 6
45601 - 2 2 6 2 2 6 2 2 6 2 2 6
45602 - 50 50 50 74 74 74 30 30 30 6 6 6
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 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 10 10 10
45616 - 34 34 34 86 86 86 14 14 14 2 2 6
45617 -121 87 25 192 133 9 219 162 10 239 182 13
45618 -236 186 11 232 195 16 241 208 19 244 214 54
45619 -246 218 60 246 218 38 246 215 20 241 208 19
45620 -241 208 19 226 184 13 121 87 25 2 2 6
45621 - 2 2 6 2 2 6 2 2 6 2 2 6
45622 - 50 50 50 82 82 82 34 34 34 10 10 10
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 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 10 10 10
45636 - 34 34 34 82 82 82 30 30 30 61 42 6
45637 -180 123 7 206 145 10 230 174 11 239 182 13
45638 -234 190 10 238 202 15 241 208 19 246 218 74
45639 -246 218 38 246 215 20 246 215 20 246 215 20
45640 -226 184 13 215 174 15 184 144 12 6 6 6
45641 - 2 2 6 2 2 6 2 2 6 2 2 6
45642 - 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 10 10 10
45656 - 30 30 30 78 78 78 50 50 50 104 69 6
45657 -192 133 9 216 158 10 236 178 12 236 186 11
45658 -232 195 16 241 208 19 244 214 54 245 215 43
45659 -246 215 20 246 215 20 241 208 19 198 155 10
45660 -200 144 11 216 158 10 156 118 10 2 2 6
45661 - 2 2 6 2 2 6 2 2 6 2 2 6
45662 - 6 6 6 90 90 90 54 54 54 18 18 18
45663 - 6 6 6 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 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 10 10 10
45676 - 30 30 30 78 78 78 46 46 46 22 22 22
45677 -137 92 6 210 162 10 239 182 13 238 190 10
45678 -238 202 15 241 208 19 246 215 20 246 215 20
45679 -241 208 19 203 166 17 185 133 11 210 150 10
45680 -216 158 10 210 150 10 102 78 10 2 2 6
45681 - 6 6 6 54 54 54 14 14 14 2 2 6
45682 - 2 2 6 62 62 62 74 74 74 30 30 30
45683 - 10 10 10 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 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 10 10 10
45696 - 34 34 34 78 78 78 50 50 50 6 6 6
45697 - 94 70 30 139 102 15 190 146 13 226 184 13
45698 -232 200 30 232 195 16 215 174 15 190 146 13
45699 -168 122 10 192 133 9 210 150 10 213 154 11
45700 -202 150 34 182 157 106 101 98 89 2 2 6
45701 - 2 2 6 78 78 78 116 116 116 58 58 58
45702 - 2 2 6 22 22 22 90 90 90 46 46 46
45703 - 18 18 18 6 6 6 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 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 10 10 10
45716 - 38 38 38 86 86 86 50 50 50 6 6 6
45717 -128 128 128 174 154 114 156 107 11 168 122 10
45718 -198 155 10 184 144 12 197 138 11 200 144 11
45719 -206 145 10 206 145 10 197 138 11 188 164 115
45720 -195 195 195 198 198 198 174 174 174 14 14 14
45721 - 2 2 6 22 22 22 116 116 116 116 116 116
45722 - 22 22 22 2 2 6 74 74 74 70 70 70
45723 - 30 30 30 10 10 10 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 6 6 6 18 18 18
45736 - 50 50 50 101 101 101 26 26 26 10 10 10
45737 -138 138 138 190 190 190 174 154 114 156 107 11
45738 -197 138 11 200 144 11 197 138 11 192 133 9
45739 -180 123 7 190 142 34 190 178 144 187 187 187
45740 -202 202 202 221 221 221 214 214 214 66 66 66
45741 - 2 2 6 2 2 6 50 50 50 62 62 62
45742 - 6 6 6 2 2 6 10 10 10 90 90 90
45743 - 50 50 50 18 18 18 6 6 6 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 10 10 10 34 34 34
45756 - 74 74 74 74 74 74 2 2 6 6 6 6
45757 -144 144 144 198 198 198 190 190 190 178 166 146
45758 -154 121 60 156 107 11 156 107 11 168 124 44
45759 -174 154 114 187 187 187 190 190 190 210 210 210
45760 -246 246 246 253 253 253 253 253 253 182 182 182
45761 - 6 6 6 2 2 6 2 2 6 2 2 6
45762 - 2 2 6 2 2 6 2 2 6 62 62 62
45763 - 74 74 74 34 34 34 14 14 14 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 10 10 10 22 22 22 54 54 54
45776 - 94 94 94 18 18 18 2 2 6 46 46 46
45777 -234 234 234 221 221 221 190 190 190 190 190 190
45778 -190 190 190 187 187 187 187 187 187 190 190 190
45779 -190 190 190 195 195 195 214 214 214 242 242 242
45780 -253 253 253 253 253 253 253 253 253 253 253 253
45781 - 82 82 82 2 2 6 2 2 6 2 2 6
45782 - 2 2 6 2 2 6 2 2 6 14 14 14
45783 - 86 86 86 54 54 54 22 22 22 6 6 6
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 6 6 6 18 18 18 46 46 46 90 90 90
45796 - 46 46 46 18 18 18 6 6 6 182 182 182
45797 -253 253 253 246 246 246 206 206 206 190 190 190
45798 -190 190 190 190 190 190 190 190 190 190 190 190
45799 -206 206 206 231 231 231 250 250 250 253 253 253
45800 -253 253 253 253 253 253 253 253 253 253 253 253
45801 -202 202 202 14 14 14 2 2 6 2 2 6
45802 - 2 2 6 2 2 6 2 2 6 2 2 6
45803 - 42 42 42 86 86 86 42 42 42 18 18 18
45804 - 6 6 6 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 6 6 6
45815 - 14 14 14 38 38 38 74 74 74 66 66 66
45816 - 2 2 6 6 6 6 90 90 90 250 250 250
45817 -253 253 253 253 253 253 238 238 238 198 198 198
45818 -190 190 190 190 190 190 195 195 195 221 221 221
45819 -246 246 246 253 253 253 253 253 253 253 253 253
45820 -253 253 253 253 253 253 253 253 253 253 253 253
45821 -253 253 253 82 82 82 2 2 6 2 2 6
45822 - 2 2 6 2 2 6 2 2 6 2 2 6
45823 - 2 2 6 78 78 78 70 70 70 34 34 34
45824 - 14 14 14 6 6 6 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 14 14 14
45835 - 34 34 34 66 66 66 78 78 78 6 6 6
45836 - 2 2 6 18 18 18 218 218 218 253 253 253
45837 -253 253 253 253 253 253 253 253 253 246 246 246
45838 -226 226 226 231 231 231 246 246 246 253 253 253
45839 -253 253 253 253 253 253 253 253 253 253 253 253
45840 -253 253 253 253 253 253 253 253 253 253 253 253
45841 -253 253 253 178 178 178 2 2 6 2 2 6
45842 - 2 2 6 2 2 6 2 2 6 2 2 6
45843 - 2 2 6 18 18 18 90 90 90 62 62 62
45844 - 30 30 30 10 10 10 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 0 0 0 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 10 10 10 26 26 26
45855 - 58 58 58 90 90 90 18 18 18 2 2 6
45856 - 2 2 6 110 110 110 253 253 253 253 253 253
45857 -253 253 253 253 253 253 253 253 253 253 253 253
45858 -250 250 250 253 253 253 253 253 253 253 253 253
45859 -253 253 253 253 253 253 253 253 253 253 253 253
45860 -253 253 253 253 253 253 253 253 253 253 253 253
45861 -253 253 253 231 231 231 18 18 18 2 2 6
45862 - 2 2 6 2 2 6 2 2 6 2 2 6
45863 - 2 2 6 2 2 6 18 18 18 94 94 94
45864 - 54 54 54 26 26 26 10 10 10 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 6 6 6 22 22 22 50 50 50
45875 - 90 90 90 26 26 26 2 2 6 2 2 6
45876 - 14 14 14 195 195 195 250 250 250 253 253 253
45877 -253 253 253 253 253 253 253 253 253 253 253 253
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -253 253 253 253 253 253 253 253 253 253 253 253
45880 -253 253 253 253 253 253 253 253 253 253 253 253
45881 -250 250 250 242 242 242 54 54 54 2 2 6
45882 - 2 2 6 2 2 6 2 2 6 2 2 6
45883 - 2 2 6 2 2 6 2 2 6 38 38 38
45884 - 86 86 86 50 50 50 22 22 22 6 6 6
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 6 6 6 14 14 14 38 38 38 82 82 82
45895 - 34 34 34 2 2 6 2 2 6 2 2 6
45896 - 42 42 42 195 195 195 246 246 246 253 253 253
45897 -253 253 253 253 253 253 253 253 253 250 250 250
45898 -242 242 242 242 242 242 250 250 250 253 253 253
45899 -253 253 253 253 253 253 253 253 253 253 253 253
45900 -253 253 253 250 250 250 246 246 246 238 238 238
45901 -226 226 226 231 231 231 101 101 101 6 6 6
45902 - 2 2 6 2 2 6 2 2 6 2 2 6
45903 - 2 2 6 2 2 6 2 2 6 2 2 6
45904 - 38 38 38 82 82 82 42 42 42 14 14 14
45905 - 6 6 6 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 10 10 10 26 26 26 62 62 62 66 66 66
45915 - 2 2 6 2 2 6 2 2 6 6 6 6
45916 - 70 70 70 170 170 170 206 206 206 234 234 234
45917 -246 246 246 250 250 250 250 250 250 238 238 238
45918 -226 226 226 231 231 231 238 238 238 250 250 250
45919 -250 250 250 250 250 250 246 246 246 231 231 231
45920 -214 214 214 206 206 206 202 202 202 202 202 202
45921 -198 198 198 202 202 202 182 182 182 18 18 18
45922 - 2 2 6 2 2 6 2 2 6 2 2 6
45923 - 2 2 6 2 2 6 2 2 6 2 2 6
45924 - 2 2 6 62 62 62 66 66 66 30 30 30
45925 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 14 14 14 42 42 42 82 82 82 18 18 18
45935 - 2 2 6 2 2 6 2 2 6 10 10 10
45936 - 94 94 94 182 182 182 218 218 218 242 242 242
45937 -250 250 250 253 253 253 253 253 253 250 250 250
45938 -234 234 234 253 253 253 253 253 253 253 253 253
45939 -253 253 253 253 253 253 253 253 253 246 246 246
45940 -238 238 238 226 226 226 210 210 210 202 202 202
45941 -195 195 195 195 195 195 210 210 210 158 158 158
45942 - 6 6 6 14 14 14 50 50 50 14 14 14
45943 - 2 2 6 2 2 6 2 2 6 2 2 6
45944 - 2 2 6 6 6 6 86 86 86 46 46 46
45945 - 18 18 18 6 6 6 0 0 0 0 0 0
45946 - 0 0 0 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 6 6 6
45954 - 22 22 22 54 54 54 70 70 70 2 2 6
45955 - 2 2 6 10 10 10 2 2 6 22 22 22
45956 -166 166 166 231 231 231 250 250 250 253 253 253
45957 -253 253 253 253 253 253 253 253 253 250 250 250
45958 -242 242 242 253 253 253 253 253 253 253 253 253
45959 -253 253 253 253 253 253 253 253 253 253 253 253
45960 -253 253 253 253 253 253 253 253 253 246 246 246
45961 -231 231 231 206 206 206 198 198 198 226 226 226
45962 - 94 94 94 2 2 6 6 6 6 38 38 38
45963 - 30 30 30 2 2 6 2 2 6 2 2 6
45964 - 2 2 6 2 2 6 62 62 62 66 66 66
45965 - 26 26 26 10 10 10 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 10 10 10
45974 - 30 30 30 74 74 74 50 50 50 2 2 6
45975 - 26 26 26 26 26 26 2 2 6 106 106 106
45976 -238 238 238 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 253 253 253 253 253 253 253 253 253
45980 -253 253 253 253 253 253 253 253 253 253 253 253
45981 -253 253 253 246 246 246 218 218 218 202 202 202
45982 -210 210 210 14 14 14 2 2 6 2 2 6
45983 - 30 30 30 22 22 22 2 2 6 2 2 6
45984 - 2 2 6 2 2 6 18 18 18 86 86 86
45985 - 42 42 42 14 14 14 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 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 14 14 14
45994 - 42 42 42 90 90 90 22 22 22 2 2 6
45995 - 42 42 42 2 2 6 18 18 18 218 218 218
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 253 253 253 253 253 253
46000 -253 253 253 253 253 253 253 253 253 253 253 253
46001 -253 253 253 253 253 253 250 250 250 221 221 221
46002 -218 218 218 101 101 101 2 2 6 14 14 14
46003 - 18 18 18 38 38 38 10 10 10 2 2 6
46004 - 2 2 6 2 2 6 2 2 6 78 78 78
46005 - 58 58 58 22 22 22 6 6 6 0 0 0
46006 - 0 0 0 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 0 0 0
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 6 6 6 18 18 18
46014 - 54 54 54 82 82 82 2 2 6 26 26 26
46015 - 22 22 22 2 2 6 123 123 123 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 253 253 253
46020 -253 253 253 253 253 253 253 253 253 253 253 253
46021 -253 253 253 253 253 253 253 253 253 250 250 250
46022 -238 238 238 198 198 198 6 6 6 38 38 38
46023 - 58 58 58 26 26 26 38 38 38 2 2 6
46024 - 2 2 6 2 2 6 2 2 6 46 46 46
46025 - 78 78 78 30 30 30 10 10 10 0 0 0
46026 - 0 0 0 0 0 0 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 0 0 0
46032 - 0 0 0 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 10 10 10 30 30 30
46034 - 74 74 74 58 58 58 2 2 6 42 42 42
46035 - 2 2 6 22 22 22 231 231 231 253 253 253
46036 -253 253 253 253 253 253 253 253 253 253 253 253
46037 -253 253 253 253 253 253 253 253 253 250 250 250
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 253 253 253 253 253 253 253 253 253
46041 -253 253 253 253 253 253 253 253 253 253 253 253
46042 -253 253 253 246 246 246 46 46 46 38 38 38
46043 - 42 42 42 14 14 14 38 38 38 14 14 14
46044 - 2 2 6 2 2 6 2 2 6 6 6 6
46045 - 86 86 86 46 46 46 14 14 14 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 0 0 0 0 0 0 0 0 0
46052 - 0 0 0 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 6 6 6 14 14 14 42 42 42
46054 - 90 90 90 18 18 18 18 18 18 26 26 26
46055 - 2 2 6 116 116 116 253 253 253 253 253 253
46056 -253 253 253 253 253 253 253 253 253 253 253 253
46057 -253 253 253 253 253 253 250 250 250 238 238 238
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 253 253 253 253 253 253
46061 -253 253 253 253 253 253 253 253 253 253 253 253
46062 -253 253 253 253 253 253 94 94 94 6 6 6
46063 - 2 2 6 2 2 6 10 10 10 34 34 34
46064 - 2 2 6 2 2 6 2 2 6 2 2 6
46065 - 74 74 74 58 58 58 22 22 22 6 6 6
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 0 0 0 0 0 0
46072 - 0 0 0 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 10 10 10 26 26 26 66 66 66
46074 - 82 82 82 2 2 6 38 38 38 6 6 6
46075 - 14 14 14 210 210 210 253 253 253 253 253 253
46076 -253 253 253 253 253 253 253 253 253 253 253 253
46077 -253 253 253 253 253 253 246 246 246 242 242 242
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 253 253 253 253 253 253
46081 -253 253 253 253 253 253 253 253 253 253 253 253
46082 -253 253 253 253 253 253 144 144 144 2 2 6
46083 - 2 2 6 2 2 6 2 2 6 46 46 46
46084 - 2 2 6 2 2 6 2 2 6 2 2 6
46085 - 42 42 42 74 74 74 30 30 30 10 10 10
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 0 0 0 0 0 0 0 0 0 0 0 0
46092 - 0 0 0 0 0 0 0 0 0 0 0 0
46093 - 6 6 6 14 14 14 42 42 42 90 90 90
46094 - 26 26 26 6 6 6 42 42 42 2 2 6
46095 - 74 74 74 250 250 250 253 253 253 253 253 253
46096 -253 253 253 253 253 253 253 253 253 253 253 253
46097 -253 253 253 253 253 253 242 242 242 242 242 242
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 253 253 253 253 253 253
46101 -253 253 253 253 253 253 253 253 253 253 253 253
46102 -253 253 253 253 253 253 182 182 182 2 2 6
46103 - 2 2 6 2 2 6 2 2 6 46 46 46
46104 - 2 2 6 2 2 6 2 2 6 2 2 6
46105 - 10 10 10 86 86 86 38 38 38 10 10 10
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 0 0 0 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 0 0 0 0 0 0 0 0 0 0 0 0
46112 - 0 0 0 0 0 0 0 0 0 0 0 0
46113 - 10 10 10 26 26 26 66 66 66 82 82 82
46114 - 2 2 6 22 22 22 18 18 18 2 2 6
46115 -149 149 149 253 253 253 253 253 253 253 253 253
46116 -253 253 253 253 253 253 253 253 253 253 253 253
46117 -253 253 253 253 253 253 234 234 234 242 242 242
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 253 253 253 253 253 253
46121 -253 253 253 253 253 253 253 253 253 253 253 253
46122 -253 253 253 253 253 253 206 206 206 2 2 6
46123 - 2 2 6 2 2 6 2 2 6 38 38 38
46124 - 2 2 6 2 2 6 2 2 6 2 2 6
46125 - 6 6 6 86 86 86 46 46 46 14 14 14
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 0 0 0 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 0 0 0
46131 - 0 0 0 0 0 0 0 0 0 0 0 0
46132 - 0 0 0 0 0 0 0 0 0 6 6 6
46133 - 18 18 18 46 46 46 86 86 86 18 18 18
46134 - 2 2 6 34 34 34 10 10 10 6 6 6
46135 -210 210 210 253 253 253 253 253 253 253 253 253
46136 -253 253 253 253 253 253 253 253 253 253 253 253
46137 -253 253 253 253 253 253 234 234 234 242 242 242
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 253 253 253 253 253 253
46141 -253 253 253 253 253 253 253 253 253 253 253 253
46142 -253 253 253 253 253 253 221 221 221 6 6 6
46143 - 2 2 6 2 2 6 6 6 6 30 30 30
46144 - 2 2 6 2 2 6 2 2 6 2 2 6
46145 - 2 2 6 82 82 82 54 54 54 18 18 18
46146 - 6 6 6 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 0 0 0
46151 - 0 0 0 0 0 0 0 0 0 0 0 0
46152 - 0 0 0 0 0 0 0 0 0 10 10 10
46153 - 26 26 26 66 66 66 62 62 62 2 2 6
46154 - 2 2 6 38 38 38 10 10 10 26 26 26
46155 -238 238 238 253 253 253 253 253 253 253 253 253
46156 -253 253 253 253 253 253 253 253 253 253 253 253
46157 -253 253 253 253 253 253 231 231 231 238 238 238
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 253 253 253 253 253 253
46161 -253 253 253 253 253 253 253 253 253 253 253 253
46162 -253 253 253 253 253 253 231 231 231 6 6 6
46163 - 2 2 6 2 2 6 10 10 10 30 30 30
46164 - 2 2 6 2 2 6 2 2 6 2 2 6
46165 - 2 2 6 66 66 66 58 58 58 22 22 22
46166 - 6 6 6 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 0 0 0
46171 - 0 0 0 0 0 0 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 10 10 10
46173 - 38 38 38 78 78 78 6 6 6 2 2 6
46174 - 2 2 6 46 46 46 14 14 14 42 42 42
46175 -246 246 246 253 253 253 253 253 253 253 253 253
46176 -253 253 253 253 253 253 253 253 253 253 253 253
46177 -253 253 253 253 253 253 231 231 231 242 242 242
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 253 253 253 253 253 253
46181 -253 253 253 253 253 253 253 253 253 253 253 253
46182 -253 253 253 253 253 253 234 234 234 10 10 10
46183 - 2 2 6 2 2 6 22 22 22 14 14 14
46184 - 2 2 6 2 2 6 2 2 6 2 2 6
46185 - 2 2 6 66 66 66 62 62 62 22 22 22
46186 - 6 6 6 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 0 0 0 0 0 0
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
46192 - 0 0 0 0 0 0 6 6 6 18 18 18
46193 - 50 50 50 74 74 74 2 2 6 2 2 6
46194 - 14 14 14 70 70 70 34 34 34 62 62 62
46195 -250 250 250 253 253 253 253 253 253 253 253 253
46196 -253 253 253 253 253 253 253 253 253 253 253 253
46197 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
46201 -253 253 253 253 253 253 253 253 253 253 253 253
46202 -253 253 253 253 253 253 234 234 234 14 14 14
46203 - 2 2 6 2 2 6 30 30 30 2 2 6
46204 - 2 2 6 2 2 6 2 2 6 2 2 6
46205 - 2 2 6 66 66 66 62 62 62 22 22 22
46206 - 6 6 6 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 0 0 0
46212 - 0 0 0 0 0 0 6 6 6 18 18 18
46213 - 54 54 54 62 62 62 2 2 6 2 2 6
46214 - 2 2 6 30 30 30 46 46 46 70 70 70
46215 -250 250 250 253 253 253 253 253 253 253 253 253
46216 -253 253 253 253 253 253 253 253 253 253 253 253
46217 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
46221 -253 253 253 253 253 253 253 253 253 253 253 253
46222 -253 253 253 253 253 253 226 226 226 10 10 10
46223 - 2 2 6 6 6 6 30 30 30 2 2 6
46224 - 2 2 6 2 2 6 2 2 6 2 2 6
46225 - 2 2 6 66 66 66 58 58 58 22 22 22
46226 - 6 6 6 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 0 0 0 0 0 0
46231 - 0 0 0 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 6 6 6 22 22 22
46233 - 58 58 58 62 62 62 2 2 6 2 2 6
46234 - 2 2 6 2 2 6 30 30 30 78 78 78
46235 -250 250 250 253 253 253 253 253 253 253 253 253
46236 -253 253 253 253 253 253 253 253 253 253 253 253
46237 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
46241 -253 253 253 253 253 253 253 253 253 253 253 253
46242 -253 253 253 253 253 253 206 206 206 2 2 6
46243 - 22 22 22 34 34 34 18 14 6 22 22 22
46244 - 26 26 26 18 18 18 6 6 6 2 2 6
46245 - 2 2 6 82 82 82 54 54 54 18 18 18
46246 - 6 6 6 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 0 0 0 0 0 0
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 6 6 6 26 26 26
46253 - 62 62 62 106 106 106 74 54 14 185 133 11
46254 -210 162 10 121 92 8 6 6 6 62 62 62
46255 -238 238 238 253 253 253 253 253 253 253 253 253
46256 -253 253 253 253 253 253 253 253 253 253 253 253
46257 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
46261 -253 253 253 253 253 253 253 253 253 253 253 253
46262 -253 253 253 253 253 253 158 158 158 18 18 18
46263 - 14 14 14 2 2 6 2 2 6 2 2 6
46264 - 6 6 6 18 18 18 66 66 66 38 38 38
46265 - 6 6 6 94 94 94 50 50 50 18 18 18
46266 - 6 6 6 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 0 0 0
46268 - 0 0 0 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 0 0 0
46271 - 0 0 0 0 0 0 0 0 0 6 6 6
46272 - 10 10 10 10 10 10 18 18 18 38 38 38
46273 - 78 78 78 142 134 106 216 158 10 242 186 14
46274 -246 190 14 246 190 14 156 118 10 10 10 10
46275 - 90 90 90 238 238 238 253 253 253 253 253 253
46276 -253 253 253 253 253 253 253 253 253 253 253 253
46277 -253 253 253 253 253 253 231 231 231 250 250 250
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 253 253 253 253 253 253
46280 -253 253 253 253 253 253 253 253 253 253 253 253
46281 -253 253 253 253 253 253 253 253 253 246 230 190
46282 -238 204 91 238 204 91 181 142 44 37 26 9
46283 - 2 2 6 2 2 6 2 2 6 2 2 6
46284 - 2 2 6 2 2 6 38 38 38 46 46 46
46285 - 26 26 26 106 106 106 54 54 54 18 18 18
46286 - 6 6 6 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 0 0 0
46288 - 0 0 0 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 0 0 0
46291 - 0 0 0 6 6 6 14 14 14 22 22 22
46292 - 30 30 30 38 38 38 50 50 50 70 70 70
46293 -106 106 106 190 142 34 226 170 11 242 186 14
46294 -246 190 14 246 190 14 246 190 14 154 114 10
46295 - 6 6 6 74 74 74 226 226 226 253 253 253
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 231 231 231 250 250 250
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 253 253 253 253 253 253
46300 -253 253 253 253 253 253 253 253 253 253 253 253
46301 -253 253 253 253 253 253 253 253 253 228 184 62
46302 -241 196 14 241 208 19 232 195 16 38 30 10
46303 - 2 2 6 2 2 6 2 2 6 2 2 6
46304 - 2 2 6 6 6 6 30 30 30 26 26 26
46305 -203 166 17 154 142 90 66 66 66 26 26 26
46306 - 6 6 6 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 0 0 0
46308 - 0 0 0 0 0 0 0 0 0 0 0 0
46309 - 0 0 0 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 6 6 6 18 18 18 38 38 38 58 58 58
46312 - 78 78 78 86 86 86 101 101 101 123 123 123
46313 -175 146 61 210 150 10 234 174 13 246 186 14
46314 -246 190 14 246 190 14 246 190 14 238 190 10
46315 -102 78 10 2 2 6 46 46 46 198 198 198
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 234 234 234 242 242 242
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 253 253 253 253 253 253
46320 -253 253 253 253 253 253 253 253 253 253 253 253
46321 -253 253 253 253 253 253 253 253 253 224 178 62
46322 -242 186 14 241 196 14 210 166 10 22 18 6
46323 - 2 2 6 2 2 6 2 2 6 2 2 6
46324 - 2 2 6 2 2 6 6 6 6 121 92 8
46325 -238 202 15 232 195 16 82 82 82 34 34 34
46326 - 10 10 10 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 0 0 0
46328 - 0 0 0 0 0 0 0 0 0 0 0 0
46329 - 0 0 0 0 0 0 0 0 0 0 0 0
46330 - 0 0 0 0 0 0 0 0 0 0 0 0
46331 - 14 14 14 38 38 38 70 70 70 154 122 46
46332 -190 142 34 200 144 11 197 138 11 197 138 11
46333 -213 154 11 226 170 11 242 186 14 246 190 14
46334 -246 190 14 246 190 14 246 190 14 246 190 14
46335 -225 175 15 46 32 6 2 2 6 22 22 22
46336 -158 158 158 250 250 250 253 253 253 253 253 253
46337 -253 253 253 253 253 253 253 253 253 253 253 253
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 253 253 253 253 253 253 253 253 253
46340 -253 253 253 253 253 253 253 253 253 253 253 253
46341 -253 253 253 250 250 250 242 242 242 224 178 62
46342 -239 182 13 236 186 11 213 154 11 46 32 6
46343 - 2 2 6 2 2 6 2 2 6 2 2 6
46344 - 2 2 6 2 2 6 61 42 6 225 175 15
46345 -238 190 10 236 186 11 112 100 78 42 42 42
46346 - 14 14 14 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 0 0 0 0 0 0
46348 - 0 0 0 0 0 0 0 0 0 0 0 0
46349 - 0 0 0 0 0 0 0 0 0 0 0 0
46350 - 0 0 0 0 0 0 0 0 0 6 6 6
46351 - 22 22 22 54 54 54 154 122 46 213 154 11
46352 -226 170 11 230 174 11 226 170 11 226 170 11
46353 -236 178 12 242 186 14 246 190 14 246 190 14
46354 -246 190 14 246 190 14 246 190 14 246 190 14
46355 -241 196 14 184 144 12 10 10 10 2 2 6
46356 - 6 6 6 116 116 116 242 242 242 253 253 253
46357 -253 253 253 253 253 253 253 253 253 253 253 253
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 253 253 253 253 253 253 253 253 253
46360 -253 253 253 253 253 253 253 253 253 253 253 253
46361 -253 253 253 231 231 231 198 198 198 214 170 54
46362 -236 178 12 236 178 12 210 150 10 137 92 6
46363 - 18 14 6 2 2 6 2 2 6 2 2 6
46364 - 6 6 6 70 47 6 200 144 11 236 178 12
46365 -239 182 13 239 182 13 124 112 88 58 58 58
46366 - 22 22 22 6 6 6 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 0 0 0 0 0 0
46368 - 0 0 0 0 0 0 0 0 0 0 0 0
46369 - 0 0 0 0 0 0 0 0 0 0 0 0
46370 - 0 0 0 0 0 0 0 0 0 10 10 10
46371 - 30 30 30 70 70 70 180 133 36 226 170 11
46372 -239 182 13 242 186 14 242 186 14 246 186 14
46373 -246 190 14 246 190 14 246 190 14 246 190 14
46374 -246 190 14 246 190 14 246 190 14 246 190 14
46375 -246 190 14 232 195 16 98 70 6 2 2 6
46376 - 2 2 6 2 2 6 66 66 66 221 221 221
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 253 253 253 253 253 253 253 253 253
46380 -253 253 253 253 253 253 253 253 253 253 253 253
46381 -253 253 253 206 206 206 198 198 198 214 166 58
46382 -230 174 11 230 174 11 216 158 10 192 133 9
46383 -163 110 8 116 81 8 102 78 10 116 81 8
46384 -167 114 7 197 138 11 226 170 11 239 182 13
46385 -242 186 14 242 186 14 162 146 94 78 78 78
46386 - 34 34 34 14 14 14 6 6 6 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 0 0 0
46389 - 0 0 0 0 0 0 0 0 0 0 0 0
46390 - 0 0 0 0 0 0 0 0 0 6 6 6
46391 - 30 30 30 78 78 78 190 142 34 226 170 11
46392 -239 182 13 246 190 14 246 190 14 246 190 14
46393 -246 190 14 246 190 14 246 190 14 246 190 14
46394 -246 190 14 246 190 14 246 190 14 246 190 14
46395 -246 190 14 241 196 14 203 166 17 22 18 6
46396 - 2 2 6 2 2 6 2 2 6 38 38 38
46397 -218 218 218 253 253 253 253 253 253 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -253 253 253 253 253 253 253 253 253 253 253 253
46400 -253 253 253 253 253 253 253 253 253 253 253 253
46401 -250 250 250 206 206 206 198 198 198 202 162 69
46402 -226 170 11 236 178 12 224 166 10 210 150 10
46403 -200 144 11 197 138 11 192 133 9 197 138 11
46404 -210 150 10 226 170 11 242 186 14 246 190 14
46405 -246 190 14 246 186 14 225 175 15 124 112 88
46406 - 62 62 62 30 30 30 14 14 14 6 6 6
46407 - 0 0 0 0 0 0 0 0 0 0 0 0
46408 - 0 0 0 0 0 0 0 0 0 0 0 0
46409 - 0 0 0 0 0 0 0 0 0 0 0 0
46410 - 0 0 0 0 0 0 0 0 0 10 10 10
46411 - 30 30 30 78 78 78 174 135 50 224 166 10
46412 -239 182 13 246 190 14 246 190 14 246 190 14
46413 -246 190 14 246 190 14 246 190 14 246 190 14
46414 -246 190 14 246 190 14 246 190 14 246 190 14
46415 -246 190 14 246 190 14 241 196 14 139 102 15
46416 - 2 2 6 2 2 6 2 2 6 2 2 6
46417 - 78 78 78 250 250 250 253 253 253 253 253 253
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -253 253 253 253 253 253 253 253 253 253 253 253
46420 -253 253 253 253 253 253 253 253 253 253 253 253
46421 -250 250 250 214 214 214 198 198 198 190 150 46
46422 -219 162 10 236 178 12 234 174 13 224 166 10
46423 -216 158 10 213 154 11 213 154 11 216 158 10
46424 -226 170 11 239 182 13 246 190 14 246 190 14
46425 -246 190 14 246 190 14 242 186 14 206 162 42
46426 -101 101 101 58 58 58 30 30 30 14 14 14
46427 - 6 6 6 0 0 0 0 0 0 0 0 0
46428 - 0 0 0 0 0 0 0 0 0 0 0 0
46429 - 0 0 0 0 0 0 0 0 0 0 0 0
46430 - 0 0 0 0 0 0 0 0 0 10 10 10
46431 - 30 30 30 74 74 74 174 135 50 216 158 10
46432 -236 178 12 246 190 14 246 190 14 246 190 14
46433 -246 190 14 246 190 14 246 190 14 246 190 14
46434 -246 190 14 246 190 14 246 190 14 246 190 14
46435 -246 190 14 246 190 14 241 196 14 226 184 13
46436 - 61 42 6 2 2 6 2 2 6 2 2 6
46437 - 22 22 22 238 238 238 253 253 253 253 253 253
46438 -253 253 253 253 253 253 253 253 253 253 253 253
46439 -253 253 253 253 253 253 253 253 253 253 253 253
46440 -253 253 253 253 253 253 253 253 253 253 253 253
46441 -253 253 253 226 226 226 187 187 187 180 133 36
46442 -216 158 10 236 178 12 239 182 13 236 178 12
46443 -230 174 11 226 170 11 226 170 11 230 174 11
46444 -236 178 12 242 186 14 246 190 14 246 190 14
46445 -246 190 14 246 190 14 246 186 14 239 182 13
46446 -206 162 42 106 106 106 66 66 66 34 34 34
46447 - 14 14 14 6 6 6 0 0 0 0 0 0
46448 - 0 0 0 0 0 0 0 0 0 0 0 0
46449 - 0 0 0 0 0 0 0 0 0 0 0 0
46450 - 0 0 0 0 0 0 0 0 0 6 6 6
46451 - 26 26 26 70 70 70 163 133 67 213 154 11
46452 -236 178 12 246 190 14 246 190 14 246 190 14
46453 -246 190 14 246 190 14 246 190 14 246 190 14
46454 -246 190 14 246 190 14 246 190 14 246 190 14
46455 -246 190 14 246 190 14 246 190 14 241 196 14
46456 -190 146 13 18 14 6 2 2 6 2 2 6
46457 - 46 46 46 246 246 246 253 253 253 253 253 253
46458 -253 253 253 253 253 253 253 253 253 253 253 253
46459 -253 253 253 253 253 253 253 253 253 253 253 253
46460 -253 253 253 253 253 253 253 253 253 253 253 253
46461 -253 253 253 221 221 221 86 86 86 156 107 11
46462 -216 158 10 236 178 12 242 186 14 246 186 14
46463 -242 186 14 239 182 13 239 182 13 242 186 14
46464 -242 186 14 246 186 14 246 190 14 246 190 14
46465 -246 190 14 246 190 14 246 190 14 246 190 14
46466 -242 186 14 225 175 15 142 122 72 66 66 66
46467 - 30 30 30 10 10 10 0 0 0 0 0 0
46468 - 0 0 0 0 0 0 0 0 0 0 0 0
46469 - 0 0 0 0 0 0 0 0 0 0 0 0
46470 - 0 0 0 0 0 0 0 0 0 6 6 6
46471 - 26 26 26 70 70 70 163 133 67 210 150 10
46472 -236 178 12 246 190 14 246 190 14 246 190 14
46473 -246 190 14 246 190 14 246 190 14 246 190 14
46474 -246 190 14 246 190 14 246 190 14 246 190 14
46475 -246 190 14 246 190 14 246 190 14 246 190 14
46476 -232 195 16 121 92 8 34 34 34 106 106 106
46477 -221 221 221 253 253 253 253 253 253 253 253 253
46478 -253 253 253 253 253 253 253 253 253 253 253 253
46479 -253 253 253 253 253 253 253 253 253 253 253 253
46480 -253 253 253 253 253 253 253 253 253 253 253 253
46481 -242 242 242 82 82 82 18 14 6 163 110 8
46482 -216 158 10 236 178 12 242 186 14 246 190 14
46483 -246 190 14 246 190 14 246 190 14 246 190 14
46484 -246 190 14 246 190 14 246 190 14 246 190 14
46485 -246 190 14 246 190 14 246 190 14 246 190 14
46486 -246 190 14 246 190 14 242 186 14 163 133 67
46487 - 46 46 46 18 18 18 6 6 6 0 0 0
46488 - 0 0 0 0 0 0 0 0 0 0 0 0
46489 - 0 0 0 0 0 0 0 0 0 0 0 0
46490 - 0 0 0 0 0 0 0 0 0 10 10 10
46491 - 30 30 30 78 78 78 163 133 67 210 150 10
46492 -236 178 12 246 186 14 246 190 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 246 190 14
46494 -246 190 14 246 190 14 246 190 14 246 190 14
46495 -246 190 14 246 190 14 246 190 14 246 190 14
46496 -241 196 14 215 174 15 190 178 144 253 253 253
46497 -253 253 253 253 253 253 253 253 253 253 253 253
46498 -253 253 253 253 253 253 253 253 253 253 253 253
46499 -253 253 253 253 253 253 253 253 253 253 253 253
46500 -253 253 253 253 253 253 253 253 253 218 218 218
46501 - 58 58 58 2 2 6 22 18 6 167 114 7
46502 -216 158 10 236 178 12 246 186 14 246 190 14
46503 -246 190 14 246 190 14 246 190 14 246 190 14
46504 -246 190 14 246 190 14 246 190 14 246 190 14
46505 -246 190 14 246 190 14 246 190 14 246 190 14
46506 -246 190 14 246 186 14 242 186 14 190 150 46
46507 - 54 54 54 22 22 22 6 6 6 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 0 0 0
46509 - 0 0 0 0 0 0 0 0 0 0 0 0
46510 - 0 0 0 0 0 0 0 0 0 14 14 14
46511 - 38 38 38 86 86 86 180 133 36 213 154 11
46512 -236 178 12 246 186 14 246 190 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -246 190 14 246 190 14 246 190 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 232 195 16 190 146 13 214 214 214
46517 -253 253 253 253 253 253 253 253 253 253 253 253
46518 -253 253 253 253 253 253 253 253 253 253 253 253
46519 -253 253 253 253 253 253 253 253 253 253 253 253
46520 -253 253 253 250 250 250 170 170 170 26 26 26
46521 - 2 2 6 2 2 6 37 26 9 163 110 8
46522 -219 162 10 239 182 13 246 186 14 246 190 14
46523 -246 190 14 246 190 14 246 190 14 246 190 14
46524 -246 190 14 246 190 14 246 190 14 246 190 14
46525 -246 190 14 246 190 14 246 190 14 246 190 14
46526 -246 186 14 236 178 12 224 166 10 142 122 72
46527 - 46 46 46 18 18 18 6 6 6 0 0 0
46528 - 0 0 0 0 0 0 0 0 0 0 0 0
46529 - 0 0 0 0 0 0 0 0 0 0 0 0
46530 - 0 0 0 0 0 0 6 6 6 18 18 18
46531 - 50 50 50 109 106 95 192 133 9 224 166 10
46532 -242 186 14 246 190 14 246 190 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -246 190 14 246 190 14 246 190 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -242 186 14 226 184 13 210 162 10 142 110 46
46537 -226 226 226 253 253 253 253 253 253 253 253 253
46538 -253 253 253 253 253 253 253 253 253 253 253 253
46539 -253 253 253 253 253 253 253 253 253 253 253 253
46540 -198 198 198 66 66 66 2 2 6 2 2 6
46541 - 2 2 6 2 2 6 50 34 6 156 107 11
46542 -219 162 10 239 182 13 246 186 14 246 190 14
46543 -246 190 14 246 190 14 246 190 14 246 190 14
46544 -246 190 14 246 190 14 246 190 14 246 190 14
46545 -246 190 14 246 190 14 246 190 14 242 186 14
46546 -234 174 13 213 154 11 154 122 46 66 66 66
46547 - 30 30 30 10 10 10 0 0 0 0 0 0
46548 - 0 0 0 0 0 0 0 0 0 0 0 0
46549 - 0 0 0 0 0 0 0 0 0 0 0 0
46550 - 0 0 0 0 0 0 6 6 6 22 22 22
46551 - 58 58 58 154 121 60 206 145 10 234 174 13
46552 -242 186 14 246 186 14 246 190 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 190 14 246 190 14 246 190 14 246 190 14
46555 -246 190 14 246 190 14 246 190 14 246 190 14
46556 -246 186 14 236 178 12 210 162 10 163 110 8
46557 - 61 42 6 138 138 138 218 218 218 250 250 250
46558 -253 253 253 253 253 253 253 253 253 250 250 250
46559 -242 242 242 210 210 210 144 144 144 66 66 66
46560 - 6 6 6 2 2 6 2 2 6 2 2 6
46561 - 2 2 6 2 2 6 61 42 6 163 110 8
46562 -216 158 10 236 178 12 246 190 14 246 190 14
46563 -246 190 14 246 190 14 246 190 14 246 190 14
46564 -246 190 14 246 190 14 246 190 14 246 190 14
46565 -246 190 14 239 182 13 230 174 11 216 158 10
46566 -190 142 34 124 112 88 70 70 70 38 38 38
46567 - 18 18 18 6 6 6 0 0 0 0 0 0
46568 - 0 0 0 0 0 0 0 0 0 0 0 0
46569 - 0 0 0 0 0 0 0 0 0 0 0 0
46570 - 0 0 0 0 0 0 6 6 6 22 22 22
46571 - 62 62 62 168 124 44 206 145 10 224 166 10
46572 -236 178 12 239 182 13 242 186 14 242 186 14
46573 -246 186 14 246 190 14 246 190 14 246 190 14
46574 -246 190 14 246 190 14 246 190 14 246 190 14
46575 -246 190 14 246 190 14 246 190 14 246 190 14
46576 -246 190 14 236 178 12 216 158 10 175 118 6
46577 - 80 54 7 2 2 6 6 6 6 30 30 30
46578 - 54 54 54 62 62 62 50 50 50 38 38 38
46579 - 14 14 14 2 2 6 2 2 6 2 2 6
46580 - 2 2 6 2 2 6 2 2 6 2 2 6
46581 - 2 2 6 6 6 6 80 54 7 167 114 7
46582 -213 154 11 236 178 12 246 190 14 246 190 14
46583 -246 190 14 246 190 14 246 190 14 246 190 14
46584 -246 190 14 242 186 14 239 182 13 239 182 13
46585 -230 174 11 210 150 10 174 135 50 124 112 88
46586 - 82 82 82 54 54 54 34 34 34 18 18 18
46587 - 6 6 6 0 0 0 0 0 0 0 0 0
46588 - 0 0 0 0 0 0 0 0 0 0 0 0
46589 - 0 0 0 0 0 0 0 0 0 0 0 0
46590 - 0 0 0 0 0 0 6 6 6 18 18 18
46591 - 50 50 50 158 118 36 192 133 9 200 144 11
46592 -216 158 10 219 162 10 224 166 10 226 170 11
46593 -230 174 11 236 178 12 239 182 13 239 182 13
46594 -242 186 14 246 186 14 246 190 14 246 190 14
46595 -246 190 14 246 190 14 246 190 14 246 190 14
46596 -246 186 14 230 174 11 210 150 10 163 110 8
46597 -104 69 6 10 10 10 2 2 6 2 2 6
46598 - 2 2 6 2 2 6 2 2 6 2 2 6
46599 - 2 2 6 2 2 6 2 2 6 2 2 6
46600 - 2 2 6 2 2 6 2 2 6 2 2 6
46601 - 2 2 6 6 6 6 91 60 6 167 114 7
46602 -206 145 10 230 174 11 242 186 14 246 190 14
46603 -246 190 14 246 190 14 246 186 14 242 186 14
46604 -239 182 13 230 174 11 224 166 10 213 154 11
46605 -180 133 36 124 112 88 86 86 86 58 58 58
46606 - 38 38 38 22 22 22 10 10 10 6 6 6
46607 - 0 0 0 0 0 0 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 0 0 0 0 0 0
46609 - 0 0 0 0 0 0 0 0 0 0 0 0
46610 - 0 0 0 0 0 0 0 0 0 14 14 14
46611 - 34 34 34 70 70 70 138 110 50 158 118 36
46612 -167 114 7 180 123 7 192 133 9 197 138 11
46613 -200 144 11 206 145 10 213 154 11 219 162 10
46614 -224 166 10 230 174 11 239 182 13 242 186 14
46615 -246 186 14 246 186 14 246 186 14 246 186 14
46616 -239 182 13 216 158 10 185 133 11 152 99 6
46617 -104 69 6 18 14 6 2 2 6 2 2 6
46618 - 2 2 6 2 2 6 2 2 6 2 2 6
46619 - 2 2 6 2 2 6 2 2 6 2 2 6
46620 - 2 2 6 2 2 6 2 2 6 2 2 6
46621 - 2 2 6 6 6 6 80 54 7 152 99 6
46622 -192 133 9 219 162 10 236 178 12 239 182 13
46623 -246 186 14 242 186 14 239 182 13 236 178 12
46624 -224 166 10 206 145 10 192 133 9 154 121 60
46625 - 94 94 94 62 62 62 42 42 42 22 22 22
46626 - 14 14 14 6 6 6 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 0 0 0
46629 - 0 0 0 0 0 0 0 0 0 0 0 0
46630 - 0 0 0 0 0 0 0 0 0 6 6 6
46631 - 18 18 18 34 34 34 58 58 58 78 78 78
46632 -101 98 89 124 112 88 142 110 46 156 107 11
46633 -163 110 8 167 114 7 175 118 6 180 123 7
46634 -185 133 11 197 138 11 210 150 10 219 162 10
46635 -226 170 11 236 178 12 236 178 12 234 174 13
46636 -219 162 10 197 138 11 163 110 8 130 83 6
46637 - 91 60 6 10 10 10 2 2 6 2 2 6
46638 - 18 18 18 38 38 38 38 38 38 38 38 38
46639 - 38 38 38 38 38 38 38 38 38 38 38 38
46640 - 38 38 38 38 38 38 26 26 26 2 2 6
46641 - 2 2 6 6 6 6 70 47 6 137 92 6
46642 -175 118 6 200 144 11 219 162 10 230 174 11
46643 -234 174 13 230 174 11 219 162 10 210 150 10
46644 -192 133 9 163 110 8 124 112 88 82 82 82
46645 - 50 50 50 30 30 30 14 14 14 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
46650 - 0 0 0 0 0 0 0 0 0 0 0 0
46651 - 6 6 6 14 14 14 22 22 22 34 34 34
46652 - 42 42 42 58 58 58 74 74 74 86 86 86
46653 -101 98 89 122 102 70 130 98 46 121 87 25
46654 -137 92 6 152 99 6 163 110 8 180 123 7
46655 -185 133 11 197 138 11 206 145 10 200 144 11
46656 -180 123 7 156 107 11 130 83 6 104 69 6
46657 - 50 34 6 54 54 54 110 110 110 101 98 89
46658 - 86 86 86 82 82 82 78 78 78 78 78 78
46659 - 78 78 78 78 78 78 78 78 78 78 78 78
46660 - 78 78 78 82 82 82 86 86 86 94 94 94
46661 -106 106 106 101 101 101 86 66 34 124 80 6
46662 -156 107 11 180 123 7 192 133 9 200 144 11
46663 -206 145 10 200 144 11 192 133 9 175 118 6
46664 -139 102 15 109 106 95 70 70 70 42 42 42
46665 - 22 22 22 10 10 10 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 0 0 0 0 0 0
46670 - 0 0 0 0 0 0 0 0 0 0 0 0
46671 - 0 0 0 0 0 0 6 6 6 10 10 10
46672 - 14 14 14 22 22 22 30 30 30 38 38 38
46673 - 50 50 50 62 62 62 74 74 74 90 90 90
46674 -101 98 89 112 100 78 121 87 25 124 80 6
46675 -137 92 6 152 99 6 152 99 6 152 99 6
46676 -138 86 6 124 80 6 98 70 6 86 66 30
46677 -101 98 89 82 82 82 58 58 58 46 46 46
46678 - 38 38 38 34 34 34 34 34 34 34 34 34
46679 - 34 34 34 34 34 34 34 34 34 34 34 34
46680 - 34 34 34 34 34 34 38 38 38 42 42 42
46681 - 54 54 54 82 82 82 94 86 76 91 60 6
46682 -134 86 6 156 107 11 167 114 7 175 118 6
46683 -175 118 6 167 114 7 152 99 6 121 87 25
46684 -101 98 89 62 62 62 34 34 34 18 18 18
46685 - 6 6 6 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 0 0 0 0 0 0 0 0 0
46691 - 0 0 0 0 0 0 0 0 0 0 0 0
46692 - 0 0 0 6 6 6 6 6 6 10 10 10
46693 - 18 18 18 22 22 22 30 30 30 42 42 42
46694 - 50 50 50 66 66 66 86 86 86 101 98 89
46695 -106 86 58 98 70 6 104 69 6 104 69 6
46696 -104 69 6 91 60 6 82 62 34 90 90 90
46697 - 62 62 62 38 38 38 22 22 22 14 14 14
46698 - 10 10 10 10 10 10 10 10 10 10 10 10
46699 - 10 10 10 10 10 10 6 6 6 10 10 10
46700 - 10 10 10 10 10 10 10 10 10 14 14 14
46701 - 22 22 22 42 42 42 70 70 70 89 81 66
46702 - 80 54 7 104 69 6 124 80 6 137 92 6
46703 -134 86 6 116 81 8 100 82 52 86 86 86
46704 - 58 58 58 30 30 30 14 14 14 6 6 6
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 0 0 0 0 0 0 0 0 0
46712 - 0 0 0 0 0 0 0 0 0 0 0 0
46713 - 0 0 0 6 6 6 10 10 10 14 14 14
46714 - 18 18 18 26 26 26 38 38 38 54 54 54
46715 - 70 70 70 86 86 86 94 86 76 89 81 66
46716 - 89 81 66 86 86 86 74 74 74 50 50 50
46717 - 30 30 30 14 14 14 6 6 6 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 0 0 0 0 0 0 0 0 0 0 0 0
46720 - 0 0 0 0 0 0 0 0 0 0 0 0
46721 - 6 6 6 18 18 18 34 34 34 58 58 58
46722 - 82 82 82 89 81 66 89 81 66 89 81 66
46723 - 94 86 66 94 86 76 74 74 74 50 50 50
46724 - 26 26 26 14 14 14 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46733 - 0 0 0 0 0 0 0 0 0 0 0 0
46734 - 6 6 6 6 6 6 14 14 14 18 18 18
46735 - 30 30 30 38 38 38 46 46 46 54 54 54
46736 - 50 50 50 42 42 42 30 30 30 18 18 18
46737 - 10 10 10 0 0 0 0 0 0 0 0 0
46738 - 0 0 0 0 0 0 0 0 0 0 0 0
46739 - 0 0 0 0 0 0 0 0 0 0 0 0
46740 - 0 0 0 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 6 6 6 14 14 14 26 26 26
46742 - 38 38 38 50 50 50 58 58 58 58 58 58
46743 - 54 54 54 42 42 42 30 30 30 18 18 18
46744 - 10 10 10 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 0 0 0
46753 - 0 0 0 0 0 0 0 0 0 0 0 0
46754 - 0 0 0 0 0 0 0 0 0 6 6 6
46755 - 6 6 6 10 10 10 14 14 14 18 18 18
46756 - 18 18 18 14 14 14 10 10 10 6 6 6
46757 - 0 0 0 0 0 0 0 0 0 0 0 0
46758 - 0 0 0 0 0 0 0 0 0 0 0 0
46759 - 0 0 0 0 0 0 0 0 0 0 0 0
46760 - 0 0 0 0 0 0 0 0 0 0 0 0
46761 - 0 0 0 0 0 0 0 0 0 6 6 6
46762 - 14 14 14 18 18 18 22 22 22 22 22 22
46763 - 18 18 18 14 14 14 10 10 10 6 6 6
46764 - 0 0 0 0 0 0 0 0 0 0 0 0
46765 - 0 0 0 0 0 0 0 0 0 0 0 0
46766 - 0 0 0 0 0 0 0 0 0 0 0 0
46767 - 0 0 0 0 0 0 0 0 0 0 0 0
46768 - 0 0 0 0 0 0 0 0 0 0 0 0
46769 +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 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46858 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46863 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46872 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46873 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46877 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46878 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46879 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46885 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46886 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46887 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46891 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46892 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46893 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46894 +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 4 4 4 4 4 4 4 4 4 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46899 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46900 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46901 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46904 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46905 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46906 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46907 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46908 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46913 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46914 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46915 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46916 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46918 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46919 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46920 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46921 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4
46923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46926 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46927 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46928 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46929 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46930 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46931 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46932 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46933 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46934 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46935 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46936 +4 4 4 4 4 4
46937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46939 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46940 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46941 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46942 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46943 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46944 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46945 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46946 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46947 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46948 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46949 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4
46951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46953 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46954 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46955 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46956 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46957 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46958 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46959 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46960 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46961 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46962 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46963 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46964 +4 4 4 4 4 4
46965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46967 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46968 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46969 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46970 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46971 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46972 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46973 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46974 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46975 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46976 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46977 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46978 +4 4 4 4 4 4
46979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46981 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46982 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46983 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46984 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46985 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46986 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46987 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46988 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46989 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46990 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46991 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46992 +4 4 4 4 4 4
46993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46994 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46995 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46996 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46997 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46998 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46999 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47000 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47001 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47002 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47003 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47004 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47005 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47006 +4 4 4 4 4 4
47007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47008 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47009 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47010 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47011 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47012 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47013 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47014 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47015 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47016 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47017 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47018 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47019 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47020 +0 0 0 4 4 4
47021 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47022 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47023 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47024 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47025 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47026 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47027 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47028 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47029 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47030 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47031 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47032 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47033 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47034 +2 0 0 0 0 0
47035 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47036 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47037 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47038 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47039 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47040 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47041 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47042 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47043 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47044 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47045 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47046 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47047 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47048 +37 38 37 0 0 0
47049 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47050 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47051 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47052 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47053 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47054 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47055 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47056 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47057 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47058 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47059 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47060 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47061 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47062 +85 115 134 4 0 0
47063 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47064 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47065 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47066 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47067 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47068 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47069 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47070 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47071 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47072 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47073 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47074 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47075 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47076 +60 73 81 4 0 0
47077 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47078 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47079 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47080 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47081 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47082 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47083 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47084 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47085 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47086 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47087 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47088 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47089 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47090 +16 19 21 4 0 0
47091 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47092 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47093 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47094 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47095 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47096 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47097 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47098 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47099 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47100 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47101 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47102 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47103 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47104 +4 0 0 4 3 3
47105 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47106 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47107 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47109 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47110 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47111 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47112 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47113 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47114 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47115 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47116 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47117 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47118 +3 2 2 4 4 4
47119 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47120 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47121 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47122 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47123 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47124 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47125 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47126 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47127 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47128 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47129 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47130 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47131 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47132 +4 4 4 4 4 4
47133 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47134 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47135 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47136 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47137 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47138 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47139 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47140 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47141 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47142 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47143 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47144 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47145 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47146 +4 4 4 4 4 4
47147 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47148 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47149 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47150 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47151 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47152 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47153 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47154 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47155 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47156 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47157 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47158 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47159 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47160 +5 5 5 5 5 5
47161 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47162 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47163 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47164 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47165 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47166 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47167 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47168 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47169 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47170 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47171 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47172 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47173 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47174 +5 5 5 4 4 4
47175 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47176 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47177 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47178 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47179 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47180 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47181 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47182 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47183 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47184 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47185 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47186 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47188 +4 4 4 4 4 4
47189 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47190 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47191 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47192 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47193 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47194 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47195 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47196 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47197 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47198 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47199 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47200 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47201 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47202 +4 4 4 4 4 4
47203 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47204 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47205 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47206 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47207 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47208 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47209 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47210 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47211 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47212 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47213 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47216 +4 4 4 4 4 4
47217 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47218 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47219 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47220 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47221 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47222 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47223 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47224 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47225 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47226 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47227 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47230 +4 4 4 4 4 4
47231 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47232 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47233 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47234 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47235 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47236 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47237 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47238 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47239 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47240 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47241 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47244 +4 4 4 4 4 4
47245 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47246 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47247 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47248 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47249 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47250 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47251 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47252 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47253 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47254 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47255 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47258 +4 4 4 4 4 4
47259 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47260 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47261 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47262 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47263 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47264 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47265 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47266 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47267 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47268 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47269 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47272 +4 4 4 4 4 4
47273 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47274 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47275 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47276 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47277 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47278 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47279 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47280 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47281 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47282 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47283 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47286 +4 4 4 4 4 4
47287 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47288 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47289 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47290 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47291 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47292 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47293 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47294 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47295 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47296 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47297 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47300 +4 4 4 4 4 4
47301 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47302 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47303 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47304 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47305 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47306 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47307 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47308 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47309 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47310 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47311 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47313 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47314 +4 4 4 4 4 4
47315 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47316 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47317 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47318 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47319 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47320 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47321 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47322 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47323 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47324 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47325 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47327 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47328 +4 4 4 4 4 4
47329 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47330 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47331 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47332 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47333 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47334 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47335 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47336 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47337 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47338 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47339 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47342 +4 4 4 4 4 4
47343 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47344 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47345 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47346 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47347 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47348 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47349 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47350 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47351 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47352 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47353 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47356 +4 4 4 4 4 4
47357 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47358 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47359 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47360 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47361 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47362 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47363 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47364 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47365 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47366 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47367 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47370 +4 4 4 4 4 4
47371 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47372 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47373 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47374 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47375 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47376 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47377 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47378 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47379 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47380 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47381 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47384 +4 4 4 4 4 4
47385 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47386 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47387 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47388 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47389 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47390 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47391 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47392 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47393 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47394 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47395 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47398 +4 4 4 4 4 4
47399 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47400 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47401 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47402 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47403 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47404 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47405 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47406 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47407 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47408 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47409 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47412 +4 4 4 4 4 4
47413 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47414 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47415 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47416 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47417 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47418 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47419 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47420 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47421 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47422 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47423 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47426 +4 4 4 4 4 4
47427 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47428 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47429 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47430 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47431 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47432 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47433 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47434 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47435 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47436 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47437 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47440 +4 4 4 4 4 4
47441 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47442 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47443 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47444 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47445 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47446 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47447 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47448 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47449 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47450 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47451 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47454 +4 4 4 4 4 4
47455 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47456 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47457 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47458 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47459 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47460 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47461 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47462 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47463 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47464 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47465 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47468 +4 4 4 4 4 4
47469 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47470 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47471 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47472 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47473 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47474 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47475 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47476 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47477 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47478 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47479 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47482 +4 4 4 4 4 4
47483 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47484 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47485 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47486 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47487 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47488 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47489 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47490 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47491 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47492 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47493 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47496 +4 4 4 4 4 4
47497 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47498 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47499 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47500 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47501 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47502 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47503 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47504 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47505 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47506 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47507 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47510 +4 4 4 4 4 4
47511 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47512 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47513 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47515 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47516 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47517 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47518 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47519 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47520 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47521 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47524 +4 4 4 4 4 4
47525 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47526 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47527 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47528 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47529 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47530 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47531 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47532 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47533 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47534 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47535 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47538 +4 4 4 4 4 4
47539 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47540 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47541 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47542 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47543 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47544 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47545 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47546 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47547 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47548 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47549 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47552 +4 4 4 4 4 4
47553 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47554 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47555 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47556 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47557 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47558 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47559 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47560 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47561 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47562 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47563 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47566 +4 4 4 4 4 4
47567 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47568 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47569 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47570 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47571 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47572 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47573 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47574 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47575 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47576 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47577 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47580 +4 4 4 4 4 4
47581 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47582 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47583 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47584 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47585 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47586 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47587 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47588 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47589 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47590 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47594 +4 4 4 4 4 4
47595 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47596 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47597 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47598 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47599 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47600 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47601 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47602 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47603 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47604 +13 16 17 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47608 +4 4 4 4 4 4
47609 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47610 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47611 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47612 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47613 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47614 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47615 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47616 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47617 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47618 +4 0 0 4 0 0 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47622 +4 4 4 4 4 4
47623 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47624 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47625 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47626 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47627 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47628 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47629 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47630 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47631 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47632 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47636 +4 4 4 4 4 4
47637 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47638 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47639 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47640 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47641 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47642 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47643 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47644 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47645 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
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 4 4 4 4 4 4 4 4 4 4 4 4
47649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47650 +4 4 4 4 4 4
47651 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47652 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47653 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47654 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47655 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47656 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47657 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47658 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47659 +4 0 0 4 0 0 4 0 0 6 6 6 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 4 4 4 4 4 4 4 4 4 4 4 4
47663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47664 +4 4 4 4 4 4
47665 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47666 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47667 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47668 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47669 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47670 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47671 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47672 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47673 +4 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
47677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47678 +4 4 4 4 4 4
47679 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47680 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47681 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47682 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47683 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47684 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47685 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47686 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
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 4 4 4 4 4 4 4 4 4 4 4 4
47691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47692 +4 4 4 4 4 4
47693 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47694 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47695 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47696 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47697 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47698 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47699 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47700 +6 6 6 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47706 +4 4 4 4 4 4
47707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47708 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47709 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47710 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47711 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47712 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47713 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47714 +4 0 0 4 3 3 6 6 6 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 4 4 4 4 4 4 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 4 4 4
47721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47722 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47723 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47724 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47725 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47726 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47727 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47728 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4
47735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47736 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47737 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47738 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47739 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47740 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47741 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47742 +5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47748 +4 4 4 4 4 4
47749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47751 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47752 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47753 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47754 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47755 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47756 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47762 +4 4 4 4 4 4
47763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47766 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47767 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47768 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47769 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 4 4 4
47777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47780 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47781 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47782 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47783 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
47793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47794 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47795 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47796 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47797 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4
47807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47808 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47809 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47810 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47811 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4
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 4 4 4
47821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47823 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47824 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47825 +6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47837 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47838 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47839 +4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47851 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47852 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47853 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4
47864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47865 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47866 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4
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 4 4 4 4 4 4
47878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47880 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4
47889 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47890 index fe92eed..106e085 100644
47891 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47892 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47893 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47894 struct mb862xxfb_par *par = info->par;
47895
47896 if (info->var.bits_per_pixel == 32) {
47897 - info->fbops->fb_fillrect = cfb_fillrect;
47898 - info->fbops->fb_copyarea = cfb_copyarea;
47899 - info->fbops->fb_imageblit = cfb_imageblit;
47900 + pax_open_kernel();
47901 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47902 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47903 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47904 + pax_close_kernel();
47905 } else {
47906 outreg(disp, GC_L0EM, 3);
47907 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47908 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47909 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47910 + pax_open_kernel();
47911 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47912 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47913 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47914 + pax_close_kernel();
47915 }
47916 outreg(draw, GDC_REG_DRAW_BASE, 0);
47917 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47918 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47919 index ff22871..b129bed 100644
47920 --- a/drivers/video/nvidia/nvidia.c
47921 +++ b/drivers/video/nvidia/nvidia.c
47922 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47923 info->fix.line_length = (info->var.xres_virtual *
47924 info->var.bits_per_pixel) >> 3;
47925 if (info->var.accel_flags) {
47926 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47927 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47928 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47929 - info->fbops->fb_sync = nvidiafb_sync;
47930 + pax_open_kernel();
47931 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47932 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47933 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47934 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47935 + pax_close_kernel();
47936 info->pixmap.scan_align = 4;
47937 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47938 info->flags |= FBINFO_READS_FAST;
47939 NVResetGraphics(info);
47940 } else {
47941 - info->fbops->fb_imageblit = cfb_imageblit;
47942 - info->fbops->fb_fillrect = cfb_fillrect;
47943 - info->fbops->fb_copyarea = cfb_copyarea;
47944 - info->fbops->fb_sync = NULL;
47945 + pax_open_kernel();
47946 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47947 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47948 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47949 + *(void **)&info->fbops->fb_sync = NULL;
47950 + pax_close_kernel();
47951 info->pixmap.scan_align = 1;
47952 info->flags |= FBINFO_HWACCEL_DISABLED;
47953 info->flags &= ~FBINFO_READS_FAST;
47954 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47955 info->pixmap.size = 8 * 1024;
47956 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47957
47958 - if (!hwcur)
47959 - info->fbops->fb_cursor = NULL;
47960 + if (!hwcur) {
47961 + pax_open_kernel();
47962 + *(void **)&info->fbops->fb_cursor = NULL;
47963 + pax_close_kernel();
47964 + }
47965
47966 info->var.accel_flags = (!noaccel);
47967
47968 diff --git a/drivers/video/output.c b/drivers/video/output.c
47969 index 0d6f2cd..6285b97 100644
47970 --- a/drivers/video/output.c
47971 +++ b/drivers/video/output.c
47972 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
47973 new_dev->props = op;
47974 new_dev->dev.class = &video_output_class;
47975 new_dev->dev.parent = dev;
47976 - dev_set_name(&new_dev->dev, name);
47977 + dev_set_name(&new_dev->dev, "%s", name);
47978 dev_set_drvdata(&new_dev->dev, devdata);
47979 ret_code = device_register(&new_dev->dev);
47980 if (ret_code) {
47981 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47982 index 05c2dc3..ea1f391 100644
47983 --- a/drivers/video/s1d13xxxfb.c
47984 +++ b/drivers/video/s1d13xxxfb.c
47985 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47986
47987 switch(prod_id) {
47988 case S1D13506_PROD_ID: /* activate acceleration */
47989 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47990 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47991 + pax_open_kernel();
47992 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47993 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47994 + pax_close_kernel();
47995 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47996 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47997 break;
47998 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47999 index b2b33fc..f9f4658 100644
48000 --- a/drivers/video/smscufx.c
48001 +++ b/drivers/video/smscufx.c
48002 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48003 fb_deferred_io_cleanup(info);
48004 kfree(info->fbdefio);
48005 info->fbdefio = NULL;
48006 - info->fbops->fb_mmap = ufx_ops_mmap;
48007 + pax_open_kernel();
48008 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48009 + pax_close_kernel();
48010 }
48011
48012 pr_debug("released /dev/fb%d user=%d count=%d",
48013 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48014 index ec03e72..f578436 100644
48015 --- a/drivers/video/udlfb.c
48016 +++ b/drivers/video/udlfb.c
48017 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48018 dlfb_urb_completion(urb);
48019
48020 error:
48021 - atomic_add(bytes_sent, &dev->bytes_sent);
48022 - atomic_add(bytes_identical, &dev->bytes_identical);
48023 - atomic_add(width*height*2, &dev->bytes_rendered);
48024 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48025 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48026 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48027 end_cycles = get_cycles();
48028 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48029 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48030 >> 10)), /* Kcycles */
48031 &dev->cpu_kcycles_used);
48032
48033 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48034 dlfb_urb_completion(urb);
48035
48036 error:
48037 - atomic_add(bytes_sent, &dev->bytes_sent);
48038 - atomic_add(bytes_identical, &dev->bytes_identical);
48039 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48040 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48041 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48042 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48043 end_cycles = get_cycles();
48044 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48045 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48046 >> 10)), /* Kcycles */
48047 &dev->cpu_kcycles_used);
48048 }
48049 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48050 fb_deferred_io_cleanup(info);
48051 kfree(info->fbdefio);
48052 info->fbdefio = NULL;
48053 - info->fbops->fb_mmap = dlfb_ops_mmap;
48054 + pax_open_kernel();
48055 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48056 + pax_close_kernel();
48057 }
48058
48059 pr_warn("released /dev/fb%d user=%d count=%d\n",
48060 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48061 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48062 struct dlfb_data *dev = fb_info->par;
48063 return snprintf(buf, PAGE_SIZE, "%u\n",
48064 - atomic_read(&dev->bytes_rendered));
48065 + atomic_read_unchecked(&dev->bytes_rendered));
48066 }
48067
48068 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48069 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48070 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48071 struct dlfb_data *dev = fb_info->par;
48072 return snprintf(buf, PAGE_SIZE, "%u\n",
48073 - atomic_read(&dev->bytes_identical));
48074 + atomic_read_unchecked(&dev->bytes_identical));
48075 }
48076
48077 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48078 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48079 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48080 struct dlfb_data *dev = fb_info->par;
48081 return snprintf(buf, PAGE_SIZE, "%u\n",
48082 - atomic_read(&dev->bytes_sent));
48083 + atomic_read_unchecked(&dev->bytes_sent));
48084 }
48085
48086 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48087 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48088 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48089 struct dlfb_data *dev = fb_info->par;
48090 return snprintf(buf, PAGE_SIZE, "%u\n",
48091 - atomic_read(&dev->cpu_kcycles_used));
48092 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48093 }
48094
48095 static ssize_t edid_show(
48096 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48097 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48098 struct dlfb_data *dev = fb_info->par;
48099
48100 - atomic_set(&dev->bytes_rendered, 0);
48101 - atomic_set(&dev->bytes_identical, 0);
48102 - atomic_set(&dev->bytes_sent, 0);
48103 - atomic_set(&dev->cpu_kcycles_used, 0);
48104 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48105 + atomic_set_unchecked(&dev->bytes_identical, 0);
48106 + atomic_set_unchecked(&dev->bytes_sent, 0);
48107 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48108
48109 return count;
48110 }
48111 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48112 index e328a61..1b08ecb 100644
48113 --- a/drivers/video/uvesafb.c
48114 +++ b/drivers/video/uvesafb.c
48115 @@ -19,6 +19,7 @@
48116 #include <linux/io.h>
48117 #include <linux/mutex.h>
48118 #include <linux/slab.h>
48119 +#include <linux/moduleloader.h>
48120 #include <video/edid.h>
48121 #include <video/uvesafb.h>
48122 #ifdef CONFIG_X86
48123 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48124 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48125 par->pmi_setpal = par->ypan = 0;
48126 } else {
48127 +
48128 +#ifdef CONFIG_PAX_KERNEXEC
48129 +#ifdef CONFIG_MODULES
48130 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48131 +#endif
48132 + if (!par->pmi_code) {
48133 + par->pmi_setpal = par->ypan = 0;
48134 + return 0;
48135 + }
48136 +#endif
48137 +
48138 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48139 + task->t.regs.edi);
48140 +
48141 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48142 + pax_open_kernel();
48143 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48144 + pax_close_kernel();
48145 +
48146 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48147 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48148 +#else
48149 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48150 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48151 +#endif
48152 +
48153 printk(KERN_INFO "uvesafb: protected mode interface info at "
48154 "%04x:%04x\n",
48155 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48156 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48157 par->ypan = ypan;
48158
48159 if (par->pmi_setpal || par->ypan) {
48160 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48161 if (__supported_pte_mask & _PAGE_NX) {
48162 par->pmi_setpal = par->ypan = 0;
48163 printk(KERN_WARNING "uvesafb: NX protection is actively."
48164 "We have better not to use the PMI.\n");
48165 - } else {
48166 + } else
48167 +#endif
48168 uvesafb_vbe_getpmi(task, par);
48169 - }
48170 }
48171 #else
48172 /* The protected mode interface is not available on non-x86. */
48173 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48174 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48175
48176 /* Disable blanking if the user requested so. */
48177 - if (!blank)
48178 - info->fbops->fb_blank = NULL;
48179 + if (!blank) {
48180 + pax_open_kernel();
48181 + *(void **)&info->fbops->fb_blank = NULL;
48182 + pax_close_kernel();
48183 + }
48184
48185 /*
48186 * Find out how much IO memory is required for the mode with
48187 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48188 info->flags = FBINFO_FLAG_DEFAULT |
48189 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48190
48191 - if (!par->ypan)
48192 - info->fbops->fb_pan_display = NULL;
48193 + if (!par->ypan) {
48194 + pax_open_kernel();
48195 + *(void **)&info->fbops->fb_pan_display = NULL;
48196 + pax_close_kernel();
48197 + }
48198 }
48199
48200 static void uvesafb_init_mtrr(struct fb_info *info)
48201 @@ -1836,6 +1866,11 @@ out:
48202 if (par->vbe_modes)
48203 kfree(par->vbe_modes);
48204
48205 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48206 + if (par->pmi_code)
48207 + module_free_exec(NULL, par->pmi_code);
48208 +#endif
48209 +
48210 framebuffer_release(info);
48211 return err;
48212 }
48213 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48214 kfree(par->vbe_state_orig);
48215 if (par->vbe_state_saved)
48216 kfree(par->vbe_state_saved);
48217 +
48218 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48219 + if (par->pmi_code)
48220 + module_free_exec(NULL, par->pmi_code);
48221 +#endif
48222 +
48223 }
48224
48225 framebuffer_release(info);
48226 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48227 index 501b340..d80aa17 100644
48228 --- a/drivers/video/vesafb.c
48229 +++ b/drivers/video/vesafb.c
48230 @@ -9,6 +9,7 @@
48231 */
48232
48233 #include <linux/module.h>
48234 +#include <linux/moduleloader.h>
48235 #include <linux/kernel.h>
48236 #include <linux/errno.h>
48237 #include <linux/string.h>
48238 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48239 static int vram_total __initdata; /* Set total amount of memory */
48240 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48241 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48242 -static void (*pmi_start)(void) __read_mostly;
48243 -static void (*pmi_pal) (void) __read_mostly;
48244 +static void (*pmi_start)(void) __read_only;
48245 +static void (*pmi_pal) (void) __read_only;
48246 static int depth __read_mostly;
48247 static int vga_compat __read_mostly;
48248 /* --------------------------------------------------------------------- */
48249 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48250 unsigned int size_vmode;
48251 unsigned int size_remap;
48252 unsigned int size_total;
48253 + void *pmi_code = NULL;
48254
48255 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48256 return -ENODEV;
48257 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48258 size_remap = size_total;
48259 vesafb_fix.smem_len = size_remap;
48260
48261 -#ifndef __i386__
48262 - screen_info.vesapm_seg = 0;
48263 -#endif
48264 -
48265 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48266 printk(KERN_WARNING
48267 "vesafb: cannot reserve video memory at 0x%lx\n",
48268 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48269 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48270 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48271
48272 +#ifdef __i386__
48273 +
48274 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48275 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48276 + if (!pmi_code)
48277 +#elif !defined(CONFIG_PAX_KERNEXEC)
48278 + if (0)
48279 +#endif
48280 +
48281 +#endif
48282 + screen_info.vesapm_seg = 0;
48283 +
48284 if (screen_info.vesapm_seg) {
48285 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48286 - screen_info.vesapm_seg,screen_info.vesapm_off);
48287 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48288 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48289 }
48290
48291 if (screen_info.vesapm_seg < 0xc000)
48292 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48293
48294 if (ypan || pmi_setpal) {
48295 unsigned short *pmi_base;
48296 +
48297 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48298 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48299 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48300 +
48301 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48302 + pax_open_kernel();
48303 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48304 +#else
48305 + pmi_code = pmi_base;
48306 +#endif
48307 +
48308 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48309 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48310 +
48311 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48312 + pmi_start = ktva_ktla(pmi_start);
48313 + pmi_pal = ktva_ktla(pmi_pal);
48314 + pax_close_kernel();
48315 +#endif
48316 +
48317 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48318 if (pmi_base[3]) {
48319 printk(KERN_INFO "vesafb: pmi: ports = ");
48320 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48321 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48322 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48323
48324 - if (!ypan)
48325 - info->fbops->fb_pan_display = NULL;
48326 + if (!ypan) {
48327 + pax_open_kernel();
48328 + *(void **)&info->fbops->fb_pan_display = NULL;
48329 + pax_close_kernel();
48330 + }
48331
48332 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48333 err = -ENOMEM;
48334 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48335 info->node, info->fix.id);
48336 return 0;
48337 err:
48338 +
48339 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48340 + module_free_exec(NULL, pmi_code);
48341 +#endif
48342 +
48343 if (info->screen_base)
48344 iounmap(info->screen_base);
48345 framebuffer_release(info);
48346 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48347 index 88714ae..16c2e11 100644
48348 --- a/drivers/video/via/via_clock.h
48349 +++ b/drivers/video/via/via_clock.h
48350 @@ -56,7 +56,7 @@ struct via_clock {
48351
48352 void (*set_engine_pll_state)(u8 state);
48353 void (*set_engine_pll)(struct via_pll_config config);
48354 -};
48355 +} __no_const;
48356
48357
48358 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48359 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48360 index fef20db..d28b1ab 100644
48361 --- a/drivers/xen/xenfs/xenstored.c
48362 +++ b/drivers/xen/xenfs/xenstored.c
48363 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48364 static int xsd_kva_open(struct inode *inode, struct file *file)
48365 {
48366 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48367 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48368 + NULL);
48369 +#else
48370 xen_store_interface);
48371 +#endif
48372 +
48373 if (!file->private_data)
48374 return -ENOMEM;
48375 return 0;
48376 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48377 index 055562c..fdfb10d 100644
48378 --- a/fs/9p/vfs_addr.c
48379 +++ b/fs/9p/vfs_addr.c
48380 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48381
48382 retval = v9fs_file_write_internal(inode,
48383 v9inode->writeback_fid,
48384 - (__force const char __user *)buffer,
48385 + (const char __force_user *)buffer,
48386 len, &offset, 0);
48387 if (retval > 0)
48388 retval = 0;
48389 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48390 index d86edc8..40ff2fb 100644
48391 --- a/fs/9p/vfs_inode.c
48392 +++ b/fs/9p/vfs_inode.c
48393 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48394 void
48395 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48396 {
48397 - char *s = nd_get_link(nd);
48398 + const char *s = nd_get_link(nd);
48399
48400 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48401 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48402 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48403 index 370b24c..ff0be7b 100644
48404 --- a/fs/Kconfig.binfmt
48405 +++ b/fs/Kconfig.binfmt
48406 @@ -103,7 +103,7 @@ config HAVE_AOUT
48407
48408 config BINFMT_AOUT
48409 tristate "Kernel support for a.out and ECOFF binaries"
48410 - depends on HAVE_AOUT
48411 + depends on HAVE_AOUT && BROKEN
48412 ---help---
48413 A.out (Assembler.OUTput) is a set of formats for libraries and
48414 executables used in the earliest versions of UNIX. Linux used
48415 diff --git a/fs/aio.c b/fs/aio.c
48416 index 2bbcacf..8614116 100644
48417 --- a/fs/aio.c
48418 +++ b/fs/aio.c
48419 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48420 size += sizeof(struct io_event) * nr_events;
48421 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48422
48423 - if (nr_pages < 0)
48424 + if (nr_pages <= 0)
48425 return -EINVAL;
48426
48427 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48428 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
48429 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48430 {
48431 ssize_t ret;
48432 + struct iovec iovstack;
48433
48434 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48435
48436 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48437 if (compat)
48438 ret = compat_rw_copy_check_uvector(rw,
48439 (struct compat_iovec __user *)kiocb->ki_buf,
48440 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48441 + kiocb->ki_nr_segs, 1, &iovstack,
48442 &kiocb->ki_iovec);
48443 else
48444 #endif
48445 ret = rw_copy_check_uvector(rw,
48446 (struct iovec __user *)kiocb->ki_buf,
48447 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48448 + kiocb->ki_nr_segs, 1, &iovstack,
48449 &kiocb->ki_iovec);
48450 if (ret < 0)
48451 return ret;
48452
48453 + if (kiocb->ki_iovec == &iovstack) {
48454 + kiocb->ki_inline_vec = iovstack;
48455 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48456 + }
48457 +
48458 /* ki_nbytes now reflect bytes instead of segs */
48459 kiocb->ki_nbytes = ret;
48460 return 0;
48461 diff --git a/fs/attr.c b/fs/attr.c
48462 index 1449adb..a2038c2 100644
48463 --- a/fs/attr.c
48464 +++ b/fs/attr.c
48465 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48466 unsigned long limit;
48467
48468 limit = rlimit(RLIMIT_FSIZE);
48469 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48470 if (limit != RLIM_INFINITY && offset > limit)
48471 goto out_sig;
48472 if (offset > inode->i_sb->s_maxbytes)
48473 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48474 index 3db70da..7aeec5b 100644
48475 --- a/fs/autofs4/waitq.c
48476 +++ b/fs/autofs4/waitq.c
48477 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48478 {
48479 unsigned long sigpipe, flags;
48480 mm_segment_t fs;
48481 - const char *data = (const char *)addr;
48482 + const char __user *data = (const char __force_user *)addr;
48483 ssize_t wr = 0;
48484
48485 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48486 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48487 return 1;
48488 }
48489
48490 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48491 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48492 +#endif
48493 +
48494 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48495 enum autofs_notify notify)
48496 {
48497 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48498
48499 /* If this is a direct mount request create a dummy name */
48500 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48501 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48502 + /* this name does get written to userland via autofs4_write() */
48503 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48504 +#else
48505 qstr.len = sprintf(name, "%p", dentry);
48506 +#endif
48507 else {
48508 qstr.len = autofs4_getpath(sbi, dentry, &name);
48509 if (!qstr.len) {
48510 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48511 index 2722387..c8dd2a7 100644
48512 --- a/fs/befs/endian.h
48513 +++ b/fs/befs/endian.h
48514 @@ -11,7 +11,7 @@
48515
48516 #include <asm/byteorder.h>
48517
48518 -static inline u64
48519 +static inline u64 __intentional_overflow(-1)
48520 fs64_to_cpu(const struct super_block *sb, fs64 n)
48521 {
48522 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48523 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48524 return (__force fs64)cpu_to_be64(n);
48525 }
48526
48527 -static inline u32
48528 +static inline u32 __intentional_overflow(-1)
48529 fs32_to_cpu(const struct super_block *sb, fs32 n)
48530 {
48531 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48532 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48533 index f95dddc..b1e2c1c 100644
48534 --- a/fs/befs/linuxvfs.c
48535 +++ b/fs/befs/linuxvfs.c
48536 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48537 {
48538 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48539 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48540 - char *link = nd_get_link(nd);
48541 + const char *link = nd_get_link(nd);
48542 if (!IS_ERR(link))
48543 kfree(link);
48544 }
48545 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48546 index bce8769..7fc7544 100644
48547 --- a/fs/binfmt_aout.c
48548 +++ b/fs/binfmt_aout.c
48549 @@ -16,6 +16,7 @@
48550 #include <linux/string.h>
48551 #include <linux/fs.h>
48552 #include <linux/file.h>
48553 +#include <linux/security.h>
48554 #include <linux/stat.h>
48555 #include <linux/fcntl.h>
48556 #include <linux/ptrace.h>
48557 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48558 #endif
48559 # define START_STACK(u) ((void __user *)u.start_stack)
48560
48561 + memset(&dump, 0, sizeof(dump));
48562 +
48563 fs = get_fs();
48564 set_fs(KERNEL_DS);
48565 has_dumped = 1;
48566 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48567
48568 /* If the size of the dump file exceeds the rlimit, then see what would happen
48569 if we wrote the stack, but not the data area. */
48570 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48571 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48572 dump.u_dsize = 0;
48573
48574 /* Make sure we have enough room to write the stack and data areas. */
48575 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48576 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48577 dump.u_ssize = 0;
48578
48579 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48580 rlim = rlimit(RLIMIT_DATA);
48581 if (rlim >= RLIM_INFINITY)
48582 rlim = ~0;
48583 +
48584 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48585 if (ex.a_data + ex.a_bss > rlim)
48586 return -ENOMEM;
48587
48588 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48589
48590 install_exec_creds(bprm);
48591
48592 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48593 + current->mm->pax_flags = 0UL;
48594 +#endif
48595 +
48596 +#ifdef CONFIG_PAX_PAGEEXEC
48597 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48598 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48599 +
48600 +#ifdef CONFIG_PAX_EMUTRAMP
48601 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48602 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48603 +#endif
48604 +
48605 +#ifdef CONFIG_PAX_MPROTECT
48606 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48607 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48608 +#endif
48609 +
48610 + }
48611 +#endif
48612 +
48613 if (N_MAGIC(ex) == OMAGIC) {
48614 unsigned long text_addr, map_size;
48615 loff_t pos;
48616 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48617 }
48618
48619 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48620 - PROT_READ | PROT_WRITE | PROT_EXEC,
48621 + PROT_READ | PROT_WRITE,
48622 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48623 fd_offset + ex.a_text);
48624 if (error != N_DATADDR(ex)) {
48625 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48626 index f8a0b0e..8186af0 100644
48627 --- a/fs/binfmt_elf.c
48628 +++ b/fs/binfmt_elf.c
48629 @@ -34,6 +34,7 @@
48630 #include <linux/utsname.h>
48631 #include <linux/coredump.h>
48632 #include <linux/sched.h>
48633 +#include <linux/xattr.h>
48634 #include <asm/uaccess.h>
48635 #include <asm/param.h>
48636 #include <asm/page.h>
48637 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48638 #define elf_core_dump NULL
48639 #endif
48640
48641 +#ifdef CONFIG_PAX_MPROTECT
48642 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48643 +#endif
48644 +
48645 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48646 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48647 #else
48648 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48649 .load_binary = load_elf_binary,
48650 .load_shlib = load_elf_library,
48651 .core_dump = elf_core_dump,
48652 +
48653 +#ifdef CONFIG_PAX_MPROTECT
48654 + .handle_mprotect= elf_handle_mprotect,
48655 +#endif
48656 +
48657 .min_coredump = ELF_EXEC_PAGESIZE,
48658 };
48659
48660 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48661
48662 static int set_brk(unsigned long start, unsigned long end)
48663 {
48664 + unsigned long e = end;
48665 +
48666 start = ELF_PAGEALIGN(start);
48667 end = ELF_PAGEALIGN(end);
48668 if (end > start) {
48669 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48670 if (BAD_ADDR(addr))
48671 return addr;
48672 }
48673 - current->mm->start_brk = current->mm->brk = end;
48674 + current->mm->start_brk = current->mm->brk = e;
48675 return 0;
48676 }
48677
48678 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48679 elf_addr_t __user *u_rand_bytes;
48680 const char *k_platform = ELF_PLATFORM;
48681 const char *k_base_platform = ELF_BASE_PLATFORM;
48682 - unsigned char k_rand_bytes[16];
48683 + u32 k_rand_bytes[4];
48684 int items;
48685 elf_addr_t *elf_info;
48686 int ei_index = 0;
48687 const struct cred *cred = current_cred();
48688 struct vm_area_struct *vma;
48689 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48690
48691 /*
48692 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48693 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48694 * Generate 16 random bytes for userspace PRNG seeding.
48695 */
48696 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48697 - u_rand_bytes = (elf_addr_t __user *)
48698 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48699 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
48700 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
48701 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
48702 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
48703 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48704 + u_rand_bytes = (elf_addr_t __user *) p;
48705 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48706 return -EFAULT;
48707
48708 @@ -318,9 +335,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48709 return -EFAULT;
48710 current->mm->env_end = p;
48711
48712 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48713 +
48714 /* Put the elf_info on the stack in the right place. */
48715 sp = (elf_addr_t __user *)envp + 1;
48716 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48717 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48718 return -EFAULT;
48719 return 0;
48720 }
48721 @@ -388,15 +407,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48722 an ELF header */
48723
48724 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48725 - struct file *interpreter, unsigned long *interp_map_addr,
48726 - unsigned long no_base)
48727 + struct file *interpreter, unsigned long no_base)
48728 {
48729 struct elf_phdr *elf_phdata;
48730 struct elf_phdr *eppnt;
48731 - unsigned long load_addr = 0;
48732 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48733 int load_addr_set = 0;
48734 unsigned long last_bss = 0, elf_bss = 0;
48735 - unsigned long error = ~0UL;
48736 + unsigned long error = -EINVAL;
48737 unsigned long total_size;
48738 int retval, i, size;
48739
48740 @@ -442,6 +460,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48741 goto out_close;
48742 }
48743
48744 +#ifdef CONFIG_PAX_SEGMEXEC
48745 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48746 + pax_task_size = SEGMEXEC_TASK_SIZE;
48747 +#endif
48748 +
48749 eppnt = elf_phdata;
48750 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48751 if (eppnt->p_type == PT_LOAD) {
48752 @@ -465,8 +488,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48753 map_addr = elf_map(interpreter, load_addr + vaddr,
48754 eppnt, elf_prot, elf_type, total_size);
48755 total_size = 0;
48756 - if (!*interp_map_addr)
48757 - *interp_map_addr = map_addr;
48758 error = map_addr;
48759 if (BAD_ADDR(map_addr))
48760 goto out_close;
48761 @@ -485,8 +506,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48762 k = load_addr + eppnt->p_vaddr;
48763 if (BAD_ADDR(k) ||
48764 eppnt->p_filesz > eppnt->p_memsz ||
48765 - eppnt->p_memsz > TASK_SIZE ||
48766 - TASK_SIZE - eppnt->p_memsz < k) {
48767 + eppnt->p_memsz > pax_task_size ||
48768 + pax_task_size - eppnt->p_memsz < k) {
48769 error = -ENOMEM;
48770 goto out_close;
48771 }
48772 @@ -538,6 +559,315 @@ out:
48773 return error;
48774 }
48775
48776 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48777 +#ifdef CONFIG_PAX_SOFTMODE
48778 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48779 +{
48780 + unsigned long pax_flags = 0UL;
48781 +
48782 +#ifdef CONFIG_PAX_PAGEEXEC
48783 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48784 + pax_flags |= MF_PAX_PAGEEXEC;
48785 +#endif
48786 +
48787 +#ifdef CONFIG_PAX_SEGMEXEC
48788 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48789 + pax_flags |= MF_PAX_SEGMEXEC;
48790 +#endif
48791 +
48792 +#ifdef CONFIG_PAX_EMUTRAMP
48793 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48794 + pax_flags |= MF_PAX_EMUTRAMP;
48795 +#endif
48796 +
48797 +#ifdef CONFIG_PAX_MPROTECT
48798 + if (elf_phdata->p_flags & PF_MPROTECT)
48799 + pax_flags |= MF_PAX_MPROTECT;
48800 +#endif
48801 +
48802 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48803 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48804 + pax_flags |= MF_PAX_RANDMMAP;
48805 +#endif
48806 +
48807 + return pax_flags;
48808 +}
48809 +#endif
48810 +
48811 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48812 +{
48813 + unsigned long pax_flags = 0UL;
48814 +
48815 +#ifdef CONFIG_PAX_PAGEEXEC
48816 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48817 + pax_flags |= MF_PAX_PAGEEXEC;
48818 +#endif
48819 +
48820 +#ifdef CONFIG_PAX_SEGMEXEC
48821 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48822 + pax_flags |= MF_PAX_SEGMEXEC;
48823 +#endif
48824 +
48825 +#ifdef CONFIG_PAX_EMUTRAMP
48826 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48827 + pax_flags |= MF_PAX_EMUTRAMP;
48828 +#endif
48829 +
48830 +#ifdef CONFIG_PAX_MPROTECT
48831 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48832 + pax_flags |= MF_PAX_MPROTECT;
48833 +#endif
48834 +
48835 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48836 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48837 + pax_flags |= MF_PAX_RANDMMAP;
48838 +#endif
48839 +
48840 + return pax_flags;
48841 +}
48842 +#endif
48843 +
48844 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48845 +#ifdef CONFIG_PAX_SOFTMODE
48846 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48847 +{
48848 + unsigned long pax_flags = 0UL;
48849 +
48850 +#ifdef CONFIG_PAX_PAGEEXEC
48851 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48852 + pax_flags |= MF_PAX_PAGEEXEC;
48853 +#endif
48854 +
48855 +#ifdef CONFIG_PAX_SEGMEXEC
48856 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48857 + pax_flags |= MF_PAX_SEGMEXEC;
48858 +#endif
48859 +
48860 +#ifdef CONFIG_PAX_EMUTRAMP
48861 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48862 + pax_flags |= MF_PAX_EMUTRAMP;
48863 +#endif
48864 +
48865 +#ifdef CONFIG_PAX_MPROTECT
48866 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48867 + pax_flags |= MF_PAX_MPROTECT;
48868 +#endif
48869 +
48870 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48871 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48872 + pax_flags |= MF_PAX_RANDMMAP;
48873 +#endif
48874 +
48875 + return pax_flags;
48876 +}
48877 +#endif
48878 +
48879 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48880 +{
48881 + unsigned long pax_flags = 0UL;
48882 +
48883 +#ifdef CONFIG_PAX_PAGEEXEC
48884 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48885 + pax_flags |= MF_PAX_PAGEEXEC;
48886 +#endif
48887 +
48888 +#ifdef CONFIG_PAX_SEGMEXEC
48889 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48890 + pax_flags |= MF_PAX_SEGMEXEC;
48891 +#endif
48892 +
48893 +#ifdef CONFIG_PAX_EMUTRAMP
48894 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48895 + pax_flags |= MF_PAX_EMUTRAMP;
48896 +#endif
48897 +
48898 +#ifdef CONFIG_PAX_MPROTECT
48899 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48900 + pax_flags |= MF_PAX_MPROTECT;
48901 +#endif
48902 +
48903 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48904 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48905 + pax_flags |= MF_PAX_RANDMMAP;
48906 +#endif
48907 +
48908 + return pax_flags;
48909 +}
48910 +#endif
48911 +
48912 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48913 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48914 +{
48915 + unsigned long pax_flags = 0UL;
48916 +
48917 +#ifdef CONFIG_PAX_EI_PAX
48918 +
48919 +#ifdef CONFIG_PAX_PAGEEXEC
48920 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48921 + pax_flags |= MF_PAX_PAGEEXEC;
48922 +#endif
48923 +
48924 +#ifdef CONFIG_PAX_SEGMEXEC
48925 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48926 + pax_flags |= MF_PAX_SEGMEXEC;
48927 +#endif
48928 +
48929 +#ifdef CONFIG_PAX_EMUTRAMP
48930 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48931 + pax_flags |= MF_PAX_EMUTRAMP;
48932 +#endif
48933 +
48934 +#ifdef CONFIG_PAX_MPROTECT
48935 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48936 + pax_flags |= MF_PAX_MPROTECT;
48937 +#endif
48938 +
48939 +#ifdef CONFIG_PAX_ASLR
48940 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48941 + pax_flags |= MF_PAX_RANDMMAP;
48942 +#endif
48943 +
48944 +#else
48945 +
48946 +#ifdef CONFIG_PAX_PAGEEXEC
48947 + pax_flags |= MF_PAX_PAGEEXEC;
48948 +#endif
48949 +
48950 +#ifdef CONFIG_PAX_SEGMEXEC
48951 + pax_flags |= MF_PAX_SEGMEXEC;
48952 +#endif
48953 +
48954 +#ifdef CONFIG_PAX_MPROTECT
48955 + pax_flags |= MF_PAX_MPROTECT;
48956 +#endif
48957 +
48958 +#ifdef CONFIG_PAX_RANDMMAP
48959 + if (randomize_va_space)
48960 + pax_flags |= MF_PAX_RANDMMAP;
48961 +#endif
48962 +
48963 +#endif
48964 +
48965 + return pax_flags;
48966 +}
48967 +
48968 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48969 +{
48970 +
48971 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48972 + unsigned long i;
48973 +
48974 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48975 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48976 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48977 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48978 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48979 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48980 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48981 + return ~0UL;
48982 +
48983 +#ifdef CONFIG_PAX_SOFTMODE
48984 + if (pax_softmode)
48985 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48986 + else
48987 +#endif
48988 +
48989 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48990 + break;
48991 + }
48992 +#endif
48993 +
48994 + return ~0UL;
48995 +}
48996 +
48997 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48998 +{
48999 +
49000 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49001 + ssize_t xattr_size, i;
49002 + unsigned char xattr_value[sizeof("pemrs") - 1];
49003 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49004 +
49005 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
49006 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
49007 + return ~0UL;
49008 +
49009 + for (i = 0; i < xattr_size; i++)
49010 + switch (xattr_value[i]) {
49011 + default:
49012 + return ~0UL;
49013 +
49014 +#define parse_flag(option1, option2, flag) \
49015 + case option1: \
49016 + if (pax_flags_hardmode & MF_PAX_##flag) \
49017 + return ~0UL; \
49018 + pax_flags_hardmode |= MF_PAX_##flag; \
49019 + break; \
49020 + case option2: \
49021 + if (pax_flags_softmode & MF_PAX_##flag) \
49022 + return ~0UL; \
49023 + pax_flags_softmode |= MF_PAX_##flag; \
49024 + break;
49025 +
49026 + parse_flag('p', 'P', PAGEEXEC);
49027 + parse_flag('e', 'E', EMUTRAMP);
49028 + parse_flag('m', 'M', MPROTECT);
49029 + parse_flag('r', 'R', RANDMMAP);
49030 + parse_flag('s', 'S', SEGMEXEC);
49031 +
49032 +#undef parse_flag
49033 + }
49034 +
49035 + if (pax_flags_hardmode & pax_flags_softmode)
49036 + return ~0UL;
49037 +
49038 +#ifdef CONFIG_PAX_SOFTMODE
49039 + if (pax_softmode)
49040 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49041 + else
49042 +#endif
49043 +
49044 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49045 +#else
49046 + return ~0UL;
49047 +#endif
49048 +
49049 +}
49050 +
49051 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49052 +{
49053 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49054 +
49055 + pax_flags = pax_parse_ei_pax(elf_ex);
49056 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49057 + xattr_pax_flags = pax_parse_xattr_pax(file);
49058 +
49059 + if (pt_pax_flags == ~0UL)
49060 + pt_pax_flags = xattr_pax_flags;
49061 + else if (xattr_pax_flags == ~0UL)
49062 + xattr_pax_flags = pt_pax_flags;
49063 + if (pt_pax_flags != xattr_pax_flags)
49064 + return -EINVAL;
49065 + if (pt_pax_flags != ~0UL)
49066 + pax_flags = pt_pax_flags;
49067 +
49068 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49069 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49070 + if ((__supported_pte_mask & _PAGE_NX))
49071 + pax_flags &= ~MF_PAX_SEGMEXEC;
49072 + else
49073 + pax_flags &= ~MF_PAX_PAGEEXEC;
49074 + }
49075 +#endif
49076 +
49077 + if (0 > pax_check_flags(&pax_flags))
49078 + return -EINVAL;
49079 +
49080 + current->mm->pax_flags = pax_flags;
49081 + return 0;
49082 +}
49083 +#endif
49084 +
49085 /*
49086 * These are the functions used to load ELF style executables and shared
49087 * libraries. There is no binary dependent code anywhere else.
49088 @@ -554,6 +884,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49089 {
49090 unsigned int random_variable = 0;
49091
49092 +#ifdef CONFIG_PAX_RANDUSTACK
49093 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49094 + return stack_top - current->mm->delta_stack;
49095 +#endif
49096 +
49097 if ((current->flags & PF_RANDOMIZE) &&
49098 !(current->personality & ADDR_NO_RANDOMIZE)) {
49099 random_variable = get_random_int() & STACK_RND_MASK;
49100 @@ -572,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49101 unsigned long load_addr = 0, load_bias = 0;
49102 int load_addr_set = 0;
49103 char * elf_interpreter = NULL;
49104 - unsigned long error;
49105 + unsigned long error = 0;
49106 struct elf_phdr *elf_ppnt, *elf_phdata;
49107 unsigned long elf_bss, elf_brk;
49108 int retval, i;
49109 @@ -582,12 +917,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49110 unsigned long start_code, end_code, start_data, end_data;
49111 unsigned long reloc_func_desc __maybe_unused = 0;
49112 int executable_stack = EXSTACK_DEFAULT;
49113 - unsigned long def_flags = 0;
49114 struct pt_regs *regs = current_pt_regs();
49115 struct {
49116 struct elfhdr elf_ex;
49117 struct elfhdr interp_elf_ex;
49118 } *loc;
49119 + unsigned long pax_task_size = TASK_SIZE;
49120
49121 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49122 if (!loc) {
49123 @@ -723,11 +1058,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49124 goto out_free_dentry;
49125
49126 /* OK, This is the point of no return */
49127 - current->mm->def_flags = def_flags;
49128 +
49129 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49130 + current->mm->pax_flags = 0UL;
49131 +#endif
49132 +
49133 +#ifdef CONFIG_PAX_DLRESOLVE
49134 + current->mm->call_dl_resolve = 0UL;
49135 +#endif
49136 +
49137 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49138 + current->mm->call_syscall = 0UL;
49139 +#endif
49140 +
49141 +#ifdef CONFIG_PAX_ASLR
49142 + current->mm->delta_mmap = 0UL;
49143 + current->mm->delta_stack = 0UL;
49144 +#endif
49145 +
49146 + current->mm->def_flags = 0;
49147 +
49148 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49149 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49150 + send_sig(SIGKILL, current, 0);
49151 + goto out_free_dentry;
49152 + }
49153 +#endif
49154 +
49155 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49156 + pax_set_initial_flags(bprm);
49157 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49158 + if (pax_set_initial_flags_func)
49159 + (pax_set_initial_flags_func)(bprm);
49160 +#endif
49161 +
49162 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49163 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49164 + current->mm->context.user_cs_limit = PAGE_SIZE;
49165 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49166 + }
49167 +#endif
49168 +
49169 +#ifdef CONFIG_PAX_SEGMEXEC
49170 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49171 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49172 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49173 + pax_task_size = SEGMEXEC_TASK_SIZE;
49174 + current->mm->def_flags |= VM_NOHUGEPAGE;
49175 + }
49176 +#endif
49177 +
49178 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49179 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49180 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49181 + put_cpu();
49182 + }
49183 +#endif
49184
49185 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49186 may depend on the personality. */
49187 SET_PERSONALITY(loc->elf_ex);
49188 +
49189 +#ifdef CONFIG_PAX_ASLR
49190 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49191 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49192 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49193 + }
49194 +#endif
49195 +
49196 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49197 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49198 + executable_stack = EXSTACK_DISABLE_X;
49199 + current->personality &= ~READ_IMPLIES_EXEC;
49200 + } else
49201 +#endif
49202 +
49203 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49204 current->personality |= READ_IMPLIES_EXEC;
49205
49206 @@ -819,6 +1224,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49207 #else
49208 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49209 #endif
49210 +
49211 +#ifdef CONFIG_PAX_RANDMMAP
49212 + /* PaX: randomize base address at the default exe base if requested */
49213 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49214 +#ifdef CONFIG_SPARC64
49215 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49216 +#else
49217 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49218 +#endif
49219 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49220 + elf_flags |= MAP_FIXED;
49221 + }
49222 +#endif
49223 +
49224 }
49225
49226 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49227 @@ -851,9 +1270,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49228 * allowed task size. Note that p_filesz must always be
49229 * <= p_memsz so it is only necessary to check p_memsz.
49230 */
49231 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49232 - elf_ppnt->p_memsz > TASK_SIZE ||
49233 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49234 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49235 + elf_ppnt->p_memsz > pax_task_size ||
49236 + pax_task_size - elf_ppnt->p_memsz < k) {
49237 /* set_brk can never work. Avoid overflows. */
49238 send_sig(SIGKILL, current, 0);
49239 retval = -EINVAL;
49240 @@ -892,17 +1311,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49241 goto out_free_dentry;
49242 }
49243 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49244 - send_sig(SIGSEGV, current, 0);
49245 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49246 - goto out_free_dentry;
49247 + /*
49248 + * This bss-zeroing can fail if the ELF
49249 + * file specifies odd protections. So
49250 + * we don't check the return value
49251 + */
49252 }
49253
49254 +#ifdef CONFIG_PAX_RANDMMAP
49255 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49256 + unsigned long start, size, flags;
49257 + vm_flags_t vm_flags;
49258 +
49259 + start = ELF_PAGEALIGN(elf_brk);
49260 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49261 + flags = MAP_FIXED | MAP_PRIVATE;
49262 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49263 +
49264 + down_write(&current->mm->mmap_sem);
49265 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49266 + retval = -ENOMEM;
49267 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49268 +// if (current->personality & ADDR_NO_RANDOMIZE)
49269 +// vm_flags |= VM_READ | VM_MAYREAD;
49270 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49271 + retval = IS_ERR_VALUE(start) ? start : 0;
49272 + }
49273 + up_write(&current->mm->mmap_sem);
49274 + if (retval == 0)
49275 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49276 + if (retval < 0) {
49277 + send_sig(SIGKILL, current, 0);
49278 + goto out_free_dentry;
49279 + }
49280 + }
49281 +#endif
49282 +
49283 if (elf_interpreter) {
49284 - unsigned long interp_map_addr = 0;
49285 -
49286 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49287 interpreter,
49288 - &interp_map_addr,
49289 load_bias);
49290 if (!IS_ERR((void *)elf_entry)) {
49291 /*
49292 @@ -1124,7 +1571,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49293 * Decide what to dump of a segment, part, all or none.
49294 */
49295 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49296 - unsigned long mm_flags)
49297 + unsigned long mm_flags, long signr)
49298 {
49299 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49300
49301 @@ -1162,7 +1609,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49302 if (vma->vm_file == NULL)
49303 return 0;
49304
49305 - if (FILTER(MAPPED_PRIVATE))
49306 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49307 goto whole;
49308
49309 /*
49310 @@ -1387,9 +1834,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49311 {
49312 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49313 int i = 0;
49314 - do
49315 + do {
49316 i += 2;
49317 - while (auxv[i - 2] != AT_NULL);
49318 + } while (auxv[i - 2] != AT_NULL);
49319 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49320 }
49321
49322 @@ -1398,7 +1845,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49323 {
49324 mm_segment_t old_fs = get_fs();
49325 set_fs(KERNEL_DS);
49326 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49327 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49328 set_fs(old_fs);
49329 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49330 }
49331 @@ -2019,14 +2466,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49332 }
49333
49334 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49335 - unsigned long mm_flags)
49336 + struct coredump_params *cprm)
49337 {
49338 struct vm_area_struct *vma;
49339 size_t size = 0;
49340
49341 for (vma = first_vma(current, gate_vma); vma != NULL;
49342 vma = next_vma(vma, gate_vma))
49343 - size += vma_dump_size(vma, mm_flags);
49344 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49345 return size;
49346 }
49347
49348 @@ -2119,7 +2566,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49349
49350 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49351
49352 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49353 + offset += elf_core_vma_data_size(gate_vma, cprm);
49354 offset += elf_core_extra_data_size();
49355 e_shoff = offset;
49356
49357 @@ -2133,10 +2580,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49358 offset = dataoff;
49359
49360 size += sizeof(*elf);
49361 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49362 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49363 goto end_coredump;
49364
49365 size += sizeof(*phdr4note);
49366 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49367 if (size > cprm->limit
49368 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49369 goto end_coredump;
49370 @@ -2150,7 +2599,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49371 phdr.p_offset = offset;
49372 phdr.p_vaddr = vma->vm_start;
49373 phdr.p_paddr = 0;
49374 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49375 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49376 phdr.p_memsz = vma->vm_end - vma->vm_start;
49377 offset += phdr.p_filesz;
49378 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49379 @@ -2161,6 +2610,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49380 phdr.p_align = ELF_EXEC_PAGESIZE;
49381
49382 size += sizeof(phdr);
49383 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49384 if (size > cprm->limit
49385 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49386 goto end_coredump;
49387 @@ -2185,7 +2635,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49388 unsigned long addr;
49389 unsigned long end;
49390
49391 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49392 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49393
49394 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49395 struct page *page;
49396 @@ -2194,6 +2644,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49397 page = get_dump_page(addr);
49398 if (page) {
49399 void *kaddr = kmap(page);
49400 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49401 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49402 !dump_write(cprm->file, kaddr,
49403 PAGE_SIZE);
49404 @@ -2211,6 +2662,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49405
49406 if (e_phnum == PN_XNUM) {
49407 size += sizeof(*shdr4extnum);
49408 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49409 if (size > cprm->limit
49410 || !dump_write(cprm->file, shdr4extnum,
49411 sizeof(*shdr4extnum)))
49412 @@ -2231,6 +2683,97 @@ out:
49413
49414 #endif /* CONFIG_ELF_CORE */
49415
49416 +#ifdef CONFIG_PAX_MPROTECT
49417 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49418 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49419 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49420 + *
49421 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49422 + * basis because we want to allow the common case and not the special ones.
49423 + */
49424 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49425 +{
49426 + struct elfhdr elf_h;
49427 + struct elf_phdr elf_p;
49428 + unsigned long i;
49429 + unsigned long oldflags;
49430 + bool is_textrel_rw, is_textrel_rx, is_relro;
49431 +
49432 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49433 + return;
49434 +
49435 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49436 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49437 +
49438 +#ifdef CONFIG_PAX_ELFRELOCS
49439 + /* possible TEXTREL */
49440 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49441 + 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);
49442 +#else
49443 + is_textrel_rw = false;
49444 + is_textrel_rx = false;
49445 +#endif
49446 +
49447 + /* possible RELRO */
49448 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49449 +
49450 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49451 + return;
49452 +
49453 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49454 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49455 +
49456 +#ifdef CONFIG_PAX_ETEXECRELOCS
49457 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49458 +#else
49459 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49460 +#endif
49461 +
49462 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49463 + !elf_check_arch(&elf_h) ||
49464 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49465 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49466 + return;
49467 +
49468 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49469 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49470 + return;
49471 + switch (elf_p.p_type) {
49472 + case PT_DYNAMIC:
49473 + if (!is_textrel_rw && !is_textrel_rx)
49474 + continue;
49475 + i = 0UL;
49476 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49477 + elf_dyn dyn;
49478 +
49479 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49480 + return;
49481 + if (dyn.d_tag == DT_NULL)
49482 + return;
49483 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49484 + gr_log_textrel(vma);
49485 + if (is_textrel_rw)
49486 + vma->vm_flags |= VM_MAYWRITE;
49487 + else
49488 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49489 + vma->vm_flags &= ~VM_MAYWRITE;
49490 + return;
49491 + }
49492 + i++;
49493 + }
49494 + return;
49495 +
49496 + case PT_GNU_RELRO:
49497 + if (!is_relro)
49498 + continue;
49499 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49500 + vma->vm_flags &= ~VM_MAYWRITE;
49501 + return;
49502 + }
49503 + }
49504 +}
49505 +#endif
49506 +
49507 static int __init init_elf_binfmt(void)
49508 {
49509 register_binfmt(&elf_format);
49510 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49511 index d50bbe5..af3b649 100644
49512 --- a/fs/binfmt_flat.c
49513 +++ b/fs/binfmt_flat.c
49514 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49515 realdatastart = (unsigned long) -ENOMEM;
49516 printk("Unable to allocate RAM for process data, errno %d\n",
49517 (int)-realdatastart);
49518 + down_write(&current->mm->mmap_sem);
49519 vm_munmap(textpos, text_len);
49520 + up_write(&current->mm->mmap_sem);
49521 ret = realdatastart;
49522 goto err;
49523 }
49524 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49525 }
49526 if (IS_ERR_VALUE(result)) {
49527 printk("Unable to read data+bss, errno %d\n", (int)-result);
49528 + down_write(&current->mm->mmap_sem);
49529 vm_munmap(textpos, text_len);
49530 vm_munmap(realdatastart, len);
49531 + up_write(&current->mm->mmap_sem);
49532 ret = result;
49533 goto err;
49534 }
49535 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49536 }
49537 if (IS_ERR_VALUE(result)) {
49538 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49539 + down_write(&current->mm->mmap_sem);
49540 vm_munmap(textpos, text_len + data_len + extra +
49541 MAX_SHARED_LIBS * sizeof(unsigned long));
49542 + up_write(&current->mm->mmap_sem);
49543 ret = result;
49544 goto err;
49545 }
49546 diff --git a/fs/bio.c b/fs/bio.c
49547 index 94bbc04..6fe78a4 100644
49548 --- a/fs/bio.c
49549 +++ b/fs/bio.c
49550 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49551 /*
49552 * Overflow, abort
49553 */
49554 - if (end < start)
49555 + if (end < start || end - start > INT_MAX - nr_pages)
49556 return ERR_PTR(-EINVAL);
49557
49558 nr_pages += end - start;
49559 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49560 /*
49561 * Overflow, abort
49562 */
49563 - if (end < start)
49564 + if (end < start || end - start > INT_MAX - nr_pages)
49565 return ERR_PTR(-EINVAL);
49566
49567 nr_pages += end - start;
49568 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49569 const int read = bio_data_dir(bio) == READ;
49570 struct bio_map_data *bmd = bio->bi_private;
49571 int i;
49572 - char *p = bmd->sgvecs[0].iov_base;
49573 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49574
49575 bio_for_each_segment_all(bvec, bio, i) {
49576 char *addr = page_address(bvec->bv_page);
49577 diff --git a/fs/block_dev.c b/fs/block_dev.c
49578 index 2091db8..81dafe9 100644
49579 --- a/fs/block_dev.c
49580 +++ b/fs/block_dev.c
49581 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49582 else if (bdev->bd_contains == bdev)
49583 return true; /* is a whole device which isn't held */
49584
49585 - else if (whole->bd_holder == bd_may_claim)
49586 + else if (whole->bd_holder == (void *)bd_may_claim)
49587 return true; /* is a partition of a device that is being partitioned */
49588 else if (whole->bd_holder != NULL)
49589 return false; /* is a partition of a held device */
49590 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49591 index 02fae7f..48da375 100644
49592 --- a/fs/btrfs/ctree.c
49593 +++ b/fs/btrfs/ctree.c
49594 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49595 free_extent_buffer(buf);
49596 add_root_to_dirty_list(root);
49597 } else {
49598 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49599 - parent_start = parent->start;
49600 - else
49601 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49602 + if (parent)
49603 + parent_start = parent->start;
49604 + else
49605 + parent_start = 0;
49606 + } else
49607 parent_start = 0;
49608
49609 WARN_ON(trans->transid != btrfs_header_generation(parent));
49610 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49611 index 0f81d67..0ad55fe 100644
49612 --- a/fs/btrfs/ioctl.c
49613 +++ b/fs/btrfs/ioctl.c
49614 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49615 for (i = 0; i < num_types; i++) {
49616 struct btrfs_space_info *tmp;
49617
49618 + /* Don't copy in more than we allocated */
49619 if (!slot_count)
49620 break;
49621
49622 + slot_count--;
49623 +
49624 info = NULL;
49625 rcu_read_lock();
49626 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49627 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49628 memcpy(dest, &space, sizeof(space));
49629 dest++;
49630 space_args.total_spaces++;
49631 - slot_count--;
49632 }
49633 - if (!slot_count)
49634 - break;
49635 }
49636 up_read(&info->groups_sem);
49637 }
49638 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49639 index f0857e0..e7023c5 100644
49640 --- a/fs/btrfs/super.c
49641 +++ b/fs/btrfs/super.c
49642 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49643 function, line, errstr);
49644 return;
49645 }
49646 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49647 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49648 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49649 }
49650 /*
49651 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49652 index 622f469..e8d2d55 100644
49653 --- a/fs/cachefiles/bind.c
49654 +++ b/fs/cachefiles/bind.c
49655 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49656 args);
49657
49658 /* start by checking things over */
49659 - ASSERT(cache->fstop_percent >= 0 &&
49660 - cache->fstop_percent < cache->fcull_percent &&
49661 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49662 cache->fcull_percent < cache->frun_percent &&
49663 cache->frun_percent < 100);
49664
49665 - ASSERT(cache->bstop_percent >= 0 &&
49666 - cache->bstop_percent < cache->bcull_percent &&
49667 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49668 cache->bcull_percent < cache->brun_percent &&
49669 cache->brun_percent < 100);
49670
49671 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49672 index 0a1467b..6a53245 100644
49673 --- a/fs/cachefiles/daemon.c
49674 +++ b/fs/cachefiles/daemon.c
49675 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49676 if (n > buflen)
49677 return -EMSGSIZE;
49678
49679 - if (copy_to_user(_buffer, buffer, n) != 0)
49680 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49681 return -EFAULT;
49682
49683 return n;
49684 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49685 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49686 return -EIO;
49687
49688 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49689 + if (datalen > PAGE_SIZE - 1)
49690 return -EOPNOTSUPP;
49691
49692 /* drag the command string into the kernel so we can parse it */
49693 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49694 if (args[0] != '%' || args[1] != '\0')
49695 return -EINVAL;
49696
49697 - if (fstop < 0 || fstop >= cache->fcull_percent)
49698 + if (fstop >= cache->fcull_percent)
49699 return cachefiles_daemon_range_error(cache, args);
49700
49701 cache->fstop_percent = fstop;
49702 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49703 if (args[0] != '%' || args[1] != '\0')
49704 return -EINVAL;
49705
49706 - if (bstop < 0 || bstop >= cache->bcull_percent)
49707 + if (bstop >= cache->bcull_percent)
49708 return cachefiles_daemon_range_error(cache, args);
49709
49710 cache->bstop_percent = bstop;
49711 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49712 index 4938251..7e01445 100644
49713 --- a/fs/cachefiles/internal.h
49714 +++ b/fs/cachefiles/internal.h
49715 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49716 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49717 struct rb_root active_nodes; /* active nodes (can't be culled) */
49718 rwlock_t active_lock; /* lock for active_nodes */
49719 - atomic_t gravecounter; /* graveyard uniquifier */
49720 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49721 unsigned frun_percent; /* when to stop culling (% files) */
49722 unsigned fcull_percent; /* when to start culling (% files) */
49723 unsigned fstop_percent; /* when to stop allocating (% files) */
49724 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49725 * proc.c
49726 */
49727 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49728 -extern atomic_t cachefiles_lookup_histogram[HZ];
49729 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49730 -extern atomic_t cachefiles_create_histogram[HZ];
49731 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49732 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49733 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49734
49735 extern int __init cachefiles_proc_init(void);
49736 extern void cachefiles_proc_cleanup(void);
49737 static inline
49738 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49739 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49740 {
49741 unsigned long jif = jiffies - start_jif;
49742 if (jif >= HZ)
49743 jif = HZ - 1;
49744 - atomic_inc(&histogram[jif]);
49745 + atomic_inc_unchecked(&histogram[jif]);
49746 }
49747
49748 #else
49749 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49750 index 8c01c5fc..15f982e 100644
49751 --- a/fs/cachefiles/namei.c
49752 +++ b/fs/cachefiles/namei.c
49753 @@ -317,7 +317,7 @@ try_again:
49754 /* first step is to make up a grave dentry in the graveyard */
49755 sprintf(nbuffer, "%08x%08x",
49756 (uint32_t) get_seconds(),
49757 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49758 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49759
49760 /* do the multiway lock magic */
49761 trap = lock_rename(cache->graveyard, dir);
49762 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49763 index eccd339..4c1d995 100644
49764 --- a/fs/cachefiles/proc.c
49765 +++ b/fs/cachefiles/proc.c
49766 @@ -14,9 +14,9 @@
49767 #include <linux/seq_file.h>
49768 #include "internal.h"
49769
49770 -atomic_t cachefiles_lookup_histogram[HZ];
49771 -atomic_t cachefiles_mkdir_histogram[HZ];
49772 -atomic_t cachefiles_create_histogram[HZ];
49773 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49774 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49775 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49776
49777 /*
49778 * display the latency histogram
49779 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49780 return 0;
49781 default:
49782 index = (unsigned long) v - 3;
49783 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49784 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49785 - z = atomic_read(&cachefiles_create_histogram[index]);
49786 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49787 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49788 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49789 if (x == 0 && y == 0 && z == 0)
49790 return 0;
49791
49792 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49793 index 317f9ee..3d24511 100644
49794 --- a/fs/cachefiles/rdwr.c
49795 +++ b/fs/cachefiles/rdwr.c
49796 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49797 old_fs = get_fs();
49798 set_fs(KERNEL_DS);
49799 ret = file->f_op->write(
49800 - file, (const void __user *) data, len, &pos);
49801 + file, (const void __force_user *) data, len, &pos);
49802 set_fs(old_fs);
49803 kunmap(page);
49804 file_end_write(file);
49805 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49806 index f02d82b..2632cf86 100644
49807 --- a/fs/ceph/dir.c
49808 +++ b/fs/ceph/dir.c
49809 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49810 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49811 struct ceph_mds_client *mdsc = fsc->mdsc;
49812 unsigned frag = fpos_frag(filp->f_pos);
49813 - int off = fpos_off(filp->f_pos);
49814 + unsigned int off = fpos_off(filp->f_pos);
49815 int err;
49816 u32 ftype;
49817 struct ceph_mds_reply_info_parsed *rinfo;
49818 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49819 index d597483..747901b 100644
49820 --- a/fs/cifs/cifs_debug.c
49821 +++ b/fs/cifs/cifs_debug.c
49822 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49823
49824 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49825 #ifdef CONFIG_CIFS_STATS2
49826 - atomic_set(&totBufAllocCount, 0);
49827 - atomic_set(&totSmBufAllocCount, 0);
49828 + atomic_set_unchecked(&totBufAllocCount, 0);
49829 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49830 #endif /* CONFIG_CIFS_STATS2 */
49831 spin_lock(&cifs_tcp_ses_lock);
49832 list_for_each(tmp1, &cifs_tcp_ses_list) {
49833 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49834 tcon = list_entry(tmp3,
49835 struct cifs_tcon,
49836 tcon_list);
49837 - atomic_set(&tcon->num_smbs_sent, 0);
49838 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49839 if (server->ops->clear_stats)
49840 server->ops->clear_stats(tcon);
49841 }
49842 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49843 smBufAllocCount.counter, cifs_min_small);
49844 #ifdef CONFIG_CIFS_STATS2
49845 seq_printf(m, "Total Large %d Small %d Allocations\n",
49846 - atomic_read(&totBufAllocCount),
49847 - atomic_read(&totSmBufAllocCount));
49848 + atomic_read_unchecked(&totBufAllocCount),
49849 + atomic_read_unchecked(&totSmBufAllocCount));
49850 #endif /* CONFIG_CIFS_STATS2 */
49851
49852 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49853 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49854 if (tcon->need_reconnect)
49855 seq_puts(m, "\tDISCONNECTED ");
49856 seq_printf(m, "\nSMBs: %d",
49857 - atomic_read(&tcon->num_smbs_sent));
49858 + atomic_read_unchecked(&tcon->num_smbs_sent));
49859 if (server->ops->print_stats)
49860 server->ops->print_stats(m, tcon);
49861 }
49862 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49863 index 3752b9f..8db5569 100644
49864 --- a/fs/cifs/cifsfs.c
49865 +++ b/fs/cifs/cifsfs.c
49866 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
49867 */
49868 cifs_req_cachep = kmem_cache_create("cifs_request",
49869 CIFSMaxBufSize + max_hdr_size, 0,
49870 - SLAB_HWCACHE_ALIGN, NULL);
49871 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49872 if (cifs_req_cachep == NULL)
49873 return -ENOMEM;
49874
49875 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
49876 efficient to alloc 1 per page off the slab compared to 17K (5page)
49877 alloc of large cifs buffers even when page debugging is on */
49878 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49879 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49880 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49881 NULL);
49882 if (cifs_sm_req_cachep == NULL) {
49883 mempool_destroy(cifs_req_poolp);
49884 @@ -1147,8 +1147,8 @@ init_cifs(void)
49885 atomic_set(&bufAllocCount, 0);
49886 atomic_set(&smBufAllocCount, 0);
49887 #ifdef CONFIG_CIFS_STATS2
49888 - atomic_set(&totBufAllocCount, 0);
49889 - atomic_set(&totSmBufAllocCount, 0);
49890 + atomic_set_unchecked(&totBufAllocCount, 0);
49891 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49892 #endif /* CONFIG_CIFS_STATS2 */
49893
49894 atomic_set(&midCount, 0);
49895 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49896 index 4f07f6f..55de8ce 100644
49897 --- a/fs/cifs/cifsglob.h
49898 +++ b/fs/cifs/cifsglob.h
49899 @@ -751,35 +751,35 @@ struct cifs_tcon {
49900 __u16 Flags; /* optional support bits */
49901 enum statusEnum tidStatus;
49902 #ifdef CONFIG_CIFS_STATS
49903 - atomic_t num_smbs_sent;
49904 + atomic_unchecked_t num_smbs_sent;
49905 union {
49906 struct {
49907 - atomic_t num_writes;
49908 - atomic_t num_reads;
49909 - atomic_t num_flushes;
49910 - atomic_t num_oplock_brks;
49911 - atomic_t num_opens;
49912 - atomic_t num_closes;
49913 - atomic_t num_deletes;
49914 - atomic_t num_mkdirs;
49915 - atomic_t num_posixopens;
49916 - atomic_t num_posixmkdirs;
49917 - atomic_t num_rmdirs;
49918 - atomic_t num_renames;
49919 - atomic_t num_t2renames;
49920 - atomic_t num_ffirst;
49921 - atomic_t num_fnext;
49922 - atomic_t num_fclose;
49923 - atomic_t num_hardlinks;
49924 - atomic_t num_symlinks;
49925 - atomic_t num_locks;
49926 - atomic_t num_acl_get;
49927 - atomic_t num_acl_set;
49928 + atomic_unchecked_t num_writes;
49929 + atomic_unchecked_t num_reads;
49930 + atomic_unchecked_t num_flushes;
49931 + atomic_unchecked_t num_oplock_brks;
49932 + atomic_unchecked_t num_opens;
49933 + atomic_unchecked_t num_closes;
49934 + atomic_unchecked_t num_deletes;
49935 + atomic_unchecked_t num_mkdirs;
49936 + atomic_unchecked_t num_posixopens;
49937 + atomic_unchecked_t num_posixmkdirs;
49938 + atomic_unchecked_t num_rmdirs;
49939 + atomic_unchecked_t num_renames;
49940 + atomic_unchecked_t num_t2renames;
49941 + atomic_unchecked_t num_ffirst;
49942 + atomic_unchecked_t num_fnext;
49943 + atomic_unchecked_t num_fclose;
49944 + atomic_unchecked_t num_hardlinks;
49945 + atomic_unchecked_t num_symlinks;
49946 + atomic_unchecked_t num_locks;
49947 + atomic_unchecked_t num_acl_get;
49948 + atomic_unchecked_t num_acl_set;
49949 } cifs_stats;
49950 #ifdef CONFIG_CIFS_SMB2
49951 struct {
49952 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49953 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49954 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49955 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49956 } smb2_stats;
49957 #endif /* CONFIG_CIFS_SMB2 */
49958 } stats;
49959 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49960 }
49961
49962 #ifdef CONFIG_CIFS_STATS
49963 -#define cifs_stats_inc atomic_inc
49964 +#define cifs_stats_inc atomic_inc_unchecked
49965
49966 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49967 unsigned int bytes)
49968 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49969 /* Various Debug counters */
49970 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49971 #ifdef CONFIG_CIFS_STATS2
49972 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49973 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49974 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49975 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49976 #endif
49977 GLOBAL_EXTERN atomic_t smBufAllocCount;
49978 GLOBAL_EXTERN atomic_t midCount;
49979 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49980 index b83c3f5..6437caa 100644
49981 --- a/fs/cifs/link.c
49982 +++ b/fs/cifs/link.c
49983 @@ -616,7 +616,7 @@ symlink_exit:
49984
49985 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49986 {
49987 - char *p = nd_get_link(nd);
49988 + const char *p = nd_get_link(nd);
49989 if (!IS_ERR(p))
49990 kfree(p);
49991 }
49992 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49993 index 1bec014..f329411 100644
49994 --- a/fs/cifs/misc.c
49995 +++ b/fs/cifs/misc.c
49996 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49997 memset(ret_buf, 0, buf_size + 3);
49998 atomic_inc(&bufAllocCount);
49999 #ifdef CONFIG_CIFS_STATS2
50000 - atomic_inc(&totBufAllocCount);
50001 + atomic_inc_unchecked(&totBufAllocCount);
50002 #endif /* CONFIG_CIFS_STATS2 */
50003 }
50004
50005 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50006 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50007 atomic_inc(&smBufAllocCount);
50008 #ifdef CONFIG_CIFS_STATS2
50009 - atomic_inc(&totSmBufAllocCount);
50010 + atomic_inc_unchecked(&totSmBufAllocCount);
50011 #endif /* CONFIG_CIFS_STATS2 */
50012
50013 }
50014 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50015 index 3efdb9d..e845a5e 100644
50016 --- a/fs/cifs/smb1ops.c
50017 +++ b/fs/cifs/smb1ops.c
50018 @@ -591,27 +591,27 @@ static void
50019 cifs_clear_stats(struct cifs_tcon *tcon)
50020 {
50021 #ifdef CONFIG_CIFS_STATS
50022 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50023 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50024 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50025 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50026 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50027 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50028 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50029 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50030 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50031 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50032 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50033 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50034 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50035 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50036 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50037 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50038 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50039 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50040 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50041 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50042 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50043 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50044 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50045 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50046 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50047 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50048 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50049 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50050 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50051 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50052 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50053 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50054 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50055 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50056 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50057 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50058 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50059 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50060 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50061 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50062 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50063 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50064 #endif
50065 }
50066
50067 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50068 {
50069 #ifdef CONFIG_CIFS_STATS
50070 seq_printf(m, " Oplocks breaks: %d",
50071 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50072 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50073 seq_printf(m, "\nReads: %d Bytes: %llu",
50074 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50075 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50076 (long long)(tcon->bytes_read));
50077 seq_printf(m, "\nWrites: %d Bytes: %llu",
50078 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50079 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50080 (long long)(tcon->bytes_written));
50081 seq_printf(m, "\nFlushes: %d",
50082 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50083 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50084 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50085 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50086 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50087 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50088 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50089 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50090 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50091 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50092 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50093 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50094 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50095 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50096 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50097 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50098 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50099 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50100 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50101 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50102 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50103 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50104 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50105 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50106 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50107 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50108 seq_printf(m, "\nRenames: %d T2 Renames %d",
50109 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50110 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50111 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50112 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50113 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50114 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50115 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50116 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50117 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50118 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50119 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50120 #endif
50121 }
50122
50123 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50124 index f2e76f3..c44fac7 100644
50125 --- a/fs/cifs/smb2ops.c
50126 +++ b/fs/cifs/smb2ops.c
50127 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50128 #ifdef CONFIG_CIFS_STATS
50129 int i;
50130 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50131 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50132 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50133 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50134 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50135 }
50136 #endif
50137 }
50138 @@ -284,66 +284,66 @@ static void
50139 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50140 {
50141 #ifdef CONFIG_CIFS_STATS
50142 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50143 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50144 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50145 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50146 seq_printf(m, "\nNegotiates: %d sent %d failed",
50147 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50148 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50149 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50150 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50151 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50152 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50153 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50154 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50155 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50156 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50157 seq_printf(m, "\nLogoffs: %d sent %d failed",
50158 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50159 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50160 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50161 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50162 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50163 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50164 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50165 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50166 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50167 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50168 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50169 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50170 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50171 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50172 seq_printf(m, "\nCreates: %d sent %d failed",
50173 - atomic_read(&sent[SMB2_CREATE_HE]),
50174 - atomic_read(&failed[SMB2_CREATE_HE]));
50175 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50176 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50177 seq_printf(m, "\nCloses: %d sent %d failed",
50178 - atomic_read(&sent[SMB2_CLOSE_HE]),
50179 - atomic_read(&failed[SMB2_CLOSE_HE]));
50180 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50181 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50182 seq_printf(m, "\nFlushes: %d sent %d failed",
50183 - atomic_read(&sent[SMB2_FLUSH_HE]),
50184 - atomic_read(&failed[SMB2_FLUSH_HE]));
50185 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50186 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50187 seq_printf(m, "\nReads: %d sent %d failed",
50188 - atomic_read(&sent[SMB2_READ_HE]),
50189 - atomic_read(&failed[SMB2_READ_HE]));
50190 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50191 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50192 seq_printf(m, "\nWrites: %d sent %d failed",
50193 - atomic_read(&sent[SMB2_WRITE_HE]),
50194 - atomic_read(&failed[SMB2_WRITE_HE]));
50195 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50196 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50197 seq_printf(m, "\nLocks: %d sent %d failed",
50198 - atomic_read(&sent[SMB2_LOCK_HE]),
50199 - atomic_read(&failed[SMB2_LOCK_HE]));
50200 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50201 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50202 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50203 - atomic_read(&sent[SMB2_IOCTL_HE]),
50204 - atomic_read(&failed[SMB2_IOCTL_HE]));
50205 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50206 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50207 seq_printf(m, "\nCancels: %d sent %d failed",
50208 - atomic_read(&sent[SMB2_CANCEL_HE]),
50209 - atomic_read(&failed[SMB2_CANCEL_HE]));
50210 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50211 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50212 seq_printf(m, "\nEchos: %d sent %d failed",
50213 - atomic_read(&sent[SMB2_ECHO_HE]),
50214 - atomic_read(&failed[SMB2_ECHO_HE]));
50215 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50216 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50217 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50218 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50219 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50220 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50221 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50222 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50223 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50224 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50225 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50226 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50227 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50228 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50229 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50230 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50231 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50232 seq_printf(m, "\nSetInfos: %d sent %d failed",
50233 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50234 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50235 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50236 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50237 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50238 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50239 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50240 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50241 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50242 #endif
50243 }
50244
50245 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50246 index 2b95ce2..d079d75 100644
50247 --- a/fs/cifs/smb2pdu.c
50248 +++ b/fs/cifs/smb2pdu.c
50249 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50250 default:
50251 cifs_dbg(VFS, "info level %u isn't supported\n",
50252 srch_inf->info_level);
50253 - rc = -EINVAL;
50254 - goto qdir_exit;
50255 + return -EINVAL;
50256 }
50257
50258 req->FileIndex = cpu_to_le32(index);
50259 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50260 index 1da168c..8bc7ff6 100644
50261 --- a/fs/coda/cache.c
50262 +++ b/fs/coda/cache.c
50263 @@ -24,7 +24,7 @@
50264 #include "coda_linux.h"
50265 #include "coda_cache.h"
50266
50267 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50268 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50269
50270 /* replace or extend an acl cache hit */
50271 void coda_cache_enter(struct inode *inode, int mask)
50272 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50273 struct coda_inode_info *cii = ITOC(inode);
50274
50275 spin_lock(&cii->c_lock);
50276 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50277 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50278 if (!uid_eq(cii->c_uid, current_fsuid())) {
50279 cii->c_uid = current_fsuid();
50280 cii->c_cached_perm = mask;
50281 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50282 {
50283 struct coda_inode_info *cii = ITOC(inode);
50284 spin_lock(&cii->c_lock);
50285 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50286 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50287 spin_unlock(&cii->c_lock);
50288 }
50289
50290 /* remove all acl caches */
50291 void coda_cache_clear_all(struct super_block *sb)
50292 {
50293 - atomic_inc(&permission_epoch);
50294 + atomic_inc_unchecked(&permission_epoch);
50295 }
50296
50297
50298 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50299 spin_lock(&cii->c_lock);
50300 hit = (mask & cii->c_cached_perm) == mask &&
50301 uid_eq(cii->c_uid, current_fsuid()) &&
50302 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50303 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50304 spin_unlock(&cii->c_lock);
50305
50306 return hit;
50307 diff --git a/fs/compat.c b/fs/compat.c
50308 index fc3b55d..7b568ae 100644
50309 --- a/fs/compat.c
50310 +++ b/fs/compat.c
50311 @@ -54,7 +54,7 @@
50312 #include <asm/ioctls.h>
50313 #include "internal.h"
50314
50315 -int compat_log = 1;
50316 +int compat_log = 0;
50317
50318 int compat_printk(const char *fmt, ...)
50319 {
50320 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50321
50322 set_fs(KERNEL_DS);
50323 /* The __user pointer cast is valid because of the set_fs() */
50324 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50325 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50326 set_fs(oldfs);
50327 /* truncating is ok because it's a user address */
50328 if (!ret)
50329 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50330 goto out;
50331
50332 ret = -EINVAL;
50333 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50334 + if (nr_segs > UIO_MAXIOV)
50335 goto out;
50336 if (nr_segs > fast_segs) {
50337 ret = -ENOMEM;
50338 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
50339
50340 struct compat_readdir_callback {
50341 struct compat_old_linux_dirent __user *dirent;
50342 + struct file * file;
50343 int result;
50344 };
50345
50346 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50347 buf->result = -EOVERFLOW;
50348 return -EOVERFLOW;
50349 }
50350 +
50351 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50352 + return 0;
50353 +
50354 buf->result++;
50355 dirent = buf->dirent;
50356 if (!access_ok(VERIFY_WRITE, dirent,
50357 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50358
50359 buf.result = 0;
50360 buf.dirent = dirent;
50361 + buf.file = f.file;
50362
50363 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50364 if (buf.result)
50365 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
50366 struct compat_getdents_callback {
50367 struct compat_linux_dirent __user *current_dir;
50368 struct compat_linux_dirent __user *previous;
50369 + struct file * file;
50370 int count;
50371 int error;
50372 };
50373 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50374 buf->error = -EOVERFLOW;
50375 return -EOVERFLOW;
50376 }
50377 +
50378 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50379 + return 0;
50380 +
50381 dirent = buf->previous;
50382 if (dirent) {
50383 if (__put_user(offset, &dirent->d_off))
50384 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50385 buf.previous = NULL;
50386 buf.count = count;
50387 buf.error = 0;
50388 + buf.file = f.file;
50389
50390 error = vfs_readdir(f.file, compat_filldir, &buf);
50391 if (error >= 0)
50392 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50393 struct compat_getdents_callback64 {
50394 struct linux_dirent64 __user *current_dir;
50395 struct linux_dirent64 __user *previous;
50396 + struct file * file;
50397 int count;
50398 int error;
50399 };
50400 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50401 buf->error = -EINVAL; /* only used if we fail.. */
50402 if (reclen > buf->count)
50403 return -EINVAL;
50404 +
50405 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50406 + return 0;
50407 +
50408 dirent = buf->previous;
50409
50410 if (dirent) {
50411 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50412 buf.previous = NULL;
50413 buf.count = count;
50414 buf.error = 0;
50415 + buf.file = f.file;
50416
50417 error = vfs_readdir(f.file, compat_filldir64, &buf);
50418 if (error >= 0)
50419 error = buf.error;
50420 lastdirent = buf.previous;
50421 if (lastdirent) {
50422 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50423 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50424 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50425 error = -EFAULT;
50426 else
50427 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50428 index a81147e..20bf2b5 100644
50429 --- a/fs/compat_binfmt_elf.c
50430 +++ b/fs/compat_binfmt_elf.c
50431 @@ -30,11 +30,13 @@
50432 #undef elf_phdr
50433 #undef elf_shdr
50434 #undef elf_note
50435 +#undef elf_dyn
50436 #undef elf_addr_t
50437 #define elfhdr elf32_hdr
50438 #define elf_phdr elf32_phdr
50439 #define elf_shdr elf32_shdr
50440 #define elf_note elf32_note
50441 +#define elf_dyn Elf32_Dyn
50442 #define elf_addr_t Elf32_Addr
50443
50444 /*
50445 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50446 index 996cdc5..15e2f33 100644
50447 --- a/fs/compat_ioctl.c
50448 +++ b/fs/compat_ioctl.c
50449 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50450 return -EFAULT;
50451 if (__get_user(udata, &ss32->iomem_base))
50452 return -EFAULT;
50453 - ss.iomem_base = compat_ptr(udata);
50454 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50455 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50456 __get_user(ss.port_high, &ss32->port_high))
50457 return -EFAULT;
50458 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50459 for (i = 0; i < nmsgs; i++) {
50460 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50461 return -EFAULT;
50462 - if (get_user(datap, &umsgs[i].buf) ||
50463 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50464 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50465 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50466 return -EFAULT;
50467 }
50468 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50469 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
50470 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50471 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50472 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50473 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50474 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50475 return -EFAULT;
50476
50477 return ioctl_preallocate(file, p);
50478 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50479 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50480 {
50481 unsigned int a, b;
50482 - a = *(unsigned int *)p;
50483 - b = *(unsigned int *)q;
50484 + a = *(const unsigned int *)p;
50485 + b = *(const unsigned int *)q;
50486 if (a > b)
50487 return 1;
50488 if (a < b)
50489 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50490 index 7aabc6a..34c1197 100644
50491 --- a/fs/configfs/dir.c
50492 +++ b/fs/configfs/dir.c
50493 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50494 }
50495 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50496 struct configfs_dirent *next;
50497 - const char * name;
50498 + const unsigned char * name;
50499 + char d_name[sizeof(next->s_dentry->d_iname)];
50500 int len;
50501 struct inode *inode = NULL;
50502
50503 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50504 continue;
50505
50506 name = configfs_get_name(next);
50507 - len = strlen(name);
50508 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50509 + len = next->s_dentry->d_name.len;
50510 + memcpy(d_name, name, len);
50511 + name = d_name;
50512 + } else
50513 + len = strlen(name);
50514
50515 /*
50516 * We'll have a dentry and an inode for
50517 diff --git a/fs/coredump.c b/fs/coredump.c
50518 index dafafba..10b3b27 100644
50519 --- a/fs/coredump.c
50520 +++ b/fs/coredump.c
50521 @@ -52,7 +52,7 @@ struct core_name {
50522 char *corename;
50523 int used, size;
50524 };
50525 -static atomic_t call_count = ATOMIC_INIT(1);
50526 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50527
50528 /* The maximal length of core_pattern is also specified in sysctl.c */
50529
50530 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50531 {
50532 char *old_corename = cn->corename;
50533
50534 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50535 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50536 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50537
50538 if (!cn->corename) {
50539 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50540 int pid_in_pattern = 0;
50541 int err = 0;
50542
50543 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50544 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50545 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50546 cn->used = 0;
50547
50548 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
50549 struct pipe_inode_info *pipe = file->private_data;
50550
50551 pipe_lock(pipe);
50552 - pipe->readers++;
50553 - pipe->writers--;
50554 + atomic_inc(&pipe->readers);
50555 + atomic_dec(&pipe->writers);
50556 wake_up_interruptible_sync(&pipe->wait);
50557 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50558 pipe_unlock(pipe);
50559 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
50560 * We actually want wait_event_freezable() but then we need
50561 * to clear TIF_SIGPENDING and improve dump_interrupted().
50562 */
50563 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
50564 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
50565
50566 pipe_lock(pipe);
50567 - pipe->readers--;
50568 - pipe->writers++;
50569 + atomic_dec(&pipe->readers);
50570 + atomic_inc(&pipe->writers);
50571 pipe_unlock(pipe);
50572 }
50573
50574 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
50575 struct files_struct *displaced;
50576 bool need_nonrelative = false;
50577 bool core_dumped = false;
50578 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50579 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50580 + long signr = siginfo->si_signo;
50581 struct coredump_params cprm = {
50582 .siginfo = siginfo,
50583 .regs = signal_pt_regs(),
50584 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
50585 .mm_flags = mm->flags,
50586 };
50587
50588 - audit_core_dumps(siginfo->si_signo);
50589 + audit_core_dumps(signr);
50590 +
50591 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50592 + gr_handle_brute_attach(cprm.mm_flags);
50593
50594 binfmt = mm->binfmt;
50595 if (!binfmt || !binfmt->core_dump)
50596 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
50597 need_nonrelative = true;
50598 }
50599
50600 - retval = coredump_wait(siginfo->si_signo, &core_state);
50601 + retval = coredump_wait(signr, &core_state);
50602 if (retval < 0)
50603 goto fail_creds;
50604
50605 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
50606 }
50607 cprm.limit = RLIM_INFINITY;
50608
50609 - dump_count = atomic_inc_return(&core_dump_count);
50610 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50611 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50612 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50613 task_tgid_vnr(current), current->comm);
50614 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
50615 } else {
50616 struct inode *inode;
50617
50618 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50619 +
50620 if (cprm.limit < binfmt->min_coredump)
50621 goto fail_unlock;
50622
50623 @@ -666,7 +672,7 @@ close_fail:
50624 filp_close(cprm.file, NULL);
50625 fail_dropcount:
50626 if (ispipe)
50627 - atomic_dec(&core_dump_count);
50628 + atomic_dec_unchecked(&core_dump_count);
50629 fail_unlock:
50630 kfree(cn.corename);
50631 fail_corename:
50632 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
50633 {
50634 return !dump_interrupted() &&
50635 access_ok(VERIFY_READ, addr, nr) &&
50636 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50637 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50638 }
50639 EXPORT_SYMBOL(dump_write);
50640
50641 diff --git a/fs/dcache.c b/fs/dcache.c
50642 index f09b908..4dd10d8 100644
50643 --- a/fs/dcache.c
50644 +++ b/fs/dcache.c
50645 @@ -3086,7 +3086,7 @@ void __init vfs_caches_init(unsigned long mempages)
50646 mempages -= reserve;
50647
50648 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50649 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50650 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50651
50652 dcache_init();
50653 inode_init();
50654 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50655 index 4888cb3..e0f7cf8 100644
50656 --- a/fs/debugfs/inode.c
50657 +++ b/fs/debugfs/inode.c
50658 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50659 */
50660 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50661 {
50662 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50663 + return __create_file(name, S_IFDIR | S_IRWXU,
50664 +#else
50665 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50666 +#endif
50667 parent, NULL, NULL);
50668 }
50669 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50670 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50671 index 5eab400..810a3f5 100644
50672 --- a/fs/ecryptfs/inode.c
50673 +++ b/fs/ecryptfs/inode.c
50674 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50675 old_fs = get_fs();
50676 set_fs(get_ds());
50677 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50678 - (char __user *)lower_buf,
50679 + (char __force_user *)lower_buf,
50680 PATH_MAX);
50681 set_fs(old_fs);
50682 if (rc < 0)
50683 @@ -706,7 +706,7 @@ out:
50684 static void
50685 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50686 {
50687 - char *buf = nd_get_link(nd);
50688 + const char *buf = nd_get_link(nd);
50689 if (!IS_ERR(buf)) {
50690 /* Free the char* */
50691 kfree(buf);
50692 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50693 index e4141f2..d8263e8 100644
50694 --- a/fs/ecryptfs/miscdev.c
50695 +++ b/fs/ecryptfs/miscdev.c
50696 @@ -304,7 +304,7 @@ check_list:
50697 goto out_unlock_msg_ctx;
50698 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50699 if (msg_ctx->msg) {
50700 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50701 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50702 goto out_unlock_msg_ctx;
50703 i += packet_length_size;
50704 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50705 diff --git a/fs/exec.c b/fs/exec.c
50706 index ffd7a81..e38107f 100644
50707 --- a/fs/exec.c
50708 +++ b/fs/exec.c
50709 @@ -55,8 +55,20 @@
50710 #include <linux/pipe_fs_i.h>
50711 #include <linux/oom.h>
50712 #include <linux/compat.h>
50713 +#include <linux/random.h>
50714 +#include <linux/seq_file.h>
50715 +#include <linux/coredump.h>
50716 +#include <linux/mman.h>
50717 +
50718 +#ifdef CONFIG_PAX_REFCOUNT
50719 +#include <linux/kallsyms.h>
50720 +#include <linux/kdebug.h>
50721 +#endif
50722 +
50723 +#include <trace/events/fs.h>
50724
50725 #include <asm/uaccess.h>
50726 +#include <asm/sections.h>
50727 #include <asm/mmu_context.h>
50728 #include <asm/tlb.h>
50729
50730 @@ -66,17 +78,32 @@
50731
50732 #include <trace/events/sched.h>
50733
50734 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50735 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50736 +{
50737 + 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");
50738 +}
50739 +#endif
50740 +
50741 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50742 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50743 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50744 +#endif
50745 +
50746 int suid_dumpable = 0;
50747
50748 static LIST_HEAD(formats);
50749 static DEFINE_RWLOCK(binfmt_lock);
50750
50751 +extern int gr_process_kernel_exec_ban(void);
50752 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
50753 +
50754 void __register_binfmt(struct linux_binfmt * fmt, int insert)
50755 {
50756 BUG_ON(!fmt);
50757 write_lock(&binfmt_lock);
50758 - insert ? list_add(&fmt->lh, &formats) :
50759 - list_add_tail(&fmt->lh, &formats);
50760 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50761 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50762 write_unlock(&binfmt_lock);
50763 }
50764
50765 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
50766 void unregister_binfmt(struct linux_binfmt * fmt)
50767 {
50768 write_lock(&binfmt_lock);
50769 - list_del(&fmt->lh);
50770 + pax_list_del((struct list_head *)&fmt->lh);
50771 write_unlock(&binfmt_lock);
50772 }
50773
50774 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50775 int write)
50776 {
50777 struct page *page;
50778 - int ret;
50779
50780 -#ifdef CONFIG_STACK_GROWSUP
50781 - if (write) {
50782 - ret = expand_downwards(bprm->vma, pos);
50783 - if (ret < 0)
50784 - return NULL;
50785 - }
50786 -#endif
50787 - ret = get_user_pages(current, bprm->mm, pos,
50788 - 1, write, 1, &page, NULL);
50789 - if (ret <= 0)
50790 + if (0 > expand_downwards(bprm->vma, pos))
50791 + return NULL;
50792 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50793 return NULL;
50794
50795 if (write) {
50796 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50797 if (size <= ARG_MAX)
50798 return page;
50799
50800 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50801 + // only allow 512KB for argv+env on suid/sgid binaries
50802 + // to prevent easy ASLR exhaustion
50803 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50804 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50805 + (size > (512 * 1024))) {
50806 + put_page(page);
50807 + return NULL;
50808 + }
50809 +#endif
50810 +
50811 /*
50812 * Limit to 1/4-th the stack size for the argv+env strings.
50813 * This ensures that:
50814 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50815 vma->vm_end = STACK_TOP_MAX;
50816 vma->vm_start = vma->vm_end - PAGE_SIZE;
50817 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50818 +
50819 +#ifdef CONFIG_PAX_SEGMEXEC
50820 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50821 +#endif
50822 +
50823 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50824 INIT_LIST_HEAD(&vma->anon_vma_chain);
50825
50826 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50827 mm->stack_vm = mm->total_vm = 1;
50828 up_write(&mm->mmap_sem);
50829 bprm->p = vma->vm_end - sizeof(void *);
50830 +
50831 +#ifdef CONFIG_PAX_RANDUSTACK
50832 + if (randomize_va_space)
50833 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
50834 +#endif
50835 +
50836 return 0;
50837 err:
50838 up_write(&mm->mmap_sem);
50839 @@ -396,7 +437,7 @@ struct user_arg_ptr {
50840 } ptr;
50841 };
50842
50843 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50844 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50845 {
50846 const char __user *native;
50847
50848 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50849 compat_uptr_t compat;
50850
50851 if (get_user(compat, argv.ptr.compat + nr))
50852 - return ERR_PTR(-EFAULT);
50853 + return (const char __force_user *)ERR_PTR(-EFAULT);
50854
50855 return compat_ptr(compat);
50856 }
50857 #endif
50858
50859 if (get_user(native, argv.ptr.native + nr))
50860 - return ERR_PTR(-EFAULT);
50861 + return (const char __force_user *)ERR_PTR(-EFAULT);
50862
50863 return native;
50864 }
50865 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
50866 if (!p)
50867 break;
50868
50869 - if (IS_ERR(p))
50870 + if (IS_ERR((const char __force_kernel *)p))
50871 return -EFAULT;
50872
50873 if (i >= max)
50874 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50875
50876 ret = -EFAULT;
50877 str = get_user_arg_ptr(argv, argc);
50878 - if (IS_ERR(str))
50879 + if (IS_ERR((const char __force_kernel *)str))
50880 goto out;
50881
50882 len = strnlen_user(str, MAX_ARG_STRLEN);
50883 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50884 int r;
50885 mm_segment_t oldfs = get_fs();
50886 struct user_arg_ptr argv = {
50887 - .ptr.native = (const char __user *const __user *)__argv,
50888 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50889 };
50890
50891 set_fs(KERNEL_DS);
50892 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50893 unsigned long new_end = old_end - shift;
50894 struct mmu_gather tlb;
50895
50896 - BUG_ON(new_start > new_end);
50897 + if (new_start >= new_end || new_start < mmap_min_addr)
50898 + return -ENOMEM;
50899
50900 /*
50901 * ensure there are no vmas between where we want to go
50902 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50903 if (vma != find_vma(mm, new_start))
50904 return -EFAULT;
50905
50906 +#ifdef CONFIG_PAX_SEGMEXEC
50907 + BUG_ON(pax_find_mirror_vma(vma));
50908 +#endif
50909 +
50910 /*
50911 * cover the whole range: [new_start, old_end)
50912 */
50913 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50914 stack_top = arch_align_stack(stack_top);
50915 stack_top = PAGE_ALIGN(stack_top);
50916
50917 - if (unlikely(stack_top < mmap_min_addr) ||
50918 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50919 - return -ENOMEM;
50920 -
50921 stack_shift = vma->vm_end - stack_top;
50922
50923 bprm->p -= stack_shift;
50924 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50925 bprm->exec -= stack_shift;
50926
50927 down_write(&mm->mmap_sem);
50928 +
50929 + /* Move stack pages down in memory. */
50930 + if (stack_shift) {
50931 + ret = shift_arg_pages(vma, stack_shift);
50932 + if (ret)
50933 + goto out_unlock;
50934 + }
50935 +
50936 vm_flags = VM_STACK_FLAGS;
50937
50938 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50939 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50940 + vm_flags &= ~VM_EXEC;
50941 +
50942 +#ifdef CONFIG_PAX_MPROTECT
50943 + if (mm->pax_flags & MF_PAX_MPROTECT)
50944 + vm_flags &= ~VM_MAYEXEC;
50945 +#endif
50946 +
50947 + }
50948 +#endif
50949 +
50950 /*
50951 * Adjust stack execute permissions; explicitly enable for
50952 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50953 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50954 goto out_unlock;
50955 BUG_ON(prev != vma);
50956
50957 - /* Move stack pages down in memory. */
50958 - if (stack_shift) {
50959 - ret = shift_arg_pages(vma, stack_shift);
50960 - if (ret)
50961 - goto out_unlock;
50962 - }
50963 -
50964 /* mprotect_fixup is overkill to remove the temporary stack flags */
50965 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50966
50967 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50968 #endif
50969 current->mm->start_stack = bprm->p;
50970 ret = expand_stack(vma, stack_base);
50971 +
50972 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50973 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50974 + unsigned long size;
50975 + vm_flags_t vm_flags;
50976 +
50977 + size = STACK_TOP - vma->vm_end;
50978 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50979 +
50980 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50981 +
50982 +#ifdef CONFIG_X86
50983 + if (!ret) {
50984 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50985 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50986 + }
50987 +#endif
50988 +
50989 + }
50990 +#endif
50991 +
50992 if (ret)
50993 ret = -EFAULT;
50994
50995 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
50996
50997 fsnotify_open(file);
50998
50999 + trace_open_exec(name);
51000 +
51001 err = deny_write_access(file);
51002 if (err)
51003 goto exit;
51004 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
51005 old_fs = get_fs();
51006 set_fs(get_ds());
51007 /* The cast to a user pointer is valid due to the set_fs() */
51008 - result = vfs_read(file, (void __user *)addr, count, &pos);
51009 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51010 set_fs(old_fs);
51011 return result;
51012 }
51013 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51014 }
51015 rcu_read_unlock();
51016
51017 - if (p->fs->users > n_fs) {
51018 + if (atomic_read(&p->fs->users) > n_fs) {
51019 bprm->unsafe |= LSM_UNSAFE_SHARE;
51020 } else {
51021 res = -EAGAIN;
51022 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51023
51024 EXPORT_SYMBOL(search_binary_handler);
51025
51026 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51027 +static DEFINE_PER_CPU(u64, exec_counter);
51028 +static int __init init_exec_counters(void)
51029 +{
51030 + unsigned int cpu;
51031 +
51032 + for_each_possible_cpu(cpu) {
51033 + per_cpu(exec_counter, cpu) = (u64)cpu;
51034 + }
51035 +
51036 + return 0;
51037 +}
51038 +early_initcall(init_exec_counters);
51039 +static inline void increment_exec_counter(void)
51040 +{
51041 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51042 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51043 +}
51044 +#else
51045 +static inline void increment_exec_counter(void) {}
51046 +#endif
51047 +
51048 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51049 + struct user_arg_ptr argv);
51050 +
51051 /*
51052 * sys_execve() executes a new program.
51053 */
51054 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
51055 struct user_arg_ptr argv,
51056 struct user_arg_ptr envp)
51057 {
51058 +#ifdef CONFIG_GRKERNSEC
51059 + struct file *old_exec_file;
51060 + struct acl_subject_label *old_acl;
51061 + struct rlimit old_rlim[RLIM_NLIMITS];
51062 +#endif
51063 struct linux_binprm *bprm;
51064 struct file *file;
51065 struct files_struct *displaced;
51066 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
51067 int retval;
51068 const struct cred *cred = current_cred();
51069
51070 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
51071 +
51072 /*
51073 * We move the actual failure in case of RLIMIT_NPROC excess from
51074 * set*uid() to execve() because too many poorly written programs
51075 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
51076 if (IS_ERR(file))
51077 goto out_unmark;
51078
51079 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51080 + retval = -EPERM;
51081 + goto out_file;
51082 + }
51083 +
51084 sched_exec();
51085
51086 bprm->file = file;
51087 bprm->filename = filename;
51088 bprm->interp = filename;
51089
51090 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
51091 + retval = -EACCES;
51092 + goto out_file;
51093 + }
51094 +
51095 retval = bprm_mm_init(bprm);
51096 if (retval)
51097 goto out_file;
51098 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
51099 if (retval < 0)
51100 goto out;
51101
51102 +#ifdef CONFIG_GRKERNSEC
51103 + old_acl = current->acl;
51104 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51105 + old_exec_file = current->exec_file;
51106 + get_file(file);
51107 + current->exec_file = file;
51108 +#endif
51109 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51110 + /* limit suid stack to 8MB
51111 + * we saved the old limits above and will restore them if this exec fails
51112 + */
51113 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51114 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51115 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51116 +#endif
51117 +
51118 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
51119 + retval = -EPERM;
51120 + goto out_fail;
51121 + }
51122 +
51123 + if (!gr_tpe_allow(file)) {
51124 + retval = -EACCES;
51125 + goto out_fail;
51126 + }
51127 +
51128 + if (gr_check_crash_exec(file)) {
51129 + retval = -EACCES;
51130 + goto out_fail;
51131 + }
51132 +
51133 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
51134 + bprm->unsafe);
51135 + if (retval < 0)
51136 + goto out_fail;
51137 +
51138 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51139 if (retval < 0)
51140 - goto out;
51141 + goto out_fail;
51142
51143 bprm->exec = bprm->p;
51144 retval = copy_strings(bprm->envc, envp, bprm);
51145 if (retval < 0)
51146 - goto out;
51147 + goto out_fail;
51148
51149 retval = copy_strings(bprm->argc, argv, bprm);
51150 if (retval < 0)
51151 - goto out;
51152 + goto out_fail;
51153 +
51154 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51155 +
51156 + gr_handle_exec_args(bprm, argv);
51157
51158 retval = search_binary_handler(bprm);
51159 if (retval < 0)
51160 - goto out;
51161 + goto out_fail;
51162 +#ifdef CONFIG_GRKERNSEC
51163 + if (old_exec_file)
51164 + fput(old_exec_file);
51165 +#endif
51166
51167 /* execve succeeded */
51168 +
51169 + increment_exec_counter();
51170 current->fs->in_exec = 0;
51171 current->in_execve = 0;
51172 acct_update_integrals(current);
51173 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
51174 put_files_struct(displaced);
51175 return retval;
51176
51177 +out_fail:
51178 +#ifdef CONFIG_GRKERNSEC
51179 + current->acl = old_acl;
51180 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51181 + fput(current->exec_file);
51182 + current->exec_file = old_exec_file;
51183 +#endif
51184 +
51185 out:
51186 if (bprm->mm) {
51187 acct_arg_size(bprm, 0);
51188 @@ -1701,3 +1875,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51189 return error;
51190 }
51191 #endif
51192 +
51193 +int pax_check_flags(unsigned long *flags)
51194 +{
51195 + int retval = 0;
51196 +
51197 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51198 + if (*flags & MF_PAX_SEGMEXEC)
51199 + {
51200 + *flags &= ~MF_PAX_SEGMEXEC;
51201 + retval = -EINVAL;
51202 + }
51203 +#endif
51204 +
51205 + if ((*flags & MF_PAX_PAGEEXEC)
51206 +
51207 +#ifdef CONFIG_PAX_PAGEEXEC
51208 + && (*flags & MF_PAX_SEGMEXEC)
51209 +#endif
51210 +
51211 + )
51212 + {
51213 + *flags &= ~MF_PAX_PAGEEXEC;
51214 + retval = -EINVAL;
51215 + }
51216 +
51217 + if ((*flags & MF_PAX_MPROTECT)
51218 +
51219 +#ifdef CONFIG_PAX_MPROTECT
51220 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51221 +#endif
51222 +
51223 + )
51224 + {
51225 + *flags &= ~MF_PAX_MPROTECT;
51226 + retval = -EINVAL;
51227 + }
51228 +
51229 + if ((*flags & MF_PAX_EMUTRAMP)
51230 +
51231 +#ifdef CONFIG_PAX_EMUTRAMP
51232 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51233 +#endif
51234 +
51235 + )
51236 + {
51237 + *flags &= ~MF_PAX_EMUTRAMP;
51238 + retval = -EINVAL;
51239 + }
51240 +
51241 + return retval;
51242 +}
51243 +
51244 +EXPORT_SYMBOL(pax_check_flags);
51245 +
51246 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51247 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51248 +{
51249 + struct task_struct *tsk = current;
51250 + struct mm_struct *mm = current->mm;
51251 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51252 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51253 + char *path_exec = NULL;
51254 + char *path_fault = NULL;
51255 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51256 + siginfo_t info = { };
51257 +
51258 + if (buffer_exec && buffer_fault) {
51259 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51260 +
51261 + down_read(&mm->mmap_sem);
51262 + vma = mm->mmap;
51263 + while (vma && (!vma_exec || !vma_fault)) {
51264 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51265 + vma_exec = vma;
51266 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51267 + vma_fault = vma;
51268 + vma = vma->vm_next;
51269 + }
51270 + if (vma_exec) {
51271 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51272 + if (IS_ERR(path_exec))
51273 + path_exec = "<path too long>";
51274 + else {
51275 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51276 + if (path_exec) {
51277 + *path_exec = 0;
51278 + path_exec = buffer_exec;
51279 + } else
51280 + path_exec = "<path too long>";
51281 + }
51282 + }
51283 + if (vma_fault) {
51284 + start = vma_fault->vm_start;
51285 + end = vma_fault->vm_end;
51286 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51287 + if (vma_fault->vm_file) {
51288 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51289 + if (IS_ERR(path_fault))
51290 + path_fault = "<path too long>";
51291 + else {
51292 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51293 + if (path_fault) {
51294 + *path_fault = 0;
51295 + path_fault = buffer_fault;
51296 + } else
51297 + path_fault = "<path too long>";
51298 + }
51299 + } else
51300 + path_fault = "<anonymous mapping>";
51301 + }
51302 + up_read(&mm->mmap_sem);
51303 + }
51304 + if (tsk->signal->curr_ip)
51305 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51306 + else
51307 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51308 + 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),
51309 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51310 + free_page((unsigned long)buffer_exec);
51311 + free_page((unsigned long)buffer_fault);
51312 + pax_report_insns(regs, pc, sp);
51313 + info.si_signo = SIGKILL;
51314 + info.si_errno = 0;
51315 + info.si_code = SI_KERNEL;
51316 + info.si_pid = 0;
51317 + info.si_uid = 0;
51318 + do_coredump(&info);
51319 +}
51320 +#endif
51321 +
51322 +#ifdef CONFIG_PAX_REFCOUNT
51323 +void pax_report_refcount_overflow(struct pt_regs *regs)
51324 +{
51325 + if (current->signal->curr_ip)
51326 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51327 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51328 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51329 + else
51330 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51331 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51332 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51333 + show_regs(regs);
51334 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51335 +}
51336 +#endif
51337 +
51338 +#ifdef CONFIG_PAX_USERCOPY
51339 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51340 +static noinline int check_stack_object(const void *obj, unsigned long len)
51341 +{
51342 + const void * const stack = task_stack_page(current);
51343 + const void * const stackend = stack + THREAD_SIZE;
51344 +
51345 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51346 + const void *frame = NULL;
51347 + const void *oldframe;
51348 +#endif
51349 +
51350 + if (obj + len < obj)
51351 + return -1;
51352 +
51353 + if (obj + len <= stack || stackend <= obj)
51354 + return 0;
51355 +
51356 + if (obj < stack || stackend < obj + len)
51357 + return -1;
51358 +
51359 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51360 + oldframe = __builtin_frame_address(1);
51361 + if (oldframe)
51362 + frame = __builtin_frame_address(2);
51363 + /*
51364 + low ----------------------------------------------> high
51365 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51366 + ^----------------^
51367 + allow copies only within here
51368 + */
51369 + while (stack <= frame && frame < stackend) {
51370 + /* if obj + len extends past the last frame, this
51371 + check won't pass and the next frame will be 0,
51372 + causing us to bail out and correctly report
51373 + the copy as invalid
51374 + */
51375 + if (obj + len <= frame)
51376 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51377 + oldframe = frame;
51378 + frame = *(const void * const *)frame;
51379 + }
51380 + return -1;
51381 +#else
51382 + return 1;
51383 +#endif
51384 +}
51385 +
51386 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51387 +{
51388 + if (current->signal->curr_ip)
51389 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51390 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51391 + else
51392 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51393 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51394 + dump_stack();
51395 + gr_handle_kernel_exploit();
51396 + do_group_exit(SIGKILL);
51397 +}
51398 +#endif
51399 +
51400 +#ifdef CONFIG_PAX_USERCOPY
51401 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51402 +{
51403 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51404 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51405 +#ifdef CONFIG_MODULES
51406 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51407 +#else
51408 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51409 +#endif
51410 +
51411 +#else
51412 + unsigned long textlow = (unsigned long)_stext;
51413 + unsigned long texthigh = (unsigned long)_etext;
51414 +#endif
51415 +
51416 + if (high <= textlow || low > texthigh)
51417 + return false;
51418 + else
51419 + return true;
51420 +}
51421 +#endif
51422 +
51423 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51424 +{
51425 +
51426 +#ifdef CONFIG_PAX_USERCOPY
51427 + const char *type;
51428 +
51429 + if (!n)
51430 + return;
51431 +
51432 + type = check_heap_object(ptr, n);
51433 + if (!type) {
51434 + int ret = check_stack_object(ptr, n);
51435 + if (ret == 1 || ret == 2)
51436 + return;
51437 + if (ret == 0) {
51438 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51439 + type = "<kernel text>";
51440 + else
51441 + return;
51442 + } else
51443 + type = "<process stack>";
51444 + }
51445 +
51446 + pax_report_usercopy(ptr, n, to_user, type);
51447 +#endif
51448 +
51449 +}
51450 +EXPORT_SYMBOL(__check_object_size);
51451 +
51452 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51453 +void pax_track_stack(void)
51454 +{
51455 + unsigned long sp = (unsigned long)&sp;
51456 + if (sp < current_thread_info()->lowest_stack &&
51457 + sp > (unsigned long)task_stack_page(current))
51458 + current_thread_info()->lowest_stack = sp;
51459 +}
51460 +EXPORT_SYMBOL(pax_track_stack);
51461 +#endif
51462 +
51463 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51464 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51465 +{
51466 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51467 + dump_stack();
51468 + do_group_exit(SIGKILL);
51469 +}
51470 +EXPORT_SYMBOL(report_size_overflow);
51471 +#endif
51472 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51473 index 9f9992b..8b59411 100644
51474 --- a/fs/ext2/balloc.c
51475 +++ b/fs/ext2/balloc.c
51476 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51477
51478 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51479 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51480 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51481 + if (free_blocks < root_blocks + 1 &&
51482 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51483 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51484 - !in_group_p (sbi->s_resgid))) {
51485 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51486 return 0;
51487 }
51488 return 1;
51489 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51490 index 22548f5..41521d8 100644
51491 --- a/fs/ext3/balloc.c
51492 +++ b/fs/ext3/balloc.c
51493 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51494
51495 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51496 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51497 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51498 + if (free_blocks < root_blocks + 1 &&
51499 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51500 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51501 - !in_group_p (sbi->s_resgid))) {
51502 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51503 return 0;
51504 }
51505 return 1;
51506 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51507 index d0f13ea..4b2dadd 100644
51508 --- a/fs/ext4/balloc.c
51509 +++ b/fs/ext4/balloc.c
51510 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51511 /* Hm, nope. Are (enough) root reserved clusters available? */
51512 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51513 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51514 - capable(CAP_SYS_RESOURCE) ||
51515 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51516 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51517 + capable_nolog(CAP_SYS_RESOURCE)) {
51518
51519 if (free_clusters >= (nclusters + dirty_clusters +
51520 resv_clusters))
51521 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51522 index 5aae3d1..b5da7f8 100644
51523 --- a/fs/ext4/ext4.h
51524 +++ b/fs/ext4/ext4.h
51525 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
51526 unsigned long s_mb_last_start;
51527
51528 /* stats for buddy allocator */
51529 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51530 - atomic_t s_bal_success; /* we found long enough chunks */
51531 - atomic_t s_bal_allocated; /* in blocks */
51532 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51533 - atomic_t s_bal_goals; /* goal hits */
51534 - atomic_t s_bal_breaks; /* too long searches */
51535 - atomic_t s_bal_2orders; /* 2^order hits */
51536 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51537 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51538 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51539 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51540 + atomic_unchecked_t s_bal_goals; /* goal hits */
51541 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51542 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51543 spinlock_t s_bal_lock;
51544 unsigned long s_mb_buddies_generated;
51545 unsigned long long s_mb_generation_time;
51546 - atomic_t s_mb_lost_chunks;
51547 - atomic_t s_mb_preallocated;
51548 - atomic_t s_mb_discarded;
51549 + atomic_unchecked_t s_mb_lost_chunks;
51550 + atomic_unchecked_t s_mb_preallocated;
51551 + atomic_unchecked_t s_mb_discarded;
51552 atomic_t s_lock_busy;
51553
51554 /* locality groups */
51555 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51556 index def8408..8253d11 100644
51557 --- a/fs/ext4/mballoc.c
51558 +++ b/fs/ext4/mballoc.c
51559 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51560 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51561
51562 if (EXT4_SB(sb)->s_mb_stats)
51563 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51564 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51565
51566 break;
51567 }
51568 @@ -2170,7 +2170,7 @@ repeat:
51569 ac->ac_status = AC_STATUS_CONTINUE;
51570 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51571 cr = 3;
51572 - atomic_inc(&sbi->s_mb_lost_chunks);
51573 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51574 goto repeat;
51575 }
51576 }
51577 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
51578 if (sbi->s_mb_stats) {
51579 ext4_msg(sb, KERN_INFO,
51580 "mballoc: %u blocks %u reqs (%u success)",
51581 - atomic_read(&sbi->s_bal_allocated),
51582 - atomic_read(&sbi->s_bal_reqs),
51583 - atomic_read(&sbi->s_bal_success));
51584 + atomic_read_unchecked(&sbi->s_bal_allocated),
51585 + atomic_read_unchecked(&sbi->s_bal_reqs),
51586 + atomic_read_unchecked(&sbi->s_bal_success));
51587 ext4_msg(sb, KERN_INFO,
51588 "mballoc: %u extents scanned, %u goal hits, "
51589 "%u 2^N hits, %u breaks, %u lost",
51590 - atomic_read(&sbi->s_bal_ex_scanned),
51591 - atomic_read(&sbi->s_bal_goals),
51592 - atomic_read(&sbi->s_bal_2orders),
51593 - atomic_read(&sbi->s_bal_breaks),
51594 - atomic_read(&sbi->s_mb_lost_chunks));
51595 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51596 + atomic_read_unchecked(&sbi->s_bal_goals),
51597 + atomic_read_unchecked(&sbi->s_bal_2orders),
51598 + atomic_read_unchecked(&sbi->s_bal_breaks),
51599 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51600 ext4_msg(sb, KERN_INFO,
51601 "mballoc: %lu generated and it took %Lu",
51602 sbi->s_mb_buddies_generated,
51603 sbi->s_mb_generation_time);
51604 ext4_msg(sb, KERN_INFO,
51605 "mballoc: %u preallocated, %u discarded",
51606 - atomic_read(&sbi->s_mb_preallocated),
51607 - atomic_read(&sbi->s_mb_discarded));
51608 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51609 + atomic_read_unchecked(&sbi->s_mb_discarded));
51610 }
51611
51612 free_percpu(sbi->s_locality_groups);
51613 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51614 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51615
51616 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51617 - atomic_inc(&sbi->s_bal_reqs);
51618 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51619 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51620 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51621 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51622 - atomic_inc(&sbi->s_bal_success);
51623 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51624 + atomic_inc_unchecked(&sbi->s_bal_success);
51625 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51626 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51627 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51628 - atomic_inc(&sbi->s_bal_goals);
51629 + atomic_inc_unchecked(&sbi->s_bal_goals);
51630 if (ac->ac_found > sbi->s_mb_max_to_scan)
51631 - atomic_inc(&sbi->s_bal_breaks);
51632 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51633 }
51634
51635 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51636 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51637 trace_ext4_mb_new_inode_pa(ac, pa);
51638
51639 ext4_mb_use_inode_pa(ac, pa);
51640 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51641 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51642
51643 ei = EXT4_I(ac->ac_inode);
51644 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51645 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51646 trace_ext4_mb_new_group_pa(ac, pa);
51647
51648 ext4_mb_use_group_pa(ac, pa);
51649 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51650 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51651
51652 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51653 lg = ac->ac_lg;
51654 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51655 * from the bitmap and continue.
51656 */
51657 }
51658 - atomic_add(free, &sbi->s_mb_discarded);
51659 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51660
51661 return err;
51662 }
51663 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51664 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51665 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51666 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51667 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51668 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51669 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51670
51671 return 0;
51672 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51673 index 214461e..3614c89 100644
51674 --- a/fs/ext4/mmp.c
51675 +++ b/fs/ext4/mmp.c
51676 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51677 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51678 const char *function, unsigned int line, const char *msg)
51679 {
51680 - __ext4_warning(sb, function, line, msg);
51681 + __ext4_warning(sb, function, line, "%s", msg);
51682 __ext4_warning(sb, function, line,
51683 "MMP failure info: last update time: %llu, last update "
51684 "node: %s, last update device: %s\n",
51685 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51686 index b27c96d..6ed4df2 100644
51687 --- a/fs/ext4/resize.c
51688 +++ b/fs/ext4/resize.c
51689 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51690 ext4_fsblk_t end = start + input->blocks_count;
51691 ext4_group_t group = input->group;
51692 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51693 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51694 - ext4_fsblk_t metaend = start + overhead;
51695 + unsigned overhead;
51696 + ext4_fsblk_t metaend;
51697 struct buffer_head *bh = NULL;
51698 ext4_grpblk_t free_blocks_count, offset;
51699 int err = -EINVAL;
51700
51701 + if (group != sbi->s_groups_count) {
51702 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51703 + input->group, sbi->s_groups_count);
51704 + return -EINVAL;
51705 + }
51706 +
51707 + overhead = ext4_group_overhead_blocks(sb, group);
51708 + metaend = start + overhead;
51709 input->free_blocks_count = free_blocks_count =
51710 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51711
51712 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51713 free_blocks_count, input->reserved_blocks);
51714
51715 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51716 - if (group != sbi->s_groups_count)
51717 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51718 - input->group, sbi->s_groups_count);
51719 - else if (offset != 0)
51720 + if (offset != 0)
51721 ext4_warning(sb, "Last group not full");
51722 else if (input->reserved_blocks > input->blocks_count / 5)
51723 ext4_warning(sb, "Reserved blocks too high (%u)",
51724 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51725 index 94cc84d..2490974 100644
51726 --- a/fs/ext4/super.c
51727 +++ b/fs/ext4/super.c
51728 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51729 }
51730
51731 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51732 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51733 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51734 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51735
51736 #ifdef CONFIG_QUOTA
51737 @@ -2378,7 +2378,7 @@ struct ext4_attr {
51738 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51739 const char *, size_t);
51740 int offset;
51741 -};
51742 +} __do_const;
51743
51744 static int parse_strtoull(const char *buf,
51745 unsigned long long max, unsigned long long *value)
51746 diff --git a/fs/fcntl.c b/fs/fcntl.c
51747 index 6599222..e7bf0de 100644
51748 --- a/fs/fcntl.c
51749 +++ b/fs/fcntl.c
51750 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51751 if (err)
51752 return err;
51753
51754 + if (gr_handle_chroot_fowner(pid, type))
51755 + return -ENOENT;
51756 + if (gr_check_protected_task_fowner(pid, type))
51757 + return -EACCES;
51758 +
51759 f_modown(filp, pid, type, force);
51760 return 0;
51761 }
51762 diff --git a/fs/fhandle.c b/fs/fhandle.c
51763 index 999ff5c..41f4109 100644
51764 --- a/fs/fhandle.c
51765 +++ b/fs/fhandle.c
51766 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51767 } else
51768 retval = 0;
51769 /* copy the mount id */
51770 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51771 - sizeof(*mnt_id)) ||
51772 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51773 copy_to_user(ufh, handle,
51774 sizeof(struct file_handle) + handle_bytes))
51775 retval = -EFAULT;
51776 diff --git a/fs/file.c b/fs/file.c
51777 index 4a78f98..9447397 100644
51778 --- a/fs/file.c
51779 +++ b/fs/file.c
51780 @@ -16,6 +16,7 @@
51781 #include <linux/slab.h>
51782 #include <linux/vmalloc.h>
51783 #include <linux/file.h>
51784 +#include <linux/security.h>
51785 #include <linux/fdtable.h>
51786 #include <linux/bitops.h>
51787 #include <linux/interrupt.h>
51788 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51789 if (!file)
51790 return __close_fd(files, fd);
51791
51792 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51793 if (fd >= rlimit(RLIMIT_NOFILE))
51794 return -EBADF;
51795
51796 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51797 if (unlikely(oldfd == newfd))
51798 return -EINVAL;
51799
51800 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51801 if (newfd >= rlimit(RLIMIT_NOFILE))
51802 return -EBADF;
51803
51804 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51805 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51806 {
51807 int err;
51808 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51809 if (from >= rlimit(RLIMIT_NOFILE))
51810 return -EINVAL;
51811 err = alloc_fd(from, flags);
51812 diff --git a/fs/filesystems.c b/fs/filesystems.c
51813 index 92567d9..fcd8cbf 100644
51814 --- a/fs/filesystems.c
51815 +++ b/fs/filesystems.c
51816 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51817 int len = dot ? dot - name : strlen(name);
51818
51819 fs = __get_fs_type(name, len);
51820 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51821 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51822 +#else
51823 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51824 +#endif
51825 fs = __get_fs_type(name, len);
51826
51827 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51828 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51829 index d8ac61d..79a36f0 100644
51830 --- a/fs/fs_struct.c
51831 +++ b/fs/fs_struct.c
51832 @@ -4,6 +4,7 @@
51833 #include <linux/path.h>
51834 #include <linux/slab.h>
51835 #include <linux/fs_struct.h>
51836 +#include <linux/grsecurity.h>
51837 #include "internal.h"
51838
51839 /*
51840 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51841 write_seqcount_begin(&fs->seq);
51842 old_root = fs->root;
51843 fs->root = *path;
51844 + gr_set_chroot_entries(current, path);
51845 write_seqcount_end(&fs->seq);
51846 spin_unlock(&fs->lock);
51847 if (old_root.dentry)
51848 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51849 int hits = 0;
51850 spin_lock(&fs->lock);
51851 write_seqcount_begin(&fs->seq);
51852 + /* this root replacement is only done by pivot_root,
51853 + leave grsec's chroot tagging alone for this task
51854 + so that a pivoted root isn't treated as a chroot
51855 + */
51856 hits += replace_path(&fs->root, old_root, new_root);
51857 hits += replace_path(&fs->pwd, old_root, new_root);
51858 write_seqcount_end(&fs->seq);
51859 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51860 task_lock(tsk);
51861 spin_lock(&fs->lock);
51862 tsk->fs = NULL;
51863 - kill = !--fs->users;
51864 + gr_clear_chroot_entries(tsk);
51865 + kill = !atomic_dec_return(&fs->users);
51866 spin_unlock(&fs->lock);
51867 task_unlock(tsk);
51868 if (kill)
51869 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51870 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51871 /* We don't need to lock fs - think why ;-) */
51872 if (fs) {
51873 - fs->users = 1;
51874 + atomic_set(&fs->users, 1);
51875 fs->in_exec = 0;
51876 spin_lock_init(&fs->lock);
51877 seqcount_init(&fs->seq);
51878 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51879 spin_lock(&old->lock);
51880 fs->root = old->root;
51881 path_get(&fs->root);
51882 + /* instead of calling gr_set_chroot_entries here,
51883 + we call it from every caller of this function
51884 + */
51885 fs->pwd = old->pwd;
51886 path_get(&fs->pwd);
51887 spin_unlock(&old->lock);
51888 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51889
51890 task_lock(current);
51891 spin_lock(&fs->lock);
51892 - kill = !--fs->users;
51893 + kill = !atomic_dec_return(&fs->users);
51894 current->fs = new_fs;
51895 + gr_set_chroot_entries(current, &new_fs->root);
51896 spin_unlock(&fs->lock);
51897 task_unlock(current);
51898
51899 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51900
51901 int current_umask(void)
51902 {
51903 - return current->fs->umask;
51904 + return current->fs->umask | gr_acl_umask();
51905 }
51906 EXPORT_SYMBOL(current_umask);
51907
51908 /* to be mentioned only in INIT_TASK */
51909 struct fs_struct init_fs = {
51910 - .users = 1,
51911 + .users = ATOMIC_INIT(1),
51912 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51913 .seq = SEQCNT_ZERO,
51914 .umask = 0022,
51915 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51916 index e2cba1f..17a25bb 100644
51917 --- a/fs/fscache/cookie.c
51918 +++ b/fs/fscache/cookie.c
51919 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51920 parent ? (char *) parent->def->name : "<no-parent>",
51921 def->name, netfs_data);
51922
51923 - fscache_stat(&fscache_n_acquires);
51924 + fscache_stat_unchecked(&fscache_n_acquires);
51925
51926 /* if there's no parent cookie, then we don't create one here either */
51927 if (!parent) {
51928 - fscache_stat(&fscache_n_acquires_null);
51929 + fscache_stat_unchecked(&fscache_n_acquires_null);
51930 _leave(" [no parent]");
51931 return NULL;
51932 }
51933 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51934 /* allocate and initialise a cookie */
51935 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51936 if (!cookie) {
51937 - fscache_stat(&fscache_n_acquires_oom);
51938 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51939 _leave(" [ENOMEM]");
51940 return NULL;
51941 }
51942 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51943
51944 switch (cookie->def->type) {
51945 case FSCACHE_COOKIE_TYPE_INDEX:
51946 - fscache_stat(&fscache_n_cookie_index);
51947 + fscache_stat_unchecked(&fscache_n_cookie_index);
51948 break;
51949 case FSCACHE_COOKIE_TYPE_DATAFILE:
51950 - fscache_stat(&fscache_n_cookie_data);
51951 + fscache_stat_unchecked(&fscache_n_cookie_data);
51952 break;
51953 default:
51954 - fscache_stat(&fscache_n_cookie_special);
51955 + fscache_stat_unchecked(&fscache_n_cookie_special);
51956 break;
51957 }
51958
51959 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51960 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51961 atomic_dec(&parent->n_children);
51962 __fscache_cookie_put(cookie);
51963 - fscache_stat(&fscache_n_acquires_nobufs);
51964 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51965 _leave(" = NULL");
51966 return NULL;
51967 }
51968 }
51969
51970 - fscache_stat(&fscache_n_acquires_ok);
51971 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51972 _leave(" = %p", cookie);
51973 return cookie;
51974 }
51975 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51976 cache = fscache_select_cache_for_object(cookie->parent);
51977 if (!cache) {
51978 up_read(&fscache_addremove_sem);
51979 - fscache_stat(&fscache_n_acquires_no_cache);
51980 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51981 _leave(" = -ENOMEDIUM [no cache]");
51982 return -ENOMEDIUM;
51983 }
51984 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51985 object = cache->ops->alloc_object(cache, cookie);
51986 fscache_stat_d(&fscache_n_cop_alloc_object);
51987 if (IS_ERR(object)) {
51988 - fscache_stat(&fscache_n_object_no_alloc);
51989 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51990 ret = PTR_ERR(object);
51991 goto error;
51992 }
51993
51994 - fscache_stat(&fscache_n_object_alloc);
51995 + fscache_stat_unchecked(&fscache_n_object_alloc);
51996
51997 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51998
51999 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52000
52001 _enter("{%s}", cookie->def->name);
52002
52003 - fscache_stat(&fscache_n_invalidates);
52004 + fscache_stat_unchecked(&fscache_n_invalidates);
52005
52006 /* Only permit invalidation of data files. Invalidating an index will
52007 * require the caller to release all its attachments to the tree rooted
52008 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52009 {
52010 struct fscache_object *object;
52011
52012 - fscache_stat(&fscache_n_updates);
52013 + fscache_stat_unchecked(&fscache_n_updates);
52014
52015 if (!cookie) {
52016 - fscache_stat(&fscache_n_updates_null);
52017 + fscache_stat_unchecked(&fscache_n_updates_null);
52018 _leave(" [no cookie]");
52019 return;
52020 }
52021 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52022 struct fscache_object *object;
52023 unsigned long event;
52024
52025 - fscache_stat(&fscache_n_relinquishes);
52026 + fscache_stat_unchecked(&fscache_n_relinquishes);
52027 if (retire)
52028 - fscache_stat(&fscache_n_relinquishes_retire);
52029 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52030
52031 if (!cookie) {
52032 - fscache_stat(&fscache_n_relinquishes_null);
52033 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52034 _leave(" [no cookie]");
52035 return;
52036 }
52037 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52038
52039 /* wait for the cookie to finish being instantiated (or to fail) */
52040 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52041 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52042 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52043 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52044 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52045 }
52046 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52047 index ee38fef..0a326d4 100644
52048 --- a/fs/fscache/internal.h
52049 +++ b/fs/fscache/internal.h
52050 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52051 * stats.c
52052 */
52053 #ifdef CONFIG_FSCACHE_STATS
52054 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52055 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52056 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52057 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52058
52059 -extern atomic_t fscache_n_op_pend;
52060 -extern atomic_t fscache_n_op_run;
52061 -extern atomic_t fscache_n_op_enqueue;
52062 -extern atomic_t fscache_n_op_deferred_release;
52063 -extern atomic_t fscache_n_op_release;
52064 -extern atomic_t fscache_n_op_gc;
52065 -extern atomic_t fscache_n_op_cancelled;
52066 -extern atomic_t fscache_n_op_rejected;
52067 +extern atomic_unchecked_t fscache_n_op_pend;
52068 +extern atomic_unchecked_t fscache_n_op_run;
52069 +extern atomic_unchecked_t fscache_n_op_enqueue;
52070 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52071 +extern atomic_unchecked_t fscache_n_op_release;
52072 +extern atomic_unchecked_t fscache_n_op_gc;
52073 +extern atomic_unchecked_t fscache_n_op_cancelled;
52074 +extern atomic_unchecked_t fscache_n_op_rejected;
52075
52076 -extern atomic_t fscache_n_attr_changed;
52077 -extern atomic_t fscache_n_attr_changed_ok;
52078 -extern atomic_t fscache_n_attr_changed_nobufs;
52079 -extern atomic_t fscache_n_attr_changed_nomem;
52080 -extern atomic_t fscache_n_attr_changed_calls;
52081 +extern atomic_unchecked_t fscache_n_attr_changed;
52082 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52083 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52084 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52085 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52086
52087 -extern atomic_t fscache_n_allocs;
52088 -extern atomic_t fscache_n_allocs_ok;
52089 -extern atomic_t fscache_n_allocs_wait;
52090 -extern atomic_t fscache_n_allocs_nobufs;
52091 -extern atomic_t fscache_n_allocs_intr;
52092 -extern atomic_t fscache_n_allocs_object_dead;
52093 -extern atomic_t fscache_n_alloc_ops;
52094 -extern atomic_t fscache_n_alloc_op_waits;
52095 +extern atomic_unchecked_t fscache_n_allocs;
52096 +extern atomic_unchecked_t fscache_n_allocs_ok;
52097 +extern atomic_unchecked_t fscache_n_allocs_wait;
52098 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52099 +extern atomic_unchecked_t fscache_n_allocs_intr;
52100 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52101 +extern atomic_unchecked_t fscache_n_alloc_ops;
52102 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52103
52104 -extern atomic_t fscache_n_retrievals;
52105 -extern atomic_t fscache_n_retrievals_ok;
52106 -extern atomic_t fscache_n_retrievals_wait;
52107 -extern atomic_t fscache_n_retrievals_nodata;
52108 -extern atomic_t fscache_n_retrievals_nobufs;
52109 -extern atomic_t fscache_n_retrievals_intr;
52110 -extern atomic_t fscache_n_retrievals_nomem;
52111 -extern atomic_t fscache_n_retrievals_object_dead;
52112 -extern atomic_t fscache_n_retrieval_ops;
52113 -extern atomic_t fscache_n_retrieval_op_waits;
52114 +extern atomic_unchecked_t fscache_n_retrievals;
52115 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52116 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52117 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52118 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52119 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52120 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52121 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52122 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52123 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52124
52125 -extern atomic_t fscache_n_stores;
52126 -extern atomic_t fscache_n_stores_ok;
52127 -extern atomic_t fscache_n_stores_again;
52128 -extern atomic_t fscache_n_stores_nobufs;
52129 -extern atomic_t fscache_n_stores_oom;
52130 -extern atomic_t fscache_n_store_ops;
52131 -extern atomic_t fscache_n_store_calls;
52132 -extern atomic_t fscache_n_store_pages;
52133 -extern atomic_t fscache_n_store_radix_deletes;
52134 -extern atomic_t fscache_n_store_pages_over_limit;
52135 +extern atomic_unchecked_t fscache_n_stores;
52136 +extern atomic_unchecked_t fscache_n_stores_ok;
52137 +extern atomic_unchecked_t fscache_n_stores_again;
52138 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52139 +extern atomic_unchecked_t fscache_n_stores_oom;
52140 +extern atomic_unchecked_t fscache_n_store_ops;
52141 +extern atomic_unchecked_t fscache_n_store_calls;
52142 +extern atomic_unchecked_t fscache_n_store_pages;
52143 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52144 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52145
52146 -extern atomic_t fscache_n_store_vmscan_not_storing;
52147 -extern atomic_t fscache_n_store_vmscan_gone;
52148 -extern atomic_t fscache_n_store_vmscan_busy;
52149 -extern atomic_t fscache_n_store_vmscan_cancelled;
52150 -extern atomic_t fscache_n_store_vmscan_wait;
52151 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52152 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52153 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52154 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52155 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52156
52157 -extern atomic_t fscache_n_marks;
52158 -extern atomic_t fscache_n_uncaches;
52159 +extern atomic_unchecked_t fscache_n_marks;
52160 +extern atomic_unchecked_t fscache_n_uncaches;
52161
52162 -extern atomic_t fscache_n_acquires;
52163 -extern atomic_t fscache_n_acquires_null;
52164 -extern atomic_t fscache_n_acquires_no_cache;
52165 -extern atomic_t fscache_n_acquires_ok;
52166 -extern atomic_t fscache_n_acquires_nobufs;
52167 -extern atomic_t fscache_n_acquires_oom;
52168 +extern atomic_unchecked_t fscache_n_acquires;
52169 +extern atomic_unchecked_t fscache_n_acquires_null;
52170 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52171 +extern atomic_unchecked_t fscache_n_acquires_ok;
52172 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52173 +extern atomic_unchecked_t fscache_n_acquires_oom;
52174
52175 -extern atomic_t fscache_n_invalidates;
52176 -extern atomic_t fscache_n_invalidates_run;
52177 +extern atomic_unchecked_t fscache_n_invalidates;
52178 +extern atomic_unchecked_t fscache_n_invalidates_run;
52179
52180 -extern atomic_t fscache_n_updates;
52181 -extern atomic_t fscache_n_updates_null;
52182 -extern atomic_t fscache_n_updates_run;
52183 +extern atomic_unchecked_t fscache_n_updates;
52184 +extern atomic_unchecked_t fscache_n_updates_null;
52185 +extern atomic_unchecked_t fscache_n_updates_run;
52186
52187 -extern atomic_t fscache_n_relinquishes;
52188 -extern atomic_t fscache_n_relinquishes_null;
52189 -extern atomic_t fscache_n_relinquishes_waitcrt;
52190 -extern atomic_t fscache_n_relinquishes_retire;
52191 +extern atomic_unchecked_t fscache_n_relinquishes;
52192 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52193 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52194 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52195
52196 -extern atomic_t fscache_n_cookie_index;
52197 -extern atomic_t fscache_n_cookie_data;
52198 -extern atomic_t fscache_n_cookie_special;
52199 +extern atomic_unchecked_t fscache_n_cookie_index;
52200 +extern atomic_unchecked_t fscache_n_cookie_data;
52201 +extern atomic_unchecked_t fscache_n_cookie_special;
52202
52203 -extern atomic_t fscache_n_object_alloc;
52204 -extern atomic_t fscache_n_object_no_alloc;
52205 -extern atomic_t fscache_n_object_lookups;
52206 -extern atomic_t fscache_n_object_lookups_negative;
52207 -extern atomic_t fscache_n_object_lookups_positive;
52208 -extern atomic_t fscache_n_object_lookups_timed_out;
52209 -extern atomic_t fscache_n_object_created;
52210 -extern atomic_t fscache_n_object_avail;
52211 -extern atomic_t fscache_n_object_dead;
52212 +extern atomic_unchecked_t fscache_n_object_alloc;
52213 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52214 +extern atomic_unchecked_t fscache_n_object_lookups;
52215 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52216 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52217 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52218 +extern atomic_unchecked_t fscache_n_object_created;
52219 +extern atomic_unchecked_t fscache_n_object_avail;
52220 +extern atomic_unchecked_t fscache_n_object_dead;
52221
52222 -extern atomic_t fscache_n_checkaux_none;
52223 -extern atomic_t fscache_n_checkaux_okay;
52224 -extern atomic_t fscache_n_checkaux_update;
52225 -extern atomic_t fscache_n_checkaux_obsolete;
52226 +extern atomic_unchecked_t fscache_n_checkaux_none;
52227 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52228 +extern atomic_unchecked_t fscache_n_checkaux_update;
52229 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52230
52231 extern atomic_t fscache_n_cop_alloc_object;
52232 extern atomic_t fscache_n_cop_lookup_object;
52233 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52234 atomic_inc(stat);
52235 }
52236
52237 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52238 +{
52239 + atomic_inc_unchecked(stat);
52240 +}
52241 +
52242 static inline void fscache_stat_d(atomic_t *stat)
52243 {
52244 atomic_dec(stat);
52245 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52246
52247 #define __fscache_stat(stat) (NULL)
52248 #define fscache_stat(stat) do {} while (0)
52249 +#define fscache_stat_unchecked(stat) do {} while (0)
52250 #define fscache_stat_d(stat) do {} while (0)
52251 #endif
52252
52253 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52254 index 50d41c1..10ee117 100644
52255 --- a/fs/fscache/object.c
52256 +++ b/fs/fscache/object.c
52257 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52258 /* Invalidate an object on disk */
52259 case FSCACHE_OBJECT_INVALIDATING:
52260 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52261 - fscache_stat(&fscache_n_invalidates_run);
52262 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52263 fscache_stat(&fscache_n_cop_invalidate_object);
52264 fscache_invalidate_object(object);
52265 fscache_stat_d(&fscache_n_cop_invalidate_object);
52266 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52267 /* update the object metadata on disk */
52268 case FSCACHE_OBJECT_UPDATING:
52269 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52270 - fscache_stat(&fscache_n_updates_run);
52271 + fscache_stat_unchecked(&fscache_n_updates_run);
52272 fscache_stat(&fscache_n_cop_update_object);
52273 object->cache->ops->update_object(object);
52274 fscache_stat_d(&fscache_n_cop_update_object);
52275 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52276 spin_lock(&object->lock);
52277 object->state = FSCACHE_OBJECT_DEAD;
52278 spin_unlock(&object->lock);
52279 - fscache_stat(&fscache_n_object_dead);
52280 + fscache_stat_unchecked(&fscache_n_object_dead);
52281 goto terminal_transit;
52282
52283 /* handle the parent cache of this object being withdrawn from
52284 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52285 spin_lock(&object->lock);
52286 object->state = FSCACHE_OBJECT_DEAD;
52287 spin_unlock(&object->lock);
52288 - fscache_stat(&fscache_n_object_dead);
52289 + fscache_stat_unchecked(&fscache_n_object_dead);
52290 goto terminal_transit;
52291
52292 /* complain about the object being woken up once it is
52293 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52294 parent->cookie->def->name, cookie->def->name,
52295 object->cache->tag->name);
52296
52297 - fscache_stat(&fscache_n_object_lookups);
52298 + fscache_stat_unchecked(&fscache_n_object_lookups);
52299 fscache_stat(&fscache_n_cop_lookup_object);
52300 ret = object->cache->ops->lookup_object(object);
52301 fscache_stat_d(&fscache_n_cop_lookup_object);
52302 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52303 if (ret == -ETIMEDOUT) {
52304 /* probably stuck behind another object, so move this one to
52305 * the back of the queue */
52306 - fscache_stat(&fscache_n_object_lookups_timed_out);
52307 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52308 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52309 }
52310
52311 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52312
52313 spin_lock(&object->lock);
52314 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52315 - fscache_stat(&fscache_n_object_lookups_negative);
52316 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52317
52318 /* transit here to allow write requests to begin stacking up
52319 * and read requests to begin returning ENODATA */
52320 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52321 * result, in which case there may be data available */
52322 spin_lock(&object->lock);
52323 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52324 - fscache_stat(&fscache_n_object_lookups_positive);
52325 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52326
52327 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52328
52329 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52330 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52331 } else {
52332 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52333 - fscache_stat(&fscache_n_object_created);
52334 + fscache_stat_unchecked(&fscache_n_object_created);
52335
52336 object->state = FSCACHE_OBJECT_AVAILABLE;
52337 spin_unlock(&object->lock);
52338 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52339 fscache_enqueue_dependents(object);
52340
52341 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52342 - fscache_stat(&fscache_n_object_avail);
52343 + fscache_stat_unchecked(&fscache_n_object_avail);
52344
52345 _leave("");
52346 }
52347 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52348 enum fscache_checkaux result;
52349
52350 if (!object->cookie->def->check_aux) {
52351 - fscache_stat(&fscache_n_checkaux_none);
52352 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52353 return FSCACHE_CHECKAUX_OKAY;
52354 }
52355
52356 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52357 switch (result) {
52358 /* entry okay as is */
52359 case FSCACHE_CHECKAUX_OKAY:
52360 - fscache_stat(&fscache_n_checkaux_okay);
52361 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52362 break;
52363
52364 /* entry requires update */
52365 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52366 - fscache_stat(&fscache_n_checkaux_update);
52367 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52368 break;
52369
52370 /* entry requires deletion */
52371 case FSCACHE_CHECKAUX_OBSOLETE:
52372 - fscache_stat(&fscache_n_checkaux_obsolete);
52373 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52374 break;
52375
52376 default:
52377 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52378 index 762a9ec..2023284 100644
52379 --- a/fs/fscache/operation.c
52380 +++ b/fs/fscache/operation.c
52381 @@ -17,7 +17,7 @@
52382 #include <linux/slab.h>
52383 #include "internal.h"
52384
52385 -atomic_t fscache_op_debug_id;
52386 +atomic_unchecked_t fscache_op_debug_id;
52387 EXPORT_SYMBOL(fscache_op_debug_id);
52388
52389 /**
52390 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52391 ASSERTCMP(atomic_read(&op->usage), >, 0);
52392 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52393
52394 - fscache_stat(&fscache_n_op_enqueue);
52395 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52396 switch (op->flags & FSCACHE_OP_TYPE) {
52397 case FSCACHE_OP_ASYNC:
52398 _debug("queue async");
52399 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52400 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52401 if (op->processor)
52402 fscache_enqueue_operation(op);
52403 - fscache_stat(&fscache_n_op_run);
52404 + fscache_stat_unchecked(&fscache_n_op_run);
52405 }
52406
52407 /*
52408 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52409 if (object->n_in_progress > 0) {
52410 atomic_inc(&op->usage);
52411 list_add_tail(&op->pend_link, &object->pending_ops);
52412 - fscache_stat(&fscache_n_op_pend);
52413 + fscache_stat_unchecked(&fscache_n_op_pend);
52414 } else if (!list_empty(&object->pending_ops)) {
52415 atomic_inc(&op->usage);
52416 list_add_tail(&op->pend_link, &object->pending_ops);
52417 - fscache_stat(&fscache_n_op_pend);
52418 + fscache_stat_unchecked(&fscache_n_op_pend);
52419 fscache_start_operations(object);
52420 } else {
52421 ASSERTCMP(object->n_in_progress, ==, 0);
52422 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52423 object->n_exclusive++; /* reads and writes must wait */
52424 atomic_inc(&op->usage);
52425 list_add_tail(&op->pend_link, &object->pending_ops);
52426 - fscache_stat(&fscache_n_op_pend);
52427 + fscache_stat_unchecked(&fscache_n_op_pend);
52428 ret = 0;
52429 } else {
52430 /* If we're in any other state, there must have been an I/O
52431 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52432 if (object->n_exclusive > 0) {
52433 atomic_inc(&op->usage);
52434 list_add_tail(&op->pend_link, &object->pending_ops);
52435 - fscache_stat(&fscache_n_op_pend);
52436 + fscache_stat_unchecked(&fscache_n_op_pend);
52437 } else if (!list_empty(&object->pending_ops)) {
52438 atomic_inc(&op->usage);
52439 list_add_tail(&op->pend_link, &object->pending_ops);
52440 - fscache_stat(&fscache_n_op_pend);
52441 + fscache_stat_unchecked(&fscache_n_op_pend);
52442 fscache_start_operations(object);
52443 } else {
52444 ASSERTCMP(object->n_exclusive, ==, 0);
52445 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52446 object->n_ops++;
52447 atomic_inc(&op->usage);
52448 list_add_tail(&op->pend_link, &object->pending_ops);
52449 - fscache_stat(&fscache_n_op_pend);
52450 + fscache_stat_unchecked(&fscache_n_op_pend);
52451 ret = 0;
52452 } else if (object->state == FSCACHE_OBJECT_DYING ||
52453 object->state == FSCACHE_OBJECT_LC_DYING ||
52454 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52455 - fscache_stat(&fscache_n_op_rejected);
52456 + fscache_stat_unchecked(&fscache_n_op_rejected);
52457 op->state = FSCACHE_OP_ST_CANCELLED;
52458 ret = -ENOBUFS;
52459 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52460 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52461 ret = -EBUSY;
52462 if (op->state == FSCACHE_OP_ST_PENDING) {
52463 ASSERT(!list_empty(&op->pend_link));
52464 - fscache_stat(&fscache_n_op_cancelled);
52465 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52466 list_del_init(&op->pend_link);
52467 if (do_cancel)
52468 do_cancel(op);
52469 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52470 while (!list_empty(&object->pending_ops)) {
52471 op = list_entry(object->pending_ops.next,
52472 struct fscache_operation, pend_link);
52473 - fscache_stat(&fscache_n_op_cancelled);
52474 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52475 list_del_init(&op->pend_link);
52476
52477 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52478 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52479 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52480 op->state = FSCACHE_OP_ST_DEAD;
52481
52482 - fscache_stat(&fscache_n_op_release);
52483 + fscache_stat_unchecked(&fscache_n_op_release);
52484
52485 if (op->release) {
52486 op->release(op);
52487 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52488 * lock, and defer it otherwise */
52489 if (!spin_trylock(&object->lock)) {
52490 _debug("defer put");
52491 - fscache_stat(&fscache_n_op_deferred_release);
52492 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52493
52494 cache = object->cache;
52495 spin_lock(&cache->op_gc_list_lock);
52496 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52497
52498 _debug("GC DEFERRED REL OBJ%x OP%x",
52499 object->debug_id, op->debug_id);
52500 - fscache_stat(&fscache_n_op_gc);
52501 + fscache_stat_unchecked(&fscache_n_op_gc);
52502
52503 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52504 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52505 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52506 index ff000e5..c44ec6d 100644
52507 --- a/fs/fscache/page.c
52508 +++ b/fs/fscache/page.c
52509 @@ -61,7 +61,7 @@ try_again:
52510 val = radix_tree_lookup(&cookie->stores, page->index);
52511 if (!val) {
52512 rcu_read_unlock();
52513 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52514 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52515 __fscache_uncache_page(cookie, page);
52516 return true;
52517 }
52518 @@ -91,11 +91,11 @@ try_again:
52519 spin_unlock(&cookie->stores_lock);
52520
52521 if (xpage) {
52522 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52523 - fscache_stat(&fscache_n_store_radix_deletes);
52524 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52525 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52526 ASSERTCMP(xpage, ==, page);
52527 } else {
52528 - fscache_stat(&fscache_n_store_vmscan_gone);
52529 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52530 }
52531
52532 wake_up_bit(&cookie->flags, 0);
52533 @@ -110,11 +110,11 @@ page_busy:
52534 * sleeping on memory allocation, so we may need to impose a timeout
52535 * too. */
52536 if (!(gfp & __GFP_WAIT)) {
52537 - fscache_stat(&fscache_n_store_vmscan_busy);
52538 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52539 return false;
52540 }
52541
52542 - fscache_stat(&fscache_n_store_vmscan_wait);
52543 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52544 __fscache_wait_on_page_write(cookie, page);
52545 gfp &= ~__GFP_WAIT;
52546 goto try_again;
52547 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52548 FSCACHE_COOKIE_STORING_TAG);
52549 if (!radix_tree_tag_get(&cookie->stores, page->index,
52550 FSCACHE_COOKIE_PENDING_TAG)) {
52551 - fscache_stat(&fscache_n_store_radix_deletes);
52552 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52553 xpage = radix_tree_delete(&cookie->stores, page->index);
52554 }
52555 spin_unlock(&cookie->stores_lock);
52556 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52557
52558 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52559
52560 - fscache_stat(&fscache_n_attr_changed_calls);
52561 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52562
52563 if (fscache_object_is_active(object)) {
52564 fscache_stat(&fscache_n_cop_attr_changed);
52565 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52566
52567 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52568
52569 - fscache_stat(&fscache_n_attr_changed);
52570 + fscache_stat_unchecked(&fscache_n_attr_changed);
52571
52572 op = kzalloc(sizeof(*op), GFP_KERNEL);
52573 if (!op) {
52574 - fscache_stat(&fscache_n_attr_changed_nomem);
52575 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52576 _leave(" = -ENOMEM");
52577 return -ENOMEM;
52578 }
52579 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52580 if (fscache_submit_exclusive_op(object, op) < 0)
52581 goto nobufs;
52582 spin_unlock(&cookie->lock);
52583 - fscache_stat(&fscache_n_attr_changed_ok);
52584 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52585 fscache_put_operation(op);
52586 _leave(" = 0");
52587 return 0;
52588 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52589 nobufs:
52590 spin_unlock(&cookie->lock);
52591 kfree(op);
52592 - fscache_stat(&fscache_n_attr_changed_nobufs);
52593 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52594 _leave(" = %d", -ENOBUFS);
52595 return -ENOBUFS;
52596 }
52597 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52598 /* allocate a retrieval operation and attempt to submit it */
52599 op = kzalloc(sizeof(*op), GFP_NOIO);
52600 if (!op) {
52601 - fscache_stat(&fscache_n_retrievals_nomem);
52602 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52603 return NULL;
52604 }
52605
52606 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52607 return 0;
52608 }
52609
52610 - fscache_stat(&fscache_n_retrievals_wait);
52611 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52612
52613 jif = jiffies;
52614 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52615 fscache_wait_bit_interruptible,
52616 TASK_INTERRUPTIBLE) != 0) {
52617 - fscache_stat(&fscache_n_retrievals_intr);
52618 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52619 _leave(" = -ERESTARTSYS");
52620 return -ERESTARTSYS;
52621 }
52622 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52623 */
52624 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52625 struct fscache_retrieval *op,
52626 - atomic_t *stat_op_waits,
52627 - atomic_t *stat_object_dead)
52628 + atomic_unchecked_t *stat_op_waits,
52629 + atomic_unchecked_t *stat_object_dead)
52630 {
52631 int ret;
52632
52633 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52634 goto check_if_dead;
52635
52636 _debug(">>> WT");
52637 - fscache_stat(stat_op_waits);
52638 + fscache_stat_unchecked(stat_op_waits);
52639 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52640 fscache_wait_bit_interruptible,
52641 TASK_INTERRUPTIBLE) != 0) {
52642 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52643
52644 check_if_dead:
52645 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52646 - fscache_stat(stat_object_dead);
52647 + fscache_stat_unchecked(stat_object_dead);
52648 _leave(" = -ENOBUFS [cancelled]");
52649 return -ENOBUFS;
52650 }
52651 if (unlikely(fscache_object_is_dead(object))) {
52652 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52653 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52654 - fscache_stat(stat_object_dead);
52655 + fscache_stat_unchecked(stat_object_dead);
52656 return -ENOBUFS;
52657 }
52658 return 0;
52659 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52660
52661 _enter("%p,%p,,,", cookie, page);
52662
52663 - fscache_stat(&fscache_n_retrievals);
52664 + fscache_stat_unchecked(&fscache_n_retrievals);
52665
52666 if (hlist_empty(&cookie->backing_objects))
52667 goto nobufs;
52668 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52669 goto nobufs_unlock_dec;
52670 spin_unlock(&cookie->lock);
52671
52672 - fscache_stat(&fscache_n_retrieval_ops);
52673 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52674
52675 /* pin the netfs read context in case we need to do the actual netfs
52676 * read because we've encountered a cache read failure */
52677 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52678
52679 error:
52680 if (ret == -ENOMEM)
52681 - fscache_stat(&fscache_n_retrievals_nomem);
52682 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52683 else if (ret == -ERESTARTSYS)
52684 - fscache_stat(&fscache_n_retrievals_intr);
52685 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52686 else if (ret == -ENODATA)
52687 - fscache_stat(&fscache_n_retrievals_nodata);
52688 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52689 else if (ret < 0)
52690 - fscache_stat(&fscache_n_retrievals_nobufs);
52691 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52692 else
52693 - fscache_stat(&fscache_n_retrievals_ok);
52694 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52695
52696 fscache_put_retrieval(op);
52697 _leave(" = %d", ret);
52698 @@ -467,7 +467,7 @@ nobufs_unlock:
52699 spin_unlock(&cookie->lock);
52700 kfree(op);
52701 nobufs:
52702 - fscache_stat(&fscache_n_retrievals_nobufs);
52703 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52704 _leave(" = -ENOBUFS");
52705 return -ENOBUFS;
52706 }
52707 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52708
52709 _enter("%p,,%d,,,", cookie, *nr_pages);
52710
52711 - fscache_stat(&fscache_n_retrievals);
52712 + fscache_stat_unchecked(&fscache_n_retrievals);
52713
52714 if (hlist_empty(&cookie->backing_objects))
52715 goto nobufs;
52716 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52717 goto nobufs_unlock_dec;
52718 spin_unlock(&cookie->lock);
52719
52720 - fscache_stat(&fscache_n_retrieval_ops);
52721 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52722
52723 /* pin the netfs read context in case we need to do the actual netfs
52724 * read because we've encountered a cache read failure */
52725 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52726
52727 error:
52728 if (ret == -ENOMEM)
52729 - fscache_stat(&fscache_n_retrievals_nomem);
52730 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52731 else if (ret == -ERESTARTSYS)
52732 - fscache_stat(&fscache_n_retrievals_intr);
52733 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52734 else if (ret == -ENODATA)
52735 - fscache_stat(&fscache_n_retrievals_nodata);
52736 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52737 else if (ret < 0)
52738 - fscache_stat(&fscache_n_retrievals_nobufs);
52739 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52740 else
52741 - fscache_stat(&fscache_n_retrievals_ok);
52742 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52743
52744 fscache_put_retrieval(op);
52745 _leave(" = %d", ret);
52746 @@ -591,7 +591,7 @@ nobufs_unlock:
52747 spin_unlock(&cookie->lock);
52748 kfree(op);
52749 nobufs:
52750 - fscache_stat(&fscache_n_retrievals_nobufs);
52751 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52752 _leave(" = -ENOBUFS");
52753 return -ENOBUFS;
52754 }
52755 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52756
52757 _enter("%p,%p,,,", cookie, page);
52758
52759 - fscache_stat(&fscache_n_allocs);
52760 + fscache_stat_unchecked(&fscache_n_allocs);
52761
52762 if (hlist_empty(&cookie->backing_objects))
52763 goto nobufs;
52764 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52765 goto nobufs_unlock;
52766 spin_unlock(&cookie->lock);
52767
52768 - fscache_stat(&fscache_n_alloc_ops);
52769 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52770
52771 ret = fscache_wait_for_retrieval_activation(
52772 object, op,
52773 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52774
52775 error:
52776 if (ret == -ERESTARTSYS)
52777 - fscache_stat(&fscache_n_allocs_intr);
52778 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52779 else if (ret < 0)
52780 - fscache_stat(&fscache_n_allocs_nobufs);
52781 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52782 else
52783 - fscache_stat(&fscache_n_allocs_ok);
52784 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52785
52786 fscache_put_retrieval(op);
52787 _leave(" = %d", ret);
52788 @@ -677,7 +677,7 @@ nobufs_unlock:
52789 spin_unlock(&cookie->lock);
52790 kfree(op);
52791 nobufs:
52792 - fscache_stat(&fscache_n_allocs_nobufs);
52793 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52794 _leave(" = -ENOBUFS");
52795 return -ENOBUFS;
52796 }
52797 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52798
52799 spin_lock(&cookie->stores_lock);
52800
52801 - fscache_stat(&fscache_n_store_calls);
52802 + fscache_stat_unchecked(&fscache_n_store_calls);
52803
52804 /* find a page to store */
52805 page = NULL;
52806 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52807 page = results[0];
52808 _debug("gang %d [%lx]", n, page->index);
52809 if (page->index > op->store_limit) {
52810 - fscache_stat(&fscache_n_store_pages_over_limit);
52811 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52812 goto superseded;
52813 }
52814
52815 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52816 spin_unlock(&cookie->stores_lock);
52817 spin_unlock(&object->lock);
52818
52819 - fscache_stat(&fscache_n_store_pages);
52820 + fscache_stat_unchecked(&fscache_n_store_pages);
52821 fscache_stat(&fscache_n_cop_write_page);
52822 ret = object->cache->ops->write_page(op, page);
52823 fscache_stat_d(&fscache_n_cop_write_page);
52824 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52825 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52826 ASSERT(PageFsCache(page));
52827
52828 - fscache_stat(&fscache_n_stores);
52829 + fscache_stat_unchecked(&fscache_n_stores);
52830
52831 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52832 _leave(" = -ENOBUFS [invalidating]");
52833 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52834 spin_unlock(&cookie->stores_lock);
52835 spin_unlock(&object->lock);
52836
52837 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52838 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52839 op->store_limit = object->store_limit;
52840
52841 if (fscache_submit_op(object, &op->op) < 0)
52842 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52843
52844 spin_unlock(&cookie->lock);
52845 radix_tree_preload_end();
52846 - fscache_stat(&fscache_n_store_ops);
52847 - fscache_stat(&fscache_n_stores_ok);
52848 + fscache_stat_unchecked(&fscache_n_store_ops);
52849 + fscache_stat_unchecked(&fscache_n_stores_ok);
52850
52851 /* the work queue now carries its own ref on the object */
52852 fscache_put_operation(&op->op);
52853 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52854 return 0;
52855
52856 already_queued:
52857 - fscache_stat(&fscache_n_stores_again);
52858 + fscache_stat_unchecked(&fscache_n_stores_again);
52859 already_pending:
52860 spin_unlock(&cookie->stores_lock);
52861 spin_unlock(&object->lock);
52862 spin_unlock(&cookie->lock);
52863 radix_tree_preload_end();
52864 kfree(op);
52865 - fscache_stat(&fscache_n_stores_ok);
52866 + fscache_stat_unchecked(&fscache_n_stores_ok);
52867 _leave(" = 0");
52868 return 0;
52869
52870 @@ -959,14 +959,14 @@ nobufs:
52871 spin_unlock(&cookie->lock);
52872 radix_tree_preload_end();
52873 kfree(op);
52874 - fscache_stat(&fscache_n_stores_nobufs);
52875 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52876 _leave(" = -ENOBUFS");
52877 return -ENOBUFS;
52878
52879 nomem_free:
52880 kfree(op);
52881 nomem:
52882 - fscache_stat(&fscache_n_stores_oom);
52883 + fscache_stat_unchecked(&fscache_n_stores_oom);
52884 _leave(" = -ENOMEM");
52885 return -ENOMEM;
52886 }
52887 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52888 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52889 ASSERTCMP(page, !=, NULL);
52890
52891 - fscache_stat(&fscache_n_uncaches);
52892 + fscache_stat_unchecked(&fscache_n_uncaches);
52893
52894 /* cache withdrawal may beat us to it */
52895 if (!PageFsCache(page))
52896 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52897 struct fscache_cookie *cookie = op->op.object->cookie;
52898
52899 #ifdef CONFIG_FSCACHE_STATS
52900 - atomic_inc(&fscache_n_marks);
52901 + atomic_inc_unchecked(&fscache_n_marks);
52902 #endif
52903
52904 _debug("- mark %p{%lx}", page, page->index);
52905 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52906 index 40d13c7..ddf52b9 100644
52907 --- a/fs/fscache/stats.c
52908 +++ b/fs/fscache/stats.c
52909 @@ -18,99 +18,99 @@
52910 /*
52911 * operation counters
52912 */
52913 -atomic_t fscache_n_op_pend;
52914 -atomic_t fscache_n_op_run;
52915 -atomic_t fscache_n_op_enqueue;
52916 -atomic_t fscache_n_op_requeue;
52917 -atomic_t fscache_n_op_deferred_release;
52918 -atomic_t fscache_n_op_release;
52919 -atomic_t fscache_n_op_gc;
52920 -atomic_t fscache_n_op_cancelled;
52921 -atomic_t fscache_n_op_rejected;
52922 +atomic_unchecked_t fscache_n_op_pend;
52923 +atomic_unchecked_t fscache_n_op_run;
52924 +atomic_unchecked_t fscache_n_op_enqueue;
52925 +atomic_unchecked_t fscache_n_op_requeue;
52926 +atomic_unchecked_t fscache_n_op_deferred_release;
52927 +atomic_unchecked_t fscache_n_op_release;
52928 +atomic_unchecked_t fscache_n_op_gc;
52929 +atomic_unchecked_t fscache_n_op_cancelled;
52930 +atomic_unchecked_t fscache_n_op_rejected;
52931
52932 -atomic_t fscache_n_attr_changed;
52933 -atomic_t fscache_n_attr_changed_ok;
52934 -atomic_t fscache_n_attr_changed_nobufs;
52935 -atomic_t fscache_n_attr_changed_nomem;
52936 -atomic_t fscache_n_attr_changed_calls;
52937 +atomic_unchecked_t fscache_n_attr_changed;
52938 +atomic_unchecked_t fscache_n_attr_changed_ok;
52939 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52940 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52941 +atomic_unchecked_t fscache_n_attr_changed_calls;
52942
52943 -atomic_t fscache_n_allocs;
52944 -atomic_t fscache_n_allocs_ok;
52945 -atomic_t fscache_n_allocs_wait;
52946 -atomic_t fscache_n_allocs_nobufs;
52947 -atomic_t fscache_n_allocs_intr;
52948 -atomic_t fscache_n_allocs_object_dead;
52949 -atomic_t fscache_n_alloc_ops;
52950 -atomic_t fscache_n_alloc_op_waits;
52951 +atomic_unchecked_t fscache_n_allocs;
52952 +atomic_unchecked_t fscache_n_allocs_ok;
52953 +atomic_unchecked_t fscache_n_allocs_wait;
52954 +atomic_unchecked_t fscache_n_allocs_nobufs;
52955 +atomic_unchecked_t fscache_n_allocs_intr;
52956 +atomic_unchecked_t fscache_n_allocs_object_dead;
52957 +atomic_unchecked_t fscache_n_alloc_ops;
52958 +atomic_unchecked_t fscache_n_alloc_op_waits;
52959
52960 -atomic_t fscache_n_retrievals;
52961 -atomic_t fscache_n_retrievals_ok;
52962 -atomic_t fscache_n_retrievals_wait;
52963 -atomic_t fscache_n_retrievals_nodata;
52964 -atomic_t fscache_n_retrievals_nobufs;
52965 -atomic_t fscache_n_retrievals_intr;
52966 -atomic_t fscache_n_retrievals_nomem;
52967 -atomic_t fscache_n_retrievals_object_dead;
52968 -atomic_t fscache_n_retrieval_ops;
52969 -atomic_t fscache_n_retrieval_op_waits;
52970 +atomic_unchecked_t fscache_n_retrievals;
52971 +atomic_unchecked_t fscache_n_retrievals_ok;
52972 +atomic_unchecked_t fscache_n_retrievals_wait;
52973 +atomic_unchecked_t fscache_n_retrievals_nodata;
52974 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52975 +atomic_unchecked_t fscache_n_retrievals_intr;
52976 +atomic_unchecked_t fscache_n_retrievals_nomem;
52977 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52978 +atomic_unchecked_t fscache_n_retrieval_ops;
52979 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52980
52981 -atomic_t fscache_n_stores;
52982 -atomic_t fscache_n_stores_ok;
52983 -atomic_t fscache_n_stores_again;
52984 -atomic_t fscache_n_stores_nobufs;
52985 -atomic_t fscache_n_stores_oom;
52986 -atomic_t fscache_n_store_ops;
52987 -atomic_t fscache_n_store_calls;
52988 -atomic_t fscache_n_store_pages;
52989 -atomic_t fscache_n_store_radix_deletes;
52990 -atomic_t fscache_n_store_pages_over_limit;
52991 +atomic_unchecked_t fscache_n_stores;
52992 +atomic_unchecked_t fscache_n_stores_ok;
52993 +atomic_unchecked_t fscache_n_stores_again;
52994 +atomic_unchecked_t fscache_n_stores_nobufs;
52995 +atomic_unchecked_t fscache_n_stores_oom;
52996 +atomic_unchecked_t fscache_n_store_ops;
52997 +atomic_unchecked_t fscache_n_store_calls;
52998 +atomic_unchecked_t fscache_n_store_pages;
52999 +atomic_unchecked_t fscache_n_store_radix_deletes;
53000 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53001
53002 -atomic_t fscache_n_store_vmscan_not_storing;
53003 -atomic_t fscache_n_store_vmscan_gone;
53004 -atomic_t fscache_n_store_vmscan_busy;
53005 -atomic_t fscache_n_store_vmscan_cancelled;
53006 -atomic_t fscache_n_store_vmscan_wait;
53007 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53008 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53009 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53010 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53011 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53012
53013 -atomic_t fscache_n_marks;
53014 -atomic_t fscache_n_uncaches;
53015 +atomic_unchecked_t fscache_n_marks;
53016 +atomic_unchecked_t fscache_n_uncaches;
53017
53018 -atomic_t fscache_n_acquires;
53019 -atomic_t fscache_n_acquires_null;
53020 -atomic_t fscache_n_acquires_no_cache;
53021 -atomic_t fscache_n_acquires_ok;
53022 -atomic_t fscache_n_acquires_nobufs;
53023 -atomic_t fscache_n_acquires_oom;
53024 +atomic_unchecked_t fscache_n_acquires;
53025 +atomic_unchecked_t fscache_n_acquires_null;
53026 +atomic_unchecked_t fscache_n_acquires_no_cache;
53027 +atomic_unchecked_t fscache_n_acquires_ok;
53028 +atomic_unchecked_t fscache_n_acquires_nobufs;
53029 +atomic_unchecked_t fscache_n_acquires_oom;
53030
53031 -atomic_t fscache_n_invalidates;
53032 -atomic_t fscache_n_invalidates_run;
53033 +atomic_unchecked_t fscache_n_invalidates;
53034 +atomic_unchecked_t fscache_n_invalidates_run;
53035
53036 -atomic_t fscache_n_updates;
53037 -atomic_t fscache_n_updates_null;
53038 -atomic_t fscache_n_updates_run;
53039 +atomic_unchecked_t fscache_n_updates;
53040 +atomic_unchecked_t fscache_n_updates_null;
53041 +atomic_unchecked_t fscache_n_updates_run;
53042
53043 -atomic_t fscache_n_relinquishes;
53044 -atomic_t fscache_n_relinquishes_null;
53045 -atomic_t fscache_n_relinquishes_waitcrt;
53046 -atomic_t fscache_n_relinquishes_retire;
53047 +atomic_unchecked_t fscache_n_relinquishes;
53048 +atomic_unchecked_t fscache_n_relinquishes_null;
53049 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53050 +atomic_unchecked_t fscache_n_relinquishes_retire;
53051
53052 -atomic_t fscache_n_cookie_index;
53053 -atomic_t fscache_n_cookie_data;
53054 -atomic_t fscache_n_cookie_special;
53055 +atomic_unchecked_t fscache_n_cookie_index;
53056 +atomic_unchecked_t fscache_n_cookie_data;
53057 +atomic_unchecked_t fscache_n_cookie_special;
53058
53059 -atomic_t fscache_n_object_alloc;
53060 -atomic_t fscache_n_object_no_alloc;
53061 -atomic_t fscache_n_object_lookups;
53062 -atomic_t fscache_n_object_lookups_negative;
53063 -atomic_t fscache_n_object_lookups_positive;
53064 -atomic_t fscache_n_object_lookups_timed_out;
53065 -atomic_t fscache_n_object_created;
53066 -atomic_t fscache_n_object_avail;
53067 -atomic_t fscache_n_object_dead;
53068 +atomic_unchecked_t fscache_n_object_alloc;
53069 +atomic_unchecked_t fscache_n_object_no_alloc;
53070 +atomic_unchecked_t fscache_n_object_lookups;
53071 +atomic_unchecked_t fscache_n_object_lookups_negative;
53072 +atomic_unchecked_t fscache_n_object_lookups_positive;
53073 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53074 +atomic_unchecked_t fscache_n_object_created;
53075 +atomic_unchecked_t fscache_n_object_avail;
53076 +atomic_unchecked_t fscache_n_object_dead;
53077
53078 -atomic_t fscache_n_checkaux_none;
53079 -atomic_t fscache_n_checkaux_okay;
53080 -atomic_t fscache_n_checkaux_update;
53081 -atomic_t fscache_n_checkaux_obsolete;
53082 +atomic_unchecked_t fscache_n_checkaux_none;
53083 +atomic_unchecked_t fscache_n_checkaux_okay;
53084 +atomic_unchecked_t fscache_n_checkaux_update;
53085 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53086
53087 atomic_t fscache_n_cop_alloc_object;
53088 atomic_t fscache_n_cop_lookup_object;
53089 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53090 seq_puts(m, "FS-Cache statistics\n");
53091
53092 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53093 - atomic_read(&fscache_n_cookie_index),
53094 - atomic_read(&fscache_n_cookie_data),
53095 - atomic_read(&fscache_n_cookie_special));
53096 + atomic_read_unchecked(&fscache_n_cookie_index),
53097 + atomic_read_unchecked(&fscache_n_cookie_data),
53098 + atomic_read_unchecked(&fscache_n_cookie_special));
53099
53100 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53101 - atomic_read(&fscache_n_object_alloc),
53102 - atomic_read(&fscache_n_object_no_alloc),
53103 - atomic_read(&fscache_n_object_avail),
53104 - atomic_read(&fscache_n_object_dead));
53105 + atomic_read_unchecked(&fscache_n_object_alloc),
53106 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53107 + atomic_read_unchecked(&fscache_n_object_avail),
53108 + atomic_read_unchecked(&fscache_n_object_dead));
53109 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53110 - atomic_read(&fscache_n_checkaux_none),
53111 - atomic_read(&fscache_n_checkaux_okay),
53112 - atomic_read(&fscache_n_checkaux_update),
53113 - atomic_read(&fscache_n_checkaux_obsolete));
53114 + atomic_read_unchecked(&fscache_n_checkaux_none),
53115 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53116 + atomic_read_unchecked(&fscache_n_checkaux_update),
53117 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53118
53119 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53120 - atomic_read(&fscache_n_marks),
53121 - atomic_read(&fscache_n_uncaches));
53122 + atomic_read_unchecked(&fscache_n_marks),
53123 + atomic_read_unchecked(&fscache_n_uncaches));
53124
53125 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53126 " oom=%u\n",
53127 - atomic_read(&fscache_n_acquires),
53128 - atomic_read(&fscache_n_acquires_null),
53129 - atomic_read(&fscache_n_acquires_no_cache),
53130 - atomic_read(&fscache_n_acquires_ok),
53131 - atomic_read(&fscache_n_acquires_nobufs),
53132 - atomic_read(&fscache_n_acquires_oom));
53133 + atomic_read_unchecked(&fscache_n_acquires),
53134 + atomic_read_unchecked(&fscache_n_acquires_null),
53135 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53136 + atomic_read_unchecked(&fscache_n_acquires_ok),
53137 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53138 + atomic_read_unchecked(&fscache_n_acquires_oom));
53139
53140 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53141 - atomic_read(&fscache_n_object_lookups),
53142 - atomic_read(&fscache_n_object_lookups_negative),
53143 - atomic_read(&fscache_n_object_lookups_positive),
53144 - atomic_read(&fscache_n_object_created),
53145 - atomic_read(&fscache_n_object_lookups_timed_out));
53146 + atomic_read_unchecked(&fscache_n_object_lookups),
53147 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53148 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53149 + atomic_read_unchecked(&fscache_n_object_created),
53150 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53151
53152 seq_printf(m, "Invals : n=%u run=%u\n",
53153 - atomic_read(&fscache_n_invalidates),
53154 - atomic_read(&fscache_n_invalidates_run));
53155 + atomic_read_unchecked(&fscache_n_invalidates),
53156 + atomic_read_unchecked(&fscache_n_invalidates_run));
53157
53158 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53159 - atomic_read(&fscache_n_updates),
53160 - atomic_read(&fscache_n_updates_null),
53161 - atomic_read(&fscache_n_updates_run));
53162 + atomic_read_unchecked(&fscache_n_updates),
53163 + atomic_read_unchecked(&fscache_n_updates_null),
53164 + atomic_read_unchecked(&fscache_n_updates_run));
53165
53166 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53167 - atomic_read(&fscache_n_relinquishes),
53168 - atomic_read(&fscache_n_relinquishes_null),
53169 - atomic_read(&fscache_n_relinquishes_waitcrt),
53170 - atomic_read(&fscache_n_relinquishes_retire));
53171 + atomic_read_unchecked(&fscache_n_relinquishes),
53172 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53173 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53174 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53175
53176 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53177 - atomic_read(&fscache_n_attr_changed),
53178 - atomic_read(&fscache_n_attr_changed_ok),
53179 - atomic_read(&fscache_n_attr_changed_nobufs),
53180 - atomic_read(&fscache_n_attr_changed_nomem),
53181 - atomic_read(&fscache_n_attr_changed_calls));
53182 + atomic_read_unchecked(&fscache_n_attr_changed),
53183 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53184 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53185 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53186 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53187
53188 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53189 - atomic_read(&fscache_n_allocs),
53190 - atomic_read(&fscache_n_allocs_ok),
53191 - atomic_read(&fscache_n_allocs_wait),
53192 - atomic_read(&fscache_n_allocs_nobufs),
53193 - atomic_read(&fscache_n_allocs_intr));
53194 + atomic_read_unchecked(&fscache_n_allocs),
53195 + atomic_read_unchecked(&fscache_n_allocs_ok),
53196 + atomic_read_unchecked(&fscache_n_allocs_wait),
53197 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53198 + atomic_read_unchecked(&fscache_n_allocs_intr));
53199 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53200 - atomic_read(&fscache_n_alloc_ops),
53201 - atomic_read(&fscache_n_alloc_op_waits),
53202 - atomic_read(&fscache_n_allocs_object_dead));
53203 + atomic_read_unchecked(&fscache_n_alloc_ops),
53204 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53205 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53206
53207 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53208 " int=%u oom=%u\n",
53209 - atomic_read(&fscache_n_retrievals),
53210 - atomic_read(&fscache_n_retrievals_ok),
53211 - atomic_read(&fscache_n_retrievals_wait),
53212 - atomic_read(&fscache_n_retrievals_nodata),
53213 - atomic_read(&fscache_n_retrievals_nobufs),
53214 - atomic_read(&fscache_n_retrievals_intr),
53215 - atomic_read(&fscache_n_retrievals_nomem));
53216 + atomic_read_unchecked(&fscache_n_retrievals),
53217 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53218 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53219 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53220 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53221 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53222 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53223 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53224 - atomic_read(&fscache_n_retrieval_ops),
53225 - atomic_read(&fscache_n_retrieval_op_waits),
53226 - atomic_read(&fscache_n_retrievals_object_dead));
53227 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53228 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53229 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53230
53231 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53232 - atomic_read(&fscache_n_stores),
53233 - atomic_read(&fscache_n_stores_ok),
53234 - atomic_read(&fscache_n_stores_again),
53235 - atomic_read(&fscache_n_stores_nobufs),
53236 - atomic_read(&fscache_n_stores_oom));
53237 + atomic_read_unchecked(&fscache_n_stores),
53238 + atomic_read_unchecked(&fscache_n_stores_ok),
53239 + atomic_read_unchecked(&fscache_n_stores_again),
53240 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53241 + atomic_read_unchecked(&fscache_n_stores_oom));
53242 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53243 - atomic_read(&fscache_n_store_ops),
53244 - atomic_read(&fscache_n_store_calls),
53245 - atomic_read(&fscache_n_store_pages),
53246 - atomic_read(&fscache_n_store_radix_deletes),
53247 - atomic_read(&fscache_n_store_pages_over_limit));
53248 + atomic_read_unchecked(&fscache_n_store_ops),
53249 + atomic_read_unchecked(&fscache_n_store_calls),
53250 + atomic_read_unchecked(&fscache_n_store_pages),
53251 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53252 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53253
53254 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53255 - atomic_read(&fscache_n_store_vmscan_not_storing),
53256 - atomic_read(&fscache_n_store_vmscan_gone),
53257 - atomic_read(&fscache_n_store_vmscan_busy),
53258 - atomic_read(&fscache_n_store_vmscan_cancelled),
53259 - atomic_read(&fscache_n_store_vmscan_wait));
53260 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53261 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53262 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53263 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53264 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53265
53266 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53267 - atomic_read(&fscache_n_op_pend),
53268 - atomic_read(&fscache_n_op_run),
53269 - atomic_read(&fscache_n_op_enqueue),
53270 - atomic_read(&fscache_n_op_cancelled),
53271 - atomic_read(&fscache_n_op_rejected));
53272 + atomic_read_unchecked(&fscache_n_op_pend),
53273 + atomic_read_unchecked(&fscache_n_op_run),
53274 + atomic_read_unchecked(&fscache_n_op_enqueue),
53275 + atomic_read_unchecked(&fscache_n_op_cancelled),
53276 + atomic_read_unchecked(&fscache_n_op_rejected));
53277 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53278 - atomic_read(&fscache_n_op_deferred_release),
53279 - atomic_read(&fscache_n_op_release),
53280 - atomic_read(&fscache_n_op_gc));
53281 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53282 + atomic_read_unchecked(&fscache_n_op_release),
53283 + atomic_read_unchecked(&fscache_n_op_gc));
53284
53285 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53286 atomic_read(&fscache_n_cop_alloc_object),
53287 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53288 index aef34b1..59bfd7b 100644
53289 --- a/fs/fuse/cuse.c
53290 +++ b/fs/fuse/cuse.c
53291 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
53292 INIT_LIST_HEAD(&cuse_conntbl[i]);
53293
53294 /* inherit and extend fuse_dev_operations */
53295 - cuse_channel_fops = fuse_dev_operations;
53296 - cuse_channel_fops.owner = THIS_MODULE;
53297 - cuse_channel_fops.open = cuse_channel_open;
53298 - cuse_channel_fops.release = cuse_channel_release;
53299 + pax_open_kernel();
53300 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53301 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53302 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53303 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53304 + pax_close_kernel();
53305
53306 cuse_class = class_create(THIS_MODULE, "cuse");
53307 if (IS_ERR(cuse_class))
53308 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53309 index 1d55f94..088da65 100644
53310 --- a/fs/fuse/dev.c
53311 +++ b/fs/fuse/dev.c
53312 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53313 ret = 0;
53314 pipe_lock(pipe);
53315
53316 - if (!pipe->readers) {
53317 + if (!atomic_read(&pipe->readers)) {
53318 send_sig(SIGPIPE, current, 0);
53319 if (!ret)
53320 ret = -EPIPE;
53321 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53322 page_nr++;
53323 ret += buf->len;
53324
53325 - if (pipe->files)
53326 + if (atomic_read(&pipe->files))
53327 do_wakeup = 1;
53328 }
53329
53330 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53331 index f3f783d..bf11a8e 100644
53332 --- a/fs/fuse/dir.c
53333 +++ b/fs/fuse/dir.c
53334 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
53335 return link;
53336 }
53337
53338 -static void free_link(char *link)
53339 +static void free_link(const char *link)
53340 {
53341 if (!IS_ERR(link))
53342 free_page((unsigned long) link);
53343 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53344 index 62b484e..0f9a140 100644
53345 --- a/fs/gfs2/inode.c
53346 +++ b/fs/gfs2/inode.c
53347 @@ -1441,7 +1441,7 @@ out:
53348
53349 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53350 {
53351 - char *s = nd_get_link(nd);
53352 + const char *s = nd_get_link(nd);
53353 if (!IS_ERR(s))
53354 kfree(s);
53355 }
53356 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53357 index a3f868a..bb308ae 100644
53358 --- a/fs/hugetlbfs/inode.c
53359 +++ b/fs/hugetlbfs/inode.c
53360 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53361 struct mm_struct *mm = current->mm;
53362 struct vm_area_struct *vma;
53363 struct hstate *h = hstate_file(file);
53364 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53365 struct vm_unmapped_area_info info;
53366
53367 if (len & ~huge_page_mask(h))
53368 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53369 return addr;
53370 }
53371
53372 +#ifdef CONFIG_PAX_RANDMMAP
53373 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53374 +#endif
53375 +
53376 if (addr) {
53377 addr = ALIGN(addr, huge_page_size(h));
53378 vma = find_vma(mm, addr);
53379 - if (TASK_SIZE - len >= addr &&
53380 - (!vma || addr + len <= vma->vm_start))
53381 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53382 return addr;
53383 }
53384
53385 info.flags = 0;
53386 info.length = len;
53387 info.low_limit = TASK_UNMAPPED_BASE;
53388 +
53389 +#ifdef CONFIG_PAX_RANDMMAP
53390 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53391 + info.low_limit += mm->delta_mmap;
53392 +#endif
53393 +
53394 info.high_limit = TASK_SIZE;
53395 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53396 info.align_offset = 0;
53397 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53398 };
53399 MODULE_ALIAS_FS("hugetlbfs");
53400
53401 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53402 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53403
53404 static int can_do_hugetlb_shm(void)
53405 {
53406 diff --git a/fs/inode.c b/fs/inode.c
53407 index 00d5fc3..98ce7d7 100644
53408 --- a/fs/inode.c
53409 +++ b/fs/inode.c
53410 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53411
53412 #ifdef CONFIG_SMP
53413 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53414 - static atomic_t shared_last_ino;
53415 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53416 + static atomic_unchecked_t shared_last_ino;
53417 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53418
53419 res = next - LAST_INO_BATCH;
53420 }
53421 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53422 index 4a6cf28..d3a29d3 100644
53423 --- a/fs/jffs2/erase.c
53424 +++ b/fs/jffs2/erase.c
53425 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53426 struct jffs2_unknown_node marker = {
53427 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53428 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53429 - .totlen = cpu_to_je32(c->cleanmarker_size)
53430 + .totlen = cpu_to_je32(c->cleanmarker_size),
53431 + .hdr_crc = cpu_to_je32(0)
53432 };
53433
53434 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53435 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53436 index a6597d6..41b30ec 100644
53437 --- a/fs/jffs2/wbuf.c
53438 +++ b/fs/jffs2/wbuf.c
53439 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53440 {
53441 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53442 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53443 - .totlen = constant_cpu_to_je32(8)
53444 + .totlen = constant_cpu_to_je32(8),
53445 + .hdr_crc = constant_cpu_to_je32(0)
53446 };
53447
53448 /*
53449 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53450 index 788e0a9..8433098 100644
53451 --- a/fs/jfs/super.c
53452 +++ b/fs/jfs/super.c
53453 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
53454
53455 jfs_inode_cachep =
53456 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53457 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53458 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53459 init_once);
53460 if (jfs_inode_cachep == NULL)
53461 return -ENOMEM;
53462 diff --git a/fs/libfs.c b/fs/libfs.c
53463 index 916da8c..1588998 100644
53464 --- a/fs/libfs.c
53465 +++ b/fs/libfs.c
53466 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53467
53468 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53469 struct dentry *next;
53470 + char d_name[sizeof(next->d_iname)];
53471 + const unsigned char *name;
53472 +
53473 next = list_entry(p, struct dentry, d_u.d_child);
53474 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53475 if (!simple_positive(next)) {
53476 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53477
53478 spin_unlock(&next->d_lock);
53479 spin_unlock(&dentry->d_lock);
53480 - if (filldir(dirent, next->d_name.name,
53481 + name = next->d_name.name;
53482 + if (name == next->d_iname) {
53483 + memcpy(d_name, name, next->d_name.len);
53484 + name = d_name;
53485 + }
53486 + if (filldir(dirent, name,
53487 next->d_name.len, filp->f_pos,
53488 next->d_inode->i_ino,
53489 dt_type(next->d_inode)) < 0)
53490 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53491 index 9760ecb..9b838ef 100644
53492 --- a/fs/lockd/clntproc.c
53493 +++ b/fs/lockd/clntproc.c
53494 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53495 /*
53496 * Cookie counter for NLM requests
53497 */
53498 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53499 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53500
53501 void nlmclnt_next_cookie(struct nlm_cookie *c)
53502 {
53503 - u32 cookie = atomic_inc_return(&nlm_cookie);
53504 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53505
53506 memcpy(c->data, &cookie, 4);
53507 c->len=4;
53508 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53509 index a2aa97d..10d6c41 100644
53510 --- a/fs/lockd/svc.c
53511 +++ b/fs/lockd/svc.c
53512 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53513 svc_sock_update_bufs(serv);
53514 serv->sv_maxconn = nlm_max_connections;
53515
53516 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53517 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53518 if (IS_ERR(nlmsvc_task)) {
53519 error = PTR_ERR(nlmsvc_task);
53520 printk(KERN_WARNING
53521 diff --git a/fs/locks.c b/fs/locks.c
53522 index cb424a4..850e4dd 100644
53523 --- a/fs/locks.c
53524 +++ b/fs/locks.c
53525 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53526 return;
53527
53528 if (filp->f_op && filp->f_op->flock) {
53529 - struct file_lock fl = {
53530 + struct file_lock flock = {
53531 .fl_pid = current->tgid,
53532 .fl_file = filp,
53533 .fl_flags = FL_FLOCK,
53534 .fl_type = F_UNLCK,
53535 .fl_end = OFFSET_MAX,
53536 };
53537 - filp->f_op->flock(filp, F_SETLKW, &fl);
53538 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53539 - fl.fl_ops->fl_release_private(&fl);
53540 + filp->f_op->flock(filp, F_SETLKW, &flock);
53541 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53542 + flock.fl_ops->fl_release_private(&flock);
53543 }
53544
53545 lock_flocks();
53546 diff --git a/fs/namei.c b/fs/namei.c
53547 index 9ed9361..2b72db1 100644
53548 --- a/fs/namei.c
53549 +++ b/fs/namei.c
53550 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53551 if (ret != -EACCES)
53552 return ret;
53553
53554 +#ifdef CONFIG_GRKERNSEC
53555 + /* we'll block if we have to log due to a denied capability use */
53556 + if (mask & MAY_NOT_BLOCK)
53557 + return -ECHILD;
53558 +#endif
53559 +
53560 if (S_ISDIR(inode->i_mode)) {
53561 /* DACs are overridable for directories */
53562 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53563 - return 0;
53564 if (!(mask & MAY_WRITE))
53565 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53566 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53567 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53568 return 0;
53569 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53570 + return 0;
53571 return -EACCES;
53572 }
53573 /*
53574 + * Searching includes executable on directories, else just read.
53575 + */
53576 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53577 + if (mask == MAY_READ)
53578 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53579 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53580 + return 0;
53581 +
53582 + /*
53583 * Read/write DACs are always overridable.
53584 * Executable DACs are overridable when there is
53585 * at least one exec bit set.
53586 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53587 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53588 return 0;
53589
53590 - /*
53591 - * Searching includes executable on directories, else just read.
53592 - */
53593 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53594 - if (mask == MAY_READ)
53595 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53596 - return 0;
53597 -
53598 return -EACCES;
53599 }
53600
53601 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53602 {
53603 struct dentry *dentry = link->dentry;
53604 int error;
53605 - char *s;
53606 + const char *s;
53607
53608 BUG_ON(nd->flags & LOOKUP_RCU);
53609
53610 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53611 if (error)
53612 goto out_put_nd_path;
53613
53614 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53615 + dentry->d_inode, dentry, nd->path.mnt)) {
53616 + error = -EACCES;
53617 + goto out_put_nd_path;
53618 + }
53619 +
53620 nd->last_type = LAST_BIND;
53621 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53622 error = PTR_ERR(*p);
53623 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53624 if (res)
53625 break;
53626 res = walk_component(nd, path, LOOKUP_FOLLOW);
53627 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53628 + res = -EACCES;
53629 put_link(nd, &link, cookie);
53630 } while (res > 0);
53631
53632 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53633 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53634 {
53635 unsigned long a, b, adata, bdata, mask, hash, len;
53636 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53637 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53638
53639 hash = a = 0;
53640 len = -sizeof(unsigned long);
53641 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53642 if (err)
53643 break;
53644 err = lookup_last(nd, &path);
53645 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53646 + err = -EACCES;
53647 put_link(nd, &link, cookie);
53648 }
53649 }
53650 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53651 if (!err)
53652 err = complete_walk(nd);
53653
53654 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53655 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53656 + path_put(&nd->path);
53657 + err = -ENOENT;
53658 + }
53659 + }
53660 +
53661 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53662 if (!can_lookup(nd->inode)) {
53663 path_put(&nd->path);
53664 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53665 retval = path_lookupat(dfd, name->name,
53666 flags | LOOKUP_REVAL, nd);
53667
53668 - if (likely(!retval))
53669 + if (likely(!retval)) {
53670 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53671 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53672 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53673 + path_put(&nd->path);
53674 + return -ENOENT;
53675 + }
53676 + }
53677 + }
53678 return retval;
53679 }
53680
53681 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53682 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53683 return -EPERM;
53684
53685 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53686 + return -EPERM;
53687 + if (gr_handle_rawio(inode))
53688 + return -EPERM;
53689 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53690 + return -EACCES;
53691 +
53692 return 0;
53693 }
53694
53695 @@ -2602,7 +2641,7 @@ looked_up:
53696 * cleared otherwise prior to returning.
53697 */
53698 static int lookup_open(struct nameidata *nd, struct path *path,
53699 - struct file *file,
53700 + struct path *link, struct file *file,
53701 const struct open_flags *op,
53702 bool got_write, int *opened)
53703 {
53704 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53705 /* Negative dentry, just create the file */
53706 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53707 umode_t mode = op->mode;
53708 +
53709 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53710 + error = -EACCES;
53711 + goto out_dput;
53712 + }
53713 +
53714 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53715 + error = -EACCES;
53716 + goto out_dput;
53717 + }
53718 +
53719 if (!IS_POSIXACL(dir->d_inode))
53720 mode &= ~current_umask();
53721 /*
53722 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53723 nd->flags & LOOKUP_EXCL);
53724 if (error)
53725 goto out_dput;
53726 + else
53727 + gr_handle_create(dentry, nd->path.mnt);
53728 }
53729 out_no_open:
53730 path->dentry = dentry;
53731 @@ -2672,7 +2724,7 @@ out_dput:
53732 /*
53733 * Handle the last step of open()
53734 */
53735 -static int do_last(struct nameidata *nd, struct path *path,
53736 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53737 struct file *file, const struct open_flags *op,
53738 int *opened, struct filename *name)
53739 {
53740 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53741 error = complete_walk(nd);
53742 if (error)
53743 return error;
53744 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53745 + error = -ENOENT;
53746 + goto out;
53747 + }
53748 audit_inode(name, nd->path.dentry, 0);
53749 if (open_flag & O_CREAT) {
53750 error = -EISDIR;
53751 goto out;
53752 }
53753 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53754 + error = -EACCES;
53755 + goto out;
53756 + }
53757 goto finish_open;
53758 case LAST_BIND:
53759 error = complete_walk(nd);
53760 if (error)
53761 return error;
53762 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53763 + error = -ENOENT;
53764 + goto out;
53765 + }
53766 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53767 + error = -EACCES;
53768 + goto out;
53769 + }
53770 audit_inode(name, dir, 0);
53771 goto finish_open;
53772 }
53773 @@ -2759,7 +2827,7 @@ retry_lookup:
53774 */
53775 }
53776 mutex_lock(&dir->d_inode->i_mutex);
53777 - error = lookup_open(nd, path, file, op, got_write, opened);
53778 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53779 mutex_unlock(&dir->d_inode->i_mutex);
53780
53781 if (error <= 0) {
53782 @@ -2783,11 +2851,28 @@ retry_lookup:
53783 goto finish_open_created;
53784 }
53785
53786 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53787 + error = -ENOENT;
53788 + goto exit_dput;
53789 + }
53790 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53791 + error = -EACCES;
53792 + goto exit_dput;
53793 + }
53794 +
53795 /*
53796 * create/update audit record if it already exists.
53797 */
53798 - if (path->dentry->d_inode)
53799 + if (path->dentry->d_inode) {
53800 + /* only check if O_CREAT is specified, all other checks need to go
53801 + into may_open */
53802 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53803 + error = -EACCES;
53804 + goto exit_dput;
53805 + }
53806 +
53807 audit_inode(name, path->dentry, 0);
53808 + }
53809
53810 /*
53811 * If atomic_open() acquired write access it is dropped now due to
53812 @@ -2828,6 +2913,11 @@ finish_lookup:
53813 }
53814 }
53815 BUG_ON(inode != path->dentry->d_inode);
53816 + /* if we're resolving a symlink to another symlink */
53817 + if (link && gr_handle_symlink_owner(link, inode)) {
53818 + error = -EACCES;
53819 + goto out;
53820 + }
53821 return 1;
53822 }
53823
53824 @@ -2837,7 +2927,6 @@ finish_lookup:
53825 save_parent.dentry = nd->path.dentry;
53826 save_parent.mnt = mntget(path->mnt);
53827 nd->path.dentry = path->dentry;
53828 -
53829 }
53830 nd->inode = inode;
53831 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53832 @@ -2846,6 +2935,16 @@ finish_lookup:
53833 path_put(&save_parent);
53834 return error;
53835 }
53836 +
53837 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53838 + error = -ENOENT;
53839 + goto out;
53840 + }
53841 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53842 + error = -EACCES;
53843 + goto out;
53844 + }
53845 +
53846 error = -EISDIR;
53847 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53848 goto out;
53849 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53850 if (unlikely(error))
53851 goto out;
53852
53853 - error = do_last(nd, &path, file, op, &opened, pathname);
53854 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53855 while (unlikely(error > 0)) { /* trailing symlink */
53856 struct path link = path;
53857 void *cookie;
53858 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53859 error = follow_link(&link, nd, &cookie);
53860 if (unlikely(error))
53861 break;
53862 - error = do_last(nd, &path, file, op, &opened, pathname);
53863 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53864 put_link(nd, &link, cookie);
53865 }
53866 out:
53867 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53868 goto unlock;
53869
53870 error = -EEXIST;
53871 - if (dentry->d_inode)
53872 + if (dentry->d_inode) {
53873 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53874 + error = -ENOENT;
53875 + }
53876 goto fail;
53877 + }
53878 /*
53879 * Special case - lookup gave negative, but... we had foo/bar/
53880 * From the vfs_mknod() POV we just have a negative dentry -
53881 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53882 }
53883 EXPORT_SYMBOL(user_path_create);
53884
53885 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53886 +{
53887 + struct filename *tmp = getname(pathname);
53888 + struct dentry *res;
53889 + if (IS_ERR(tmp))
53890 + return ERR_CAST(tmp);
53891 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53892 + if (IS_ERR(res))
53893 + putname(tmp);
53894 + else
53895 + *to = tmp;
53896 + return res;
53897 +}
53898 +
53899 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53900 {
53901 int error = may_create(dir, dentry);
53902 @@ -3177,6 +3294,17 @@ retry:
53903
53904 if (!IS_POSIXACL(path.dentry->d_inode))
53905 mode &= ~current_umask();
53906 +
53907 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53908 + error = -EPERM;
53909 + goto out;
53910 + }
53911 +
53912 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53913 + error = -EACCES;
53914 + goto out;
53915 + }
53916 +
53917 error = security_path_mknod(&path, dentry, mode, dev);
53918 if (error)
53919 goto out;
53920 @@ -3193,6 +3321,8 @@ retry:
53921 break;
53922 }
53923 out:
53924 + if (!error)
53925 + gr_handle_create(dentry, path.mnt);
53926 done_path_create(&path, dentry);
53927 if (retry_estale(error, lookup_flags)) {
53928 lookup_flags |= LOOKUP_REVAL;
53929 @@ -3245,9 +3375,16 @@ retry:
53930
53931 if (!IS_POSIXACL(path.dentry->d_inode))
53932 mode &= ~current_umask();
53933 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53934 + error = -EACCES;
53935 + goto out;
53936 + }
53937 error = security_path_mkdir(&path, dentry, mode);
53938 if (!error)
53939 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53940 + if (!error)
53941 + gr_handle_create(dentry, path.mnt);
53942 +out:
53943 done_path_create(&path, dentry);
53944 if (retry_estale(error, lookup_flags)) {
53945 lookup_flags |= LOOKUP_REVAL;
53946 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53947 struct filename *name;
53948 struct dentry *dentry;
53949 struct nameidata nd;
53950 + ino_t saved_ino = 0;
53951 + dev_t saved_dev = 0;
53952 unsigned int lookup_flags = 0;
53953 retry:
53954 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53955 @@ -3360,10 +3499,21 @@ retry:
53956 error = -ENOENT;
53957 goto exit3;
53958 }
53959 +
53960 + saved_ino = dentry->d_inode->i_ino;
53961 + saved_dev = gr_get_dev_from_dentry(dentry);
53962 +
53963 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53964 + error = -EACCES;
53965 + goto exit3;
53966 + }
53967 +
53968 error = security_path_rmdir(&nd.path, dentry);
53969 if (error)
53970 goto exit3;
53971 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53972 + if (!error && (saved_dev || saved_ino))
53973 + gr_handle_delete(saved_ino, saved_dev);
53974 exit3:
53975 dput(dentry);
53976 exit2:
53977 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53978 struct dentry *dentry;
53979 struct nameidata nd;
53980 struct inode *inode = NULL;
53981 + ino_t saved_ino = 0;
53982 + dev_t saved_dev = 0;
53983 unsigned int lookup_flags = 0;
53984 retry:
53985 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53986 @@ -3455,10 +3607,22 @@ retry:
53987 if (!inode)
53988 goto slashes;
53989 ihold(inode);
53990 +
53991 + if (inode->i_nlink <= 1) {
53992 + saved_ino = inode->i_ino;
53993 + saved_dev = gr_get_dev_from_dentry(dentry);
53994 + }
53995 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53996 + error = -EACCES;
53997 + goto exit2;
53998 + }
53999 +
54000 error = security_path_unlink(&nd.path, dentry);
54001 if (error)
54002 goto exit2;
54003 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54004 + if (!error && (saved_ino || saved_dev))
54005 + gr_handle_delete(saved_ino, saved_dev);
54006 exit2:
54007 dput(dentry);
54008 }
54009 @@ -3536,9 +3700,17 @@ retry:
54010 if (IS_ERR(dentry))
54011 goto out_putname;
54012
54013 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54014 + error = -EACCES;
54015 + goto out;
54016 + }
54017 +
54018 error = security_path_symlink(&path, dentry, from->name);
54019 if (!error)
54020 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54021 + if (!error)
54022 + gr_handle_create(dentry, path.mnt);
54023 +out:
54024 done_path_create(&path, dentry);
54025 if (retry_estale(error, lookup_flags)) {
54026 lookup_flags |= LOOKUP_REVAL;
54027 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54028 {
54029 struct dentry *new_dentry;
54030 struct path old_path, new_path;
54031 + struct filename *to = NULL;
54032 int how = 0;
54033 int error;
54034
54035 @@ -3635,7 +3808,7 @@ retry:
54036 if (error)
54037 return error;
54038
54039 - new_dentry = user_path_create(newdfd, newname, &new_path,
54040 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54041 (how & LOOKUP_REVAL));
54042 error = PTR_ERR(new_dentry);
54043 if (IS_ERR(new_dentry))
54044 @@ -3647,11 +3820,28 @@ retry:
54045 error = may_linkat(&old_path);
54046 if (unlikely(error))
54047 goto out_dput;
54048 +
54049 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54050 + old_path.dentry->d_inode,
54051 + old_path.dentry->d_inode->i_mode, to)) {
54052 + error = -EACCES;
54053 + goto out_dput;
54054 + }
54055 +
54056 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54057 + old_path.dentry, old_path.mnt, to)) {
54058 + error = -EACCES;
54059 + goto out_dput;
54060 + }
54061 +
54062 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54063 if (error)
54064 goto out_dput;
54065 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54066 + if (!error)
54067 + gr_handle_create(new_dentry, new_path.mnt);
54068 out_dput:
54069 + putname(to);
54070 done_path_create(&new_path, new_dentry);
54071 if (retry_estale(error, how)) {
54072 how |= LOOKUP_REVAL;
54073 @@ -3897,12 +4087,21 @@ retry:
54074 if (new_dentry == trap)
54075 goto exit5;
54076
54077 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54078 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54079 + to);
54080 + if (error)
54081 + goto exit5;
54082 +
54083 error = security_path_rename(&oldnd.path, old_dentry,
54084 &newnd.path, new_dentry);
54085 if (error)
54086 goto exit5;
54087 error = vfs_rename(old_dir->d_inode, old_dentry,
54088 new_dir->d_inode, new_dentry);
54089 + if (!error)
54090 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54091 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54092 exit5:
54093 dput(new_dentry);
54094 exit4:
54095 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54096
54097 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54098 {
54099 + char tmpbuf[64];
54100 + const char *newlink;
54101 int len;
54102
54103 len = PTR_ERR(link);
54104 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54105 len = strlen(link);
54106 if (len > (unsigned) buflen)
54107 len = buflen;
54108 - if (copy_to_user(buffer, link, len))
54109 +
54110 + if (len < sizeof(tmpbuf)) {
54111 + memcpy(tmpbuf, link, len);
54112 + newlink = tmpbuf;
54113 + } else
54114 + newlink = link;
54115 +
54116 + if (copy_to_user(buffer, newlink, len))
54117 len = -EFAULT;
54118 out:
54119 return len;
54120 diff --git a/fs/namespace.c b/fs/namespace.c
54121 index 7b1ca9b..6faeccf 100644
54122 --- a/fs/namespace.c
54123 +++ b/fs/namespace.c
54124 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
54125 if (!(sb->s_flags & MS_RDONLY))
54126 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54127 up_write(&sb->s_umount);
54128 +
54129 + gr_log_remount(mnt->mnt_devname, retval);
54130 +
54131 return retval;
54132 }
54133
54134 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
54135 }
54136 br_write_unlock(&vfsmount_lock);
54137 namespace_unlock();
54138 +
54139 + gr_log_unmount(mnt->mnt_devname, retval);
54140 +
54141 return retval;
54142 }
54143
54144 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
54145 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54146 */
54147
54148 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54149 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54150 {
54151 struct path path;
54152 struct mount *mnt;
54153 @@ -1342,7 +1348,7 @@ out:
54154 /*
54155 * The 2.0 compatible umount. No flags.
54156 */
54157 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54158 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54159 {
54160 return sys_umount(name, 0);
54161 }
54162 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54163 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54164 MS_STRICTATIME);
54165
54166 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54167 + retval = -EPERM;
54168 + goto dput_out;
54169 + }
54170 +
54171 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54172 + retval = -EPERM;
54173 + goto dput_out;
54174 + }
54175 +
54176 if (flags & MS_REMOUNT)
54177 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54178 data_page);
54179 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54180 dev_name, data_page);
54181 dput_out:
54182 path_put(&path);
54183 +
54184 + gr_log_mount(dev_name, dir_name, retval);
54185 +
54186 return retval;
54187 }
54188
54189 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54190 }
54191 EXPORT_SYMBOL(mount_subtree);
54192
54193 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54194 - char __user *, type, unsigned long, flags, void __user *, data)
54195 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54196 + const char __user *, type, unsigned long, flags, void __user *, data)
54197 {
54198 int ret;
54199 char *kernel_type;
54200 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54201 if (error)
54202 goto out2;
54203
54204 + if (gr_handle_chroot_pivot()) {
54205 + error = -EPERM;
54206 + goto out2;
54207 + }
54208 +
54209 get_fs_root(current->fs, &root);
54210 old_mp = lock_mount(&old);
54211 error = PTR_ERR(old_mp);
54212 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54213 !nsown_capable(CAP_SYS_ADMIN))
54214 return -EPERM;
54215
54216 - if (fs->users != 1)
54217 + if (atomic_read(&fs->users) != 1)
54218 return -EINVAL;
54219
54220 get_mnt_ns(mnt_ns);
54221 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54222 index cff089a..4c3d57a 100644
54223 --- a/fs/nfs/callback.c
54224 +++ b/fs/nfs/callback.c
54225 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54226 struct svc_rqst *rqstp;
54227 int (*callback_svc)(void *vrqstp);
54228 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54229 - char svc_name[12];
54230 int ret;
54231
54232 nfs_callback_bc_serv(minorversion, xprt, serv);
54233 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54234
54235 svc_sock_update_bufs(serv);
54236
54237 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54238 cb_info->serv = serv;
54239 cb_info->rqst = rqstp;
54240 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54241 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54242 if (IS_ERR(cb_info->task)) {
54243 ret = PTR_ERR(cb_info->task);
54244 svc_exit_thread(cb_info->rqst);
54245 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54246 index a35582c..ebbdcd5 100644
54247 --- a/fs/nfs/callback_xdr.c
54248 +++ b/fs/nfs/callback_xdr.c
54249 @@ -51,7 +51,7 @@ struct callback_op {
54250 callback_decode_arg_t decode_args;
54251 callback_encode_res_t encode_res;
54252 long res_maxsize;
54253 -};
54254 +} __do_const;
54255
54256 static struct callback_op callback_ops[];
54257
54258 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54259 index c1c7a9d..7afa0b8 100644
54260 --- a/fs/nfs/inode.c
54261 +++ b/fs/nfs/inode.c
54262 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54263 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54264 }
54265
54266 -static atomic_long_t nfs_attr_generation_counter;
54267 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54268
54269 static unsigned long nfs_read_attr_generation_counter(void)
54270 {
54271 - return atomic_long_read(&nfs_attr_generation_counter);
54272 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54273 }
54274
54275 unsigned long nfs_inc_attr_generation_counter(void)
54276 {
54277 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54278 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54279 }
54280
54281 void nfs_fattr_init(struct nfs_fattr *fattr)
54282 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54283 index 1fab140..73d0f75 100644
54284 --- a/fs/nfs/nfs4state.c
54285 +++ b/fs/nfs/nfs4state.c
54286 @@ -1194,7 +1194,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54287 snprintf(buf, sizeof(buf), "%s-manager",
54288 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54289 rcu_read_unlock();
54290 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54291 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54292 if (IS_ERR(task)) {
54293 printk(KERN_ERR "%s: kthread_run: %ld\n",
54294 __func__, PTR_ERR(task));
54295 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54296 index 27d74a2..c4c2a73 100644
54297 --- a/fs/nfsd/nfs4proc.c
54298 +++ b/fs/nfsd/nfs4proc.c
54299 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
54300 nfsd4op_rsize op_rsize_bop;
54301 stateid_getter op_get_currentstateid;
54302 stateid_setter op_set_currentstateid;
54303 -};
54304 +} __do_const;
54305
54306 static struct nfsd4_operation nfsd4_ops[];
54307
54308 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54309 index 6cd86e0..0369a36 100644
54310 --- a/fs/nfsd/nfs4xdr.c
54311 +++ b/fs/nfsd/nfs4xdr.c
54312 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54313
54314 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54315
54316 -static nfsd4_dec nfsd4_dec_ops[] = {
54317 +static const nfsd4_dec nfsd4_dec_ops[] = {
54318 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54319 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54320 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54321 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54322 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54323 };
54324
54325 -static nfsd4_dec nfsd41_dec_ops[] = {
54326 +static const nfsd4_dec nfsd41_dec_ops[] = {
54327 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54328 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54329 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54330 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54331 };
54332
54333 struct nfsd4_minorversion_ops {
54334 - nfsd4_dec *decoders;
54335 + const nfsd4_dec *decoders;
54336 int nops;
54337 };
54338
54339 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54340 index e76244e..9fe8f2f1 100644
54341 --- a/fs/nfsd/nfscache.c
54342 +++ b/fs/nfsd/nfscache.c
54343 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54344 {
54345 struct svc_cacherep *rp = rqstp->rq_cacherep;
54346 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54347 - int len;
54348 + long len;
54349 size_t bufsize = 0;
54350
54351 if (!rp)
54352 return;
54353
54354 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54355 - len >>= 2;
54356 + if (statp) {
54357 + len = (char*)statp - (char*)resv->iov_base;
54358 + len = resv->iov_len - len;
54359 + len >>= 2;
54360 + }
54361
54362 /* Don't cache excessive amounts of data and XDR failures */
54363 if (!statp || len > (256 >> 2)) {
54364 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54365 index 84ce601..633d226 100644
54366 --- a/fs/nfsd/vfs.c
54367 +++ b/fs/nfsd/vfs.c
54368 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54369 } else {
54370 oldfs = get_fs();
54371 set_fs(KERNEL_DS);
54372 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54373 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54374 set_fs(oldfs);
54375 }
54376
54377 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54378
54379 /* Write the data. */
54380 oldfs = get_fs(); set_fs(KERNEL_DS);
54381 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54382 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54383 set_fs(oldfs);
54384 if (host_err < 0)
54385 goto out_nfserr;
54386 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54387 */
54388
54389 oldfs = get_fs(); set_fs(KERNEL_DS);
54390 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54391 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54392 set_fs(oldfs);
54393
54394 if (host_err < 0)
54395 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54396 index fea6bd5..8ee9d81 100644
54397 --- a/fs/nls/nls_base.c
54398 +++ b/fs/nls/nls_base.c
54399 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54400
54401 int register_nls(struct nls_table * nls)
54402 {
54403 - struct nls_table ** tmp = &tables;
54404 + struct nls_table *tmp = tables;
54405
54406 if (nls->next)
54407 return -EBUSY;
54408
54409 spin_lock(&nls_lock);
54410 - while (*tmp) {
54411 - if (nls == *tmp) {
54412 + while (tmp) {
54413 + if (nls == tmp) {
54414 spin_unlock(&nls_lock);
54415 return -EBUSY;
54416 }
54417 - tmp = &(*tmp)->next;
54418 + tmp = tmp->next;
54419 }
54420 - nls->next = tables;
54421 + pax_open_kernel();
54422 + *(struct nls_table **)&nls->next = tables;
54423 + pax_close_kernel();
54424 tables = nls;
54425 spin_unlock(&nls_lock);
54426 return 0;
54427 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54428
54429 int unregister_nls(struct nls_table * nls)
54430 {
54431 - struct nls_table ** tmp = &tables;
54432 + struct nls_table * const * tmp = &tables;
54433
54434 spin_lock(&nls_lock);
54435 while (*tmp) {
54436 if (nls == *tmp) {
54437 - *tmp = nls->next;
54438 + pax_open_kernel();
54439 + *(struct nls_table **)tmp = nls->next;
54440 + pax_close_kernel();
54441 spin_unlock(&nls_lock);
54442 return 0;
54443 }
54444 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54445 index 7424929..35f6be5 100644
54446 --- a/fs/nls/nls_euc-jp.c
54447 +++ b/fs/nls/nls_euc-jp.c
54448 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54449 p_nls = load_nls("cp932");
54450
54451 if (p_nls) {
54452 - table.charset2upper = p_nls->charset2upper;
54453 - table.charset2lower = p_nls->charset2lower;
54454 + pax_open_kernel();
54455 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54456 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54457 + pax_close_kernel();
54458 return register_nls(&table);
54459 }
54460
54461 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54462 index e7bc1d7..06bd4bb 100644
54463 --- a/fs/nls/nls_koi8-ru.c
54464 +++ b/fs/nls/nls_koi8-ru.c
54465 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54466 p_nls = load_nls("koi8-u");
54467
54468 if (p_nls) {
54469 - table.charset2upper = p_nls->charset2upper;
54470 - table.charset2lower = p_nls->charset2lower;
54471 + pax_open_kernel();
54472 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54473 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54474 + pax_close_kernel();
54475 return register_nls(&table);
54476 }
54477
54478 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54479 index 6c80083..a1e6299 100644
54480 --- a/fs/notify/fanotify/fanotify_user.c
54481 +++ b/fs/notify/fanotify/fanotify_user.c
54482 @@ -122,6 +122,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54483 metadata->event_len = FAN_EVENT_METADATA_LEN;
54484 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54485 metadata->vers = FANOTIFY_METADATA_VERSION;
54486 + metadata->reserved = 0;
54487 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54488 metadata->pid = pid_vnr(event->tgid);
54489 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54490 @@ -252,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54491
54492 fd = fanotify_event_metadata.fd;
54493 ret = -EFAULT;
54494 - if (copy_to_user(buf, &fanotify_event_metadata,
54495 - fanotify_event_metadata.event_len))
54496 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54497 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54498 goto out_close_fd;
54499
54500 ret = prepare_for_access_response(group, event, fd);
54501 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54502 index 7b51b05..5ea5ef6 100644
54503 --- a/fs/notify/notification.c
54504 +++ b/fs/notify/notification.c
54505 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54506 * get set to 0 so it will never get 'freed'
54507 */
54508 static struct fsnotify_event *q_overflow_event;
54509 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54510 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54511
54512 /**
54513 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54514 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54515 */
54516 u32 fsnotify_get_cookie(void)
54517 {
54518 - return atomic_inc_return(&fsnotify_sync_cookie);
54519 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54520 }
54521 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54522
54523 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54524 index aa411c3..c260a84 100644
54525 --- a/fs/ntfs/dir.c
54526 +++ b/fs/ntfs/dir.c
54527 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54528 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54529 ~(s64)(ndir->itype.index.block_size - 1)));
54530 /* Bounds checks. */
54531 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54532 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54533 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54534 "inode 0x%lx or driver bug.", vdir->i_ino);
54535 goto err_out;
54536 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54537 index c5670b8..01a3656 100644
54538 --- a/fs/ntfs/file.c
54539 +++ b/fs/ntfs/file.c
54540 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54541 #endif /* NTFS_RW */
54542 };
54543
54544 -const struct file_operations ntfs_empty_file_ops = {};
54545 +const struct file_operations ntfs_empty_file_ops __read_only;
54546
54547 -const struct inode_operations ntfs_empty_inode_ops = {};
54548 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54549 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54550 index aebeacd..0dcdd26 100644
54551 --- a/fs/ocfs2/localalloc.c
54552 +++ b/fs/ocfs2/localalloc.c
54553 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54554 goto bail;
54555 }
54556
54557 - atomic_inc(&osb->alloc_stats.moves);
54558 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54559
54560 bail:
54561 if (handle)
54562 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54563 index d355e6e..578d905 100644
54564 --- a/fs/ocfs2/ocfs2.h
54565 +++ b/fs/ocfs2/ocfs2.h
54566 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54567
54568 struct ocfs2_alloc_stats
54569 {
54570 - atomic_t moves;
54571 - atomic_t local_data;
54572 - atomic_t bitmap_data;
54573 - atomic_t bg_allocs;
54574 - atomic_t bg_extends;
54575 + atomic_unchecked_t moves;
54576 + atomic_unchecked_t local_data;
54577 + atomic_unchecked_t bitmap_data;
54578 + atomic_unchecked_t bg_allocs;
54579 + atomic_unchecked_t bg_extends;
54580 };
54581
54582 enum ocfs2_local_alloc_state
54583 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54584 index b7e74b5..19c6536 100644
54585 --- a/fs/ocfs2/suballoc.c
54586 +++ b/fs/ocfs2/suballoc.c
54587 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54588 mlog_errno(status);
54589 goto bail;
54590 }
54591 - atomic_inc(&osb->alloc_stats.bg_extends);
54592 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54593
54594 /* You should never ask for this much metadata */
54595 BUG_ON(bits_wanted >
54596 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54597 mlog_errno(status);
54598 goto bail;
54599 }
54600 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54601 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54602
54603 *suballoc_loc = res.sr_bg_blkno;
54604 *suballoc_bit_start = res.sr_bit_offset;
54605 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54606 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54607 res->sr_bits);
54608
54609 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54610 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54611
54612 BUG_ON(res->sr_bits != 1);
54613
54614 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54615 mlog_errno(status);
54616 goto bail;
54617 }
54618 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54619 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54620
54621 BUG_ON(res.sr_bits != 1);
54622
54623 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54624 cluster_start,
54625 num_clusters);
54626 if (!status)
54627 - atomic_inc(&osb->alloc_stats.local_data);
54628 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54629 } else {
54630 if (min_clusters > (osb->bitmap_cpg - 1)) {
54631 /* The only paths asking for contiguousness
54632 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54633 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54634 res.sr_bg_blkno,
54635 res.sr_bit_offset);
54636 - atomic_inc(&osb->alloc_stats.bitmap_data);
54637 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54638 *num_clusters = res.sr_bits;
54639 }
54640 }
54641 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54642 index 01b8516..579c4df 100644
54643 --- a/fs/ocfs2/super.c
54644 +++ b/fs/ocfs2/super.c
54645 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54646 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54647 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54648 "Stats",
54649 - atomic_read(&osb->alloc_stats.bitmap_data),
54650 - atomic_read(&osb->alloc_stats.local_data),
54651 - atomic_read(&osb->alloc_stats.bg_allocs),
54652 - atomic_read(&osb->alloc_stats.moves),
54653 - atomic_read(&osb->alloc_stats.bg_extends));
54654 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54655 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54656 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54657 + atomic_read_unchecked(&osb->alloc_stats.moves),
54658 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54659
54660 out += snprintf(buf + out, len - out,
54661 "%10s => State: %u Descriptor: %llu Size: %u bits "
54662 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54663 spin_lock_init(&osb->osb_xattr_lock);
54664 ocfs2_init_steal_slots(osb);
54665
54666 - atomic_set(&osb->alloc_stats.moves, 0);
54667 - atomic_set(&osb->alloc_stats.local_data, 0);
54668 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54669 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54670 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54671 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54672 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54673 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54674 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54675 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54676
54677 /* Copy the blockcheck stats from the superblock probe */
54678 osb->osb_ecc_stats = *stats;
54679 diff --git a/fs/open.c b/fs/open.c
54680 index 8c74100..4239c48 100644
54681 --- a/fs/open.c
54682 +++ b/fs/open.c
54683 @@ -32,6 +32,8 @@
54684 #include <linux/dnotify.h>
54685 #include <linux/compat.h>
54686
54687 +#define CREATE_TRACE_POINTS
54688 +#include <trace/events/fs.h>
54689 #include "internal.h"
54690
54691 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54692 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54693 error = locks_verify_truncate(inode, NULL, length);
54694 if (!error)
54695 error = security_path_truncate(path);
54696 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54697 + error = -EACCES;
54698 if (!error)
54699 error = do_truncate(path->dentry, length, 0, NULL);
54700
54701 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54702 error = locks_verify_truncate(inode, f.file, length);
54703 if (!error)
54704 error = security_path_truncate(&f.file->f_path);
54705 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54706 + error = -EACCES;
54707 if (!error)
54708 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54709 sb_end_write(inode->i_sb);
54710 @@ -360,6 +366,9 @@ retry:
54711 if (__mnt_is_readonly(path.mnt))
54712 res = -EROFS;
54713
54714 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54715 + res = -EACCES;
54716 +
54717 out_path_release:
54718 path_put(&path);
54719 if (retry_estale(res, lookup_flags)) {
54720 @@ -391,6 +400,8 @@ retry:
54721 if (error)
54722 goto dput_and_out;
54723
54724 + gr_log_chdir(path.dentry, path.mnt);
54725 +
54726 set_fs_pwd(current->fs, &path);
54727
54728 dput_and_out:
54729 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54730 goto out_putf;
54731
54732 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54733 +
54734 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54735 + error = -EPERM;
54736 +
54737 + if (!error)
54738 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54739 +
54740 if (!error)
54741 set_fs_pwd(current->fs, &f.file->f_path);
54742 out_putf:
54743 @@ -449,7 +467,13 @@ retry:
54744 if (error)
54745 goto dput_and_out;
54746
54747 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54748 + goto dput_and_out;
54749 +
54750 set_fs_root(current->fs, &path);
54751 +
54752 + gr_handle_chroot_chdir(&path);
54753 +
54754 error = 0;
54755 dput_and_out:
54756 path_put(&path);
54757 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
54758 if (error)
54759 return error;
54760 mutex_lock(&inode->i_mutex);
54761 +
54762 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54763 + error = -EACCES;
54764 + goto out_unlock;
54765 + }
54766 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54767 + error = -EACCES;
54768 + goto out_unlock;
54769 + }
54770 +
54771 error = security_path_chmod(path, mode);
54772 if (error)
54773 goto out_unlock;
54774 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54775 uid = make_kuid(current_user_ns(), user);
54776 gid = make_kgid(current_user_ns(), group);
54777
54778 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54779 + return -EACCES;
54780 +
54781 newattrs.ia_valid = ATTR_CTIME;
54782 if (user != (uid_t) -1) {
54783 if (!uid_valid(uid))
54784 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54785 } else {
54786 fsnotify_open(f);
54787 fd_install(fd, f);
54788 + trace_do_sys_open(tmp->name, flags, mode);
54789 }
54790 }
54791 putname(tmp);
54792 diff --git a/fs/pipe.c b/fs/pipe.c
54793 index d2c45e1..009fe1c 100644
54794 --- a/fs/pipe.c
54795 +++ b/fs/pipe.c
54796 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
54797
54798 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
54799 {
54800 - if (pipe->files)
54801 + if (atomic_read(&pipe->files))
54802 mutex_lock_nested(&pipe->mutex, subclass);
54803 }
54804
54805 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
54806
54807 void pipe_unlock(struct pipe_inode_info *pipe)
54808 {
54809 - if (pipe->files)
54810 + if (atomic_read(&pipe->files))
54811 mutex_unlock(&pipe->mutex);
54812 }
54813 EXPORT_SYMBOL(pipe_unlock);
54814 @@ -449,9 +449,9 @@ redo:
54815 }
54816 if (bufs) /* More to do? */
54817 continue;
54818 - if (!pipe->writers)
54819 + if (!atomic_read(&pipe->writers))
54820 break;
54821 - if (!pipe->waiting_writers) {
54822 + if (!atomic_read(&pipe->waiting_writers)) {
54823 /* syscall merging: Usually we must not sleep
54824 * if O_NONBLOCK is set, or if we got some data.
54825 * But if a writer sleeps in kernel space, then
54826 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54827 ret = 0;
54828 __pipe_lock(pipe);
54829
54830 - if (!pipe->readers) {
54831 + if (!atomic_read(&pipe->readers)) {
54832 send_sig(SIGPIPE, current, 0);
54833 ret = -EPIPE;
54834 goto out;
54835 @@ -562,7 +562,7 @@ redo1:
54836 for (;;) {
54837 int bufs;
54838
54839 - if (!pipe->readers) {
54840 + if (!atomic_read(&pipe->readers)) {
54841 send_sig(SIGPIPE, current, 0);
54842 if (!ret)
54843 ret = -EPIPE;
54844 @@ -653,9 +653,9 @@ redo2:
54845 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54846 do_wakeup = 0;
54847 }
54848 - pipe->waiting_writers++;
54849 + atomic_inc(&pipe->waiting_writers);
54850 pipe_wait(pipe);
54851 - pipe->waiting_writers--;
54852 + atomic_dec(&pipe->waiting_writers);
54853 }
54854 out:
54855 __pipe_unlock(pipe);
54856 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54857 mask = 0;
54858 if (filp->f_mode & FMODE_READ) {
54859 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54860 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54861 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54862 mask |= POLLHUP;
54863 }
54864
54865 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54866 * Most Unices do not set POLLERR for FIFOs but on Linux they
54867 * behave exactly like pipes for poll().
54868 */
54869 - if (!pipe->readers)
54870 + if (!atomic_read(&pipe->readers))
54871 mask |= POLLERR;
54872 }
54873
54874 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
54875
54876 __pipe_lock(pipe);
54877 if (file->f_mode & FMODE_READ)
54878 - pipe->readers--;
54879 + atomic_dec(&pipe->readers);
54880 if (file->f_mode & FMODE_WRITE)
54881 - pipe->writers--;
54882 + atomic_dec(&pipe->writers);
54883
54884 - if (pipe->readers || pipe->writers) {
54885 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
54886 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54887 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54888 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
54889 }
54890 spin_lock(&inode->i_lock);
54891 - if (!--pipe->files) {
54892 + if (atomic_dec_and_test(&pipe->files)) {
54893 inode->i_pipe = NULL;
54894 kill = 1;
54895 }
54896 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
54897 kfree(pipe);
54898 }
54899
54900 -static struct vfsmount *pipe_mnt __read_mostly;
54901 +struct vfsmount *pipe_mnt __read_mostly;
54902
54903 /*
54904 * pipefs_dname() is called from d_path().
54905 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
54906 goto fail_iput;
54907
54908 inode->i_pipe = pipe;
54909 - pipe->files = 2;
54910 - pipe->readers = pipe->writers = 1;
54911 + atomic_set(&pipe->files, 2);
54912 + atomic_set(&pipe->readers, 1);
54913 + atomic_set(&pipe->writers, 1);
54914 inode->i_fop = &pipefifo_fops;
54915
54916 /*
54917 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
54918 spin_lock(&inode->i_lock);
54919 if (inode->i_pipe) {
54920 pipe = inode->i_pipe;
54921 - pipe->files++;
54922 + atomic_inc(&pipe->files);
54923 spin_unlock(&inode->i_lock);
54924 } else {
54925 spin_unlock(&inode->i_lock);
54926 pipe = alloc_pipe_info();
54927 if (!pipe)
54928 return -ENOMEM;
54929 - pipe->files = 1;
54930 + atomic_set(&pipe->files, 1);
54931 spin_lock(&inode->i_lock);
54932 if (unlikely(inode->i_pipe)) {
54933 - inode->i_pipe->files++;
54934 + atomic_inc(&inode->i_pipe->files);
54935 spin_unlock(&inode->i_lock);
54936 free_pipe_info(pipe);
54937 pipe = inode->i_pipe;
54938 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
54939 * opened, even when there is no process writing the FIFO.
54940 */
54941 pipe->r_counter++;
54942 - if (pipe->readers++ == 0)
54943 + if (atomic_inc_return(&pipe->readers) == 1)
54944 wake_up_partner(pipe);
54945
54946 - if (!is_pipe && !pipe->writers) {
54947 + if (!is_pipe && !atomic_read(&pipe->writers)) {
54948 if ((filp->f_flags & O_NONBLOCK)) {
54949 /* suppress POLLHUP until we have
54950 * seen a writer */
54951 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
54952 * errno=ENXIO when there is no process reading the FIFO.
54953 */
54954 ret = -ENXIO;
54955 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
54956 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
54957 goto err;
54958
54959 pipe->w_counter++;
54960 - if (!pipe->writers++)
54961 + if (atomic_inc_return(&pipe->writers) == 1)
54962 wake_up_partner(pipe);
54963
54964 - if (!is_pipe && !pipe->readers) {
54965 + if (!is_pipe && !atomic_read(&pipe->readers)) {
54966 if (wait_for_partner(pipe, &pipe->r_counter))
54967 goto err_wr;
54968 }
54969 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
54970 * the process can at least talk to itself.
54971 */
54972
54973 - pipe->readers++;
54974 - pipe->writers++;
54975 + atomic_inc(&pipe->readers);
54976 + atomic_inc(&pipe->writers);
54977 pipe->r_counter++;
54978 pipe->w_counter++;
54979 - if (pipe->readers == 1 || pipe->writers == 1)
54980 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
54981 wake_up_partner(pipe);
54982 break;
54983
54984 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
54985 return 0;
54986
54987 err_rd:
54988 - if (!--pipe->readers)
54989 + if (atomic_dec_and_test(&pipe->readers))
54990 wake_up_interruptible(&pipe->wait);
54991 ret = -ERESTARTSYS;
54992 goto err;
54993
54994 err_wr:
54995 - if (!--pipe->writers)
54996 + if (atomic_dec_and_test(&pipe->writers))
54997 wake_up_interruptible(&pipe->wait);
54998 ret = -ERESTARTSYS;
54999 goto err;
55000
55001 err:
55002 spin_lock(&inode->i_lock);
55003 - if (!--pipe->files) {
55004 + if (atomic_dec_and_test(&pipe->files)) {
55005 inode->i_pipe = NULL;
55006 kill = 1;
55007 }
55008 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55009 index 15af622..0e9f4467 100644
55010 --- a/fs/proc/Kconfig
55011 +++ b/fs/proc/Kconfig
55012 @@ -30,12 +30,12 @@ config PROC_FS
55013
55014 config PROC_KCORE
55015 bool "/proc/kcore support" if !ARM
55016 - depends on PROC_FS && MMU
55017 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55018
55019 config PROC_VMCORE
55020 bool "/proc/vmcore support"
55021 - depends on PROC_FS && CRASH_DUMP
55022 - default y
55023 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55024 + default n
55025 help
55026 Exports the dump image of crashed kernel in ELF format.
55027
55028 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55029 limited in memory.
55030
55031 config PROC_PAGE_MONITOR
55032 - default y
55033 - depends on PROC_FS && MMU
55034 + default n
55035 + depends on PROC_FS && MMU && !GRKERNSEC
55036 bool "Enable /proc page monitoring" if EXPERT
55037 help
55038 Various /proc files exist to monitor process memory utilization:
55039 diff --git a/fs/proc/array.c b/fs/proc/array.c
55040 index cbd0f1b..adec3f0 100644
55041 --- a/fs/proc/array.c
55042 +++ b/fs/proc/array.c
55043 @@ -60,6 +60,7 @@
55044 #include <linux/tty.h>
55045 #include <linux/string.h>
55046 #include <linux/mman.h>
55047 +#include <linux/grsecurity.h>
55048 #include <linux/proc_fs.h>
55049 #include <linux/ioport.h>
55050 #include <linux/uaccess.h>
55051 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55052 seq_putc(m, '\n');
55053 }
55054
55055 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55056 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55057 +{
55058 + if (p->mm)
55059 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55060 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55061 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55062 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55063 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55064 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55065 + else
55066 + seq_printf(m, "PaX:\t-----\n");
55067 +}
55068 +#endif
55069 +
55070 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55071 struct pid *pid, struct task_struct *task)
55072 {
55073 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55074 task_cpus_allowed(m, task);
55075 cpuset_task_status_allowed(m, task);
55076 task_context_switch_counts(m, task);
55077 +
55078 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55079 + task_pax(m, task);
55080 +#endif
55081 +
55082 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55083 + task_grsec_rbac(m, task);
55084 +#endif
55085 +
55086 return 0;
55087 }
55088
55089 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55090 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55091 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55092 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55093 +#endif
55094 +
55095 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55096 struct pid *pid, struct task_struct *task, int whole)
55097 {
55098 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55099 char tcomm[sizeof(task->comm)];
55100 unsigned long flags;
55101
55102 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55103 + if (current->exec_id != m->exec_id) {
55104 + gr_log_badprocpid("stat");
55105 + return 0;
55106 + }
55107 +#endif
55108 +
55109 state = *get_task_state(task);
55110 vsize = eip = esp = 0;
55111 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55112 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55113 gtime = task_gtime(task);
55114 }
55115
55116 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55117 + if (PAX_RAND_FLAGS(mm)) {
55118 + eip = 0;
55119 + esp = 0;
55120 + wchan = 0;
55121 + }
55122 +#endif
55123 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55124 + wchan = 0;
55125 + eip =0;
55126 + esp =0;
55127 +#endif
55128 +
55129 /* scale priority and nice values from timeslices to -20..20 */
55130 /* to make it look like a "normal" Unix priority/nice value */
55131 priority = task_prio(task);
55132 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55133 seq_put_decimal_ull(m, ' ', vsize);
55134 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55135 seq_put_decimal_ull(m, ' ', rsslim);
55136 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55137 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55138 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55139 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55140 +#else
55141 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55142 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55143 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55144 +#endif
55145 seq_put_decimal_ull(m, ' ', esp);
55146 seq_put_decimal_ull(m, ' ', eip);
55147 /* The signal information here is obsolete.
55148 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55149 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55150 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55151
55152 - if (mm && permitted) {
55153 + if (mm && permitted
55154 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55155 + && !PAX_RAND_FLAGS(mm)
55156 +#endif
55157 + ) {
55158 seq_put_decimal_ull(m, ' ', mm->start_data);
55159 seq_put_decimal_ull(m, ' ', mm->end_data);
55160 seq_put_decimal_ull(m, ' ', mm->start_brk);
55161 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55162 struct pid *pid, struct task_struct *task)
55163 {
55164 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55165 - struct mm_struct *mm = get_task_mm(task);
55166 + struct mm_struct *mm;
55167
55168 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55169 + if (current->exec_id != m->exec_id) {
55170 + gr_log_badprocpid("statm");
55171 + return 0;
55172 + }
55173 +#endif
55174 + mm = get_task_mm(task);
55175 if (mm) {
55176 size = task_statm(mm, &shared, &text, &data, &resident);
55177 mmput(mm);
55178 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55179 return 0;
55180 }
55181
55182 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55183 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55184 +{
55185 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55186 +}
55187 +#endif
55188 +
55189 #ifdef CONFIG_CHECKPOINT_RESTORE
55190 static struct pid *
55191 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55192 diff --git a/fs/proc/base.c b/fs/proc/base.c
55193 index c3834da..b402b2b 100644
55194 --- a/fs/proc/base.c
55195 +++ b/fs/proc/base.c
55196 @@ -113,6 +113,14 @@ struct pid_entry {
55197 union proc_op op;
55198 };
55199
55200 +struct getdents_callback {
55201 + struct linux_dirent __user * current_dir;
55202 + struct linux_dirent __user * previous;
55203 + struct file * file;
55204 + int count;
55205 + int error;
55206 +};
55207 +
55208 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55209 .name = (NAME), \
55210 .len = sizeof(NAME) - 1, \
55211 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55212 if (!mm->arg_end)
55213 goto out_mm; /* Shh! No looking before we're done */
55214
55215 + if (gr_acl_handle_procpidmem(task))
55216 + goto out_mm;
55217 +
55218 len = mm->arg_end - mm->arg_start;
55219
55220 if (len > PAGE_SIZE)
55221 @@ -237,12 +248,28 @@ out:
55222 return res;
55223 }
55224
55225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55226 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55227 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55228 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55229 +#endif
55230 +
55231 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55232 {
55233 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55234 int res = PTR_ERR(mm);
55235 if (mm && !IS_ERR(mm)) {
55236 unsigned int nwords = 0;
55237 +
55238 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55239 + /* allow if we're currently ptracing this task */
55240 + if (PAX_RAND_FLAGS(mm) &&
55241 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55242 + mmput(mm);
55243 + return 0;
55244 + }
55245 +#endif
55246 +
55247 do {
55248 nwords += 2;
55249 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55250 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55251 }
55252
55253
55254 -#ifdef CONFIG_KALLSYMS
55255 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55256 /*
55257 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55258 * Returns the resolved symbol. If that fails, simply return the address.
55259 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
55260 mutex_unlock(&task->signal->cred_guard_mutex);
55261 }
55262
55263 -#ifdef CONFIG_STACKTRACE
55264 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55265
55266 #define MAX_STACK_TRACE_DEPTH 64
55267
55268 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55269 return count;
55270 }
55271
55272 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55273 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55274 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55275 {
55276 long nr;
55277 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55278 /************************************************************************/
55279
55280 /* permission checks */
55281 -static int proc_fd_access_allowed(struct inode *inode)
55282 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55283 {
55284 struct task_struct *task;
55285 int allowed = 0;
55286 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55287 */
55288 task = get_proc_task(inode);
55289 if (task) {
55290 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55291 + if (log)
55292 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55293 + else
55294 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55295 put_task_struct(task);
55296 }
55297 return allowed;
55298 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55299 struct task_struct *task,
55300 int hide_pid_min)
55301 {
55302 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55303 + return false;
55304 +
55305 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55306 + rcu_read_lock();
55307 + {
55308 + const struct cred *tmpcred = current_cred();
55309 + const struct cred *cred = __task_cred(task);
55310 +
55311 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55312 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55313 + || in_group_p(grsec_proc_gid)
55314 +#endif
55315 + ) {
55316 + rcu_read_unlock();
55317 + return true;
55318 + }
55319 + }
55320 + rcu_read_unlock();
55321 +
55322 + if (!pid->hide_pid)
55323 + return false;
55324 +#endif
55325 +
55326 if (pid->hide_pid < hide_pid_min)
55327 return true;
55328 if (in_group_p(pid->pid_gid))
55329 return true;
55330 +
55331 return ptrace_may_access(task, PTRACE_MODE_READ);
55332 }
55333
55334 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55335 put_task_struct(task);
55336
55337 if (!has_perms) {
55338 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55339 + {
55340 +#else
55341 if (pid->hide_pid == 2) {
55342 +#endif
55343 /*
55344 * Let's make getdents(), stat(), and open()
55345 * consistent with each other. If a process
55346 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55347 if (!task)
55348 return -ESRCH;
55349
55350 + if (gr_acl_handle_procpidmem(task)) {
55351 + put_task_struct(task);
55352 + return -EPERM;
55353 + }
55354 +
55355 mm = mm_access(task, mode);
55356 put_task_struct(task);
55357
55358 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55359
55360 file->private_data = mm;
55361
55362 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55363 + file->f_version = current->exec_id;
55364 +#endif
55365 +
55366 return 0;
55367 }
55368
55369 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55370 ssize_t copied;
55371 char *page;
55372
55373 +#ifdef CONFIG_GRKERNSEC
55374 + if (write)
55375 + return -EPERM;
55376 +#endif
55377 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55378 + if (file->f_version != current->exec_id) {
55379 + gr_log_badprocpid("mem");
55380 + return 0;
55381 + }
55382 +#endif
55383 +
55384 if (!mm)
55385 return 0;
55386
55387 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55388 goto free;
55389
55390 while (count > 0) {
55391 - int this_len = min_t(int, count, PAGE_SIZE);
55392 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55393
55394 if (write && copy_from_user(page, buf, this_len)) {
55395 copied = -EFAULT;
55396 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55397 if (!mm)
55398 return 0;
55399
55400 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55401 + if (file->f_version != current->exec_id) {
55402 + gr_log_badprocpid("environ");
55403 + return 0;
55404 + }
55405 +#endif
55406 +
55407 page = (char *)__get_free_page(GFP_TEMPORARY);
55408 if (!page)
55409 return -ENOMEM;
55410 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55411 goto free;
55412 while (count > 0) {
55413 size_t this_len, max_len;
55414 - int retval;
55415 + ssize_t retval;
55416
55417 if (src >= (mm->env_end - mm->env_start))
55418 break;
55419 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55420 int error = -EACCES;
55421
55422 /* Are we allowed to snoop on the tasks file descriptors? */
55423 - if (!proc_fd_access_allowed(inode))
55424 + if (!proc_fd_access_allowed(inode, 0))
55425 goto out;
55426
55427 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55428 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55429 struct path path;
55430
55431 /* Are we allowed to snoop on the tasks file descriptors? */
55432 - if (!proc_fd_access_allowed(inode))
55433 - goto out;
55434 + /* logging this is needed for learning on chromium to work properly,
55435 + but we don't want to flood the logs from 'ps' which does a readlink
55436 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55437 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55438 + */
55439 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55440 + if (!proc_fd_access_allowed(inode,0))
55441 + goto out;
55442 + } else {
55443 + if (!proc_fd_access_allowed(inode,1))
55444 + goto out;
55445 + }
55446
55447 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55448 if (error)
55449 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55450 rcu_read_lock();
55451 cred = __task_cred(task);
55452 inode->i_uid = cred->euid;
55453 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55454 + inode->i_gid = grsec_proc_gid;
55455 +#else
55456 inode->i_gid = cred->egid;
55457 +#endif
55458 rcu_read_unlock();
55459 }
55460 security_task_to_inode(task, inode);
55461 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55462 return -ENOENT;
55463 }
55464 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55465 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55466 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55467 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55468 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55469 +#endif
55470 task_dumpable(task)) {
55471 cred = __task_cred(task);
55472 stat->uid = cred->euid;
55473 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55474 + stat->gid = grsec_proc_gid;
55475 +#else
55476 stat->gid = cred->egid;
55477 +#endif
55478 }
55479 }
55480 rcu_read_unlock();
55481 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55482
55483 if (task) {
55484 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55485 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55486 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55487 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55488 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55489 +#endif
55490 task_dumpable(task)) {
55491 rcu_read_lock();
55492 cred = __task_cred(task);
55493 inode->i_uid = cred->euid;
55494 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55495 + inode->i_gid = grsec_proc_gid;
55496 +#else
55497 inode->i_gid = cred->egid;
55498 +#endif
55499 rcu_read_unlock();
55500 } else {
55501 inode->i_uid = GLOBAL_ROOT_UID;
55502 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55503 if (!task)
55504 goto out_no_task;
55505
55506 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55507 + goto out;
55508 +
55509 /*
55510 * Yes, it does not scale. And it should not. Don't add
55511 * new entries into /proc/<tgid>/ without very good reasons.
55512 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
55513 if (!task)
55514 goto out_no_task;
55515
55516 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55517 + goto out;
55518 +
55519 ret = 0;
55520 i = filp->f_pos;
55521 switch (i) {
55522 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55523 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55524 #endif
55525 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55526 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55527 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55528 INF("syscall", S_IRUGO, proc_pid_syscall),
55529 #endif
55530 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55531 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55532 #ifdef CONFIG_SECURITY
55533 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55534 #endif
55535 -#ifdef CONFIG_KALLSYMS
55536 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55537 INF("wchan", S_IRUGO, proc_pid_wchan),
55538 #endif
55539 -#ifdef CONFIG_STACKTRACE
55540 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55541 ONE("stack", S_IRUGO, proc_pid_stack),
55542 #endif
55543 #ifdef CONFIG_SCHEDSTATS
55544 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55545 #ifdef CONFIG_HARDWALL
55546 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55547 #endif
55548 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55549 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55550 +#endif
55551 #ifdef CONFIG_USER_NS
55552 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55553 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55554 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55555 if (!inode)
55556 goto out;
55557
55558 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55559 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55560 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55561 + inode->i_gid = grsec_proc_gid;
55562 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55563 +#else
55564 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55565 +#endif
55566 inode->i_op = &proc_tgid_base_inode_operations;
55567 inode->i_fop = &proc_tgid_base_operations;
55568 inode->i_flags|=S_IMMUTABLE;
55569 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55570 if (!task)
55571 goto out;
55572
55573 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55574 + goto out_put_task;
55575 +
55576 result = proc_pid_instantiate(dir, dentry, task, NULL);
55577 +out_put_task:
55578 put_task_struct(task);
55579 out:
55580 return result;
55581 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55582 static int fake_filldir(void *buf, const char *name, int namelen,
55583 loff_t offset, u64 ino, unsigned d_type)
55584 {
55585 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55586 + __buf->error = -EINVAL;
55587 return 0;
55588 }
55589
55590 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
55591 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55592 #endif
55593 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55594 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55595 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55596 INF("syscall", S_IRUGO, proc_pid_syscall),
55597 #endif
55598 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55599 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
55600 #ifdef CONFIG_SECURITY
55601 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55602 #endif
55603 -#ifdef CONFIG_KALLSYMS
55604 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55605 INF("wchan", S_IRUGO, proc_pid_wchan),
55606 #endif
55607 -#ifdef CONFIG_STACKTRACE
55608 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55609 ONE("stack", S_IRUGO, proc_pid_stack),
55610 #endif
55611 #ifdef CONFIG_SCHEDSTATS
55612 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55613 index 82676e3..5f8518a 100644
55614 --- a/fs/proc/cmdline.c
55615 +++ b/fs/proc/cmdline.c
55616 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55617
55618 static int __init proc_cmdline_init(void)
55619 {
55620 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55621 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55622 +#else
55623 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55624 +#endif
55625 return 0;
55626 }
55627 module_init(proc_cmdline_init);
55628 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55629 index b143471..bb105e5 100644
55630 --- a/fs/proc/devices.c
55631 +++ b/fs/proc/devices.c
55632 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55633
55634 static int __init proc_devices_init(void)
55635 {
55636 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55637 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55638 +#else
55639 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55640 +#endif
55641 return 0;
55642 }
55643 module_init(proc_devices_init);
55644 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55645 index d7a4a28..0201742 100644
55646 --- a/fs/proc/fd.c
55647 +++ b/fs/proc/fd.c
55648 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55649 if (!task)
55650 return -ENOENT;
55651
55652 - files = get_files_struct(task);
55653 + if (!gr_acl_handle_procpidmem(task))
55654 + files = get_files_struct(task);
55655 put_task_struct(task);
55656
55657 if (files) {
55658 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55659 */
55660 int proc_fd_permission(struct inode *inode, int mask)
55661 {
55662 + struct task_struct *task;
55663 int rv = generic_permission(inode, mask);
55664 - if (rv == 0)
55665 - return 0;
55666 +
55667 if (task_pid(current) == proc_pid(inode))
55668 rv = 0;
55669 +
55670 + task = get_proc_task(inode);
55671 + if (task == NULL)
55672 + return rv;
55673 +
55674 + if (gr_acl_handle_procpidmem(task))
55675 + rv = -EACCES;
55676 +
55677 + put_task_struct(task);
55678 +
55679 return rv;
55680 }
55681
55682 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55683 index 073aea6..0630370 100644
55684 --- a/fs/proc/inode.c
55685 +++ b/fs/proc/inode.c
55686 @@ -23,11 +23,17 @@
55687 #include <linux/slab.h>
55688 #include <linux/mount.h>
55689 #include <linux/magic.h>
55690 +#include <linux/grsecurity.h>
55691
55692 #include <asm/uaccess.h>
55693
55694 #include "internal.h"
55695
55696 +#ifdef CONFIG_PROC_SYSCTL
55697 +extern const struct inode_operations proc_sys_inode_operations;
55698 +extern const struct inode_operations proc_sys_dir_operations;
55699 +#endif
55700 +
55701 static void proc_evict_inode(struct inode *inode)
55702 {
55703 struct proc_dir_entry *de;
55704 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
55705 ns = PROC_I(inode)->ns.ns;
55706 if (ns_ops && ns)
55707 ns_ops->put(ns);
55708 +
55709 +#ifdef CONFIG_PROC_SYSCTL
55710 + if (inode->i_op == &proc_sys_inode_operations ||
55711 + inode->i_op == &proc_sys_dir_operations)
55712 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55713 +#endif
55714 +
55715 }
55716
55717 static struct kmem_cache * proc_inode_cachep;
55718 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55719 if (de->mode) {
55720 inode->i_mode = de->mode;
55721 inode->i_uid = de->uid;
55722 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55723 + inode->i_gid = grsec_proc_gid;
55724 +#else
55725 inode->i_gid = de->gid;
55726 +#endif
55727 }
55728 if (de->size)
55729 inode->i_size = de->size;
55730 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55731 index d600fb0..3b495fe 100644
55732 --- a/fs/proc/internal.h
55733 +++ b/fs/proc/internal.h
55734 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
55735 struct pid *, struct task_struct *);
55736 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
55737 struct pid *, struct task_struct *);
55738 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55739 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55740 +#endif
55741
55742 /*
55743 * base.c
55744 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55745 index 0a22194..a9fc8c1 100644
55746 --- a/fs/proc/kcore.c
55747 +++ b/fs/proc/kcore.c
55748 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55749 * the addresses in the elf_phdr on our list.
55750 */
55751 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55752 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55753 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55754 + if (tsz > buflen)
55755 tsz = buflen;
55756 -
55757 +
55758 while (buflen) {
55759 struct kcore_list *m;
55760
55761 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55762 kfree(elf_buf);
55763 } else {
55764 if (kern_addr_valid(start)) {
55765 - unsigned long n;
55766 + char *elf_buf;
55767 + mm_segment_t oldfs;
55768
55769 - n = copy_to_user(buffer, (char *)start, tsz);
55770 - /*
55771 - * We cannot distinguish between fault on source
55772 - * and fault on destination. When this happens
55773 - * we clear too and hope it will trigger the
55774 - * EFAULT again.
55775 - */
55776 - if (n) {
55777 - if (clear_user(buffer + tsz - n,
55778 - n))
55779 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55780 + if (!elf_buf)
55781 + return -ENOMEM;
55782 + oldfs = get_fs();
55783 + set_fs(KERNEL_DS);
55784 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55785 + set_fs(oldfs);
55786 + if (copy_to_user(buffer, elf_buf, tsz)) {
55787 + kfree(elf_buf);
55788 return -EFAULT;
55789 + }
55790 }
55791 + set_fs(oldfs);
55792 + kfree(elf_buf);
55793 } else {
55794 if (clear_user(buffer, tsz))
55795 return -EFAULT;
55796 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55797
55798 static int open_kcore(struct inode *inode, struct file *filp)
55799 {
55800 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55801 + return -EPERM;
55802 +#endif
55803 if (!capable(CAP_SYS_RAWIO))
55804 return -EPERM;
55805 if (kcore_need_update)
55806 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55807 index 5aa847a..f77c8d4 100644
55808 --- a/fs/proc/meminfo.c
55809 +++ b/fs/proc/meminfo.c
55810 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55811 vmi.used >> 10,
55812 vmi.largest_chunk >> 10
55813 #ifdef CONFIG_MEMORY_FAILURE
55814 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55815 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55816 #endif
55817 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55818 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55819 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55820 index ccfd99b..1b7e255 100644
55821 --- a/fs/proc/nommu.c
55822 +++ b/fs/proc/nommu.c
55823 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55824 if (len < 1)
55825 len = 1;
55826 seq_printf(m, "%*c", len, ' ');
55827 - seq_path(m, &file->f_path, "");
55828 + seq_path(m, &file->f_path, "\n\\");
55829 }
55830
55831 seq_putc(m, '\n');
55832 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55833 index 986e832..6e8e859 100644
55834 --- a/fs/proc/proc_net.c
55835 +++ b/fs/proc/proc_net.c
55836 @@ -23,6 +23,7 @@
55837 #include <linux/nsproxy.h>
55838 #include <net/net_namespace.h>
55839 #include <linux/seq_file.h>
55840 +#include <linux/grsecurity.h>
55841
55842 #include "internal.h"
55843
55844 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55845 struct task_struct *task;
55846 struct nsproxy *ns;
55847 struct net *net = NULL;
55848 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55849 + const struct cred *cred = current_cred();
55850 +#endif
55851 +
55852 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55853 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55854 + return net;
55855 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55856 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55857 + return net;
55858 +#endif
55859
55860 rcu_read_lock();
55861 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55862 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55863 index ac05f33..1e6dc7e 100644
55864 --- a/fs/proc/proc_sysctl.c
55865 +++ b/fs/proc/proc_sysctl.c
55866 @@ -13,11 +13,15 @@
55867 #include <linux/module.h>
55868 #include "internal.h"
55869
55870 +extern int gr_handle_chroot_sysctl(const int op);
55871 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55872 + const int op);
55873 +
55874 static const struct dentry_operations proc_sys_dentry_operations;
55875 static const struct file_operations proc_sys_file_operations;
55876 -static const struct inode_operations proc_sys_inode_operations;
55877 +const struct inode_operations proc_sys_inode_operations;
55878 static const struct file_operations proc_sys_dir_file_operations;
55879 -static const struct inode_operations proc_sys_dir_operations;
55880 +const struct inode_operations proc_sys_dir_operations;
55881
55882 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55883 {
55884 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55885
55886 err = NULL;
55887 d_set_d_op(dentry, &proc_sys_dentry_operations);
55888 +
55889 + gr_handle_proc_create(dentry, inode);
55890 +
55891 d_add(dentry, inode);
55892
55893 out:
55894 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55895 struct inode *inode = file_inode(filp);
55896 struct ctl_table_header *head = grab_header(inode);
55897 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55898 + int op = write ? MAY_WRITE : MAY_READ;
55899 ssize_t error;
55900 size_t res;
55901
55902 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55903 * and won't be until we finish.
55904 */
55905 error = -EPERM;
55906 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55907 + if (sysctl_perm(head, table, op))
55908 goto out;
55909
55910 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55911 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55912 if (!table->proc_handler)
55913 goto out;
55914
55915 +#ifdef CONFIG_GRKERNSEC
55916 + error = -EPERM;
55917 + if (gr_handle_chroot_sysctl(op))
55918 + goto out;
55919 + dget(filp->f_path.dentry);
55920 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55921 + dput(filp->f_path.dentry);
55922 + goto out;
55923 + }
55924 + dput(filp->f_path.dentry);
55925 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55926 + goto out;
55927 + if (write && !capable(CAP_SYS_ADMIN))
55928 + goto out;
55929 +#endif
55930 +
55931 /* careful: calling conventions are nasty here */
55932 res = count;
55933 error = table->proc_handler(table, write, buf, &res, ppos);
55934 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55935 return -ENOMEM;
55936 } else {
55937 d_set_d_op(child, &proc_sys_dentry_operations);
55938 +
55939 + gr_handle_proc_create(child, inode);
55940 +
55941 d_add(child, inode);
55942 }
55943 } else {
55944 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55945 if ((*pos)++ < file->f_pos)
55946 return 0;
55947
55948 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55949 + return 0;
55950 +
55951 if (unlikely(S_ISLNK(table->mode)))
55952 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55953 else
55954 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55955 if (IS_ERR(head))
55956 return PTR_ERR(head);
55957
55958 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55959 + return -ENOENT;
55960 +
55961 generic_fillattr(inode, stat);
55962 if (table)
55963 stat->mode = (stat->mode & S_IFMT) | table->mode;
55964 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55965 .llseek = generic_file_llseek,
55966 };
55967
55968 -static const struct inode_operations proc_sys_inode_operations = {
55969 +const struct inode_operations proc_sys_inode_operations = {
55970 .permission = proc_sys_permission,
55971 .setattr = proc_sys_setattr,
55972 .getattr = proc_sys_getattr,
55973 };
55974
55975 -static const struct inode_operations proc_sys_dir_operations = {
55976 +const struct inode_operations proc_sys_dir_operations = {
55977 .lookup = proc_sys_lookup,
55978 .permission = proc_sys_permission,
55979 .setattr = proc_sys_setattr,
55980 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55981 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55982 const char *name, int namelen)
55983 {
55984 - struct ctl_table *table;
55985 + ctl_table_no_const *table;
55986 struct ctl_dir *new;
55987 struct ctl_node *node;
55988 char *new_name;
55989 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55990 return NULL;
55991
55992 node = (struct ctl_node *)(new + 1);
55993 - table = (struct ctl_table *)(node + 1);
55994 + table = (ctl_table_no_const *)(node + 1);
55995 new_name = (char *)(table + 2);
55996 memcpy(new_name, name, namelen);
55997 new_name[namelen] = '\0';
55998 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55999 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
56000 struct ctl_table_root *link_root)
56001 {
56002 - struct ctl_table *link_table, *entry, *link;
56003 + ctl_table_no_const *link_table, *link;
56004 + struct ctl_table *entry;
56005 struct ctl_table_header *links;
56006 struct ctl_node *node;
56007 char *link_name;
56008 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56009 return NULL;
56010
56011 node = (struct ctl_node *)(links + 1);
56012 - link_table = (struct ctl_table *)(node + nr_entries);
56013 + link_table = (ctl_table_no_const *)(node + nr_entries);
56014 link_name = (char *)&link_table[nr_entries + 1];
56015
56016 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56017 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56018 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56019 struct ctl_table *table)
56020 {
56021 - struct ctl_table *ctl_table_arg = NULL;
56022 - struct ctl_table *entry, *files;
56023 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56024 + struct ctl_table *entry;
56025 int nr_files = 0;
56026 int nr_dirs = 0;
56027 int err = -ENOMEM;
56028 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56029 nr_files++;
56030 }
56031
56032 - files = table;
56033 /* If there are mixed files and directories we need a new table */
56034 if (nr_dirs && nr_files) {
56035 - struct ctl_table *new;
56036 + ctl_table_no_const *new;
56037 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56038 GFP_KERNEL);
56039 if (!files)
56040 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56041 /* Register everything except a directory full of subdirectories */
56042 if (nr_files || !nr_dirs) {
56043 struct ctl_table_header *header;
56044 - header = __register_sysctl_table(set, path, files);
56045 + header = __register_sysctl_table(set, path, files ? files : table);
56046 if (!header) {
56047 kfree(ctl_table_arg);
56048 goto out;
56049 diff --git a/fs/proc/root.c b/fs/proc/root.c
56050 index 41a6ea9..23eaa92 100644
56051 --- a/fs/proc/root.c
56052 +++ b/fs/proc/root.c
56053 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
56054 #ifdef CONFIG_PROC_DEVICETREE
56055 proc_device_tree_init();
56056 #endif
56057 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56058 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56059 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56060 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56061 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56062 +#endif
56063 +#else
56064 proc_mkdir("bus", NULL);
56065 +#endif
56066 proc_sys_init();
56067 }
56068
56069 diff --git a/fs/proc/self.c b/fs/proc/self.c
56070 index 6b6a993..807cccc 100644
56071 --- a/fs/proc/self.c
56072 +++ b/fs/proc/self.c
56073 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56074 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56075 void *cookie)
56076 {
56077 - char *s = nd_get_link(nd);
56078 + const char *s = nd_get_link(nd);
56079 if (!IS_ERR(s))
56080 kfree(s);
56081 }
56082 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56083 index 3e636d8..83e3b71 100644
56084 --- a/fs/proc/task_mmu.c
56085 +++ b/fs/proc/task_mmu.c
56086 @@ -11,12 +11,19 @@
56087 #include <linux/rmap.h>
56088 #include <linux/swap.h>
56089 #include <linux/swapops.h>
56090 +#include <linux/grsecurity.h>
56091
56092 #include <asm/elf.h>
56093 #include <asm/uaccess.h>
56094 #include <asm/tlbflush.h>
56095 #include "internal.h"
56096
56097 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56098 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56099 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56100 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56101 +#endif
56102 +
56103 void task_mem(struct seq_file *m, struct mm_struct *mm)
56104 {
56105 unsigned long data, text, lib, swap;
56106 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56107 "VmExe:\t%8lu kB\n"
56108 "VmLib:\t%8lu kB\n"
56109 "VmPTE:\t%8lu kB\n"
56110 - "VmSwap:\t%8lu kB\n",
56111 - hiwater_vm << (PAGE_SHIFT-10),
56112 + "VmSwap:\t%8lu kB\n"
56113 +
56114 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56115 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56116 +#endif
56117 +
56118 + ,hiwater_vm << (PAGE_SHIFT-10),
56119 total_vm << (PAGE_SHIFT-10),
56120 mm->locked_vm << (PAGE_SHIFT-10),
56121 mm->pinned_vm << (PAGE_SHIFT-10),
56122 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56123 data << (PAGE_SHIFT-10),
56124 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56125 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56126 - swap << (PAGE_SHIFT-10));
56127 + swap << (PAGE_SHIFT-10)
56128 +
56129 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56130 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56131 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56132 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56133 +#else
56134 + , mm->context.user_cs_base
56135 + , mm->context.user_cs_limit
56136 +#endif
56137 +#endif
56138 +
56139 + );
56140 }
56141
56142 unsigned long task_vsize(struct mm_struct *mm)
56143 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56144 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56145 }
56146
56147 - /* We don't show the stack guard page in /proc/maps */
56148 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56149 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56150 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56151 +#else
56152 start = vma->vm_start;
56153 - if (stack_guard_page_start(vma, start))
56154 - start += PAGE_SIZE;
56155 end = vma->vm_end;
56156 - if (stack_guard_page_end(vma, end))
56157 - end -= PAGE_SIZE;
56158 +#endif
56159
56160 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56161 start,
56162 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56163 flags & VM_WRITE ? 'w' : '-',
56164 flags & VM_EXEC ? 'x' : '-',
56165 flags & VM_MAYSHARE ? 's' : 'p',
56166 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56167 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56168 +#else
56169 pgoff,
56170 +#endif
56171 MAJOR(dev), MINOR(dev), ino, &len);
56172
56173 /*
56174 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56175 */
56176 if (file) {
56177 pad_len_spaces(m, len);
56178 - seq_path(m, &file->f_path, "\n");
56179 + seq_path(m, &file->f_path, "\n\\");
56180 goto done;
56181 }
56182
56183 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56184 * Thread stack in /proc/PID/task/TID/maps or
56185 * the main process stack.
56186 */
56187 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56188 - vma->vm_end >= mm->start_stack)) {
56189 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56190 + (vma->vm_start <= mm->start_stack &&
56191 + vma->vm_end >= mm->start_stack)) {
56192 name = "[stack]";
56193 } else {
56194 /* Thread stack in /proc/PID/maps */
56195 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56196 struct proc_maps_private *priv = m->private;
56197 struct task_struct *task = priv->task;
56198
56199 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56200 + if (current->exec_id != m->exec_id) {
56201 + gr_log_badprocpid("maps");
56202 + return 0;
56203 + }
56204 +#endif
56205 +
56206 show_map_vma(m, vma, is_pid);
56207
56208 if (m->count < m->size) /* vma is copied successfully */
56209 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56210 .private = &mss,
56211 };
56212
56213 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56214 + if (current->exec_id != m->exec_id) {
56215 + gr_log_badprocpid("smaps");
56216 + return 0;
56217 + }
56218 +#endif
56219 memset(&mss, 0, sizeof mss);
56220 - mss.vma = vma;
56221 - /* mmap_sem is held in m_start */
56222 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56223 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56224 -
56225 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56226 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56227 +#endif
56228 + mss.vma = vma;
56229 + /* mmap_sem is held in m_start */
56230 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56231 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56232 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56233 + }
56234 +#endif
56235 show_map_vma(m, vma, is_pid);
56236
56237 seq_printf(m,
56238 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56239 "KernelPageSize: %8lu kB\n"
56240 "MMUPageSize: %8lu kB\n"
56241 "Locked: %8lu kB\n",
56242 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56243 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56244 +#else
56245 (vma->vm_end - vma->vm_start) >> 10,
56246 +#endif
56247 mss.resident >> 10,
56248 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56249 mss.shared_clean >> 10,
56250 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56251 int n;
56252 char buffer[50];
56253
56254 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56255 + if (current->exec_id != m->exec_id) {
56256 + gr_log_badprocpid("numa_maps");
56257 + return 0;
56258 + }
56259 +#endif
56260 +
56261 if (!mm)
56262 return 0;
56263
56264 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56265 mpol_to_str(buffer, sizeof(buffer), pol);
56266 mpol_cond_put(pol);
56267
56268 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56269 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56270 +#else
56271 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56272 +#endif
56273
56274 if (file) {
56275 seq_printf(m, " file=");
56276 - seq_path(m, &file->f_path, "\n\t= ");
56277 + seq_path(m, &file->f_path, "\n\t\\= ");
56278 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56279 seq_printf(m, " heap");
56280 } else {
56281 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56282 index 56123a6..5a2f6ec 100644
56283 --- a/fs/proc/task_nommu.c
56284 +++ b/fs/proc/task_nommu.c
56285 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56286 else
56287 bytes += kobjsize(mm);
56288
56289 - if (current->fs && current->fs->users > 1)
56290 + if (current->fs && atomic_read(&current->fs->users) > 1)
56291 sbytes += kobjsize(current->fs);
56292 else
56293 bytes += kobjsize(current->fs);
56294 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56295
56296 if (file) {
56297 pad_len_spaces(m, len);
56298 - seq_path(m, &file->f_path, "");
56299 + seq_path(m, &file->f_path, "\n\\");
56300 } else if (mm) {
56301 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56302
56303 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56304 index 17f7e08..e4b1529 100644
56305 --- a/fs/proc/vmcore.c
56306 +++ b/fs/proc/vmcore.c
56307 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56308 nr_bytes = count;
56309
56310 /* If pfn is not ram, return zeros for sparse dump files */
56311 - if (pfn_is_ram(pfn) == 0)
56312 - memset(buf, 0, nr_bytes);
56313 - else {
56314 + if (pfn_is_ram(pfn) == 0) {
56315 + if (userbuf) {
56316 + if (clear_user((char __force_user *)buf, nr_bytes))
56317 + return -EFAULT;
56318 + } else
56319 + memset(buf, 0, nr_bytes);
56320 + } else {
56321 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56322 offset, userbuf);
56323 if (tmp < 0)
56324 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56325 if (tsz > nr_bytes)
56326 tsz = nr_bytes;
56327
56328 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56329 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56330 if (tmp < 0)
56331 return tmp;
56332 buflen -= tsz;
56333 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56334 index b00fcc9..e0c6381 100644
56335 --- a/fs/qnx6/qnx6.h
56336 +++ b/fs/qnx6/qnx6.h
56337 @@ -74,7 +74,7 @@ enum {
56338 BYTESEX_BE,
56339 };
56340
56341 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56342 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56343 {
56344 if (sbi->s_bytesex == BYTESEX_LE)
56345 return le64_to_cpu((__force __le64)n);
56346 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56347 return (__force __fs64)cpu_to_be64(n);
56348 }
56349
56350 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56351 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56352 {
56353 if (sbi->s_bytesex == BYTESEX_LE)
56354 return le32_to_cpu((__force __le32)n);
56355 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56356 index 16e8abb..2dcf914 100644
56357 --- a/fs/quota/netlink.c
56358 +++ b/fs/quota/netlink.c
56359 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56360 void quota_send_warning(struct kqid qid, dev_t dev,
56361 const char warntype)
56362 {
56363 - static atomic_t seq;
56364 + static atomic_unchecked_t seq;
56365 struct sk_buff *skb;
56366 void *msg_head;
56367 int ret;
56368 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56369 "VFS: Not enough memory to send quota warning.\n");
56370 return;
56371 }
56372 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56373 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56374 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56375 if (!msg_head) {
56376 printk(KERN_ERR
56377 diff --git a/fs/read_write.c b/fs/read_write.c
56378 index 2cefa41..c7e2fe0 100644
56379 --- a/fs/read_write.c
56380 +++ b/fs/read_write.c
56381 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56382
56383 old_fs = get_fs();
56384 set_fs(get_ds());
56385 - p = (__force const char __user *)buf;
56386 + p = (const char __force_user *)buf;
56387 if (count > MAX_RW_COUNT)
56388 count = MAX_RW_COUNT;
56389 if (file->f_op->write)
56390 diff --git a/fs/readdir.c b/fs/readdir.c
56391 index fee38e0..12fdf47 100644
56392 --- a/fs/readdir.c
56393 +++ b/fs/readdir.c
56394 @@ -17,6 +17,7 @@
56395 #include <linux/security.h>
56396 #include <linux/syscalls.h>
56397 #include <linux/unistd.h>
56398 +#include <linux/namei.h>
56399
56400 #include <asm/uaccess.h>
56401
56402 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56403
56404 struct readdir_callback {
56405 struct old_linux_dirent __user * dirent;
56406 + struct file * file;
56407 int result;
56408 };
56409
56410 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56411 buf->result = -EOVERFLOW;
56412 return -EOVERFLOW;
56413 }
56414 +
56415 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56416 + return 0;
56417 +
56418 buf->result++;
56419 dirent = buf->dirent;
56420 if (!access_ok(VERIFY_WRITE, dirent,
56421 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56422
56423 buf.result = 0;
56424 buf.dirent = dirent;
56425 + buf.file = f.file;
56426
56427 error = vfs_readdir(f.file, fillonedir, &buf);
56428 if (buf.result)
56429 @@ -139,6 +146,7 @@ struct linux_dirent {
56430 struct getdents_callback {
56431 struct linux_dirent __user * current_dir;
56432 struct linux_dirent __user * previous;
56433 + struct file * file;
56434 int count;
56435 int error;
56436 };
56437 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56438 buf->error = -EOVERFLOW;
56439 return -EOVERFLOW;
56440 }
56441 +
56442 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56443 + return 0;
56444 +
56445 dirent = buf->previous;
56446 if (dirent) {
56447 if (__put_user(offset, &dirent->d_off))
56448 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56449 buf.previous = NULL;
56450 buf.count = count;
56451 buf.error = 0;
56452 + buf.file = f.file;
56453
56454 error = vfs_readdir(f.file, filldir, &buf);
56455 if (error >= 0)
56456 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56457 struct getdents_callback64 {
56458 struct linux_dirent64 __user * current_dir;
56459 struct linux_dirent64 __user * previous;
56460 + struct file *file;
56461 int count;
56462 int error;
56463 };
56464 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56465 buf->error = -EINVAL; /* only used if we fail.. */
56466 if (reclen > buf->count)
56467 return -EINVAL;
56468 +
56469 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56470 + return 0;
56471 +
56472 dirent = buf->previous;
56473 if (dirent) {
56474 if (__put_user(offset, &dirent->d_off))
56475 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56476
56477 buf.current_dir = dirent;
56478 buf.previous = NULL;
56479 + buf.file = f.file;
56480 buf.count = count;
56481 buf.error = 0;
56482
56483 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56484 error = buf.error;
56485 lastdirent = buf.previous;
56486 if (lastdirent) {
56487 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56488 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56489 if (__put_user(d_off, &lastdirent->d_off))
56490 error = -EFAULT;
56491 else
56492 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56493 index 2b7882b..1c5ef48 100644
56494 --- a/fs/reiserfs/do_balan.c
56495 +++ b/fs/reiserfs/do_balan.c
56496 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56497 return;
56498 }
56499
56500 - atomic_inc(&(fs_generation(tb->tb_sb)));
56501 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56502 do_balance_starts(tb);
56503
56504 /* balance leaf returns 0 except if combining L R and S into
56505 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56506 index 33532f7..4846ade 100644
56507 --- a/fs/reiserfs/procfs.c
56508 +++ b/fs/reiserfs/procfs.c
56509 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56510 "SMALL_TAILS " : "NO_TAILS ",
56511 replay_only(sb) ? "REPLAY_ONLY " : "",
56512 convert_reiserfs(sb) ? "CONV " : "",
56513 - atomic_read(&r->s_generation_counter),
56514 + atomic_read_unchecked(&r->s_generation_counter),
56515 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56516 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56517 SF(s_good_search_by_key_reada), SF(s_bmaps),
56518 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56519 index 157e474..65a6114 100644
56520 --- a/fs/reiserfs/reiserfs.h
56521 +++ b/fs/reiserfs/reiserfs.h
56522 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56523 /* Comment? -Hans */
56524 wait_queue_head_t s_wait;
56525 /* To be obsoleted soon by per buffer seals.. -Hans */
56526 - atomic_t s_generation_counter; // increased by one every time the
56527 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56528 // tree gets re-balanced
56529 unsigned long s_properties; /* File system properties. Currently holds
56530 on-disk FS format */
56531 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56532 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56533
56534 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56535 -#define get_generation(s) atomic_read (&fs_generation(s))
56536 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56537 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56538 #define __fs_changed(gen,s) (gen != get_generation (s))
56539 #define fs_changed(gen,s) \
56540 diff --git a/fs/select.c b/fs/select.c
56541 index 8c1c96c..a0f9b6d 100644
56542 --- a/fs/select.c
56543 +++ b/fs/select.c
56544 @@ -20,6 +20,7 @@
56545 #include <linux/export.h>
56546 #include <linux/slab.h>
56547 #include <linux/poll.h>
56548 +#include <linux/security.h>
56549 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56550 #include <linux/file.h>
56551 #include <linux/fdtable.h>
56552 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56553 struct poll_list *walk = head;
56554 unsigned long todo = nfds;
56555
56556 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56557 if (nfds > rlimit(RLIMIT_NOFILE))
56558 return -EINVAL;
56559
56560 diff --git a/fs/seq_file.c b/fs/seq_file.c
56561 index 774c1eb..b67582a 100644
56562 --- a/fs/seq_file.c
56563 +++ b/fs/seq_file.c
56564 @@ -10,6 +10,7 @@
56565 #include <linux/seq_file.h>
56566 #include <linux/slab.h>
56567 #include <linux/cred.h>
56568 +#include <linux/sched.h>
56569
56570 #include <asm/uaccess.h>
56571 #include <asm/page.h>
56572 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56573 #ifdef CONFIG_USER_NS
56574 p->user_ns = file->f_cred->user_ns;
56575 #endif
56576 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56577 + p->exec_id = current->exec_id;
56578 +#endif
56579
56580 /*
56581 * Wrappers around seq_open(e.g. swaps_open) need to be
56582 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56583 return 0;
56584 }
56585 if (!m->buf) {
56586 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56587 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56588 if (!m->buf)
56589 return -ENOMEM;
56590 }
56591 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56592 Eoverflow:
56593 m->op->stop(m, p);
56594 kfree(m->buf);
56595 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56596 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56597 return !m->buf ? -ENOMEM : -EAGAIN;
56598 }
56599
56600 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56601
56602 /* grab buffer if we didn't have one */
56603 if (!m->buf) {
56604 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56605 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56606 if (!m->buf)
56607 goto Enomem;
56608 }
56609 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56610 goto Fill;
56611 m->op->stop(m, p);
56612 kfree(m->buf);
56613 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56614 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56615 if (!m->buf)
56616 goto Enomem;
56617 m->count = 0;
56618 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56619 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56620 void *data)
56621 {
56622 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56623 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56624 int res = -ENOMEM;
56625
56626 if (op) {
56627 diff --git a/fs/splice.c b/fs/splice.c
56628 index d37431d..81c3044 100644
56629 --- a/fs/splice.c
56630 +++ b/fs/splice.c
56631 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56632 pipe_lock(pipe);
56633
56634 for (;;) {
56635 - if (!pipe->readers) {
56636 + if (!atomic_read(&pipe->readers)) {
56637 send_sig(SIGPIPE, current, 0);
56638 if (!ret)
56639 ret = -EPIPE;
56640 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56641 page_nr++;
56642 ret += buf->len;
56643
56644 - if (pipe->files)
56645 + if (atomic_read(&pipe->files))
56646 do_wakeup = 1;
56647
56648 if (!--spd->nr_pages)
56649 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56650 do_wakeup = 0;
56651 }
56652
56653 - pipe->waiting_writers++;
56654 + atomic_inc(&pipe->waiting_writers);
56655 pipe_wait(pipe);
56656 - pipe->waiting_writers--;
56657 + atomic_dec(&pipe->waiting_writers);
56658 }
56659
56660 pipe_unlock(pipe);
56661 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56662 old_fs = get_fs();
56663 set_fs(get_ds());
56664 /* The cast to a user pointer is valid due to the set_fs() */
56665 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56666 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56667 set_fs(old_fs);
56668
56669 return res;
56670 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56671 old_fs = get_fs();
56672 set_fs(get_ds());
56673 /* The cast to a user pointer is valid due to the set_fs() */
56674 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56675 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56676 set_fs(old_fs);
56677
56678 return res;
56679 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56680 goto err;
56681
56682 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56683 - vec[i].iov_base = (void __user *) page_address(page);
56684 + vec[i].iov_base = (void __force_user *) page_address(page);
56685 vec[i].iov_len = this_len;
56686 spd.pages[i] = page;
56687 spd.nr_pages++;
56688 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
56689 ops->release(pipe, buf);
56690 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
56691 pipe->nrbufs--;
56692 - if (pipe->files)
56693 + if (atomic_read(&pipe->files))
56694 sd->need_wakeup = true;
56695 }
56696
56697 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56698 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56699 {
56700 while (!pipe->nrbufs) {
56701 - if (!pipe->writers)
56702 + if (!atomic_read(&pipe->writers))
56703 return 0;
56704
56705 - if (!pipe->waiting_writers && sd->num_spliced)
56706 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56707 return 0;
56708
56709 if (sd->flags & SPLICE_F_NONBLOCK)
56710 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56711 * out of the pipe right after the splice_to_pipe(). So set
56712 * PIPE_READERS appropriately.
56713 */
56714 - pipe->readers = 1;
56715 + atomic_set(&pipe->readers, 1);
56716
56717 current->splice_pipe = pipe;
56718 }
56719 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56720 ret = -ERESTARTSYS;
56721 break;
56722 }
56723 - if (!pipe->writers)
56724 + if (!atomic_read(&pipe->writers))
56725 break;
56726 - if (!pipe->waiting_writers) {
56727 + if (!atomic_read(&pipe->waiting_writers)) {
56728 if (flags & SPLICE_F_NONBLOCK) {
56729 ret = -EAGAIN;
56730 break;
56731 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56732 pipe_lock(pipe);
56733
56734 while (pipe->nrbufs >= pipe->buffers) {
56735 - if (!pipe->readers) {
56736 + if (!atomic_read(&pipe->readers)) {
56737 send_sig(SIGPIPE, current, 0);
56738 ret = -EPIPE;
56739 break;
56740 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56741 ret = -ERESTARTSYS;
56742 break;
56743 }
56744 - pipe->waiting_writers++;
56745 + atomic_inc(&pipe->waiting_writers);
56746 pipe_wait(pipe);
56747 - pipe->waiting_writers--;
56748 + atomic_dec(&pipe->waiting_writers);
56749 }
56750
56751 pipe_unlock(pipe);
56752 @@ -1854,14 +1854,14 @@ retry:
56753 pipe_double_lock(ipipe, opipe);
56754
56755 do {
56756 - if (!opipe->readers) {
56757 + if (!atomic_read(&opipe->readers)) {
56758 send_sig(SIGPIPE, current, 0);
56759 if (!ret)
56760 ret = -EPIPE;
56761 break;
56762 }
56763
56764 - if (!ipipe->nrbufs && !ipipe->writers)
56765 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56766 break;
56767
56768 /*
56769 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56770 pipe_double_lock(ipipe, opipe);
56771
56772 do {
56773 - if (!opipe->readers) {
56774 + if (!atomic_read(&opipe->readers)) {
56775 send_sig(SIGPIPE, current, 0);
56776 if (!ret)
56777 ret = -EPIPE;
56778 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56779 * return EAGAIN if we have the potential of some data in the
56780 * future, otherwise just return 0
56781 */
56782 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56783 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56784 ret = -EAGAIN;
56785
56786 pipe_unlock(ipipe);
56787 diff --git a/fs/stat.c b/fs/stat.c
56788 index 04ce1ac..a13dd1e 100644
56789 --- a/fs/stat.c
56790 +++ b/fs/stat.c
56791 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56792 stat->gid = inode->i_gid;
56793 stat->rdev = inode->i_rdev;
56794 stat->size = i_size_read(inode);
56795 - stat->atime = inode->i_atime;
56796 - stat->mtime = inode->i_mtime;
56797 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56798 + stat->atime = inode->i_ctime;
56799 + stat->mtime = inode->i_ctime;
56800 + } else {
56801 + stat->atime = inode->i_atime;
56802 + stat->mtime = inode->i_mtime;
56803 + }
56804 stat->ctime = inode->i_ctime;
56805 stat->blksize = (1 << inode->i_blkbits);
56806 stat->blocks = inode->i_blocks;
56807 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56808 if (retval)
56809 return retval;
56810
56811 - if (inode->i_op->getattr)
56812 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56813 + if (inode->i_op->getattr) {
56814 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56815 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56816 + stat->atime = stat->ctime;
56817 + stat->mtime = stat->ctime;
56818 + }
56819 + return retval;
56820 + }
56821
56822 generic_fillattr(inode, stat);
56823 return 0;
56824 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56825 index 15c68f9..36a8b3e 100644
56826 --- a/fs/sysfs/bin.c
56827 +++ b/fs/sysfs/bin.c
56828 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56829 return ret;
56830 }
56831
56832 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56833 - void *buf, int len, int write)
56834 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56835 + void *buf, size_t len, int write)
56836 {
56837 struct file *file = vma->vm_file;
56838 struct bin_buffer *bb = file->private_data;
56839 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56840 - int ret;
56841 + ssize_t ret;
56842
56843 if (!bb->vm_ops)
56844 return -EINVAL;
56845 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56846 index e8e0e71..3ca455a 100644
56847 --- a/fs/sysfs/dir.c
56848 +++ b/fs/sysfs/dir.c
56849 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56850 *
56851 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56852 */
56853 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56854 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56855 {
56856 unsigned long hash = init_name_hash();
56857 unsigned int len = strlen(name);
56858 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56859 struct sysfs_dirent *sd;
56860 int rc;
56861
56862 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56863 + const char *parent_name = parent_sd->s_name;
56864 +
56865 + mode = S_IFDIR | S_IRWXU;
56866 +
56867 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56868 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56869 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56870 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56871 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56872 +#endif
56873 +
56874 /* allocate */
56875 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56876 if (!sd)
56877 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56878 index 602f56d..6853db8 100644
56879 --- a/fs/sysfs/file.c
56880 +++ b/fs/sysfs/file.c
56881 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56882
56883 struct sysfs_open_dirent {
56884 atomic_t refcnt;
56885 - atomic_t event;
56886 + atomic_unchecked_t event;
56887 wait_queue_head_t poll;
56888 struct list_head buffers; /* goes through sysfs_buffer.list */
56889 };
56890 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56891 if (!sysfs_get_active(attr_sd))
56892 return -ENODEV;
56893
56894 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56895 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56896 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56897
56898 sysfs_put_active(attr_sd);
56899 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56900 return -ENOMEM;
56901
56902 atomic_set(&new_od->refcnt, 0);
56903 - atomic_set(&new_od->event, 1);
56904 + atomic_set_unchecked(&new_od->event, 1);
56905 init_waitqueue_head(&new_od->poll);
56906 INIT_LIST_HEAD(&new_od->buffers);
56907 goto retry;
56908 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56909
56910 sysfs_put_active(attr_sd);
56911
56912 - if (buffer->event != atomic_read(&od->event))
56913 + if (buffer->event != atomic_read_unchecked(&od->event))
56914 goto trigger;
56915
56916 return DEFAULT_POLLMASK;
56917 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56918
56919 od = sd->s_attr.open;
56920 if (od) {
56921 - atomic_inc(&od->event);
56922 + atomic_inc_unchecked(&od->event);
56923 wake_up_interruptible(&od->poll);
56924 }
56925
56926 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56927 index 8c940df..25b733e 100644
56928 --- a/fs/sysfs/symlink.c
56929 +++ b/fs/sysfs/symlink.c
56930 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56931
56932 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56933 {
56934 - char *page = nd_get_link(nd);
56935 + const char *page = nd_get_link(nd);
56936 if (!IS_ERR(page))
56937 free_page((unsigned long)page);
56938 }
56939 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56940 index 69d4889..a810bd4 100644
56941 --- a/fs/sysv/sysv.h
56942 +++ b/fs/sysv/sysv.h
56943 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56944 #endif
56945 }
56946
56947 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56948 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56949 {
56950 if (sbi->s_bytesex == BYTESEX_PDP)
56951 return PDP_swab((__force __u32)n);
56952 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56953 index e18b988..f1d4ad0f 100644
56954 --- a/fs/ubifs/io.c
56955 +++ b/fs/ubifs/io.c
56956 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56957 return err;
56958 }
56959
56960 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56961 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56962 {
56963 int err;
56964
56965 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56966 index c175b4d..8f36a16 100644
56967 --- a/fs/udf/misc.c
56968 +++ b/fs/udf/misc.c
56969 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56970
56971 u8 udf_tag_checksum(const struct tag *t)
56972 {
56973 - u8 *data = (u8 *)t;
56974 + const u8 *data = (const u8 *)t;
56975 u8 checksum = 0;
56976 int i;
56977 for (i = 0; i < sizeof(struct tag); ++i)
56978 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56979 index 8d974c4..b82f6ec 100644
56980 --- a/fs/ufs/swab.h
56981 +++ b/fs/ufs/swab.h
56982 @@ -22,7 +22,7 @@ enum {
56983 BYTESEX_BE
56984 };
56985
56986 -static inline u64
56987 +static inline u64 __intentional_overflow(-1)
56988 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56989 {
56990 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56991 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56992 return (__force __fs64)cpu_to_be64(n);
56993 }
56994
56995 -static inline u32
56996 +static inline u32 __intentional_overflow(-1)
56997 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56998 {
56999 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57000 diff --git a/fs/utimes.c b/fs/utimes.c
57001 index f4fb7ec..3fe03c0 100644
57002 --- a/fs/utimes.c
57003 +++ b/fs/utimes.c
57004 @@ -1,6 +1,7 @@
57005 #include <linux/compiler.h>
57006 #include <linux/file.h>
57007 #include <linux/fs.h>
57008 +#include <linux/security.h>
57009 #include <linux/linkage.h>
57010 #include <linux/mount.h>
57011 #include <linux/namei.h>
57012 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
57013 goto mnt_drop_write_and_out;
57014 }
57015 }
57016 +
57017 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
57018 + error = -EACCES;
57019 + goto mnt_drop_write_and_out;
57020 + }
57021 +
57022 mutex_lock(&inode->i_mutex);
57023 error = notify_change(path->dentry, &newattrs);
57024 mutex_unlock(&inode->i_mutex);
57025 diff --git a/fs/xattr.c b/fs/xattr.c
57026 index 3377dff..4d074d9 100644
57027 --- a/fs/xattr.c
57028 +++ b/fs/xattr.c
57029 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
57030 return rc;
57031 }
57032
57033 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
57034 +ssize_t
57035 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
57036 +{
57037 + struct inode *inode = dentry->d_inode;
57038 + ssize_t error;
57039 +
57040 + error = inode_permission(inode, MAY_EXEC);
57041 + if (error)
57042 + return error;
57043 +
57044 + if (inode->i_op->getxattr)
57045 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
57046 + else
57047 + error = -EOPNOTSUPP;
57048 +
57049 + return error;
57050 +}
57051 +EXPORT_SYMBOL(pax_getxattr);
57052 +#endif
57053 +
57054 ssize_t
57055 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
57056 {
57057 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57058 * Extended attribute SET operations
57059 */
57060 static long
57061 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57062 +setxattr(struct path *path, const char __user *name, const void __user *value,
57063 size_t size, int flags)
57064 {
57065 int error;
57066 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57067 posix_acl_fix_xattr_from_user(kvalue, size);
57068 }
57069
57070 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57071 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57072 + error = -EACCES;
57073 + goto out;
57074 + }
57075 +
57076 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57077 out:
57078 if (vvalue)
57079 vfree(vvalue);
57080 @@ -377,7 +403,7 @@ retry:
57081 return error;
57082 error = mnt_want_write(path.mnt);
57083 if (!error) {
57084 - error = setxattr(path.dentry, name, value, size, flags);
57085 + error = setxattr(&path, name, value, size, flags);
57086 mnt_drop_write(path.mnt);
57087 }
57088 path_put(&path);
57089 @@ -401,7 +427,7 @@ retry:
57090 return error;
57091 error = mnt_want_write(path.mnt);
57092 if (!error) {
57093 - error = setxattr(path.dentry, name, value, size, flags);
57094 + error = setxattr(&path, name, value, size, flags);
57095 mnt_drop_write(path.mnt);
57096 }
57097 path_put(&path);
57098 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57099 const void __user *,value, size_t, size, int, flags)
57100 {
57101 struct fd f = fdget(fd);
57102 - struct dentry *dentry;
57103 int error = -EBADF;
57104
57105 if (!f.file)
57106 return error;
57107 - dentry = f.file->f_path.dentry;
57108 - audit_inode(NULL, dentry, 0);
57109 + audit_inode(NULL, f.file->f_path.dentry, 0);
57110 error = mnt_want_write_file(f.file);
57111 if (!error) {
57112 - error = setxattr(dentry, name, value, size, flags);
57113 + error = setxattr(&f.file->f_path, name, value, size, flags);
57114 mnt_drop_write_file(f.file);
57115 }
57116 fdput(f);
57117 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57118 index 9fbea87..6b19972 100644
57119 --- a/fs/xattr_acl.c
57120 +++ b/fs/xattr_acl.c
57121 @@ -76,8 +76,8 @@ struct posix_acl *
57122 posix_acl_from_xattr(struct user_namespace *user_ns,
57123 const void *value, size_t size)
57124 {
57125 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57126 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57127 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57128 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57129 int count;
57130 struct posix_acl *acl;
57131 struct posix_acl_entry *acl_e;
57132 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57133 index 8904284..ee0e14b 100644
57134 --- a/fs/xfs/xfs_bmap.c
57135 +++ b/fs/xfs/xfs_bmap.c
57136 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
57137
57138 #else
57139 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
57140 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57141 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
57142 #endif /* DEBUG */
57143
57144 /*
57145 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57146 index 6157424..ac98f6d 100644
57147 --- a/fs/xfs/xfs_dir2_sf.c
57148 +++ b/fs/xfs/xfs_dir2_sf.c
57149 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57150 }
57151
57152 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57153 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57154 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57155 + char name[sfep->namelen];
57156 + memcpy(name, sfep->name, sfep->namelen);
57157 + if (filldir(dirent, name, sfep->namelen,
57158 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57159 + *offset = off & 0x7fffffff;
57160 + return 0;
57161 + }
57162 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57163 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57164 *offset = off & 0x7fffffff;
57165 return 0;
57166 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57167 index 5e99968..45bd327 100644
57168 --- a/fs/xfs/xfs_ioctl.c
57169 +++ b/fs/xfs/xfs_ioctl.c
57170 @@ -127,7 +127,7 @@ xfs_find_handle(
57171 }
57172
57173 error = -EFAULT;
57174 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57175 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57176 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57177 goto out_put;
57178
57179 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57180 index ca9ecaa..60100c7 100644
57181 --- a/fs/xfs/xfs_iops.c
57182 +++ b/fs/xfs/xfs_iops.c
57183 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57184 struct nameidata *nd,
57185 void *p)
57186 {
57187 - char *s = nd_get_link(nd);
57188 + const char *s = nd_get_link(nd);
57189
57190 if (!IS_ERR(s))
57191 kfree(s);
57192 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57193 new file mode 100644
57194 index 0000000..c9c4ac3
57195 --- /dev/null
57196 +++ b/grsecurity/Kconfig
57197 @@ -0,0 +1,1054 @@
57198 +#
57199 +# grecurity configuration
57200 +#
57201 +menu "Memory Protections"
57202 +depends on GRKERNSEC
57203 +
57204 +config GRKERNSEC_KMEM
57205 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57206 + default y if GRKERNSEC_CONFIG_AUTO
57207 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57208 + help
57209 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57210 + be written to or read from to modify or leak the contents of the running
57211 + kernel. /dev/port will also not be allowed to be opened and support
57212 + for /dev/cpu/*/msr will be removed. If you have module
57213 + support disabled, enabling this will close up five ways that are
57214 + currently used to insert malicious code into the running kernel.
57215 +
57216 + Even with all these features enabled, we still highly recommend that
57217 + you use the RBAC system, as it is still possible for an attacker to
57218 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57219 +
57220 + If you are not using XFree86, you may be able to stop this additional
57221 + case by enabling the 'Disable privileged I/O' option. Though nothing
57222 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57223 + but only to video memory, which is the only writing we allow in this
57224 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57225 + not be allowed to mprotect it with PROT_WRITE later.
57226 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57227 + from working.
57228 +
57229 + It is highly recommended that you say Y here if you meet all the
57230 + conditions above.
57231 +
57232 +config GRKERNSEC_VM86
57233 + bool "Restrict VM86 mode"
57234 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57235 + depends on X86_32
57236 +
57237 + help
57238 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57239 + make use of a special execution mode on 32bit x86 processors called
57240 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57241 + video cards and will still work with this option enabled. The purpose
57242 + of the option is to prevent exploitation of emulation errors in
57243 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57244 + Nearly all users should be able to enable this option.
57245 +
57246 +config GRKERNSEC_IO
57247 + bool "Disable privileged I/O"
57248 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57249 + depends on X86
57250 + select RTC_CLASS
57251 + select RTC_INTF_DEV
57252 + select RTC_DRV_CMOS
57253 +
57254 + help
57255 + If you say Y here, all ioperm and iopl calls will return an error.
57256 + Ioperm and iopl can be used to modify the running kernel.
57257 + Unfortunately, some programs need this access to operate properly,
57258 + the most notable of which are XFree86 and hwclock. hwclock can be
57259 + remedied by having RTC support in the kernel, so real-time
57260 + clock support is enabled if this option is enabled, to ensure
57261 + that hwclock operates correctly. XFree86 still will not
57262 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57263 + IF YOU USE XFree86. If you use XFree86 and you still want to
57264 + protect your kernel against modification, use the RBAC system.
57265 +
57266 +config GRKERNSEC_JIT_HARDEN
57267 + bool "Harden BPF JIT against spray attacks"
57268 + default y if GRKERNSEC_CONFIG_AUTO
57269 + depends on BPF_JIT
57270 + help
57271 + If you say Y here, the native code generated by the kernel's Berkeley
57272 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57273 + attacks that attempt to fit attacker-beneficial instructions in
57274 + 32bit immediate fields of JIT-generated native instructions. The
57275 + attacker will generally aim to cause an unintended instruction sequence
57276 + of JIT-generated native code to execute by jumping into the middle of
57277 + a generated instruction. This feature effectively randomizes the 32bit
57278 + immediate constants present in the generated code to thwart such attacks.
57279 +
57280 + If you're using KERNEXEC, it's recommended that you enable this option
57281 + to supplement the hardening of the kernel.
57282 +
57283 +config GRKERNSEC_PERF_HARDEN
57284 + bool "Disable unprivileged PERF_EVENTS usage by default"
57285 + default y if GRKERNSEC_CONFIG_AUTO
57286 + depends on PERF_EVENTS
57287 + help
57288 + If you say Y here, the range of acceptable values for the
57289 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57290 + default to a new value: 3. When the sysctl is set to this value, no
57291 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57292 +
57293 + Though PERF_EVENTS can be used legitimately for performance monitoring
57294 + and low-level application profiling, it is forced on regardless of
57295 + configuration, has been at fault for several vulnerabilities, and
57296 + creates new opportunities for side channels and other information leaks.
57297 +
57298 + This feature puts PERF_EVENTS into a secure default state and permits
57299 + the administrator to change out of it temporarily if unprivileged
57300 + application profiling is needed.
57301 +
57302 +config GRKERNSEC_RAND_THREADSTACK
57303 + bool "Insert random gaps between thread stacks"
57304 + default y if GRKERNSEC_CONFIG_AUTO
57305 + depends on PAX_RANDMMAP && !PPC
57306 + help
57307 + If you say Y here, a random-sized gap will be enforced between allocated
57308 + thread stacks. Glibc's NPTL and other threading libraries that
57309 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57310 + The implementation currently provides 8 bits of entropy for the gap.
57311 +
57312 + Many distributions do not compile threaded remote services with the
57313 + -fstack-check argument to GCC, causing the variable-sized stack-based
57314 + allocator, alloca(), to not probe the stack on allocation. This
57315 + permits an unbounded alloca() to skip over any guard page and potentially
57316 + modify another thread's stack reliably. An enforced random gap
57317 + reduces the reliability of such an attack and increases the chance
57318 + that such a read/write to another thread's stack instead lands in
57319 + an unmapped area, causing a crash and triggering grsecurity's
57320 + anti-bruteforcing logic.
57321 +
57322 +config GRKERNSEC_PROC_MEMMAP
57323 + bool "Harden ASLR against information leaks and entropy reduction"
57324 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57325 + depends on PAX_NOEXEC || PAX_ASLR
57326 + help
57327 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57328 + give no information about the addresses of its mappings if
57329 + PaX features that rely on random addresses are enabled on the task.
57330 + In addition to sanitizing this information and disabling other
57331 + dangerous sources of information, this option causes reads of sensitive
57332 + /proc/<pid> entries where the file descriptor was opened in a different
57333 + task than the one performing the read. Such attempts are logged.
57334 + This option also limits argv/env strings for suid/sgid binaries
57335 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57336 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57337 + binaries to prevent alternative mmap layouts from being abused.
57338 +
57339 + If you use PaX it is essential that you say Y here as it closes up
57340 + several holes that make full ASLR useless locally.
57341 +
57342 +config GRKERNSEC_BRUTE
57343 + bool "Deter exploit bruteforcing"
57344 + default y if GRKERNSEC_CONFIG_AUTO
57345 + help
57346 + If you say Y here, attempts to bruteforce exploits against forking
57347 + daemons such as apache or sshd, as well as against suid/sgid binaries
57348 + will be deterred. When a child of a forking daemon is killed by PaX
57349 + or crashes due to an illegal instruction or other suspicious signal,
57350 + the parent process will be delayed 30 seconds upon every subsequent
57351 + fork until the administrator is able to assess the situation and
57352 + restart the daemon.
57353 + In the suid/sgid case, the attempt is logged, the user has all their
57354 + existing instances of the suid/sgid binary terminated and will
57355 + be unable to execute any suid/sgid binaries for 15 minutes.
57356 +
57357 + It is recommended that you also enable signal logging in the auditing
57358 + section so that logs are generated when a process triggers a suspicious
57359 + signal.
57360 + If the sysctl option is enabled, a sysctl option with name
57361 + "deter_bruteforce" is created.
57362 +
57363 +
57364 +config GRKERNSEC_MODHARDEN
57365 + bool "Harden module auto-loading"
57366 + default y if GRKERNSEC_CONFIG_AUTO
57367 + depends on MODULES
57368 + help
57369 + If you say Y here, module auto-loading in response to use of some
57370 + feature implemented by an unloaded module will be restricted to
57371 + root users. Enabling this option helps defend against attacks
57372 + by unprivileged users who abuse the auto-loading behavior to
57373 + cause a vulnerable module to load that is then exploited.
57374 +
57375 + If this option prevents a legitimate use of auto-loading for a
57376 + non-root user, the administrator can execute modprobe manually
57377 + with the exact name of the module mentioned in the alert log.
57378 + Alternatively, the administrator can add the module to the list
57379 + of modules loaded at boot by modifying init scripts.
57380 +
57381 + Modification of init scripts will most likely be needed on
57382 + Ubuntu servers with encrypted home directory support enabled,
57383 + as the first non-root user logging in will cause the ecb(aes),
57384 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57385 +
57386 +config GRKERNSEC_HIDESYM
57387 + bool "Hide kernel symbols"
57388 + default y if GRKERNSEC_CONFIG_AUTO
57389 + select PAX_USERCOPY_SLABS
57390 + help
57391 + If you say Y here, getting information on loaded modules, and
57392 + displaying all kernel symbols through a syscall will be restricted
57393 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57394 + /proc/kallsyms will be restricted to the root user. The RBAC
57395 + system can hide that entry even from root.
57396 +
57397 + This option also prevents leaking of kernel addresses through
57398 + several /proc entries.
57399 +
57400 + Note that this option is only effective provided the following
57401 + conditions are met:
57402 + 1) The kernel using grsecurity is not precompiled by some distribution
57403 + 2) You have also enabled GRKERNSEC_DMESG
57404 + 3) You are using the RBAC system and hiding other files such as your
57405 + kernel image and System.map. Alternatively, enabling this option
57406 + causes the permissions on /boot, /lib/modules, and the kernel
57407 + source directory to change at compile time to prevent
57408 + reading by non-root users.
57409 + If the above conditions are met, this option will aid in providing a
57410 + useful protection against local kernel exploitation of overflows
57411 + and arbitrary read/write vulnerabilities.
57412 +
57413 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57414 + in addition to this feature.
57415 +
57416 +config GRKERNSEC_KERN_LOCKOUT
57417 + bool "Active kernel exploit response"
57418 + default y if GRKERNSEC_CONFIG_AUTO
57419 + depends on X86 || ARM || PPC || SPARC
57420 + help
57421 + If you say Y here, when a PaX alert is triggered due to suspicious
57422 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57423 + or an OOPS occurs due to bad memory accesses, instead of just
57424 + terminating the offending process (and potentially allowing
57425 + a subsequent exploit from the same user), we will take one of two
57426 + actions:
57427 + If the user was root, we will panic the system
57428 + If the user was non-root, we will log the attempt, terminate
57429 + all processes owned by the user, then prevent them from creating
57430 + any new processes until the system is restarted
57431 + This deters repeated kernel exploitation/bruteforcing attempts
57432 + and is useful for later forensics.
57433 +
57434 +endmenu
57435 +menu "Role Based Access Control Options"
57436 +depends on GRKERNSEC
57437 +
57438 +config GRKERNSEC_RBAC_DEBUG
57439 + bool
57440 +
57441 +config GRKERNSEC_NO_RBAC
57442 + bool "Disable RBAC system"
57443 + help
57444 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57445 + preventing the RBAC system from being enabled. You should only say Y
57446 + here if you have no intention of using the RBAC system, so as to prevent
57447 + an attacker with root access from misusing the RBAC system to hide files
57448 + and processes when loadable module support and /dev/[k]mem have been
57449 + locked down.
57450 +
57451 +config GRKERNSEC_ACL_HIDEKERN
57452 + bool "Hide kernel processes"
57453 + help
57454 + If you say Y here, all kernel threads will be hidden to all
57455 + processes but those whose subject has the "view hidden processes"
57456 + flag.
57457 +
57458 +config GRKERNSEC_ACL_MAXTRIES
57459 + int "Maximum tries before password lockout"
57460 + default 3
57461 + help
57462 + This option enforces the maximum number of times a user can attempt
57463 + to authorize themselves with the grsecurity RBAC system before being
57464 + denied the ability to attempt authorization again for a specified time.
57465 + The lower the number, the harder it will be to brute-force a password.
57466 +
57467 +config GRKERNSEC_ACL_TIMEOUT
57468 + int "Time to wait after max password tries, in seconds"
57469 + default 30
57470 + help
57471 + This option specifies the time the user must wait after attempting to
57472 + authorize to the RBAC system with the maximum number of invalid
57473 + passwords. The higher the number, the harder it will be to brute-force
57474 + a password.
57475 +
57476 +endmenu
57477 +menu "Filesystem Protections"
57478 +depends on GRKERNSEC
57479 +
57480 +config GRKERNSEC_PROC
57481 + bool "Proc restrictions"
57482 + default y if GRKERNSEC_CONFIG_AUTO
57483 + help
57484 + If you say Y here, the permissions of the /proc filesystem
57485 + will be altered to enhance system security and privacy. You MUST
57486 + choose either a user only restriction or a user and group restriction.
57487 + Depending upon the option you choose, you can either restrict users to
57488 + see only the processes they themselves run, or choose a group that can
57489 + view all processes and files normally restricted to root if you choose
57490 + the "restrict to user only" option. NOTE: If you're running identd or
57491 + ntpd as a non-root user, you will have to run it as the group you
57492 + specify here.
57493 +
57494 +config GRKERNSEC_PROC_USER
57495 + bool "Restrict /proc to user only"
57496 + depends on GRKERNSEC_PROC
57497 + help
57498 + If you say Y here, non-root users will only be able to view their own
57499 + processes, and restricts them from viewing network-related information,
57500 + and viewing kernel symbol and module information.
57501 +
57502 +config GRKERNSEC_PROC_USERGROUP
57503 + bool "Allow special group"
57504 + default y if GRKERNSEC_CONFIG_AUTO
57505 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57506 + help
57507 + If you say Y here, you will be able to select a group that will be
57508 + able to view all processes and network-related information. If you've
57509 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57510 + remain hidden. This option is useful if you want to run identd as
57511 + a non-root user. The group you select may also be chosen at boot time
57512 + via "grsec_proc_gid=" on the kernel commandline.
57513 +
57514 +config GRKERNSEC_PROC_GID
57515 + int "GID for special group"
57516 + depends on GRKERNSEC_PROC_USERGROUP
57517 + default 1001
57518 +
57519 +config GRKERNSEC_PROC_ADD
57520 + bool "Additional restrictions"
57521 + default y if GRKERNSEC_CONFIG_AUTO
57522 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57523 + help
57524 + If you say Y here, additional restrictions will be placed on
57525 + /proc that keep normal users from viewing device information and
57526 + slabinfo information that could be useful for exploits.
57527 +
57528 +config GRKERNSEC_LINK
57529 + bool "Linking restrictions"
57530 + default y if GRKERNSEC_CONFIG_AUTO
57531 + help
57532 + If you say Y here, /tmp race exploits will be prevented, since users
57533 + will no longer be able to follow symlinks owned by other users in
57534 + world-writable +t directories (e.g. /tmp), unless the owner of the
57535 + symlink is the owner of the directory. users will also not be
57536 + able to hardlink to files they do not own. If the sysctl option is
57537 + enabled, a sysctl option with name "linking_restrictions" is created.
57538 +
57539 +config GRKERNSEC_SYMLINKOWN
57540 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57541 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57542 + help
57543 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57544 + that prevents it from being used as a security feature. As Apache
57545 + verifies the symlink by performing a stat() against the target of
57546 + the symlink before it is followed, an attacker can setup a symlink
57547 + to point to a same-owned file, then replace the symlink with one
57548 + that targets another user's file just after Apache "validates" the
57549 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57550 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57551 + will be in place for the group you specify. If the sysctl option
57552 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57553 + created.
57554 +
57555 +config GRKERNSEC_SYMLINKOWN_GID
57556 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57557 + depends on GRKERNSEC_SYMLINKOWN
57558 + default 1006
57559 + help
57560 + Setting this GID determines what group kernel-enforced
57561 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57562 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57563 +
57564 +config GRKERNSEC_FIFO
57565 + bool "FIFO restrictions"
57566 + default y if GRKERNSEC_CONFIG_AUTO
57567 + help
57568 + If you say Y here, users will not be able to write to FIFOs they don't
57569 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57570 + the FIFO is the same owner of the directory it's held in. If the sysctl
57571 + option is enabled, a sysctl option with name "fifo_restrictions" is
57572 + created.
57573 +
57574 +config GRKERNSEC_SYSFS_RESTRICT
57575 + bool "Sysfs/debugfs restriction"
57576 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57577 + depends on SYSFS
57578 + help
57579 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57580 + any filesystem normally mounted under it (e.g. debugfs) will be
57581 + mostly accessible only by root. These filesystems generally provide access
57582 + to hardware and debug information that isn't appropriate for unprivileged
57583 + users of the system. Sysfs and debugfs have also become a large source
57584 + of new vulnerabilities, ranging from infoleaks to local compromise.
57585 + There has been very little oversight with an eye toward security involved
57586 + in adding new exporters of information to these filesystems, so their
57587 + use is discouraged.
57588 + For reasons of compatibility, a few directories have been whitelisted
57589 + for access by non-root users:
57590 + /sys/fs/selinux
57591 + /sys/fs/fuse
57592 + /sys/devices/system/cpu
57593 +
57594 +config GRKERNSEC_ROFS
57595 + bool "Runtime read-only mount protection"
57596 + help
57597 + If you say Y here, a sysctl option with name "romount_protect" will
57598 + be created. By setting this option to 1 at runtime, filesystems
57599 + will be protected in the following ways:
57600 + * No new writable mounts will be allowed
57601 + * Existing read-only mounts won't be able to be remounted read/write
57602 + * Write operations will be denied on all block devices
57603 + This option acts independently of grsec_lock: once it is set to 1,
57604 + it cannot be turned off. Therefore, please be mindful of the resulting
57605 + behavior if this option is enabled in an init script on a read-only
57606 + filesystem. This feature is mainly intended for secure embedded systems.
57607 +
57608 +config GRKERNSEC_DEVICE_SIDECHANNEL
57609 + bool "Eliminate stat/notify-based device sidechannels"
57610 + default y if GRKERNSEC_CONFIG_AUTO
57611 + help
57612 + If you say Y here, timing analyses on block or character
57613 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57614 + will be thwarted for unprivileged users. If a process without
57615 + CAP_MKNOD stats such a device, the last access and last modify times
57616 + will match the device's create time. No access or modify events
57617 + will be triggered through inotify/dnotify/fanotify for such devices.
57618 + This feature will prevent attacks that may at a minimum
57619 + allow an attacker to determine the administrator's password length.
57620 +
57621 +config GRKERNSEC_CHROOT
57622 + bool "Chroot jail restrictions"
57623 + default y if GRKERNSEC_CONFIG_AUTO
57624 + help
57625 + If you say Y here, you will be able to choose several options that will
57626 + make breaking out of a chrooted jail much more difficult. If you
57627 + encounter no software incompatibilities with the following options, it
57628 + is recommended that you enable each one.
57629 +
57630 +config GRKERNSEC_CHROOT_MOUNT
57631 + bool "Deny mounts"
57632 + default y if GRKERNSEC_CONFIG_AUTO
57633 + depends on GRKERNSEC_CHROOT
57634 + help
57635 + If you say Y here, processes inside a chroot will not be able to
57636 + mount or remount filesystems. If the sysctl option is enabled, a
57637 + sysctl option with name "chroot_deny_mount" is created.
57638 +
57639 +config GRKERNSEC_CHROOT_DOUBLE
57640 + bool "Deny double-chroots"
57641 + default y if GRKERNSEC_CONFIG_AUTO
57642 + depends on GRKERNSEC_CHROOT
57643 + help
57644 + If you say Y here, processes inside a chroot will not be able to chroot
57645 + again outside the chroot. This is a widely used method of breaking
57646 + out of a chroot jail and should not be allowed. If the sysctl
57647 + option is enabled, a sysctl option with name
57648 + "chroot_deny_chroot" is created.
57649 +
57650 +config GRKERNSEC_CHROOT_PIVOT
57651 + bool "Deny pivot_root in chroot"
57652 + default y if GRKERNSEC_CONFIG_AUTO
57653 + depends on GRKERNSEC_CHROOT
57654 + help
57655 + If you say Y here, processes inside a chroot will not be able to use
57656 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57657 + works similar to chroot in that it changes the root filesystem. This
57658 + function could be misused in a chrooted process to attempt to break out
57659 + of the chroot, and therefore should not be allowed. If the sysctl
57660 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57661 + created.
57662 +
57663 +config GRKERNSEC_CHROOT_CHDIR
57664 + bool "Enforce chdir(\"/\") on all chroots"
57665 + default y if GRKERNSEC_CONFIG_AUTO
57666 + depends on GRKERNSEC_CHROOT
57667 + help
57668 + If you say Y here, the current working directory of all newly-chrooted
57669 + applications will be set to the the root directory of the chroot.
57670 + The man page on chroot(2) states:
57671 + Note that this call does not change the current working
57672 + directory, so that `.' can be outside the tree rooted at
57673 + `/'. In particular, the super-user can escape from a
57674 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57675 +
57676 + It is recommended that you say Y here, since it's not known to break
57677 + any software. If the sysctl option is enabled, a sysctl option with
57678 + name "chroot_enforce_chdir" is created.
57679 +
57680 +config GRKERNSEC_CHROOT_CHMOD
57681 + bool "Deny (f)chmod +s"
57682 + default y if GRKERNSEC_CONFIG_AUTO
57683 + depends on GRKERNSEC_CHROOT
57684 + help
57685 + If you say Y here, processes inside a chroot will not be able to chmod
57686 + or fchmod files to make them have suid or sgid bits. This protects
57687 + against another published method of breaking a chroot. If the sysctl
57688 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57689 + created.
57690 +
57691 +config GRKERNSEC_CHROOT_FCHDIR
57692 + bool "Deny fchdir out of chroot"
57693 + default y if GRKERNSEC_CONFIG_AUTO
57694 + depends on GRKERNSEC_CHROOT
57695 + help
57696 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57697 + to a file descriptor of the chrooting process that points to a directory
57698 + outside the filesystem will be stopped. If the sysctl option
57699 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57700 +
57701 +config GRKERNSEC_CHROOT_MKNOD
57702 + bool "Deny mknod"
57703 + default y if GRKERNSEC_CONFIG_AUTO
57704 + depends on GRKERNSEC_CHROOT
57705 + help
57706 + If you say Y here, processes inside a chroot will not be allowed to
57707 + mknod. The problem with using mknod inside a chroot is that it
57708 + would allow an attacker to create a device entry that is the same
57709 + as one on the physical root of your system, which could range from
57710 + anything from the console device to a device for your harddrive (which
57711 + they could then use to wipe the drive or steal data). It is recommended
57712 + that you say Y here, unless you run into software incompatibilities.
57713 + If the sysctl option is enabled, a sysctl option with name
57714 + "chroot_deny_mknod" is created.
57715 +
57716 +config GRKERNSEC_CHROOT_SHMAT
57717 + bool "Deny shmat() out of chroot"
57718 + default y if GRKERNSEC_CONFIG_AUTO
57719 + depends on GRKERNSEC_CHROOT
57720 + help
57721 + If you say Y here, processes inside a chroot will not be able to attach
57722 + to shared memory segments that were created outside of the chroot jail.
57723 + It is recommended that you say Y here. If the sysctl option is enabled,
57724 + a sysctl option with name "chroot_deny_shmat" is created.
57725 +
57726 +config GRKERNSEC_CHROOT_UNIX
57727 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57728 + default y if GRKERNSEC_CONFIG_AUTO
57729 + depends on GRKERNSEC_CHROOT
57730 + help
57731 + If you say Y here, processes inside a chroot will not be able to
57732 + connect to abstract (meaning not belonging to a filesystem) Unix
57733 + domain sockets that were bound outside of a chroot. It is recommended
57734 + that you say Y here. If the sysctl option is enabled, a sysctl option
57735 + with name "chroot_deny_unix" is created.
57736 +
57737 +config GRKERNSEC_CHROOT_FINDTASK
57738 + bool "Protect outside processes"
57739 + default y if GRKERNSEC_CONFIG_AUTO
57740 + depends on GRKERNSEC_CHROOT
57741 + help
57742 + If you say Y here, processes inside a chroot will not be able to
57743 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57744 + getsid, or view any process outside of the chroot. If the sysctl
57745 + option is enabled, a sysctl option with name "chroot_findtask" is
57746 + created.
57747 +
57748 +config GRKERNSEC_CHROOT_NICE
57749 + bool "Restrict priority changes"
57750 + default y if GRKERNSEC_CONFIG_AUTO
57751 + depends on GRKERNSEC_CHROOT
57752 + help
57753 + If you say Y here, processes inside a chroot will not be able to raise
57754 + the priority of processes in the chroot, or alter the priority of
57755 + processes outside the chroot. This provides more security than simply
57756 + removing CAP_SYS_NICE from the process' capability set. If the
57757 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57758 + is created.
57759 +
57760 +config GRKERNSEC_CHROOT_SYSCTL
57761 + bool "Deny sysctl writes"
57762 + default y if GRKERNSEC_CONFIG_AUTO
57763 + depends on GRKERNSEC_CHROOT
57764 + help
57765 + If you say Y here, an attacker in a chroot will not be able to
57766 + write to sysctl entries, either by sysctl(2) or through a /proc
57767 + interface. It is strongly recommended that you say Y here. If the
57768 + sysctl option is enabled, a sysctl option with name
57769 + "chroot_deny_sysctl" is created.
57770 +
57771 +config GRKERNSEC_CHROOT_CAPS
57772 + bool "Capability restrictions"
57773 + default y if GRKERNSEC_CONFIG_AUTO
57774 + depends on GRKERNSEC_CHROOT
57775 + help
57776 + If you say Y here, the capabilities on all processes within a
57777 + chroot jail will be lowered to stop module insertion, raw i/o,
57778 + system and net admin tasks, rebooting the system, modifying immutable
57779 + files, modifying IPC owned by another, and changing the system time.
57780 + This is left an option because it can break some apps. Disable this
57781 + if your chrooted apps are having problems performing those kinds of
57782 + tasks. If the sysctl option is enabled, a sysctl option with
57783 + name "chroot_caps" is created.
57784 +
57785 +config GRKERNSEC_CHROOT_INITRD
57786 + bool "Exempt initrd tasks from restrictions"
57787 + default y if GRKERNSEC_CONFIG_AUTO
57788 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57789 + help
57790 + If you say Y here, tasks started prior to init will be exempted from
57791 + grsecurity's chroot restrictions. This option is mainly meant to
57792 + resolve Plymouth's performing privileged operations unnecessarily
57793 + in a chroot.
57794 +
57795 +endmenu
57796 +menu "Kernel Auditing"
57797 +depends on GRKERNSEC
57798 +
57799 +config GRKERNSEC_AUDIT_GROUP
57800 + bool "Single group for auditing"
57801 + help
57802 + If you say Y here, the exec and chdir logging features will only operate
57803 + on a group you specify. This option is recommended if you only want to
57804 + watch certain users instead of having a large amount of logs from the
57805 + entire system. If the sysctl option is enabled, a sysctl option with
57806 + name "audit_group" is created.
57807 +
57808 +config GRKERNSEC_AUDIT_GID
57809 + int "GID for auditing"
57810 + depends on GRKERNSEC_AUDIT_GROUP
57811 + default 1007
57812 +
57813 +config GRKERNSEC_EXECLOG
57814 + bool "Exec logging"
57815 + help
57816 + If you say Y here, all execve() calls will be logged (since the
57817 + other exec*() calls are frontends to execve(), all execution
57818 + will be logged). Useful for shell-servers that like to keep track
57819 + of their users. If the sysctl option is enabled, a sysctl option with
57820 + name "exec_logging" is created.
57821 + WARNING: This option when enabled will produce a LOT of logs, especially
57822 + on an active system.
57823 +
57824 +config GRKERNSEC_RESLOG
57825 + bool "Resource logging"
57826 + default y if GRKERNSEC_CONFIG_AUTO
57827 + help
57828 + If you say Y here, all attempts to overstep resource limits will
57829 + be logged with the resource name, the requested size, and the current
57830 + limit. It is highly recommended that you say Y here. If the sysctl
57831 + option is enabled, a sysctl option with name "resource_logging" is
57832 + created. If the RBAC system is enabled, the sysctl value is ignored.
57833 +
57834 +config GRKERNSEC_CHROOT_EXECLOG
57835 + bool "Log execs within chroot"
57836 + help
57837 + If you say Y here, all executions inside a chroot jail will be logged
57838 + to syslog. This can cause a large amount of logs if certain
57839 + applications (eg. djb's daemontools) are installed on the system, and
57840 + is therefore left as an option. If the sysctl option is enabled, a
57841 + sysctl option with name "chroot_execlog" is created.
57842 +
57843 +config GRKERNSEC_AUDIT_PTRACE
57844 + bool "Ptrace logging"
57845 + help
57846 + If you say Y here, all attempts to attach to a process via ptrace
57847 + will be logged. If the sysctl option is enabled, a sysctl option
57848 + with name "audit_ptrace" is created.
57849 +
57850 +config GRKERNSEC_AUDIT_CHDIR
57851 + bool "Chdir logging"
57852 + help
57853 + If you say Y here, all chdir() calls will be logged. If the sysctl
57854 + option is enabled, a sysctl option with name "audit_chdir" is created.
57855 +
57856 +config GRKERNSEC_AUDIT_MOUNT
57857 + bool "(Un)Mount logging"
57858 + help
57859 + If you say Y here, all mounts and unmounts will be logged. If the
57860 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57861 + created.
57862 +
57863 +config GRKERNSEC_SIGNAL
57864 + bool "Signal logging"
57865 + default y if GRKERNSEC_CONFIG_AUTO
57866 + help
57867 + If you say Y here, certain important signals will be logged, such as
57868 + SIGSEGV, which will as a result inform you of when a error in a program
57869 + occurred, which in some cases could mean a possible exploit attempt.
57870 + If the sysctl option is enabled, a sysctl option with name
57871 + "signal_logging" is created.
57872 +
57873 +config GRKERNSEC_FORKFAIL
57874 + bool "Fork failure logging"
57875 + help
57876 + If you say Y here, all failed fork() attempts will be logged.
57877 + This could suggest a fork bomb, or someone attempting to overstep
57878 + their process limit. If the sysctl option is enabled, a sysctl option
57879 + with name "forkfail_logging" is created.
57880 +
57881 +config GRKERNSEC_TIME
57882 + bool "Time change logging"
57883 + default y if GRKERNSEC_CONFIG_AUTO
57884 + help
57885 + If you say Y here, any changes of the system clock will be logged.
57886 + If the sysctl option is enabled, a sysctl option with name
57887 + "timechange_logging" is created.
57888 +
57889 +config GRKERNSEC_PROC_IPADDR
57890 + bool "/proc/<pid>/ipaddr support"
57891 + default y if GRKERNSEC_CONFIG_AUTO
57892 + help
57893 + If you say Y here, a new entry will be added to each /proc/<pid>
57894 + directory that contains the IP address of the person using the task.
57895 + The IP is carried across local TCP and AF_UNIX stream sockets.
57896 + This information can be useful for IDS/IPSes to perform remote response
57897 + to a local attack. The entry is readable by only the owner of the
57898 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57899 + the RBAC system), and thus does not create privacy concerns.
57900 +
57901 +config GRKERNSEC_RWXMAP_LOG
57902 + bool 'Denied RWX mmap/mprotect logging'
57903 + default y if GRKERNSEC_CONFIG_AUTO
57904 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57905 + help
57906 + If you say Y here, calls to mmap() and mprotect() with explicit
57907 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57908 + denied by the PAX_MPROTECT feature. If the sysctl option is
57909 + enabled, a sysctl option with name "rwxmap_logging" is created.
57910 +
57911 +config GRKERNSEC_AUDIT_TEXTREL
57912 + bool 'ELF text relocations logging (READ HELP)'
57913 + depends on PAX_MPROTECT
57914 + help
57915 + If you say Y here, text relocations will be logged with the filename
57916 + of the offending library or binary. The purpose of the feature is
57917 + to help Linux distribution developers get rid of libraries and
57918 + binaries that need text relocations which hinder the future progress
57919 + of PaX. Only Linux distribution developers should say Y here, and
57920 + never on a production machine, as this option creates an information
57921 + leak that could aid an attacker in defeating the randomization of
57922 + a single memory region. If the sysctl option is enabled, a sysctl
57923 + option with name "audit_textrel" is created.
57924 +
57925 +endmenu
57926 +
57927 +menu "Executable Protections"
57928 +depends on GRKERNSEC
57929 +
57930 +config GRKERNSEC_DMESG
57931 + bool "Dmesg(8) restriction"
57932 + default y if GRKERNSEC_CONFIG_AUTO
57933 + help
57934 + If you say Y here, non-root users will not be able to use dmesg(8)
57935 + to view the contents of the kernel's circular log buffer.
57936 + The kernel's log buffer often contains kernel addresses and other
57937 + identifying information useful to an attacker in fingerprinting a
57938 + system for a targeted exploit.
57939 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57940 + created.
57941 +
57942 +config GRKERNSEC_HARDEN_PTRACE
57943 + bool "Deter ptrace-based process snooping"
57944 + default y if GRKERNSEC_CONFIG_AUTO
57945 + help
57946 + If you say Y here, TTY sniffers and other malicious monitoring
57947 + programs implemented through ptrace will be defeated. If you
57948 + have been using the RBAC system, this option has already been
57949 + enabled for several years for all users, with the ability to make
57950 + fine-grained exceptions.
57951 +
57952 + This option only affects the ability of non-root users to ptrace
57953 + processes that are not a descendent of the ptracing process.
57954 + This means that strace ./binary and gdb ./binary will still work,
57955 + but attaching to arbitrary processes will not. If the sysctl
57956 + option is enabled, a sysctl option with name "harden_ptrace" is
57957 + created.
57958 +
57959 +config GRKERNSEC_PTRACE_READEXEC
57960 + bool "Require read access to ptrace sensitive binaries"
57961 + default y if GRKERNSEC_CONFIG_AUTO
57962 + help
57963 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57964 + binaries. This option is useful in environments that
57965 + remove the read bits (e.g. file mode 4711) from suid binaries to
57966 + prevent infoleaking of their contents. This option adds
57967 + consistency to the use of that file mode, as the binary could normally
57968 + be read out when run without privileges while ptracing.
57969 +
57970 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57971 + is created.
57972 +
57973 +config GRKERNSEC_SETXID
57974 + bool "Enforce consistent multithreaded privileges"
57975 + default y if GRKERNSEC_CONFIG_AUTO
57976 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57977 + help
57978 + If you say Y here, a change from a root uid to a non-root uid
57979 + in a multithreaded application will cause the resulting uids,
57980 + gids, supplementary groups, and capabilities in that thread
57981 + to be propagated to the other threads of the process. In most
57982 + cases this is unnecessary, as glibc will emulate this behavior
57983 + on behalf of the application. Other libcs do not act in the
57984 + same way, allowing the other threads of the process to continue
57985 + running with root privileges. If the sysctl option is enabled,
57986 + a sysctl option with name "consistent_setxid" is created.
57987 +
57988 +config GRKERNSEC_TPE
57989 + bool "Trusted Path Execution (TPE)"
57990 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57991 + help
57992 + If you say Y here, you will be able to choose a gid to add to the
57993 + supplementary groups of users you want to mark as "untrusted."
57994 + These users will not be able to execute any files that are not in
57995 + root-owned directories writable only by root. If the sysctl option
57996 + is enabled, a sysctl option with name "tpe" is created.
57997 +
57998 +config GRKERNSEC_TPE_ALL
57999 + bool "Partially restrict all non-root users"
58000 + depends on GRKERNSEC_TPE
58001 + help
58002 + If you say Y here, all non-root users will be covered under
58003 + a weaker TPE restriction. This is separate from, and in addition to,
58004 + the main TPE options that you have selected elsewhere. Thus, if a
58005 + "trusted" GID is chosen, this restriction applies to even that GID.
58006 + Under this restriction, all non-root users will only be allowed to
58007 + execute files in directories they own that are not group or
58008 + world-writable, or in directories owned by root and writable only by
58009 + root. If the sysctl option is enabled, a sysctl option with name
58010 + "tpe_restrict_all" is created.
58011 +
58012 +config GRKERNSEC_TPE_INVERT
58013 + bool "Invert GID option"
58014 + depends on GRKERNSEC_TPE
58015 + help
58016 + If you say Y here, the group you specify in the TPE configuration will
58017 + decide what group TPE restrictions will be *disabled* for. This
58018 + option is useful if you want TPE restrictions to be applied to most
58019 + users on the system. If the sysctl option is enabled, a sysctl option
58020 + with name "tpe_invert" is created. Unlike other sysctl options, this
58021 + entry will default to on for backward-compatibility.
58022 +
58023 +config GRKERNSEC_TPE_GID
58024 + int
58025 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
58026 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
58027 +
58028 +config GRKERNSEC_TPE_UNTRUSTED_GID
58029 + int "GID for TPE-untrusted users"
58030 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
58031 + default 1005
58032 + help
58033 + Setting this GID determines what group TPE restrictions will be
58034 + *enabled* for. If the sysctl option is enabled, a sysctl option
58035 + with name "tpe_gid" is created.
58036 +
58037 +config GRKERNSEC_TPE_TRUSTED_GID
58038 + int "GID for TPE-trusted users"
58039 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
58040 + default 1005
58041 + help
58042 + Setting this GID determines what group TPE restrictions will be
58043 + *disabled* for. If the sysctl option is enabled, a sysctl option
58044 + with name "tpe_gid" is created.
58045 +
58046 +endmenu
58047 +menu "Network Protections"
58048 +depends on GRKERNSEC
58049 +
58050 +config GRKERNSEC_RANDNET
58051 + bool "Larger entropy pools"
58052 + default y if GRKERNSEC_CONFIG_AUTO
58053 + help
58054 + If you say Y here, the entropy pools used for many features of Linux
58055 + and grsecurity will be doubled in size. Since several grsecurity
58056 + features use additional randomness, it is recommended that you say Y
58057 + here. Saying Y here has a similar effect as modifying
58058 + /proc/sys/kernel/random/poolsize.
58059 +
58060 +config GRKERNSEC_BLACKHOLE
58061 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
58062 + default y if GRKERNSEC_CONFIG_AUTO
58063 + depends on NET
58064 + help
58065 + If you say Y here, neither TCP resets nor ICMP
58066 + destination-unreachable packets will be sent in response to packets
58067 + sent to ports for which no associated listening process exists.
58068 + This feature supports both IPV4 and IPV6 and exempts the
58069 + loopback interface from blackholing. Enabling this feature
58070 + makes a host more resilient to DoS attacks and reduces network
58071 + visibility against scanners.
58072 +
58073 + The blackhole feature as-implemented is equivalent to the FreeBSD
58074 + blackhole feature, as it prevents RST responses to all packets, not
58075 + just SYNs. Under most application behavior this causes no
58076 + problems, but applications (like haproxy) may not close certain
58077 + connections in a way that cleanly terminates them on the remote
58078 + end, leaving the remote host in LAST_ACK state. Because of this
58079 + side-effect and to prevent intentional LAST_ACK DoSes, this
58080 + feature also adds automatic mitigation against such attacks.
58081 + The mitigation drastically reduces the amount of time a socket
58082 + can spend in LAST_ACK state. If you're using haproxy and not
58083 + all servers it connects to have this option enabled, consider
58084 + disabling this feature on the haproxy host.
58085 +
58086 + If the sysctl option is enabled, two sysctl options with names
58087 + "ip_blackhole" and "lastack_retries" will be created.
58088 + While "ip_blackhole" takes the standard zero/non-zero on/off
58089 + toggle, "lastack_retries" uses the same kinds of values as
58090 + "tcp_retries1" and "tcp_retries2". The default value of 4
58091 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58092 + state.
58093 +
58094 +config GRKERNSEC_NO_SIMULT_CONNECT
58095 + bool "Disable TCP Simultaneous Connect"
58096 + default y if GRKERNSEC_CONFIG_AUTO
58097 + depends on NET
58098 + help
58099 + If you say Y here, a feature by Willy Tarreau will be enabled that
58100 + removes a weakness in Linux's strict implementation of TCP that
58101 + allows two clients to connect to each other without either entering
58102 + a listening state. The weakness allows an attacker to easily prevent
58103 + a client from connecting to a known server provided the source port
58104 + for the connection is guessed correctly.
58105 +
58106 + As the weakness could be used to prevent an antivirus or IPS from
58107 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58108 + it should be eliminated by enabling this option. Though Linux is
58109 + one of few operating systems supporting simultaneous connect, it
58110 + has no legitimate use in practice and is rarely supported by firewalls.
58111 +
58112 +config GRKERNSEC_SOCKET
58113 + bool "Socket restrictions"
58114 + depends on NET
58115 + help
58116 + If you say Y here, you will be able to choose from several options.
58117 + If you assign a GID on your system and add it to the supplementary
58118 + groups of users you want to restrict socket access to, this patch
58119 + will perform up to three things, based on the option(s) you choose.
58120 +
58121 +config GRKERNSEC_SOCKET_ALL
58122 + bool "Deny any sockets to group"
58123 + depends on GRKERNSEC_SOCKET
58124 + help
58125 + If you say Y here, you will be able to choose a GID of whose users will
58126 + be unable to connect to other hosts from your machine or run server
58127 + applications from your machine. If the sysctl option is enabled, a
58128 + sysctl option with name "socket_all" is created.
58129 +
58130 +config GRKERNSEC_SOCKET_ALL_GID
58131 + int "GID to deny all sockets for"
58132 + depends on GRKERNSEC_SOCKET_ALL
58133 + default 1004
58134 + help
58135 + Here you can choose the GID to disable socket access for. Remember to
58136 + add the users you want socket access disabled for to the GID
58137 + specified here. If the sysctl option is enabled, a sysctl option
58138 + with name "socket_all_gid" is created.
58139 +
58140 +config GRKERNSEC_SOCKET_CLIENT
58141 + bool "Deny client sockets to group"
58142 + depends on GRKERNSEC_SOCKET
58143 + help
58144 + If you say Y here, you will be able to choose a GID of whose users will
58145 + be unable to connect to other hosts from your machine, but will be
58146 + able to run servers. If this option is enabled, all users in the group
58147 + you specify will have to use passive mode when initiating ftp transfers
58148 + from the shell on your machine. If the sysctl option is enabled, a
58149 + sysctl option with name "socket_client" is created.
58150 +
58151 +config GRKERNSEC_SOCKET_CLIENT_GID
58152 + int "GID to deny client sockets for"
58153 + depends on GRKERNSEC_SOCKET_CLIENT
58154 + default 1003
58155 + help
58156 + Here you can choose the GID to disable client socket access for.
58157 + Remember to add the users you want client socket access disabled for to
58158 + the GID specified here. If the sysctl option is enabled, a sysctl
58159 + option with name "socket_client_gid" is created.
58160 +
58161 +config GRKERNSEC_SOCKET_SERVER
58162 + bool "Deny server sockets to group"
58163 + depends on GRKERNSEC_SOCKET
58164 + help
58165 + If you say Y here, you will be able to choose a GID of whose users will
58166 + be unable to run server applications from your machine. If the sysctl
58167 + option is enabled, a sysctl option with name "socket_server" is created.
58168 +
58169 +config GRKERNSEC_SOCKET_SERVER_GID
58170 + int "GID to deny server sockets for"
58171 + depends on GRKERNSEC_SOCKET_SERVER
58172 + default 1002
58173 + help
58174 + Here you can choose the GID to disable server socket access for.
58175 + Remember to add the users you want server socket access disabled for to
58176 + the GID specified here. If the sysctl option is enabled, a sysctl
58177 + option with name "socket_server_gid" is created.
58178 +
58179 +endmenu
58180 +menu "Sysctl Support"
58181 +depends on GRKERNSEC && SYSCTL
58182 +
58183 +config GRKERNSEC_SYSCTL
58184 + bool "Sysctl support"
58185 + default y if GRKERNSEC_CONFIG_AUTO
58186 + help
58187 + If you say Y here, you will be able to change the options that
58188 + grsecurity runs with at bootup, without having to recompile your
58189 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58190 + to enable (1) or disable (0) various features. All the sysctl entries
58191 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58192 + All features enabled in the kernel configuration are disabled at boot
58193 + if you do not say Y to the "Turn on features by default" option.
58194 + All options should be set at startup, and the grsec_lock entry should
58195 + be set to a non-zero value after all the options are set.
58196 + *THIS IS EXTREMELY IMPORTANT*
58197 +
58198 +config GRKERNSEC_SYSCTL_DISTRO
58199 + bool "Extra sysctl support for distro makers (READ HELP)"
58200 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58201 + help
58202 + If you say Y here, additional sysctl options will be created
58203 + for features that affect processes running as root. Therefore,
58204 + it is critical when using this option that the grsec_lock entry be
58205 + enabled after boot. Only distros with prebuilt kernel packages
58206 + with this option enabled that can ensure grsec_lock is enabled
58207 + after boot should use this option.
58208 + *Failure to set grsec_lock after boot makes all grsec features
58209 + this option covers useless*
58210 +
58211 + Currently this option creates the following sysctl entries:
58212 + "Disable Privileged I/O": "disable_priv_io"
58213 +
58214 +config GRKERNSEC_SYSCTL_ON
58215 + bool "Turn on features by default"
58216 + default y if GRKERNSEC_CONFIG_AUTO
58217 + depends on GRKERNSEC_SYSCTL
58218 + help
58219 + If you say Y here, instead of having all features enabled in the
58220 + kernel configuration disabled at boot time, the features will be
58221 + enabled at boot time. It is recommended you say Y here unless
58222 + there is some reason you would want all sysctl-tunable features to
58223 + be disabled by default. As mentioned elsewhere, it is important
58224 + to enable the grsec_lock entry once you have finished modifying
58225 + the sysctl entries.
58226 +
58227 +endmenu
58228 +menu "Logging Options"
58229 +depends on GRKERNSEC
58230 +
58231 +config GRKERNSEC_FLOODTIME
58232 + int "Seconds in between log messages (minimum)"
58233 + default 10
58234 + help
58235 + This option allows you to enforce the number of seconds between
58236 + grsecurity log messages. The default should be suitable for most
58237 + people, however, if you choose to change it, choose a value small enough
58238 + to allow informative logs to be produced, but large enough to
58239 + prevent flooding.
58240 +
58241 +config GRKERNSEC_FLOODBURST
58242 + int "Number of messages in a burst (maximum)"
58243 + default 6
58244 + help
58245 + This option allows you to choose the maximum number of messages allowed
58246 + within the flood time interval you chose in a separate option. The
58247 + default should be suitable for most people, however if you find that
58248 + many of your logs are being interpreted as flooding, you may want to
58249 + raise this value.
58250 +
58251 +endmenu
58252 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58253 new file mode 100644
58254 index 0000000..1b9afa9
58255 --- /dev/null
58256 +++ b/grsecurity/Makefile
58257 @@ -0,0 +1,38 @@
58258 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58259 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58260 +# into an RBAC system
58261 +#
58262 +# All code in this directory and various hooks inserted throughout the kernel
58263 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58264 +# under the GPL v2 or higher
58265 +
58266 +KBUILD_CFLAGS += -Werror
58267 +
58268 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58269 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58270 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58271 +
58272 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58273 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58274 + gracl_learn.o grsec_log.o
58275 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58276 +
58277 +ifdef CONFIG_NET
58278 +obj-y += grsec_sock.o
58279 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58280 +endif
58281 +
58282 +ifndef CONFIG_GRKERNSEC
58283 +obj-y += grsec_disabled.o
58284 +endif
58285 +
58286 +ifdef CONFIG_GRKERNSEC_HIDESYM
58287 +extra-y := grsec_hidesym.o
58288 +$(obj)/grsec_hidesym.o:
58289 + @-chmod -f 500 /boot
58290 + @-chmod -f 500 /lib/modules
58291 + @-chmod -f 500 /lib64/modules
58292 + @-chmod -f 500 /lib32/modules
58293 + @-chmod -f 700 .
58294 + @echo ' grsec: protected kernel image paths'
58295 +endif
58296 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58297 new file mode 100644
58298 index 0000000..0d5c602
58299 --- /dev/null
58300 +++ b/grsecurity/gracl.c
58301 @@ -0,0 +1,4073 @@
58302 +#include <linux/kernel.h>
58303 +#include <linux/module.h>
58304 +#include <linux/sched.h>
58305 +#include <linux/mm.h>
58306 +#include <linux/file.h>
58307 +#include <linux/fs.h>
58308 +#include <linux/namei.h>
58309 +#include <linux/mount.h>
58310 +#include <linux/tty.h>
58311 +#include <linux/proc_fs.h>
58312 +#include <linux/lglock.h>
58313 +#include <linux/slab.h>
58314 +#include <linux/vmalloc.h>
58315 +#include <linux/types.h>
58316 +#include <linux/sysctl.h>
58317 +#include <linux/netdevice.h>
58318 +#include <linux/ptrace.h>
58319 +#include <linux/gracl.h>
58320 +#include <linux/gralloc.h>
58321 +#include <linux/security.h>
58322 +#include <linux/grinternal.h>
58323 +#include <linux/pid_namespace.h>
58324 +#include <linux/stop_machine.h>
58325 +#include <linux/fdtable.h>
58326 +#include <linux/percpu.h>
58327 +#include <linux/lglock.h>
58328 +#include <linux/hugetlb.h>
58329 +#include <linux/posix-timers.h>
58330 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58331 +#include <linux/magic.h>
58332 +#include <linux/pagemap.h>
58333 +#include "../fs/btrfs/async-thread.h"
58334 +#include "../fs/btrfs/ctree.h"
58335 +#include "../fs/btrfs/btrfs_inode.h"
58336 +#endif
58337 +#include "../fs/mount.h"
58338 +
58339 +#include <asm/uaccess.h>
58340 +#include <asm/errno.h>
58341 +#include <asm/mman.h>
58342 +
58343 +extern struct lglock vfsmount_lock;
58344 +
58345 +static struct acl_role_db acl_role_set;
58346 +static struct name_db name_set;
58347 +static struct inodev_db inodev_set;
58348 +
58349 +/* for keeping track of userspace pointers used for subjects, so we
58350 + can share references in the kernel as well
58351 +*/
58352 +
58353 +static struct path real_root;
58354 +
58355 +static struct acl_subj_map_db subj_map_set;
58356 +
58357 +static struct acl_role_label *default_role;
58358 +
58359 +static struct acl_role_label *role_list;
58360 +
58361 +static u16 acl_sp_role_value;
58362 +
58363 +extern char *gr_shared_page[4];
58364 +static DEFINE_MUTEX(gr_dev_mutex);
58365 +DEFINE_RWLOCK(gr_inode_lock);
58366 +
58367 +struct gr_arg *gr_usermode;
58368 +
58369 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58370 +
58371 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58372 +extern void gr_clear_learn_entries(void);
58373 +
58374 +unsigned char *gr_system_salt;
58375 +unsigned char *gr_system_sum;
58376 +
58377 +static struct sprole_pw **acl_special_roles = NULL;
58378 +static __u16 num_sprole_pws = 0;
58379 +
58380 +static struct acl_role_label *kernel_role = NULL;
58381 +
58382 +static unsigned int gr_auth_attempts = 0;
58383 +static unsigned long gr_auth_expires = 0UL;
58384 +
58385 +#ifdef CONFIG_NET
58386 +extern struct vfsmount *sock_mnt;
58387 +#endif
58388 +
58389 +extern struct vfsmount *pipe_mnt;
58390 +extern struct vfsmount *shm_mnt;
58391 +
58392 +#ifdef CONFIG_HUGETLBFS
58393 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58394 +#endif
58395 +
58396 +static struct acl_object_label *fakefs_obj_rw;
58397 +static struct acl_object_label *fakefs_obj_rwx;
58398 +
58399 +extern int gr_init_uidset(void);
58400 +extern void gr_free_uidset(void);
58401 +extern void gr_remove_uid(uid_t uid);
58402 +extern int gr_find_uid(uid_t uid);
58403 +
58404 +__inline__ int
58405 +gr_acl_is_enabled(void)
58406 +{
58407 + return (gr_status & GR_READY);
58408 +}
58409 +
58410 +static inline dev_t __get_dev(const struct dentry *dentry)
58411 +{
58412 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58413 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58414 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58415 + else
58416 +#endif
58417 + return dentry->d_sb->s_dev;
58418 +}
58419 +
58420 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58421 +{
58422 + return __get_dev(dentry);
58423 +}
58424 +
58425 +static char gr_task_roletype_to_char(struct task_struct *task)
58426 +{
58427 + switch (task->role->roletype &
58428 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58429 + GR_ROLE_SPECIAL)) {
58430 + case GR_ROLE_DEFAULT:
58431 + return 'D';
58432 + case GR_ROLE_USER:
58433 + return 'U';
58434 + case GR_ROLE_GROUP:
58435 + return 'G';
58436 + case GR_ROLE_SPECIAL:
58437 + return 'S';
58438 + }
58439 +
58440 + return 'X';
58441 +}
58442 +
58443 +char gr_roletype_to_char(void)
58444 +{
58445 + return gr_task_roletype_to_char(current);
58446 +}
58447 +
58448 +__inline__ int
58449 +gr_acl_tpe_check(void)
58450 +{
58451 + if (unlikely(!(gr_status & GR_READY)))
58452 + return 0;
58453 + if (current->role->roletype & GR_ROLE_TPE)
58454 + return 1;
58455 + else
58456 + return 0;
58457 +}
58458 +
58459 +int
58460 +gr_handle_rawio(const struct inode *inode)
58461 +{
58462 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58463 + if (inode && S_ISBLK(inode->i_mode) &&
58464 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58465 + !capable(CAP_SYS_RAWIO))
58466 + return 1;
58467 +#endif
58468 + return 0;
58469 +}
58470 +
58471 +static int
58472 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58473 +{
58474 + if (likely(lena != lenb))
58475 + return 0;
58476 +
58477 + return !memcmp(a, b, lena);
58478 +}
58479 +
58480 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58481 +{
58482 + *buflen -= namelen;
58483 + if (*buflen < 0)
58484 + return -ENAMETOOLONG;
58485 + *buffer -= namelen;
58486 + memcpy(*buffer, str, namelen);
58487 + return 0;
58488 +}
58489 +
58490 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58491 +{
58492 + return prepend(buffer, buflen, name->name, name->len);
58493 +}
58494 +
58495 +static int prepend_path(const struct path *path, struct path *root,
58496 + char **buffer, int *buflen)
58497 +{
58498 + struct dentry *dentry = path->dentry;
58499 + struct vfsmount *vfsmnt = path->mnt;
58500 + struct mount *mnt = real_mount(vfsmnt);
58501 + bool slash = false;
58502 + int error = 0;
58503 +
58504 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58505 + struct dentry * parent;
58506 +
58507 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58508 + /* Global root? */
58509 + if (!mnt_has_parent(mnt)) {
58510 + goto out;
58511 + }
58512 + dentry = mnt->mnt_mountpoint;
58513 + mnt = mnt->mnt_parent;
58514 + vfsmnt = &mnt->mnt;
58515 + continue;
58516 + }
58517 + parent = dentry->d_parent;
58518 + prefetch(parent);
58519 + spin_lock(&dentry->d_lock);
58520 + error = prepend_name(buffer, buflen, &dentry->d_name);
58521 + spin_unlock(&dentry->d_lock);
58522 + if (!error)
58523 + error = prepend(buffer, buflen, "/", 1);
58524 + if (error)
58525 + break;
58526 +
58527 + slash = true;
58528 + dentry = parent;
58529 + }
58530 +
58531 +out:
58532 + if (!error && !slash)
58533 + error = prepend(buffer, buflen, "/", 1);
58534 +
58535 + return error;
58536 +}
58537 +
58538 +/* this must be called with vfsmount_lock and rename_lock held */
58539 +
58540 +static char *__our_d_path(const struct path *path, struct path *root,
58541 + char *buf, int buflen)
58542 +{
58543 + char *res = buf + buflen;
58544 + int error;
58545 +
58546 + prepend(&res, &buflen, "\0", 1);
58547 + error = prepend_path(path, root, &res, &buflen);
58548 + if (error)
58549 + return ERR_PTR(error);
58550 +
58551 + return res;
58552 +}
58553 +
58554 +static char *
58555 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58556 +{
58557 + char *retval;
58558 +
58559 + retval = __our_d_path(path, root, buf, buflen);
58560 + if (unlikely(IS_ERR(retval)))
58561 + retval = strcpy(buf, "<path too long>");
58562 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58563 + retval[1] = '\0';
58564 +
58565 + return retval;
58566 +}
58567 +
58568 +static char *
58569 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58570 + char *buf, int buflen)
58571 +{
58572 + struct path path;
58573 + char *res;
58574 +
58575 + path.dentry = (struct dentry *)dentry;
58576 + path.mnt = (struct vfsmount *)vfsmnt;
58577 +
58578 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58579 + by the RBAC system */
58580 + res = gen_full_path(&path, &real_root, buf, buflen);
58581 +
58582 + return res;
58583 +}
58584 +
58585 +static char *
58586 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58587 + char *buf, int buflen)
58588 +{
58589 + char *res;
58590 + struct path path;
58591 + struct path root;
58592 + struct task_struct *reaper = init_pid_ns.child_reaper;
58593 +
58594 + path.dentry = (struct dentry *)dentry;
58595 + path.mnt = (struct vfsmount *)vfsmnt;
58596 +
58597 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58598 + get_fs_root(reaper->fs, &root);
58599 +
58600 + br_read_lock(&vfsmount_lock);
58601 + write_seqlock(&rename_lock);
58602 + res = gen_full_path(&path, &root, buf, buflen);
58603 + write_sequnlock(&rename_lock);
58604 + br_read_unlock(&vfsmount_lock);
58605 +
58606 + path_put(&root);
58607 + return res;
58608 +}
58609 +
58610 +static char *
58611 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58612 +{
58613 + char *ret;
58614 + br_read_lock(&vfsmount_lock);
58615 + write_seqlock(&rename_lock);
58616 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58617 + PAGE_SIZE);
58618 + write_sequnlock(&rename_lock);
58619 + br_read_unlock(&vfsmount_lock);
58620 + return ret;
58621 +}
58622 +
58623 +static char *
58624 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58625 +{
58626 + char *ret;
58627 + char *buf;
58628 + int buflen;
58629 +
58630 + br_read_lock(&vfsmount_lock);
58631 + write_seqlock(&rename_lock);
58632 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58633 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58634 + buflen = (int)(ret - buf);
58635 + if (buflen >= 5)
58636 + prepend(&ret, &buflen, "/proc", 5);
58637 + else
58638 + ret = strcpy(buf, "<path too long>");
58639 + write_sequnlock(&rename_lock);
58640 + br_read_unlock(&vfsmount_lock);
58641 + return ret;
58642 +}
58643 +
58644 +char *
58645 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58646 +{
58647 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58648 + PAGE_SIZE);
58649 +}
58650 +
58651 +char *
58652 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58653 +{
58654 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58655 + PAGE_SIZE);
58656 +}
58657 +
58658 +char *
58659 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58660 +{
58661 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58662 + PAGE_SIZE);
58663 +}
58664 +
58665 +char *
58666 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58667 +{
58668 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58669 + PAGE_SIZE);
58670 +}
58671 +
58672 +char *
58673 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58674 +{
58675 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58676 + PAGE_SIZE);
58677 +}
58678 +
58679 +__inline__ __u32
58680 +to_gr_audit(const __u32 reqmode)
58681 +{
58682 + /* masks off auditable permission flags, then shifts them to create
58683 + auditing flags, and adds the special case of append auditing if
58684 + we're requesting write */
58685 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58686 +}
58687 +
58688 +struct acl_subject_label *
58689 +lookup_subject_map(const struct acl_subject_label *userp)
58690 +{
58691 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58692 + struct subject_map *match;
58693 +
58694 + match = subj_map_set.s_hash[index];
58695 +
58696 + while (match && match->user != userp)
58697 + match = match->next;
58698 +
58699 + if (match != NULL)
58700 + return match->kernel;
58701 + else
58702 + return NULL;
58703 +}
58704 +
58705 +static void
58706 +insert_subj_map_entry(struct subject_map *subjmap)
58707 +{
58708 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58709 + struct subject_map **curr;
58710 +
58711 + subjmap->prev = NULL;
58712 +
58713 + curr = &subj_map_set.s_hash[index];
58714 + if (*curr != NULL)
58715 + (*curr)->prev = subjmap;
58716 +
58717 + subjmap->next = *curr;
58718 + *curr = subjmap;
58719 +
58720 + return;
58721 +}
58722 +
58723 +static struct acl_role_label *
58724 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58725 + const gid_t gid)
58726 +{
58727 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58728 + struct acl_role_label *match;
58729 + struct role_allowed_ip *ipp;
58730 + unsigned int x;
58731 + u32 curr_ip = task->signal->curr_ip;
58732 +
58733 + task->signal->saved_ip = curr_ip;
58734 +
58735 + match = acl_role_set.r_hash[index];
58736 +
58737 + while (match) {
58738 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58739 + for (x = 0; x < match->domain_child_num; x++) {
58740 + if (match->domain_children[x] == uid)
58741 + goto found;
58742 + }
58743 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58744 + break;
58745 + match = match->next;
58746 + }
58747 +found:
58748 + if (match == NULL) {
58749 + try_group:
58750 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58751 + match = acl_role_set.r_hash[index];
58752 +
58753 + while (match) {
58754 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58755 + for (x = 0; x < match->domain_child_num; x++) {
58756 + if (match->domain_children[x] == gid)
58757 + goto found2;
58758 + }
58759 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58760 + break;
58761 + match = match->next;
58762 + }
58763 +found2:
58764 + if (match == NULL)
58765 + match = default_role;
58766 + if (match->allowed_ips == NULL)
58767 + return match;
58768 + else {
58769 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58770 + if (likely
58771 + ((ntohl(curr_ip) & ipp->netmask) ==
58772 + (ntohl(ipp->addr) & ipp->netmask)))
58773 + return match;
58774 + }
58775 + match = default_role;
58776 + }
58777 + } else if (match->allowed_ips == NULL) {
58778 + return match;
58779 + } else {
58780 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58781 + if (likely
58782 + ((ntohl(curr_ip) & ipp->netmask) ==
58783 + (ntohl(ipp->addr) & ipp->netmask)))
58784 + return match;
58785 + }
58786 + goto try_group;
58787 + }
58788 +
58789 + return match;
58790 +}
58791 +
58792 +struct acl_subject_label *
58793 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58794 + const struct acl_role_label *role)
58795 +{
58796 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58797 + struct acl_subject_label *match;
58798 +
58799 + match = role->subj_hash[index];
58800 +
58801 + while (match && (match->inode != ino || match->device != dev ||
58802 + (match->mode & GR_DELETED))) {
58803 + match = match->next;
58804 + }
58805 +
58806 + if (match && !(match->mode & GR_DELETED))
58807 + return match;
58808 + else
58809 + return NULL;
58810 +}
58811 +
58812 +struct acl_subject_label *
58813 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58814 + const struct acl_role_label *role)
58815 +{
58816 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58817 + struct acl_subject_label *match;
58818 +
58819 + match = role->subj_hash[index];
58820 +
58821 + while (match && (match->inode != ino || match->device != dev ||
58822 + !(match->mode & GR_DELETED))) {
58823 + match = match->next;
58824 + }
58825 +
58826 + if (match && (match->mode & GR_DELETED))
58827 + return match;
58828 + else
58829 + return NULL;
58830 +}
58831 +
58832 +static struct acl_object_label *
58833 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58834 + const struct acl_subject_label *subj)
58835 +{
58836 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58837 + struct acl_object_label *match;
58838 +
58839 + match = subj->obj_hash[index];
58840 +
58841 + while (match && (match->inode != ino || match->device != dev ||
58842 + (match->mode & GR_DELETED))) {
58843 + match = match->next;
58844 + }
58845 +
58846 + if (match && !(match->mode & GR_DELETED))
58847 + return match;
58848 + else
58849 + return NULL;
58850 +}
58851 +
58852 +static struct acl_object_label *
58853 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58854 + const struct acl_subject_label *subj)
58855 +{
58856 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58857 + struct acl_object_label *match;
58858 +
58859 + match = subj->obj_hash[index];
58860 +
58861 + while (match && (match->inode != ino || match->device != dev ||
58862 + !(match->mode & GR_DELETED))) {
58863 + match = match->next;
58864 + }
58865 +
58866 + if (match && (match->mode & GR_DELETED))
58867 + return match;
58868 +
58869 + match = subj->obj_hash[index];
58870 +
58871 + while (match && (match->inode != ino || match->device != dev ||
58872 + (match->mode & GR_DELETED))) {
58873 + match = match->next;
58874 + }
58875 +
58876 + if (match && !(match->mode & GR_DELETED))
58877 + return match;
58878 + else
58879 + return NULL;
58880 +}
58881 +
58882 +static struct name_entry *
58883 +lookup_name_entry(const char *name)
58884 +{
58885 + unsigned int len = strlen(name);
58886 + unsigned int key = full_name_hash(name, len);
58887 + unsigned int index = key % name_set.n_size;
58888 + struct name_entry *match;
58889 +
58890 + match = name_set.n_hash[index];
58891 +
58892 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58893 + match = match->next;
58894 +
58895 + return match;
58896 +}
58897 +
58898 +static struct name_entry *
58899 +lookup_name_entry_create(const char *name)
58900 +{
58901 + unsigned int len = strlen(name);
58902 + unsigned int key = full_name_hash(name, len);
58903 + unsigned int index = key % name_set.n_size;
58904 + struct name_entry *match;
58905 +
58906 + match = name_set.n_hash[index];
58907 +
58908 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58909 + !match->deleted))
58910 + match = match->next;
58911 +
58912 + if (match && match->deleted)
58913 + return match;
58914 +
58915 + match = name_set.n_hash[index];
58916 +
58917 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58918 + match->deleted))
58919 + match = match->next;
58920 +
58921 + if (match && !match->deleted)
58922 + return match;
58923 + else
58924 + return NULL;
58925 +}
58926 +
58927 +static struct inodev_entry *
58928 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58929 +{
58930 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58931 + struct inodev_entry *match;
58932 +
58933 + match = inodev_set.i_hash[index];
58934 +
58935 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58936 + match = match->next;
58937 +
58938 + return match;
58939 +}
58940 +
58941 +static void
58942 +insert_inodev_entry(struct inodev_entry *entry)
58943 +{
58944 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58945 + inodev_set.i_size);
58946 + struct inodev_entry **curr;
58947 +
58948 + entry->prev = NULL;
58949 +
58950 + curr = &inodev_set.i_hash[index];
58951 + if (*curr != NULL)
58952 + (*curr)->prev = entry;
58953 +
58954 + entry->next = *curr;
58955 + *curr = entry;
58956 +
58957 + return;
58958 +}
58959 +
58960 +static void
58961 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58962 +{
58963 + unsigned int index =
58964 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58965 + struct acl_role_label **curr;
58966 + struct acl_role_label *tmp, *tmp2;
58967 +
58968 + curr = &acl_role_set.r_hash[index];
58969 +
58970 + /* simple case, slot is empty, just set it to our role */
58971 + if (*curr == NULL) {
58972 + *curr = role;
58973 + } else {
58974 + /* example:
58975 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58976 + 2 -> 3
58977 + */
58978 + /* first check to see if we can already be reached via this slot */
58979 + tmp = *curr;
58980 + while (tmp && tmp != role)
58981 + tmp = tmp->next;
58982 + if (tmp == role) {
58983 + /* we don't need to add ourselves to this slot's chain */
58984 + return;
58985 + }
58986 + /* we need to add ourselves to this chain, two cases */
58987 + if (role->next == NULL) {
58988 + /* simple case, append the current chain to our role */
58989 + role->next = *curr;
58990 + *curr = role;
58991 + } else {
58992 + /* 1 -> 2 -> 3 -> 4
58993 + 2 -> 3 -> 4
58994 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58995 + */
58996 + /* trickier case: walk our role's chain until we find
58997 + the role for the start of the current slot's chain */
58998 + tmp = role;
58999 + tmp2 = *curr;
59000 + while (tmp->next && tmp->next != tmp2)
59001 + tmp = tmp->next;
59002 + if (tmp->next == tmp2) {
59003 + /* from example above, we found 3, so just
59004 + replace this slot's chain with ours */
59005 + *curr = role;
59006 + } else {
59007 + /* we didn't find a subset of our role's chain
59008 + in the current slot's chain, so append their
59009 + chain to ours, and set us as the first role in
59010 + the slot's chain
59011 +
59012 + we could fold this case with the case above,
59013 + but making it explicit for clarity
59014 + */
59015 + tmp->next = tmp2;
59016 + *curr = role;
59017 + }
59018 + }
59019 + }
59020 +
59021 + return;
59022 +}
59023 +
59024 +static void
59025 +insert_acl_role_label(struct acl_role_label *role)
59026 +{
59027 + int i;
59028 +
59029 + if (role_list == NULL) {
59030 + role_list = role;
59031 + role->prev = NULL;
59032 + } else {
59033 + role->prev = role_list;
59034 + role_list = role;
59035 + }
59036 +
59037 + /* used for hash chains */
59038 + role->next = NULL;
59039 +
59040 + if (role->roletype & GR_ROLE_DOMAIN) {
59041 + for (i = 0; i < role->domain_child_num; i++)
59042 + __insert_acl_role_label(role, role->domain_children[i]);
59043 + } else
59044 + __insert_acl_role_label(role, role->uidgid);
59045 +}
59046 +
59047 +static int
59048 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
59049 +{
59050 + struct name_entry **curr, *nentry;
59051 + struct inodev_entry *ientry;
59052 + unsigned int len = strlen(name);
59053 + unsigned int key = full_name_hash(name, len);
59054 + unsigned int index = key % name_set.n_size;
59055 +
59056 + curr = &name_set.n_hash[index];
59057 +
59058 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
59059 + curr = &((*curr)->next);
59060 +
59061 + if (*curr != NULL)
59062 + return 1;
59063 +
59064 + nentry = acl_alloc(sizeof (struct name_entry));
59065 + if (nentry == NULL)
59066 + return 0;
59067 + ientry = acl_alloc(sizeof (struct inodev_entry));
59068 + if (ientry == NULL)
59069 + return 0;
59070 + ientry->nentry = nentry;
59071 +
59072 + nentry->key = key;
59073 + nentry->name = name;
59074 + nentry->inode = inode;
59075 + nentry->device = device;
59076 + nentry->len = len;
59077 + nentry->deleted = deleted;
59078 +
59079 + nentry->prev = NULL;
59080 + curr = &name_set.n_hash[index];
59081 + if (*curr != NULL)
59082 + (*curr)->prev = nentry;
59083 + nentry->next = *curr;
59084 + *curr = nentry;
59085 +
59086 + /* insert us into the table searchable by inode/dev */
59087 + insert_inodev_entry(ientry);
59088 +
59089 + return 1;
59090 +}
59091 +
59092 +static void
59093 +insert_acl_obj_label(struct acl_object_label *obj,
59094 + struct acl_subject_label *subj)
59095 +{
59096 + unsigned int index =
59097 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59098 + struct acl_object_label **curr;
59099 +
59100 +
59101 + obj->prev = NULL;
59102 +
59103 + curr = &subj->obj_hash[index];
59104 + if (*curr != NULL)
59105 + (*curr)->prev = obj;
59106 +
59107 + obj->next = *curr;
59108 + *curr = obj;
59109 +
59110 + return;
59111 +}
59112 +
59113 +static void
59114 +insert_acl_subj_label(struct acl_subject_label *obj,
59115 + struct acl_role_label *role)
59116 +{
59117 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59118 + struct acl_subject_label **curr;
59119 +
59120 + obj->prev = NULL;
59121 +
59122 + curr = &role->subj_hash[index];
59123 + if (*curr != NULL)
59124 + (*curr)->prev = obj;
59125 +
59126 + obj->next = *curr;
59127 + *curr = obj;
59128 +
59129 + return;
59130 +}
59131 +
59132 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59133 +
59134 +static void *
59135 +create_table(__u32 * len, int elementsize)
59136 +{
59137 + unsigned int table_sizes[] = {
59138 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59139 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59140 + 4194301, 8388593, 16777213, 33554393, 67108859
59141 + };
59142 + void *newtable = NULL;
59143 + unsigned int pwr = 0;
59144 +
59145 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59146 + table_sizes[pwr] <= *len)
59147 + pwr++;
59148 +
59149 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59150 + return newtable;
59151 +
59152 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59153 + newtable =
59154 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59155 + else
59156 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59157 +
59158 + *len = table_sizes[pwr];
59159 +
59160 + return newtable;
59161 +}
59162 +
59163 +static int
59164 +init_variables(const struct gr_arg *arg)
59165 +{
59166 + struct task_struct *reaper = init_pid_ns.child_reaper;
59167 + unsigned int stacksize;
59168 +
59169 + subj_map_set.s_size = arg->role_db.num_subjects;
59170 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59171 + name_set.n_size = arg->role_db.num_objects;
59172 + inodev_set.i_size = arg->role_db.num_objects;
59173 +
59174 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59175 + !name_set.n_size || !inodev_set.i_size)
59176 + return 1;
59177 +
59178 + if (!gr_init_uidset())
59179 + return 1;
59180 +
59181 + /* set up the stack that holds allocation info */
59182 +
59183 + stacksize = arg->role_db.num_pointers + 5;
59184 +
59185 + if (!acl_alloc_stack_init(stacksize))
59186 + return 1;
59187 +
59188 + /* grab reference for the real root dentry and vfsmount */
59189 + get_fs_root(reaper->fs, &real_root);
59190 +
59191 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59192 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59193 +#endif
59194 +
59195 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59196 + if (fakefs_obj_rw == NULL)
59197 + return 1;
59198 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59199 +
59200 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59201 + if (fakefs_obj_rwx == NULL)
59202 + return 1;
59203 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59204 +
59205 + subj_map_set.s_hash =
59206 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59207 + acl_role_set.r_hash =
59208 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59209 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59210 + inodev_set.i_hash =
59211 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59212 +
59213 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59214 + !name_set.n_hash || !inodev_set.i_hash)
59215 + return 1;
59216 +
59217 + memset(subj_map_set.s_hash, 0,
59218 + sizeof(struct subject_map *) * subj_map_set.s_size);
59219 + memset(acl_role_set.r_hash, 0,
59220 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59221 + memset(name_set.n_hash, 0,
59222 + sizeof (struct name_entry *) * name_set.n_size);
59223 + memset(inodev_set.i_hash, 0,
59224 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59225 +
59226 + return 0;
59227 +}
59228 +
59229 +/* free information not needed after startup
59230 + currently contains user->kernel pointer mappings for subjects
59231 +*/
59232 +
59233 +static void
59234 +free_init_variables(void)
59235 +{
59236 + __u32 i;
59237 +
59238 + if (subj_map_set.s_hash) {
59239 + for (i = 0; i < subj_map_set.s_size; i++) {
59240 + if (subj_map_set.s_hash[i]) {
59241 + kfree(subj_map_set.s_hash[i]);
59242 + subj_map_set.s_hash[i] = NULL;
59243 + }
59244 + }
59245 +
59246 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59247 + PAGE_SIZE)
59248 + kfree(subj_map_set.s_hash);
59249 + else
59250 + vfree(subj_map_set.s_hash);
59251 + }
59252 +
59253 + return;
59254 +}
59255 +
59256 +static void
59257 +free_variables(void)
59258 +{
59259 + struct acl_subject_label *s;
59260 + struct acl_role_label *r;
59261 + struct task_struct *task, *task2;
59262 + unsigned int x;
59263 +
59264 + gr_clear_learn_entries();
59265 +
59266 + read_lock(&tasklist_lock);
59267 + do_each_thread(task2, task) {
59268 + task->acl_sp_role = 0;
59269 + task->acl_role_id = 0;
59270 + task->acl = NULL;
59271 + task->role = NULL;
59272 + } while_each_thread(task2, task);
59273 + read_unlock(&tasklist_lock);
59274 +
59275 + /* release the reference to the real root dentry and vfsmount */
59276 + path_put(&real_root);
59277 + memset(&real_root, 0, sizeof(real_root));
59278 +
59279 + /* free all object hash tables */
59280 +
59281 + FOR_EACH_ROLE_START(r)
59282 + if (r->subj_hash == NULL)
59283 + goto next_role;
59284 + FOR_EACH_SUBJECT_START(r, s, x)
59285 + if (s->obj_hash == NULL)
59286 + break;
59287 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59288 + kfree(s->obj_hash);
59289 + else
59290 + vfree(s->obj_hash);
59291 + FOR_EACH_SUBJECT_END(s, x)
59292 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59293 + if (s->obj_hash == NULL)
59294 + break;
59295 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59296 + kfree(s->obj_hash);
59297 + else
59298 + vfree(s->obj_hash);
59299 + FOR_EACH_NESTED_SUBJECT_END(s)
59300 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59301 + kfree(r->subj_hash);
59302 + else
59303 + vfree(r->subj_hash);
59304 + r->subj_hash = NULL;
59305 +next_role:
59306 + FOR_EACH_ROLE_END(r)
59307 +
59308 + acl_free_all();
59309 +
59310 + if (acl_role_set.r_hash) {
59311 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59312 + PAGE_SIZE)
59313 + kfree(acl_role_set.r_hash);
59314 + else
59315 + vfree(acl_role_set.r_hash);
59316 + }
59317 + if (name_set.n_hash) {
59318 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59319 + PAGE_SIZE)
59320 + kfree(name_set.n_hash);
59321 + else
59322 + vfree(name_set.n_hash);
59323 + }
59324 +
59325 + if (inodev_set.i_hash) {
59326 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59327 + PAGE_SIZE)
59328 + kfree(inodev_set.i_hash);
59329 + else
59330 + vfree(inodev_set.i_hash);
59331 + }
59332 +
59333 + gr_free_uidset();
59334 +
59335 + memset(&name_set, 0, sizeof (struct name_db));
59336 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59337 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59338 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59339 +
59340 + default_role = NULL;
59341 + kernel_role = NULL;
59342 + role_list = NULL;
59343 +
59344 + return;
59345 +}
59346 +
59347 +static __u32
59348 +count_user_objs(struct acl_object_label *userp)
59349 +{
59350 + struct acl_object_label o_tmp;
59351 + __u32 num = 0;
59352 +
59353 + while (userp) {
59354 + if (copy_from_user(&o_tmp, userp,
59355 + sizeof (struct acl_object_label)))
59356 + break;
59357 +
59358 + userp = o_tmp.prev;
59359 + num++;
59360 + }
59361 +
59362 + return num;
59363 +}
59364 +
59365 +static struct acl_subject_label *
59366 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59367 +
59368 +static int
59369 +copy_user_glob(struct acl_object_label *obj)
59370 +{
59371 + struct acl_object_label *g_tmp, **guser;
59372 + unsigned int len;
59373 + char *tmp;
59374 +
59375 + if (obj->globbed == NULL)
59376 + return 0;
59377 +
59378 + guser = &obj->globbed;
59379 + while (*guser) {
59380 + g_tmp = (struct acl_object_label *)
59381 + acl_alloc(sizeof (struct acl_object_label));
59382 + if (g_tmp == NULL)
59383 + return -ENOMEM;
59384 +
59385 + if (copy_from_user(g_tmp, *guser,
59386 + sizeof (struct acl_object_label)))
59387 + return -EFAULT;
59388 +
59389 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59390 +
59391 + if (!len || len >= PATH_MAX)
59392 + return -EINVAL;
59393 +
59394 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59395 + return -ENOMEM;
59396 +
59397 + if (copy_from_user(tmp, g_tmp->filename, len))
59398 + return -EFAULT;
59399 + tmp[len-1] = '\0';
59400 + g_tmp->filename = tmp;
59401 +
59402 + *guser = g_tmp;
59403 + guser = &(g_tmp->next);
59404 + }
59405 +
59406 + return 0;
59407 +}
59408 +
59409 +static int
59410 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59411 + struct acl_role_label *role)
59412 +{
59413 + struct acl_object_label *o_tmp;
59414 + unsigned int len;
59415 + int ret;
59416 + char *tmp;
59417 +
59418 + while (userp) {
59419 + if ((o_tmp = (struct acl_object_label *)
59420 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59421 + return -ENOMEM;
59422 +
59423 + if (copy_from_user(o_tmp, userp,
59424 + sizeof (struct acl_object_label)))
59425 + return -EFAULT;
59426 +
59427 + userp = o_tmp->prev;
59428 +
59429 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59430 +
59431 + if (!len || len >= PATH_MAX)
59432 + return -EINVAL;
59433 +
59434 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59435 + return -ENOMEM;
59436 +
59437 + if (copy_from_user(tmp, o_tmp->filename, len))
59438 + return -EFAULT;
59439 + tmp[len-1] = '\0';
59440 + o_tmp->filename = tmp;
59441 +
59442 + insert_acl_obj_label(o_tmp, subj);
59443 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59444 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59445 + return -ENOMEM;
59446 +
59447 + ret = copy_user_glob(o_tmp);
59448 + if (ret)
59449 + return ret;
59450 +
59451 + if (o_tmp->nested) {
59452 + int already_copied;
59453 +
59454 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59455 + if (IS_ERR(o_tmp->nested))
59456 + return PTR_ERR(o_tmp->nested);
59457 +
59458 + /* insert into nested subject list if we haven't copied this one yet
59459 + to prevent duplicate entries */
59460 + if (!already_copied) {
59461 + o_tmp->nested->next = role->hash->first;
59462 + role->hash->first = o_tmp->nested;
59463 + }
59464 + }
59465 + }
59466 +
59467 + return 0;
59468 +}
59469 +
59470 +static __u32
59471 +count_user_subjs(struct acl_subject_label *userp)
59472 +{
59473 + struct acl_subject_label s_tmp;
59474 + __u32 num = 0;
59475 +
59476 + while (userp) {
59477 + if (copy_from_user(&s_tmp, userp,
59478 + sizeof (struct acl_subject_label)))
59479 + break;
59480 +
59481 + userp = s_tmp.prev;
59482 + }
59483 +
59484 + return num;
59485 +}
59486 +
59487 +static int
59488 +copy_user_allowedips(struct acl_role_label *rolep)
59489 +{
59490 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59491 +
59492 + ruserip = rolep->allowed_ips;
59493 +
59494 + while (ruserip) {
59495 + rlast = rtmp;
59496 +
59497 + if ((rtmp = (struct role_allowed_ip *)
59498 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59499 + return -ENOMEM;
59500 +
59501 + if (copy_from_user(rtmp, ruserip,
59502 + sizeof (struct role_allowed_ip)))
59503 + return -EFAULT;
59504 +
59505 + ruserip = rtmp->prev;
59506 +
59507 + if (!rlast) {
59508 + rtmp->prev = NULL;
59509 + rolep->allowed_ips = rtmp;
59510 + } else {
59511 + rlast->next = rtmp;
59512 + rtmp->prev = rlast;
59513 + }
59514 +
59515 + if (!ruserip)
59516 + rtmp->next = NULL;
59517 + }
59518 +
59519 + return 0;
59520 +}
59521 +
59522 +static int
59523 +copy_user_transitions(struct acl_role_label *rolep)
59524 +{
59525 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59526 +
59527 + unsigned int len;
59528 + char *tmp;
59529 +
59530 + rusertp = rolep->transitions;
59531 +
59532 + while (rusertp) {
59533 + rlast = rtmp;
59534 +
59535 + if ((rtmp = (struct role_transition *)
59536 + acl_alloc(sizeof (struct role_transition))) == NULL)
59537 + return -ENOMEM;
59538 +
59539 + if (copy_from_user(rtmp, rusertp,
59540 + sizeof (struct role_transition)))
59541 + return -EFAULT;
59542 +
59543 + rusertp = rtmp->prev;
59544 +
59545 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59546 +
59547 + if (!len || len >= GR_SPROLE_LEN)
59548 + return -EINVAL;
59549 +
59550 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59551 + return -ENOMEM;
59552 +
59553 + if (copy_from_user(tmp, rtmp->rolename, len))
59554 + return -EFAULT;
59555 + tmp[len-1] = '\0';
59556 + rtmp->rolename = tmp;
59557 +
59558 + if (!rlast) {
59559 + rtmp->prev = NULL;
59560 + rolep->transitions = rtmp;
59561 + } else {
59562 + rlast->next = rtmp;
59563 + rtmp->prev = rlast;
59564 + }
59565 +
59566 + if (!rusertp)
59567 + rtmp->next = NULL;
59568 + }
59569 +
59570 + return 0;
59571 +}
59572 +
59573 +static struct acl_subject_label *
59574 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59575 +{
59576 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59577 + unsigned int len;
59578 + char *tmp;
59579 + __u32 num_objs;
59580 + struct acl_ip_label **i_tmp, *i_utmp2;
59581 + struct gr_hash_struct ghash;
59582 + struct subject_map *subjmap;
59583 + unsigned int i_num;
59584 + int err;
59585 +
59586 + if (already_copied != NULL)
59587 + *already_copied = 0;
59588 +
59589 + s_tmp = lookup_subject_map(userp);
59590 +
59591 + /* we've already copied this subject into the kernel, just return
59592 + the reference to it, and don't copy it over again
59593 + */
59594 + if (s_tmp) {
59595 + if (already_copied != NULL)
59596 + *already_copied = 1;
59597 + return(s_tmp);
59598 + }
59599 +
59600 + if ((s_tmp = (struct acl_subject_label *)
59601 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59602 + return ERR_PTR(-ENOMEM);
59603 +
59604 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59605 + if (subjmap == NULL)
59606 + return ERR_PTR(-ENOMEM);
59607 +
59608 + subjmap->user = userp;
59609 + subjmap->kernel = s_tmp;
59610 + insert_subj_map_entry(subjmap);
59611 +
59612 + if (copy_from_user(s_tmp, userp,
59613 + sizeof (struct acl_subject_label)))
59614 + return ERR_PTR(-EFAULT);
59615 +
59616 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59617 +
59618 + if (!len || len >= PATH_MAX)
59619 + return ERR_PTR(-EINVAL);
59620 +
59621 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59622 + return ERR_PTR(-ENOMEM);
59623 +
59624 + if (copy_from_user(tmp, s_tmp->filename, len))
59625 + return ERR_PTR(-EFAULT);
59626 + tmp[len-1] = '\0';
59627 + s_tmp->filename = tmp;
59628 +
59629 + if (!strcmp(s_tmp->filename, "/"))
59630 + role->root_label = s_tmp;
59631 +
59632 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59633 + return ERR_PTR(-EFAULT);
59634 +
59635 + /* copy user and group transition tables */
59636 +
59637 + if (s_tmp->user_trans_num) {
59638 + uid_t *uidlist;
59639 +
59640 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59641 + if (uidlist == NULL)
59642 + return ERR_PTR(-ENOMEM);
59643 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59644 + return ERR_PTR(-EFAULT);
59645 +
59646 + s_tmp->user_transitions = uidlist;
59647 + }
59648 +
59649 + if (s_tmp->group_trans_num) {
59650 + gid_t *gidlist;
59651 +
59652 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59653 + if (gidlist == NULL)
59654 + return ERR_PTR(-ENOMEM);
59655 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59656 + return ERR_PTR(-EFAULT);
59657 +
59658 + s_tmp->group_transitions = gidlist;
59659 + }
59660 +
59661 + /* set up object hash table */
59662 + num_objs = count_user_objs(ghash.first);
59663 +
59664 + s_tmp->obj_hash_size = num_objs;
59665 + s_tmp->obj_hash =
59666 + (struct acl_object_label **)
59667 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59668 +
59669 + if (!s_tmp->obj_hash)
59670 + return ERR_PTR(-ENOMEM);
59671 +
59672 + memset(s_tmp->obj_hash, 0,
59673 + s_tmp->obj_hash_size *
59674 + sizeof (struct acl_object_label *));
59675 +
59676 + /* add in objects */
59677 + err = copy_user_objs(ghash.first, s_tmp, role);
59678 +
59679 + if (err)
59680 + return ERR_PTR(err);
59681 +
59682 + /* set pointer for parent subject */
59683 + if (s_tmp->parent_subject) {
59684 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59685 +
59686 + if (IS_ERR(s_tmp2))
59687 + return s_tmp2;
59688 +
59689 + s_tmp->parent_subject = s_tmp2;
59690 + }
59691 +
59692 + /* add in ip acls */
59693 +
59694 + if (!s_tmp->ip_num) {
59695 + s_tmp->ips = NULL;
59696 + goto insert;
59697 + }
59698 +
59699 + i_tmp =
59700 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59701 + sizeof (struct acl_ip_label *));
59702 +
59703 + if (!i_tmp)
59704 + return ERR_PTR(-ENOMEM);
59705 +
59706 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59707 + *(i_tmp + i_num) =
59708 + (struct acl_ip_label *)
59709 + acl_alloc(sizeof (struct acl_ip_label));
59710 + if (!*(i_tmp + i_num))
59711 + return ERR_PTR(-ENOMEM);
59712 +
59713 + if (copy_from_user
59714 + (&i_utmp2, s_tmp->ips + i_num,
59715 + sizeof (struct acl_ip_label *)))
59716 + return ERR_PTR(-EFAULT);
59717 +
59718 + if (copy_from_user
59719 + (*(i_tmp + i_num), i_utmp2,
59720 + sizeof (struct acl_ip_label)))
59721 + return ERR_PTR(-EFAULT);
59722 +
59723 + if ((*(i_tmp + i_num))->iface == NULL)
59724 + continue;
59725 +
59726 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59727 + if (!len || len >= IFNAMSIZ)
59728 + return ERR_PTR(-EINVAL);
59729 + tmp = acl_alloc(len);
59730 + if (tmp == NULL)
59731 + return ERR_PTR(-ENOMEM);
59732 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59733 + return ERR_PTR(-EFAULT);
59734 + (*(i_tmp + i_num))->iface = tmp;
59735 + }
59736 +
59737 + s_tmp->ips = i_tmp;
59738 +
59739 +insert:
59740 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59741 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59742 + return ERR_PTR(-ENOMEM);
59743 +
59744 + return s_tmp;
59745 +}
59746 +
59747 +static int
59748 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59749 +{
59750 + struct acl_subject_label s_pre;
59751 + struct acl_subject_label * ret;
59752 + int err;
59753 +
59754 + while (userp) {
59755 + if (copy_from_user(&s_pre, userp,
59756 + sizeof (struct acl_subject_label)))
59757 + return -EFAULT;
59758 +
59759 + ret = do_copy_user_subj(userp, role, NULL);
59760 +
59761 + err = PTR_ERR(ret);
59762 + if (IS_ERR(ret))
59763 + return err;
59764 +
59765 + insert_acl_subj_label(ret, role);
59766 +
59767 + userp = s_pre.prev;
59768 + }
59769 +
59770 + return 0;
59771 +}
59772 +
59773 +static int
59774 +copy_user_acl(struct gr_arg *arg)
59775 +{
59776 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59777 + struct acl_subject_label *subj_list;
59778 + struct sprole_pw *sptmp;
59779 + struct gr_hash_struct *ghash;
59780 + uid_t *domainlist;
59781 + unsigned int r_num;
59782 + unsigned int len;
59783 + char *tmp;
59784 + int err = 0;
59785 + __u16 i;
59786 + __u32 num_subjs;
59787 +
59788 + /* we need a default and kernel role */
59789 + if (arg->role_db.num_roles < 2)
59790 + return -EINVAL;
59791 +
59792 + /* copy special role authentication info from userspace */
59793 +
59794 + num_sprole_pws = arg->num_sprole_pws;
59795 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59796 +
59797 + if (!acl_special_roles && num_sprole_pws)
59798 + return -ENOMEM;
59799 +
59800 + for (i = 0; i < num_sprole_pws; i++) {
59801 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59802 + if (!sptmp)
59803 + return -ENOMEM;
59804 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59805 + sizeof (struct sprole_pw)))
59806 + return -EFAULT;
59807 +
59808 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59809 +
59810 + if (!len || len >= GR_SPROLE_LEN)
59811 + return -EINVAL;
59812 +
59813 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59814 + return -ENOMEM;
59815 +
59816 + if (copy_from_user(tmp, sptmp->rolename, len))
59817 + return -EFAULT;
59818 +
59819 + tmp[len-1] = '\0';
59820 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59821 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59822 +#endif
59823 + sptmp->rolename = tmp;
59824 + acl_special_roles[i] = sptmp;
59825 + }
59826 +
59827 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59828 +
59829 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59830 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59831 +
59832 + if (!r_tmp)
59833 + return -ENOMEM;
59834 +
59835 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59836 + sizeof (struct acl_role_label *)))
59837 + return -EFAULT;
59838 +
59839 + if (copy_from_user(r_tmp, r_utmp2,
59840 + sizeof (struct acl_role_label)))
59841 + return -EFAULT;
59842 +
59843 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59844 +
59845 + if (!len || len >= PATH_MAX)
59846 + return -EINVAL;
59847 +
59848 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59849 + return -ENOMEM;
59850 +
59851 + if (copy_from_user(tmp, r_tmp->rolename, len))
59852 + return -EFAULT;
59853 +
59854 + tmp[len-1] = '\0';
59855 + r_tmp->rolename = tmp;
59856 +
59857 + if (!strcmp(r_tmp->rolename, "default")
59858 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59859 + default_role = r_tmp;
59860 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59861 + kernel_role = r_tmp;
59862 + }
59863 +
59864 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59865 + return -ENOMEM;
59866 +
59867 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59868 + return -EFAULT;
59869 +
59870 + r_tmp->hash = ghash;
59871 +
59872 + num_subjs = count_user_subjs(r_tmp->hash->first);
59873 +
59874 + r_tmp->subj_hash_size = num_subjs;
59875 + r_tmp->subj_hash =
59876 + (struct acl_subject_label **)
59877 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59878 +
59879 + if (!r_tmp->subj_hash)
59880 + return -ENOMEM;
59881 +
59882 + err = copy_user_allowedips(r_tmp);
59883 + if (err)
59884 + return err;
59885 +
59886 + /* copy domain info */
59887 + if (r_tmp->domain_children != NULL) {
59888 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59889 + if (domainlist == NULL)
59890 + return -ENOMEM;
59891 +
59892 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59893 + return -EFAULT;
59894 +
59895 + r_tmp->domain_children = domainlist;
59896 + }
59897 +
59898 + err = copy_user_transitions(r_tmp);
59899 + if (err)
59900 + return err;
59901 +
59902 + memset(r_tmp->subj_hash, 0,
59903 + r_tmp->subj_hash_size *
59904 + sizeof (struct acl_subject_label *));
59905 +
59906 + /* acquire the list of subjects, then NULL out
59907 + the list prior to parsing the subjects for this role,
59908 + as during this parsing the list is replaced with a list
59909 + of *nested* subjects for the role
59910 + */
59911 + subj_list = r_tmp->hash->first;
59912 +
59913 + /* set nested subject list to null */
59914 + r_tmp->hash->first = NULL;
59915 +
59916 + err = copy_user_subjs(subj_list, r_tmp);
59917 +
59918 + if (err)
59919 + return err;
59920 +
59921 + insert_acl_role_label(r_tmp);
59922 + }
59923 +
59924 + if (default_role == NULL || kernel_role == NULL)
59925 + return -EINVAL;
59926 +
59927 + return err;
59928 +}
59929 +
59930 +static int
59931 +gracl_init(struct gr_arg *args)
59932 +{
59933 + int error = 0;
59934 +
59935 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59936 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59937 +
59938 + if (init_variables(args)) {
59939 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59940 + error = -ENOMEM;
59941 + free_variables();
59942 + goto out;
59943 + }
59944 +
59945 + error = copy_user_acl(args);
59946 + free_init_variables();
59947 + if (error) {
59948 + free_variables();
59949 + goto out;
59950 + }
59951 +
59952 + if ((error = gr_set_acls(0))) {
59953 + free_variables();
59954 + goto out;
59955 + }
59956 +
59957 + pax_open_kernel();
59958 + gr_status |= GR_READY;
59959 + pax_close_kernel();
59960 +
59961 + out:
59962 + return error;
59963 +}
59964 +
59965 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59966 +
59967 +static int
59968 +glob_match(const char *p, const char *n)
59969 +{
59970 + char c;
59971 +
59972 + while ((c = *p++) != '\0') {
59973 + switch (c) {
59974 + case '?':
59975 + if (*n == '\0')
59976 + return 1;
59977 + else if (*n == '/')
59978 + return 1;
59979 + break;
59980 + case '\\':
59981 + if (*n != c)
59982 + return 1;
59983 + break;
59984 + case '*':
59985 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59986 + if (*n == '/')
59987 + return 1;
59988 + else if (c == '?') {
59989 + if (*n == '\0')
59990 + return 1;
59991 + else
59992 + ++n;
59993 + }
59994 + }
59995 + if (c == '\0') {
59996 + return 0;
59997 + } else {
59998 + const char *endp;
59999 +
60000 + if ((endp = strchr(n, '/')) == NULL)
60001 + endp = n + strlen(n);
60002 +
60003 + if (c == '[') {
60004 + for (--p; n < endp; ++n)
60005 + if (!glob_match(p, n))
60006 + return 0;
60007 + } else if (c == '/') {
60008 + while (*n != '\0' && *n != '/')
60009 + ++n;
60010 + if (*n == '/' && !glob_match(p, n + 1))
60011 + return 0;
60012 + } else {
60013 + for (--p; n < endp; ++n)
60014 + if (*n == c && !glob_match(p, n))
60015 + return 0;
60016 + }
60017 +
60018 + return 1;
60019 + }
60020 + case '[':
60021 + {
60022 + int not;
60023 + char cold;
60024 +
60025 + if (*n == '\0' || *n == '/')
60026 + return 1;
60027 +
60028 + not = (*p == '!' || *p == '^');
60029 + if (not)
60030 + ++p;
60031 +
60032 + c = *p++;
60033 + for (;;) {
60034 + unsigned char fn = (unsigned char)*n;
60035 +
60036 + if (c == '\0')
60037 + return 1;
60038 + else {
60039 + if (c == fn)
60040 + goto matched;
60041 + cold = c;
60042 + c = *p++;
60043 +
60044 + if (c == '-' && *p != ']') {
60045 + unsigned char cend = *p++;
60046 +
60047 + if (cend == '\0')
60048 + return 1;
60049 +
60050 + if (cold <= fn && fn <= cend)
60051 + goto matched;
60052 +
60053 + c = *p++;
60054 + }
60055 + }
60056 +
60057 + if (c == ']')
60058 + break;
60059 + }
60060 + if (!not)
60061 + return 1;
60062 + break;
60063 + matched:
60064 + while (c != ']') {
60065 + if (c == '\0')
60066 + return 1;
60067 +
60068 + c = *p++;
60069 + }
60070 + if (not)
60071 + return 1;
60072 + }
60073 + break;
60074 + default:
60075 + if (c != *n)
60076 + return 1;
60077 + }
60078 +
60079 + ++n;
60080 + }
60081 +
60082 + if (*n == '\0')
60083 + return 0;
60084 +
60085 + if (*n == '/')
60086 + return 0;
60087 +
60088 + return 1;
60089 +}
60090 +
60091 +static struct acl_object_label *
60092 +chk_glob_label(struct acl_object_label *globbed,
60093 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60094 +{
60095 + struct acl_object_label *tmp;
60096 +
60097 + if (*path == NULL)
60098 + *path = gr_to_filename_nolock(dentry, mnt);
60099 +
60100 + tmp = globbed;
60101 +
60102 + while (tmp) {
60103 + if (!glob_match(tmp->filename, *path))
60104 + return tmp;
60105 + tmp = tmp->next;
60106 + }
60107 +
60108 + return NULL;
60109 +}
60110 +
60111 +static struct acl_object_label *
60112 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60113 + const ino_t curr_ino, const dev_t curr_dev,
60114 + const struct acl_subject_label *subj, char **path, const int checkglob)
60115 +{
60116 + struct acl_subject_label *tmpsubj;
60117 + struct acl_object_label *retval;
60118 + struct acl_object_label *retval2;
60119 +
60120 + tmpsubj = (struct acl_subject_label *) subj;
60121 + read_lock(&gr_inode_lock);
60122 + do {
60123 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60124 + if (retval) {
60125 + if (checkglob && retval->globbed) {
60126 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60127 + if (retval2)
60128 + retval = retval2;
60129 + }
60130 + break;
60131 + }
60132 + } while ((tmpsubj = tmpsubj->parent_subject));
60133 + read_unlock(&gr_inode_lock);
60134 +
60135 + return retval;
60136 +}
60137 +
60138 +static __inline__ struct acl_object_label *
60139 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60140 + struct dentry *curr_dentry,
60141 + const struct acl_subject_label *subj, char **path, const int checkglob)
60142 +{
60143 + int newglob = checkglob;
60144 + ino_t inode;
60145 + dev_t device;
60146 +
60147 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60148 + as we don't want a / * rule to match instead of the / object
60149 + don't do this for create lookups that call this function though, since they're looking up
60150 + on the parent and thus need globbing checks on all paths
60151 + */
60152 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60153 + newglob = GR_NO_GLOB;
60154 +
60155 + spin_lock(&curr_dentry->d_lock);
60156 + inode = curr_dentry->d_inode->i_ino;
60157 + device = __get_dev(curr_dentry);
60158 + spin_unlock(&curr_dentry->d_lock);
60159 +
60160 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60161 +}
60162 +
60163 +#ifdef CONFIG_HUGETLBFS
60164 +static inline bool
60165 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60166 +{
60167 + int i;
60168 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60169 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60170 + return true;
60171 + }
60172 +
60173 + return false;
60174 +}
60175 +#endif
60176 +
60177 +static struct acl_object_label *
60178 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60179 + const struct acl_subject_label *subj, char *path, const int checkglob)
60180 +{
60181 + struct dentry *dentry = (struct dentry *) l_dentry;
60182 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60183 + struct mount *real_mnt = real_mount(mnt);
60184 + struct acl_object_label *retval;
60185 + struct dentry *parent;
60186 +
60187 + br_read_lock(&vfsmount_lock);
60188 + write_seqlock(&rename_lock);
60189 +
60190 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60191 +#ifdef CONFIG_NET
60192 + mnt == sock_mnt ||
60193 +#endif
60194 +#ifdef CONFIG_HUGETLBFS
60195 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60196 +#endif
60197 + /* ignore Eric Biederman */
60198 + IS_PRIVATE(l_dentry->d_inode))) {
60199 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60200 + goto out;
60201 + }
60202 +
60203 + for (;;) {
60204 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60205 + break;
60206 +
60207 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60208 + if (!mnt_has_parent(real_mnt))
60209 + break;
60210 +
60211 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60212 + if (retval != NULL)
60213 + goto out;
60214 +
60215 + dentry = real_mnt->mnt_mountpoint;
60216 + real_mnt = real_mnt->mnt_parent;
60217 + mnt = &real_mnt->mnt;
60218 + continue;
60219 + }
60220 +
60221 + parent = dentry->d_parent;
60222 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60223 + if (retval != NULL)
60224 + goto out;
60225 +
60226 + dentry = parent;
60227 + }
60228 +
60229 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60230 +
60231 + /* real_root is pinned so we don't have to hold a reference */
60232 + if (retval == NULL)
60233 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60234 +out:
60235 + write_sequnlock(&rename_lock);
60236 + br_read_unlock(&vfsmount_lock);
60237 +
60238 + BUG_ON(retval == NULL);
60239 +
60240 + return retval;
60241 +}
60242 +
60243 +static __inline__ struct acl_object_label *
60244 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60245 + const struct acl_subject_label *subj)
60246 +{
60247 + char *path = NULL;
60248 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60249 +}
60250 +
60251 +static __inline__ struct acl_object_label *
60252 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60253 + const struct acl_subject_label *subj)
60254 +{
60255 + char *path = NULL;
60256 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60257 +}
60258 +
60259 +static __inline__ struct acl_object_label *
60260 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60261 + const struct acl_subject_label *subj, char *path)
60262 +{
60263 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60264 +}
60265 +
60266 +static struct acl_subject_label *
60267 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60268 + const struct acl_role_label *role)
60269 +{
60270 + struct dentry *dentry = (struct dentry *) l_dentry;
60271 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60272 + struct mount *real_mnt = real_mount(mnt);
60273 + struct acl_subject_label *retval;
60274 + struct dentry *parent;
60275 +
60276 + br_read_lock(&vfsmount_lock);
60277 + write_seqlock(&rename_lock);
60278 +
60279 + for (;;) {
60280 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60281 + break;
60282 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60283 + if (!mnt_has_parent(real_mnt))
60284 + break;
60285 +
60286 + spin_lock(&dentry->d_lock);
60287 + read_lock(&gr_inode_lock);
60288 + retval =
60289 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60290 + __get_dev(dentry), role);
60291 + read_unlock(&gr_inode_lock);
60292 + spin_unlock(&dentry->d_lock);
60293 + if (retval != NULL)
60294 + goto out;
60295 +
60296 + dentry = real_mnt->mnt_mountpoint;
60297 + real_mnt = real_mnt->mnt_parent;
60298 + mnt = &real_mnt->mnt;
60299 + continue;
60300 + }
60301 +
60302 + spin_lock(&dentry->d_lock);
60303 + read_lock(&gr_inode_lock);
60304 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60305 + __get_dev(dentry), role);
60306 + read_unlock(&gr_inode_lock);
60307 + parent = dentry->d_parent;
60308 + spin_unlock(&dentry->d_lock);
60309 +
60310 + if (retval != NULL)
60311 + goto out;
60312 +
60313 + dentry = parent;
60314 + }
60315 +
60316 + spin_lock(&dentry->d_lock);
60317 + read_lock(&gr_inode_lock);
60318 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60319 + __get_dev(dentry), role);
60320 + read_unlock(&gr_inode_lock);
60321 + spin_unlock(&dentry->d_lock);
60322 +
60323 + if (unlikely(retval == NULL)) {
60324 + /* real_root is pinned, we don't need to hold a reference */
60325 + read_lock(&gr_inode_lock);
60326 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60327 + __get_dev(real_root.dentry), role);
60328 + read_unlock(&gr_inode_lock);
60329 + }
60330 +out:
60331 + write_sequnlock(&rename_lock);
60332 + br_read_unlock(&vfsmount_lock);
60333 +
60334 + BUG_ON(retval == NULL);
60335 +
60336 + return retval;
60337 +}
60338 +
60339 +static void
60340 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60341 +{
60342 + struct task_struct *task = current;
60343 + const struct cred *cred = current_cred();
60344 +
60345 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60346 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60347 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60348 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60349 +
60350 + return;
60351 +}
60352 +
60353 +static void
60354 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60355 +{
60356 + struct task_struct *task = current;
60357 + const struct cred *cred = current_cred();
60358 +
60359 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60360 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60361 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60362 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60363 +
60364 + return;
60365 +}
60366 +
60367 +static void
60368 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60369 +{
60370 + struct task_struct *task = current;
60371 + const struct cred *cred = current_cred();
60372 +
60373 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60374 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60375 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60376 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60377 +
60378 + return;
60379 +}
60380 +
60381 +__u32
60382 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60383 + const struct vfsmount * mnt)
60384 +{
60385 + __u32 retval = mode;
60386 + struct acl_subject_label *curracl;
60387 + struct acl_object_label *currobj;
60388 +
60389 + if (unlikely(!(gr_status & GR_READY)))
60390 + return (mode & ~GR_AUDITS);
60391 +
60392 + curracl = current->acl;
60393 +
60394 + currobj = chk_obj_label(dentry, mnt, curracl);
60395 + retval = currobj->mode & mode;
60396 +
60397 + /* if we're opening a specified transfer file for writing
60398 + (e.g. /dev/initctl), then transfer our role to init
60399 + */
60400 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60401 + current->role->roletype & GR_ROLE_PERSIST)) {
60402 + struct task_struct *task = init_pid_ns.child_reaper;
60403 +
60404 + if (task->role != current->role) {
60405 + task->acl_sp_role = 0;
60406 + task->acl_role_id = current->acl_role_id;
60407 + task->role = current->role;
60408 + rcu_read_lock();
60409 + read_lock(&grsec_exec_file_lock);
60410 + gr_apply_subject_to_task(task);
60411 + read_unlock(&grsec_exec_file_lock);
60412 + rcu_read_unlock();
60413 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60414 + }
60415 + }
60416 +
60417 + if (unlikely
60418 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60419 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60420 + __u32 new_mode = mode;
60421 +
60422 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60423 +
60424 + retval = new_mode;
60425 +
60426 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60427 + new_mode |= GR_INHERIT;
60428 +
60429 + if (!(mode & GR_NOLEARN))
60430 + gr_log_learn(dentry, mnt, new_mode);
60431 + }
60432 +
60433 + return retval;
60434 +}
60435 +
60436 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60437 + const struct dentry *parent,
60438 + const struct vfsmount *mnt)
60439 +{
60440 + struct name_entry *match;
60441 + struct acl_object_label *matchpo;
60442 + struct acl_subject_label *curracl;
60443 + char *path;
60444 +
60445 + if (unlikely(!(gr_status & GR_READY)))
60446 + return NULL;
60447 +
60448 + preempt_disable();
60449 + path = gr_to_filename_rbac(new_dentry, mnt);
60450 + match = lookup_name_entry_create(path);
60451 +
60452 + curracl = current->acl;
60453 +
60454 + if (match) {
60455 + read_lock(&gr_inode_lock);
60456 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60457 + read_unlock(&gr_inode_lock);
60458 +
60459 + if (matchpo) {
60460 + preempt_enable();
60461 + return matchpo;
60462 + }
60463 + }
60464 +
60465 + // lookup parent
60466 +
60467 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60468 +
60469 + preempt_enable();
60470 + return matchpo;
60471 +}
60472 +
60473 +__u32
60474 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60475 + const struct vfsmount * mnt, const __u32 mode)
60476 +{
60477 + struct acl_object_label *matchpo;
60478 + __u32 retval;
60479 +
60480 + if (unlikely(!(gr_status & GR_READY)))
60481 + return (mode & ~GR_AUDITS);
60482 +
60483 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60484 +
60485 + retval = matchpo->mode & mode;
60486 +
60487 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60488 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60489 + __u32 new_mode = mode;
60490 +
60491 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60492 +
60493 + gr_log_learn(new_dentry, mnt, new_mode);
60494 + return new_mode;
60495 + }
60496 +
60497 + return retval;
60498 +}
60499 +
60500 +__u32
60501 +gr_check_link(const struct dentry * new_dentry,
60502 + const struct dentry * parent_dentry,
60503 + const struct vfsmount * parent_mnt,
60504 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60505 +{
60506 + struct acl_object_label *obj;
60507 + __u32 oldmode, newmode;
60508 + __u32 needmode;
60509 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60510 + GR_DELETE | GR_INHERIT;
60511 +
60512 + if (unlikely(!(gr_status & GR_READY)))
60513 + return (GR_CREATE | GR_LINK);
60514 +
60515 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60516 + oldmode = obj->mode;
60517 +
60518 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60519 + newmode = obj->mode;
60520 +
60521 + needmode = newmode & checkmodes;
60522 +
60523 + // old name for hardlink must have at least the permissions of the new name
60524 + if ((oldmode & needmode) != needmode)
60525 + goto bad;
60526 +
60527 + // if old name had restrictions/auditing, make sure the new name does as well
60528 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60529 +
60530 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60531 + if (is_privileged_binary(old_dentry))
60532 + needmode |= GR_SETID;
60533 +
60534 + if ((newmode & needmode) != needmode)
60535 + goto bad;
60536 +
60537 + // enforce minimum permissions
60538 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60539 + return newmode;
60540 +bad:
60541 + needmode = oldmode;
60542 + if (is_privileged_binary(old_dentry))
60543 + needmode |= GR_SETID;
60544 +
60545 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60546 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60547 + return (GR_CREATE | GR_LINK);
60548 + } else if (newmode & GR_SUPPRESS)
60549 + return GR_SUPPRESS;
60550 + else
60551 + return 0;
60552 +}
60553 +
60554 +int
60555 +gr_check_hidden_task(const struct task_struct *task)
60556 +{
60557 + if (unlikely(!(gr_status & GR_READY)))
60558 + return 0;
60559 +
60560 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60561 + return 1;
60562 +
60563 + return 0;
60564 +}
60565 +
60566 +int
60567 +gr_check_protected_task(const struct task_struct *task)
60568 +{
60569 + if (unlikely(!(gr_status & GR_READY) || !task))
60570 + return 0;
60571 +
60572 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60573 + task->acl != current->acl)
60574 + return 1;
60575 +
60576 + return 0;
60577 +}
60578 +
60579 +int
60580 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60581 +{
60582 + struct task_struct *p;
60583 + int ret = 0;
60584 +
60585 + if (unlikely(!(gr_status & GR_READY) || !pid))
60586 + return ret;
60587 +
60588 + read_lock(&tasklist_lock);
60589 + do_each_pid_task(pid, type, p) {
60590 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60591 + p->acl != current->acl) {
60592 + ret = 1;
60593 + goto out;
60594 + }
60595 + } while_each_pid_task(pid, type, p);
60596 +out:
60597 + read_unlock(&tasklist_lock);
60598 +
60599 + return ret;
60600 +}
60601 +
60602 +void
60603 +gr_copy_label(struct task_struct *tsk)
60604 +{
60605 + tsk->signal->used_accept = 0;
60606 + tsk->acl_sp_role = 0;
60607 + tsk->acl_role_id = current->acl_role_id;
60608 + tsk->acl = current->acl;
60609 + tsk->role = current->role;
60610 + tsk->signal->curr_ip = current->signal->curr_ip;
60611 + tsk->signal->saved_ip = current->signal->saved_ip;
60612 + if (current->exec_file)
60613 + get_file(current->exec_file);
60614 + tsk->exec_file = current->exec_file;
60615 + tsk->is_writable = current->is_writable;
60616 + if (unlikely(current->signal->used_accept)) {
60617 + current->signal->curr_ip = 0;
60618 + current->signal->saved_ip = 0;
60619 + }
60620 +
60621 + return;
60622 +}
60623 +
60624 +static void
60625 +gr_set_proc_res(struct task_struct *task)
60626 +{
60627 + struct acl_subject_label *proc;
60628 + unsigned short i;
60629 +
60630 + proc = task->acl;
60631 +
60632 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60633 + return;
60634 +
60635 + for (i = 0; i < RLIM_NLIMITS; i++) {
60636 + if (!(proc->resmask & (1U << i)))
60637 + continue;
60638 +
60639 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60640 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60641 +
60642 + if (i == RLIMIT_CPU)
60643 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60644 + }
60645 +
60646 + return;
60647 +}
60648 +
60649 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
60650 +
60651 +int
60652 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60653 +{
60654 + unsigned int i;
60655 + __u16 num;
60656 + uid_t *uidlist;
60657 + uid_t curuid;
60658 + int realok = 0;
60659 + int effectiveok = 0;
60660 + int fsok = 0;
60661 + uid_t globalreal, globaleffective, globalfs;
60662 +
60663 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
60664 + struct user_struct *user;
60665 +
60666 + if (!uid_valid(real))
60667 + goto skipit;
60668 +
60669 + /* find user based on global namespace */
60670 +
60671 + globalreal = GR_GLOBAL_UID(real);
60672 +
60673 + user = find_user(make_kuid(&init_user_ns, globalreal));
60674 + if (user == NULL)
60675 + goto skipit;
60676 +
60677 + if (gr_process_kernel_setuid_ban(user)) {
60678 + /* for find_user */
60679 + free_uid(user);
60680 + return 1;
60681 + }
60682 +
60683 + /* for find_user */
60684 + free_uid(user);
60685 +
60686 +skipit:
60687 +#endif
60688 +
60689 + if (unlikely(!(gr_status & GR_READY)))
60690 + return 0;
60691 +
60692 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60693 + gr_log_learn_uid_change(real, effective, fs);
60694 +
60695 + num = current->acl->user_trans_num;
60696 + uidlist = current->acl->user_transitions;
60697 +
60698 + if (uidlist == NULL)
60699 + return 0;
60700 +
60701 + if (!uid_valid(real)) {
60702 + realok = 1;
60703 + globalreal = (uid_t)-1;
60704 + } else {
60705 + globalreal = GR_GLOBAL_UID(real);
60706 + }
60707 + if (!uid_valid(effective)) {
60708 + effectiveok = 1;
60709 + globaleffective = (uid_t)-1;
60710 + } else {
60711 + globaleffective = GR_GLOBAL_UID(effective);
60712 + }
60713 + if (!uid_valid(fs)) {
60714 + fsok = 1;
60715 + globalfs = (uid_t)-1;
60716 + } else {
60717 + globalfs = GR_GLOBAL_UID(fs);
60718 + }
60719 +
60720 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60721 + for (i = 0; i < num; i++) {
60722 + curuid = uidlist[i];
60723 + if (globalreal == curuid)
60724 + realok = 1;
60725 + if (globaleffective == curuid)
60726 + effectiveok = 1;
60727 + if (globalfs == curuid)
60728 + fsok = 1;
60729 + }
60730 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60731 + for (i = 0; i < num; i++) {
60732 + curuid = uidlist[i];
60733 + if (globalreal == curuid)
60734 + break;
60735 + if (globaleffective == curuid)
60736 + break;
60737 + if (globalfs == curuid)
60738 + break;
60739 + }
60740 + /* not in deny list */
60741 + if (i == num) {
60742 + realok = 1;
60743 + effectiveok = 1;
60744 + fsok = 1;
60745 + }
60746 + }
60747 +
60748 + if (realok && effectiveok && fsok)
60749 + return 0;
60750 + else {
60751 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60752 + return 1;
60753 + }
60754 +}
60755 +
60756 +int
60757 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60758 +{
60759 + unsigned int i;
60760 + __u16 num;
60761 + gid_t *gidlist;
60762 + gid_t curgid;
60763 + int realok = 0;
60764 + int effectiveok = 0;
60765 + int fsok = 0;
60766 + gid_t globalreal, globaleffective, globalfs;
60767 +
60768 + if (unlikely(!(gr_status & GR_READY)))
60769 + return 0;
60770 +
60771 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60772 + gr_log_learn_gid_change(real, effective, fs);
60773 +
60774 + num = current->acl->group_trans_num;
60775 + gidlist = current->acl->group_transitions;
60776 +
60777 + if (gidlist == NULL)
60778 + return 0;
60779 +
60780 + if (!gid_valid(real)) {
60781 + realok = 1;
60782 + globalreal = (gid_t)-1;
60783 + } else {
60784 + globalreal = GR_GLOBAL_GID(real);
60785 + }
60786 + if (!gid_valid(effective)) {
60787 + effectiveok = 1;
60788 + globaleffective = (gid_t)-1;
60789 + } else {
60790 + globaleffective = GR_GLOBAL_GID(effective);
60791 + }
60792 + if (!gid_valid(fs)) {
60793 + fsok = 1;
60794 + globalfs = (gid_t)-1;
60795 + } else {
60796 + globalfs = GR_GLOBAL_GID(fs);
60797 + }
60798 +
60799 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60800 + for (i = 0; i < num; i++) {
60801 + curgid = gidlist[i];
60802 + if (globalreal == curgid)
60803 + realok = 1;
60804 + if (globaleffective == curgid)
60805 + effectiveok = 1;
60806 + if (globalfs == curgid)
60807 + fsok = 1;
60808 + }
60809 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60810 + for (i = 0; i < num; i++) {
60811 + curgid = gidlist[i];
60812 + if (globalreal == curgid)
60813 + break;
60814 + if (globaleffective == curgid)
60815 + break;
60816 + if (globalfs == curgid)
60817 + break;
60818 + }
60819 + /* not in deny list */
60820 + if (i == num) {
60821 + realok = 1;
60822 + effectiveok = 1;
60823 + fsok = 1;
60824 + }
60825 + }
60826 +
60827 + if (realok && effectiveok && fsok)
60828 + return 0;
60829 + else {
60830 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60831 + return 1;
60832 + }
60833 +}
60834 +
60835 +extern int gr_acl_is_capable(const int cap);
60836 +
60837 +void
60838 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60839 +{
60840 + struct acl_role_label *role = task->role;
60841 + struct acl_subject_label *subj = NULL;
60842 + struct acl_object_label *obj;
60843 + struct file *filp;
60844 + uid_t uid;
60845 + gid_t gid;
60846 +
60847 + if (unlikely(!(gr_status & GR_READY)))
60848 + return;
60849 +
60850 + uid = GR_GLOBAL_UID(kuid);
60851 + gid = GR_GLOBAL_GID(kgid);
60852 +
60853 + filp = task->exec_file;
60854 +
60855 + /* kernel process, we'll give them the kernel role */
60856 + if (unlikely(!filp)) {
60857 + task->role = kernel_role;
60858 + task->acl = kernel_role->root_label;
60859 + return;
60860 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60861 + role = lookup_acl_role_label(task, uid, gid);
60862 +
60863 + /* don't change the role if we're not a privileged process */
60864 + if (role && task->role != role &&
60865 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60866 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60867 + return;
60868 +
60869 + /* perform subject lookup in possibly new role
60870 + we can use this result below in the case where role == task->role
60871 + */
60872 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60873 +
60874 + /* if we changed uid/gid, but result in the same role
60875 + and are using inheritance, don't lose the inherited subject
60876 + if current subject is other than what normal lookup
60877 + would result in, we arrived via inheritance, don't
60878 + lose subject
60879 + */
60880 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60881 + (subj == task->acl)))
60882 + task->acl = subj;
60883 +
60884 + task->role = role;
60885 +
60886 + task->is_writable = 0;
60887 +
60888 + /* ignore additional mmap checks for processes that are writable
60889 + by the default ACL */
60890 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60891 + if (unlikely(obj->mode & GR_WRITE))
60892 + task->is_writable = 1;
60893 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60894 + if (unlikely(obj->mode & GR_WRITE))
60895 + task->is_writable = 1;
60896 +
60897 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60898 + 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);
60899 +#endif
60900 +
60901 + gr_set_proc_res(task);
60902 +
60903 + return;
60904 +}
60905 +
60906 +int
60907 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60908 + const int unsafe_flags)
60909 +{
60910 + struct task_struct *task = current;
60911 + struct acl_subject_label *newacl;
60912 + struct acl_object_label *obj;
60913 + __u32 retmode;
60914 +
60915 + if (unlikely(!(gr_status & GR_READY)))
60916 + return 0;
60917 +
60918 + newacl = chk_subj_label(dentry, mnt, task->role);
60919 +
60920 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60921 + did an exec
60922 + */
60923 + rcu_read_lock();
60924 + read_lock(&tasklist_lock);
60925 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60926 + (task->parent->acl->mode & GR_POVERRIDE))) {
60927 + read_unlock(&tasklist_lock);
60928 + rcu_read_unlock();
60929 + goto skip_check;
60930 + }
60931 + read_unlock(&tasklist_lock);
60932 + rcu_read_unlock();
60933 +
60934 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60935 + !(task->role->roletype & GR_ROLE_GOD) &&
60936 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60937 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60938 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60939 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60940 + else
60941 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60942 + return -EACCES;
60943 + }
60944 +
60945 +skip_check:
60946 +
60947 + obj = chk_obj_label(dentry, mnt, task->acl);
60948 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60949 +
60950 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60951 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60952 + if (obj->nested)
60953 + task->acl = obj->nested;
60954 + else
60955 + task->acl = newacl;
60956 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60957 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60958 +
60959 + task->is_writable = 0;
60960 +
60961 + /* ignore additional mmap checks for processes that are writable
60962 + by the default ACL */
60963 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60964 + if (unlikely(obj->mode & GR_WRITE))
60965 + task->is_writable = 1;
60966 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60967 + if (unlikely(obj->mode & GR_WRITE))
60968 + task->is_writable = 1;
60969 +
60970 + gr_set_proc_res(task);
60971 +
60972 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60973 + 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);
60974 +#endif
60975 + return 0;
60976 +}
60977 +
60978 +/* always called with valid inodev ptr */
60979 +static void
60980 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60981 +{
60982 + struct acl_object_label *matchpo;
60983 + struct acl_subject_label *matchps;
60984 + struct acl_subject_label *subj;
60985 + struct acl_role_label *role;
60986 + unsigned int x;
60987 +
60988 + FOR_EACH_ROLE_START(role)
60989 + FOR_EACH_SUBJECT_START(role, subj, x)
60990 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60991 + matchpo->mode |= GR_DELETED;
60992 + FOR_EACH_SUBJECT_END(subj,x)
60993 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60994 + /* nested subjects aren't in the role's subj_hash table */
60995 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60996 + matchpo->mode |= GR_DELETED;
60997 + FOR_EACH_NESTED_SUBJECT_END(subj)
60998 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60999 + matchps->mode |= GR_DELETED;
61000 + FOR_EACH_ROLE_END(role)
61001 +
61002 + inodev->nentry->deleted = 1;
61003 +
61004 + return;
61005 +}
61006 +
61007 +void
61008 +gr_handle_delete(const ino_t ino, const dev_t dev)
61009 +{
61010 + struct inodev_entry *inodev;
61011 +
61012 + if (unlikely(!(gr_status & GR_READY)))
61013 + return;
61014 +
61015 + write_lock(&gr_inode_lock);
61016 + inodev = lookup_inodev_entry(ino, dev);
61017 + if (inodev != NULL)
61018 + do_handle_delete(inodev, ino, dev);
61019 + write_unlock(&gr_inode_lock);
61020 +
61021 + return;
61022 +}
61023 +
61024 +static void
61025 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
61026 + const ino_t newinode, const dev_t newdevice,
61027 + struct acl_subject_label *subj)
61028 +{
61029 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
61030 + struct acl_object_label *match;
61031 +
61032 + match = subj->obj_hash[index];
61033 +
61034 + while (match && (match->inode != oldinode ||
61035 + match->device != olddevice ||
61036 + !(match->mode & GR_DELETED)))
61037 + match = match->next;
61038 +
61039 + if (match && (match->inode == oldinode)
61040 + && (match->device == olddevice)
61041 + && (match->mode & GR_DELETED)) {
61042 + if (match->prev == NULL) {
61043 + subj->obj_hash[index] = match->next;
61044 + if (match->next != NULL)
61045 + match->next->prev = NULL;
61046 + } else {
61047 + match->prev->next = match->next;
61048 + if (match->next != NULL)
61049 + match->next->prev = match->prev;
61050 + }
61051 + match->prev = NULL;
61052 + match->next = NULL;
61053 + match->inode = newinode;
61054 + match->device = newdevice;
61055 + match->mode &= ~GR_DELETED;
61056 +
61057 + insert_acl_obj_label(match, subj);
61058 + }
61059 +
61060 + return;
61061 +}
61062 +
61063 +static void
61064 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
61065 + const ino_t newinode, const dev_t newdevice,
61066 + struct acl_role_label *role)
61067 +{
61068 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
61069 + struct acl_subject_label *match;
61070 +
61071 + match = role->subj_hash[index];
61072 +
61073 + while (match && (match->inode != oldinode ||
61074 + match->device != olddevice ||
61075 + !(match->mode & GR_DELETED)))
61076 + match = match->next;
61077 +
61078 + if (match && (match->inode == oldinode)
61079 + && (match->device == olddevice)
61080 + && (match->mode & GR_DELETED)) {
61081 + if (match->prev == NULL) {
61082 + role->subj_hash[index] = match->next;
61083 + if (match->next != NULL)
61084 + match->next->prev = NULL;
61085 + } else {
61086 + match->prev->next = match->next;
61087 + if (match->next != NULL)
61088 + match->next->prev = match->prev;
61089 + }
61090 + match->prev = NULL;
61091 + match->next = NULL;
61092 + match->inode = newinode;
61093 + match->device = newdevice;
61094 + match->mode &= ~GR_DELETED;
61095 +
61096 + insert_acl_subj_label(match, role);
61097 + }
61098 +
61099 + return;
61100 +}
61101 +
61102 +static void
61103 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61104 + const ino_t newinode, const dev_t newdevice)
61105 +{
61106 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61107 + struct inodev_entry *match;
61108 +
61109 + match = inodev_set.i_hash[index];
61110 +
61111 + while (match && (match->nentry->inode != oldinode ||
61112 + match->nentry->device != olddevice || !match->nentry->deleted))
61113 + match = match->next;
61114 +
61115 + if (match && (match->nentry->inode == oldinode)
61116 + && (match->nentry->device == olddevice) &&
61117 + match->nentry->deleted) {
61118 + if (match->prev == NULL) {
61119 + inodev_set.i_hash[index] = match->next;
61120 + if (match->next != NULL)
61121 + match->next->prev = NULL;
61122 + } else {
61123 + match->prev->next = match->next;
61124 + if (match->next != NULL)
61125 + match->next->prev = match->prev;
61126 + }
61127 + match->prev = NULL;
61128 + match->next = NULL;
61129 + match->nentry->inode = newinode;
61130 + match->nentry->device = newdevice;
61131 + match->nentry->deleted = 0;
61132 +
61133 + insert_inodev_entry(match);
61134 + }
61135 +
61136 + return;
61137 +}
61138 +
61139 +static void
61140 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61141 +{
61142 + struct acl_subject_label *subj;
61143 + struct acl_role_label *role;
61144 + unsigned int x;
61145 +
61146 + FOR_EACH_ROLE_START(role)
61147 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61148 +
61149 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61150 + if ((subj->inode == ino) && (subj->device == dev)) {
61151 + subj->inode = ino;
61152 + subj->device = dev;
61153 + }
61154 + /* nested subjects aren't in the role's subj_hash table */
61155 + update_acl_obj_label(matchn->inode, matchn->device,
61156 + ino, dev, subj);
61157 + FOR_EACH_NESTED_SUBJECT_END(subj)
61158 + FOR_EACH_SUBJECT_START(role, subj, x)
61159 + update_acl_obj_label(matchn->inode, matchn->device,
61160 + ino, dev, subj);
61161 + FOR_EACH_SUBJECT_END(subj,x)
61162 + FOR_EACH_ROLE_END(role)
61163 +
61164 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61165 +
61166 + return;
61167 +}
61168 +
61169 +static void
61170 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61171 + const struct vfsmount *mnt)
61172 +{
61173 + ino_t ino = dentry->d_inode->i_ino;
61174 + dev_t dev = __get_dev(dentry);
61175 +
61176 + __do_handle_create(matchn, ino, dev);
61177 +
61178 + return;
61179 +}
61180 +
61181 +void
61182 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61183 +{
61184 + struct name_entry *matchn;
61185 +
61186 + if (unlikely(!(gr_status & GR_READY)))
61187 + return;
61188 +
61189 + preempt_disable();
61190 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61191 +
61192 + if (unlikely((unsigned long)matchn)) {
61193 + write_lock(&gr_inode_lock);
61194 + do_handle_create(matchn, dentry, mnt);
61195 + write_unlock(&gr_inode_lock);
61196 + }
61197 + preempt_enable();
61198 +
61199 + return;
61200 +}
61201 +
61202 +void
61203 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61204 +{
61205 + struct name_entry *matchn;
61206 +
61207 + if (unlikely(!(gr_status & GR_READY)))
61208 + return;
61209 +
61210 + preempt_disable();
61211 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61212 +
61213 + if (unlikely((unsigned long)matchn)) {
61214 + write_lock(&gr_inode_lock);
61215 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61216 + write_unlock(&gr_inode_lock);
61217 + }
61218 + preempt_enable();
61219 +
61220 + return;
61221 +}
61222 +
61223 +void
61224 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61225 + struct dentry *old_dentry,
61226 + struct dentry *new_dentry,
61227 + struct vfsmount *mnt, const __u8 replace)
61228 +{
61229 + struct name_entry *matchn;
61230 + struct inodev_entry *inodev;
61231 + struct inode *inode = new_dentry->d_inode;
61232 + ino_t old_ino = old_dentry->d_inode->i_ino;
61233 + dev_t old_dev = __get_dev(old_dentry);
61234 +
61235 + /* vfs_rename swaps the name and parent link for old_dentry and
61236 + new_dentry
61237 + at this point, old_dentry has the new name, parent link, and inode
61238 + for the renamed file
61239 + if a file is being replaced by a rename, new_dentry has the inode
61240 + and name for the replaced file
61241 + */
61242 +
61243 + if (unlikely(!(gr_status & GR_READY)))
61244 + return;
61245 +
61246 + preempt_disable();
61247 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61248 +
61249 + /* we wouldn't have to check d_inode if it weren't for
61250 + NFS silly-renaming
61251 + */
61252 +
61253 + write_lock(&gr_inode_lock);
61254 + if (unlikely(replace && inode)) {
61255 + ino_t new_ino = inode->i_ino;
61256 + dev_t new_dev = __get_dev(new_dentry);
61257 +
61258 + inodev = lookup_inodev_entry(new_ino, new_dev);
61259 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61260 + do_handle_delete(inodev, new_ino, new_dev);
61261 + }
61262 +
61263 + inodev = lookup_inodev_entry(old_ino, old_dev);
61264 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61265 + do_handle_delete(inodev, old_ino, old_dev);
61266 +
61267 + if (unlikely((unsigned long)matchn))
61268 + do_handle_create(matchn, old_dentry, mnt);
61269 +
61270 + write_unlock(&gr_inode_lock);
61271 + preempt_enable();
61272 +
61273 + return;
61274 +}
61275 +
61276 +static int
61277 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61278 + unsigned char **sum)
61279 +{
61280 + struct acl_role_label *r;
61281 + struct role_allowed_ip *ipp;
61282 + struct role_transition *trans;
61283 + unsigned int i;
61284 + int found = 0;
61285 + u32 curr_ip = current->signal->curr_ip;
61286 +
61287 + current->signal->saved_ip = curr_ip;
61288 +
61289 + /* check transition table */
61290 +
61291 + for (trans = current->role->transitions; trans; trans = trans->next) {
61292 + if (!strcmp(rolename, trans->rolename)) {
61293 + found = 1;
61294 + break;
61295 + }
61296 + }
61297 +
61298 + if (!found)
61299 + return 0;
61300 +
61301 + /* handle special roles that do not require authentication
61302 + and check ip */
61303 +
61304 + FOR_EACH_ROLE_START(r)
61305 + if (!strcmp(rolename, r->rolename) &&
61306 + (r->roletype & GR_ROLE_SPECIAL)) {
61307 + found = 0;
61308 + if (r->allowed_ips != NULL) {
61309 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61310 + if ((ntohl(curr_ip) & ipp->netmask) ==
61311 + (ntohl(ipp->addr) & ipp->netmask))
61312 + found = 1;
61313 + }
61314 + } else
61315 + found = 2;
61316 + if (!found)
61317 + return 0;
61318 +
61319 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61320 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61321 + *salt = NULL;
61322 + *sum = NULL;
61323 + return 1;
61324 + }
61325 + }
61326 + FOR_EACH_ROLE_END(r)
61327 +
61328 + for (i = 0; i < num_sprole_pws; i++) {
61329 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61330 + *salt = acl_special_roles[i]->salt;
61331 + *sum = acl_special_roles[i]->sum;
61332 + return 1;
61333 + }
61334 + }
61335 +
61336 + return 0;
61337 +}
61338 +
61339 +static void
61340 +assign_special_role(char *rolename)
61341 +{
61342 + struct acl_object_label *obj;
61343 + struct acl_role_label *r;
61344 + struct acl_role_label *assigned = NULL;
61345 + struct task_struct *tsk;
61346 + struct file *filp;
61347 +
61348 + FOR_EACH_ROLE_START(r)
61349 + if (!strcmp(rolename, r->rolename) &&
61350 + (r->roletype & GR_ROLE_SPECIAL)) {
61351 + assigned = r;
61352 + break;
61353 + }
61354 + FOR_EACH_ROLE_END(r)
61355 +
61356 + if (!assigned)
61357 + return;
61358 +
61359 + read_lock(&tasklist_lock);
61360 + read_lock(&grsec_exec_file_lock);
61361 +
61362 + tsk = current->real_parent;
61363 + if (tsk == NULL)
61364 + goto out_unlock;
61365 +
61366 + filp = tsk->exec_file;
61367 + if (filp == NULL)
61368 + goto out_unlock;
61369 +
61370 + tsk->is_writable = 0;
61371 +
61372 + tsk->acl_sp_role = 1;
61373 + tsk->acl_role_id = ++acl_sp_role_value;
61374 + tsk->role = assigned;
61375 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61376 +
61377 + /* ignore additional mmap checks for processes that are writable
61378 + by the default ACL */
61379 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61380 + if (unlikely(obj->mode & GR_WRITE))
61381 + tsk->is_writable = 1;
61382 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61383 + if (unlikely(obj->mode & GR_WRITE))
61384 + tsk->is_writable = 1;
61385 +
61386 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61387 + 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));
61388 +#endif
61389 +
61390 +out_unlock:
61391 + read_unlock(&grsec_exec_file_lock);
61392 + read_unlock(&tasklist_lock);
61393 + return;
61394 +}
61395 +
61396 +int gr_check_secure_terminal(struct task_struct *task)
61397 +{
61398 + struct task_struct *p, *p2, *p3;
61399 + struct files_struct *files;
61400 + struct fdtable *fdt;
61401 + struct file *our_file = NULL, *file;
61402 + int i;
61403 +
61404 + if (task->signal->tty == NULL)
61405 + return 1;
61406 +
61407 + files = get_files_struct(task);
61408 + if (files != NULL) {
61409 + rcu_read_lock();
61410 + fdt = files_fdtable(files);
61411 + for (i=0; i < fdt->max_fds; i++) {
61412 + file = fcheck_files(files, i);
61413 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61414 + get_file(file);
61415 + our_file = file;
61416 + }
61417 + }
61418 + rcu_read_unlock();
61419 + put_files_struct(files);
61420 + }
61421 +
61422 + if (our_file == NULL)
61423 + return 1;
61424 +
61425 + read_lock(&tasklist_lock);
61426 + do_each_thread(p2, p) {
61427 + files = get_files_struct(p);
61428 + if (files == NULL ||
61429 + (p->signal && p->signal->tty == task->signal->tty)) {
61430 + if (files != NULL)
61431 + put_files_struct(files);
61432 + continue;
61433 + }
61434 + rcu_read_lock();
61435 + fdt = files_fdtable(files);
61436 + for (i=0; i < fdt->max_fds; i++) {
61437 + file = fcheck_files(files, i);
61438 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61439 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61440 + p3 = task;
61441 + while (task_pid_nr(p3) > 0) {
61442 + if (p3 == p)
61443 + break;
61444 + p3 = p3->real_parent;
61445 + }
61446 + if (p3 == p)
61447 + break;
61448 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61449 + gr_handle_alertkill(p);
61450 + rcu_read_unlock();
61451 + put_files_struct(files);
61452 + read_unlock(&tasklist_lock);
61453 + fput(our_file);
61454 + return 0;
61455 + }
61456 + }
61457 + rcu_read_unlock();
61458 + put_files_struct(files);
61459 + } while_each_thread(p2, p);
61460 + read_unlock(&tasklist_lock);
61461 +
61462 + fput(our_file);
61463 + return 1;
61464 +}
61465 +
61466 +static int gr_rbac_disable(void *unused)
61467 +{
61468 + pax_open_kernel();
61469 + gr_status &= ~GR_READY;
61470 + pax_close_kernel();
61471 +
61472 + return 0;
61473 +}
61474 +
61475 +ssize_t
61476 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61477 +{
61478 + struct gr_arg_wrapper uwrap;
61479 + unsigned char *sprole_salt = NULL;
61480 + unsigned char *sprole_sum = NULL;
61481 + int error = sizeof (struct gr_arg_wrapper);
61482 + int error2 = 0;
61483 +
61484 + mutex_lock(&gr_dev_mutex);
61485 +
61486 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61487 + error = -EPERM;
61488 + goto out;
61489 + }
61490 +
61491 + if (count != sizeof (struct gr_arg_wrapper)) {
61492 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61493 + error = -EINVAL;
61494 + goto out;
61495 + }
61496 +
61497 +
61498 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61499 + gr_auth_expires = 0;
61500 + gr_auth_attempts = 0;
61501 + }
61502 +
61503 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61504 + error = -EFAULT;
61505 + goto out;
61506 + }
61507 +
61508 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61509 + error = -EINVAL;
61510 + goto out;
61511 + }
61512 +
61513 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61514 + error = -EFAULT;
61515 + goto out;
61516 + }
61517 +
61518 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61519 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61520 + time_after(gr_auth_expires, get_seconds())) {
61521 + error = -EBUSY;
61522 + goto out;
61523 + }
61524 +
61525 + /* if non-root trying to do anything other than use a special role,
61526 + do not attempt authentication, do not count towards authentication
61527 + locking
61528 + */
61529 +
61530 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61531 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61532 + gr_is_global_nonroot(current_uid())) {
61533 + error = -EPERM;
61534 + goto out;
61535 + }
61536 +
61537 + /* ensure pw and special role name are null terminated */
61538 +
61539 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61540 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61541 +
61542 + /* Okay.
61543 + * We have our enough of the argument structure..(we have yet
61544 + * to copy_from_user the tables themselves) . Copy the tables
61545 + * only if we need them, i.e. for loading operations. */
61546 +
61547 + switch (gr_usermode->mode) {
61548 + case GR_STATUS:
61549 + if (gr_status & GR_READY) {
61550 + error = 1;
61551 + if (!gr_check_secure_terminal(current))
61552 + error = 3;
61553 + } else
61554 + error = 2;
61555 + goto out;
61556 + case GR_SHUTDOWN:
61557 + if ((gr_status & GR_READY)
61558 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61559 + stop_machine(gr_rbac_disable, NULL, NULL);
61560 + free_variables();
61561 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61562 + memset(gr_system_salt, 0, GR_SALT_LEN);
61563 + memset(gr_system_sum, 0, GR_SHA_LEN);
61564 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61565 + } else if (gr_status & GR_READY) {
61566 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61567 + error = -EPERM;
61568 + } else {
61569 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61570 + error = -EAGAIN;
61571 + }
61572 + break;
61573 + case GR_ENABLE:
61574 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61575 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61576 + else {
61577 + if (gr_status & GR_READY)
61578 + error = -EAGAIN;
61579 + else
61580 + error = error2;
61581 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61582 + }
61583 + break;
61584 + case GR_RELOAD:
61585 + if (!(gr_status & GR_READY)) {
61586 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61587 + error = -EAGAIN;
61588 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61589 + stop_machine(gr_rbac_disable, NULL, NULL);
61590 + free_variables();
61591 + error2 = gracl_init(gr_usermode);
61592 + if (!error2)
61593 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61594 + else {
61595 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61596 + error = error2;
61597 + }
61598 + } else {
61599 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61600 + error = -EPERM;
61601 + }
61602 + break;
61603 + case GR_SEGVMOD:
61604 + if (unlikely(!(gr_status & GR_READY))) {
61605 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61606 + error = -EAGAIN;
61607 + break;
61608 + }
61609 +
61610 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61611 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61612 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61613 + struct acl_subject_label *segvacl;
61614 + segvacl =
61615 + lookup_acl_subj_label(gr_usermode->segv_inode,
61616 + gr_usermode->segv_device,
61617 + current->role);
61618 + if (segvacl) {
61619 + segvacl->crashes = 0;
61620 + segvacl->expires = 0;
61621 + }
61622 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61623 + gr_remove_uid(gr_usermode->segv_uid);
61624 + }
61625 + } else {
61626 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61627 + error = -EPERM;
61628 + }
61629 + break;
61630 + case GR_SPROLE:
61631 + case GR_SPROLEPAM:
61632 + if (unlikely(!(gr_status & GR_READY))) {
61633 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61634 + error = -EAGAIN;
61635 + break;
61636 + }
61637 +
61638 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61639 + current->role->expires = 0;
61640 + current->role->auth_attempts = 0;
61641 + }
61642 +
61643 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61644 + time_after(current->role->expires, get_seconds())) {
61645 + error = -EBUSY;
61646 + goto out;
61647 + }
61648 +
61649 + if (lookup_special_role_auth
61650 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61651 + && ((!sprole_salt && !sprole_sum)
61652 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61653 + char *p = "";
61654 + assign_special_role(gr_usermode->sp_role);
61655 + read_lock(&tasklist_lock);
61656 + if (current->real_parent)
61657 + p = current->real_parent->role->rolename;
61658 + read_unlock(&tasklist_lock);
61659 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61660 + p, acl_sp_role_value);
61661 + } else {
61662 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61663 + error = -EPERM;
61664 + if(!(current->role->auth_attempts++))
61665 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61666 +
61667 + goto out;
61668 + }
61669 + break;
61670 + case GR_UNSPROLE:
61671 + if (unlikely(!(gr_status & GR_READY))) {
61672 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61673 + error = -EAGAIN;
61674 + break;
61675 + }
61676 +
61677 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61678 + char *p = "";
61679 + int i = 0;
61680 +
61681 + read_lock(&tasklist_lock);
61682 + if (current->real_parent) {
61683 + p = current->real_parent->role->rolename;
61684 + i = current->real_parent->acl_role_id;
61685 + }
61686 + read_unlock(&tasklist_lock);
61687 +
61688 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61689 + gr_set_acls(1);
61690 + } else {
61691 + error = -EPERM;
61692 + goto out;
61693 + }
61694 + break;
61695 + default:
61696 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61697 + error = -EINVAL;
61698 + break;
61699 + }
61700 +
61701 + if (error != -EPERM)
61702 + goto out;
61703 +
61704 + if(!(gr_auth_attempts++))
61705 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61706 +
61707 + out:
61708 + mutex_unlock(&gr_dev_mutex);
61709 + return error;
61710 +}
61711 +
61712 +/* must be called with
61713 + rcu_read_lock();
61714 + read_lock(&tasklist_lock);
61715 + read_lock(&grsec_exec_file_lock);
61716 +*/
61717 +int gr_apply_subject_to_task(struct task_struct *task)
61718 +{
61719 + struct acl_object_label *obj;
61720 + char *tmpname;
61721 + struct acl_subject_label *tmpsubj;
61722 + struct file *filp;
61723 + struct name_entry *nmatch;
61724 +
61725 + filp = task->exec_file;
61726 + if (filp == NULL)
61727 + return 0;
61728 +
61729 + /* the following is to apply the correct subject
61730 + on binaries running when the RBAC system
61731 + is enabled, when the binaries have been
61732 + replaced or deleted since their execution
61733 + -----
61734 + when the RBAC system starts, the inode/dev
61735 + from exec_file will be one the RBAC system
61736 + is unaware of. It only knows the inode/dev
61737 + of the present file on disk, or the absence
61738 + of it.
61739 + */
61740 + preempt_disable();
61741 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61742 +
61743 + nmatch = lookup_name_entry(tmpname);
61744 + preempt_enable();
61745 + tmpsubj = NULL;
61746 + if (nmatch) {
61747 + if (nmatch->deleted)
61748 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61749 + else
61750 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61751 + if (tmpsubj != NULL)
61752 + task->acl = tmpsubj;
61753 + }
61754 + if (tmpsubj == NULL)
61755 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61756 + task->role);
61757 + if (task->acl) {
61758 + task->is_writable = 0;
61759 + /* ignore additional mmap checks for processes that are writable
61760 + by the default ACL */
61761 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61762 + if (unlikely(obj->mode & GR_WRITE))
61763 + task->is_writable = 1;
61764 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61765 + if (unlikely(obj->mode & GR_WRITE))
61766 + task->is_writable = 1;
61767 +
61768 + gr_set_proc_res(task);
61769 +
61770 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61771 + 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);
61772 +#endif
61773 + } else {
61774 + return 1;
61775 + }
61776 +
61777 + return 0;
61778 +}
61779 +
61780 +int
61781 +gr_set_acls(const int type)
61782 +{
61783 + struct task_struct *task, *task2;
61784 + struct acl_role_label *role = current->role;
61785 + __u16 acl_role_id = current->acl_role_id;
61786 + const struct cred *cred;
61787 + int ret;
61788 +
61789 + rcu_read_lock();
61790 + read_lock(&tasklist_lock);
61791 + read_lock(&grsec_exec_file_lock);
61792 + do_each_thread(task2, task) {
61793 + /* check to see if we're called from the exit handler,
61794 + if so, only replace ACLs that have inherited the admin
61795 + ACL */
61796 +
61797 + if (type && (task->role != role ||
61798 + task->acl_role_id != acl_role_id))
61799 + continue;
61800 +
61801 + task->acl_role_id = 0;
61802 + task->acl_sp_role = 0;
61803 +
61804 + if (task->exec_file) {
61805 + cred = __task_cred(task);
61806 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61807 + ret = gr_apply_subject_to_task(task);
61808 + if (ret) {
61809 + read_unlock(&grsec_exec_file_lock);
61810 + read_unlock(&tasklist_lock);
61811 + rcu_read_unlock();
61812 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61813 + return ret;
61814 + }
61815 + } else {
61816 + // it's a kernel process
61817 + task->role = kernel_role;
61818 + task->acl = kernel_role->root_label;
61819 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61820 + task->acl->mode &= ~GR_PROCFIND;
61821 +#endif
61822 + }
61823 + } while_each_thread(task2, task);
61824 + read_unlock(&grsec_exec_file_lock);
61825 + read_unlock(&tasklist_lock);
61826 + rcu_read_unlock();
61827 +
61828 + return 0;
61829 +}
61830 +
61831 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61832 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61833 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61834 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61835 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61836 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61837 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61838 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61839 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61840 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61841 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61842 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61843 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61844 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61845 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61846 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61847 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61848 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61849 +};
61850 +
61851 +void
61852 +gr_learn_resource(const struct task_struct *task,
61853 + const int res, const unsigned long wanted, const int gt)
61854 +{
61855 + struct acl_subject_label *acl;
61856 + const struct cred *cred;
61857 +
61858 + if (unlikely((gr_status & GR_READY) &&
61859 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61860 + goto skip_reslog;
61861 +
61862 + gr_log_resource(task, res, wanted, gt);
61863 +skip_reslog:
61864 +
61865 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61866 + return;
61867 +
61868 + acl = task->acl;
61869 +
61870 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61871 + !(acl->resmask & (1U << (unsigned short) res))))
61872 + return;
61873 +
61874 + if (wanted >= acl->res[res].rlim_cur) {
61875 + unsigned long res_add;
61876 +
61877 + res_add = wanted + res_learn_bumps[res];
61878 +
61879 + acl->res[res].rlim_cur = res_add;
61880 +
61881 + if (wanted > acl->res[res].rlim_max)
61882 + acl->res[res].rlim_max = res_add;
61883 +
61884 + /* only log the subject filename, since resource logging is supported for
61885 + single-subject learning only */
61886 + rcu_read_lock();
61887 + cred = __task_cred(task);
61888 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61889 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61890 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61891 + "", (unsigned long) res, &task->signal->saved_ip);
61892 + rcu_read_unlock();
61893 + }
61894 +
61895 + return;
61896 +}
61897 +EXPORT_SYMBOL(gr_learn_resource);
61898 +#endif
61899 +
61900 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61901 +void
61902 +pax_set_initial_flags(struct linux_binprm *bprm)
61903 +{
61904 + struct task_struct *task = current;
61905 + struct acl_subject_label *proc;
61906 + unsigned long flags;
61907 +
61908 + if (unlikely(!(gr_status & GR_READY)))
61909 + return;
61910 +
61911 + flags = pax_get_flags(task);
61912 +
61913 + proc = task->acl;
61914 +
61915 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61916 + flags &= ~MF_PAX_PAGEEXEC;
61917 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61918 + flags &= ~MF_PAX_SEGMEXEC;
61919 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61920 + flags &= ~MF_PAX_RANDMMAP;
61921 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61922 + flags &= ~MF_PAX_EMUTRAMP;
61923 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61924 + flags &= ~MF_PAX_MPROTECT;
61925 +
61926 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61927 + flags |= MF_PAX_PAGEEXEC;
61928 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61929 + flags |= MF_PAX_SEGMEXEC;
61930 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61931 + flags |= MF_PAX_RANDMMAP;
61932 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61933 + flags |= MF_PAX_EMUTRAMP;
61934 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61935 + flags |= MF_PAX_MPROTECT;
61936 +
61937 + pax_set_flags(task, flags);
61938 +
61939 + return;
61940 +}
61941 +#endif
61942 +
61943 +int
61944 +gr_handle_proc_ptrace(struct task_struct *task)
61945 +{
61946 + struct file *filp;
61947 + struct task_struct *tmp = task;
61948 + struct task_struct *curtemp = current;
61949 + __u32 retmode;
61950 +
61951 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61952 + if (unlikely(!(gr_status & GR_READY)))
61953 + return 0;
61954 +#endif
61955 +
61956 + read_lock(&tasklist_lock);
61957 + read_lock(&grsec_exec_file_lock);
61958 + filp = task->exec_file;
61959 +
61960 + while (task_pid_nr(tmp) > 0) {
61961 + if (tmp == curtemp)
61962 + break;
61963 + tmp = tmp->real_parent;
61964 + }
61965 +
61966 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61967 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61968 + read_unlock(&grsec_exec_file_lock);
61969 + read_unlock(&tasklist_lock);
61970 + return 1;
61971 + }
61972 +
61973 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61974 + if (!(gr_status & GR_READY)) {
61975 + read_unlock(&grsec_exec_file_lock);
61976 + read_unlock(&tasklist_lock);
61977 + return 0;
61978 + }
61979 +#endif
61980 +
61981 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61982 + read_unlock(&grsec_exec_file_lock);
61983 + read_unlock(&tasklist_lock);
61984 +
61985 + if (retmode & GR_NOPTRACE)
61986 + return 1;
61987 +
61988 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61989 + && (current->acl != task->acl || (current->acl != current->role->root_label
61990 + && task_pid_nr(current) != task_pid_nr(task))))
61991 + return 1;
61992 +
61993 + return 0;
61994 +}
61995 +
61996 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61997 +{
61998 + if (unlikely(!(gr_status & GR_READY)))
61999 + return;
62000 +
62001 + if (!(current->role->roletype & GR_ROLE_GOD))
62002 + return;
62003 +
62004 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
62005 + p->role->rolename, gr_task_roletype_to_char(p),
62006 + p->acl->filename);
62007 +}
62008 +
62009 +int
62010 +gr_handle_ptrace(struct task_struct *task, const long request)
62011 +{
62012 + struct task_struct *tmp = task;
62013 + struct task_struct *curtemp = current;
62014 + __u32 retmode;
62015 +
62016 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62017 + if (unlikely(!(gr_status & GR_READY)))
62018 + return 0;
62019 +#endif
62020 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
62021 + read_lock(&tasklist_lock);
62022 + while (task_pid_nr(tmp) > 0) {
62023 + if (tmp == curtemp)
62024 + break;
62025 + tmp = tmp->real_parent;
62026 + }
62027 +
62028 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62029 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
62030 + read_unlock(&tasklist_lock);
62031 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62032 + return 1;
62033 + }
62034 + read_unlock(&tasklist_lock);
62035 + }
62036 +
62037 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62038 + if (!(gr_status & GR_READY))
62039 + return 0;
62040 +#endif
62041 +
62042 + read_lock(&grsec_exec_file_lock);
62043 + if (unlikely(!task->exec_file)) {
62044 + read_unlock(&grsec_exec_file_lock);
62045 + return 0;
62046 + }
62047 +
62048 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
62049 + read_unlock(&grsec_exec_file_lock);
62050 +
62051 + if (retmode & GR_NOPTRACE) {
62052 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62053 + return 1;
62054 + }
62055 +
62056 + if (retmode & GR_PTRACERD) {
62057 + switch (request) {
62058 + case PTRACE_SEIZE:
62059 + case PTRACE_POKETEXT:
62060 + case PTRACE_POKEDATA:
62061 + case PTRACE_POKEUSR:
62062 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
62063 + case PTRACE_SETREGS:
62064 + case PTRACE_SETFPREGS:
62065 +#endif
62066 +#ifdef CONFIG_X86
62067 + case PTRACE_SETFPXREGS:
62068 +#endif
62069 +#ifdef CONFIG_ALTIVEC
62070 + case PTRACE_SETVRREGS:
62071 +#endif
62072 + return 1;
62073 + default:
62074 + return 0;
62075 + }
62076 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
62077 + !(current->role->roletype & GR_ROLE_GOD) &&
62078 + (current->acl != task->acl)) {
62079 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62080 + return 1;
62081 + }
62082 +
62083 + return 0;
62084 +}
62085 +
62086 +static int is_writable_mmap(const struct file *filp)
62087 +{
62088 + struct task_struct *task = current;
62089 + struct acl_object_label *obj, *obj2;
62090 +
62091 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62092 + !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))) {
62093 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62094 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62095 + task->role->root_label);
62096 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62097 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62098 + return 1;
62099 + }
62100 + }
62101 + return 0;
62102 +}
62103 +
62104 +int
62105 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62106 +{
62107 + __u32 mode;
62108 +
62109 + if (unlikely(!file || !(prot & PROT_EXEC)))
62110 + return 1;
62111 +
62112 + if (is_writable_mmap(file))
62113 + return 0;
62114 +
62115 + mode =
62116 + gr_search_file(file->f_path.dentry,
62117 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62118 + file->f_path.mnt);
62119 +
62120 + if (!gr_tpe_allow(file))
62121 + return 0;
62122 +
62123 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62124 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62125 + return 0;
62126 + } else if (unlikely(!(mode & GR_EXEC))) {
62127 + return 0;
62128 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62129 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62130 + return 1;
62131 + }
62132 +
62133 + return 1;
62134 +}
62135 +
62136 +int
62137 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62138 +{
62139 + __u32 mode;
62140 +
62141 + if (unlikely(!file || !(prot & PROT_EXEC)))
62142 + return 1;
62143 +
62144 + if (is_writable_mmap(file))
62145 + return 0;
62146 +
62147 + mode =
62148 + gr_search_file(file->f_path.dentry,
62149 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62150 + file->f_path.mnt);
62151 +
62152 + if (!gr_tpe_allow(file))
62153 + return 0;
62154 +
62155 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62156 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62157 + return 0;
62158 + } else if (unlikely(!(mode & GR_EXEC))) {
62159 + return 0;
62160 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62161 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62162 + return 1;
62163 + }
62164 +
62165 + return 1;
62166 +}
62167 +
62168 +void
62169 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62170 +{
62171 + unsigned long runtime;
62172 + unsigned long cputime;
62173 + unsigned int wday, cday;
62174 + __u8 whr, chr;
62175 + __u8 wmin, cmin;
62176 + __u8 wsec, csec;
62177 + struct timespec timeval;
62178 +
62179 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62180 + !(task->acl->mode & GR_PROCACCT)))
62181 + return;
62182 +
62183 + do_posix_clock_monotonic_gettime(&timeval);
62184 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62185 + wday = runtime / (3600 * 24);
62186 + runtime -= wday * (3600 * 24);
62187 + whr = runtime / 3600;
62188 + runtime -= whr * 3600;
62189 + wmin = runtime / 60;
62190 + runtime -= wmin * 60;
62191 + wsec = runtime;
62192 +
62193 + cputime = (task->utime + task->stime) / HZ;
62194 + cday = cputime / (3600 * 24);
62195 + cputime -= cday * (3600 * 24);
62196 + chr = cputime / 3600;
62197 + cputime -= chr * 3600;
62198 + cmin = cputime / 60;
62199 + cputime -= cmin * 60;
62200 + csec = cputime;
62201 +
62202 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62203 +
62204 + return;
62205 +}
62206 +
62207 +void gr_set_kernel_label(struct task_struct *task)
62208 +{
62209 + if (gr_status & GR_READY) {
62210 + task->role = kernel_role;
62211 + task->acl = kernel_role->root_label;
62212 + }
62213 + return;
62214 +}
62215 +
62216 +#ifdef CONFIG_TASKSTATS
62217 +int gr_is_taskstats_denied(int pid)
62218 +{
62219 + struct task_struct *task;
62220 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62221 + const struct cred *cred;
62222 +#endif
62223 + int ret = 0;
62224 +
62225 + /* restrict taskstats viewing to un-chrooted root users
62226 + who have the 'view' subject flag if the RBAC system is enabled
62227 + */
62228 +
62229 + rcu_read_lock();
62230 + read_lock(&tasklist_lock);
62231 + task = find_task_by_vpid(pid);
62232 + if (task) {
62233 +#ifdef CONFIG_GRKERNSEC_CHROOT
62234 + if (proc_is_chrooted(task))
62235 + ret = -EACCES;
62236 +#endif
62237 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62238 + cred = __task_cred(task);
62239 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62240 + if (gr_is_global_nonroot(cred->uid))
62241 + ret = -EACCES;
62242 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62243 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62244 + ret = -EACCES;
62245 +#endif
62246 +#endif
62247 + if (gr_status & GR_READY) {
62248 + if (!(task->acl->mode & GR_VIEW))
62249 + ret = -EACCES;
62250 + }
62251 + } else
62252 + ret = -ENOENT;
62253 +
62254 + read_unlock(&tasklist_lock);
62255 + rcu_read_unlock();
62256 +
62257 + return ret;
62258 +}
62259 +#endif
62260 +
62261 +/* AUXV entries are filled via a descendant of search_binary_handler
62262 + after we've already applied the subject for the target
62263 +*/
62264 +int gr_acl_enable_at_secure(void)
62265 +{
62266 + if (unlikely(!(gr_status & GR_READY)))
62267 + return 0;
62268 +
62269 + if (current->acl->mode & GR_ATSECURE)
62270 + return 1;
62271 +
62272 + return 0;
62273 +}
62274 +
62275 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62276 +{
62277 + struct task_struct *task = current;
62278 + struct dentry *dentry = file->f_path.dentry;
62279 + struct vfsmount *mnt = file->f_path.mnt;
62280 + struct acl_object_label *obj, *tmp;
62281 + struct acl_subject_label *subj;
62282 + unsigned int bufsize;
62283 + int is_not_root;
62284 + char *path;
62285 + dev_t dev = __get_dev(dentry);
62286 +
62287 + if (unlikely(!(gr_status & GR_READY)))
62288 + return 1;
62289 +
62290 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62291 + return 1;
62292 +
62293 + /* ignore Eric Biederman */
62294 + if (IS_PRIVATE(dentry->d_inode))
62295 + return 1;
62296 +
62297 + subj = task->acl;
62298 + read_lock(&gr_inode_lock);
62299 + do {
62300 + obj = lookup_acl_obj_label(ino, dev, subj);
62301 + if (obj != NULL) {
62302 + read_unlock(&gr_inode_lock);
62303 + return (obj->mode & GR_FIND) ? 1 : 0;
62304 + }
62305 + } while ((subj = subj->parent_subject));
62306 + read_unlock(&gr_inode_lock);
62307 +
62308 + /* this is purely an optimization since we're looking for an object
62309 + for the directory we're doing a readdir on
62310 + if it's possible for any globbed object to match the entry we're
62311 + filling into the directory, then the object we find here will be
62312 + an anchor point with attached globbed objects
62313 + */
62314 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62315 + if (obj->globbed == NULL)
62316 + return (obj->mode & GR_FIND) ? 1 : 0;
62317 +
62318 + is_not_root = ((obj->filename[0] == '/') &&
62319 + (obj->filename[1] == '\0')) ? 0 : 1;
62320 + bufsize = PAGE_SIZE - namelen - is_not_root;
62321 +
62322 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62323 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62324 + return 1;
62325 +
62326 + preempt_disable();
62327 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62328 + bufsize);
62329 +
62330 + bufsize = strlen(path);
62331 +
62332 + /* if base is "/", don't append an additional slash */
62333 + if (is_not_root)
62334 + *(path + bufsize) = '/';
62335 + memcpy(path + bufsize + is_not_root, name, namelen);
62336 + *(path + bufsize + namelen + is_not_root) = '\0';
62337 +
62338 + tmp = obj->globbed;
62339 + while (tmp) {
62340 + if (!glob_match(tmp->filename, path)) {
62341 + preempt_enable();
62342 + return (tmp->mode & GR_FIND) ? 1 : 0;
62343 + }
62344 + tmp = tmp->next;
62345 + }
62346 + preempt_enable();
62347 + return (obj->mode & GR_FIND) ? 1 : 0;
62348 +}
62349 +
62350 +void gr_put_exec_file(struct task_struct *task)
62351 +{
62352 + struct file *filp;
62353 +
62354 + write_lock(&grsec_exec_file_lock);
62355 + filp = task->exec_file;
62356 + task->exec_file = NULL;
62357 + write_unlock(&grsec_exec_file_lock);
62358 +
62359 + if (filp)
62360 + fput(filp);
62361 +
62362 + return;
62363 +}
62364 +
62365 +
62366 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62367 +EXPORT_SYMBOL(gr_acl_is_enabled);
62368 +#endif
62369 +EXPORT_SYMBOL(gr_set_kernel_label);
62370 +#ifdef CONFIG_SECURITY
62371 +EXPORT_SYMBOL(gr_check_user_change);
62372 +EXPORT_SYMBOL(gr_check_group_change);
62373 +#endif
62374 +
62375 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62376 new file mode 100644
62377 index 0000000..34fefda
62378 --- /dev/null
62379 +++ b/grsecurity/gracl_alloc.c
62380 @@ -0,0 +1,105 @@
62381 +#include <linux/kernel.h>
62382 +#include <linux/mm.h>
62383 +#include <linux/slab.h>
62384 +#include <linux/vmalloc.h>
62385 +#include <linux/gracl.h>
62386 +#include <linux/grsecurity.h>
62387 +
62388 +static unsigned long alloc_stack_next = 1;
62389 +static unsigned long alloc_stack_size = 1;
62390 +static void **alloc_stack;
62391 +
62392 +static __inline__ int
62393 +alloc_pop(void)
62394 +{
62395 + if (alloc_stack_next == 1)
62396 + return 0;
62397 +
62398 + kfree(alloc_stack[alloc_stack_next - 2]);
62399 +
62400 + alloc_stack_next--;
62401 +
62402 + return 1;
62403 +}
62404 +
62405 +static __inline__ int
62406 +alloc_push(void *buf)
62407 +{
62408 + if (alloc_stack_next >= alloc_stack_size)
62409 + return 1;
62410 +
62411 + alloc_stack[alloc_stack_next - 1] = buf;
62412 +
62413 + alloc_stack_next++;
62414 +
62415 + return 0;
62416 +}
62417 +
62418 +void *
62419 +acl_alloc(unsigned long len)
62420 +{
62421 + void *ret = NULL;
62422 +
62423 + if (!len || len > PAGE_SIZE)
62424 + goto out;
62425 +
62426 + ret = kmalloc(len, GFP_KERNEL);
62427 +
62428 + if (ret) {
62429 + if (alloc_push(ret)) {
62430 + kfree(ret);
62431 + ret = NULL;
62432 + }
62433 + }
62434 +
62435 +out:
62436 + return ret;
62437 +}
62438 +
62439 +void *
62440 +acl_alloc_num(unsigned long num, unsigned long len)
62441 +{
62442 + if (!len || (num > (PAGE_SIZE / len)))
62443 + return NULL;
62444 +
62445 + return acl_alloc(num * len);
62446 +}
62447 +
62448 +void
62449 +acl_free_all(void)
62450 +{
62451 + if (gr_acl_is_enabled() || !alloc_stack)
62452 + return;
62453 +
62454 + while (alloc_pop()) ;
62455 +
62456 + if (alloc_stack) {
62457 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62458 + kfree(alloc_stack);
62459 + else
62460 + vfree(alloc_stack);
62461 + }
62462 +
62463 + alloc_stack = NULL;
62464 + alloc_stack_size = 1;
62465 + alloc_stack_next = 1;
62466 +
62467 + return;
62468 +}
62469 +
62470 +int
62471 +acl_alloc_stack_init(unsigned long size)
62472 +{
62473 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62474 + alloc_stack =
62475 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62476 + else
62477 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62478 +
62479 + alloc_stack_size = size;
62480 +
62481 + if (!alloc_stack)
62482 + return 0;
62483 + else
62484 + return 1;
62485 +}
62486 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62487 new file mode 100644
62488 index 0000000..bdd51ea
62489 --- /dev/null
62490 +++ b/grsecurity/gracl_cap.c
62491 @@ -0,0 +1,110 @@
62492 +#include <linux/kernel.h>
62493 +#include <linux/module.h>
62494 +#include <linux/sched.h>
62495 +#include <linux/gracl.h>
62496 +#include <linux/grsecurity.h>
62497 +#include <linux/grinternal.h>
62498 +
62499 +extern const char *captab_log[];
62500 +extern int captab_log_entries;
62501 +
62502 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62503 +{
62504 + struct acl_subject_label *curracl;
62505 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62506 + kernel_cap_t cap_audit = __cap_empty_set;
62507 +
62508 + if (!gr_acl_is_enabled())
62509 + return 1;
62510 +
62511 + curracl = task->acl;
62512 +
62513 + cap_drop = curracl->cap_lower;
62514 + cap_mask = curracl->cap_mask;
62515 + cap_audit = curracl->cap_invert_audit;
62516 +
62517 + while ((curracl = curracl->parent_subject)) {
62518 + /* if the cap isn't specified in the current computed mask but is specified in the
62519 + current level subject, and is lowered in the current level subject, then add
62520 + it to the set of dropped capabilities
62521 + otherwise, add the current level subject's mask to the current computed mask
62522 + */
62523 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62524 + cap_raise(cap_mask, cap);
62525 + if (cap_raised(curracl->cap_lower, cap))
62526 + cap_raise(cap_drop, cap);
62527 + if (cap_raised(curracl->cap_invert_audit, cap))
62528 + cap_raise(cap_audit, cap);
62529 + }
62530 + }
62531 +
62532 + if (!cap_raised(cap_drop, cap)) {
62533 + if (cap_raised(cap_audit, cap))
62534 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62535 + return 1;
62536 + }
62537 +
62538 + curracl = task->acl;
62539 +
62540 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62541 + && cap_raised(cred->cap_effective, cap)) {
62542 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62543 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62544 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62545 + gr_to_filename(task->exec_file->f_path.dentry,
62546 + task->exec_file->f_path.mnt) : curracl->filename,
62547 + curracl->filename, 0UL,
62548 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62549 + return 1;
62550 + }
62551 +
62552 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62553 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62554 +
62555 + return 0;
62556 +}
62557 +
62558 +int
62559 +gr_acl_is_capable(const int cap)
62560 +{
62561 + return gr_task_acl_is_capable(current, current_cred(), cap);
62562 +}
62563 +
62564 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62565 +{
62566 + struct acl_subject_label *curracl;
62567 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62568 +
62569 + if (!gr_acl_is_enabled())
62570 + return 1;
62571 +
62572 + curracl = task->acl;
62573 +
62574 + cap_drop = curracl->cap_lower;
62575 + cap_mask = curracl->cap_mask;
62576 +
62577 + while ((curracl = curracl->parent_subject)) {
62578 + /* if the cap isn't specified in the current computed mask but is specified in the
62579 + current level subject, and is lowered in the current level subject, then add
62580 + it to the set of dropped capabilities
62581 + otherwise, add the current level subject's mask to the current computed mask
62582 + */
62583 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62584 + cap_raise(cap_mask, cap);
62585 + if (cap_raised(curracl->cap_lower, cap))
62586 + cap_raise(cap_drop, cap);
62587 + }
62588 + }
62589 +
62590 + if (!cap_raised(cap_drop, cap))
62591 + return 1;
62592 +
62593 + return 0;
62594 +}
62595 +
62596 +int
62597 +gr_acl_is_capable_nolog(const int cap)
62598 +{
62599 + return gr_task_acl_is_capable_nolog(current, cap);
62600 +}
62601 +
62602 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62603 new file mode 100644
62604 index 0000000..a340c17
62605 --- /dev/null
62606 +++ b/grsecurity/gracl_fs.c
62607 @@ -0,0 +1,431 @@
62608 +#include <linux/kernel.h>
62609 +#include <linux/sched.h>
62610 +#include <linux/types.h>
62611 +#include <linux/fs.h>
62612 +#include <linux/file.h>
62613 +#include <linux/stat.h>
62614 +#include <linux/grsecurity.h>
62615 +#include <linux/grinternal.h>
62616 +#include <linux/gracl.h>
62617 +
62618 +umode_t
62619 +gr_acl_umask(void)
62620 +{
62621 + if (unlikely(!gr_acl_is_enabled()))
62622 + return 0;
62623 +
62624 + return current->role->umask;
62625 +}
62626 +
62627 +__u32
62628 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62629 + const struct vfsmount * mnt)
62630 +{
62631 + __u32 mode;
62632 +
62633 + if (unlikely(!dentry->d_inode))
62634 + return GR_FIND;
62635 +
62636 + mode =
62637 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62638 +
62639 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62640 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62641 + return mode;
62642 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62643 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62644 + return 0;
62645 + } else if (unlikely(!(mode & GR_FIND)))
62646 + return 0;
62647 +
62648 + return GR_FIND;
62649 +}
62650 +
62651 +__u32
62652 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62653 + int acc_mode)
62654 +{
62655 + __u32 reqmode = GR_FIND;
62656 + __u32 mode;
62657 +
62658 + if (unlikely(!dentry->d_inode))
62659 + return reqmode;
62660 +
62661 + if (acc_mode & MAY_APPEND)
62662 + reqmode |= GR_APPEND;
62663 + else if (acc_mode & MAY_WRITE)
62664 + reqmode |= GR_WRITE;
62665 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62666 + reqmode |= GR_READ;
62667 +
62668 + mode =
62669 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62670 + mnt);
62671 +
62672 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62673 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62674 + reqmode & GR_READ ? " reading" : "",
62675 + reqmode & GR_WRITE ? " writing" : reqmode &
62676 + GR_APPEND ? " appending" : "");
62677 + return reqmode;
62678 + } else
62679 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62680 + {
62681 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62682 + reqmode & GR_READ ? " reading" : "",
62683 + reqmode & GR_WRITE ? " writing" : reqmode &
62684 + GR_APPEND ? " appending" : "");
62685 + return 0;
62686 + } else if (unlikely((mode & reqmode) != reqmode))
62687 + return 0;
62688 +
62689 + return reqmode;
62690 +}
62691 +
62692 +__u32
62693 +gr_acl_handle_creat(const struct dentry * dentry,
62694 + const struct dentry * p_dentry,
62695 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62696 + const int imode)
62697 +{
62698 + __u32 reqmode = GR_WRITE | GR_CREATE;
62699 + __u32 mode;
62700 +
62701 + if (acc_mode & MAY_APPEND)
62702 + reqmode |= GR_APPEND;
62703 + // if a directory was required or the directory already exists, then
62704 + // don't count this open as a read
62705 + if ((acc_mode & MAY_READ) &&
62706 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62707 + reqmode |= GR_READ;
62708 + if ((open_flags & O_CREAT) &&
62709 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62710 + reqmode |= GR_SETID;
62711 +
62712 + mode =
62713 + gr_check_create(dentry, p_dentry, p_mnt,
62714 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62715 +
62716 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62717 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62718 + reqmode & GR_READ ? " reading" : "",
62719 + reqmode & GR_WRITE ? " writing" : reqmode &
62720 + GR_APPEND ? " appending" : "");
62721 + return reqmode;
62722 + } else
62723 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62724 + {
62725 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62726 + reqmode & GR_READ ? " reading" : "",
62727 + reqmode & GR_WRITE ? " writing" : reqmode &
62728 + GR_APPEND ? " appending" : "");
62729 + return 0;
62730 + } else if (unlikely((mode & reqmode) != reqmode))
62731 + return 0;
62732 +
62733 + return reqmode;
62734 +}
62735 +
62736 +__u32
62737 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62738 + const int fmode)
62739 +{
62740 + __u32 mode, reqmode = GR_FIND;
62741 +
62742 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62743 + reqmode |= GR_EXEC;
62744 + if (fmode & S_IWOTH)
62745 + reqmode |= GR_WRITE;
62746 + if (fmode & S_IROTH)
62747 + reqmode |= GR_READ;
62748 +
62749 + mode =
62750 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62751 + mnt);
62752 +
62753 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62754 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62755 + reqmode & GR_READ ? " reading" : "",
62756 + reqmode & GR_WRITE ? " writing" : "",
62757 + reqmode & GR_EXEC ? " executing" : "");
62758 + return reqmode;
62759 + } else
62760 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62761 + {
62762 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62763 + reqmode & GR_READ ? " reading" : "",
62764 + reqmode & GR_WRITE ? " writing" : "",
62765 + reqmode & GR_EXEC ? " executing" : "");
62766 + return 0;
62767 + } else if (unlikely((mode & reqmode) != reqmode))
62768 + return 0;
62769 +
62770 + return reqmode;
62771 +}
62772 +
62773 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62774 +{
62775 + __u32 mode;
62776 +
62777 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62778 +
62779 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62780 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62781 + return mode;
62782 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62783 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62784 + return 0;
62785 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62786 + return 0;
62787 +
62788 + return (reqmode);
62789 +}
62790 +
62791 +__u32
62792 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62793 +{
62794 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62795 +}
62796 +
62797 +__u32
62798 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62799 +{
62800 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62801 +}
62802 +
62803 +__u32
62804 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62805 +{
62806 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62807 +}
62808 +
62809 +__u32
62810 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62811 +{
62812 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62813 +}
62814 +
62815 +__u32
62816 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62817 + umode_t *modeptr)
62818 +{
62819 + umode_t mode;
62820 +
62821 + *modeptr &= ~gr_acl_umask();
62822 + mode = *modeptr;
62823 +
62824 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62825 + return 1;
62826 +
62827 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62828 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62829 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62830 + GR_CHMOD_ACL_MSG);
62831 + } else {
62832 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62833 + }
62834 +}
62835 +
62836 +__u32
62837 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62838 +{
62839 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62840 +}
62841 +
62842 +__u32
62843 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62844 +{
62845 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62846 +}
62847 +
62848 +__u32
62849 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62850 +{
62851 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62852 +}
62853 +
62854 +__u32
62855 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62856 +{
62857 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62858 + GR_UNIXCONNECT_ACL_MSG);
62859 +}
62860 +
62861 +/* hardlinks require at minimum create and link permission,
62862 + any additional privilege required is based on the
62863 + privilege of the file being linked to
62864 +*/
62865 +__u32
62866 +gr_acl_handle_link(const struct dentry * new_dentry,
62867 + const struct dentry * parent_dentry,
62868 + const struct vfsmount * parent_mnt,
62869 + const struct dentry * old_dentry,
62870 + const struct vfsmount * old_mnt, const struct filename *to)
62871 +{
62872 + __u32 mode;
62873 + __u32 needmode = GR_CREATE | GR_LINK;
62874 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62875 +
62876 + mode =
62877 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62878 + old_mnt);
62879 +
62880 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62881 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62882 + return mode;
62883 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62884 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62885 + return 0;
62886 + } else if (unlikely((mode & needmode) != needmode))
62887 + return 0;
62888 +
62889 + return 1;
62890 +}
62891 +
62892 +__u32
62893 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62894 + const struct dentry * parent_dentry,
62895 + const struct vfsmount * parent_mnt, const struct filename *from)
62896 +{
62897 + __u32 needmode = GR_WRITE | GR_CREATE;
62898 + __u32 mode;
62899 +
62900 + mode =
62901 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62902 + GR_CREATE | GR_AUDIT_CREATE |
62903 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62904 +
62905 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62906 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62907 + return mode;
62908 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62909 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62910 + return 0;
62911 + } else if (unlikely((mode & needmode) != needmode))
62912 + return 0;
62913 +
62914 + return (GR_WRITE | GR_CREATE);
62915 +}
62916 +
62917 +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)
62918 +{
62919 + __u32 mode;
62920 +
62921 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62922 +
62923 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62924 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62925 + return mode;
62926 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62927 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62928 + return 0;
62929 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62930 + return 0;
62931 +
62932 + return (reqmode);
62933 +}
62934 +
62935 +__u32
62936 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62937 + const struct dentry * parent_dentry,
62938 + const struct vfsmount * parent_mnt,
62939 + const int mode)
62940 +{
62941 + __u32 reqmode = GR_WRITE | GR_CREATE;
62942 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62943 + reqmode |= GR_SETID;
62944 +
62945 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62946 + reqmode, GR_MKNOD_ACL_MSG);
62947 +}
62948 +
62949 +__u32
62950 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62951 + const struct dentry *parent_dentry,
62952 + const struct vfsmount *parent_mnt)
62953 +{
62954 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62955 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62956 +}
62957 +
62958 +#define RENAME_CHECK_SUCCESS(old, new) \
62959 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62960 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62961 +
62962 +int
62963 +gr_acl_handle_rename(struct dentry *new_dentry,
62964 + struct dentry *parent_dentry,
62965 + const struct vfsmount *parent_mnt,
62966 + struct dentry *old_dentry,
62967 + struct inode *old_parent_inode,
62968 + struct vfsmount *old_mnt, const struct filename *newname)
62969 +{
62970 + __u32 comp1, comp2;
62971 + int error = 0;
62972 +
62973 + if (unlikely(!gr_acl_is_enabled()))
62974 + return 0;
62975 +
62976 + if (!new_dentry->d_inode) {
62977 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62978 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62979 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62980 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62981 + GR_DELETE | GR_AUDIT_DELETE |
62982 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62983 + GR_SUPPRESS, old_mnt);
62984 + } else {
62985 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62986 + GR_CREATE | GR_DELETE |
62987 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62988 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62989 + GR_SUPPRESS, parent_mnt);
62990 + comp2 =
62991 + gr_search_file(old_dentry,
62992 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62993 + GR_DELETE | GR_AUDIT_DELETE |
62994 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62995 + }
62996 +
62997 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62998 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62999 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63000 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
63001 + && !(comp2 & GR_SUPPRESS)) {
63002 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63003 + error = -EACCES;
63004 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
63005 + error = -EACCES;
63006 +
63007 + return error;
63008 +}
63009 +
63010 +void
63011 +gr_acl_handle_exit(void)
63012 +{
63013 + u16 id;
63014 + char *rolename;
63015 +
63016 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
63017 + !(current->role->roletype & GR_ROLE_PERSIST))) {
63018 + id = current->acl_role_id;
63019 + rolename = current->role->rolename;
63020 + gr_set_acls(1);
63021 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
63022 + }
63023 +
63024 + gr_put_exec_file(current);
63025 + return;
63026 +}
63027 +
63028 +int
63029 +gr_acl_handle_procpidmem(const struct task_struct *task)
63030 +{
63031 + if (unlikely(!gr_acl_is_enabled()))
63032 + return 0;
63033 +
63034 + if (task != current && task->acl->mode & GR_PROTPROCFD)
63035 + return -EACCES;
63036 +
63037 + return 0;
63038 +}
63039 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
63040 new file mode 100644
63041 index 0000000..8132048
63042 --- /dev/null
63043 +++ b/grsecurity/gracl_ip.c
63044 @@ -0,0 +1,387 @@
63045 +#include <linux/kernel.h>
63046 +#include <asm/uaccess.h>
63047 +#include <asm/errno.h>
63048 +#include <net/sock.h>
63049 +#include <linux/file.h>
63050 +#include <linux/fs.h>
63051 +#include <linux/net.h>
63052 +#include <linux/in.h>
63053 +#include <linux/skbuff.h>
63054 +#include <linux/ip.h>
63055 +#include <linux/udp.h>
63056 +#include <linux/types.h>
63057 +#include <linux/sched.h>
63058 +#include <linux/netdevice.h>
63059 +#include <linux/inetdevice.h>
63060 +#include <linux/gracl.h>
63061 +#include <linux/grsecurity.h>
63062 +#include <linux/grinternal.h>
63063 +
63064 +#define GR_BIND 0x01
63065 +#define GR_CONNECT 0x02
63066 +#define GR_INVERT 0x04
63067 +#define GR_BINDOVERRIDE 0x08
63068 +#define GR_CONNECTOVERRIDE 0x10
63069 +#define GR_SOCK_FAMILY 0x20
63070 +
63071 +static const char * gr_protocols[IPPROTO_MAX] = {
63072 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
63073 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
63074 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
63075 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
63076 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
63077 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
63078 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
63079 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
63080 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
63081 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63082 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63083 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63084 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63085 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63086 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63087 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63088 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63089 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63090 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63091 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63092 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63093 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63094 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63095 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63096 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63097 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63098 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63099 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63100 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63101 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63102 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63103 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63104 + };
63105 +
63106 +static const char * gr_socktypes[SOCK_MAX] = {
63107 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63108 + "unknown:7", "unknown:8", "unknown:9", "packet"
63109 + };
63110 +
63111 +static const char * gr_sockfamilies[AF_MAX+1] = {
63112 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63113 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63114 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63115 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63116 + };
63117 +
63118 +const char *
63119 +gr_proto_to_name(unsigned char proto)
63120 +{
63121 + return gr_protocols[proto];
63122 +}
63123 +
63124 +const char *
63125 +gr_socktype_to_name(unsigned char type)
63126 +{
63127 + return gr_socktypes[type];
63128 +}
63129 +
63130 +const char *
63131 +gr_sockfamily_to_name(unsigned char family)
63132 +{
63133 + return gr_sockfamilies[family];
63134 +}
63135 +
63136 +int
63137 +gr_search_socket(const int domain, const int type, const int protocol)
63138 +{
63139 + struct acl_subject_label *curr;
63140 + const struct cred *cred = current_cred();
63141 +
63142 + if (unlikely(!gr_acl_is_enabled()))
63143 + goto exit;
63144 +
63145 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63146 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63147 + goto exit; // let the kernel handle it
63148 +
63149 + curr = current->acl;
63150 +
63151 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63152 + /* the family is allowed, if this is PF_INET allow it only if
63153 + the extra sock type/protocol checks pass */
63154 + if (domain == PF_INET)
63155 + goto inet_check;
63156 + goto exit;
63157 + } else {
63158 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63159 + __u32 fakeip = 0;
63160 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63161 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63162 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63163 + gr_to_filename(current->exec_file->f_path.dentry,
63164 + current->exec_file->f_path.mnt) :
63165 + curr->filename, curr->filename,
63166 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63167 + &current->signal->saved_ip);
63168 + goto exit;
63169 + }
63170 + goto exit_fail;
63171 + }
63172 +
63173 +inet_check:
63174 + /* the rest of this checking is for IPv4 only */
63175 + if (!curr->ips)
63176 + goto exit;
63177 +
63178 + if ((curr->ip_type & (1U << type)) &&
63179 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63180 + goto exit;
63181 +
63182 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63183 + /* we don't place acls on raw sockets , and sometimes
63184 + dgram/ip sockets are opened for ioctl and not
63185 + bind/connect, so we'll fake a bind learn log */
63186 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63187 + __u32 fakeip = 0;
63188 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63189 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63190 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63191 + gr_to_filename(current->exec_file->f_path.dentry,
63192 + current->exec_file->f_path.mnt) :
63193 + curr->filename, curr->filename,
63194 + &fakeip, 0, type,
63195 + protocol, GR_CONNECT, &current->signal->saved_ip);
63196 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63197 + __u32 fakeip = 0;
63198 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63199 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63200 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63201 + gr_to_filename(current->exec_file->f_path.dentry,
63202 + current->exec_file->f_path.mnt) :
63203 + curr->filename, curr->filename,
63204 + &fakeip, 0, type,
63205 + protocol, GR_BIND, &current->signal->saved_ip);
63206 + }
63207 + /* we'll log when they use connect or bind */
63208 + goto exit;
63209 + }
63210 +
63211 +exit_fail:
63212 + if (domain == PF_INET)
63213 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63214 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63215 + else
63216 +#ifndef CONFIG_IPV6
63217 + if (domain != PF_INET6)
63218 +#endif
63219 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63220 + gr_socktype_to_name(type), protocol);
63221 +
63222 + return 0;
63223 +exit:
63224 + return 1;
63225 +}
63226 +
63227 +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)
63228 +{
63229 + if ((ip->mode & mode) &&
63230 + (ip_port >= ip->low) &&
63231 + (ip_port <= ip->high) &&
63232 + ((ntohl(ip_addr) & our_netmask) ==
63233 + (ntohl(our_addr) & our_netmask))
63234 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63235 + && (ip->type & (1U << type))) {
63236 + if (ip->mode & GR_INVERT)
63237 + return 2; // specifically denied
63238 + else
63239 + return 1; // allowed
63240 + }
63241 +
63242 + return 0; // not specifically allowed, may continue parsing
63243 +}
63244 +
63245 +static int
63246 +gr_search_connectbind(const int full_mode, struct sock *sk,
63247 + struct sockaddr_in *addr, const int type)
63248 +{
63249 + char iface[IFNAMSIZ] = {0};
63250 + struct acl_subject_label *curr;
63251 + struct acl_ip_label *ip;
63252 + struct inet_sock *isk;
63253 + struct net_device *dev;
63254 + struct in_device *idev;
63255 + unsigned long i;
63256 + int ret;
63257 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63258 + __u32 ip_addr = 0;
63259 + __u32 our_addr;
63260 + __u32 our_netmask;
63261 + char *p;
63262 + __u16 ip_port = 0;
63263 + const struct cred *cred = current_cred();
63264 +
63265 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63266 + return 0;
63267 +
63268 + curr = current->acl;
63269 + isk = inet_sk(sk);
63270 +
63271 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63272 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63273 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63274 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63275 + struct sockaddr_in saddr;
63276 + int err;
63277 +
63278 + saddr.sin_family = AF_INET;
63279 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63280 + saddr.sin_port = isk->inet_sport;
63281 +
63282 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63283 + if (err)
63284 + return err;
63285 +
63286 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63287 + if (err)
63288 + return err;
63289 + }
63290 +
63291 + if (!curr->ips)
63292 + return 0;
63293 +
63294 + ip_addr = addr->sin_addr.s_addr;
63295 + ip_port = ntohs(addr->sin_port);
63296 +
63297 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63298 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63299 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63300 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63301 + gr_to_filename(current->exec_file->f_path.dentry,
63302 + current->exec_file->f_path.mnt) :
63303 + curr->filename, curr->filename,
63304 + &ip_addr, ip_port, type,
63305 + sk->sk_protocol, mode, &current->signal->saved_ip);
63306 + return 0;
63307 + }
63308 +
63309 + for (i = 0; i < curr->ip_num; i++) {
63310 + ip = *(curr->ips + i);
63311 + if (ip->iface != NULL) {
63312 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63313 + p = strchr(iface, ':');
63314 + if (p != NULL)
63315 + *p = '\0';
63316 + dev = dev_get_by_name(sock_net(sk), iface);
63317 + if (dev == NULL)
63318 + continue;
63319 + idev = in_dev_get(dev);
63320 + if (idev == NULL) {
63321 + dev_put(dev);
63322 + continue;
63323 + }
63324 + rcu_read_lock();
63325 + for_ifa(idev) {
63326 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63327 + our_addr = ifa->ifa_address;
63328 + our_netmask = 0xffffffff;
63329 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63330 + if (ret == 1) {
63331 + rcu_read_unlock();
63332 + in_dev_put(idev);
63333 + dev_put(dev);
63334 + return 0;
63335 + } else if (ret == 2) {
63336 + rcu_read_unlock();
63337 + in_dev_put(idev);
63338 + dev_put(dev);
63339 + goto denied;
63340 + }
63341 + }
63342 + } endfor_ifa(idev);
63343 + rcu_read_unlock();
63344 + in_dev_put(idev);
63345 + dev_put(dev);
63346 + } else {
63347 + our_addr = ip->addr;
63348 + our_netmask = ip->netmask;
63349 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63350 + if (ret == 1)
63351 + return 0;
63352 + else if (ret == 2)
63353 + goto denied;
63354 + }
63355 + }
63356 +
63357 +denied:
63358 + if (mode == GR_BIND)
63359 + 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));
63360 + else if (mode == GR_CONNECT)
63361 + 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));
63362 +
63363 + return -EACCES;
63364 +}
63365 +
63366 +int
63367 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63368 +{
63369 + /* always allow disconnection of dgram sockets with connect */
63370 + if (addr->sin_family == AF_UNSPEC)
63371 + return 0;
63372 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63373 +}
63374 +
63375 +int
63376 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63377 +{
63378 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63379 +}
63380 +
63381 +int gr_search_listen(struct socket *sock)
63382 +{
63383 + struct sock *sk = sock->sk;
63384 + struct sockaddr_in addr;
63385 +
63386 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63387 + addr.sin_port = inet_sk(sk)->inet_sport;
63388 +
63389 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63390 +}
63391 +
63392 +int gr_search_accept(struct socket *sock)
63393 +{
63394 + struct sock *sk = sock->sk;
63395 + struct sockaddr_in addr;
63396 +
63397 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63398 + addr.sin_port = inet_sk(sk)->inet_sport;
63399 +
63400 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63401 +}
63402 +
63403 +int
63404 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63405 +{
63406 + if (addr)
63407 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63408 + else {
63409 + struct sockaddr_in sin;
63410 + const struct inet_sock *inet = inet_sk(sk);
63411 +
63412 + sin.sin_addr.s_addr = inet->inet_daddr;
63413 + sin.sin_port = inet->inet_dport;
63414 +
63415 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63416 + }
63417 +}
63418 +
63419 +int
63420 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63421 +{
63422 + struct sockaddr_in sin;
63423 +
63424 + if (unlikely(skb->len < sizeof (struct udphdr)))
63425 + return 0; // skip this packet
63426 +
63427 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63428 + sin.sin_port = udp_hdr(skb)->source;
63429 +
63430 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63431 +}
63432 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63433 new file mode 100644
63434 index 0000000..25f54ef
63435 --- /dev/null
63436 +++ b/grsecurity/gracl_learn.c
63437 @@ -0,0 +1,207 @@
63438 +#include <linux/kernel.h>
63439 +#include <linux/mm.h>
63440 +#include <linux/sched.h>
63441 +#include <linux/poll.h>
63442 +#include <linux/string.h>
63443 +#include <linux/file.h>
63444 +#include <linux/types.h>
63445 +#include <linux/vmalloc.h>
63446 +#include <linux/grinternal.h>
63447 +
63448 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63449 + size_t count, loff_t *ppos);
63450 +extern int gr_acl_is_enabled(void);
63451 +
63452 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63453 +static int gr_learn_attached;
63454 +
63455 +/* use a 512k buffer */
63456 +#define LEARN_BUFFER_SIZE (512 * 1024)
63457 +
63458 +static DEFINE_SPINLOCK(gr_learn_lock);
63459 +static DEFINE_MUTEX(gr_learn_user_mutex);
63460 +
63461 +/* we need to maintain two buffers, so that the kernel context of grlearn
63462 + uses a semaphore around the userspace copying, and the other kernel contexts
63463 + use a spinlock when copying into the buffer, since they cannot sleep
63464 +*/
63465 +static char *learn_buffer;
63466 +static char *learn_buffer_user;
63467 +static int learn_buffer_len;
63468 +static int learn_buffer_user_len;
63469 +
63470 +static ssize_t
63471 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63472 +{
63473 + DECLARE_WAITQUEUE(wait, current);
63474 + ssize_t retval = 0;
63475 +
63476 + add_wait_queue(&learn_wait, &wait);
63477 + set_current_state(TASK_INTERRUPTIBLE);
63478 + do {
63479 + mutex_lock(&gr_learn_user_mutex);
63480 + spin_lock(&gr_learn_lock);
63481 + if (learn_buffer_len)
63482 + break;
63483 + spin_unlock(&gr_learn_lock);
63484 + mutex_unlock(&gr_learn_user_mutex);
63485 + if (file->f_flags & O_NONBLOCK) {
63486 + retval = -EAGAIN;
63487 + goto out;
63488 + }
63489 + if (signal_pending(current)) {
63490 + retval = -ERESTARTSYS;
63491 + goto out;
63492 + }
63493 +
63494 + schedule();
63495 + } while (1);
63496 +
63497 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63498 + learn_buffer_user_len = learn_buffer_len;
63499 + retval = learn_buffer_len;
63500 + learn_buffer_len = 0;
63501 +
63502 + spin_unlock(&gr_learn_lock);
63503 +
63504 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63505 + retval = -EFAULT;
63506 +
63507 + mutex_unlock(&gr_learn_user_mutex);
63508 +out:
63509 + set_current_state(TASK_RUNNING);
63510 + remove_wait_queue(&learn_wait, &wait);
63511 + return retval;
63512 +}
63513 +
63514 +static unsigned int
63515 +poll_learn(struct file * file, poll_table * wait)
63516 +{
63517 + poll_wait(file, &learn_wait, wait);
63518 +
63519 + if (learn_buffer_len)
63520 + return (POLLIN | POLLRDNORM);
63521 +
63522 + return 0;
63523 +}
63524 +
63525 +void
63526 +gr_clear_learn_entries(void)
63527 +{
63528 + char *tmp;
63529 +
63530 + mutex_lock(&gr_learn_user_mutex);
63531 + spin_lock(&gr_learn_lock);
63532 + tmp = learn_buffer;
63533 + learn_buffer = NULL;
63534 + spin_unlock(&gr_learn_lock);
63535 + if (tmp)
63536 + vfree(tmp);
63537 + if (learn_buffer_user != NULL) {
63538 + vfree(learn_buffer_user);
63539 + learn_buffer_user = NULL;
63540 + }
63541 + learn_buffer_len = 0;
63542 + mutex_unlock(&gr_learn_user_mutex);
63543 +
63544 + return;
63545 +}
63546 +
63547 +void
63548 +gr_add_learn_entry(const char *fmt, ...)
63549 +{
63550 + va_list args;
63551 + unsigned int len;
63552 +
63553 + if (!gr_learn_attached)
63554 + return;
63555 +
63556 + spin_lock(&gr_learn_lock);
63557 +
63558 + /* leave a gap at the end so we know when it's "full" but don't have to
63559 + compute the exact length of the string we're trying to append
63560 + */
63561 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63562 + spin_unlock(&gr_learn_lock);
63563 + wake_up_interruptible(&learn_wait);
63564 + return;
63565 + }
63566 + if (learn_buffer == NULL) {
63567 + spin_unlock(&gr_learn_lock);
63568 + return;
63569 + }
63570 +
63571 + va_start(args, fmt);
63572 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63573 + va_end(args);
63574 +
63575 + learn_buffer_len += len + 1;
63576 +
63577 + spin_unlock(&gr_learn_lock);
63578 + wake_up_interruptible(&learn_wait);
63579 +
63580 + return;
63581 +}
63582 +
63583 +static int
63584 +open_learn(struct inode *inode, struct file *file)
63585 +{
63586 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63587 + return -EBUSY;
63588 + if (file->f_mode & FMODE_READ) {
63589 + int retval = 0;
63590 + mutex_lock(&gr_learn_user_mutex);
63591 + if (learn_buffer == NULL)
63592 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63593 + if (learn_buffer_user == NULL)
63594 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63595 + if (learn_buffer == NULL) {
63596 + retval = -ENOMEM;
63597 + goto out_error;
63598 + }
63599 + if (learn_buffer_user == NULL) {
63600 + retval = -ENOMEM;
63601 + goto out_error;
63602 + }
63603 + learn_buffer_len = 0;
63604 + learn_buffer_user_len = 0;
63605 + gr_learn_attached = 1;
63606 +out_error:
63607 + mutex_unlock(&gr_learn_user_mutex);
63608 + return retval;
63609 + }
63610 + return 0;
63611 +}
63612 +
63613 +static int
63614 +close_learn(struct inode *inode, struct file *file)
63615 +{
63616 + if (file->f_mode & FMODE_READ) {
63617 + char *tmp = NULL;
63618 + mutex_lock(&gr_learn_user_mutex);
63619 + spin_lock(&gr_learn_lock);
63620 + tmp = learn_buffer;
63621 + learn_buffer = NULL;
63622 + spin_unlock(&gr_learn_lock);
63623 + if (tmp)
63624 + vfree(tmp);
63625 + if (learn_buffer_user != NULL) {
63626 + vfree(learn_buffer_user);
63627 + learn_buffer_user = NULL;
63628 + }
63629 + learn_buffer_len = 0;
63630 + learn_buffer_user_len = 0;
63631 + gr_learn_attached = 0;
63632 + mutex_unlock(&gr_learn_user_mutex);
63633 + }
63634 +
63635 + return 0;
63636 +}
63637 +
63638 +const struct file_operations grsec_fops = {
63639 + .read = read_learn,
63640 + .write = write_grsec_handler,
63641 + .open = open_learn,
63642 + .release = close_learn,
63643 + .poll = poll_learn,
63644 +};
63645 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63646 new file mode 100644
63647 index 0000000..39645c9
63648 --- /dev/null
63649 +++ b/grsecurity/gracl_res.c
63650 @@ -0,0 +1,68 @@
63651 +#include <linux/kernel.h>
63652 +#include <linux/sched.h>
63653 +#include <linux/gracl.h>
63654 +#include <linux/grinternal.h>
63655 +
63656 +static const char *restab_log[] = {
63657 + [RLIMIT_CPU] = "RLIMIT_CPU",
63658 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63659 + [RLIMIT_DATA] = "RLIMIT_DATA",
63660 + [RLIMIT_STACK] = "RLIMIT_STACK",
63661 + [RLIMIT_CORE] = "RLIMIT_CORE",
63662 + [RLIMIT_RSS] = "RLIMIT_RSS",
63663 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63664 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63665 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63666 + [RLIMIT_AS] = "RLIMIT_AS",
63667 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63668 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63669 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63670 + [RLIMIT_NICE] = "RLIMIT_NICE",
63671 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63672 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63673 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63674 +};
63675 +
63676 +void
63677 +gr_log_resource(const struct task_struct *task,
63678 + const int res, const unsigned long wanted, const int gt)
63679 +{
63680 + const struct cred *cred;
63681 + unsigned long rlim;
63682 +
63683 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63684 + return;
63685 +
63686 + // not yet supported resource
63687 + if (unlikely(!restab_log[res]))
63688 + return;
63689 +
63690 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63691 + rlim = task_rlimit_max(task, res);
63692 + else
63693 + rlim = task_rlimit(task, res);
63694 +
63695 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63696 + return;
63697 +
63698 + rcu_read_lock();
63699 + cred = __task_cred(task);
63700 +
63701 + if (res == RLIMIT_NPROC &&
63702 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63703 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63704 + goto out_rcu_unlock;
63705 + else if (res == RLIMIT_MEMLOCK &&
63706 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63707 + goto out_rcu_unlock;
63708 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63709 + goto out_rcu_unlock;
63710 + rcu_read_unlock();
63711 +
63712 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63713 +
63714 + return;
63715 +out_rcu_unlock:
63716 + rcu_read_unlock();
63717 + return;
63718 +}
63719 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63720 new file mode 100644
63721 index 0000000..3c38bfe
63722 --- /dev/null
63723 +++ b/grsecurity/gracl_segv.c
63724 @@ -0,0 +1,305 @@
63725 +#include <linux/kernel.h>
63726 +#include <linux/mm.h>
63727 +#include <asm/uaccess.h>
63728 +#include <asm/errno.h>
63729 +#include <asm/mman.h>
63730 +#include <net/sock.h>
63731 +#include <linux/file.h>
63732 +#include <linux/fs.h>
63733 +#include <linux/net.h>
63734 +#include <linux/in.h>
63735 +#include <linux/slab.h>
63736 +#include <linux/types.h>
63737 +#include <linux/sched.h>
63738 +#include <linux/timer.h>
63739 +#include <linux/gracl.h>
63740 +#include <linux/grsecurity.h>
63741 +#include <linux/grinternal.h>
63742 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63743 +#include <linux/magic.h>
63744 +#include <linux/pagemap.h>
63745 +#include "../fs/btrfs/async-thread.h"
63746 +#include "../fs/btrfs/ctree.h"
63747 +#include "../fs/btrfs/btrfs_inode.h"
63748 +#endif
63749 +
63750 +static struct crash_uid *uid_set;
63751 +static unsigned short uid_used;
63752 +static DEFINE_SPINLOCK(gr_uid_lock);
63753 +extern rwlock_t gr_inode_lock;
63754 +extern struct acl_subject_label *
63755 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63756 + struct acl_role_label *role);
63757 +
63758 +static inline dev_t __get_dev(const struct dentry *dentry)
63759 +{
63760 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63761 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63762 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63763 + else
63764 +#endif
63765 + return dentry->d_sb->s_dev;
63766 +}
63767 +
63768 +int
63769 +gr_init_uidset(void)
63770 +{
63771 + uid_set =
63772 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63773 + uid_used = 0;
63774 +
63775 + return uid_set ? 1 : 0;
63776 +}
63777 +
63778 +void
63779 +gr_free_uidset(void)
63780 +{
63781 + if (uid_set)
63782 + kfree(uid_set);
63783 +
63784 + return;
63785 +}
63786 +
63787 +int
63788 +gr_find_uid(const uid_t uid)
63789 +{
63790 + struct crash_uid *tmp = uid_set;
63791 + uid_t buid;
63792 + int low = 0, high = uid_used - 1, mid;
63793 +
63794 + while (high >= low) {
63795 + mid = (low + high) >> 1;
63796 + buid = tmp[mid].uid;
63797 + if (buid == uid)
63798 + return mid;
63799 + if (buid > uid)
63800 + high = mid - 1;
63801 + if (buid < uid)
63802 + low = mid + 1;
63803 + }
63804 +
63805 + return -1;
63806 +}
63807 +
63808 +static __inline__ void
63809 +gr_insertsort(void)
63810 +{
63811 + unsigned short i, j;
63812 + struct crash_uid index;
63813 +
63814 + for (i = 1; i < uid_used; i++) {
63815 + index = uid_set[i];
63816 + j = i;
63817 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63818 + uid_set[j] = uid_set[j - 1];
63819 + j--;
63820 + }
63821 + uid_set[j] = index;
63822 + }
63823 +
63824 + return;
63825 +}
63826 +
63827 +static __inline__ void
63828 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63829 +{
63830 + int loc;
63831 + uid_t uid = GR_GLOBAL_UID(kuid);
63832 +
63833 + if (uid_used == GR_UIDTABLE_MAX)
63834 + return;
63835 +
63836 + loc = gr_find_uid(uid);
63837 +
63838 + if (loc >= 0) {
63839 + uid_set[loc].expires = expires;
63840 + return;
63841 + }
63842 +
63843 + uid_set[uid_used].uid = uid;
63844 + uid_set[uid_used].expires = expires;
63845 + uid_used++;
63846 +
63847 + gr_insertsort();
63848 +
63849 + return;
63850 +}
63851 +
63852 +void
63853 +gr_remove_uid(const unsigned short loc)
63854 +{
63855 + unsigned short i;
63856 +
63857 + for (i = loc + 1; i < uid_used; i++)
63858 + uid_set[i - 1] = uid_set[i];
63859 +
63860 + uid_used--;
63861 +
63862 + return;
63863 +}
63864 +
63865 +int
63866 +gr_check_crash_uid(const kuid_t kuid)
63867 +{
63868 + int loc;
63869 + int ret = 0;
63870 + uid_t uid;
63871 +
63872 + if (unlikely(!gr_acl_is_enabled()))
63873 + return 0;
63874 +
63875 + uid = GR_GLOBAL_UID(kuid);
63876 +
63877 + spin_lock(&gr_uid_lock);
63878 + loc = gr_find_uid(uid);
63879 +
63880 + if (loc < 0)
63881 + goto out_unlock;
63882 +
63883 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63884 + gr_remove_uid(loc);
63885 + else
63886 + ret = 1;
63887 +
63888 +out_unlock:
63889 + spin_unlock(&gr_uid_lock);
63890 + return ret;
63891 +}
63892 +
63893 +static __inline__ int
63894 +proc_is_setxid(const struct cred *cred)
63895 +{
63896 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63897 + !uid_eq(cred->uid, cred->fsuid))
63898 + return 1;
63899 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63900 + !gid_eq(cred->gid, cred->fsgid))
63901 + return 1;
63902 +
63903 + return 0;
63904 +}
63905 +
63906 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63907 +
63908 +void
63909 +gr_handle_crash(struct task_struct *task, const int sig)
63910 +{
63911 + struct acl_subject_label *curr;
63912 + struct task_struct *tsk, *tsk2;
63913 + const struct cred *cred;
63914 + const struct cred *cred2;
63915 +
63916 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63917 + return;
63918 +
63919 + if (unlikely(!gr_acl_is_enabled()))
63920 + return;
63921 +
63922 + curr = task->acl;
63923 +
63924 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63925 + return;
63926 +
63927 + if (time_before_eq(curr->expires, get_seconds())) {
63928 + curr->expires = 0;
63929 + curr->crashes = 0;
63930 + }
63931 +
63932 + curr->crashes++;
63933 +
63934 + if (!curr->expires)
63935 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63936 +
63937 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63938 + time_after(curr->expires, get_seconds())) {
63939 + rcu_read_lock();
63940 + cred = __task_cred(task);
63941 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63942 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63943 + spin_lock(&gr_uid_lock);
63944 + gr_insert_uid(cred->uid, curr->expires);
63945 + spin_unlock(&gr_uid_lock);
63946 + curr->expires = 0;
63947 + curr->crashes = 0;
63948 + read_lock(&tasklist_lock);
63949 + do_each_thread(tsk2, tsk) {
63950 + cred2 = __task_cred(tsk);
63951 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63952 + gr_fake_force_sig(SIGKILL, tsk);
63953 + } while_each_thread(tsk2, tsk);
63954 + read_unlock(&tasklist_lock);
63955 + } else {
63956 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63957 + read_lock(&tasklist_lock);
63958 + read_lock(&grsec_exec_file_lock);
63959 + do_each_thread(tsk2, tsk) {
63960 + if (likely(tsk != task)) {
63961 + // if this thread has the same subject as the one that triggered
63962 + // RES_CRASH and it's the same binary, kill it
63963 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
63964 + gr_fake_force_sig(SIGKILL, tsk);
63965 + }
63966 + } while_each_thread(tsk2, tsk);
63967 + read_unlock(&grsec_exec_file_lock);
63968 + read_unlock(&tasklist_lock);
63969 + }
63970 + rcu_read_unlock();
63971 + }
63972 +
63973 + return;
63974 +}
63975 +
63976 +int
63977 +gr_check_crash_exec(const struct file *filp)
63978 +{
63979 + struct acl_subject_label *curr;
63980 +
63981 + if (unlikely(!gr_acl_is_enabled()))
63982 + return 0;
63983 +
63984 + read_lock(&gr_inode_lock);
63985 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63986 + __get_dev(filp->f_path.dentry),
63987 + current->role);
63988 + read_unlock(&gr_inode_lock);
63989 +
63990 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63991 + (!curr->crashes && !curr->expires))
63992 + return 0;
63993 +
63994 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63995 + time_after(curr->expires, get_seconds()))
63996 + return 1;
63997 + else if (time_before_eq(curr->expires, get_seconds())) {
63998 + curr->crashes = 0;
63999 + curr->expires = 0;
64000 + }
64001 +
64002 + return 0;
64003 +}
64004 +
64005 +void
64006 +gr_handle_alertkill(struct task_struct *task)
64007 +{
64008 + struct acl_subject_label *curracl;
64009 + __u32 curr_ip;
64010 + struct task_struct *p, *p2;
64011 +
64012 + if (unlikely(!gr_acl_is_enabled()))
64013 + return;
64014 +
64015 + curracl = task->acl;
64016 + curr_ip = task->signal->curr_ip;
64017 +
64018 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
64019 + read_lock(&tasklist_lock);
64020 + do_each_thread(p2, p) {
64021 + if (p->signal->curr_ip == curr_ip)
64022 + gr_fake_force_sig(SIGKILL, p);
64023 + } while_each_thread(p2, p);
64024 + read_unlock(&tasklist_lock);
64025 + } else if (curracl->mode & GR_KILLPROC)
64026 + gr_fake_force_sig(SIGKILL, task);
64027 +
64028 + return;
64029 +}
64030 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
64031 new file mode 100644
64032 index 0000000..98011b0
64033 --- /dev/null
64034 +++ b/grsecurity/gracl_shm.c
64035 @@ -0,0 +1,40 @@
64036 +#include <linux/kernel.h>
64037 +#include <linux/mm.h>
64038 +#include <linux/sched.h>
64039 +#include <linux/file.h>
64040 +#include <linux/ipc.h>
64041 +#include <linux/gracl.h>
64042 +#include <linux/grsecurity.h>
64043 +#include <linux/grinternal.h>
64044 +
64045 +int
64046 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64047 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64048 +{
64049 + struct task_struct *task;
64050 +
64051 + if (!gr_acl_is_enabled())
64052 + return 1;
64053 +
64054 + rcu_read_lock();
64055 + read_lock(&tasklist_lock);
64056 +
64057 + task = find_task_by_vpid(shm_cprid);
64058 +
64059 + if (unlikely(!task))
64060 + task = find_task_by_vpid(shm_lapid);
64061 +
64062 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
64063 + (task_pid_nr(task) == shm_lapid)) &&
64064 + (task->acl->mode & GR_PROTSHM) &&
64065 + (task->acl != current->acl))) {
64066 + read_unlock(&tasklist_lock);
64067 + rcu_read_unlock();
64068 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
64069 + return 0;
64070 + }
64071 + read_unlock(&tasklist_lock);
64072 + rcu_read_unlock();
64073 +
64074 + return 1;
64075 +}
64076 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
64077 new file mode 100644
64078 index 0000000..bc0be01
64079 --- /dev/null
64080 +++ b/grsecurity/grsec_chdir.c
64081 @@ -0,0 +1,19 @@
64082 +#include <linux/kernel.h>
64083 +#include <linux/sched.h>
64084 +#include <linux/fs.h>
64085 +#include <linux/file.h>
64086 +#include <linux/grsecurity.h>
64087 +#include <linux/grinternal.h>
64088 +
64089 +void
64090 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64091 +{
64092 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64093 + if ((grsec_enable_chdir && grsec_enable_group &&
64094 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64095 + !grsec_enable_group)) {
64096 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64097 + }
64098 +#endif
64099 + return;
64100 +}
64101 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64102 new file mode 100644
64103 index 0000000..bd6e105
64104 --- /dev/null
64105 +++ b/grsecurity/grsec_chroot.c
64106 @@ -0,0 +1,370 @@
64107 +#include <linux/kernel.h>
64108 +#include <linux/module.h>
64109 +#include <linux/sched.h>
64110 +#include <linux/file.h>
64111 +#include <linux/fs.h>
64112 +#include <linux/mount.h>
64113 +#include <linux/types.h>
64114 +#include "../fs/mount.h"
64115 +#include <linux/grsecurity.h>
64116 +#include <linux/grinternal.h>
64117 +
64118 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64119 +static int gr_init_ran;
64120 +#endif
64121 +
64122 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
64123 +{
64124 +#ifdef CONFIG_GRKERNSEC
64125 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64126 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64127 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64128 + && gr_init_ran
64129 +#endif
64130 + )
64131 + task->gr_is_chrooted = 1;
64132 + else {
64133 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64134 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64135 + gr_init_ran = 1;
64136 +#endif
64137 + task->gr_is_chrooted = 0;
64138 + }
64139 +
64140 + task->gr_chroot_dentry = path->dentry;
64141 +#endif
64142 + return;
64143 +}
64144 +
64145 +void gr_clear_chroot_entries(struct task_struct *task)
64146 +{
64147 +#ifdef CONFIG_GRKERNSEC
64148 + task->gr_is_chrooted = 0;
64149 + task->gr_chroot_dentry = NULL;
64150 +#endif
64151 + return;
64152 +}
64153 +
64154 +int
64155 +gr_handle_chroot_unix(const pid_t pid)
64156 +{
64157 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64158 + struct task_struct *p;
64159 +
64160 + if (unlikely(!grsec_enable_chroot_unix))
64161 + return 1;
64162 +
64163 + if (likely(!proc_is_chrooted(current)))
64164 + return 1;
64165 +
64166 + rcu_read_lock();
64167 + read_lock(&tasklist_lock);
64168 + p = find_task_by_vpid_unrestricted(pid);
64169 + if (unlikely(p && !have_same_root(current, p))) {
64170 + read_unlock(&tasklist_lock);
64171 + rcu_read_unlock();
64172 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64173 + return 0;
64174 + }
64175 + read_unlock(&tasklist_lock);
64176 + rcu_read_unlock();
64177 +#endif
64178 + return 1;
64179 +}
64180 +
64181 +int
64182 +gr_handle_chroot_nice(void)
64183 +{
64184 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64185 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64186 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64187 + return -EPERM;
64188 + }
64189 +#endif
64190 + return 0;
64191 +}
64192 +
64193 +int
64194 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64195 +{
64196 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64197 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64198 + && proc_is_chrooted(current)) {
64199 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64200 + return -EACCES;
64201 + }
64202 +#endif
64203 + return 0;
64204 +}
64205 +
64206 +int
64207 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64208 +{
64209 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64210 + struct task_struct *p;
64211 + int ret = 0;
64212 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64213 + return ret;
64214 +
64215 + read_lock(&tasklist_lock);
64216 + do_each_pid_task(pid, type, p) {
64217 + if (!have_same_root(current, p)) {
64218 + ret = 1;
64219 + goto out;
64220 + }
64221 + } while_each_pid_task(pid, type, p);
64222 +out:
64223 + read_unlock(&tasklist_lock);
64224 + return ret;
64225 +#endif
64226 + return 0;
64227 +}
64228 +
64229 +int
64230 +gr_pid_is_chrooted(struct task_struct *p)
64231 +{
64232 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64233 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64234 + return 0;
64235 +
64236 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64237 + !have_same_root(current, p)) {
64238 + return 1;
64239 + }
64240 +#endif
64241 + return 0;
64242 +}
64243 +
64244 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64245 +
64246 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64247 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64248 +{
64249 + struct path path, currentroot;
64250 + int ret = 0;
64251 +
64252 + path.dentry = (struct dentry *)u_dentry;
64253 + path.mnt = (struct vfsmount *)u_mnt;
64254 + get_fs_root(current->fs, &currentroot);
64255 + if (path_is_under(&path, &currentroot))
64256 + ret = 1;
64257 + path_put(&currentroot);
64258 +
64259 + return ret;
64260 +}
64261 +#endif
64262 +
64263 +int
64264 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64265 +{
64266 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64267 + if (!grsec_enable_chroot_fchdir)
64268 + return 1;
64269 +
64270 + if (!proc_is_chrooted(current))
64271 + return 1;
64272 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64273 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64274 + return 0;
64275 + }
64276 +#endif
64277 + return 1;
64278 +}
64279 +
64280 +int
64281 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64282 + const time_t shm_createtime)
64283 +{
64284 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64285 + struct task_struct *p;
64286 + time_t starttime;
64287 +
64288 + if (unlikely(!grsec_enable_chroot_shmat))
64289 + return 1;
64290 +
64291 + if (likely(!proc_is_chrooted(current)))
64292 + return 1;
64293 +
64294 + rcu_read_lock();
64295 + read_lock(&tasklist_lock);
64296 +
64297 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64298 + starttime = p->start_time.tv_sec;
64299 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64300 + if (have_same_root(current, p)) {
64301 + goto allow;
64302 + } else {
64303 + read_unlock(&tasklist_lock);
64304 + rcu_read_unlock();
64305 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64306 + return 0;
64307 + }
64308 + }
64309 + /* creator exited, pid reuse, fall through to next check */
64310 + }
64311 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64312 + if (unlikely(!have_same_root(current, p))) {
64313 + read_unlock(&tasklist_lock);
64314 + rcu_read_unlock();
64315 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64316 + return 0;
64317 + }
64318 + }
64319 +
64320 +allow:
64321 + read_unlock(&tasklist_lock);
64322 + rcu_read_unlock();
64323 +#endif
64324 + return 1;
64325 +}
64326 +
64327 +void
64328 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64329 +{
64330 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64331 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64332 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64333 +#endif
64334 + return;
64335 +}
64336 +
64337 +int
64338 +gr_handle_chroot_mknod(const struct dentry *dentry,
64339 + const struct vfsmount *mnt, const int mode)
64340 +{
64341 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64342 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64343 + proc_is_chrooted(current)) {
64344 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64345 + return -EPERM;
64346 + }
64347 +#endif
64348 + return 0;
64349 +}
64350 +
64351 +int
64352 +gr_handle_chroot_mount(const struct dentry *dentry,
64353 + const struct vfsmount *mnt, const char *dev_name)
64354 +{
64355 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64356 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64357 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64358 + return -EPERM;
64359 + }
64360 +#endif
64361 + return 0;
64362 +}
64363 +
64364 +int
64365 +gr_handle_chroot_pivot(void)
64366 +{
64367 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64368 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64369 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64370 + return -EPERM;
64371 + }
64372 +#endif
64373 + return 0;
64374 +}
64375 +
64376 +int
64377 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64378 +{
64379 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64380 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64381 + !gr_is_outside_chroot(dentry, mnt)) {
64382 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64383 + return -EPERM;
64384 + }
64385 +#endif
64386 + return 0;
64387 +}
64388 +
64389 +extern const char *captab_log[];
64390 +extern int captab_log_entries;
64391 +
64392 +int
64393 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64394 +{
64395 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64396 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64397 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64398 + if (cap_raised(chroot_caps, cap)) {
64399 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64400 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64401 + }
64402 + return 0;
64403 + }
64404 + }
64405 +#endif
64406 + return 1;
64407 +}
64408 +
64409 +int
64410 +gr_chroot_is_capable(const int cap)
64411 +{
64412 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64413 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64414 +#endif
64415 + return 1;
64416 +}
64417 +
64418 +int
64419 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64420 +{
64421 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64422 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64423 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64424 + if (cap_raised(chroot_caps, cap)) {
64425 + return 0;
64426 + }
64427 + }
64428 +#endif
64429 + return 1;
64430 +}
64431 +
64432 +int
64433 +gr_chroot_is_capable_nolog(const int cap)
64434 +{
64435 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64436 + return gr_task_chroot_is_capable_nolog(current, cap);
64437 +#endif
64438 + return 1;
64439 +}
64440 +
64441 +int
64442 +gr_handle_chroot_sysctl(const int op)
64443 +{
64444 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64445 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64446 + proc_is_chrooted(current))
64447 + return -EACCES;
64448 +#endif
64449 + return 0;
64450 +}
64451 +
64452 +void
64453 +gr_handle_chroot_chdir(const struct path *path)
64454 +{
64455 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64456 + if (grsec_enable_chroot_chdir)
64457 + set_fs_pwd(current->fs, path);
64458 +#endif
64459 + return;
64460 +}
64461 +
64462 +int
64463 +gr_handle_chroot_chmod(const struct dentry *dentry,
64464 + const struct vfsmount *mnt, const int mode)
64465 +{
64466 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64467 + /* allow chmod +s on directories, but not files */
64468 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64469 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64470 + proc_is_chrooted(current)) {
64471 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64472 + return -EPERM;
64473 + }
64474 +#endif
64475 + return 0;
64476 +}
64477 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64478 new file mode 100644
64479 index 0000000..ce65ceb
64480 --- /dev/null
64481 +++ b/grsecurity/grsec_disabled.c
64482 @@ -0,0 +1,434 @@
64483 +#include <linux/kernel.h>
64484 +#include <linux/module.h>
64485 +#include <linux/sched.h>
64486 +#include <linux/file.h>
64487 +#include <linux/fs.h>
64488 +#include <linux/kdev_t.h>
64489 +#include <linux/net.h>
64490 +#include <linux/in.h>
64491 +#include <linux/ip.h>
64492 +#include <linux/skbuff.h>
64493 +#include <linux/sysctl.h>
64494 +
64495 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64496 +void
64497 +pax_set_initial_flags(struct linux_binprm *bprm)
64498 +{
64499 + return;
64500 +}
64501 +#endif
64502 +
64503 +#ifdef CONFIG_SYSCTL
64504 +__u32
64505 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64506 +{
64507 + return 0;
64508 +}
64509 +#endif
64510 +
64511 +#ifdef CONFIG_TASKSTATS
64512 +int gr_is_taskstats_denied(int pid)
64513 +{
64514 + return 0;
64515 +}
64516 +#endif
64517 +
64518 +int
64519 +gr_acl_is_enabled(void)
64520 +{
64521 + return 0;
64522 +}
64523 +
64524 +void
64525 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64526 +{
64527 + return;
64528 +}
64529 +
64530 +int
64531 +gr_handle_rawio(const struct inode *inode)
64532 +{
64533 + return 0;
64534 +}
64535 +
64536 +void
64537 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64538 +{
64539 + return;
64540 +}
64541 +
64542 +int
64543 +gr_handle_ptrace(struct task_struct *task, const long request)
64544 +{
64545 + return 0;
64546 +}
64547 +
64548 +int
64549 +gr_handle_proc_ptrace(struct task_struct *task)
64550 +{
64551 + return 0;
64552 +}
64553 +
64554 +int
64555 +gr_set_acls(const int type)
64556 +{
64557 + return 0;
64558 +}
64559 +
64560 +int
64561 +gr_check_hidden_task(const struct task_struct *tsk)
64562 +{
64563 + return 0;
64564 +}
64565 +
64566 +int
64567 +gr_check_protected_task(const struct task_struct *task)
64568 +{
64569 + return 0;
64570 +}
64571 +
64572 +int
64573 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64574 +{
64575 + return 0;
64576 +}
64577 +
64578 +void
64579 +gr_copy_label(struct task_struct *tsk)
64580 +{
64581 + return;
64582 +}
64583 +
64584 +void
64585 +gr_set_pax_flags(struct task_struct *task)
64586 +{
64587 + return;
64588 +}
64589 +
64590 +int
64591 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64592 + const int unsafe_share)
64593 +{
64594 + return 0;
64595 +}
64596 +
64597 +void
64598 +gr_handle_delete(const ino_t ino, const dev_t dev)
64599 +{
64600 + return;
64601 +}
64602 +
64603 +void
64604 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64605 +{
64606 + return;
64607 +}
64608 +
64609 +void
64610 +gr_handle_crash(struct task_struct *task, const int sig)
64611 +{
64612 + return;
64613 +}
64614 +
64615 +int
64616 +gr_check_crash_exec(const struct file *filp)
64617 +{
64618 + return 0;
64619 +}
64620 +
64621 +int
64622 +gr_check_crash_uid(const kuid_t uid)
64623 +{
64624 + return 0;
64625 +}
64626 +
64627 +void
64628 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64629 + struct dentry *old_dentry,
64630 + struct dentry *new_dentry,
64631 + struct vfsmount *mnt, const __u8 replace)
64632 +{
64633 + return;
64634 +}
64635 +
64636 +int
64637 +gr_search_socket(const int family, const int type, const int protocol)
64638 +{
64639 + return 1;
64640 +}
64641 +
64642 +int
64643 +gr_search_connectbind(const int mode, const struct socket *sock,
64644 + const struct sockaddr_in *addr)
64645 +{
64646 + return 0;
64647 +}
64648 +
64649 +void
64650 +gr_handle_alertkill(struct task_struct *task)
64651 +{
64652 + return;
64653 +}
64654 +
64655 +__u32
64656 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64657 +{
64658 + return 1;
64659 +}
64660 +
64661 +__u32
64662 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64663 + const struct vfsmount * mnt)
64664 +{
64665 + return 1;
64666 +}
64667 +
64668 +__u32
64669 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64670 + int acc_mode)
64671 +{
64672 + return 1;
64673 +}
64674 +
64675 +__u32
64676 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64677 +{
64678 + return 1;
64679 +}
64680 +
64681 +__u32
64682 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64683 +{
64684 + return 1;
64685 +}
64686 +
64687 +int
64688 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64689 + unsigned int *vm_flags)
64690 +{
64691 + return 1;
64692 +}
64693 +
64694 +__u32
64695 +gr_acl_handle_truncate(const struct dentry * dentry,
64696 + const struct vfsmount * mnt)
64697 +{
64698 + return 1;
64699 +}
64700 +
64701 +__u32
64702 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64703 +{
64704 + return 1;
64705 +}
64706 +
64707 +__u32
64708 +gr_acl_handle_access(const struct dentry * dentry,
64709 + const struct vfsmount * mnt, const int fmode)
64710 +{
64711 + return 1;
64712 +}
64713 +
64714 +__u32
64715 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64716 + umode_t *mode)
64717 +{
64718 + return 1;
64719 +}
64720 +
64721 +__u32
64722 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64723 +{
64724 + return 1;
64725 +}
64726 +
64727 +__u32
64728 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64729 +{
64730 + return 1;
64731 +}
64732 +
64733 +void
64734 +grsecurity_init(void)
64735 +{
64736 + return;
64737 +}
64738 +
64739 +umode_t gr_acl_umask(void)
64740 +{
64741 + return 0;
64742 +}
64743 +
64744 +__u32
64745 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64746 + const struct dentry * parent_dentry,
64747 + const struct vfsmount * parent_mnt,
64748 + const int mode)
64749 +{
64750 + return 1;
64751 +}
64752 +
64753 +__u32
64754 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64755 + const struct dentry * parent_dentry,
64756 + const struct vfsmount * parent_mnt)
64757 +{
64758 + return 1;
64759 +}
64760 +
64761 +__u32
64762 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64763 + const struct dentry * parent_dentry,
64764 + const struct vfsmount * parent_mnt, const struct filename *from)
64765 +{
64766 + return 1;
64767 +}
64768 +
64769 +__u32
64770 +gr_acl_handle_link(const struct dentry * new_dentry,
64771 + const struct dentry * parent_dentry,
64772 + const struct vfsmount * parent_mnt,
64773 + const struct dentry * old_dentry,
64774 + const struct vfsmount * old_mnt, const struct filename *to)
64775 +{
64776 + return 1;
64777 +}
64778 +
64779 +int
64780 +gr_acl_handle_rename(const struct dentry *new_dentry,
64781 + const struct dentry *parent_dentry,
64782 + const struct vfsmount *parent_mnt,
64783 + const struct dentry *old_dentry,
64784 + const struct inode *old_parent_inode,
64785 + const struct vfsmount *old_mnt, const struct filename *newname)
64786 +{
64787 + return 0;
64788 +}
64789 +
64790 +int
64791 +gr_acl_handle_filldir(const struct file *file, const char *name,
64792 + const int namelen, const ino_t ino)
64793 +{
64794 + return 1;
64795 +}
64796 +
64797 +int
64798 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64799 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64800 +{
64801 + return 1;
64802 +}
64803 +
64804 +int
64805 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64806 +{
64807 + return 0;
64808 +}
64809 +
64810 +int
64811 +gr_search_accept(const struct socket *sock)
64812 +{
64813 + return 0;
64814 +}
64815 +
64816 +int
64817 +gr_search_listen(const struct socket *sock)
64818 +{
64819 + return 0;
64820 +}
64821 +
64822 +int
64823 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64824 +{
64825 + return 0;
64826 +}
64827 +
64828 +__u32
64829 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64830 +{
64831 + return 1;
64832 +}
64833 +
64834 +__u32
64835 +gr_acl_handle_creat(const struct dentry * dentry,
64836 + const struct dentry * p_dentry,
64837 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64838 + const int imode)
64839 +{
64840 + return 1;
64841 +}
64842 +
64843 +void
64844 +gr_acl_handle_exit(void)
64845 +{
64846 + return;
64847 +}
64848 +
64849 +int
64850 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64851 +{
64852 + return 1;
64853 +}
64854 +
64855 +void
64856 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64857 +{
64858 + return;
64859 +}
64860 +
64861 +int
64862 +gr_acl_handle_procpidmem(const struct task_struct *task)
64863 +{
64864 + return 0;
64865 +}
64866 +
64867 +int
64868 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64869 +{
64870 + return 0;
64871 +}
64872 +
64873 +int
64874 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64875 +{
64876 + return 0;
64877 +}
64878 +
64879 +void
64880 +gr_set_kernel_label(struct task_struct *task)
64881 +{
64882 + return;
64883 +}
64884 +
64885 +int
64886 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64887 +{
64888 + return 0;
64889 +}
64890 +
64891 +int
64892 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64893 +{
64894 + return 0;
64895 +}
64896 +
64897 +int gr_acl_enable_at_secure(void)
64898 +{
64899 + return 0;
64900 +}
64901 +
64902 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64903 +{
64904 + return dentry->d_sb->s_dev;
64905 +}
64906 +
64907 +void gr_put_exec_file(struct task_struct *task)
64908 +{
64909 + return;
64910 +}
64911 +
64912 +EXPORT_SYMBOL(gr_set_kernel_label);
64913 +#ifdef CONFIG_SECURITY
64914 +EXPORT_SYMBOL(gr_check_user_change);
64915 +EXPORT_SYMBOL(gr_check_group_change);
64916 +#endif
64917 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64918 new file mode 100644
64919 index 0000000..387032b
64920 --- /dev/null
64921 +++ b/grsecurity/grsec_exec.c
64922 @@ -0,0 +1,187 @@
64923 +#include <linux/kernel.h>
64924 +#include <linux/sched.h>
64925 +#include <linux/file.h>
64926 +#include <linux/binfmts.h>
64927 +#include <linux/fs.h>
64928 +#include <linux/types.h>
64929 +#include <linux/grdefs.h>
64930 +#include <linux/grsecurity.h>
64931 +#include <linux/grinternal.h>
64932 +#include <linux/capability.h>
64933 +#include <linux/module.h>
64934 +#include <linux/compat.h>
64935 +
64936 +#include <asm/uaccess.h>
64937 +
64938 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64939 +static char gr_exec_arg_buf[132];
64940 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64941 +#endif
64942 +
64943 +struct user_arg_ptr {
64944 +#ifdef CONFIG_COMPAT
64945 + bool is_compat;
64946 +#endif
64947 + union {
64948 + const char __user *const __user *native;
64949 +#ifdef CONFIG_COMPAT
64950 + const compat_uptr_t __user *compat;
64951 +#endif
64952 + } ptr;
64953 +};
64954 +
64955 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64956 +
64957 +void
64958 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64959 +{
64960 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64961 + char *grarg = gr_exec_arg_buf;
64962 + unsigned int i, x, execlen = 0;
64963 + char c;
64964 +
64965 + if (!((grsec_enable_execlog && grsec_enable_group &&
64966 + in_group_p(grsec_audit_gid))
64967 + || (grsec_enable_execlog && !grsec_enable_group)))
64968 + return;
64969 +
64970 + mutex_lock(&gr_exec_arg_mutex);
64971 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64972 +
64973 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64974 + const char __user *p;
64975 + unsigned int len;
64976 +
64977 + p = get_user_arg_ptr(argv, i);
64978 + if (IS_ERR(p))
64979 + goto log;
64980 +
64981 + len = strnlen_user(p, 128 - execlen);
64982 + if (len > 128 - execlen)
64983 + len = 128 - execlen;
64984 + else if (len > 0)
64985 + len--;
64986 + if (copy_from_user(grarg + execlen, p, len))
64987 + goto log;
64988 +
64989 + /* rewrite unprintable characters */
64990 + for (x = 0; x < len; x++) {
64991 + c = *(grarg + execlen + x);
64992 + if (c < 32 || c > 126)
64993 + *(grarg + execlen + x) = ' ';
64994 + }
64995 +
64996 + execlen += len;
64997 + *(grarg + execlen) = ' ';
64998 + *(grarg + execlen + 1) = '\0';
64999 + execlen++;
65000 + }
65001 +
65002 + log:
65003 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
65004 + bprm->file->f_path.mnt, grarg);
65005 + mutex_unlock(&gr_exec_arg_mutex);
65006 +#endif
65007 + return;
65008 +}
65009 +
65010 +#ifdef CONFIG_GRKERNSEC
65011 +extern int gr_acl_is_capable(const int cap);
65012 +extern int gr_acl_is_capable_nolog(const int cap);
65013 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65014 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
65015 +extern int gr_chroot_is_capable(const int cap);
65016 +extern int gr_chroot_is_capable_nolog(const int cap);
65017 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65018 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
65019 +#endif
65020 +
65021 +const char *captab_log[] = {
65022 + "CAP_CHOWN",
65023 + "CAP_DAC_OVERRIDE",
65024 + "CAP_DAC_READ_SEARCH",
65025 + "CAP_FOWNER",
65026 + "CAP_FSETID",
65027 + "CAP_KILL",
65028 + "CAP_SETGID",
65029 + "CAP_SETUID",
65030 + "CAP_SETPCAP",
65031 + "CAP_LINUX_IMMUTABLE",
65032 + "CAP_NET_BIND_SERVICE",
65033 + "CAP_NET_BROADCAST",
65034 + "CAP_NET_ADMIN",
65035 + "CAP_NET_RAW",
65036 + "CAP_IPC_LOCK",
65037 + "CAP_IPC_OWNER",
65038 + "CAP_SYS_MODULE",
65039 + "CAP_SYS_RAWIO",
65040 + "CAP_SYS_CHROOT",
65041 + "CAP_SYS_PTRACE",
65042 + "CAP_SYS_PACCT",
65043 + "CAP_SYS_ADMIN",
65044 + "CAP_SYS_BOOT",
65045 + "CAP_SYS_NICE",
65046 + "CAP_SYS_RESOURCE",
65047 + "CAP_SYS_TIME",
65048 + "CAP_SYS_TTY_CONFIG",
65049 + "CAP_MKNOD",
65050 + "CAP_LEASE",
65051 + "CAP_AUDIT_WRITE",
65052 + "CAP_AUDIT_CONTROL",
65053 + "CAP_SETFCAP",
65054 + "CAP_MAC_OVERRIDE",
65055 + "CAP_MAC_ADMIN",
65056 + "CAP_SYSLOG",
65057 + "CAP_WAKE_ALARM"
65058 +};
65059 +
65060 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
65061 +
65062 +int gr_is_capable(const int cap)
65063 +{
65064 +#ifdef CONFIG_GRKERNSEC
65065 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
65066 + return 1;
65067 + return 0;
65068 +#else
65069 + return 1;
65070 +#endif
65071 +}
65072 +
65073 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65074 +{
65075 +#ifdef CONFIG_GRKERNSEC
65076 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
65077 + return 1;
65078 + return 0;
65079 +#else
65080 + return 1;
65081 +#endif
65082 +}
65083 +
65084 +int gr_is_capable_nolog(const int cap)
65085 +{
65086 +#ifdef CONFIG_GRKERNSEC
65087 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
65088 + return 1;
65089 + return 0;
65090 +#else
65091 + return 1;
65092 +#endif
65093 +}
65094 +
65095 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
65096 +{
65097 +#ifdef CONFIG_GRKERNSEC
65098 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65099 + return 1;
65100 + return 0;
65101 +#else
65102 + return 1;
65103 +#endif
65104 +}
65105 +
65106 +EXPORT_SYMBOL(gr_is_capable);
65107 +EXPORT_SYMBOL(gr_is_capable_nolog);
65108 +EXPORT_SYMBOL(gr_task_is_capable);
65109 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65110 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65111 new file mode 100644
65112 index 0000000..06cc6ea
65113 --- /dev/null
65114 +++ b/grsecurity/grsec_fifo.c
65115 @@ -0,0 +1,24 @@
65116 +#include <linux/kernel.h>
65117 +#include <linux/sched.h>
65118 +#include <linux/fs.h>
65119 +#include <linux/file.h>
65120 +#include <linux/grinternal.h>
65121 +
65122 +int
65123 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65124 + const struct dentry *dir, const int flag, const int acc_mode)
65125 +{
65126 +#ifdef CONFIG_GRKERNSEC_FIFO
65127 + const struct cred *cred = current_cred();
65128 +
65129 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65130 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65131 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65132 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65133 + if (!inode_permission(dentry->d_inode, acc_mode))
65134 + 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));
65135 + return -EACCES;
65136 + }
65137 +#endif
65138 + return 0;
65139 +}
65140 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65141 new file mode 100644
65142 index 0000000..8ca18bf
65143 --- /dev/null
65144 +++ b/grsecurity/grsec_fork.c
65145 @@ -0,0 +1,23 @@
65146 +#include <linux/kernel.h>
65147 +#include <linux/sched.h>
65148 +#include <linux/grsecurity.h>
65149 +#include <linux/grinternal.h>
65150 +#include <linux/errno.h>
65151 +
65152 +void
65153 +gr_log_forkfail(const int retval)
65154 +{
65155 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65156 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65157 + switch (retval) {
65158 + case -EAGAIN:
65159 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65160 + break;
65161 + case -ENOMEM:
65162 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65163 + break;
65164 + }
65165 + }
65166 +#endif
65167 + return;
65168 +}
65169 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65170 new file mode 100644
65171 index 0000000..a862e9f
65172 --- /dev/null
65173 +++ b/grsecurity/grsec_init.c
65174 @@ -0,0 +1,283 @@
65175 +#include <linux/kernel.h>
65176 +#include <linux/sched.h>
65177 +#include <linux/mm.h>
65178 +#include <linux/gracl.h>
65179 +#include <linux/slab.h>
65180 +#include <linux/vmalloc.h>
65181 +#include <linux/percpu.h>
65182 +#include <linux/module.h>
65183 +
65184 +int grsec_enable_ptrace_readexec;
65185 +int grsec_enable_setxid;
65186 +int grsec_enable_symlinkown;
65187 +kgid_t grsec_symlinkown_gid;
65188 +int grsec_enable_brute;
65189 +int grsec_enable_link;
65190 +int grsec_enable_dmesg;
65191 +int grsec_enable_harden_ptrace;
65192 +int grsec_enable_fifo;
65193 +int grsec_enable_execlog;
65194 +int grsec_enable_signal;
65195 +int grsec_enable_forkfail;
65196 +int grsec_enable_audit_ptrace;
65197 +int grsec_enable_time;
65198 +int grsec_enable_audit_textrel;
65199 +int grsec_enable_group;
65200 +kgid_t grsec_audit_gid;
65201 +int grsec_enable_chdir;
65202 +int grsec_enable_mount;
65203 +int grsec_enable_rofs;
65204 +int grsec_enable_chroot_findtask;
65205 +int grsec_enable_chroot_mount;
65206 +int grsec_enable_chroot_shmat;
65207 +int grsec_enable_chroot_fchdir;
65208 +int grsec_enable_chroot_double;
65209 +int grsec_enable_chroot_pivot;
65210 +int grsec_enable_chroot_chdir;
65211 +int grsec_enable_chroot_chmod;
65212 +int grsec_enable_chroot_mknod;
65213 +int grsec_enable_chroot_nice;
65214 +int grsec_enable_chroot_execlog;
65215 +int grsec_enable_chroot_caps;
65216 +int grsec_enable_chroot_sysctl;
65217 +int grsec_enable_chroot_unix;
65218 +int grsec_enable_tpe;
65219 +kgid_t grsec_tpe_gid;
65220 +int grsec_enable_blackhole;
65221 +#ifdef CONFIG_IPV6_MODULE
65222 +EXPORT_SYMBOL(grsec_enable_blackhole);
65223 +#endif
65224 +int grsec_lastack_retries;
65225 +int grsec_enable_tpe_all;
65226 +int grsec_enable_tpe_invert;
65227 +int grsec_enable_socket_all;
65228 +kgid_t grsec_socket_all_gid;
65229 +int grsec_enable_socket_client;
65230 +kgid_t grsec_socket_client_gid;
65231 +int grsec_enable_socket_server;
65232 +kgid_t grsec_socket_server_gid;
65233 +int grsec_resource_logging;
65234 +int grsec_disable_privio;
65235 +int grsec_enable_log_rwxmaps;
65236 +int grsec_lock;
65237 +
65238 +DEFINE_SPINLOCK(grsec_alert_lock);
65239 +unsigned long grsec_alert_wtime = 0;
65240 +unsigned long grsec_alert_fyet = 0;
65241 +
65242 +DEFINE_SPINLOCK(grsec_audit_lock);
65243 +
65244 +DEFINE_RWLOCK(grsec_exec_file_lock);
65245 +
65246 +char *gr_shared_page[4];
65247 +
65248 +char *gr_alert_log_fmt;
65249 +char *gr_audit_log_fmt;
65250 +char *gr_alert_log_buf;
65251 +char *gr_audit_log_buf;
65252 +
65253 +extern struct gr_arg *gr_usermode;
65254 +extern unsigned char *gr_system_salt;
65255 +extern unsigned char *gr_system_sum;
65256 +
65257 +void __init
65258 +grsecurity_init(void)
65259 +{
65260 + int j;
65261 + /* create the per-cpu shared pages */
65262 +
65263 +#ifdef CONFIG_X86
65264 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65265 +#endif
65266 +
65267 + for (j = 0; j < 4; j++) {
65268 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65269 + if (gr_shared_page[j] == NULL) {
65270 + panic("Unable to allocate grsecurity shared page");
65271 + return;
65272 + }
65273 + }
65274 +
65275 + /* allocate log buffers */
65276 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65277 + if (!gr_alert_log_fmt) {
65278 + panic("Unable to allocate grsecurity alert log format buffer");
65279 + return;
65280 + }
65281 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65282 + if (!gr_audit_log_fmt) {
65283 + panic("Unable to allocate grsecurity audit log format buffer");
65284 + return;
65285 + }
65286 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65287 + if (!gr_alert_log_buf) {
65288 + panic("Unable to allocate grsecurity alert log buffer");
65289 + return;
65290 + }
65291 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65292 + if (!gr_audit_log_buf) {
65293 + panic("Unable to allocate grsecurity audit log buffer");
65294 + return;
65295 + }
65296 +
65297 + /* allocate memory for authentication structure */
65298 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65299 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65300 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65301 +
65302 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65303 + panic("Unable to allocate grsecurity authentication structure");
65304 + return;
65305 + }
65306 +
65307 +
65308 +#ifdef CONFIG_GRKERNSEC_IO
65309 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65310 + grsec_disable_privio = 1;
65311 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65312 + grsec_disable_privio = 1;
65313 +#else
65314 + grsec_disable_privio = 0;
65315 +#endif
65316 +#endif
65317 +
65318 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65319 + /* for backward compatibility, tpe_invert always defaults to on if
65320 + enabled in the kernel
65321 + */
65322 + grsec_enable_tpe_invert = 1;
65323 +#endif
65324 +
65325 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65326 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65327 + grsec_lock = 1;
65328 +#endif
65329 +
65330 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65331 + grsec_enable_audit_textrel = 1;
65332 +#endif
65333 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65334 + grsec_enable_log_rwxmaps = 1;
65335 +#endif
65336 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65337 + grsec_enable_group = 1;
65338 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65339 +#endif
65340 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65341 + grsec_enable_ptrace_readexec = 1;
65342 +#endif
65343 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65344 + grsec_enable_chdir = 1;
65345 +#endif
65346 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65347 + grsec_enable_harden_ptrace = 1;
65348 +#endif
65349 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65350 + grsec_enable_mount = 1;
65351 +#endif
65352 +#ifdef CONFIG_GRKERNSEC_LINK
65353 + grsec_enable_link = 1;
65354 +#endif
65355 +#ifdef CONFIG_GRKERNSEC_BRUTE
65356 + grsec_enable_brute = 1;
65357 +#endif
65358 +#ifdef CONFIG_GRKERNSEC_DMESG
65359 + grsec_enable_dmesg = 1;
65360 +#endif
65361 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65362 + grsec_enable_blackhole = 1;
65363 + grsec_lastack_retries = 4;
65364 +#endif
65365 +#ifdef CONFIG_GRKERNSEC_FIFO
65366 + grsec_enable_fifo = 1;
65367 +#endif
65368 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65369 + grsec_enable_execlog = 1;
65370 +#endif
65371 +#ifdef CONFIG_GRKERNSEC_SETXID
65372 + grsec_enable_setxid = 1;
65373 +#endif
65374 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65375 + grsec_enable_signal = 1;
65376 +#endif
65377 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65378 + grsec_enable_forkfail = 1;
65379 +#endif
65380 +#ifdef CONFIG_GRKERNSEC_TIME
65381 + grsec_enable_time = 1;
65382 +#endif
65383 +#ifdef CONFIG_GRKERNSEC_RESLOG
65384 + grsec_resource_logging = 1;
65385 +#endif
65386 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65387 + grsec_enable_chroot_findtask = 1;
65388 +#endif
65389 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65390 + grsec_enable_chroot_unix = 1;
65391 +#endif
65392 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65393 + grsec_enable_chroot_mount = 1;
65394 +#endif
65395 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65396 + grsec_enable_chroot_fchdir = 1;
65397 +#endif
65398 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65399 + grsec_enable_chroot_shmat = 1;
65400 +#endif
65401 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65402 + grsec_enable_audit_ptrace = 1;
65403 +#endif
65404 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65405 + grsec_enable_chroot_double = 1;
65406 +#endif
65407 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65408 + grsec_enable_chroot_pivot = 1;
65409 +#endif
65410 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65411 + grsec_enable_chroot_chdir = 1;
65412 +#endif
65413 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65414 + grsec_enable_chroot_chmod = 1;
65415 +#endif
65416 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65417 + grsec_enable_chroot_mknod = 1;
65418 +#endif
65419 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65420 + grsec_enable_chroot_nice = 1;
65421 +#endif
65422 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65423 + grsec_enable_chroot_execlog = 1;
65424 +#endif
65425 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65426 + grsec_enable_chroot_caps = 1;
65427 +#endif
65428 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65429 + grsec_enable_chroot_sysctl = 1;
65430 +#endif
65431 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65432 + grsec_enable_symlinkown = 1;
65433 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65434 +#endif
65435 +#ifdef CONFIG_GRKERNSEC_TPE
65436 + grsec_enable_tpe = 1;
65437 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65438 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65439 + grsec_enable_tpe_all = 1;
65440 +#endif
65441 +#endif
65442 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65443 + grsec_enable_socket_all = 1;
65444 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65445 +#endif
65446 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65447 + grsec_enable_socket_client = 1;
65448 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65449 +#endif
65450 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65451 + grsec_enable_socket_server = 1;
65452 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65453 +#endif
65454 +#endif
65455 +
65456 + return;
65457 +}
65458 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65459 new file mode 100644
65460 index 0000000..5e05e20
65461 --- /dev/null
65462 +++ b/grsecurity/grsec_link.c
65463 @@ -0,0 +1,58 @@
65464 +#include <linux/kernel.h>
65465 +#include <linux/sched.h>
65466 +#include <linux/fs.h>
65467 +#include <linux/file.h>
65468 +#include <linux/grinternal.h>
65469 +
65470 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65471 +{
65472 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65473 + const struct inode *link_inode = link->dentry->d_inode;
65474 +
65475 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65476 + /* ignore root-owned links, e.g. /proc/self */
65477 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65478 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65479 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65480 + return 1;
65481 + }
65482 +#endif
65483 + return 0;
65484 +}
65485 +
65486 +int
65487 +gr_handle_follow_link(const struct inode *parent,
65488 + const struct inode *inode,
65489 + const struct dentry *dentry, const struct vfsmount *mnt)
65490 +{
65491 +#ifdef CONFIG_GRKERNSEC_LINK
65492 + const struct cred *cred = current_cred();
65493 +
65494 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65495 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65496 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65497 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65498 + return -EACCES;
65499 + }
65500 +#endif
65501 + return 0;
65502 +}
65503 +
65504 +int
65505 +gr_handle_hardlink(const struct dentry *dentry,
65506 + const struct vfsmount *mnt,
65507 + struct inode *inode, const int mode, const struct filename *to)
65508 +{
65509 +#ifdef CONFIG_GRKERNSEC_LINK
65510 + const struct cred *cred = current_cred();
65511 +
65512 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65513 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65514 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65515 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65516 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65517 + return -EPERM;
65518 + }
65519 +#endif
65520 + return 0;
65521 +}
65522 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65523 new file mode 100644
65524 index 0000000..7c06085
65525 --- /dev/null
65526 +++ b/grsecurity/grsec_log.c
65527 @@ -0,0 +1,326 @@
65528 +#include <linux/kernel.h>
65529 +#include <linux/sched.h>
65530 +#include <linux/file.h>
65531 +#include <linux/tty.h>
65532 +#include <linux/fs.h>
65533 +#include <linux/grinternal.h>
65534 +
65535 +#ifdef CONFIG_TREE_PREEMPT_RCU
65536 +#define DISABLE_PREEMPT() preempt_disable()
65537 +#define ENABLE_PREEMPT() preempt_enable()
65538 +#else
65539 +#define DISABLE_PREEMPT()
65540 +#define ENABLE_PREEMPT()
65541 +#endif
65542 +
65543 +#define BEGIN_LOCKS(x) \
65544 + DISABLE_PREEMPT(); \
65545 + rcu_read_lock(); \
65546 + read_lock(&tasklist_lock); \
65547 + read_lock(&grsec_exec_file_lock); \
65548 + if (x != GR_DO_AUDIT) \
65549 + spin_lock(&grsec_alert_lock); \
65550 + else \
65551 + spin_lock(&grsec_audit_lock)
65552 +
65553 +#define END_LOCKS(x) \
65554 + if (x != GR_DO_AUDIT) \
65555 + spin_unlock(&grsec_alert_lock); \
65556 + else \
65557 + spin_unlock(&grsec_audit_lock); \
65558 + read_unlock(&grsec_exec_file_lock); \
65559 + read_unlock(&tasklist_lock); \
65560 + rcu_read_unlock(); \
65561 + ENABLE_PREEMPT(); \
65562 + if (x == GR_DONT_AUDIT) \
65563 + gr_handle_alertkill(current)
65564 +
65565 +enum {
65566 + FLOODING,
65567 + NO_FLOODING
65568 +};
65569 +
65570 +extern char *gr_alert_log_fmt;
65571 +extern char *gr_audit_log_fmt;
65572 +extern char *gr_alert_log_buf;
65573 +extern char *gr_audit_log_buf;
65574 +
65575 +static int gr_log_start(int audit)
65576 +{
65577 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65578 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65579 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65580 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65581 + unsigned long curr_secs = get_seconds();
65582 +
65583 + if (audit == GR_DO_AUDIT)
65584 + goto set_fmt;
65585 +
65586 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65587 + grsec_alert_wtime = curr_secs;
65588 + grsec_alert_fyet = 0;
65589 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65590 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65591 + grsec_alert_fyet++;
65592 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65593 + grsec_alert_wtime = curr_secs;
65594 + grsec_alert_fyet++;
65595 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65596 + return FLOODING;
65597 + }
65598 + else return FLOODING;
65599 +
65600 +set_fmt:
65601 +#endif
65602 + memset(buf, 0, PAGE_SIZE);
65603 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65604 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65605 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65606 + } else if (current->signal->curr_ip) {
65607 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65608 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65609 + } else if (gr_acl_is_enabled()) {
65610 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65611 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65612 + } else {
65613 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65614 + strcpy(buf, fmt);
65615 + }
65616 +
65617 + return NO_FLOODING;
65618 +}
65619 +
65620 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65621 + __attribute__ ((format (printf, 2, 0)));
65622 +
65623 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65624 +{
65625 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65626 + unsigned int len = strlen(buf);
65627 +
65628 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65629 +
65630 + return;
65631 +}
65632 +
65633 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65634 + __attribute__ ((format (printf, 2, 3)));
65635 +
65636 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65637 +{
65638 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65639 + unsigned int len = strlen(buf);
65640 + va_list ap;
65641 +
65642 + va_start(ap, msg);
65643 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65644 + va_end(ap);
65645 +
65646 + return;
65647 +}
65648 +
65649 +static void gr_log_end(int audit, int append_default)
65650 +{
65651 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65652 + if (append_default) {
65653 + struct task_struct *task = current;
65654 + struct task_struct *parent = task->real_parent;
65655 + const struct cred *cred = __task_cred(task);
65656 + const struct cred *pcred = __task_cred(parent);
65657 + unsigned int len = strlen(buf);
65658 +
65659 + 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));
65660 + }
65661 +
65662 + printk("%s\n", buf);
65663 +
65664 + return;
65665 +}
65666 +
65667 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65668 +{
65669 + int logtype;
65670 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65671 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65672 + void *voidptr = NULL;
65673 + int num1 = 0, num2 = 0;
65674 + unsigned long ulong1 = 0, ulong2 = 0;
65675 + struct dentry *dentry = NULL;
65676 + struct vfsmount *mnt = NULL;
65677 + struct file *file = NULL;
65678 + struct task_struct *task = NULL;
65679 + const struct cred *cred, *pcred;
65680 + va_list ap;
65681 +
65682 + BEGIN_LOCKS(audit);
65683 + logtype = gr_log_start(audit);
65684 + if (logtype == FLOODING) {
65685 + END_LOCKS(audit);
65686 + return;
65687 + }
65688 + va_start(ap, argtypes);
65689 + switch (argtypes) {
65690 + case GR_TTYSNIFF:
65691 + task = va_arg(ap, struct task_struct *);
65692 + 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));
65693 + break;
65694 + case GR_SYSCTL_HIDDEN:
65695 + str1 = va_arg(ap, char *);
65696 + gr_log_middle_varargs(audit, msg, result, str1);
65697 + break;
65698 + case GR_RBAC:
65699 + dentry = va_arg(ap, struct dentry *);
65700 + mnt = va_arg(ap, struct vfsmount *);
65701 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65702 + break;
65703 + case GR_RBAC_STR:
65704 + dentry = va_arg(ap, struct dentry *);
65705 + mnt = va_arg(ap, struct vfsmount *);
65706 + str1 = va_arg(ap, char *);
65707 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65708 + break;
65709 + case GR_STR_RBAC:
65710 + str1 = va_arg(ap, char *);
65711 + dentry = va_arg(ap, struct dentry *);
65712 + mnt = va_arg(ap, struct vfsmount *);
65713 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65714 + break;
65715 + case GR_RBAC_MODE2:
65716 + dentry = va_arg(ap, struct dentry *);
65717 + mnt = va_arg(ap, struct vfsmount *);
65718 + str1 = va_arg(ap, char *);
65719 + str2 = va_arg(ap, char *);
65720 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65721 + break;
65722 + case GR_RBAC_MODE3:
65723 + dentry = va_arg(ap, struct dentry *);
65724 + mnt = va_arg(ap, struct vfsmount *);
65725 + str1 = va_arg(ap, char *);
65726 + str2 = va_arg(ap, char *);
65727 + str3 = va_arg(ap, char *);
65728 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65729 + break;
65730 + case GR_FILENAME:
65731 + dentry = va_arg(ap, struct dentry *);
65732 + mnt = va_arg(ap, struct vfsmount *);
65733 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65734 + break;
65735 + case GR_STR_FILENAME:
65736 + str1 = va_arg(ap, char *);
65737 + dentry = va_arg(ap, struct dentry *);
65738 + mnt = va_arg(ap, struct vfsmount *);
65739 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65740 + break;
65741 + case GR_FILENAME_STR:
65742 + dentry = va_arg(ap, struct dentry *);
65743 + mnt = va_arg(ap, struct vfsmount *);
65744 + str1 = va_arg(ap, char *);
65745 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65746 + break;
65747 + case GR_FILENAME_TWO_INT:
65748 + dentry = va_arg(ap, struct dentry *);
65749 + mnt = va_arg(ap, struct vfsmount *);
65750 + num1 = va_arg(ap, int);
65751 + num2 = va_arg(ap, int);
65752 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65753 + break;
65754 + case GR_FILENAME_TWO_INT_STR:
65755 + dentry = va_arg(ap, struct dentry *);
65756 + mnt = va_arg(ap, struct vfsmount *);
65757 + num1 = va_arg(ap, int);
65758 + num2 = va_arg(ap, int);
65759 + str1 = va_arg(ap, char *);
65760 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65761 + break;
65762 + case GR_TEXTREL:
65763 + file = va_arg(ap, struct file *);
65764 + ulong1 = va_arg(ap, unsigned long);
65765 + ulong2 = va_arg(ap, unsigned long);
65766 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65767 + break;
65768 + case GR_PTRACE:
65769 + task = va_arg(ap, struct task_struct *);
65770 + 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));
65771 + break;
65772 + case GR_RESOURCE:
65773 + task = va_arg(ap, struct task_struct *);
65774 + cred = __task_cred(task);
65775 + pcred = __task_cred(task->real_parent);
65776 + ulong1 = va_arg(ap, unsigned long);
65777 + str1 = va_arg(ap, char *);
65778 + ulong2 = va_arg(ap, unsigned long);
65779 + 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));
65780 + break;
65781 + case GR_CAP:
65782 + task = va_arg(ap, struct task_struct *);
65783 + cred = __task_cred(task);
65784 + pcred = __task_cred(task->real_parent);
65785 + str1 = va_arg(ap, char *);
65786 + 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));
65787 + break;
65788 + case GR_SIG:
65789 + str1 = va_arg(ap, char *);
65790 + voidptr = va_arg(ap, void *);
65791 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65792 + break;
65793 + case GR_SIG2:
65794 + task = va_arg(ap, struct task_struct *);
65795 + cred = __task_cred(task);
65796 + pcred = __task_cred(task->real_parent);
65797 + num1 = va_arg(ap, int);
65798 + 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));
65799 + break;
65800 + case GR_CRASH1:
65801 + task = va_arg(ap, struct task_struct *);
65802 + cred = __task_cred(task);
65803 + pcred = __task_cred(task->real_parent);
65804 + ulong1 = va_arg(ap, unsigned long);
65805 + 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);
65806 + break;
65807 + case GR_CRASH2:
65808 + task = va_arg(ap, struct task_struct *);
65809 + cred = __task_cred(task);
65810 + pcred = __task_cred(task->real_parent);
65811 + ulong1 = va_arg(ap, unsigned long);
65812 + 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);
65813 + break;
65814 + case GR_RWXMAP:
65815 + file = va_arg(ap, struct file *);
65816 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65817 + break;
65818 + case GR_PSACCT:
65819 + {
65820 + unsigned int wday, cday;
65821 + __u8 whr, chr;
65822 + __u8 wmin, cmin;
65823 + __u8 wsec, csec;
65824 + char cur_tty[64] = { 0 };
65825 + char parent_tty[64] = { 0 };
65826 +
65827 + task = va_arg(ap, struct task_struct *);
65828 + wday = va_arg(ap, unsigned int);
65829 + cday = va_arg(ap, unsigned int);
65830 + whr = va_arg(ap, int);
65831 + chr = va_arg(ap, int);
65832 + wmin = va_arg(ap, int);
65833 + cmin = va_arg(ap, int);
65834 + wsec = va_arg(ap, int);
65835 + csec = va_arg(ap, int);
65836 + ulong1 = va_arg(ap, unsigned long);
65837 + cred = __task_cred(task);
65838 + pcred = __task_cred(task->real_parent);
65839 +
65840 + 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));
65841 + }
65842 + break;
65843 + default:
65844 + gr_log_middle(audit, msg, ap);
65845 + }
65846 + va_end(ap);
65847 + // these don't need DEFAULTSECARGS printed on the end
65848 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65849 + gr_log_end(audit, 0);
65850 + else
65851 + gr_log_end(audit, 1);
65852 + END_LOCKS(audit);
65853 +}
65854 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65855 new file mode 100644
65856 index 0000000..f536303
65857 --- /dev/null
65858 +++ b/grsecurity/grsec_mem.c
65859 @@ -0,0 +1,40 @@
65860 +#include <linux/kernel.h>
65861 +#include <linux/sched.h>
65862 +#include <linux/mm.h>
65863 +#include <linux/mman.h>
65864 +#include <linux/grinternal.h>
65865 +
65866 +void
65867 +gr_handle_ioperm(void)
65868 +{
65869 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65870 + return;
65871 +}
65872 +
65873 +void
65874 +gr_handle_iopl(void)
65875 +{
65876 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65877 + return;
65878 +}
65879 +
65880 +void
65881 +gr_handle_mem_readwrite(u64 from, u64 to)
65882 +{
65883 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65884 + return;
65885 +}
65886 +
65887 +void
65888 +gr_handle_vm86(void)
65889 +{
65890 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65891 + return;
65892 +}
65893 +
65894 +void
65895 +gr_log_badprocpid(const char *entry)
65896 +{
65897 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65898 + return;
65899 +}
65900 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65901 new file mode 100644
65902 index 0000000..2131422
65903 --- /dev/null
65904 +++ b/grsecurity/grsec_mount.c
65905 @@ -0,0 +1,62 @@
65906 +#include <linux/kernel.h>
65907 +#include <linux/sched.h>
65908 +#include <linux/mount.h>
65909 +#include <linux/grsecurity.h>
65910 +#include <linux/grinternal.h>
65911 +
65912 +void
65913 +gr_log_remount(const char *devname, const int retval)
65914 +{
65915 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65916 + if (grsec_enable_mount && (retval >= 0))
65917 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65918 +#endif
65919 + return;
65920 +}
65921 +
65922 +void
65923 +gr_log_unmount(const char *devname, const int retval)
65924 +{
65925 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65926 + if (grsec_enable_mount && (retval >= 0))
65927 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65928 +#endif
65929 + return;
65930 +}
65931 +
65932 +void
65933 +gr_log_mount(const char *from, const char *to, const int retval)
65934 +{
65935 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65936 + if (grsec_enable_mount && (retval >= 0))
65937 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65938 +#endif
65939 + return;
65940 +}
65941 +
65942 +int
65943 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65944 +{
65945 +#ifdef CONFIG_GRKERNSEC_ROFS
65946 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65947 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65948 + return -EPERM;
65949 + } else
65950 + return 0;
65951 +#endif
65952 + return 0;
65953 +}
65954 +
65955 +int
65956 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65957 +{
65958 +#ifdef CONFIG_GRKERNSEC_ROFS
65959 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65960 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65961 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65962 + return -EPERM;
65963 + } else
65964 + return 0;
65965 +#endif
65966 + return 0;
65967 +}
65968 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65969 new file mode 100644
65970 index 0000000..a3b12a0
65971 --- /dev/null
65972 +++ b/grsecurity/grsec_pax.c
65973 @@ -0,0 +1,36 @@
65974 +#include <linux/kernel.h>
65975 +#include <linux/sched.h>
65976 +#include <linux/mm.h>
65977 +#include <linux/file.h>
65978 +#include <linux/grinternal.h>
65979 +#include <linux/grsecurity.h>
65980 +
65981 +void
65982 +gr_log_textrel(struct vm_area_struct * vma)
65983 +{
65984 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65985 + if (grsec_enable_audit_textrel)
65986 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65987 +#endif
65988 + return;
65989 +}
65990 +
65991 +void
65992 +gr_log_rwxmmap(struct file *file)
65993 +{
65994 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65995 + if (grsec_enable_log_rwxmaps)
65996 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65997 +#endif
65998 + return;
65999 +}
66000 +
66001 +void
66002 +gr_log_rwxmprotect(struct file *file)
66003 +{
66004 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66005 + if (grsec_enable_log_rwxmaps)
66006 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
66007 +#endif
66008 + return;
66009 +}
66010 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
66011 new file mode 100644
66012 index 0000000..f7f29aa
66013 --- /dev/null
66014 +++ b/grsecurity/grsec_ptrace.c
66015 @@ -0,0 +1,30 @@
66016 +#include <linux/kernel.h>
66017 +#include <linux/sched.h>
66018 +#include <linux/grinternal.h>
66019 +#include <linux/security.h>
66020 +
66021 +void
66022 +gr_audit_ptrace(struct task_struct *task)
66023 +{
66024 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66025 + if (grsec_enable_audit_ptrace)
66026 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
66027 +#endif
66028 + return;
66029 +}
66030 +
66031 +int
66032 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
66033 +{
66034 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66035 + const struct dentry *dentry = file->f_path.dentry;
66036 + const struct vfsmount *mnt = file->f_path.mnt;
66037 +
66038 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
66039 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
66040 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
66041 + return -EACCES;
66042 + }
66043 +#endif
66044 + return 0;
66045 +}
66046 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
66047 new file mode 100644
66048 index 0000000..4e29cc7
66049 --- /dev/null
66050 +++ b/grsecurity/grsec_sig.c
66051 @@ -0,0 +1,246 @@
66052 +#include <linux/kernel.h>
66053 +#include <linux/sched.h>
66054 +#include <linux/fs.h>
66055 +#include <linux/delay.h>
66056 +#include <linux/grsecurity.h>
66057 +#include <linux/grinternal.h>
66058 +#include <linux/hardirq.h>
66059 +
66060 +char *signames[] = {
66061 + [SIGSEGV] = "Segmentation fault",
66062 + [SIGILL] = "Illegal instruction",
66063 + [SIGABRT] = "Abort",
66064 + [SIGBUS] = "Invalid alignment/Bus error"
66065 +};
66066 +
66067 +void
66068 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
66069 +{
66070 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66071 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
66072 + (sig == SIGABRT) || (sig == SIGBUS))) {
66073 + if (task_pid_nr(t) == task_pid_nr(current)) {
66074 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
66075 + } else {
66076 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
66077 + }
66078 + }
66079 +#endif
66080 + return;
66081 +}
66082 +
66083 +int
66084 +gr_handle_signal(const struct task_struct *p, const int sig)
66085 +{
66086 +#ifdef CONFIG_GRKERNSEC
66087 + /* ignore the 0 signal for protected task checks */
66088 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
66089 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
66090 + return -EPERM;
66091 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
66092 + return -EPERM;
66093 + }
66094 +#endif
66095 + return 0;
66096 +}
66097 +
66098 +#ifdef CONFIG_GRKERNSEC
66099 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66100 +
66101 +int gr_fake_force_sig(int sig, struct task_struct *t)
66102 +{
66103 + unsigned long int flags;
66104 + int ret, blocked, ignored;
66105 + struct k_sigaction *action;
66106 +
66107 + spin_lock_irqsave(&t->sighand->siglock, flags);
66108 + action = &t->sighand->action[sig-1];
66109 + ignored = action->sa.sa_handler == SIG_IGN;
66110 + blocked = sigismember(&t->blocked, sig);
66111 + if (blocked || ignored) {
66112 + action->sa.sa_handler = SIG_DFL;
66113 + if (blocked) {
66114 + sigdelset(&t->blocked, sig);
66115 + recalc_sigpending_and_wake(t);
66116 + }
66117 + }
66118 + if (action->sa.sa_handler == SIG_DFL)
66119 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66120 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66121 +
66122 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66123 +
66124 + return ret;
66125 +}
66126 +#endif
66127 +
66128 +#ifdef CONFIG_GRKERNSEC_BRUTE
66129 +#define GR_USER_BAN_TIME (15 * 60)
66130 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66131 +
66132 +static int __get_dumpable(unsigned long mm_flags)
66133 +{
66134 + int ret;
66135 +
66136 + ret = mm_flags & MMF_DUMPABLE_MASK;
66137 + return (ret >= 2) ? 2 : ret;
66138 +}
66139 +#endif
66140 +
66141 +void gr_handle_brute_attach(unsigned long mm_flags)
66142 +{
66143 +#ifdef CONFIG_GRKERNSEC_BRUTE
66144 + struct task_struct *p = current;
66145 + kuid_t uid = GLOBAL_ROOT_UID;
66146 + int daemon = 0;
66147 +
66148 + if (!grsec_enable_brute)
66149 + return;
66150 +
66151 + rcu_read_lock();
66152 + read_lock(&tasklist_lock);
66153 + read_lock(&grsec_exec_file_lock);
66154 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
66155 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66156 + p->real_parent->brute = 1;
66157 + daemon = 1;
66158 + } else {
66159 + const struct cred *cred = __task_cred(p), *cred2;
66160 + struct task_struct *tsk, *tsk2;
66161 +
66162 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66163 + struct user_struct *user;
66164 +
66165 + uid = cred->uid;
66166 +
66167 + /* this is put upon execution past expiration */
66168 + user = find_user(uid);
66169 + if (user == NULL)
66170 + goto unlock;
66171 + user->suid_banned = 1;
66172 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
66173 + if (user->suid_ban_expires == ~0UL)
66174 + user->suid_ban_expires--;
66175 +
66176 + /* only kill other threads of the same binary, from the same user */
66177 + do_each_thread(tsk2, tsk) {
66178 + cred2 = __task_cred(tsk);
66179 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
66180 + gr_fake_force_sig(SIGKILL, tsk);
66181 + } while_each_thread(tsk2, tsk);
66182 + }
66183 + }
66184 +unlock:
66185 + read_unlock(&grsec_exec_file_lock);
66186 + read_unlock(&tasklist_lock);
66187 + rcu_read_unlock();
66188 +
66189 + if (gr_is_global_nonroot(uid))
66190 + 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);
66191 + else if (daemon)
66192 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66193 +
66194 +#endif
66195 + return;
66196 +}
66197 +
66198 +void gr_handle_brute_check(void)
66199 +{
66200 +#ifdef CONFIG_GRKERNSEC_BRUTE
66201 + struct task_struct *p = current;
66202 +
66203 + if (unlikely(p->brute)) {
66204 + if (!grsec_enable_brute)
66205 + p->brute = 0;
66206 + else if (time_before(get_seconds(), p->brute_expires))
66207 + msleep(30 * 1000);
66208 + }
66209 +#endif
66210 + return;
66211 +}
66212 +
66213 +void gr_handle_kernel_exploit(void)
66214 +{
66215 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66216 + const struct cred *cred;
66217 + struct task_struct *tsk, *tsk2;
66218 + struct user_struct *user;
66219 + kuid_t uid;
66220 +
66221 + if (in_irq() || in_serving_softirq() || in_nmi())
66222 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66223 +
66224 + uid = current_uid();
66225 +
66226 + if (gr_is_global_root(uid))
66227 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66228 + else {
66229 + /* kill all the processes of this user, hold a reference
66230 + to their creds struct, and prevent them from creating
66231 + another process until system reset
66232 + */
66233 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66234 + GR_GLOBAL_UID(uid));
66235 + /* we intentionally leak this ref */
66236 + user = get_uid(current->cred->user);
66237 + if (user)
66238 + user->kernel_banned = 1;
66239 +
66240 + /* kill all processes of this user */
66241 + read_lock(&tasklist_lock);
66242 + do_each_thread(tsk2, tsk) {
66243 + cred = __task_cred(tsk);
66244 + if (uid_eq(cred->uid, uid))
66245 + gr_fake_force_sig(SIGKILL, tsk);
66246 + } while_each_thread(tsk2, tsk);
66247 + read_unlock(&tasklist_lock);
66248 + }
66249 +#endif
66250 +}
66251 +
66252 +#ifdef CONFIG_GRKERNSEC_BRUTE
66253 +static bool suid_ban_expired(struct user_struct *user)
66254 +{
66255 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
66256 + user->suid_banned = 0;
66257 + user->suid_ban_expires = 0;
66258 + free_uid(user);
66259 + return true;
66260 + }
66261 +
66262 + return false;
66263 +}
66264 +#endif
66265 +
66266 +int gr_process_kernel_exec_ban(void)
66267 +{
66268 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66269 + if (unlikely(current->cred->user->kernel_banned))
66270 + return -EPERM;
66271 +#endif
66272 + return 0;
66273 +}
66274 +
66275 +int gr_process_kernel_setuid_ban(struct user_struct *user)
66276 +{
66277 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66278 + if (unlikely(user->kernel_banned))
66279 + gr_fake_force_sig(SIGKILL, current);
66280 +#endif
66281 + return 0;
66282 +}
66283 +
66284 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
66285 +{
66286 +#ifdef CONFIG_GRKERNSEC_BRUTE
66287 + struct user_struct *user = current->cred->user;
66288 + if (unlikely(user->suid_banned)) {
66289 + if (suid_ban_expired(user))
66290 + return 0;
66291 + /* disallow execution of suid binaries only */
66292 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
66293 + return -EPERM;
66294 + }
66295 +#endif
66296 + return 0;
66297 +}
66298 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66299 new file mode 100644
66300 index 0000000..4030d57
66301 --- /dev/null
66302 +++ b/grsecurity/grsec_sock.c
66303 @@ -0,0 +1,244 @@
66304 +#include <linux/kernel.h>
66305 +#include <linux/module.h>
66306 +#include <linux/sched.h>
66307 +#include <linux/file.h>
66308 +#include <linux/net.h>
66309 +#include <linux/in.h>
66310 +#include <linux/ip.h>
66311 +#include <net/sock.h>
66312 +#include <net/inet_sock.h>
66313 +#include <linux/grsecurity.h>
66314 +#include <linux/grinternal.h>
66315 +#include <linux/gracl.h>
66316 +
66317 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66318 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66319 +
66320 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66321 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66322 +
66323 +#ifdef CONFIG_UNIX_MODULE
66324 +EXPORT_SYMBOL(gr_acl_handle_unix);
66325 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66326 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66327 +EXPORT_SYMBOL(gr_handle_create);
66328 +#endif
66329 +
66330 +#ifdef CONFIG_GRKERNSEC
66331 +#define gr_conn_table_size 32749
66332 +struct conn_table_entry {
66333 + struct conn_table_entry *next;
66334 + struct signal_struct *sig;
66335 +};
66336 +
66337 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66338 +DEFINE_SPINLOCK(gr_conn_table_lock);
66339 +
66340 +extern const char * gr_socktype_to_name(unsigned char type);
66341 +extern const char * gr_proto_to_name(unsigned char proto);
66342 +extern const char * gr_sockfamily_to_name(unsigned char family);
66343 +
66344 +static __inline__ int
66345 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66346 +{
66347 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66348 +}
66349 +
66350 +static __inline__ int
66351 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66352 + __u16 sport, __u16 dport)
66353 +{
66354 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66355 + sig->gr_sport == sport && sig->gr_dport == dport))
66356 + return 1;
66357 + else
66358 + return 0;
66359 +}
66360 +
66361 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66362 +{
66363 + struct conn_table_entry **match;
66364 + unsigned int index;
66365 +
66366 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66367 + sig->gr_sport, sig->gr_dport,
66368 + gr_conn_table_size);
66369 +
66370 + newent->sig = sig;
66371 +
66372 + match = &gr_conn_table[index];
66373 + newent->next = *match;
66374 + *match = newent;
66375 +
66376 + return;
66377 +}
66378 +
66379 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66380 +{
66381 + struct conn_table_entry *match, *last = NULL;
66382 + unsigned int index;
66383 +
66384 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66385 + sig->gr_sport, sig->gr_dport,
66386 + gr_conn_table_size);
66387 +
66388 + match = gr_conn_table[index];
66389 + while (match && !conn_match(match->sig,
66390 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66391 + sig->gr_dport)) {
66392 + last = match;
66393 + match = match->next;
66394 + }
66395 +
66396 + if (match) {
66397 + if (last)
66398 + last->next = match->next;
66399 + else
66400 + gr_conn_table[index] = NULL;
66401 + kfree(match);
66402 + }
66403 +
66404 + return;
66405 +}
66406 +
66407 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66408 + __u16 sport, __u16 dport)
66409 +{
66410 + struct conn_table_entry *match;
66411 + unsigned int index;
66412 +
66413 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66414 +
66415 + match = gr_conn_table[index];
66416 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66417 + match = match->next;
66418 +
66419 + if (match)
66420 + return match->sig;
66421 + else
66422 + return NULL;
66423 +}
66424 +
66425 +#endif
66426 +
66427 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66428 +{
66429 +#ifdef CONFIG_GRKERNSEC
66430 + struct signal_struct *sig = task->signal;
66431 + struct conn_table_entry *newent;
66432 +
66433 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66434 + if (newent == NULL)
66435 + return;
66436 + /* no bh lock needed since we are called with bh disabled */
66437 + spin_lock(&gr_conn_table_lock);
66438 + gr_del_task_from_ip_table_nolock(sig);
66439 + sig->gr_saddr = inet->inet_rcv_saddr;
66440 + sig->gr_daddr = inet->inet_daddr;
66441 + sig->gr_sport = inet->inet_sport;
66442 + sig->gr_dport = inet->inet_dport;
66443 + gr_add_to_task_ip_table_nolock(sig, newent);
66444 + spin_unlock(&gr_conn_table_lock);
66445 +#endif
66446 + return;
66447 +}
66448 +
66449 +void gr_del_task_from_ip_table(struct task_struct *task)
66450 +{
66451 +#ifdef CONFIG_GRKERNSEC
66452 + spin_lock_bh(&gr_conn_table_lock);
66453 + gr_del_task_from_ip_table_nolock(task->signal);
66454 + spin_unlock_bh(&gr_conn_table_lock);
66455 +#endif
66456 + return;
66457 +}
66458 +
66459 +void
66460 +gr_attach_curr_ip(const struct sock *sk)
66461 +{
66462 +#ifdef CONFIG_GRKERNSEC
66463 + struct signal_struct *p, *set;
66464 + const struct inet_sock *inet = inet_sk(sk);
66465 +
66466 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66467 + return;
66468 +
66469 + set = current->signal;
66470 +
66471 + spin_lock_bh(&gr_conn_table_lock);
66472 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66473 + inet->inet_dport, inet->inet_sport);
66474 + if (unlikely(p != NULL)) {
66475 + set->curr_ip = p->curr_ip;
66476 + set->used_accept = 1;
66477 + gr_del_task_from_ip_table_nolock(p);
66478 + spin_unlock_bh(&gr_conn_table_lock);
66479 + return;
66480 + }
66481 + spin_unlock_bh(&gr_conn_table_lock);
66482 +
66483 + set->curr_ip = inet->inet_daddr;
66484 + set->used_accept = 1;
66485 +#endif
66486 + return;
66487 +}
66488 +
66489 +int
66490 +gr_handle_sock_all(const int family, const int type, const int protocol)
66491 +{
66492 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66493 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66494 + (family != AF_UNIX)) {
66495 + if (family == AF_INET)
66496 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66497 + else
66498 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66499 + return -EACCES;
66500 + }
66501 +#endif
66502 + return 0;
66503 +}
66504 +
66505 +int
66506 +gr_handle_sock_server(const struct sockaddr *sck)
66507 +{
66508 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66509 + if (grsec_enable_socket_server &&
66510 + in_group_p(grsec_socket_server_gid) &&
66511 + sck && (sck->sa_family != AF_UNIX) &&
66512 + (sck->sa_family != AF_LOCAL)) {
66513 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66514 + return -EACCES;
66515 + }
66516 +#endif
66517 + return 0;
66518 +}
66519 +
66520 +int
66521 +gr_handle_sock_server_other(const struct sock *sck)
66522 +{
66523 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66524 + if (grsec_enable_socket_server &&
66525 + in_group_p(grsec_socket_server_gid) &&
66526 + sck && (sck->sk_family != AF_UNIX) &&
66527 + (sck->sk_family != AF_LOCAL)) {
66528 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66529 + return -EACCES;
66530 + }
66531 +#endif
66532 + return 0;
66533 +}
66534 +
66535 +int
66536 +gr_handle_sock_client(const struct sockaddr *sck)
66537 +{
66538 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66539 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66540 + sck && (sck->sa_family != AF_UNIX) &&
66541 + (sck->sa_family != AF_LOCAL)) {
66542 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66543 + return -EACCES;
66544 + }
66545 +#endif
66546 + return 0;
66547 +}
66548 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66549 new file mode 100644
66550 index 0000000..f55ef0f
66551 --- /dev/null
66552 +++ b/grsecurity/grsec_sysctl.c
66553 @@ -0,0 +1,469 @@
66554 +#include <linux/kernel.h>
66555 +#include <linux/sched.h>
66556 +#include <linux/sysctl.h>
66557 +#include <linux/grsecurity.h>
66558 +#include <linux/grinternal.h>
66559 +
66560 +int
66561 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66562 +{
66563 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66564 + if (dirname == NULL || name == NULL)
66565 + return 0;
66566 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66567 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66568 + return -EACCES;
66569 + }
66570 +#endif
66571 + return 0;
66572 +}
66573 +
66574 +#ifdef CONFIG_GRKERNSEC_ROFS
66575 +static int __maybe_unused one = 1;
66576 +#endif
66577 +
66578 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66579 +struct ctl_table grsecurity_table[] = {
66580 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66581 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66582 +#ifdef CONFIG_GRKERNSEC_IO
66583 + {
66584 + .procname = "disable_priv_io",
66585 + .data = &grsec_disable_privio,
66586 + .maxlen = sizeof(int),
66587 + .mode = 0600,
66588 + .proc_handler = &proc_dointvec,
66589 + },
66590 +#endif
66591 +#endif
66592 +#ifdef CONFIG_GRKERNSEC_LINK
66593 + {
66594 + .procname = "linking_restrictions",
66595 + .data = &grsec_enable_link,
66596 + .maxlen = sizeof(int),
66597 + .mode = 0600,
66598 + .proc_handler = &proc_dointvec,
66599 + },
66600 +#endif
66601 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66602 + {
66603 + .procname = "enforce_symlinksifowner",
66604 + .data = &grsec_enable_symlinkown,
66605 + .maxlen = sizeof(int),
66606 + .mode = 0600,
66607 + .proc_handler = &proc_dointvec,
66608 + },
66609 + {
66610 + .procname = "symlinkown_gid",
66611 + .data = &grsec_symlinkown_gid,
66612 + .maxlen = sizeof(int),
66613 + .mode = 0600,
66614 + .proc_handler = &proc_dointvec,
66615 + },
66616 +#endif
66617 +#ifdef CONFIG_GRKERNSEC_BRUTE
66618 + {
66619 + .procname = "deter_bruteforce",
66620 + .data = &grsec_enable_brute,
66621 + .maxlen = sizeof(int),
66622 + .mode = 0600,
66623 + .proc_handler = &proc_dointvec,
66624 + },
66625 +#endif
66626 +#ifdef CONFIG_GRKERNSEC_FIFO
66627 + {
66628 + .procname = "fifo_restrictions",
66629 + .data = &grsec_enable_fifo,
66630 + .maxlen = sizeof(int),
66631 + .mode = 0600,
66632 + .proc_handler = &proc_dointvec,
66633 + },
66634 +#endif
66635 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66636 + {
66637 + .procname = "ptrace_readexec",
66638 + .data = &grsec_enable_ptrace_readexec,
66639 + .maxlen = sizeof(int),
66640 + .mode = 0600,
66641 + .proc_handler = &proc_dointvec,
66642 + },
66643 +#endif
66644 +#ifdef CONFIG_GRKERNSEC_SETXID
66645 + {
66646 + .procname = "consistent_setxid",
66647 + .data = &grsec_enable_setxid,
66648 + .maxlen = sizeof(int),
66649 + .mode = 0600,
66650 + .proc_handler = &proc_dointvec,
66651 + },
66652 +#endif
66653 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66654 + {
66655 + .procname = "ip_blackhole",
66656 + .data = &grsec_enable_blackhole,
66657 + .maxlen = sizeof(int),
66658 + .mode = 0600,
66659 + .proc_handler = &proc_dointvec,
66660 + },
66661 + {
66662 + .procname = "lastack_retries",
66663 + .data = &grsec_lastack_retries,
66664 + .maxlen = sizeof(int),
66665 + .mode = 0600,
66666 + .proc_handler = &proc_dointvec,
66667 + },
66668 +#endif
66669 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66670 + {
66671 + .procname = "exec_logging",
66672 + .data = &grsec_enable_execlog,
66673 + .maxlen = sizeof(int),
66674 + .mode = 0600,
66675 + .proc_handler = &proc_dointvec,
66676 + },
66677 +#endif
66678 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66679 + {
66680 + .procname = "rwxmap_logging",
66681 + .data = &grsec_enable_log_rwxmaps,
66682 + .maxlen = sizeof(int),
66683 + .mode = 0600,
66684 + .proc_handler = &proc_dointvec,
66685 + },
66686 +#endif
66687 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66688 + {
66689 + .procname = "signal_logging",
66690 + .data = &grsec_enable_signal,
66691 + .maxlen = sizeof(int),
66692 + .mode = 0600,
66693 + .proc_handler = &proc_dointvec,
66694 + },
66695 +#endif
66696 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66697 + {
66698 + .procname = "forkfail_logging",
66699 + .data = &grsec_enable_forkfail,
66700 + .maxlen = sizeof(int),
66701 + .mode = 0600,
66702 + .proc_handler = &proc_dointvec,
66703 + },
66704 +#endif
66705 +#ifdef CONFIG_GRKERNSEC_TIME
66706 + {
66707 + .procname = "timechange_logging",
66708 + .data = &grsec_enable_time,
66709 + .maxlen = sizeof(int),
66710 + .mode = 0600,
66711 + .proc_handler = &proc_dointvec,
66712 + },
66713 +#endif
66714 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66715 + {
66716 + .procname = "chroot_deny_shmat",
66717 + .data = &grsec_enable_chroot_shmat,
66718 + .maxlen = sizeof(int),
66719 + .mode = 0600,
66720 + .proc_handler = &proc_dointvec,
66721 + },
66722 +#endif
66723 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66724 + {
66725 + .procname = "chroot_deny_unix",
66726 + .data = &grsec_enable_chroot_unix,
66727 + .maxlen = sizeof(int),
66728 + .mode = 0600,
66729 + .proc_handler = &proc_dointvec,
66730 + },
66731 +#endif
66732 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66733 + {
66734 + .procname = "chroot_deny_mount",
66735 + .data = &grsec_enable_chroot_mount,
66736 + .maxlen = sizeof(int),
66737 + .mode = 0600,
66738 + .proc_handler = &proc_dointvec,
66739 + },
66740 +#endif
66741 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66742 + {
66743 + .procname = "chroot_deny_fchdir",
66744 + .data = &grsec_enable_chroot_fchdir,
66745 + .maxlen = sizeof(int),
66746 + .mode = 0600,
66747 + .proc_handler = &proc_dointvec,
66748 + },
66749 +#endif
66750 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66751 + {
66752 + .procname = "chroot_deny_chroot",
66753 + .data = &grsec_enable_chroot_double,
66754 + .maxlen = sizeof(int),
66755 + .mode = 0600,
66756 + .proc_handler = &proc_dointvec,
66757 + },
66758 +#endif
66759 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66760 + {
66761 + .procname = "chroot_deny_pivot",
66762 + .data = &grsec_enable_chroot_pivot,
66763 + .maxlen = sizeof(int),
66764 + .mode = 0600,
66765 + .proc_handler = &proc_dointvec,
66766 + },
66767 +#endif
66768 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66769 + {
66770 + .procname = "chroot_enforce_chdir",
66771 + .data = &grsec_enable_chroot_chdir,
66772 + .maxlen = sizeof(int),
66773 + .mode = 0600,
66774 + .proc_handler = &proc_dointvec,
66775 + },
66776 +#endif
66777 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66778 + {
66779 + .procname = "chroot_deny_chmod",
66780 + .data = &grsec_enable_chroot_chmod,
66781 + .maxlen = sizeof(int),
66782 + .mode = 0600,
66783 + .proc_handler = &proc_dointvec,
66784 + },
66785 +#endif
66786 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66787 + {
66788 + .procname = "chroot_deny_mknod",
66789 + .data = &grsec_enable_chroot_mknod,
66790 + .maxlen = sizeof(int),
66791 + .mode = 0600,
66792 + .proc_handler = &proc_dointvec,
66793 + },
66794 +#endif
66795 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66796 + {
66797 + .procname = "chroot_restrict_nice",
66798 + .data = &grsec_enable_chroot_nice,
66799 + .maxlen = sizeof(int),
66800 + .mode = 0600,
66801 + .proc_handler = &proc_dointvec,
66802 + },
66803 +#endif
66804 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66805 + {
66806 + .procname = "chroot_execlog",
66807 + .data = &grsec_enable_chroot_execlog,
66808 + .maxlen = sizeof(int),
66809 + .mode = 0600,
66810 + .proc_handler = &proc_dointvec,
66811 + },
66812 +#endif
66813 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66814 + {
66815 + .procname = "chroot_caps",
66816 + .data = &grsec_enable_chroot_caps,
66817 + .maxlen = sizeof(int),
66818 + .mode = 0600,
66819 + .proc_handler = &proc_dointvec,
66820 + },
66821 +#endif
66822 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66823 + {
66824 + .procname = "chroot_deny_sysctl",
66825 + .data = &grsec_enable_chroot_sysctl,
66826 + .maxlen = sizeof(int),
66827 + .mode = 0600,
66828 + .proc_handler = &proc_dointvec,
66829 + },
66830 +#endif
66831 +#ifdef CONFIG_GRKERNSEC_TPE
66832 + {
66833 + .procname = "tpe",
66834 + .data = &grsec_enable_tpe,
66835 + .maxlen = sizeof(int),
66836 + .mode = 0600,
66837 + .proc_handler = &proc_dointvec,
66838 + },
66839 + {
66840 + .procname = "tpe_gid",
66841 + .data = &grsec_tpe_gid,
66842 + .maxlen = sizeof(int),
66843 + .mode = 0600,
66844 + .proc_handler = &proc_dointvec,
66845 + },
66846 +#endif
66847 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66848 + {
66849 + .procname = "tpe_invert",
66850 + .data = &grsec_enable_tpe_invert,
66851 + .maxlen = sizeof(int),
66852 + .mode = 0600,
66853 + .proc_handler = &proc_dointvec,
66854 + },
66855 +#endif
66856 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66857 + {
66858 + .procname = "tpe_restrict_all",
66859 + .data = &grsec_enable_tpe_all,
66860 + .maxlen = sizeof(int),
66861 + .mode = 0600,
66862 + .proc_handler = &proc_dointvec,
66863 + },
66864 +#endif
66865 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66866 + {
66867 + .procname = "socket_all",
66868 + .data = &grsec_enable_socket_all,
66869 + .maxlen = sizeof(int),
66870 + .mode = 0600,
66871 + .proc_handler = &proc_dointvec,
66872 + },
66873 + {
66874 + .procname = "socket_all_gid",
66875 + .data = &grsec_socket_all_gid,
66876 + .maxlen = sizeof(int),
66877 + .mode = 0600,
66878 + .proc_handler = &proc_dointvec,
66879 + },
66880 +#endif
66881 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66882 + {
66883 + .procname = "socket_client",
66884 + .data = &grsec_enable_socket_client,
66885 + .maxlen = sizeof(int),
66886 + .mode = 0600,
66887 + .proc_handler = &proc_dointvec,
66888 + },
66889 + {
66890 + .procname = "socket_client_gid",
66891 + .data = &grsec_socket_client_gid,
66892 + .maxlen = sizeof(int),
66893 + .mode = 0600,
66894 + .proc_handler = &proc_dointvec,
66895 + },
66896 +#endif
66897 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66898 + {
66899 + .procname = "socket_server",
66900 + .data = &grsec_enable_socket_server,
66901 + .maxlen = sizeof(int),
66902 + .mode = 0600,
66903 + .proc_handler = &proc_dointvec,
66904 + },
66905 + {
66906 + .procname = "socket_server_gid",
66907 + .data = &grsec_socket_server_gid,
66908 + .maxlen = sizeof(int),
66909 + .mode = 0600,
66910 + .proc_handler = &proc_dointvec,
66911 + },
66912 +#endif
66913 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66914 + {
66915 + .procname = "audit_group",
66916 + .data = &grsec_enable_group,
66917 + .maxlen = sizeof(int),
66918 + .mode = 0600,
66919 + .proc_handler = &proc_dointvec,
66920 + },
66921 + {
66922 + .procname = "audit_gid",
66923 + .data = &grsec_audit_gid,
66924 + .maxlen = sizeof(int),
66925 + .mode = 0600,
66926 + .proc_handler = &proc_dointvec,
66927 + },
66928 +#endif
66929 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66930 + {
66931 + .procname = "audit_chdir",
66932 + .data = &grsec_enable_chdir,
66933 + .maxlen = sizeof(int),
66934 + .mode = 0600,
66935 + .proc_handler = &proc_dointvec,
66936 + },
66937 +#endif
66938 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66939 + {
66940 + .procname = "audit_mount",
66941 + .data = &grsec_enable_mount,
66942 + .maxlen = sizeof(int),
66943 + .mode = 0600,
66944 + .proc_handler = &proc_dointvec,
66945 + },
66946 +#endif
66947 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66948 + {
66949 + .procname = "audit_textrel",
66950 + .data = &grsec_enable_audit_textrel,
66951 + .maxlen = sizeof(int),
66952 + .mode = 0600,
66953 + .proc_handler = &proc_dointvec,
66954 + },
66955 +#endif
66956 +#ifdef CONFIG_GRKERNSEC_DMESG
66957 + {
66958 + .procname = "dmesg",
66959 + .data = &grsec_enable_dmesg,
66960 + .maxlen = sizeof(int),
66961 + .mode = 0600,
66962 + .proc_handler = &proc_dointvec,
66963 + },
66964 +#endif
66965 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66966 + {
66967 + .procname = "chroot_findtask",
66968 + .data = &grsec_enable_chroot_findtask,
66969 + .maxlen = sizeof(int),
66970 + .mode = 0600,
66971 + .proc_handler = &proc_dointvec,
66972 + },
66973 +#endif
66974 +#ifdef CONFIG_GRKERNSEC_RESLOG
66975 + {
66976 + .procname = "resource_logging",
66977 + .data = &grsec_resource_logging,
66978 + .maxlen = sizeof(int),
66979 + .mode = 0600,
66980 + .proc_handler = &proc_dointvec,
66981 + },
66982 +#endif
66983 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66984 + {
66985 + .procname = "audit_ptrace",
66986 + .data = &grsec_enable_audit_ptrace,
66987 + .maxlen = sizeof(int),
66988 + .mode = 0600,
66989 + .proc_handler = &proc_dointvec,
66990 + },
66991 +#endif
66992 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66993 + {
66994 + .procname = "harden_ptrace",
66995 + .data = &grsec_enable_harden_ptrace,
66996 + .maxlen = sizeof(int),
66997 + .mode = 0600,
66998 + .proc_handler = &proc_dointvec,
66999 + },
67000 +#endif
67001 + {
67002 + .procname = "grsec_lock",
67003 + .data = &grsec_lock,
67004 + .maxlen = sizeof(int),
67005 + .mode = 0600,
67006 + .proc_handler = &proc_dointvec,
67007 + },
67008 +#endif
67009 +#ifdef CONFIG_GRKERNSEC_ROFS
67010 + {
67011 + .procname = "romount_protect",
67012 + .data = &grsec_enable_rofs,
67013 + .maxlen = sizeof(int),
67014 + .mode = 0600,
67015 + .proc_handler = &proc_dointvec_minmax,
67016 + .extra1 = &one,
67017 + .extra2 = &one,
67018 + },
67019 +#endif
67020 + { }
67021 +};
67022 +#endif
67023 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
67024 new file mode 100644
67025 index 0000000..0dc13c3
67026 --- /dev/null
67027 +++ b/grsecurity/grsec_time.c
67028 @@ -0,0 +1,16 @@
67029 +#include <linux/kernel.h>
67030 +#include <linux/sched.h>
67031 +#include <linux/grinternal.h>
67032 +#include <linux/module.h>
67033 +
67034 +void
67035 +gr_log_timechange(void)
67036 +{
67037 +#ifdef CONFIG_GRKERNSEC_TIME
67038 + if (grsec_enable_time)
67039 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
67040 +#endif
67041 + return;
67042 +}
67043 +
67044 +EXPORT_SYMBOL(gr_log_timechange);
67045 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
67046 new file mode 100644
67047 index 0000000..ee57dcf
67048 --- /dev/null
67049 +++ b/grsecurity/grsec_tpe.c
67050 @@ -0,0 +1,73 @@
67051 +#include <linux/kernel.h>
67052 +#include <linux/sched.h>
67053 +#include <linux/file.h>
67054 +#include <linux/fs.h>
67055 +#include <linux/grinternal.h>
67056 +
67057 +extern int gr_acl_tpe_check(void);
67058 +
67059 +int
67060 +gr_tpe_allow(const struct file *file)
67061 +{
67062 +#ifdef CONFIG_GRKERNSEC
67063 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
67064 + const struct cred *cred = current_cred();
67065 + char *msg = NULL;
67066 + char *msg2 = NULL;
67067 +
67068 + // never restrict root
67069 + if (gr_is_global_root(cred->uid))
67070 + return 1;
67071 +
67072 + if (grsec_enable_tpe) {
67073 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67074 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
67075 + msg = "not being in trusted group";
67076 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
67077 + msg = "being in untrusted group";
67078 +#else
67079 + if (in_group_p(grsec_tpe_gid))
67080 + msg = "being in untrusted group";
67081 +#endif
67082 + }
67083 + if (!msg && gr_acl_tpe_check())
67084 + msg = "being in untrusted role";
67085 +
67086 + // not in any affected group/role
67087 + if (!msg)
67088 + goto next_check;
67089 +
67090 + if (gr_is_global_nonroot(inode->i_uid))
67091 + msg2 = "file in non-root-owned directory";
67092 + else if (inode->i_mode & S_IWOTH)
67093 + msg2 = "file in world-writable directory";
67094 + else if (inode->i_mode & S_IWGRP)
67095 + msg2 = "file in group-writable directory";
67096 +
67097 + if (msg && msg2) {
67098 + char fullmsg[70] = {0};
67099 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
67100 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
67101 + return 0;
67102 + }
67103 + msg = NULL;
67104 +next_check:
67105 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67106 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
67107 + return 1;
67108 +
67109 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
67110 + msg = "directory not owned by user";
67111 + else if (inode->i_mode & S_IWOTH)
67112 + msg = "file in world-writable directory";
67113 + else if (inode->i_mode & S_IWGRP)
67114 + msg = "file in group-writable directory";
67115 +
67116 + if (msg) {
67117 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67118 + return 0;
67119 + }
67120 +#endif
67121 +#endif
67122 + return 1;
67123 +}
67124 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67125 new file mode 100644
67126 index 0000000..9f7b1ac
67127 --- /dev/null
67128 +++ b/grsecurity/grsum.c
67129 @@ -0,0 +1,61 @@
67130 +#include <linux/err.h>
67131 +#include <linux/kernel.h>
67132 +#include <linux/sched.h>
67133 +#include <linux/mm.h>
67134 +#include <linux/scatterlist.h>
67135 +#include <linux/crypto.h>
67136 +#include <linux/gracl.h>
67137 +
67138 +
67139 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67140 +#error "crypto and sha256 must be built into the kernel"
67141 +#endif
67142 +
67143 +int
67144 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67145 +{
67146 + char *p;
67147 + struct crypto_hash *tfm;
67148 + struct hash_desc desc;
67149 + struct scatterlist sg;
67150 + unsigned char temp_sum[GR_SHA_LEN];
67151 + volatile int retval = 0;
67152 + volatile int dummy = 0;
67153 + unsigned int i;
67154 +
67155 + sg_init_table(&sg, 1);
67156 +
67157 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67158 + if (IS_ERR(tfm)) {
67159 + /* should never happen, since sha256 should be built in */
67160 + return 1;
67161 + }
67162 +
67163 + desc.tfm = tfm;
67164 + desc.flags = 0;
67165 +
67166 + crypto_hash_init(&desc);
67167 +
67168 + p = salt;
67169 + sg_set_buf(&sg, p, GR_SALT_LEN);
67170 + crypto_hash_update(&desc, &sg, sg.length);
67171 +
67172 + p = entry->pw;
67173 + sg_set_buf(&sg, p, strlen(p));
67174 +
67175 + crypto_hash_update(&desc, &sg, sg.length);
67176 +
67177 + crypto_hash_final(&desc, temp_sum);
67178 +
67179 + memset(entry->pw, 0, GR_PW_LEN);
67180 +
67181 + for (i = 0; i < GR_SHA_LEN; i++)
67182 + if (sum[i] != temp_sum[i])
67183 + retval = 1;
67184 + else
67185 + dummy = 1; // waste a cycle
67186 +
67187 + crypto_free_hash(tfm);
67188 +
67189 + return retval;
67190 +}
67191 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67192 index 77ff547..181834f 100644
67193 --- a/include/asm-generic/4level-fixup.h
67194 +++ b/include/asm-generic/4level-fixup.h
67195 @@ -13,8 +13,10 @@
67196 #define pmd_alloc(mm, pud, address) \
67197 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67198 NULL: pmd_offset(pud, address))
67199 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67200
67201 #define pud_alloc(mm, pgd, address) (pgd)
67202 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67203 #define pud_offset(pgd, start) (pgd)
67204 #define pud_none(pud) 0
67205 #define pud_bad(pud) 0
67206 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67207 index b7babf0..04ad282 100644
67208 --- a/include/asm-generic/atomic-long.h
67209 +++ b/include/asm-generic/atomic-long.h
67210 @@ -22,6 +22,12 @@
67211
67212 typedef atomic64_t atomic_long_t;
67213
67214 +#ifdef CONFIG_PAX_REFCOUNT
67215 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67216 +#else
67217 +typedef atomic64_t atomic_long_unchecked_t;
67218 +#endif
67219 +
67220 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67221
67222 static inline long atomic_long_read(atomic_long_t *l)
67223 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67224 return (long)atomic64_read(v);
67225 }
67226
67227 +#ifdef CONFIG_PAX_REFCOUNT
67228 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67229 +{
67230 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67231 +
67232 + return (long)atomic64_read_unchecked(v);
67233 +}
67234 +#endif
67235 +
67236 static inline void atomic_long_set(atomic_long_t *l, long i)
67237 {
67238 atomic64_t *v = (atomic64_t *)l;
67239 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67240 atomic64_set(v, i);
67241 }
67242
67243 +#ifdef CONFIG_PAX_REFCOUNT
67244 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67245 +{
67246 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67247 +
67248 + atomic64_set_unchecked(v, i);
67249 +}
67250 +#endif
67251 +
67252 static inline void atomic_long_inc(atomic_long_t *l)
67253 {
67254 atomic64_t *v = (atomic64_t *)l;
67255 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67256 atomic64_inc(v);
67257 }
67258
67259 +#ifdef CONFIG_PAX_REFCOUNT
67260 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67261 +{
67262 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67263 +
67264 + atomic64_inc_unchecked(v);
67265 +}
67266 +#endif
67267 +
67268 static inline void atomic_long_dec(atomic_long_t *l)
67269 {
67270 atomic64_t *v = (atomic64_t *)l;
67271 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67272 atomic64_dec(v);
67273 }
67274
67275 +#ifdef CONFIG_PAX_REFCOUNT
67276 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67277 +{
67278 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67279 +
67280 + atomic64_dec_unchecked(v);
67281 +}
67282 +#endif
67283 +
67284 static inline void atomic_long_add(long i, atomic_long_t *l)
67285 {
67286 atomic64_t *v = (atomic64_t *)l;
67287 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67288 atomic64_add(i, v);
67289 }
67290
67291 +#ifdef CONFIG_PAX_REFCOUNT
67292 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67293 +{
67294 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67295 +
67296 + atomic64_add_unchecked(i, v);
67297 +}
67298 +#endif
67299 +
67300 static inline void atomic_long_sub(long i, atomic_long_t *l)
67301 {
67302 atomic64_t *v = (atomic64_t *)l;
67303 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67304 atomic64_sub(i, v);
67305 }
67306
67307 +#ifdef CONFIG_PAX_REFCOUNT
67308 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67309 +{
67310 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67311 +
67312 + atomic64_sub_unchecked(i, v);
67313 +}
67314 +#endif
67315 +
67316 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67317 {
67318 atomic64_t *v = (atomic64_t *)l;
67319 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67320 return (long)atomic64_add_return(i, v);
67321 }
67322
67323 +#ifdef CONFIG_PAX_REFCOUNT
67324 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67325 +{
67326 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67327 +
67328 + return (long)atomic64_add_return_unchecked(i, v);
67329 +}
67330 +#endif
67331 +
67332 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67333 {
67334 atomic64_t *v = (atomic64_t *)l;
67335 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67336 return (long)atomic64_inc_return(v);
67337 }
67338
67339 +#ifdef CONFIG_PAX_REFCOUNT
67340 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67341 +{
67342 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67343 +
67344 + return (long)atomic64_inc_return_unchecked(v);
67345 +}
67346 +#endif
67347 +
67348 static inline long atomic_long_dec_return(atomic_long_t *l)
67349 {
67350 atomic64_t *v = (atomic64_t *)l;
67351 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67352
67353 typedef atomic_t atomic_long_t;
67354
67355 +#ifdef CONFIG_PAX_REFCOUNT
67356 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67357 +#else
67358 +typedef atomic_t atomic_long_unchecked_t;
67359 +#endif
67360 +
67361 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67362 static inline long atomic_long_read(atomic_long_t *l)
67363 {
67364 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67365 return (long)atomic_read(v);
67366 }
67367
67368 +#ifdef CONFIG_PAX_REFCOUNT
67369 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67370 +{
67371 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67372 +
67373 + return (long)atomic_read_unchecked(v);
67374 +}
67375 +#endif
67376 +
67377 static inline void atomic_long_set(atomic_long_t *l, long i)
67378 {
67379 atomic_t *v = (atomic_t *)l;
67380 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67381 atomic_set(v, i);
67382 }
67383
67384 +#ifdef CONFIG_PAX_REFCOUNT
67385 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67386 +{
67387 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67388 +
67389 + atomic_set_unchecked(v, i);
67390 +}
67391 +#endif
67392 +
67393 static inline void atomic_long_inc(atomic_long_t *l)
67394 {
67395 atomic_t *v = (atomic_t *)l;
67396 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67397 atomic_inc(v);
67398 }
67399
67400 +#ifdef CONFIG_PAX_REFCOUNT
67401 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67402 +{
67403 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67404 +
67405 + atomic_inc_unchecked(v);
67406 +}
67407 +#endif
67408 +
67409 static inline void atomic_long_dec(atomic_long_t *l)
67410 {
67411 atomic_t *v = (atomic_t *)l;
67412 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67413 atomic_dec(v);
67414 }
67415
67416 +#ifdef CONFIG_PAX_REFCOUNT
67417 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67418 +{
67419 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67420 +
67421 + atomic_dec_unchecked(v);
67422 +}
67423 +#endif
67424 +
67425 static inline void atomic_long_add(long i, atomic_long_t *l)
67426 {
67427 atomic_t *v = (atomic_t *)l;
67428 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67429 atomic_add(i, v);
67430 }
67431
67432 +#ifdef CONFIG_PAX_REFCOUNT
67433 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67434 +{
67435 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67436 +
67437 + atomic_add_unchecked(i, v);
67438 +}
67439 +#endif
67440 +
67441 static inline void atomic_long_sub(long i, atomic_long_t *l)
67442 {
67443 atomic_t *v = (atomic_t *)l;
67444 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67445 atomic_sub(i, v);
67446 }
67447
67448 +#ifdef CONFIG_PAX_REFCOUNT
67449 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67450 +{
67451 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67452 +
67453 + atomic_sub_unchecked(i, v);
67454 +}
67455 +#endif
67456 +
67457 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67458 {
67459 atomic_t *v = (atomic_t *)l;
67460 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67461 return (long)atomic_add_return(i, v);
67462 }
67463
67464 +#ifdef CONFIG_PAX_REFCOUNT
67465 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67466 +{
67467 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67468 +
67469 + return (long)atomic_add_return_unchecked(i, v);
67470 +}
67471 +
67472 +#endif
67473 +
67474 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67475 {
67476 atomic_t *v = (atomic_t *)l;
67477 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67478 return (long)atomic_inc_return(v);
67479 }
67480
67481 +#ifdef CONFIG_PAX_REFCOUNT
67482 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67483 +{
67484 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67485 +
67486 + return (long)atomic_inc_return_unchecked(v);
67487 +}
67488 +#endif
67489 +
67490 static inline long atomic_long_dec_return(atomic_long_t *l)
67491 {
67492 atomic_t *v = (atomic_t *)l;
67493 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67494
67495 #endif /* BITS_PER_LONG == 64 */
67496
67497 +#ifdef CONFIG_PAX_REFCOUNT
67498 +static inline void pax_refcount_needs_these_functions(void)
67499 +{
67500 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67501 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67502 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67503 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67504 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67505 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67506 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67507 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67508 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67509 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67510 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67511 +#ifdef CONFIG_X86
67512 + atomic_clear_mask_unchecked(0, NULL);
67513 + atomic_set_mask_unchecked(0, NULL);
67514 +#endif
67515 +
67516 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67517 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67518 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67519 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67520 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67521 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67522 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67523 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67524 +}
67525 +#else
67526 +#define atomic_read_unchecked(v) atomic_read(v)
67527 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67528 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67529 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67530 +#define atomic_inc_unchecked(v) atomic_inc(v)
67531 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67532 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67533 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67534 +#define atomic_dec_unchecked(v) atomic_dec(v)
67535 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67536 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67537 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67538 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67539 +
67540 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67541 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67542 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67543 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67544 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67545 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67546 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67547 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67548 +#endif
67549 +
67550 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67551 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67552 index 33bd2de..f31bff97 100644
67553 --- a/include/asm-generic/atomic.h
67554 +++ b/include/asm-generic/atomic.h
67555 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67556 * Atomically clears the bits set in @mask from @v
67557 */
67558 #ifndef atomic_clear_mask
67559 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67560 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67561 {
67562 unsigned long flags;
67563
67564 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67565 index b18ce4f..2ee2843 100644
67566 --- a/include/asm-generic/atomic64.h
67567 +++ b/include/asm-generic/atomic64.h
67568 @@ -16,6 +16,8 @@ typedef struct {
67569 long long counter;
67570 } atomic64_t;
67571
67572 +typedef atomic64_t atomic64_unchecked_t;
67573 +
67574 #define ATOMIC64_INIT(i) { (i) }
67575
67576 extern long long atomic64_read(const atomic64_t *v);
67577 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67578 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67579 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67580
67581 +#define atomic64_read_unchecked(v) atomic64_read(v)
67582 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67583 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67584 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67585 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67586 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67587 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67588 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67589 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67590 +
67591 #endif /* _ASM_GENERIC_ATOMIC64_H */
67592 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67593 index 1bfcfe5..e04c5c9 100644
67594 --- a/include/asm-generic/cache.h
67595 +++ b/include/asm-generic/cache.h
67596 @@ -6,7 +6,7 @@
67597 * cache lines need to provide their own cache.h.
67598 */
67599
67600 -#define L1_CACHE_SHIFT 5
67601 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67602 +#define L1_CACHE_SHIFT 5UL
67603 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67604
67605 #endif /* __ASM_GENERIC_CACHE_H */
67606 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67607 index 0d68a1e..b74a761 100644
67608 --- a/include/asm-generic/emergency-restart.h
67609 +++ b/include/asm-generic/emergency-restart.h
67610 @@ -1,7 +1,7 @@
67611 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67612 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67613
67614 -static inline void machine_emergency_restart(void)
67615 +static inline __noreturn void machine_emergency_restart(void)
67616 {
67617 machine_restart(NULL);
67618 }
67619 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67620 index 90f99c7..00ce236 100644
67621 --- a/include/asm-generic/kmap_types.h
67622 +++ b/include/asm-generic/kmap_types.h
67623 @@ -2,9 +2,9 @@
67624 #define _ASM_GENERIC_KMAP_TYPES_H
67625
67626 #ifdef __WITH_KM_FENCE
67627 -# define KM_TYPE_NR 41
67628 +# define KM_TYPE_NR 42
67629 #else
67630 -# define KM_TYPE_NR 20
67631 +# define KM_TYPE_NR 21
67632 #endif
67633
67634 #endif
67635 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67636 index 9ceb03b..62b0b8f 100644
67637 --- a/include/asm-generic/local.h
67638 +++ b/include/asm-generic/local.h
67639 @@ -23,24 +23,37 @@ typedef struct
67640 atomic_long_t a;
67641 } local_t;
67642
67643 +typedef struct {
67644 + atomic_long_unchecked_t a;
67645 +} local_unchecked_t;
67646 +
67647 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67648
67649 #define local_read(l) atomic_long_read(&(l)->a)
67650 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67651 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67652 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67653 #define local_inc(l) atomic_long_inc(&(l)->a)
67654 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67655 #define local_dec(l) atomic_long_dec(&(l)->a)
67656 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67657 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67658 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67659 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67660 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67661
67662 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67663 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67664 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67665 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67666 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67667 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67668 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67669 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67670 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67671
67672 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67673 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67674 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67675 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67676 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67677 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67678 index 725612b..9cc513a 100644
67679 --- a/include/asm-generic/pgtable-nopmd.h
67680 +++ b/include/asm-generic/pgtable-nopmd.h
67681 @@ -1,14 +1,19 @@
67682 #ifndef _PGTABLE_NOPMD_H
67683 #define _PGTABLE_NOPMD_H
67684
67685 -#ifndef __ASSEMBLY__
67686 -
67687 #include <asm-generic/pgtable-nopud.h>
67688
67689 -struct mm_struct;
67690 -
67691 #define __PAGETABLE_PMD_FOLDED
67692
67693 +#define PMD_SHIFT PUD_SHIFT
67694 +#define PTRS_PER_PMD 1
67695 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67696 +#define PMD_MASK (~(PMD_SIZE-1))
67697 +
67698 +#ifndef __ASSEMBLY__
67699 +
67700 +struct mm_struct;
67701 +
67702 /*
67703 * Having the pmd type consist of a pud gets the size right, and allows
67704 * us to conceptually access the pud entry that this pmd is folded into
67705 @@ -16,11 +21,6 @@ struct mm_struct;
67706 */
67707 typedef struct { pud_t pud; } pmd_t;
67708
67709 -#define PMD_SHIFT PUD_SHIFT
67710 -#define PTRS_PER_PMD 1
67711 -#define PMD_SIZE (1UL << PMD_SHIFT)
67712 -#define PMD_MASK (~(PMD_SIZE-1))
67713 -
67714 /*
67715 * The "pud_xxx()" functions here are trivial for a folded two-level
67716 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67717 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67718 index 810431d..0ec4804f 100644
67719 --- a/include/asm-generic/pgtable-nopud.h
67720 +++ b/include/asm-generic/pgtable-nopud.h
67721 @@ -1,10 +1,15 @@
67722 #ifndef _PGTABLE_NOPUD_H
67723 #define _PGTABLE_NOPUD_H
67724
67725 -#ifndef __ASSEMBLY__
67726 -
67727 #define __PAGETABLE_PUD_FOLDED
67728
67729 +#define PUD_SHIFT PGDIR_SHIFT
67730 +#define PTRS_PER_PUD 1
67731 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67732 +#define PUD_MASK (~(PUD_SIZE-1))
67733 +
67734 +#ifndef __ASSEMBLY__
67735 +
67736 /*
67737 * Having the pud type consist of a pgd gets the size right, and allows
67738 * us to conceptually access the pgd entry that this pud is folded into
67739 @@ -12,11 +17,6 @@
67740 */
67741 typedef struct { pgd_t pgd; } pud_t;
67742
67743 -#define PUD_SHIFT PGDIR_SHIFT
67744 -#define PTRS_PER_PUD 1
67745 -#define PUD_SIZE (1UL << PUD_SHIFT)
67746 -#define PUD_MASK (~(PUD_SIZE-1))
67747 -
67748 /*
67749 * The "pgd_xxx()" functions here are trivial for a folded two-level
67750 * setup: the pud is never bad, and a pud always exists (as it's folded
67751 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67752 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67753
67754 #define pgd_populate(mm, pgd, pud) do { } while (0)
67755 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67756 /*
67757 * (puds are folded into pgds so this doesn't get actually called,
67758 * but the define is needed for a generic inline function.)
67759 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67760 index a59ff51..2594a70 100644
67761 --- a/include/asm-generic/pgtable.h
67762 +++ b/include/asm-generic/pgtable.h
67763 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67764 }
67765 #endif /* CONFIG_NUMA_BALANCING */
67766
67767 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67768 +static inline unsigned long pax_open_kernel(void) { return 0; }
67769 +#endif
67770 +
67771 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67772 +static inline unsigned long pax_close_kernel(void) { return 0; }
67773 +#endif
67774 +
67775 #endif /* CONFIG_MMU */
67776
67777 #endif /* !__ASSEMBLY__ */
67778 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67779 index eb58d2d..df131bf 100644
67780 --- a/include/asm-generic/vmlinux.lds.h
67781 +++ b/include/asm-generic/vmlinux.lds.h
67782 @@ -239,6 +239,7 @@
67783 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67784 VMLINUX_SYMBOL(__start_rodata) = .; \
67785 *(.rodata) *(.rodata.*) \
67786 + *(.data..read_only) \
67787 *(__vermagic) /* Kernel version magic */ \
67788 . = ALIGN(8); \
67789 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67790 @@ -749,17 +750,18 @@
67791 * section in the linker script will go there too. @phdr should have
67792 * a leading colon.
67793 *
67794 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67795 + * Note that this macros defines per_cpu_load as an absolute symbol.
67796 * If there is no need to put the percpu section at a predetermined
67797 * address, use PERCPU_SECTION.
67798 */
67799 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67800 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67801 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67802 + per_cpu_load = .; \
67803 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67804 - LOAD_OFFSET) { \
67805 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67806 PERCPU_INPUT(cacheline) \
67807 } phdr \
67808 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67809 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67810
67811 /**
67812 * PERCPU_SECTION - define output section for percpu area, simple version
67813 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67814 index 418d270..bfd2794 100644
67815 --- a/include/crypto/algapi.h
67816 +++ b/include/crypto/algapi.h
67817 @@ -34,7 +34,7 @@ struct crypto_type {
67818 unsigned int maskclear;
67819 unsigned int maskset;
67820 unsigned int tfmsize;
67821 -};
67822 +} __do_const;
67823
67824 struct crypto_instance {
67825 struct crypto_alg alg;
67826 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67827 index 63d17ee..716de2b 100644
67828 --- a/include/drm/drmP.h
67829 +++ b/include/drm/drmP.h
67830 @@ -72,6 +72,7 @@
67831 #include <linux/workqueue.h>
67832 #include <linux/poll.h>
67833 #include <asm/pgalloc.h>
67834 +#include <asm/local.h>
67835 #include <drm/drm.h>
67836 #include <drm/drm_sarea.h>
67837
67838 @@ -296,10 +297,12 @@ do { \
67839 * \param cmd command.
67840 * \param arg argument.
67841 */
67842 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67843 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67844 + struct drm_file *file_priv);
67845 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67846 struct drm_file *file_priv);
67847
67848 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67849 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67850 unsigned long arg);
67851
67852 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67853 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67854 struct drm_ioctl_desc {
67855 unsigned int cmd;
67856 int flags;
67857 - drm_ioctl_t *func;
67858 + drm_ioctl_t func;
67859 unsigned int cmd_drv;
67860 const char *name;
67861 -};
67862 +} __do_const;
67863
67864 /**
67865 * Creates a driver or general drm_ioctl_desc array entry for the given
67866 @@ -1015,7 +1018,7 @@ struct drm_info_list {
67867 int (*show)(struct seq_file*, void*); /** show callback */
67868 u32 driver_features; /**< Required driver features for this entry */
67869 void *data;
67870 -};
67871 +} __do_const;
67872
67873 /**
67874 * debugfs node structure. This structure represents a debugfs file.
67875 @@ -1088,7 +1091,7 @@ struct drm_device {
67876
67877 /** \name Usage Counters */
67878 /*@{ */
67879 - int open_count; /**< Outstanding files open */
67880 + local_t open_count; /**< Outstanding files open */
67881 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67882 atomic_t vma_count; /**< Outstanding vma areas open */
67883 int buf_use; /**< Buffers in use -- cannot alloc */
67884 @@ -1099,7 +1102,7 @@ struct drm_device {
67885 /*@{ */
67886 unsigned long counters;
67887 enum drm_stat_type types[15];
67888 - atomic_t counts[15];
67889 + atomic_unchecked_t counts[15];
67890 /*@} */
67891
67892 struct list_head filelist;
67893 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67894 index f43d556..94d9343 100644
67895 --- a/include/drm/drm_crtc_helper.h
67896 +++ b/include/drm/drm_crtc_helper.h
67897 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67898 struct drm_connector *connector);
67899 /* disable encoder when not in use - more explicit than dpms off */
67900 void (*disable)(struct drm_encoder *encoder);
67901 -};
67902 +} __no_const;
67903
67904 /**
67905 * drm_connector_helper_funcs - helper operations for connectors
67906 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67907 index 72dcbe8..8db58d7 100644
67908 --- a/include/drm/ttm/ttm_memory.h
67909 +++ b/include/drm/ttm/ttm_memory.h
67910 @@ -48,7 +48,7 @@
67911
67912 struct ttm_mem_shrink {
67913 int (*do_shrink) (struct ttm_mem_shrink *);
67914 -};
67915 +} __no_const;
67916
67917 /**
67918 * struct ttm_mem_global - Global memory accounting structure.
67919 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67920 index 4b840e8..155d235 100644
67921 --- a/include/keys/asymmetric-subtype.h
67922 +++ b/include/keys/asymmetric-subtype.h
67923 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67924 /* Verify the signature on a key of this subtype (optional) */
67925 int (*verify_signature)(const struct key *key,
67926 const struct public_key_signature *sig);
67927 -};
67928 +} __do_const;
67929
67930 /**
67931 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67932 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67933 index c1da539..1dcec55 100644
67934 --- a/include/linux/atmdev.h
67935 +++ b/include/linux/atmdev.h
67936 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67937 #endif
67938
67939 struct k_atm_aal_stats {
67940 -#define __HANDLE_ITEM(i) atomic_t i
67941 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67942 __AAL_STAT_ITEMS
67943 #undef __HANDLE_ITEM
67944 };
67945 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67946 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67947 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67948 struct module *owner;
67949 -};
67950 +} __do_const ;
67951
67952 struct atmphy_ops {
67953 int (*start)(struct atm_dev *dev);
67954 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67955 index 70cf138..cabb82e 100644
67956 --- a/include/linux/binfmts.h
67957 +++ b/include/linux/binfmts.h
67958 @@ -73,8 +73,9 @@ struct linux_binfmt {
67959 int (*load_binary)(struct linux_binprm *);
67960 int (*load_shlib)(struct file *);
67961 int (*core_dump)(struct coredump_params *cprm);
67962 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67963 unsigned long min_coredump; /* minimal dump size */
67964 -};
67965 +} __do_const;
67966
67967 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67968
67969 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67970 index 2fdb4a4..54aad7e 100644
67971 --- a/include/linux/blkdev.h
67972 +++ b/include/linux/blkdev.h
67973 @@ -1526,7 +1526,7 @@ struct block_device_operations {
67974 /* this callback is with swap_lock and sometimes page table lock held */
67975 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67976 struct module *owner;
67977 -};
67978 +} __do_const;
67979
67980 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67981 unsigned long);
67982 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67983 index 7c2e030..b72475d 100644
67984 --- a/include/linux/blktrace_api.h
67985 +++ b/include/linux/blktrace_api.h
67986 @@ -23,7 +23,7 @@ struct blk_trace {
67987 struct dentry *dir;
67988 struct dentry *dropped_file;
67989 struct dentry *msg_file;
67990 - atomic_t dropped;
67991 + atomic_unchecked_t dropped;
67992 };
67993
67994 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67995 diff --git a/include/linux/cache.h b/include/linux/cache.h
67996 index 4c57065..4307975 100644
67997 --- a/include/linux/cache.h
67998 +++ b/include/linux/cache.h
67999 @@ -16,6 +16,10 @@
68000 #define __read_mostly
68001 #endif
68002
68003 +#ifndef __read_only
68004 +#define __read_only __read_mostly
68005 +#endif
68006 +
68007 #ifndef ____cacheline_aligned
68008 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
68009 #endif
68010 diff --git a/include/linux/capability.h b/include/linux/capability.h
68011 index d9a4f7f4..19f77d6 100644
68012 --- a/include/linux/capability.h
68013 +++ b/include/linux/capability.h
68014 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
68015 extern bool nsown_capable(int cap);
68016 extern bool inode_capable(const struct inode *inode, int cap);
68017 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
68018 +extern bool capable_nolog(int cap);
68019 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
68020 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
68021
68022 /* audit system wants to get cap info from files as well */
68023 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
68024
68025 +extern int is_privileged_binary(const struct dentry *dentry);
68026 +
68027 #endif /* !_LINUX_CAPABILITY_H */
68028 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
68029 index 8609d57..86e4d79 100644
68030 --- a/include/linux/cdrom.h
68031 +++ b/include/linux/cdrom.h
68032 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
68033
68034 /* driver specifications */
68035 const int capability; /* capability flags */
68036 - int n_minors; /* number of active minor devices */
68037 /* handle uniform packets for scsi type devices (scsi,atapi) */
68038 int (*generic_packet) (struct cdrom_device_info *,
68039 struct packet_command *);
68040 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
68041 index 4ce9056..86caac6 100644
68042 --- a/include/linux/cleancache.h
68043 +++ b/include/linux/cleancache.h
68044 @@ -31,7 +31,7 @@ struct cleancache_ops {
68045 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
68046 void (*invalidate_inode)(int, struct cleancache_filekey);
68047 void (*invalidate_fs)(int);
68048 -};
68049 +} __no_const;
68050
68051 extern struct cleancache_ops *
68052 cleancache_register_ops(struct cleancache_ops *ops);
68053 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
68054 index 1186098..f87e53d 100644
68055 --- a/include/linux/clk-provider.h
68056 +++ b/include/linux/clk-provider.h
68057 @@ -132,6 +132,7 @@ struct clk_ops {
68058 unsigned long);
68059 void (*init)(struct clk_hw *hw);
68060 };
68061 +typedef struct clk_ops __no_const clk_ops_no_const;
68062
68063 /**
68064 * struct clk_init_data - holds init data that's common to all clocks and is
68065 diff --git a/include/linux/compat.h b/include/linux/compat.h
68066 index 7f0c1dd..b5729c6 100644
68067 --- a/include/linux/compat.h
68068 +++ b/include/linux/compat.h
68069 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
68070 compat_size_t __user *len_ptr);
68071
68072 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
68073 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
68074 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
68075 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
68076 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
68077 compat_ssize_t msgsz, int msgflg);
68078 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
68079 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
68080 compat_ulong_t addr, compat_ulong_t data);
68081 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
68082 - compat_long_t addr, compat_long_t data);
68083 + compat_ulong_t addr, compat_ulong_t data);
68084
68085 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
68086 /*
68087 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
68088 index 842de22..7f3a41f 100644
68089 --- a/include/linux/compiler-gcc4.h
68090 +++ b/include/linux/compiler-gcc4.h
68091 @@ -39,9 +39,29 @@
68092 # define __compiletime_warning(message) __attribute__((warning(message)))
68093 # define __compiletime_error(message) __attribute__((error(message)))
68094 #endif /* __CHECKER__ */
68095 +
68096 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
68097 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
68098 +#define __bos0(ptr) __bos((ptr), 0)
68099 +#define __bos1(ptr) __bos((ptr), 1)
68100 #endif /* GCC_VERSION >= 40300 */
68101
68102 #if GCC_VERSION >= 40500
68103 +
68104 +#ifdef CONSTIFY_PLUGIN
68105 +#define __no_const __attribute__((no_const))
68106 +#define __do_const __attribute__((do_const))
68107 +#endif
68108 +
68109 +#ifdef SIZE_OVERFLOW_PLUGIN
68110 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
68111 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
68112 +#endif
68113 +
68114 +#ifdef LATENT_ENTROPY_PLUGIN
68115 +#define __latent_entropy __attribute__((latent_entropy))
68116 +#endif
68117 +
68118 /*
68119 * Mark a position in code as unreachable. This can be used to
68120 * suppress control flow warnings after asm blocks that transfer
68121 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68122 index 92669cd..1771a15 100644
68123 --- a/include/linux/compiler.h
68124 +++ b/include/linux/compiler.h
68125 @@ -5,11 +5,14 @@
68126
68127 #ifdef __CHECKER__
68128 # define __user __attribute__((noderef, address_space(1)))
68129 +# define __force_user __force __user
68130 # define __kernel __attribute__((address_space(0)))
68131 +# define __force_kernel __force __kernel
68132 # define __safe __attribute__((safe))
68133 # define __force __attribute__((force))
68134 # define __nocast __attribute__((nocast))
68135 # define __iomem __attribute__((noderef, address_space(2)))
68136 +# define __force_iomem __force __iomem
68137 # define __must_hold(x) __attribute__((context(x,1,1)))
68138 # define __acquires(x) __attribute__((context(x,0,1)))
68139 # define __releases(x) __attribute__((context(x,1,0)))
68140 @@ -17,20 +20,37 @@
68141 # define __release(x) __context__(x,-1)
68142 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68143 # define __percpu __attribute__((noderef, address_space(3)))
68144 +# define __force_percpu __force __percpu
68145 #ifdef CONFIG_SPARSE_RCU_POINTER
68146 # define __rcu __attribute__((noderef, address_space(4)))
68147 +# define __force_rcu __force __rcu
68148 #else
68149 # define __rcu
68150 +# define __force_rcu
68151 #endif
68152 extern void __chk_user_ptr(const volatile void __user *);
68153 extern void __chk_io_ptr(const volatile void __iomem *);
68154 #else
68155 -# define __user
68156 -# define __kernel
68157 +# ifdef CHECKER_PLUGIN
68158 +//# define __user
68159 +//# define __force_user
68160 +//# define __kernel
68161 +//# define __force_kernel
68162 +# else
68163 +# ifdef STRUCTLEAK_PLUGIN
68164 +# define __user __attribute__((user))
68165 +# else
68166 +# define __user
68167 +# endif
68168 +# define __force_user
68169 +# define __kernel
68170 +# define __force_kernel
68171 +# endif
68172 # define __safe
68173 # define __force
68174 # define __nocast
68175 # define __iomem
68176 +# define __force_iomem
68177 # define __chk_user_ptr(x) (void)0
68178 # define __chk_io_ptr(x) (void)0
68179 # define __builtin_warning(x, y...) (1)
68180 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68181 # define __release(x) (void)0
68182 # define __cond_lock(x,c) (c)
68183 # define __percpu
68184 +# define __force_percpu
68185 # define __rcu
68186 +# define __force_rcu
68187 #endif
68188
68189 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68190 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68191 # define __attribute_const__ /* unimplemented */
68192 #endif
68193
68194 +#ifndef __no_const
68195 +# define __no_const
68196 +#endif
68197 +
68198 +#ifndef __do_const
68199 +# define __do_const
68200 +#endif
68201 +
68202 +#ifndef __size_overflow
68203 +# define __size_overflow(...)
68204 +#endif
68205 +
68206 +#ifndef __intentional_overflow
68207 +# define __intentional_overflow(...)
68208 +#endif
68209 +
68210 +#ifndef __latent_entropy
68211 +# define __latent_entropy
68212 +#endif
68213 +
68214 /*
68215 * Tell gcc if a function is cold. The compiler will assume any path
68216 * directly leading to the call is unlikely.
68217 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68218 #define __cold
68219 #endif
68220
68221 +#ifndef __alloc_size
68222 +#define __alloc_size(...)
68223 +#endif
68224 +
68225 +#ifndef __bos
68226 +#define __bos(ptr, arg)
68227 +#endif
68228 +
68229 +#ifndef __bos0
68230 +#define __bos0(ptr)
68231 +#endif
68232 +
68233 +#ifndef __bos1
68234 +#define __bos1(ptr)
68235 +#endif
68236 +
68237 /* Simple shorthand for a section definition */
68238 #ifndef __section
68239 # define __section(S) __attribute__ ((__section__(#S)))
68240 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68241 * use is to mediate communication between process-level code and irq/NMI
68242 * handlers, all running on the same CPU.
68243 */
68244 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68245 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68246 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68247
68248 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
68249 #ifdef CONFIG_KPROBES
68250 diff --git a/include/linux/completion.h b/include/linux/completion.h
68251 index 33f0280..35c6568 100644
68252 --- a/include/linux/completion.h
68253 +++ b/include/linux/completion.h
68254 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68255 extern void wait_for_completion(struct completion *);
68256 extern void wait_for_completion_io(struct completion *);
68257 extern int wait_for_completion_interruptible(struct completion *x);
68258 -extern int wait_for_completion_killable(struct completion *x);
68259 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68260 extern unsigned long wait_for_completion_timeout(struct completion *x,
68261 unsigned long timeout);
68262 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68263 unsigned long timeout);
68264 extern long wait_for_completion_interruptible_timeout(
68265 - struct completion *x, unsigned long timeout);
68266 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68267 extern long wait_for_completion_killable_timeout(
68268 - struct completion *x, unsigned long timeout);
68269 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68270 extern bool try_wait_for_completion(struct completion *x);
68271 extern bool completion_done(struct completion *x);
68272
68273 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68274 index 34025df..d94bbbc 100644
68275 --- a/include/linux/configfs.h
68276 +++ b/include/linux/configfs.h
68277 @@ -125,7 +125,7 @@ struct configfs_attribute {
68278 const char *ca_name;
68279 struct module *ca_owner;
68280 umode_t ca_mode;
68281 -};
68282 +} __do_const;
68283
68284 /*
68285 * Users often need to create attribute structures for their configurable
68286 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68287 index 9f3c7e8..a18c7b6 100644
68288 --- a/include/linux/cpu.h
68289 +++ b/include/linux/cpu.h
68290 @@ -115,7 +115,7 @@ enum {
68291 /* Need to know about CPUs going up/down? */
68292 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68293 #define cpu_notifier(fn, pri) { \
68294 - static struct notifier_block fn##_nb __cpuinitdata = \
68295 + static struct notifier_block fn##_nb = \
68296 { .notifier_call = fn, .priority = pri }; \
68297 register_cpu_notifier(&fn##_nb); \
68298 }
68299 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68300 index 037d36a..ca5fe6e 100644
68301 --- a/include/linux/cpufreq.h
68302 +++ b/include/linux/cpufreq.h
68303 @@ -262,7 +262,7 @@ struct cpufreq_driver {
68304 int (*suspend) (struct cpufreq_policy *policy);
68305 int (*resume) (struct cpufreq_policy *policy);
68306 struct freq_attr **attr;
68307 -};
68308 +} __do_const;
68309
68310 /* flags */
68311
68312 @@ -321,6 +321,7 @@ struct global_attr {
68313 ssize_t (*store)(struct kobject *a, struct attribute *b,
68314 const char *c, size_t count);
68315 };
68316 +typedef struct global_attr __no_const global_attr_no_const;
68317
68318 #define define_one_global_ro(_name) \
68319 static struct global_attr _name = \
68320 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68321 index 8f04062..900239a 100644
68322 --- a/include/linux/cpuidle.h
68323 +++ b/include/linux/cpuidle.h
68324 @@ -52,7 +52,8 @@ struct cpuidle_state {
68325 int index);
68326
68327 int (*enter_dead) (struct cpuidle_device *dev, int index);
68328 -};
68329 +} __do_const;
68330 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68331
68332 /* Idle State Flags */
68333 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68334 @@ -191,7 +192,7 @@ struct cpuidle_governor {
68335 void (*reflect) (struct cpuidle_device *dev, int index);
68336
68337 struct module *owner;
68338 -};
68339 +} __do_const;
68340
68341 #ifdef CONFIG_CPU_IDLE
68342
68343 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68344 index d08e4d2..95fad61 100644
68345 --- a/include/linux/cpumask.h
68346 +++ b/include/linux/cpumask.h
68347 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68348 }
68349
68350 /* Valid inputs for n are -1 and 0. */
68351 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68352 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68353 {
68354 return n+1;
68355 }
68356
68357 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68358 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68359 {
68360 return n+1;
68361 }
68362
68363 -static inline unsigned int cpumask_next_and(int n,
68364 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68365 const struct cpumask *srcp,
68366 const struct cpumask *andp)
68367 {
68368 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68369 *
68370 * Returns >= nr_cpu_ids if no further cpus set.
68371 */
68372 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68373 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68374 {
68375 /* -1 is a legal arg here. */
68376 if (n != -1)
68377 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68378 *
68379 * Returns >= nr_cpu_ids if no further cpus unset.
68380 */
68381 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68382 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68383 {
68384 /* -1 is a legal arg here. */
68385 if (n != -1)
68386 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68387 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68388 }
68389
68390 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68391 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68392 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68393
68394 /**
68395 diff --git a/include/linux/cred.h b/include/linux/cred.h
68396 index 04421e8..6bce4ef 100644
68397 --- a/include/linux/cred.h
68398 +++ b/include/linux/cred.h
68399 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68400 static inline void validate_process_creds(void)
68401 {
68402 }
68403 +static inline void validate_task_creds(struct task_struct *task)
68404 +{
68405 +}
68406 #endif
68407
68408 /**
68409 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68410 index b92eadf..b4ecdc1 100644
68411 --- a/include/linux/crypto.h
68412 +++ b/include/linux/crypto.h
68413 @@ -373,7 +373,7 @@ struct cipher_tfm {
68414 const u8 *key, unsigned int keylen);
68415 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68416 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68417 -};
68418 +} __no_const;
68419
68420 struct hash_tfm {
68421 int (*init)(struct hash_desc *desc);
68422 @@ -394,13 +394,13 @@ struct compress_tfm {
68423 int (*cot_decompress)(struct crypto_tfm *tfm,
68424 const u8 *src, unsigned int slen,
68425 u8 *dst, unsigned int *dlen);
68426 -};
68427 +} __no_const;
68428
68429 struct rng_tfm {
68430 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68431 unsigned int dlen);
68432 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68433 -};
68434 +} __no_const;
68435
68436 #define crt_ablkcipher crt_u.ablkcipher
68437 #define crt_aead crt_u.aead
68438 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68439 index 653589e..4ef254a 100644
68440 --- a/include/linux/ctype.h
68441 +++ b/include/linux/ctype.h
68442 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68443 * Fast implementation of tolower() for internal usage. Do not use in your
68444 * code.
68445 */
68446 -static inline char _tolower(const char c)
68447 +static inline unsigned char _tolower(const unsigned char c)
68448 {
68449 return c | 0x20;
68450 }
68451 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68452 index 7925bf0..d5143d2 100644
68453 --- a/include/linux/decompress/mm.h
68454 +++ b/include/linux/decompress/mm.h
68455 @@ -77,7 +77,7 @@ static void free(void *where)
68456 * warnings when not needed (indeed large_malloc / large_free are not
68457 * needed by inflate */
68458
68459 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68460 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68461 #define free(a) kfree(a)
68462
68463 #define large_malloc(a) vmalloc(a)
68464 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68465 index fe8c447..bdc1f33 100644
68466 --- a/include/linux/devfreq.h
68467 +++ b/include/linux/devfreq.h
68468 @@ -114,7 +114,7 @@ struct devfreq_governor {
68469 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68470 int (*event_handler)(struct devfreq *devfreq,
68471 unsigned int event, void *data);
68472 -};
68473 +} __do_const;
68474
68475 /**
68476 * struct devfreq - Device devfreq structure
68477 diff --git a/include/linux/device.h b/include/linux/device.h
68478 index c0a1261..dba7569 100644
68479 --- a/include/linux/device.h
68480 +++ b/include/linux/device.h
68481 @@ -290,7 +290,7 @@ struct subsys_interface {
68482 struct list_head node;
68483 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68484 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68485 -};
68486 +} __do_const;
68487
68488 int subsys_interface_register(struct subsys_interface *sif);
68489 void subsys_interface_unregister(struct subsys_interface *sif);
68490 @@ -473,7 +473,7 @@ struct device_type {
68491 void (*release)(struct device *dev);
68492
68493 const struct dev_pm_ops *pm;
68494 -};
68495 +} __do_const;
68496
68497 /* interface for exporting device attributes */
68498 struct device_attribute {
68499 @@ -483,11 +483,12 @@ struct device_attribute {
68500 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68501 const char *buf, size_t count);
68502 };
68503 +typedef struct device_attribute __no_const device_attribute_no_const;
68504
68505 struct dev_ext_attribute {
68506 struct device_attribute attr;
68507 void *var;
68508 -};
68509 +} __do_const;
68510
68511 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68512 char *buf);
68513 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68514 index 94af418..b1ca7a2 100644
68515 --- a/include/linux/dma-mapping.h
68516 +++ b/include/linux/dma-mapping.h
68517 @@ -54,7 +54,7 @@ struct dma_map_ops {
68518 u64 (*get_required_mask)(struct device *dev);
68519 #endif
68520 int is_phys;
68521 -};
68522 +} __do_const;
68523
68524 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68525
68526 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68527 index 96d3e4a..dc36433 100644
68528 --- a/include/linux/dmaengine.h
68529 +++ b/include/linux/dmaengine.h
68530 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
68531 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68532 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68533
68534 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68535 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68536 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68537 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68538 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68539 struct dma_pinned_list *pinned_list, struct page *page,
68540 unsigned int offset, size_t len);
68541
68542 diff --git a/include/linux/efi.h b/include/linux/efi.h
68543 index 2bc0ad7..3f7b006 100644
68544 --- a/include/linux/efi.h
68545 +++ b/include/linux/efi.h
68546 @@ -745,6 +745,7 @@ struct efivar_operations {
68547 efi_set_variable_t *set_variable;
68548 efi_query_variable_store_t *query_variable_store;
68549 };
68550 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68551
68552 struct efivars {
68553 /*
68554 diff --git a/include/linux/elf.h b/include/linux/elf.h
68555 index 40a3c0e..4c45a38 100644
68556 --- a/include/linux/elf.h
68557 +++ b/include/linux/elf.h
68558 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68559 #define elf_note elf32_note
68560 #define elf_addr_t Elf32_Off
68561 #define Elf_Half Elf32_Half
68562 +#define elf_dyn Elf32_Dyn
68563
68564 #else
68565
68566 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68567 #define elf_note elf64_note
68568 #define elf_addr_t Elf64_Off
68569 #define Elf_Half Elf64_Half
68570 +#define elf_dyn Elf64_Dyn
68571
68572 #endif
68573
68574 diff --git a/include/linux/err.h b/include/linux/err.h
68575 index f2edce2..cc2082c 100644
68576 --- a/include/linux/err.h
68577 +++ b/include/linux/err.h
68578 @@ -19,12 +19,12 @@
68579
68580 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68581
68582 -static inline void * __must_check ERR_PTR(long error)
68583 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68584 {
68585 return (void *) error;
68586 }
68587
68588 -static inline long __must_check PTR_ERR(const void *ptr)
68589 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68590 {
68591 return (long) ptr;
68592 }
68593 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68594 index fcb51c8..bdafcf6 100644
68595 --- a/include/linux/extcon.h
68596 +++ b/include/linux/extcon.h
68597 @@ -134,7 +134,7 @@ struct extcon_dev {
68598 /* /sys/class/extcon/.../mutually_exclusive/... */
68599 struct attribute_group attr_g_muex;
68600 struct attribute **attrs_muex;
68601 - struct device_attribute *d_attrs_muex;
68602 + device_attribute_no_const *d_attrs_muex;
68603 };
68604
68605 /**
68606 diff --git a/include/linux/fb.h b/include/linux/fb.h
68607 index d49c60f..2834fbe 100644
68608 --- a/include/linux/fb.h
68609 +++ b/include/linux/fb.h
68610 @@ -304,7 +304,7 @@ struct fb_ops {
68611 /* called at KDB enter and leave time to prepare the console */
68612 int (*fb_debug_enter)(struct fb_info *info);
68613 int (*fb_debug_leave)(struct fb_info *info);
68614 -};
68615 +} __do_const;
68616
68617 #ifdef CONFIG_FB_TILEBLITTING
68618 #define FB_TILE_CURSOR_NONE 0
68619 diff --git a/include/linux/filter.h b/include/linux/filter.h
68620 index f65f5a6..2f4f93a 100644
68621 --- a/include/linux/filter.h
68622 +++ b/include/linux/filter.h
68623 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68624
68625 struct sk_buff;
68626 struct sock;
68627 +struct bpf_jit_work;
68628
68629 struct sk_filter
68630 {
68631 @@ -27,6 +28,9 @@ struct sk_filter
68632 unsigned int len; /* Number of filter blocks */
68633 unsigned int (*bpf_func)(const struct sk_buff *skb,
68634 const struct sock_filter *filter);
68635 +#ifdef CONFIG_BPF_JIT
68636 + struct bpf_jit_work *work;
68637 +#endif
68638 struct rcu_head rcu;
68639 struct sock_filter insns[0];
68640 };
68641 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68642 index 8293262..2b3b8bd 100644
68643 --- a/include/linux/frontswap.h
68644 +++ b/include/linux/frontswap.h
68645 @@ -11,7 +11,7 @@ struct frontswap_ops {
68646 int (*load)(unsigned, pgoff_t, struct page *);
68647 void (*invalidate_page)(unsigned, pgoff_t);
68648 void (*invalidate_area)(unsigned);
68649 -};
68650 +} __no_const;
68651
68652 extern bool frontswap_enabled;
68653 extern struct frontswap_ops *
68654 diff --git a/include/linux/fs.h b/include/linux/fs.h
68655 index 65c2be2..4c53f6e 100644
68656 --- a/include/linux/fs.h
68657 +++ b/include/linux/fs.h
68658 @@ -1543,7 +1543,8 @@ struct file_operations {
68659 long (*fallocate)(struct file *file, int mode, loff_t offset,
68660 loff_t len);
68661 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68662 -};
68663 +} __do_const;
68664 +typedef struct file_operations __no_const file_operations_no_const;
68665
68666 struct inode_operations {
68667 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68668 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68669 inode->i_flags |= S_NOSEC;
68670 }
68671
68672 +static inline bool is_sidechannel_device(const struct inode *inode)
68673 +{
68674 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68675 + umode_t mode = inode->i_mode;
68676 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68677 +#else
68678 + return false;
68679 +#endif
68680 +}
68681 +
68682 #endif /* _LINUX_FS_H */
68683 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68684 index 2b93a9a..855d94a 100644
68685 --- a/include/linux/fs_struct.h
68686 +++ b/include/linux/fs_struct.h
68687 @@ -6,7 +6,7 @@
68688 #include <linux/seqlock.h>
68689
68690 struct fs_struct {
68691 - int users;
68692 + atomic_t users;
68693 spinlock_t lock;
68694 seqcount_t seq;
68695 int umask;
68696 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68697 index 5dfa0aa..6acf322 100644
68698 --- a/include/linux/fscache-cache.h
68699 +++ b/include/linux/fscache-cache.h
68700 @@ -112,7 +112,7 @@ struct fscache_operation {
68701 fscache_operation_release_t release;
68702 };
68703
68704 -extern atomic_t fscache_op_debug_id;
68705 +extern atomic_unchecked_t fscache_op_debug_id;
68706 extern void fscache_op_work_func(struct work_struct *work);
68707
68708 extern void fscache_enqueue_operation(struct fscache_operation *);
68709 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68710 INIT_WORK(&op->work, fscache_op_work_func);
68711 atomic_set(&op->usage, 1);
68712 op->state = FSCACHE_OP_ST_INITIALISED;
68713 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68714 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68715 op->processor = processor;
68716 op->release = release;
68717 INIT_LIST_HEAD(&op->pend_link);
68718 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68719 index 7a08623..4c07b0f 100644
68720 --- a/include/linux/fscache.h
68721 +++ b/include/linux/fscache.h
68722 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68723 * - this is mandatory for any object that may have data
68724 */
68725 void (*now_uncached)(void *cookie_netfs_data);
68726 -};
68727 +} __do_const;
68728
68729 /*
68730 * fscache cached network filesystem type
68731 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68732 index a78680a..87bd73e 100644
68733 --- a/include/linux/fsnotify.h
68734 +++ b/include/linux/fsnotify.h
68735 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68736 struct inode *inode = path->dentry->d_inode;
68737 __u32 mask = FS_ACCESS;
68738
68739 + if (is_sidechannel_device(inode))
68740 + return;
68741 +
68742 if (S_ISDIR(inode->i_mode))
68743 mask |= FS_ISDIR;
68744
68745 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68746 struct inode *inode = path->dentry->d_inode;
68747 __u32 mask = FS_MODIFY;
68748
68749 + if (is_sidechannel_device(inode))
68750 + return;
68751 +
68752 if (S_ISDIR(inode->i_mode))
68753 mask |= FS_ISDIR;
68754
68755 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68756 */
68757 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68758 {
68759 - return kstrdup(name, GFP_KERNEL);
68760 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68761 }
68762
68763 /*
68764 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68765 index 9f3c275..911b591 100644
68766 --- a/include/linux/genhd.h
68767 +++ b/include/linux/genhd.h
68768 @@ -194,7 +194,7 @@ struct gendisk {
68769 struct kobject *slave_dir;
68770
68771 struct timer_rand_state *random;
68772 - atomic_t sync_io; /* RAID */
68773 + atomic_unchecked_t sync_io; /* RAID */
68774 struct disk_events *ev;
68775 #ifdef CONFIG_BLK_DEV_INTEGRITY
68776 struct blk_integrity *integrity;
68777 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68778 index 023bc34..b02b46a 100644
68779 --- a/include/linux/genl_magic_func.h
68780 +++ b/include/linux/genl_magic_func.h
68781 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68782 },
68783
68784 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68785 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68786 +static struct genl_ops ZZZ_genl_ops[] = {
68787 #include GENL_MAGIC_INCLUDE_FILE
68788 };
68789
68790 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68791 index 0f615eb..5c3832f 100644
68792 --- a/include/linux/gfp.h
68793 +++ b/include/linux/gfp.h
68794 @@ -35,6 +35,13 @@ struct vm_area_struct;
68795 #define ___GFP_NO_KSWAPD 0x400000u
68796 #define ___GFP_OTHER_NODE 0x800000u
68797 #define ___GFP_WRITE 0x1000000u
68798 +
68799 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68800 +#define ___GFP_USERCOPY 0x2000000u
68801 +#else
68802 +#define ___GFP_USERCOPY 0
68803 +#endif
68804 +
68805 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68806
68807 /*
68808 @@ -92,6 +99,7 @@ struct vm_area_struct;
68809 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68810 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68811 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68812 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68813
68814 /*
68815 * This may seem redundant, but it's a way of annotating false positives vs.
68816 @@ -99,7 +107,7 @@ struct vm_area_struct;
68817 */
68818 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68819
68820 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68821 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68822 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68823
68824 /* This equals 0, but use constants in case they ever change */
68825 @@ -153,6 +161,8 @@ struct vm_area_struct;
68826 /* 4GB DMA on some platforms */
68827 #define GFP_DMA32 __GFP_DMA32
68828
68829 +#define GFP_USERCOPY __GFP_USERCOPY
68830 +
68831 /* Convert GFP flags to their corresponding migrate type */
68832 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68833 {
68834 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68835 new file mode 100644
68836 index 0000000..ebe6d72
68837 --- /dev/null
68838 +++ b/include/linux/gracl.h
68839 @@ -0,0 +1,319 @@
68840 +#ifndef GR_ACL_H
68841 +#define GR_ACL_H
68842 +
68843 +#include <linux/grdefs.h>
68844 +#include <linux/resource.h>
68845 +#include <linux/capability.h>
68846 +#include <linux/dcache.h>
68847 +#include <asm/resource.h>
68848 +
68849 +/* Major status information */
68850 +
68851 +#define GR_VERSION "grsecurity 2.9.1"
68852 +#define GRSECURITY_VERSION 0x2901
68853 +
68854 +enum {
68855 + GR_SHUTDOWN = 0,
68856 + GR_ENABLE = 1,
68857 + GR_SPROLE = 2,
68858 + GR_RELOAD = 3,
68859 + GR_SEGVMOD = 4,
68860 + GR_STATUS = 5,
68861 + GR_UNSPROLE = 6,
68862 + GR_PASSSET = 7,
68863 + GR_SPROLEPAM = 8,
68864 +};
68865 +
68866 +/* Password setup definitions
68867 + * kernel/grhash.c */
68868 +enum {
68869 + GR_PW_LEN = 128,
68870 + GR_SALT_LEN = 16,
68871 + GR_SHA_LEN = 32,
68872 +};
68873 +
68874 +enum {
68875 + GR_SPROLE_LEN = 64,
68876 +};
68877 +
68878 +enum {
68879 + GR_NO_GLOB = 0,
68880 + GR_REG_GLOB,
68881 + GR_CREATE_GLOB
68882 +};
68883 +
68884 +#define GR_NLIMITS 32
68885 +
68886 +/* Begin Data Structures */
68887 +
68888 +struct sprole_pw {
68889 + unsigned char *rolename;
68890 + unsigned char salt[GR_SALT_LEN];
68891 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68892 +};
68893 +
68894 +struct name_entry {
68895 + __u32 key;
68896 + ino_t inode;
68897 + dev_t device;
68898 + char *name;
68899 + __u16 len;
68900 + __u8 deleted;
68901 + struct name_entry *prev;
68902 + struct name_entry *next;
68903 +};
68904 +
68905 +struct inodev_entry {
68906 + struct name_entry *nentry;
68907 + struct inodev_entry *prev;
68908 + struct inodev_entry *next;
68909 +};
68910 +
68911 +struct acl_role_db {
68912 + struct acl_role_label **r_hash;
68913 + __u32 r_size;
68914 +};
68915 +
68916 +struct inodev_db {
68917 + struct inodev_entry **i_hash;
68918 + __u32 i_size;
68919 +};
68920 +
68921 +struct name_db {
68922 + struct name_entry **n_hash;
68923 + __u32 n_size;
68924 +};
68925 +
68926 +struct crash_uid {
68927 + uid_t uid;
68928 + unsigned long expires;
68929 +};
68930 +
68931 +struct gr_hash_struct {
68932 + void **table;
68933 + void **nametable;
68934 + void *first;
68935 + __u32 table_size;
68936 + __u32 used_size;
68937 + int type;
68938 +};
68939 +
68940 +/* Userspace Grsecurity ACL data structures */
68941 +
68942 +struct acl_subject_label {
68943 + char *filename;
68944 + ino_t inode;
68945 + dev_t device;
68946 + __u32 mode;
68947 + kernel_cap_t cap_mask;
68948 + kernel_cap_t cap_lower;
68949 + kernel_cap_t cap_invert_audit;
68950 +
68951 + struct rlimit res[GR_NLIMITS];
68952 + __u32 resmask;
68953 +
68954 + __u8 user_trans_type;
68955 + __u8 group_trans_type;
68956 + uid_t *user_transitions;
68957 + gid_t *group_transitions;
68958 + __u16 user_trans_num;
68959 + __u16 group_trans_num;
68960 +
68961 + __u32 sock_families[2];
68962 + __u32 ip_proto[8];
68963 + __u32 ip_type;
68964 + struct acl_ip_label **ips;
68965 + __u32 ip_num;
68966 + __u32 inaddr_any_override;
68967 +
68968 + __u32 crashes;
68969 + unsigned long expires;
68970 +
68971 + struct acl_subject_label *parent_subject;
68972 + struct gr_hash_struct *hash;
68973 + struct acl_subject_label *prev;
68974 + struct acl_subject_label *next;
68975 +
68976 + struct acl_object_label **obj_hash;
68977 + __u32 obj_hash_size;
68978 + __u16 pax_flags;
68979 +};
68980 +
68981 +struct role_allowed_ip {
68982 + __u32 addr;
68983 + __u32 netmask;
68984 +
68985 + struct role_allowed_ip *prev;
68986 + struct role_allowed_ip *next;
68987 +};
68988 +
68989 +struct role_transition {
68990 + char *rolename;
68991 +
68992 + struct role_transition *prev;
68993 + struct role_transition *next;
68994 +};
68995 +
68996 +struct acl_role_label {
68997 + char *rolename;
68998 + uid_t uidgid;
68999 + __u16 roletype;
69000 +
69001 + __u16 auth_attempts;
69002 + unsigned long expires;
69003 +
69004 + struct acl_subject_label *root_label;
69005 + struct gr_hash_struct *hash;
69006 +
69007 + struct acl_role_label *prev;
69008 + struct acl_role_label *next;
69009 +
69010 + struct role_transition *transitions;
69011 + struct role_allowed_ip *allowed_ips;
69012 + uid_t *domain_children;
69013 + __u16 domain_child_num;
69014 +
69015 + umode_t umask;
69016 +
69017 + struct acl_subject_label **subj_hash;
69018 + __u32 subj_hash_size;
69019 +};
69020 +
69021 +struct user_acl_role_db {
69022 + struct acl_role_label **r_table;
69023 + __u32 num_pointers; /* Number of allocations to track */
69024 + __u32 num_roles; /* Number of roles */
69025 + __u32 num_domain_children; /* Number of domain children */
69026 + __u32 num_subjects; /* Number of subjects */
69027 + __u32 num_objects; /* Number of objects */
69028 +};
69029 +
69030 +struct acl_object_label {
69031 + char *filename;
69032 + ino_t inode;
69033 + dev_t device;
69034 + __u32 mode;
69035 +
69036 + struct acl_subject_label *nested;
69037 + struct acl_object_label *globbed;
69038 +
69039 + /* next two structures not used */
69040 +
69041 + struct acl_object_label *prev;
69042 + struct acl_object_label *next;
69043 +};
69044 +
69045 +struct acl_ip_label {
69046 + char *iface;
69047 + __u32 addr;
69048 + __u32 netmask;
69049 + __u16 low, high;
69050 + __u8 mode;
69051 + __u32 type;
69052 + __u32 proto[8];
69053 +
69054 + /* next two structures not used */
69055 +
69056 + struct acl_ip_label *prev;
69057 + struct acl_ip_label *next;
69058 +};
69059 +
69060 +struct gr_arg {
69061 + struct user_acl_role_db role_db;
69062 + unsigned char pw[GR_PW_LEN];
69063 + unsigned char salt[GR_SALT_LEN];
69064 + unsigned char sum[GR_SHA_LEN];
69065 + unsigned char sp_role[GR_SPROLE_LEN];
69066 + struct sprole_pw *sprole_pws;
69067 + dev_t segv_device;
69068 + ino_t segv_inode;
69069 + uid_t segv_uid;
69070 + __u16 num_sprole_pws;
69071 + __u16 mode;
69072 +};
69073 +
69074 +struct gr_arg_wrapper {
69075 + struct gr_arg *arg;
69076 + __u32 version;
69077 + __u32 size;
69078 +};
69079 +
69080 +struct subject_map {
69081 + struct acl_subject_label *user;
69082 + struct acl_subject_label *kernel;
69083 + struct subject_map *prev;
69084 + struct subject_map *next;
69085 +};
69086 +
69087 +struct acl_subj_map_db {
69088 + struct subject_map **s_hash;
69089 + __u32 s_size;
69090 +};
69091 +
69092 +/* End Data Structures Section */
69093 +
69094 +/* Hash functions generated by empirical testing by Brad Spengler
69095 + Makes good use of the low bits of the inode. Generally 0-1 times
69096 + in loop for successful match. 0-3 for unsuccessful match.
69097 + Shift/add algorithm with modulus of table size and an XOR*/
69098 +
69099 +static __inline__ unsigned int
69100 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
69101 +{
69102 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
69103 +}
69104 +
69105 + static __inline__ unsigned int
69106 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
69107 +{
69108 + return ((const unsigned long)userp % sz);
69109 +}
69110 +
69111 +static __inline__ unsigned int
69112 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69113 +{
69114 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69115 +}
69116 +
69117 +static __inline__ unsigned int
69118 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69119 +{
69120 + return full_name_hash((const unsigned char *)name, len) % sz;
69121 +}
69122 +
69123 +#define FOR_EACH_ROLE_START(role) \
69124 + role = role_list; \
69125 + while (role) {
69126 +
69127 +#define FOR_EACH_ROLE_END(role) \
69128 + role = role->prev; \
69129 + }
69130 +
69131 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69132 + subj = NULL; \
69133 + iter = 0; \
69134 + while (iter < role->subj_hash_size) { \
69135 + if (subj == NULL) \
69136 + subj = role->subj_hash[iter]; \
69137 + if (subj == NULL) { \
69138 + iter++; \
69139 + continue; \
69140 + }
69141 +
69142 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69143 + subj = subj->next; \
69144 + if (subj == NULL) \
69145 + iter++; \
69146 + }
69147 +
69148 +
69149 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69150 + subj = role->hash->first; \
69151 + while (subj != NULL) {
69152 +
69153 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69154 + subj = subj->next; \
69155 + }
69156 +
69157 +#endif
69158 +
69159 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69160 new file mode 100644
69161 index 0000000..323ecf2
69162 --- /dev/null
69163 +++ b/include/linux/gralloc.h
69164 @@ -0,0 +1,9 @@
69165 +#ifndef __GRALLOC_H
69166 +#define __GRALLOC_H
69167 +
69168 +void acl_free_all(void);
69169 +int acl_alloc_stack_init(unsigned long size);
69170 +void *acl_alloc(unsigned long len);
69171 +void *acl_alloc_num(unsigned long num, unsigned long len);
69172 +
69173 +#endif
69174 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69175 new file mode 100644
69176 index 0000000..be66033
69177 --- /dev/null
69178 +++ b/include/linux/grdefs.h
69179 @@ -0,0 +1,140 @@
69180 +#ifndef GRDEFS_H
69181 +#define GRDEFS_H
69182 +
69183 +/* Begin grsecurity status declarations */
69184 +
69185 +enum {
69186 + GR_READY = 0x01,
69187 + GR_STATUS_INIT = 0x00 // disabled state
69188 +};
69189 +
69190 +/* Begin ACL declarations */
69191 +
69192 +/* Role flags */
69193 +
69194 +enum {
69195 + GR_ROLE_USER = 0x0001,
69196 + GR_ROLE_GROUP = 0x0002,
69197 + GR_ROLE_DEFAULT = 0x0004,
69198 + GR_ROLE_SPECIAL = 0x0008,
69199 + GR_ROLE_AUTH = 0x0010,
69200 + GR_ROLE_NOPW = 0x0020,
69201 + GR_ROLE_GOD = 0x0040,
69202 + GR_ROLE_LEARN = 0x0080,
69203 + GR_ROLE_TPE = 0x0100,
69204 + GR_ROLE_DOMAIN = 0x0200,
69205 + GR_ROLE_PAM = 0x0400,
69206 + GR_ROLE_PERSIST = 0x0800
69207 +};
69208 +
69209 +/* ACL Subject and Object mode flags */
69210 +enum {
69211 + GR_DELETED = 0x80000000
69212 +};
69213 +
69214 +/* ACL Object-only mode flags */
69215 +enum {
69216 + GR_READ = 0x00000001,
69217 + GR_APPEND = 0x00000002,
69218 + GR_WRITE = 0x00000004,
69219 + GR_EXEC = 0x00000008,
69220 + GR_FIND = 0x00000010,
69221 + GR_INHERIT = 0x00000020,
69222 + GR_SETID = 0x00000040,
69223 + GR_CREATE = 0x00000080,
69224 + GR_DELETE = 0x00000100,
69225 + GR_LINK = 0x00000200,
69226 + GR_AUDIT_READ = 0x00000400,
69227 + GR_AUDIT_APPEND = 0x00000800,
69228 + GR_AUDIT_WRITE = 0x00001000,
69229 + GR_AUDIT_EXEC = 0x00002000,
69230 + GR_AUDIT_FIND = 0x00004000,
69231 + GR_AUDIT_INHERIT= 0x00008000,
69232 + GR_AUDIT_SETID = 0x00010000,
69233 + GR_AUDIT_CREATE = 0x00020000,
69234 + GR_AUDIT_DELETE = 0x00040000,
69235 + GR_AUDIT_LINK = 0x00080000,
69236 + GR_PTRACERD = 0x00100000,
69237 + GR_NOPTRACE = 0x00200000,
69238 + GR_SUPPRESS = 0x00400000,
69239 + GR_NOLEARN = 0x00800000,
69240 + GR_INIT_TRANSFER= 0x01000000
69241 +};
69242 +
69243 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69244 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69245 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69246 +
69247 +/* ACL subject-only mode flags */
69248 +enum {
69249 + GR_KILL = 0x00000001,
69250 + GR_VIEW = 0x00000002,
69251 + GR_PROTECTED = 0x00000004,
69252 + GR_LEARN = 0x00000008,
69253 + GR_OVERRIDE = 0x00000010,
69254 + /* just a placeholder, this mode is only used in userspace */
69255 + GR_DUMMY = 0x00000020,
69256 + GR_PROTSHM = 0x00000040,
69257 + GR_KILLPROC = 0x00000080,
69258 + GR_KILLIPPROC = 0x00000100,
69259 + /* just a placeholder, this mode is only used in userspace */
69260 + GR_NOTROJAN = 0x00000200,
69261 + GR_PROTPROCFD = 0x00000400,
69262 + GR_PROCACCT = 0x00000800,
69263 + GR_RELAXPTRACE = 0x00001000,
69264 + //GR_NESTED = 0x00002000,
69265 + GR_INHERITLEARN = 0x00004000,
69266 + GR_PROCFIND = 0x00008000,
69267 + GR_POVERRIDE = 0x00010000,
69268 + GR_KERNELAUTH = 0x00020000,
69269 + GR_ATSECURE = 0x00040000,
69270 + GR_SHMEXEC = 0x00080000
69271 +};
69272 +
69273 +enum {
69274 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69275 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69276 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69277 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69278 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69279 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69280 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69281 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69282 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69283 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69284 +};
69285 +
69286 +enum {
69287 + GR_ID_USER = 0x01,
69288 + GR_ID_GROUP = 0x02,
69289 +};
69290 +
69291 +enum {
69292 + GR_ID_ALLOW = 0x01,
69293 + GR_ID_DENY = 0x02,
69294 +};
69295 +
69296 +#define GR_CRASH_RES 31
69297 +#define GR_UIDTABLE_MAX 500
69298 +
69299 +/* begin resource learning section */
69300 +enum {
69301 + GR_RLIM_CPU_BUMP = 60,
69302 + GR_RLIM_FSIZE_BUMP = 50000,
69303 + GR_RLIM_DATA_BUMP = 10000,
69304 + GR_RLIM_STACK_BUMP = 1000,
69305 + GR_RLIM_CORE_BUMP = 10000,
69306 + GR_RLIM_RSS_BUMP = 500000,
69307 + GR_RLIM_NPROC_BUMP = 1,
69308 + GR_RLIM_NOFILE_BUMP = 5,
69309 + GR_RLIM_MEMLOCK_BUMP = 50000,
69310 + GR_RLIM_AS_BUMP = 500000,
69311 + GR_RLIM_LOCKS_BUMP = 2,
69312 + GR_RLIM_SIGPENDING_BUMP = 5,
69313 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69314 + GR_RLIM_NICE_BUMP = 1,
69315 + GR_RLIM_RTPRIO_BUMP = 1,
69316 + GR_RLIM_RTTIME_BUMP = 1000000
69317 +};
69318 +
69319 +#endif
69320 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69321 new file mode 100644
69322 index 0000000..12994b5
69323 --- /dev/null
69324 +++ b/include/linux/grinternal.h
69325 @@ -0,0 +1,227 @@
69326 +#ifndef __GRINTERNAL_H
69327 +#define __GRINTERNAL_H
69328 +
69329 +#ifdef CONFIG_GRKERNSEC
69330 +
69331 +#include <linux/fs.h>
69332 +#include <linux/mnt_namespace.h>
69333 +#include <linux/nsproxy.h>
69334 +#include <linux/gracl.h>
69335 +#include <linux/grdefs.h>
69336 +#include <linux/grmsg.h>
69337 +
69338 +void gr_add_learn_entry(const char *fmt, ...)
69339 + __attribute__ ((format (printf, 1, 2)));
69340 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69341 + const struct vfsmount *mnt);
69342 +__u32 gr_check_create(const struct dentry *new_dentry,
69343 + const struct dentry *parent,
69344 + const struct vfsmount *mnt, const __u32 mode);
69345 +int gr_check_protected_task(const struct task_struct *task);
69346 +__u32 to_gr_audit(const __u32 reqmode);
69347 +int gr_set_acls(const int type);
69348 +int gr_apply_subject_to_task(struct task_struct *task);
69349 +int gr_acl_is_enabled(void);
69350 +char gr_roletype_to_char(void);
69351 +
69352 +void gr_handle_alertkill(struct task_struct *task);
69353 +char *gr_to_filename(const struct dentry *dentry,
69354 + const struct vfsmount *mnt);
69355 +char *gr_to_filename1(const struct dentry *dentry,
69356 + const struct vfsmount *mnt);
69357 +char *gr_to_filename2(const struct dentry *dentry,
69358 + const struct vfsmount *mnt);
69359 +char *gr_to_filename3(const struct dentry *dentry,
69360 + const struct vfsmount *mnt);
69361 +
69362 +extern int grsec_enable_ptrace_readexec;
69363 +extern int grsec_enable_harden_ptrace;
69364 +extern int grsec_enable_link;
69365 +extern int grsec_enable_fifo;
69366 +extern int grsec_enable_execve;
69367 +extern int grsec_enable_shm;
69368 +extern int grsec_enable_execlog;
69369 +extern int grsec_enable_signal;
69370 +extern int grsec_enable_audit_ptrace;
69371 +extern int grsec_enable_forkfail;
69372 +extern int grsec_enable_time;
69373 +extern int grsec_enable_rofs;
69374 +extern int grsec_enable_chroot_shmat;
69375 +extern int grsec_enable_chroot_mount;
69376 +extern int grsec_enable_chroot_double;
69377 +extern int grsec_enable_chroot_pivot;
69378 +extern int grsec_enable_chroot_chdir;
69379 +extern int grsec_enable_chroot_chmod;
69380 +extern int grsec_enable_chroot_mknod;
69381 +extern int grsec_enable_chroot_fchdir;
69382 +extern int grsec_enable_chroot_nice;
69383 +extern int grsec_enable_chroot_execlog;
69384 +extern int grsec_enable_chroot_caps;
69385 +extern int grsec_enable_chroot_sysctl;
69386 +extern int grsec_enable_chroot_unix;
69387 +extern int grsec_enable_symlinkown;
69388 +extern kgid_t grsec_symlinkown_gid;
69389 +extern int grsec_enable_tpe;
69390 +extern kgid_t grsec_tpe_gid;
69391 +extern int grsec_enable_tpe_all;
69392 +extern int grsec_enable_tpe_invert;
69393 +extern int grsec_enable_socket_all;
69394 +extern kgid_t grsec_socket_all_gid;
69395 +extern int grsec_enable_socket_client;
69396 +extern kgid_t grsec_socket_client_gid;
69397 +extern int grsec_enable_socket_server;
69398 +extern kgid_t grsec_socket_server_gid;
69399 +extern kgid_t grsec_audit_gid;
69400 +extern int grsec_enable_group;
69401 +extern int grsec_enable_audit_textrel;
69402 +extern int grsec_enable_log_rwxmaps;
69403 +extern int grsec_enable_mount;
69404 +extern int grsec_enable_chdir;
69405 +extern int grsec_resource_logging;
69406 +extern int grsec_enable_blackhole;
69407 +extern int grsec_lastack_retries;
69408 +extern int grsec_enable_brute;
69409 +extern int grsec_lock;
69410 +
69411 +extern spinlock_t grsec_alert_lock;
69412 +extern unsigned long grsec_alert_wtime;
69413 +extern unsigned long grsec_alert_fyet;
69414 +
69415 +extern spinlock_t grsec_audit_lock;
69416 +
69417 +extern rwlock_t grsec_exec_file_lock;
69418 +
69419 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69420 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69421 + (tsk)->exec_file->f_path.mnt) : "/")
69422 +
69423 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69424 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69425 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69426 +
69427 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69428 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69429 + (tsk)->exec_file->f_path.mnt) : "/")
69430 +
69431 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69432 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69433 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69434 +
69435 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69436 +
69437 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69438 +
69439 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
69440 +{
69441 + if (file1 && file2) {
69442 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
69443 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
69444 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
69445 + return true;
69446 + }
69447 +
69448 + return false;
69449 +}
69450 +
69451 +#define GR_CHROOT_CAPS {{ \
69452 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69453 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69454 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69455 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69456 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69457 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69458 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69459 +
69460 +#define security_learn(normal_msg,args...) \
69461 +({ \
69462 + read_lock(&grsec_exec_file_lock); \
69463 + gr_add_learn_entry(normal_msg "\n", ## args); \
69464 + read_unlock(&grsec_exec_file_lock); \
69465 +})
69466 +
69467 +enum {
69468 + GR_DO_AUDIT,
69469 + GR_DONT_AUDIT,
69470 + /* used for non-audit messages that we shouldn't kill the task on */
69471 + GR_DONT_AUDIT_GOOD
69472 +};
69473 +
69474 +enum {
69475 + GR_TTYSNIFF,
69476 + GR_RBAC,
69477 + GR_RBAC_STR,
69478 + GR_STR_RBAC,
69479 + GR_RBAC_MODE2,
69480 + GR_RBAC_MODE3,
69481 + GR_FILENAME,
69482 + GR_SYSCTL_HIDDEN,
69483 + GR_NOARGS,
69484 + GR_ONE_INT,
69485 + GR_ONE_INT_TWO_STR,
69486 + GR_ONE_STR,
69487 + GR_STR_INT,
69488 + GR_TWO_STR_INT,
69489 + GR_TWO_INT,
69490 + GR_TWO_U64,
69491 + GR_THREE_INT,
69492 + GR_FIVE_INT_TWO_STR,
69493 + GR_TWO_STR,
69494 + GR_THREE_STR,
69495 + GR_FOUR_STR,
69496 + GR_STR_FILENAME,
69497 + GR_FILENAME_STR,
69498 + GR_FILENAME_TWO_INT,
69499 + GR_FILENAME_TWO_INT_STR,
69500 + GR_TEXTREL,
69501 + GR_PTRACE,
69502 + GR_RESOURCE,
69503 + GR_CAP,
69504 + GR_SIG,
69505 + GR_SIG2,
69506 + GR_CRASH1,
69507 + GR_CRASH2,
69508 + GR_PSACCT,
69509 + GR_RWXMAP
69510 +};
69511 +
69512 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69513 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69514 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69515 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69516 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69517 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69518 +#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)
69519 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69520 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69521 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69522 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69523 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69524 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69525 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69526 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69527 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69528 +#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)
69529 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69530 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69531 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69532 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69533 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69534 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69535 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69536 +#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)
69537 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69538 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69539 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69540 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69541 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69542 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69543 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69544 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69545 +#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)
69546 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69547 +
69548 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69549 +
69550 +#endif
69551 +
69552 +#endif
69553 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69554 new file mode 100644
69555 index 0000000..2f159b5
69556 --- /dev/null
69557 +++ b/include/linux/grmsg.h
69558 @@ -0,0 +1,112 @@
69559 +#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"
69560 +#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"
69561 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69562 +#define GR_STOPMOD_MSG "denied modification of module state by "
69563 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69564 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69565 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69566 +#define GR_IOPL_MSG "denied use of iopl() by "
69567 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69568 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69569 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69570 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69571 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69572 +#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"
69573 +#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"
69574 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69575 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69576 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69577 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69578 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69579 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69580 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69581 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69582 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69583 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69584 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69585 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69586 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69587 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69588 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69589 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69590 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69591 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69592 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69593 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69594 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69595 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69596 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69597 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69598 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69599 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69600 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69601 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69602 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69603 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69604 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69605 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69606 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69607 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69608 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69609 +#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"
69610 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69611 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69612 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69613 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69614 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69615 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69616 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69617 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69618 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69619 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69620 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69621 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69622 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69623 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69624 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69625 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69626 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69627 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69628 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69629 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69630 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69631 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69632 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69633 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69634 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69635 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69636 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69637 +#define GR_TIME_MSG "time set by "
69638 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69639 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69640 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69641 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69642 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69643 +#define GR_BIND_MSG "denied bind() by "
69644 +#define GR_CONNECT_MSG "denied connect() by "
69645 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69646 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69647 +#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"
69648 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69649 +#define GR_CAP_ACL_MSG "use of %s denied for "
69650 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69651 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69652 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69653 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69654 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69655 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69656 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69657 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69658 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69659 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69660 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69661 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69662 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69663 +#define GR_VM86_MSG "denied use of vm86 by "
69664 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69665 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69666 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69667 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69668 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69669 +#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 "
69670 +#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 "
69671 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69672 new file mode 100644
69673 index 0000000..d957f6d
69674 --- /dev/null
69675 +++ b/include/linux/grsecurity.h
69676 @@ -0,0 +1,241 @@
69677 +#ifndef GR_SECURITY_H
69678 +#define GR_SECURITY_H
69679 +#include <linux/fs.h>
69680 +#include <linux/fs_struct.h>
69681 +#include <linux/binfmts.h>
69682 +#include <linux/gracl.h>
69683 +
69684 +/* notify of brain-dead configs */
69685 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69686 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69687 +#endif
69688 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69689 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69690 +#endif
69691 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69692 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69693 +#endif
69694 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69695 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69696 +#endif
69697 +
69698 +void gr_handle_brute_attach(unsigned long mm_flags);
69699 +void gr_handle_brute_check(void);
69700 +void gr_handle_kernel_exploit(void);
69701 +
69702 +char gr_roletype_to_char(void);
69703 +
69704 +int gr_acl_enable_at_secure(void);
69705 +
69706 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69707 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69708 +
69709 +void gr_del_task_from_ip_table(struct task_struct *p);
69710 +
69711 +int gr_pid_is_chrooted(struct task_struct *p);
69712 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69713 +int gr_handle_chroot_nice(void);
69714 +int gr_handle_chroot_sysctl(const int op);
69715 +int gr_handle_chroot_setpriority(struct task_struct *p,
69716 + const int niceval);
69717 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69718 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69719 + const struct vfsmount *mnt);
69720 +void gr_handle_chroot_chdir(const struct path *path);
69721 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69722 + const struct vfsmount *mnt, const int mode);
69723 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69724 + const struct vfsmount *mnt, const int mode);
69725 +int gr_handle_chroot_mount(const struct dentry *dentry,
69726 + const struct vfsmount *mnt,
69727 + const char *dev_name);
69728 +int gr_handle_chroot_pivot(void);
69729 +int gr_handle_chroot_unix(const pid_t pid);
69730 +
69731 +int gr_handle_rawio(const struct inode *inode);
69732 +
69733 +void gr_handle_ioperm(void);
69734 +void gr_handle_iopl(void);
69735 +
69736 +umode_t gr_acl_umask(void);
69737 +
69738 +int gr_tpe_allow(const struct file *file);
69739 +
69740 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69741 +void gr_clear_chroot_entries(struct task_struct *task);
69742 +
69743 +void gr_log_forkfail(const int retval);
69744 +void gr_log_timechange(void);
69745 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69746 +void gr_log_chdir(const struct dentry *dentry,
69747 + const struct vfsmount *mnt);
69748 +void gr_log_chroot_exec(const struct dentry *dentry,
69749 + const struct vfsmount *mnt);
69750 +void gr_log_remount(const char *devname, const int retval);
69751 +void gr_log_unmount(const char *devname, const int retval);
69752 +void gr_log_mount(const char *from, const char *to, const int retval);
69753 +void gr_log_textrel(struct vm_area_struct *vma);
69754 +void gr_log_rwxmmap(struct file *file);
69755 +void gr_log_rwxmprotect(struct file *file);
69756 +
69757 +int gr_handle_follow_link(const struct inode *parent,
69758 + const struct inode *inode,
69759 + const struct dentry *dentry,
69760 + const struct vfsmount *mnt);
69761 +int gr_handle_fifo(const struct dentry *dentry,
69762 + const struct vfsmount *mnt,
69763 + const struct dentry *dir, const int flag,
69764 + const int acc_mode);
69765 +int gr_handle_hardlink(const struct dentry *dentry,
69766 + const struct vfsmount *mnt,
69767 + struct inode *inode,
69768 + const int mode, const struct filename *to);
69769 +
69770 +int gr_is_capable(const int cap);
69771 +int gr_is_capable_nolog(const int cap);
69772 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69773 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69774 +
69775 +void gr_copy_label(struct task_struct *tsk);
69776 +void gr_handle_crash(struct task_struct *task, const int sig);
69777 +int gr_handle_signal(const struct task_struct *p, const int sig);
69778 +int gr_check_crash_uid(const kuid_t uid);
69779 +int gr_check_protected_task(const struct task_struct *task);
69780 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69781 +int gr_acl_handle_mmap(const struct file *file,
69782 + const unsigned long prot);
69783 +int gr_acl_handle_mprotect(const struct file *file,
69784 + const unsigned long prot);
69785 +int gr_check_hidden_task(const struct task_struct *tsk);
69786 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69787 + const struct vfsmount *mnt);
69788 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69789 + const struct vfsmount *mnt);
69790 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69791 + const struct vfsmount *mnt, const int fmode);
69792 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69793 + const struct vfsmount *mnt, umode_t *mode);
69794 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69795 + const struct vfsmount *mnt);
69796 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69797 + const struct vfsmount *mnt);
69798 +int gr_handle_ptrace(struct task_struct *task, const long request);
69799 +int gr_handle_proc_ptrace(struct task_struct *task);
69800 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69801 + const struct vfsmount *mnt);
69802 +int gr_check_crash_exec(const struct file *filp);
69803 +int gr_acl_is_enabled(void);
69804 +void gr_set_kernel_label(struct task_struct *task);
69805 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69806 + const kgid_t gid);
69807 +int gr_set_proc_label(const struct dentry *dentry,
69808 + const struct vfsmount *mnt,
69809 + const int unsafe_flags);
69810 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69811 + const struct vfsmount *mnt);
69812 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69813 + const struct vfsmount *mnt, int acc_mode);
69814 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69815 + const struct dentry *p_dentry,
69816 + const struct vfsmount *p_mnt,
69817 + int open_flags, int acc_mode, const int imode);
69818 +void gr_handle_create(const struct dentry *dentry,
69819 + const struct vfsmount *mnt);
69820 +void gr_handle_proc_create(const struct dentry *dentry,
69821 + const struct inode *inode);
69822 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69823 + const struct dentry *parent_dentry,
69824 + const struct vfsmount *parent_mnt,
69825 + const int mode);
69826 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69827 + const struct dentry *parent_dentry,
69828 + const struct vfsmount *parent_mnt);
69829 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69830 + const struct vfsmount *mnt);
69831 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69832 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69833 + const struct vfsmount *mnt);
69834 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69835 + const struct dentry *parent_dentry,
69836 + const struct vfsmount *parent_mnt,
69837 + const struct filename *from);
69838 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69839 + const struct dentry *parent_dentry,
69840 + const struct vfsmount *parent_mnt,
69841 + const struct dentry *old_dentry,
69842 + const struct vfsmount *old_mnt, const struct filename *to);
69843 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69844 +int gr_acl_handle_rename(struct dentry *new_dentry,
69845 + struct dentry *parent_dentry,
69846 + const struct vfsmount *parent_mnt,
69847 + struct dentry *old_dentry,
69848 + struct inode *old_parent_inode,
69849 + struct vfsmount *old_mnt, const struct filename *newname);
69850 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69851 + struct dentry *old_dentry,
69852 + struct dentry *new_dentry,
69853 + struct vfsmount *mnt, const __u8 replace);
69854 +__u32 gr_check_link(const struct dentry *new_dentry,
69855 + const struct dentry *parent_dentry,
69856 + const struct vfsmount *parent_mnt,
69857 + const struct dentry *old_dentry,
69858 + const struct vfsmount *old_mnt);
69859 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69860 + const unsigned int namelen, const ino_t ino);
69861 +
69862 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69863 + const struct vfsmount *mnt);
69864 +void gr_acl_handle_exit(void);
69865 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69866 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69867 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69868 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69869 +void gr_audit_ptrace(struct task_struct *task);
69870 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69871 +void gr_put_exec_file(struct task_struct *task);
69872 +
69873 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69874 +
69875 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69876 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69877 + const unsigned long wanted, const int gt);
69878 +#else
69879 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69880 + const unsigned long wanted, const int gt)
69881 +{
69882 +}
69883 +#endif
69884 +
69885 +#ifdef CONFIG_GRKERNSEC_RESLOG
69886 +extern void gr_log_resource(const struct task_struct *task, const int res,
69887 + const unsigned long wanted, const int gt);
69888 +#else
69889 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69890 + const unsigned long wanted, const int gt)
69891 +{
69892 +}
69893 +#endif
69894 +
69895 +#ifdef CONFIG_GRKERNSEC
69896 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69897 +void gr_handle_vm86(void);
69898 +void gr_handle_mem_readwrite(u64 from, u64 to);
69899 +
69900 +void gr_log_badprocpid(const char *entry);
69901 +
69902 +extern int grsec_enable_dmesg;
69903 +extern int grsec_disable_privio;
69904 +
69905 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69906 +extern kgid_t grsec_proc_gid;
69907 +#endif
69908 +
69909 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69910 +extern int grsec_enable_chroot_findtask;
69911 +#endif
69912 +#ifdef CONFIG_GRKERNSEC_SETXID
69913 +extern int grsec_enable_setxid;
69914 +#endif
69915 +#endif
69916 +
69917 +#endif
69918 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69919 new file mode 100644
69920 index 0000000..e7ffaaf
69921 --- /dev/null
69922 +++ b/include/linux/grsock.h
69923 @@ -0,0 +1,19 @@
69924 +#ifndef __GRSOCK_H
69925 +#define __GRSOCK_H
69926 +
69927 +extern void gr_attach_curr_ip(const struct sock *sk);
69928 +extern int gr_handle_sock_all(const int family, const int type,
69929 + const int protocol);
69930 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69931 +extern int gr_handle_sock_server_other(const struct sock *sck);
69932 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69933 +extern int gr_search_connect(struct socket * sock,
69934 + struct sockaddr_in * addr);
69935 +extern int gr_search_bind(struct socket * sock,
69936 + struct sockaddr_in * addr);
69937 +extern int gr_search_listen(struct socket * sock);
69938 +extern int gr_search_accept(struct socket * sock);
69939 +extern int gr_search_socket(const int domain, const int type,
69940 + const int protocol);
69941 +
69942 +#endif
69943 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69944 index 7fb31da..08b5114 100644
69945 --- a/include/linux/highmem.h
69946 +++ b/include/linux/highmem.h
69947 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69948 kunmap_atomic(kaddr);
69949 }
69950
69951 +static inline void sanitize_highpage(struct page *page)
69952 +{
69953 + void *kaddr;
69954 + unsigned long flags;
69955 +
69956 + local_irq_save(flags);
69957 + kaddr = kmap_atomic(page);
69958 + clear_page(kaddr);
69959 + kunmap_atomic(kaddr);
69960 + local_irq_restore(flags);
69961 +}
69962 +
69963 static inline void zero_user_segments(struct page *page,
69964 unsigned start1, unsigned end1,
69965 unsigned start2, unsigned end2)
69966 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69967 index 1c7b89a..7f52502 100644
69968 --- a/include/linux/hwmon-sysfs.h
69969 +++ b/include/linux/hwmon-sysfs.h
69970 @@ -25,7 +25,8 @@
69971 struct sensor_device_attribute{
69972 struct device_attribute dev_attr;
69973 int index;
69974 -};
69975 +} __do_const;
69976 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69977 #define to_sensor_dev_attr(_dev_attr) \
69978 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69979
69980 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69981 struct device_attribute dev_attr;
69982 u8 index;
69983 u8 nr;
69984 -};
69985 +} __do_const;
69986 #define to_sensor_dev_attr_2(_dev_attr) \
69987 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69988
69989 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69990 index e988fa9..ff9f17e 100644
69991 --- a/include/linux/i2c.h
69992 +++ b/include/linux/i2c.h
69993 @@ -366,6 +366,7 @@ struct i2c_algorithm {
69994 /* To determine what the adapter supports */
69995 u32 (*functionality) (struct i2c_adapter *);
69996 };
69997 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69998
69999 /**
70000 * struct i2c_bus_recovery_info - I2C bus recovery information
70001 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
70002 index d23c3c2..eb63c81 100644
70003 --- a/include/linux/i2o.h
70004 +++ b/include/linux/i2o.h
70005 @@ -565,7 +565,7 @@ struct i2o_controller {
70006 struct i2o_device *exec; /* Executive */
70007 #if BITS_PER_LONG == 64
70008 spinlock_t context_list_lock; /* lock for context_list */
70009 - atomic_t context_list_counter; /* needed for unique contexts */
70010 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
70011 struct list_head context_list; /* list of context id's
70012 and pointers */
70013 #endif
70014 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
70015 index aff7ad8..3942bbd 100644
70016 --- a/include/linux/if_pppox.h
70017 +++ b/include/linux/if_pppox.h
70018 @@ -76,7 +76,7 @@ struct pppox_proto {
70019 int (*ioctl)(struct socket *sock, unsigned int cmd,
70020 unsigned long arg);
70021 struct module *owner;
70022 -};
70023 +} __do_const;
70024
70025 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
70026 extern void unregister_pppox_proto(int proto_num);
70027 diff --git a/include/linux/init.h b/include/linux/init.h
70028 index 8618147..0821126 100644
70029 --- a/include/linux/init.h
70030 +++ b/include/linux/init.h
70031 @@ -39,9 +39,36 @@
70032 * Also note, that this data cannot be "const".
70033 */
70034
70035 +#ifdef MODULE
70036 +#define add_init_latent_entropy
70037 +#define add_devinit_latent_entropy
70038 +#define add_cpuinit_latent_entropy
70039 +#define add_meminit_latent_entropy
70040 +#else
70041 +#define add_init_latent_entropy __latent_entropy
70042 +
70043 +#ifdef CONFIG_HOTPLUG
70044 +#define add_devinit_latent_entropy
70045 +#else
70046 +#define add_devinit_latent_entropy __latent_entropy
70047 +#endif
70048 +
70049 +#ifdef CONFIG_HOTPLUG_CPU
70050 +#define add_cpuinit_latent_entropy
70051 +#else
70052 +#define add_cpuinit_latent_entropy __latent_entropy
70053 +#endif
70054 +
70055 +#ifdef CONFIG_MEMORY_HOTPLUG
70056 +#define add_meminit_latent_entropy
70057 +#else
70058 +#define add_meminit_latent_entropy __latent_entropy
70059 +#endif
70060 +#endif
70061 +
70062 /* These are for everybody (although not all archs will actually
70063 discard it in modules) */
70064 -#define __init __section(.init.text) __cold notrace
70065 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
70066 #define __initdata __section(.init.data)
70067 #define __initconst __constsection(.init.rodata)
70068 #define __exitdata __section(.exit.data)
70069 @@ -94,7 +121,7 @@
70070 #define __exit __section(.exit.text) __exitused __cold notrace
70071
70072 /* Used for HOTPLUG_CPU */
70073 -#define __cpuinit __section(.cpuinit.text) __cold notrace
70074 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
70075 #define __cpuinitdata __section(.cpuinit.data)
70076 #define __cpuinitconst __constsection(.cpuinit.rodata)
70077 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
70078 @@ -102,7 +129,7 @@
70079 #define __cpuexitconst __constsection(.cpuexit.rodata)
70080
70081 /* Used for MEMORY_HOTPLUG */
70082 -#define __meminit __section(.meminit.text) __cold notrace
70083 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
70084 #define __meminitdata __section(.meminit.data)
70085 #define __meminitconst __constsection(.meminit.rodata)
70086 #define __memexit __section(.memexit.text) __exitused __cold notrace
70087 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
70088 index 5cd0f09..c9f67cc 100644
70089 --- a/include/linux/init_task.h
70090 +++ b/include/linux/init_task.h
70091 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
70092
70093 #define INIT_TASK_COMM "swapper"
70094
70095 +#ifdef CONFIG_X86
70096 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
70097 +#else
70098 +#define INIT_TASK_THREAD_INFO
70099 +#endif
70100 +
70101 /*
70102 * INIT_TASK is used to set up the first task table, touch at
70103 * your own risk!. Base=0, limit=0x1fffff (=2MB)
70104 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
70105 RCU_POINTER_INITIALIZER(cred, &init_cred), \
70106 .comm = INIT_TASK_COMM, \
70107 .thread = INIT_THREAD, \
70108 + INIT_TASK_THREAD_INFO \
70109 .fs = &init_fs, \
70110 .files = &init_files, \
70111 .signal = &init_signals, \
70112 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
70113 index 5fa5afe..ac55b25 100644
70114 --- a/include/linux/interrupt.h
70115 +++ b/include/linux/interrupt.h
70116 @@ -430,7 +430,7 @@ enum
70117 /* map softirq index to softirq name. update 'softirq_to_name' in
70118 * kernel/softirq.c when adding a new softirq.
70119 */
70120 -extern char *softirq_to_name[NR_SOFTIRQS];
70121 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70122
70123 /* softirq mask and active fields moved to irq_cpustat_t in
70124 * asm/hardirq.h to get better cache usage. KAO
70125 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70126
70127 struct softirq_action
70128 {
70129 - void (*action)(struct softirq_action *);
70130 -};
70131 + void (*action)(void);
70132 +} __no_const;
70133
70134 asmlinkage void do_softirq(void);
70135 asmlinkage void __do_softirq(void);
70136 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70137 +extern void open_softirq(int nr, void (*action)(void));
70138 extern void softirq_init(void);
70139 extern void __raise_softirq_irqoff(unsigned int nr);
70140
70141 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70142 index 3aeb730..2177f39 100644
70143 --- a/include/linux/iommu.h
70144 +++ b/include/linux/iommu.h
70145 @@ -113,7 +113,7 @@ struct iommu_ops {
70146 u32 (*domain_get_windows)(struct iommu_domain *domain);
70147
70148 unsigned long pgsize_bitmap;
70149 -};
70150 +} __do_const;
70151
70152 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70153 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70154 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70155 index 89b7c24..382af74 100644
70156 --- a/include/linux/ioport.h
70157 +++ b/include/linux/ioport.h
70158 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70159 int adjust_resource(struct resource *res, resource_size_t start,
70160 resource_size_t size);
70161 resource_size_t resource_alignment(struct resource *res);
70162 -static inline resource_size_t resource_size(const struct resource *res)
70163 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70164 {
70165 return res->end - res->start + 1;
70166 }
70167 diff --git a/include/linux/irq.h b/include/linux/irq.h
70168 index bc4e066..50468a9 100644
70169 --- a/include/linux/irq.h
70170 +++ b/include/linux/irq.h
70171 @@ -328,7 +328,8 @@ struct irq_chip {
70172 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70173
70174 unsigned long flags;
70175 -};
70176 +} __do_const;
70177 +typedef struct irq_chip __no_const irq_chip_no_const;
70178
70179 /*
70180 * irq_chip specific flags
70181 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
70182 index 3e203eb..3fe68d0 100644
70183 --- a/include/linux/irqchip/arm-gic.h
70184 +++ b/include/linux/irqchip/arm-gic.h
70185 @@ -59,9 +59,11 @@
70186
70187 #ifndef __ASSEMBLY__
70188
70189 +#include <linux/irq.h>
70190 +
70191 struct device_node;
70192
70193 -extern struct irq_chip gic_arch_extn;
70194 +extern irq_chip_no_const gic_arch_extn;
70195
70196 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
70197 u32 offset, struct device_node *);
70198 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70199 index 6883e19..06992b1 100644
70200 --- a/include/linux/kallsyms.h
70201 +++ b/include/linux/kallsyms.h
70202 @@ -15,7 +15,8 @@
70203
70204 struct module;
70205
70206 -#ifdef CONFIG_KALLSYMS
70207 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70208 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70209 /* Lookup the address for a symbol. Returns 0 if not found. */
70210 unsigned long kallsyms_lookup_name(const char *name);
70211
70212 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70213 /* Stupid that this does nothing, but I didn't create this mess. */
70214 #define __print_symbol(fmt, addr)
70215 #endif /*CONFIG_KALLSYMS*/
70216 +#else /* when included by kallsyms.c, vsnprintf.c, or
70217 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70218 +extern void __print_symbol(const char *fmt, unsigned long address);
70219 +extern int sprint_backtrace(char *buffer, unsigned long address);
70220 +extern int sprint_symbol(char *buffer, unsigned long address);
70221 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70222 +const char *kallsyms_lookup(unsigned long addr,
70223 + unsigned long *symbolsize,
70224 + unsigned long *offset,
70225 + char **modname, char *namebuf);
70226 +#endif
70227
70228 /* This macro allows us to keep printk typechecking */
70229 static __printf(1, 2)
70230 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70231 index 518a53a..5e28358 100644
70232 --- a/include/linux/key-type.h
70233 +++ b/include/linux/key-type.h
70234 @@ -125,7 +125,7 @@ struct key_type {
70235 /* internal fields */
70236 struct list_head link; /* link in types list */
70237 struct lock_class_key lock_class; /* key->sem lock class */
70238 -};
70239 +} __do_const;
70240
70241 extern struct key_type key_type_keyring;
70242
70243 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70244 index c6e091b..a940adf 100644
70245 --- a/include/linux/kgdb.h
70246 +++ b/include/linux/kgdb.h
70247 @@ -52,7 +52,7 @@ extern int kgdb_connected;
70248 extern int kgdb_io_module_registered;
70249
70250 extern atomic_t kgdb_setting_breakpoint;
70251 -extern atomic_t kgdb_cpu_doing_single_step;
70252 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70253
70254 extern struct task_struct *kgdb_usethread;
70255 extern struct task_struct *kgdb_contthread;
70256 @@ -254,7 +254,7 @@ struct kgdb_arch {
70257 void (*correct_hw_break)(void);
70258
70259 void (*enable_nmi)(bool on);
70260 -};
70261 +} __do_const;
70262
70263 /**
70264 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70265 @@ -279,7 +279,7 @@ struct kgdb_io {
70266 void (*pre_exception) (void);
70267 void (*post_exception) (void);
70268 int is_console;
70269 -};
70270 +} __do_const;
70271
70272 extern struct kgdb_arch arch_kgdb_ops;
70273
70274 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70275 index 0555cc6..b16a7a4 100644
70276 --- a/include/linux/kmod.h
70277 +++ b/include/linux/kmod.h
70278 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70279 * usually useless though. */
70280 extern __printf(2, 3)
70281 int __request_module(bool wait, const char *name, ...);
70282 +extern __printf(3, 4)
70283 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70284 #define request_module(mod...) __request_module(true, mod)
70285 #define request_module_nowait(mod...) __request_module(false, mod)
70286 #define try_then_request_module(x, mod...) \
70287 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70288 index 939b112..ed6ed51 100644
70289 --- a/include/linux/kobject.h
70290 +++ b/include/linux/kobject.h
70291 @@ -111,7 +111,7 @@ struct kobj_type {
70292 struct attribute **default_attrs;
70293 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70294 const void *(*namespace)(struct kobject *kobj);
70295 -};
70296 +} __do_const;
70297
70298 struct kobj_uevent_env {
70299 char *envp[UEVENT_NUM_ENVP];
70300 @@ -134,6 +134,7 @@ struct kobj_attribute {
70301 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70302 const char *buf, size_t count);
70303 };
70304 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70305
70306 extern const struct sysfs_ops kobj_sysfs_ops;
70307
70308 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70309 index f66b065..c2c29b4 100644
70310 --- a/include/linux/kobject_ns.h
70311 +++ b/include/linux/kobject_ns.h
70312 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70313 const void *(*netlink_ns)(struct sock *sk);
70314 const void *(*initial_ns)(void);
70315 void (*drop_ns)(void *);
70316 -};
70317 +} __do_const;
70318
70319 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70320 int kobj_ns_type_registered(enum kobj_ns_type type);
70321 diff --git a/include/linux/kref.h b/include/linux/kref.h
70322 index 484604d..0f6c5b6 100644
70323 --- a/include/linux/kref.h
70324 +++ b/include/linux/kref.h
70325 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
70326 static inline int kref_sub(struct kref *kref, unsigned int count,
70327 void (*release)(struct kref *kref))
70328 {
70329 - WARN_ON(release == NULL);
70330 + BUG_ON(release == NULL);
70331
70332 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70333 release(kref);
70334 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70335 index 8db53cf..c21121d 100644
70336 --- a/include/linux/kvm_host.h
70337 +++ b/include/linux/kvm_host.h
70338 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
70339 {
70340 }
70341 #endif
70342 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70343 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70344 struct module *module);
70345 void kvm_exit(void);
70346
70347 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70348 struct kvm_guest_debug *dbg);
70349 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70350
70351 -int kvm_arch_init(void *opaque);
70352 +int kvm_arch_init(const void *opaque);
70353 void kvm_arch_exit(void);
70354
70355 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70356 diff --git a/include/linux/libata.h b/include/linux/libata.h
70357 index eae7a05..2cdd875 100644
70358 --- a/include/linux/libata.h
70359 +++ b/include/linux/libata.h
70360 @@ -919,7 +919,7 @@ struct ata_port_operations {
70361 * fields must be pointers.
70362 */
70363 const struct ata_port_operations *inherits;
70364 -};
70365 +} __do_const;
70366
70367 struct ata_port_info {
70368 unsigned long flags;
70369 diff --git a/include/linux/list.h b/include/linux/list.h
70370 index b83e565..baa6c1d 100644
70371 --- a/include/linux/list.h
70372 +++ b/include/linux/list.h
70373 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70374 extern void list_del(struct list_head *entry);
70375 #endif
70376
70377 +extern void __pax_list_add(struct list_head *new,
70378 + struct list_head *prev,
70379 + struct list_head *next);
70380 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70381 +{
70382 + __pax_list_add(new, head, head->next);
70383 +}
70384 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70385 +{
70386 + __pax_list_add(new, head->prev, head);
70387 +}
70388 +extern void pax_list_del(struct list_head *entry);
70389 +
70390 /**
70391 * list_replace - replace old entry by new one
70392 * @old : the element to be replaced
70393 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70394 INIT_LIST_HEAD(entry);
70395 }
70396
70397 +extern void pax_list_del_init(struct list_head *entry);
70398 +
70399 /**
70400 * list_move - delete from one list and add as another's head
70401 * @list: the entry to move
70402 diff --git a/include/linux/math64.h b/include/linux/math64.h
70403 index 2913b86..4209244 100644
70404 --- a/include/linux/math64.h
70405 +++ b/include/linux/math64.h
70406 @@ -15,7 +15,7 @@
70407 * This is commonly provided by 32bit archs to provide an optimized 64bit
70408 * divide.
70409 */
70410 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70411 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70412 {
70413 *remainder = dividend % divisor;
70414 return dividend / divisor;
70415 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70416 #define div64_ul(x, y) div_u64((x), (y))
70417
70418 #ifndef div_u64_rem
70419 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70420 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70421 {
70422 *remainder = do_div(dividend, divisor);
70423 return dividend;
70424 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70425 * divide.
70426 */
70427 #ifndef div_u64
70428 -static inline u64 div_u64(u64 dividend, u32 divisor)
70429 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70430 {
70431 u32 remainder;
70432 return div_u64_rem(dividend, divisor, &remainder);
70433 diff --git a/include/linux/mm.h b/include/linux/mm.h
70434 index e0c8528..bcf0c29 100644
70435 --- a/include/linux/mm.h
70436 +++ b/include/linux/mm.h
70437 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
70438 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70439 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70440 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70441 +
70442 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70443 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70444 +#endif
70445 +
70446 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70447
70448 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70449 @@ -205,8 +210,8 @@ struct vm_operations_struct {
70450 /* called by access_process_vm when get_user_pages() fails, typically
70451 * for use by special VMAs that can switch between memory and hardware
70452 */
70453 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70454 - void *buf, int len, int write);
70455 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70456 + void *buf, size_t len, int write);
70457 #ifdef CONFIG_NUMA
70458 /*
70459 * set_policy() op must add a reference to any non-NULL @new mempolicy
70460 @@ -236,6 +241,7 @@ struct vm_operations_struct {
70461 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70462 unsigned long size, pgoff_t pgoff);
70463 };
70464 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70465
70466 struct mmu_gather;
70467 struct inode;
70468 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70469 unsigned long *pfn);
70470 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70471 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70472 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70473 - void *buf, int len, int write);
70474 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70475 + void *buf, size_t len, int write);
70476
70477 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70478 loff_t const holebegin, loff_t const holelen)
70479 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70480 }
70481 #endif
70482
70483 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70484 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70485 - void *buf, int len, int write);
70486 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70487 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70488 + void *buf, size_t len, int write);
70489
70490 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70491 unsigned long start, unsigned long nr_pages,
70492 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
70493 int set_page_dirty_lock(struct page *page);
70494 int clear_page_dirty_for_io(struct page *page);
70495
70496 -/* Is the vma a continuation of the stack vma above it? */
70497 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70498 -{
70499 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70500 -}
70501 -
70502 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70503 - unsigned long addr)
70504 -{
70505 - return (vma->vm_flags & VM_GROWSDOWN) &&
70506 - (vma->vm_start == addr) &&
70507 - !vma_growsdown(vma->vm_prev, addr);
70508 -}
70509 -
70510 -/* Is the vma a continuation of the stack vma below it? */
70511 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70512 -{
70513 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70514 -}
70515 -
70516 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70517 - unsigned long addr)
70518 -{
70519 - return (vma->vm_flags & VM_GROWSUP) &&
70520 - (vma->vm_end == addr) &&
70521 - !vma_growsup(vma->vm_next, addr);
70522 -}
70523 -
70524 extern pid_t
70525 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70526
70527 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70528 }
70529 #endif
70530
70531 +#ifdef CONFIG_MMU
70532 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70533 +#else
70534 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70535 +{
70536 + return __pgprot(0);
70537 +}
70538 +#endif
70539 +
70540 int vma_wants_writenotify(struct vm_area_struct *vma);
70541
70542 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70543 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70544 {
70545 return 0;
70546 }
70547 +
70548 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70549 + unsigned long address)
70550 +{
70551 + return 0;
70552 +}
70553 #else
70554 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70555 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70556 #endif
70557
70558 #ifdef __PAGETABLE_PMD_FOLDED
70559 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70560 {
70561 return 0;
70562 }
70563 +
70564 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70565 + unsigned long address)
70566 +{
70567 + return 0;
70568 +}
70569 #else
70570 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70571 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70572 #endif
70573
70574 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70575 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70576 NULL: pud_offset(pgd, address);
70577 }
70578
70579 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70580 +{
70581 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70582 + NULL: pud_offset(pgd, address);
70583 +}
70584 +
70585 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70586 {
70587 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70588 NULL: pmd_offset(pud, address);
70589 }
70590 +
70591 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70592 +{
70593 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70594 + NULL: pmd_offset(pud, address);
70595 +}
70596 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70597
70598 #if USE_SPLIT_PTLOCKS
70599 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70600 unsigned long len, unsigned long prot, unsigned long flags,
70601 unsigned long pgoff, unsigned long *populate);
70602 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70603 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70604
70605 #ifdef CONFIG_MMU
70606 extern int __mm_populate(unsigned long addr, unsigned long len,
70607 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
70608 unsigned long high_limit;
70609 unsigned long align_mask;
70610 unsigned long align_offset;
70611 + unsigned long threadstack_offset;
70612 };
70613
70614 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70615 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70616 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
70617 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
70618
70619 /*
70620 * Search for an unmapped address range.
70621 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70622 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
70623 */
70624 static inline unsigned long
70625 -vm_unmapped_area(struct vm_unmapped_area_info *info)
70626 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
70627 {
70628 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
70629 return unmapped_area(info);
70630 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70631 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70632 struct vm_area_struct **pprev);
70633
70634 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70635 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70636 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70637 +
70638 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70639 NULL if none. Assume start_addr < end_addr. */
70640 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70641 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70642 return vma;
70643 }
70644
70645 -#ifdef CONFIG_MMU
70646 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70647 -#else
70648 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70649 -{
70650 - return __pgprot(0);
70651 -}
70652 -#endif
70653 -
70654 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70655 unsigned long change_prot_numa(struct vm_area_struct *vma,
70656 unsigned long start, unsigned long end);
70657 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70658 static inline void vm_stat_account(struct mm_struct *mm,
70659 unsigned long flags, struct file *file, long pages)
70660 {
70661 +
70662 +#ifdef CONFIG_PAX_RANDMMAP
70663 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70664 +#endif
70665 +
70666 mm->total_vm += pages;
70667 }
70668 #endif /* CONFIG_PROC_FS */
70669 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
70670 extern int sysctl_memory_failure_early_kill;
70671 extern int sysctl_memory_failure_recovery;
70672 extern void shake_page(struct page *p, int access);
70673 -extern atomic_long_t num_poisoned_pages;
70674 +extern atomic_long_unchecked_t num_poisoned_pages;
70675 extern int soft_offline_page(struct page *page, int flags);
70676
70677 extern void dump_page(struct page *page);
70678 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
70679 static inline void setup_nr_node_ids(void) {}
70680 #endif
70681
70682 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70683 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70684 +#else
70685 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70686 +#endif
70687 +
70688 #endif /* __KERNEL__ */
70689 #endif /* _LINUX_MM_H */
70690 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70691 index ace9a5f..81bdb59 100644
70692 --- a/include/linux/mm_types.h
70693 +++ b/include/linux/mm_types.h
70694 @@ -289,6 +289,8 @@ struct vm_area_struct {
70695 #ifdef CONFIG_NUMA
70696 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70697 #endif
70698 +
70699 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70700 };
70701
70702 struct core_thread {
70703 @@ -437,6 +439,24 @@ struct mm_struct {
70704 int first_nid;
70705 #endif
70706 struct uprobes_state uprobes_state;
70707 +
70708 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70709 + unsigned long pax_flags;
70710 +#endif
70711 +
70712 +#ifdef CONFIG_PAX_DLRESOLVE
70713 + unsigned long call_dl_resolve;
70714 +#endif
70715 +
70716 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70717 + unsigned long call_syscall;
70718 +#endif
70719 +
70720 +#ifdef CONFIG_PAX_ASLR
70721 + unsigned long delta_mmap; /* randomized offset */
70722 + unsigned long delta_stack; /* randomized offset */
70723 +#endif
70724 +
70725 };
70726
70727 /* first nid will either be a valid NID or one of these values */
70728 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70729 index c5d5278..f0b68c8 100644
70730 --- a/include/linux/mmiotrace.h
70731 +++ b/include/linux/mmiotrace.h
70732 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70733 /* Called from ioremap.c */
70734 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70735 void __iomem *addr);
70736 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70737 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70738
70739 /* For anyone to insert markers. Remember trailing newline. */
70740 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70741 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70742 {
70743 }
70744
70745 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70746 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70747 {
70748 }
70749
70750 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70751 index 5c76737..61f518e 100644
70752 --- a/include/linux/mmzone.h
70753 +++ b/include/linux/mmzone.h
70754 @@ -396,7 +396,7 @@ struct zone {
70755 unsigned long flags; /* zone flags, see below */
70756
70757 /* Zone statistics */
70758 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70759 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70760
70761 /*
70762 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70763 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70764 index b508016..237cfe5 100644
70765 --- a/include/linux/mod_devicetable.h
70766 +++ b/include/linux/mod_devicetable.h
70767 @@ -13,7 +13,7 @@
70768 typedef unsigned long kernel_ulong_t;
70769 #endif
70770
70771 -#define PCI_ANY_ID (~0)
70772 +#define PCI_ANY_ID ((__u16)~0)
70773
70774 struct pci_device_id {
70775 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70776 @@ -139,7 +139,7 @@ struct usb_device_id {
70777 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70778 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70779
70780 -#define HID_ANY_ID (~0)
70781 +#define HID_ANY_ID (~0U)
70782 #define HID_BUS_ANY 0xffff
70783 #define HID_GROUP_ANY 0x0000
70784
70785 @@ -465,7 +465,7 @@ struct dmi_system_id {
70786 const char *ident;
70787 struct dmi_strmatch matches[4];
70788 void *driver_data;
70789 -};
70790 +} __do_const;
70791 /*
70792 * struct dmi_device_id appears during expansion of
70793 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70794 diff --git a/include/linux/module.h b/include/linux/module.h
70795 index 46f1ea0..a34ca37 100644
70796 --- a/include/linux/module.h
70797 +++ b/include/linux/module.h
70798 @@ -17,9 +17,11 @@
70799 #include <linux/moduleparam.h>
70800 #include <linux/tracepoint.h>
70801 #include <linux/export.h>
70802 +#include <linux/fs.h>
70803
70804 #include <linux/percpu.h>
70805 #include <asm/module.h>
70806 +#include <asm/pgtable.h>
70807
70808 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70809 #define MODULE_SIG_STRING "~Module signature appended~\n"
70810 @@ -54,12 +56,13 @@ struct module_attribute {
70811 int (*test)(struct module *);
70812 void (*free)(struct module *);
70813 };
70814 +typedef struct module_attribute __no_const module_attribute_no_const;
70815
70816 struct module_version_attribute {
70817 struct module_attribute mattr;
70818 const char *module_name;
70819 const char *version;
70820 -} __attribute__ ((__aligned__(sizeof(void *))));
70821 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70822
70823 extern ssize_t __modver_version_show(struct module_attribute *,
70824 struct module_kobject *, char *);
70825 @@ -232,7 +235,7 @@ struct module
70826
70827 /* Sysfs stuff. */
70828 struct module_kobject mkobj;
70829 - struct module_attribute *modinfo_attrs;
70830 + module_attribute_no_const *modinfo_attrs;
70831 const char *version;
70832 const char *srcversion;
70833 struct kobject *holders_dir;
70834 @@ -281,19 +284,16 @@ struct module
70835 int (*init)(void);
70836
70837 /* If this is non-NULL, vfree after init() returns */
70838 - void *module_init;
70839 + void *module_init_rx, *module_init_rw;
70840
70841 /* Here is the actual code + data, vfree'd on unload. */
70842 - void *module_core;
70843 + void *module_core_rx, *module_core_rw;
70844
70845 /* Here are the sizes of the init and core sections */
70846 - unsigned int init_size, core_size;
70847 + unsigned int init_size_rw, core_size_rw;
70848
70849 /* The size of the executable code in each section. */
70850 - unsigned int init_text_size, core_text_size;
70851 -
70852 - /* Size of RO sections of the module (text+rodata) */
70853 - unsigned int init_ro_size, core_ro_size;
70854 + unsigned int init_size_rx, core_size_rx;
70855
70856 /* Arch-specific module values */
70857 struct mod_arch_specific arch;
70858 @@ -349,6 +349,10 @@ struct module
70859 #ifdef CONFIG_EVENT_TRACING
70860 struct ftrace_event_call **trace_events;
70861 unsigned int num_trace_events;
70862 + struct file_operations trace_id;
70863 + struct file_operations trace_enable;
70864 + struct file_operations trace_format;
70865 + struct file_operations trace_filter;
70866 #endif
70867 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70868 unsigned int num_ftrace_callsites;
70869 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70870 bool is_module_percpu_address(unsigned long addr);
70871 bool is_module_text_address(unsigned long addr);
70872
70873 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70874 +{
70875 +
70876 +#ifdef CONFIG_PAX_KERNEXEC
70877 + if (ktla_ktva(addr) >= (unsigned long)start &&
70878 + ktla_ktva(addr) < (unsigned long)start + size)
70879 + return 1;
70880 +#endif
70881 +
70882 + return ((void *)addr >= start && (void *)addr < start + size);
70883 +}
70884 +
70885 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70886 +{
70887 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70888 +}
70889 +
70890 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70891 +{
70892 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70893 +}
70894 +
70895 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70896 +{
70897 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70898 +}
70899 +
70900 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70901 +{
70902 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70903 +}
70904 +
70905 static inline int within_module_core(unsigned long addr, const struct module *mod)
70906 {
70907 - return (unsigned long)mod->module_core <= addr &&
70908 - addr < (unsigned long)mod->module_core + mod->core_size;
70909 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70910 }
70911
70912 static inline int within_module_init(unsigned long addr, const struct module *mod)
70913 {
70914 - return (unsigned long)mod->module_init <= addr &&
70915 - addr < (unsigned long)mod->module_init + mod->init_size;
70916 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70917 }
70918
70919 /* Search for module by name: must hold module_mutex. */
70920 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70921 index 560ca53..ef621ef 100644
70922 --- a/include/linux/moduleloader.h
70923 +++ b/include/linux/moduleloader.h
70924 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70925 sections. Returns NULL on failure. */
70926 void *module_alloc(unsigned long size);
70927
70928 +#ifdef CONFIG_PAX_KERNEXEC
70929 +void *module_alloc_exec(unsigned long size);
70930 +#else
70931 +#define module_alloc_exec(x) module_alloc(x)
70932 +#endif
70933 +
70934 /* Free memory returned from module_alloc. */
70935 void module_free(struct module *mod, void *module_region);
70936
70937 +#ifdef CONFIG_PAX_KERNEXEC
70938 +void module_free_exec(struct module *mod, void *module_region);
70939 +#else
70940 +#define module_free_exec(x, y) module_free((x), (y))
70941 +#endif
70942 +
70943 /*
70944 * Apply the given relocation to the (simplified) ELF. Return -error
70945 * or 0.
70946 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70947 unsigned int relsec,
70948 struct module *me)
70949 {
70950 +#ifdef CONFIG_MODULES
70951 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70952 +#endif
70953 return -ENOEXEC;
70954 }
70955 #endif
70956 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70957 unsigned int relsec,
70958 struct module *me)
70959 {
70960 +#ifdef CONFIG_MODULES
70961 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70962 +#endif
70963 return -ENOEXEC;
70964 }
70965 #endif
70966 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70967 index 137b419..fe663ec 100644
70968 --- a/include/linux/moduleparam.h
70969 +++ b/include/linux/moduleparam.h
70970 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70971 * @len is usually just sizeof(string).
70972 */
70973 #define module_param_string(name, string, len, perm) \
70974 - static const struct kparam_string __param_string_##name \
70975 + static const struct kparam_string __param_string_##name __used \
70976 = { len, string }; \
70977 __module_param_call(MODULE_PARAM_PREFIX, name, \
70978 &param_ops_string, \
70979 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70980 */
70981 #define module_param_array_named(name, array, type, nump, perm) \
70982 param_check_##type(name, &(array)[0]); \
70983 - static const struct kparam_array __param_arr_##name \
70984 + static const struct kparam_array __param_arr_##name __used \
70985 = { .max = ARRAY_SIZE(array), .num = nump, \
70986 .ops = &param_ops_##type, \
70987 .elemsize = sizeof(array[0]), .elem = array }; \
70988 diff --git a/include/linux/namei.h b/include/linux/namei.h
70989 index 5a5ff57..5ae5070 100644
70990 --- a/include/linux/namei.h
70991 +++ b/include/linux/namei.h
70992 @@ -19,7 +19,7 @@ struct nameidata {
70993 unsigned seq;
70994 int last_type;
70995 unsigned depth;
70996 - char *saved_names[MAX_NESTED_LINKS + 1];
70997 + const char *saved_names[MAX_NESTED_LINKS + 1];
70998 };
70999
71000 /*
71001 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
71002
71003 extern void nd_jump_link(struct nameidata *nd, struct path *path);
71004
71005 -static inline void nd_set_link(struct nameidata *nd, char *path)
71006 +static inline void nd_set_link(struct nameidata *nd, const char *path)
71007 {
71008 nd->saved_names[nd->depth] = path;
71009 }
71010
71011 -static inline char *nd_get_link(struct nameidata *nd)
71012 +static inline const char *nd_get_link(const struct nameidata *nd)
71013 {
71014 return nd->saved_names[nd->depth];
71015 }
71016 diff --git a/include/linux/net.h b/include/linux/net.h
71017 index 99c9f0c..e1cf296 100644
71018 --- a/include/linux/net.h
71019 +++ b/include/linux/net.h
71020 @@ -183,7 +183,7 @@ struct net_proto_family {
71021 int (*create)(struct net *net, struct socket *sock,
71022 int protocol, int kern);
71023 struct module *owner;
71024 -};
71025 +} __do_const;
71026
71027 struct iovec;
71028 struct kvec;
71029 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
71030 index 96e4c21..9cc8278 100644
71031 --- a/include/linux/netdevice.h
71032 +++ b/include/linux/netdevice.h
71033 @@ -1026,6 +1026,7 @@ struct net_device_ops {
71034 int (*ndo_change_carrier)(struct net_device *dev,
71035 bool new_carrier);
71036 };
71037 +typedef struct net_device_ops __no_const net_device_ops_no_const;
71038
71039 /*
71040 * The DEVICE structure.
71041 @@ -1094,7 +1095,7 @@ struct net_device {
71042 int iflink;
71043
71044 struct net_device_stats stats;
71045 - atomic_long_t rx_dropped; /* dropped packets by core network
71046 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
71047 * Do not use this in drivers.
71048 */
71049
71050 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
71051 index 0060fde..481c6ae 100644
71052 --- a/include/linux/netfilter.h
71053 +++ b/include/linux/netfilter.h
71054 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
71055 #endif
71056 /* Use the module struct to lock set/get code in place */
71057 struct module *owner;
71058 -};
71059 +} __do_const;
71060
71061 /* Function to register/unregister hook points. */
71062 int nf_register_hook(struct nf_hook_ops *reg);
71063 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
71064 index d80e275..c3510b8 100644
71065 --- a/include/linux/netfilter/ipset/ip_set.h
71066 +++ b/include/linux/netfilter/ipset/ip_set.h
71067 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
71068 /* Return true if "b" set is the same as "a"
71069 * according to the create set parameters */
71070 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
71071 -};
71072 +} __do_const;
71073
71074 /* The core set type structure */
71075 struct ip_set_type {
71076 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
71077 index cadb740..d7c37c0 100644
71078 --- a/include/linux/netfilter/nfnetlink.h
71079 +++ b/include/linux/netfilter/nfnetlink.h
71080 @@ -16,7 +16,7 @@ struct nfnl_callback {
71081 const struct nlattr * const cda[]);
71082 const struct nla_policy *policy; /* netlink attribute policy */
71083 const u_int16_t attr_count; /* number of nlattr's */
71084 -};
71085 +} __do_const;
71086
71087 struct nfnetlink_subsystem {
71088 const char *name;
71089 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
71090 new file mode 100644
71091 index 0000000..33f4af8
71092 --- /dev/null
71093 +++ b/include/linux/netfilter/xt_gradm.h
71094 @@ -0,0 +1,9 @@
71095 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
71096 +#define _LINUX_NETFILTER_XT_GRADM_H 1
71097 +
71098 +struct xt_gradm_mtinfo {
71099 + __u16 flags;
71100 + __u16 invflags;
71101 +};
71102 +
71103 +#endif
71104 diff --git a/include/linux/nls.h b/include/linux/nls.h
71105 index 5dc635f..35f5e11 100644
71106 --- a/include/linux/nls.h
71107 +++ b/include/linux/nls.h
71108 @@ -31,7 +31,7 @@ struct nls_table {
71109 const unsigned char *charset2upper;
71110 struct module *owner;
71111 struct nls_table *next;
71112 -};
71113 +} __do_const;
71114
71115 /* this value hold the maximum octet of charset */
71116 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71117 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71118 index d14a4c3..a078786 100644
71119 --- a/include/linux/notifier.h
71120 +++ b/include/linux/notifier.h
71121 @@ -54,7 +54,8 @@ struct notifier_block {
71122 notifier_fn_t notifier_call;
71123 struct notifier_block __rcu *next;
71124 int priority;
71125 -};
71126 +} __do_const;
71127 +typedef struct notifier_block __no_const notifier_block_no_const;
71128
71129 struct atomic_notifier_head {
71130 spinlock_t lock;
71131 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71132 index a4c5624..79d6d88 100644
71133 --- a/include/linux/oprofile.h
71134 +++ b/include/linux/oprofile.h
71135 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71136 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71137 char const * name, ulong * val);
71138
71139 -/** Create a file for read-only access to an atomic_t. */
71140 +/** Create a file for read-only access to an atomic_unchecked_t. */
71141 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71142 - char const * name, atomic_t * val);
71143 + char const * name, atomic_unchecked_t * val);
71144
71145 /** create a directory */
71146 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71147 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71148 index 8db71dc..a76bf2c 100644
71149 --- a/include/linux/pci_hotplug.h
71150 +++ b/include/linux/pci_hotplug.h
71151 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71152 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71153 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71154 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71155 -};
71156 +} __do_const;
71157 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71158
71159 /**
71160 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71161 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71162 index c5b6dbf..b124155 100644
71163 --- a/include/linux/perf_event.h
71164 +++ b/include/linux/perf_event.h
71165 @@ -318,8 +318,8 @@ struct perf_event {
71166
71167 enum perf_event_active_state state;
71168 unsigned int attach_state;
71169 - local64_t count;
71170 - atomic64_t child_count;
71171 + local64_t count; /* PaX: fix it one day */
71172 + atomic64_unchecked_t child_count;
71173
71174 /*
71175 * These are the total time in nanoseconds that the event
71176 @@ -370,8 +370,8 @@ struct perf_event {
71177 * These accumulate total time (in nanoseconds) that children
71178 * events have been enabled and running, respectively.
71179 */
71180 - atomic64_t child_total_time_enabled;
71181 - atomic64_t child_total_time_running;
71182 + atomic64_unchecked_t child_total_time_enabled;
71183 + atomic64_unchecked_t child_total_time_running;
71184
71185 /*
71186 * Protect attach/detach and child_list:
71187 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
71188 entry->ip[entry->nr++] = ip;
71189 }
71190
71191 -extern int sysctl_perf_event_paranoid;
71192 +extern int sysctl_perf_event_legitimately_concerned;
71193 extern int sysctl_perf_event_mlock;
71194 extern int sysctl_perf_event_sample_rate;
71195
71196 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
71197 void __user *buffer, size_t *lenp,
71198 loff_t *ppos);
71199
71200 +static inline bool perf_paranoid_any(void)
71201 +{
71202 + return sysctl_perf_event_legitimately_concerned > 2;
71203 +}
71204 +
71205 static inline bool perf_paranoid_tracepoint_raw(void)
71206 {
71207 - return sysctl_perf_event_paranoid > -1;
71208 + return sysctl_perf_event_legitimately_concerned > -1;
71209 }
71210
71211 static inline bool perf_paranoid_cpu(void)
71212 {
71213 - return sysctl_perf_event_paranoid > 0;
71214 + return sysctl_perf_event_legitimately_concerned > 0;
71215 }
71216
71217 static inline bool perf_paranoid_kernel(void)
71218 {
71219 - return sysctl_perf_event_paranoid > 1;
71220 + return sysctl_perf_event_legitimately_concerned > 1;
71221 }
71222
71223 extern void perf_event_init(void);
71224 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
71225 */
71226 #define perf_cpu_notifier(fn) \
71227 do { \
71228 - static struct notifier_block fn##_nb __cpuinitdata = \
71229 + static struct notifier_block fn##_nb = \
71230 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71231 unsigned long cpu = smp_processor_id(); \
71232 unsigned long flags; \
71233 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
71234 struct device_attribute attr;
71235 u64 id;
71236 const char *event_str;
71237 -};
71238 +} __do_const;
71239
71240 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
71241 static struct perf_pmu_events_attr _var = { \
71242 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71243 index b8809fe..ae4ccd0 100644
71244 --- a/include/linux/pipe_fs_i.h
71245 +++ b/include/linux/pipe_fs_i.h
71246 @@ -47,10 +47,10 @@ struct pipe_inode_info {
71247 struct mutex mutex;
71248 wait_queue_head_t wait;
71249 unsigned int nrbufs, curbuf, buffers;
71250 - unsigned int readers;
71251 - unsigned int writers;
71252 - unsigned int files;
71253 - unsigned int waiting_writers;
71254 + atomic_t readers;
71255 + atomic_t writers;
71256 + atomic_t files;
71257 + atomic_t waiting_writers;
71258 unsigned int r_counter;
71259 unsigned int w_counter;
71260 struct page *tmp_page;
71261 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71262 index 5f28cae..3d23723 100644
71263 --- a/include/linux/platform_data/usb-ehci-s5p.h
71264 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71265 @@ -14,7 +14,7 @@
71266 struct s5p_ehci_platdata {
71267 int (*phy_init)(struct platform_device *pdev, int type);
71268 int (*phy_exit)(struct platform_device *pdev, int type);
71269 -};
71270 +} __no_const;
71271
71272 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71273
71274 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
71275 index c256c59..8ea94c7 100644
71276 --- a/include/linux/platform_data/usb-ohci-exynos.h
71277 +++ b/include/linux/platform_data/usb-ohci-exynos.h
71278 @@ -14,7 +14,7 @@
71279 struct exynos4_ohci_platdata {
71280 int (*phy_init)(struct platform_device *pdev, int type);
71281 int (*phy_exit)(struct platform_device *pdev, int type);
71282 -};
71283 +} __no_const;
71284
71285 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71286
71287 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71288 index 7c1d252..c5c773e 100644
71289 --- a/include/linux/pm_domain.h
71290 +++ b/include/linux/pm_domain.h
71291 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71292
71293 struct gpd_cpu_data {
71294 unsigned int saved_exit_latency;
71295 - struct cpuidle_state *idle_state;
71296 + cpuidle_state_no_const *idle_state;
71297 };
71298
71299 struct generic_pm_domain {
71300 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71301 index 7d7e09e..8671ef8 100644
71302 --- a/include/linux/pm_runtime.h
71303 +++ b/include/linux/pm_runtime.h
71304 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71305
71306 static inline void pm_runtime_mark_last_busy(struct device *dev)
71307 {
71308 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71309 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71310 }
71311
71312 #else /* !CONFIG_PM_RUNTIME */
71313 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71314 index 195aafc..49a7bc2 100644
71315 --- a/include/linux/pnp.h
71316 +++ b/include/linux/pnp.h
71317 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71318 struct pnp_fixup {
71319 char id[7];
71320 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71321 -};
71322 +} __do_const;
71323
71324 /* config parameters */
71325 #define PNP_CONFIG_NORMAL 0x0001
71326 diff --git a/include/linux/poison.h b/include/linux/poison.h
71327 index 2110a81..13a11bb 100644
71328 --- a/include/linux/poison.h
71329 +++ b/include/linux/poison.h
71330 @@ -19,8 +19,8 @@
71331 * under normal circumstances, used to verify that nobody uses
71332 * non-initialized list entries.
71333 */
71334 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71335 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71336 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71337 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71338
71339 /********** include/linux/timer.h **********/
71340 /*
71341 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71342 index c0f44c2..1572583 100644
71343 --- a/include/linux/power/smartreflex.h
71344 +++ b/include/linux/power/smartreflex.h
71345 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71346 int (*notify)(struct omap_sr *sr, u32 status);
71347 u8 notify_flags;
71348 u8 class_type;
71349 -};
71350 +} __do_const;
71351
71352 /**
71353 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71354 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71355 index 4ea1d37..80f4b33 100644
71356 --- a/include/linux/ppp-comp.h
71357 +++ b/include/linux/ppp-comp.h
71358 @@ -84,7 +84,7 @@ struct compressor {
71359 struct module *owner;
71360 /* Extra skb space needed by the compressor algorithm */
71361 unsigned int comp_extra;
71362 -};
71363 +} __do_const;
71364
71365 /*
71366 * The return value from decompress routine is the length of the
71367 diff --git a/include/linux/printk.h b/include/linux/printk.h
71368 index 22c7052..ad3fa0a 100644
71369 --- a/include/linux/printk.h
71370 +++ b/include/linux/printk.h
71371 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
71372 void early_printk(const char *s, ...) { }
71373 #endif
71374
71375 +extern int kptr_restrict;
71376 +
71377 #ifdef CONFIG_PRINTK
71378 asmlinkage __printf(5, 0)
71379 int vprintk_emit(int facility, int level,
71380 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71381
71382 extern int printk_delay_msec;
71383 extern int dmesg_restrict;
71384 -extern int kptr_restrict;
71385
71386 extern void wake_up_klogd(void);
71387
71388 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71389 index 608e60a..c26f864 100644
71390 --- a/include/linux/proc_fs.h
71391 +++ b/include/linux/proc_fs.h
71392 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
71393 return proc_create_data(name, mode, parent, proc_fops, NULL);
71394 }
71395
71396 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71397 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71398 +{
71399 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71400 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71401 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71402 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71403 +#else
71404 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71405 +#endif
71406 +}
71407 +
71408 +
71409 extern void proc_set_size(struct proc_dir_entry *, loff_t);
71410 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
71411 extern void *PDE_DATA(const struct inode *);
71412 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
71413 index 34a1e10..03a6d03 100644
71414 --- a/include/linux/proc_ns.h
71415 +++ b/include/linux/proc_ns.h
71416 @@ -14,7 +14,7 @@ struct proc_ns_operations {
71417 void (*put)(void *ns);
71418 int (*install)(struct nsproxy *nsproxy, void *ns);
71419 unsigned int (*inum)(void *ns);
71420 -};
71421 +} __do_const;
71422
71423 struct proc_ns {
71424 void *ns;
71425 diff --git a/include/linux/random.h b/include/linux/random.h
71426 index 3b9377d..61b506a 100644
71427 --- a/include/linux/random.h
71428 +++ b/include/linux/random.h
71429 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
71430 u32 prandom_u32_state(struct rnd_state *);
71431 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71432
71433 +static inline unsigned long pax_get_random_long(void)
71434 +{
71435 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71436 +}
71437 +
71438 /*
71439 * Handle minimum values for seeds
71440 */
71441 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71442 index f4b1001..8ddb2b6 100644
71443 --- a/include/linux/rculist.h
71444 +++ b/include/linux/rculist.h
71445 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71446 struct list_head *prev, struct list_head *next);
71447 #endif
71448
71449 +extern void __pax_list_add_rcu(struct list_head *new,
71450 + struct list_head *prev, struct list_head *next);
71451 +
71452 /**
71453 * list_add_rcu - add a new entry to rcu-protected list
71454 * @new: new entry to be added
71455 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71456 __list_add_rcu(new, head, head->next);
71457 }
71458
71459 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71460 +{
71461 + __pax_list_add_rcu(new, head, head->next);
71462 +}
71463 +
71464 /**
71465 * list_add_tail_rcu - add a new entry to rcu-protected list
71466 * @new: new entry to be added
71467 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71468 __list_add_rcu(new, head->prev, head);
71469 }
71470
71471 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71472 + struct list_head *head)
71473 +{
71474 + __pax_list_add_rcu(new, head->prev, head);
71475 +}
71476 +
71477 /**
71478 * list_del_rcu - deletes entry from list without re-initialization
71479 * @entry: the element to delete from the list.
71480 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71481 entry->prev = LIST_POISON2;
71482 }
71483
71484 +extern void pax_list_del_rcu(struct list_head *entry);
71485 +
71486 /**
71487 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71488 * @n: the element to delete from the hash list.
71489 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71490 index 23b3630..e1bc12b 100644
71491 --- a/include/linux/reboot.h
71492 +++ b/include/linux/reboot.h
71493 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71494 * Architecture-specific implementations of sys_reboot commands.
71495 */
71496
71497 -extern void machine_restart(char *cmd);
71498 -extern void machine_halt(void);
71499 -extern void machine_power_off(void);
71500 +extern void machine_restart(char *cmd) __noreturn;
71501 +extern void machine_halt(void) __noreturn;
71502 +extern void machine_power_off(void) __noreturn;
71503
71504 extern void machine_shutdown(void);
71505 struct pt_regs;
71506 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71507 */
71508
71509 extern void kernel_restart_prepare(char *cmd);
71510 -extern void kernel_restart(char *cmd);
71511 -extern void kernel_halt(void);
71512 -extern void kernel_power_off(void);
71513 +extern void kernel_restart(char *cmd) __noreturn;
71514 +extern void kernel_halt(void) __noreturn;
71515 +extern void kernel_power_off(void) __noreturn;
71516
71517 extern int C_A_D; /* for sysctl */
71518 void ctrl_alt_del(void);
71519 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71520 * Emergency restart, callable from an interrupt handler.
71521 */
71522
71523 -extern void emergency_restart(void);
71524 +extern void emergency_restart(void) __noreturn;
71525 #include <asm/emergency-restart.h>
71526
71527 #endif /* _LINUX_REBOOT_H */
71528 diff --git a/include/linux/regset.h b/include/linux/regset.h
71529 index 8e0c9fe..ac4d221 100644
71530 --- a/include/linux/regset.h
71531 +++ b/include/linux/regset.h
71532 @@ -161,7 +161,8 @@ struct user_regset {
71533 unsigned int align;
71534 unsigned int bias;
71535 unsigned int core_note_type;
71536 -};
71537 +} __do_const;
71538 +typedef struct user_regset __no_const user_regset_no_const;
71539
71540 /**
71541 * struct user_regset_view - available regsets
71542 diff --git a/include/linux/relay.h b/include/linux/relay.h
71543 index d7c8359..818daf5 100644
71544 --- a/include/linux/relay.h
71545 +++ b/include/linux/relay.h
71546 @@ -157,7 +157,7 @@ struct rchan_callbacks
71547 * The callback should return 0 if successful, negative if not.
71548 */
71549 int (*remove_buf_file)(struct dentry *dentry);
71550 -};
71551 +} __no_const;
71552
71553 /*
71554 * CONFIG_RELAY kernel API, kernel/relay.c
71555 diff --git a/include/linux/rio.h b/include/linux/rio.h
71556 index 18e0993..8ab5b21 100644
71557 --- a/include/linux/rio.h
71558 +++ b/include/linux/rio.h
71559 @@ -345,7 +345,7 @@ struct rio_ops {
71560 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71561 u64 rstart, u32 size, u32 flags);
71562 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71563 -};
71564 +} __no_const;
71565
71566 #define RIO_RESOURCE_MEM 0x00000100
71567 #define RIO_RESOURCE_DOORBELL 0x00000200
71568 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71569 index 6dacb93..6174423 100644
71570 --- a/include/linux/rmap.h
71571 +++ b/include/linux/rmap.h
71572 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71573 void anon_vma_init(void); /* create anon_vma_cachep */
71574 int anon_vma_prepare(struct vm_area_struct *);
71575 void unlink_anon_vmas(struct vm_area_struct *);
71576 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71577 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71578 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71579 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71580
71581 static inline void anon_vma_merge(struct vm_area_struct *vma,
71582 struct vm_area_struct *next)
71583 diff --git a/include/linux/sched.h b/include/linux/sched.h
71584 index 178a8d9..52e71a3 100644
71585 --- a/include/linux/sched.h
71586 +++ b/include/linux/sched.h
71587 @@ -62,6 +62,7 @@ struct bio_list;
71588 struct fs_struct;
71589 struct perf_event_context;
71590 struct blk_plug;
71591 +struct linux_binprm;
71592
71593 /*
71594 * List of flags we want to share for kernel threads,
71595 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
71596 extern int in_sched_functions(unsigned long addr);
71597
71598 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71599 -extern signed long schedule_timeout(signed long timeout);
71600 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71601 extern signed long schedule_timeout_interruptible(signed long timeout);
71602 extern signed long schedule_timeout_killable(signed long timeout);
71603 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71604 @@ -314,6 +315,19 @@ struct nsproxy;
71605 struct user_namespace;
71606
71607 #ifdef CONFIG_MMU
71608 +
71609 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71610 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71611 +#else
71612 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71613 +{
71614 + return 0;
71615 +}
71616 +#endif
71617 +
71618 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71619 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71620 +
71621 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71622 extern unsigned long
71623 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71624 @@ -591,6 +605,17 @@ struct signal_struct {
71625 #ifdef CONFIG_TASKSTATS
71626 struct taskstats *stats;
71627 #endif
71628 +
71629 +#ifdef CONFIG_GRKERNSEC
71630 + u32 curr_ip;
71631 + u32 saved_ip;
71632 + u32 gr_saddr;
71633 + u32 gr_daddr;
71634 + u16 gr_sport;
71635 + u16 gr_dport;
71636 + u8 used_accept:1;
71637 +#endif
71638 +
71639 #ifdef CONFIG_AUDIT
71640 unsigned audit_tty;
71641 unsigned audit_tty_log_passwd;
71642 @@ -671,6 +696,14 @@ struct user_struct {
71643 struct key *session_keyring; /* UID's default session keyring */
71644 #endif
71645
71646 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71647 + unsigned char kernel_banned;
71648 +#endif
71649 +#ifdef CONFIG_GRKERNSEC_BRUTE
71650 + unsigned char suid_banned;
71651 + unsigned long suid_ban_expires;
71652 +#endif
71653 +
71654 /* Hash table maintenance information */
71655 struct hlist_node uidhash_node;
71656 kuid_t uid;
71657 @@ -1158,8 +1191,8 @@ struct task_struct {
71658 struct list_head thread_group;
71659
71660 struct completion *vfork_done; /* for vfork() */
71661 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71662 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71663 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71664 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71665
71666 cputime_t utime, stime, utimescaled, stimescaled;
71667 cputime_t gtime;
71668 @@ -1184,11 +1217,6 @@ struct task_struct {
71669 struct task_cputime cputime_expires;
71670 struct list_head cpu_timers[3];
71671
71672 -/* process credentials */
71673 - const struct cred __rcu *real_cred; /* objective and real subjective task
71674 - * credentials (COW) */
71675 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71676 - * credentials (COW) */
71677 char comm[TASK_COMM_LEN]; /* executable name excluding path
71678 - access with [gs]et_task_comm (which lock
71679 it with task_lock())
71680 @@ -1205,6 +1233,10 @@ struct task_struct {
71681 #endif
71682 /* CPU-specific state of this task */
71683 struct thread_struct thread;
71684 +/* thread_info moved to task_struct */
71685 +#ifdef CONFIG_X86
71686 + struct thread_info tinfo;
71687 +#endif
71688 /* filesystem information */
71689 struct fs_struct *fs;
71690 /* open file information */
71691 @@ -1278,6 +1310,10 @@ struct task_struct {
71692 gfp_t lockdep_reclaim_gfp;
71693 #endif
71694
71695 +/* process credentials */
71696 + const struct cred __rcu *real_cred; /* objective and real subjective task
71697 + * credentials (COW) */
71698 +
71699 /* journalling filesystem info */
71700 void *journal_info;
71701
71702 @@ -1316,6 +1352,10 @@ struct task_struct {
71703 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71704 struct list_head cg_list;
71705 #endif
71706 +
71707 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71708 + * credentials (COW) */
71709 +
71710 #ifdef CONFIG_FUTEX
71711 struct robust_list_head __user *robust_list;
71712 #ifdef CONFIG_COMPAT
71713 @@ -1416,8 +1456,74 @@ struct task_struct {
71714 unsigned int sequential_io;
71715 unsigned int sequential_io_avg;
71716 #endif
71717 +
71718 +#ifdef CONFIG_GRKERNSEC
71719 + /* grsecurity */
71720 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71721 + u64 exec_id;
71722 +#endif
71723 +#ifdef CONFIG_GRKERNSEC_SETXID
71724 + const struct cred *delayed_cred;
71725 +#endif
71726 + struct dentry *gr_chroot_dentry;
71727 + struct acl_subject_label *acl;
71728 + struct acl_role_label *role;
71729 + struct file *exec_file;
71730 + unsigned long brute_expires;
71731 + u16 acl_role_id;
71732 + /* is this the task that authenticated to the special role */
71733 + u8 acl_sp_role;
71734 + u8 is_writable;
71735 + u8 brute;
71736 + u8 gr_is_chrooted;
71737 +#endif
71738 +
71739 };
71740
71741 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71742 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71743 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71744 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71745 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71746 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71747 +
71748 +#ifdef CONFIG_PAX_SOFTMODE
71749 +extern int pax_softmode;
71750 +#endif
71751 +
71752 +extern int pax_check_flags(unsigned long *);
71753 +
71754 +/* if tsk != current then task_lock must be held on it */
71755 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71756 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71757 +{
71758 + if (likely(tsk->mm))
71759 + return tsk->mm->pax_flags;
71760 + else
71761 + return 0UL;
71762 +}
71763 +
71764 +/* if tsk != current then task_lock must be held on it */
71765 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71766 +{
71767 + if (likely(tsk->mm)) {
71768 + tsk->mm->pax_flags = flags;
71769 + return 0;
71770 + }
71771 + return -EINVAL;
71772 +}
71773 +#endif
71774 +
71775 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71776 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71777 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71778 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71779 +#endif
71780 +
71781 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71782 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71783 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71784 +
71785 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71786 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71787
71788 @@ -1476,7 +1582,7 @@ struct pid_namespace;
71789 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71790 struct pid_namespace *ns);
71791
71792 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71793 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71794 {
71795 return tsk->pid;
71796 }
71797 @@ -1919,7 +2025,9 @@ void yield(void);
71798 extern struct exec_domain default_exec_domain;
71799
71800 union thread_union {
71801 +#ifndef CONFIG_X86
71802 struct thread_info thread_info;
71803 +#endif
71804 unsigned long stack[THREAD_SIZE/sizeof(long)];
71805 };
71806
71807 @@ -1952,6 +2060,7 @@ extern struct pid_namespace init_pid_ns;
71808 */
71809
71810 extern struct task_struct *find_task_by_vpid(pid_t nr);
71811 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71812 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71813 struct pid_namespace *ns);
71814
71815 @@ -2118,7 +2227,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71816 extern void exit_itimers(struct signal_struct *);
71817 extern void flush_itimer_signals(void);
71818
71819 -extern void do_group_exit(int);
71820 +extern __noreturn void do_group_exit(int);
71821
71822 extern int allow_signal(int);
71823 extern int disallow_signal(int);
71824 @@ -2309,9 +2418,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71825
71826 #endif
71827
71828 -static inline int object_is_on_stack(void *obj)
71829 +static inline int object_starts_on_stack(void *obj)
71830 {
71831 - void *stack = task_stack_page(current);
71832 + const void *stack = task_stack_page(current);
71833
71834 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71835 }
71836 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71837 index bf8086b..962b035 100644
71838 --- a/include/linux/sched/sysctl.h
71839 +++ b/include/linux/sched/sysctl.h
71840 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71841 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71842
71843 extern int sysctl_max_map_count;
71844 +extern unsigned long sysctl_heap_stack_gap;
71845
71846 extern unsigned int sysctl_sched_latency;
71847 extern unsigned int sysctl_sched_min_granularity;
71848 diff --git a/include/linux/security.h b/include/linux/security.h
71849 index 4686491..2bd210e 100644
71850 --- a/include/linux/security.h
71851 +++ b/include/linux/security.h
71852 @@ -26,6 +26,7 @@
71853 #include <linux/capability.h>
71854 #include <linux/slab.h>
71855 #include <linux/err.h>
71856 +#include <linux/grsecurity.h>
71857
71858 struct linux_binprm;
71859 struct cred;
71860 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71861 index 2da29ac..aac448ec 100644
71862 --- a/include/linux/seq_file.h
71863 +++ b/include/linux/seq_file.h
71864 @@ -26,6 +26,9 @@ struct seq_file {
71865 struct mutex lock;
71866 const struct seq_operations *op;
71867 int poll_event;
71868 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71869 + u64 exec_id;
71870 +#endif
71871 #ifdef CONFIG_USER_NS
71872 struct user_namespace *user_ns;
71873 #endif
71874 @@ -38,6 +41,7 @@ struct seq_operations {
71875 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71876 int (*show) (struct seq_file *m, void *v);
71877 };
71878 +typedef struct seq_operations __no_const seq_operations_no_const;
71879
71880 #define SEQ_SKIP 1
71881
71882 diff --git a/include/linux/shm.h b/include/linux/shm.h
71883 index 429c199..4d42e38 100644
71884 --- a/include/linux/shm.h
71885 +++ b/include/linux/shm.h
71886 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71887
71888 /* The task created the shm object. NULL if the task is dead. */
71889 struct task_struct *shm_creator;
71890 +#ifdef CONFIG_GRKERNSEC
71891 + time_t shm_createtime;
71892 + pid_t shm_lapid;
71893 +#endif
71894 };
71895
71896 /* shm_mode upper byte flags */
71897 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71898 index dec1748..112c1f9 100644
71899 --- a/include/linux/skbuff.h
71900 +++ b/include/linux/skbuff.h
71901 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71902 extern struct sk_buff *__alloc_skb(unsigned int size,
71903 gfp_t priority, int flags, int node);
71904 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71905 -static inline struct sk_buff *alloc_skb(unsigned int size,
71906 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71907 gfp_t priority)
71908 {
71909 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71910 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71911 */
71912 static inline int skb_queue_empty(const struct sk_buff_head *list)
71913 {
71914 - return list->next == (struct sk_buff *)list;
71915 + return list->next == (const struct sk_buff *)list;
71916 }
71917
71918 /**
71919 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71920 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71921 const struct sk_buff *skb)
71922 {
71923 - return skb->next == (struct sk_buff *)list;
71924 + return skb->next == (const struct sk_buff *)list;
71925 }
71926
71927 /**
71928 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71929 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71930 const struct sk_buff *skb)
71931 {
71932 - return skb->prev == (struct sk_buff *)list;
71933 + return skb->prev == (const struct sk_buff *)list;
71934 }
71935
71936 /**
71937 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71938 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71939 */
71940 #ifndef NET_SKB_PAD
71941 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71942 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71943 #endif
71944
71945 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71946 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71947 int noblock, int *err);
71948 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71949 struct poll_table_struct *wait);
71950 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71951 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71952 int offset, struct iovec *to,
71953 int size);
71954 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71955 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
71956 nf_bridge_put(skb->nf_bridge);
71957 skb->nf_bridge = NULL;
71958 #endif
71959 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71960 + skb->nf_trace = 0;
71961 +#endif
71962 }
71963
71964 static inline void nf_reset_trace(struct sk_buff *skb)
71965 diff --git a/include/linux/slab.h b/include/linux/slab.h
71966 index 0c62175..9ece3d8 100644
71967 --- a/include/linux/slab.h
71968 +++ b/include/linux/slab.h
71969 @@ -12,13 +12,20 @@
71970 #include <linux/gfp.h>
71971 #include <linux/types.h>
71972 #include <linux/workqueue.h>
71973 -
71974 +#include <linux/err.h>
71975
71976 /*
71977 * Flags to pass to kmem_cache_create().
71978 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71979 */
71980 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71981 +
71982 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71983 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71984 +#else
71985 +#define SLAB_USERCOPY 0x00000000UL
71986 +#endif
71987 +
71988 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71989 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71990 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71991 @@ -89,10 +96,13 @@
71992 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71993 * Both make kfree a no-op.
71994 */
71995 -#define ZERO_SIZE_PTR ((void *)16)
71996 +#define ZERO_SIZE_PTR \
71997 +({ \
71998 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71999 + (void *)(-MAX_ERRNO-1L); \
72000 +})
72001
72002 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
72003 - (unsigned long)ZERO_SIZE_PTR)
72004 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
72005
72006
72007 struct mem_cgroup;
72008 @@ -132,6 +142,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
72009 void kfree(const void *);
72010 void kzfree(const void *);
72011 size_t ksize(const void *);
72012 +const char *check_heap_object(const void *ptr, unsigned long n);
72013 +bool is_usercopy_object(const void *ptr);
72014
72015 /*
72016 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
72017 @@ -164,7 +176,7 @@ struct kmem_cache {
72018 unsigned int align; /* Alignment as calculated */
72019 unsigned long flags; /* Active flags on the slab */
72020 const char *name; /* Slab name for sysfs */
72021 - int refcount; /* Use counter */
72022 + atomic_t refcount; /* Use counter */
72023 void (*ctor)(void *); /* Called on object slot creation */
72024 struct list_head list; /* List of all slab caches on the system */
72025 };
72026 @@ -226,6 +238,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
72027 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72028 #endif
72029
72030 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72031 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
72032 +#endif
72033 +
72034 /*
72035 * Figure out which kmalloc slab an allocation of a certain size
72036 * belongs to.
72037 @@ -234,7 +250,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72038 * 2 = 120 .. 192 bytes
72039 * n = 2^(n-1) .. 2^n -1
72040 */
72041 -static __always_inline int kmalloc_index(size_t size)
72042 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
72043 {
72044 if (!size)
72045 return 0;
72046 @@ -406,6 +422,7 @@ void print_slabinfo_header(struct seq_file *m);
72047 * for general use, and so are not documented here. For a full list of
72048 * potential flags, always refer to linux/gfp.h.
72049 */
72050 +
72051 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
72052 {
72053 if (size != 0 && n > SIZE_MAX / size)
72054 @@ -465,7 +482,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
72055 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72056 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72057 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72058 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72059 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
72060 #define kmalloc_track_caller(size, flags) \
72061 __kmalloc_track_caller(size, flags, _RET_IP_)
72062 #else
72063 @@ -485,7 +502,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72064 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72065 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72066 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72067 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
72068 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
72069 #define kmalloc_node_track_caller(size, flags, node) \
72070 __kmalloc_node_track_caller(size, flags, node, \
72071 _RET_IP_)
72072 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
72073 index cd40158..d9dc02c 100644
72074 --- a/include/linux/slab_def.h
72075 +++ b/include/linux/slab_def.h
72076 @@ -50,7 +50,7 @@ struct kmem_cache {
72077 /* 4) cache creation/removal */
72078 const char *name;
72079 struct list_head list;
72080 - int refcount;
72081 + atomic_t refcount;
72082 int object_size;
72083 int align;
72084
72085 @@ -66,10 +66,10 @@ struct kmem_cache {
72086 unsigned long node_allocs;
72087 unsigned long node_frees;
72088 unsigned long node_overflow;
72089 - atomic_t allochit;
72090 - atomic_t allocmiss;
72091 - atomic_t freehit;
72092 - atomic_t freemiss;
72093 + atomic_unchecked_t allochit;
72094 + atomic_unchecked_t allocmiss;
72095 + atomic_unchecked_t freehit;
72096 + atomic_unchecked_t freemiss;
72097
72098 /*
72099 * If debugging is enabled, then the allocator can add additional
72100 @@ -103,7 +103,7 @@ struct kmem_cache {
72101 };
72102
72103 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72104 -void *__kmalloc(size_t size, gfp_t flags);
72105 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
72106
72107 #ifdef CONFIG_TRACING
72108 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
72109 @@ -136,6 +136,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72110 cachep = kmalloc_dma_caches[i];
72111 else
72112 #endif
72113 +
72114 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72115 + if (flags & GFP_USERCOPY)
72116 + cachep = kmalloc_usercopy_caches[i];
72117 + else
72118 +#endif
72119 +
72120 cachep = kmalloc_caches[i];
72121
72122 ret = kmem_cache_alloc_trace(cachep, flags, size);
72123 @@ -146,7 +153,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72124 }
72125
72126 #ifdef CONFIG_NUMA
72127 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72128 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72129 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72130
72131 #ifdef CONFIG_TRACING
72132 @@ -185,6 +192,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72133 cachep = kmalloc_dma_caches[i];
72134 else
72135 #endif
72136 +
72137 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72138 + if (flags & GFP_USERCOPY)
72139 + cachep = kmalloc_usercopy_caches[i];
72140 + else
72141 +#endif
72142 +
72143 cachep = kmalloc_caches[i];
72144
72145 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72146 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72147 index f28e14a..7831211 100644
72148 --- a/include/linux/slob_def.h
72149 +++ b/include/linux/slob_def.h
72150 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72151 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72152 }
72153
72154 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72155 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72156
72157 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72158 {
72159 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72160 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72161 }
72162
72163 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72164 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72165 {
72166 return kmalloc(size, flags);
72167 }
72168 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72169 index 027276f..092bfe8 100644
72170 --- a/include/linux/slub_def.h
72171 +++ b/include/linux/slub_def.h
72172 @@ -80,7 +80,7 @@ struct kmem_cache {
72173 struct kmem_cache_order_objects max;
72174 struct kmem_cache_order_objects min;
72175 gfp_t allocflags; /* gfp flags to use on each alloc */
72176 - int refcount; /* Refcount for slab cache destroy */
72177 + atomic_t refcount; /* Refcount for slab cache destroy */
72178 void (*ctor)(void *);
72179 int inuse; /* Offset to metadata */
72180 int align; /* Alignment */
72181 @@ -105,7 +105,7 @@ struct kmem_cache {
72182 };
72183
72184 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72185 -void *__kmalloc(size_t size, gfp_t flags);
72186 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72187
72188 static __always_inline void *
72189 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72190 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72191 }
72192 #endif
72193
72194 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72195 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72196 {
72197 unsigned int order = get_order(size);
72198 return kmalloc_order_trace(size, flags, order);
72199 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72200 }
72201
72202 #ifdef CONFIG_NUMA
72203 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72204 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72205 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72206
72207 #ifdef CONFIG_TRACING
72208 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72209 index 54f91d3..be2c379 100644
72210 --- a/include/linux/sock_diag.h
72211 +++ b/include/linux/sock_diag.h
72212 @@ -11,7 +11,7 @@ struct sock;
72213 struct sock_diag_handler {
72214 __u8 family;
72215 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72216 -};
72217 +} __do_const;
72218
72219 int sock_diag_register(const struct sock_diag_handler *h);
72220 void sock_diag_unregister(const struct sock_diag_handler *h);
72221 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72222 index 680f9a3..f13aeb0 100644
72223 --- a/include/linux/sonet.h
72224 +++ b/include/linux/sonet.h
72225 @@ -7,7 +7,7 @@
72226 #include <uapi/linux/sonet.h>
72227
72228 struct k_sonet_stats {
72229 -#define __HANDLE_ITEM(i) atomic_t i
72230 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72231 __SONET_ITEMS
72232 #undef __HANDLE_ITEM
72233 };
72234 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
72235 index 07d8e53..dc934c9 100644
72236 --- a/include/linux/sunrpc/addr.h
72237 +++ b/include/linux/sunrpc/addr.h
72238 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72239 {
72240 switch (sap->sa_family) {
72241 case AF_INET:
72242 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72243 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72244 case AF_INET6:
72245 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72246 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72247 }
72248 return 0;
72249 }
72250 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72251 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72252 const struct sockaddr *src)
72253 {
72254 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72255 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72256 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72257
72258 dsin->sin_family = ssin->sin_family;
72259 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72260 if (sa->sa_family != AF_INET6)
72261 return 0;
72262
72263 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72264 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72265 }
72266
72267 #endif /* _LINUX_SUNRPC_ADDR_H */
72268 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72269 index bfe11be..12bc8c4 100644
72270 --- a/include/linux/sunrpc/clnt.h
72271 +++ b/include/linux/sunrpc/clnt.h
72272 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72273 unsigned int p_timer; /* Which RTT timer to use */
72274 u32 p_statidx; /* Which procedure to account */
72275 const char * p_name; /* name of procedure */
72276 -};
72277 +} __do_const;
72278
72279 #ifdef __KERNEL__
72280
72281 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72282 index 1f0216b..6a4fa50 100644
72283 --- a/include/linux/sunrpc/svc.h
72284 +++ b/include/linux/sunrpc/svc.h
72285 @@ -411,7 +411,7 @@ struct svc_procedure {
72286 unsigned int pc_count; /* call count */
72287 unsigned int pc_cachetype; /* cache info (NFS) */
72288 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72289 -};
72290 +} __do_const;
72291
72292 /*
72293 * Function prototypes.
72294 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72295 index 0b8e3e6..33e0a01 100644
72296 --- a/include/linux/sunrpc/svc_rdma.h
72297 +++ b/include/linux/sunrpc/svc_rdma.h
72298 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72299 extern unsigned int svcrdma_max_requests;
72300 extern unsigned int svcrdma_max_req_size;
72301
72302 -extern atomic_t rdma_stat_recv;
72303 -extern atomic_t rdma_stat_read;
72304 -extern atomic_t rdma_stat_write;
72305 -extern atomic_t rdma_stat_sq_starve;
72306 -extern atomic_t rdma_stat_rq_starve;
72307 -extern atomic_t rdma_stat_rq_poll;
72308 -extern atomic_t rdma_stat_rq_prod;
72309 -extern atomic_t rdma_stat_sq_poll;
72310 -extern atomic_t rdma_stat_sq_prod;
72311 +extern atomic_unchecked_t rdma_stat_recv;
72312 +extern atomic_unchecked_t rdma_stat_read;
72313 +extern atomic_unchecked_t rdma_stat_write;
72314 +extern atomic_unchecked_t rdma_stat_sq_starve;
72315 +extern atomic_unchecked_t rdma_stat_rq_starve;
72316 +extern atomic_unchecked_t rdma_stat_rq_poll;
72317 +extern atomic_unchecked_t rdma_stat_rq_prod;
72318 +extern atomic_unchecked_t rdma_stat_sq_poll;
72319 +extern atomic_unchecked_t rdma_stat_sq_prod;
72320
72321 #define RPCRDMA_VERSION 1
72322
72323 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72324 index ff374ab..7fd2ecb 100644
72325 --- a/include/linux/sunrpc/svcauth.h
72326 +++ b/include/linux/sunrpc/svcauth.h
72327 @@ -109,7 +109,7 @@ struct auth_ops {
72328 int (*release)(struct svc_rqst *rq);
72329 void (*domain_release)(struct auth_domain *);
72330 int (*set_client)(struct svc_rqst *rq);
72331 -};
72332 +} __do_const;
72333
72334 #define SVC_GARBAGE 1
72335 #define SVC_SYSERR 2
72336 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72337 index a5ffd32..0935dea 100644
72338 --- a/include/linux/swiotlb.h
72339 +++ b/include/linux/swiotlb.h
72340 @@ -60,7 +60,8 @@ extern void
72341
72342 extern void
72343 swiotlb_free_coherent(struct device *hwdev, size_t size,
72344 - void *vaddr, dma_addr_t dma_handle);
72345 + void *vaddr, dma_addr_t dma_handle,
72346 + struct dma_attrs *attrs);
72347
72348 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72349 unsigned long offset, size_t size,
72350 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72351 index 4147d70..31a1791 100644
72352 --- a/include/linux/syscalls.h
72353 +++ b/include/linux/syscalls.h
72354 @@ -362,11 +362,11 @@ asmlinkage long sys_sync(void);
72355 asmlinkage long sys_fsync(unsigned int fd);
72356 asmlinkage long sys_fdatasync(unsigned int fd);
72357 asmlinkage long sys_bdflush(int func, long data);
72358 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
72359 - char __user *type, unsigned long flags,
72360 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
72361 + const char __user *type, unsigned long flags,
72362 void __user *data);
72363 -asmlinkage long sys_umount(char __user *name, int flags);
72364 -asmlinkage long sys_oldumount(char __user *name);
72365 +asmlinkage long sys_umount(const char __user *name, int flags);
72366 +asmlinkage long sys_oldumount(const char __user *name);
72367 asmlinkage long sys_truncate(const char __user *path, long length);
72368 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
72369 asmlinkage long sys_stat(const char __user *filename,
72370 @@ -578,7 +578,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72371 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72372 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72373 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72374 - struct sockaddr __user *, int);
72375 + struct sockaddr __user *, int) __intentional_overflow(0);
72376 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72377 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72378 unsigned int vlen, unsigned flags);
72379 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72380 index 27b3b0b..e093dd9 100644
72381 --- a/include/linux/syscore_ops.h
72382 +++ b/include/linux/syscore_ops.h
72383 @@ -16,7 +16,7 @@ struct syscore_ops {
72384 int (*suspend)(void);
72385 void (*resume)(void);
72386 void (*shutdown)(void);
72387 -};
72388 +} __do_const;
72389
72390 extern void register_syscore_ops(struct syscore_ops *ops);
72391 extern void unregister_syscore_ops(struct syscore_ops *ops);
72392 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72393 index 14a8ff2..af52bad 100644
72394 --- a/include/linux/sysctl.h
72395 +++ b/include/linux/sysctl.h
72396 @@ -34,13 +34,13 @@ struct ctl_table_root;
72397 struct ctl_table_header;
72398 struct ctl_dir;
72399
72400 -typedef struct ctl_table ctl_table;
72401 -
72402 typedef int proc_handler (struct ctl_table *ctl, int write,
72403 void __user *buffer, size_t *lenp, loff_t *ppos);
72404
72405 extern int proc_dostring(struct ctl_table *, int,
72406 void __user *, size_t *, loff_t *);
72407 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72408 + void __user *, size_t *, loff_t *);
72409 extern int proc_dointvec(struct ctl_table *, int,
72410 void __user *, size_t *, loff_t *);
72411 extern int proc_dointvec_minmax(struct ctl_table *, int,
72412 @@ -115,7 +115,9 @@ struct ctl_table
72413 struct ctl_table_poll *poll;
72414 void *extra1;
72415 void *extra2;
72416 -};
72417 +} __do_const;
72418 +typedef struct ctl_table __no_const ctl_table_no_const;
72419 +typedef struct ctl_table ctl_table;
72420
72421 struct ctl_node {
72422 struct rb_node node;
72423 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72424 index e2cee22..3ddb921 100644
72425 --- a/include/linux/sysfs.h
72426 +++ b/include/linux/sysfs.h
72427 @@ -31,7 +31,8 @@ struct attribute {
72428 struct lock_class_key *key;
72429 struct lock_class_key skey;
72430 #endif
72431 -};
72432 +} __do_const;
72433 +typedef struct attribute __no_const attribute_no_const;
72434
72435 /**
72436 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72437 @@ -59,8 +60,8 @@ struct attribute_group {
72438 umode_t (*is_visible)(struct kobject *,
72439 struct attribute *, int);
72440 struct attribute **attrs;
72441 -};
72442 -
72443 +} __do_const;
72444 +typedef struct attribute_group __no_const attribute_group_no_const;
72445
72446
72447 /**
72448 @@ -107,7 +108,8 @@ struct bin_attribute {
72449 char *, loff_t, size_t);
72450 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72451 struct vm_area_struct *vma);
72452 -};
72453 +} __do_const;
72454 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72455
72456 /**
72457 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72458 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72459 index 7faf933..9b85a0c 100644
72460 --- a/include/linux/sysrq.h
72461 +++ b/include/linux/sysrq.h
72462 @@ -16,6 +16,7 @@
72463
72464 #include <linux/errno.h>
72465 #include <linux/types.h>
72466 +#include <linux/compiler.h>
72467
72468 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72469 #define SYSRQ_DEFAULT_ENABLE 1
72470 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72471 char *help_msg;
72472 char *action_msg;
72473 int enable_mask;
72474 -};
72475 +} __do_const;
72476
72477 #ifdef CONFIG_MAGIC_SYSRQ
72478
72479 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72480 index e7e0473..7989295 100644
72481 --- a/include/linux/thread_info.h
72482 +++ b/include/linux/thread_info.h
72483 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72484 #error "no set_restore_sigmask() provided and default one won't work"
72485 #endif
72486
72487 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72488 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72489 +{
72490 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72491 + if (!__builtin_constant_p(n))
72492 +#endif
72493 + __check_object_size(ptr, n, to_user);
72494 +}
72495 +
72496 #endif /* __KERNEL__ */
72497
72498 #endif /* _LINUX_THREAD_INFO_H */
72499 diff --git a/include/linux/tty.h b/include/linux/tty.h
72500 index 8780bd2..d1ae08b 100644
72501 --- a/include/linux/tty.h
72502 +++ b/include/linux/tty.h
72503 @@ -194,7 +194,7 @@ struct tty_port {
72504 const struct tty_port_operations *ops; /* Port operations */
72505 spinlock_t lock; /* Lock protecting tty field */
72506 int blocked_open; /* Waiting to open */
72507 - int count; /* Usage count */
72508 + atomic_t count; /* Usage count */
72509 wait_queue_head_t open_wait; /* Open waiters */
72510 wait_queue_head_t close_wait; /* Close waiters */
72511 wait_queue_head_t delta_msr_wait; /* Modem status change */
72512 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
72513 struct tty_struct *tty, struct file *filp);
72514 static inline int tty_port_users(struct tty_port *port)
72515 {
72516 - return port->count + port->blocked_open;
72517 + return atomic_read(&port->count) + port->blocked_open;
72518 }
72519
72520 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72521 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72522 index 756a609..b302dd6 100644
72523 --- a/include/linux/tty_driver.h
72524 +++ b/include/linux/tty_driver.h
72525 @@ -285,7 +285,7 @@ struct tty_operations {
72526 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72527 #endif
72528 const struct file_operations *proc_fops;
72529 -};
72530 +} __do_const;
72531
72532 struct tty_driver {
72533 int magic; /* magic number for this structure */
72534 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72535 index 58390c7..95e214c 100644
72536 --- a/include/linux/tty_ldisc.h
72537 +++ b/include/linux/tty_ldisc.h
72538 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72539
72540 struct module *owner;
72541
72542 - int refcount;
72543 + atomic_t refcount;
72544 };
72545
72546 struct tty_ldisc {
72547 diff --git a/include/linux/types.h b/include/linux/types.h
72548 index 4d118ba..c3ee9bf 100644
72549 --- a/include/linux/types.h
72550 +++ b/include/linux/types.h
72551 @@ -176,10 +176,26 @@ typedef struct {
72552 int counter;
72553 } atomic_t;
72554
72555 +#ifdef CONFIG_PAX_REFCOUNT
72556 +typedef struct {
72557 + int counter;
72558 +} atomic_unchecked_t;
72559 +#else
72560 +typedef atomic_t atomic_unchecked_t;
72561 +#endif
72562 +
72563 #ifdef CONFIG_64BIT
72564 typedef struct {
72565 long counter;
72566 } atomic64_t;
72567 +
72568 +#ifdef CONFIG_PAX_REFCOUNT
72569 +typedef struct {
72570 + long counter;
72571 +} atomic64_unchecked_t;
72572 +#else
72573 +typedef atomic64_t atomic64_unchecked_t;
72574 +#endif
72575 #endif
72576
72577 struct list_head {
72578 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72579 index 5ca0951..ab496a5 100644
72580 --- a/include/linux/uaccess.h
72581 +++ b/include/linux/uaccess.h
72582 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72583 long ret; \
72584 mm_segment_t old_fs = get_fs(); \
72585 \
72586 - set_fs(KERNEL_DS); \
72587 pagefault_disable(); \
72588 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72589 - pagefault_enable(); \
72590 + set_fs(KERNEL_DS); \
72591 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72592 set_fs(old_fs); \
72593 + pagefault_enable(); \
72594 ret; \
72595 })
72596
72597 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72598 index 8e522cbc..aa8572d 100644
72599 --- a/include/linux/uidgid.h
72600 +++ b/include/linux/uidgid.h
72601 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72602
72603 #endif /* CONFIG_USER_NS */
72604
72605 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72606 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72607 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72608 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72609 +
72610 #endif /* _LINUX_UIDGID_H */
72611 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72612 index 99c1b4d..562e6f3 100644
72613 --- a/include/linux/unaligned/access_ok.h
72614 +++ b/include/linux/unaligned/access_ok.h
72615 @@ -4,34 +4,34 @@
72616 #include <linux/kernel.h>
72617 #include <asm/byteorder.h>
72618
72619 -static inline u16 get_unaligned_le16(const void *p)
72620 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72621 {
72622 - return le16_to_cpup((__le16 *)p);
72623 + return le16_to_cpup((const __le16 *)p);
72624 }
72625
72626 -static inline u32 get_unaligned_le32(const void *p)
72627 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72628 {
72629 - return le32_to_cpup((__le32 *)p);
72630 + return le32_to_cpup((const __le32 *)p);
72631 }
72632
72633 -static inline u64 get_unaligned_le64(const void *p)
72634 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72635 {
72636 - return le64_to_cpup((__le64 *)p);
72637 + return le64_to_cpup((const __le64 *)p);
72638 }
72639
72640 -static inline u16 get_unaligned_be16(const void *p)
72641 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72642 {
72643 - return be16_to_cpup((__be16 *)p);
72644 + return be16_to_cpup((const __be16 *)p);
72645 }
72646
72647 -static inline u32 get_unaligned_be32(const void *p)
72648 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72649 {
72650 - return be32_to_cpup((__be32 *)p);
72651 + return be32_to_cpup((const __be32 *)p);
72652 }
72653
72654 -static inline u64 get_unaligned_be64(const void *p)
72655 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72656 {
72657 - return be64_to_cpup((__be64 *)p);
72658 + return be64_to_cpup((const __be64 *)p);
72659 }
72660
72661 static inline void put_unaligned_le16(u16 val, void *p)
72662 diff --git a/include/linux/usb.h b/include/linux/usb.h
72663 index a0bee5a..5533a52 100644
72664 --- a/include/linux/usb.h
72665 +++ b/include/linux/usb.h
72666 @@ -552,7 +552,7 @@ struct usb_device {
72667 int maxchild;
72668
72669 u32 quirks;
72670 - atomic_t urbnum;
72671 + atomic_unchecked_t urbnum;
72672
72673 unsigned long active_duration;
72674
72675 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72676
72677 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72678 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72679 - void *data, __u16 size, int timeout);
72680 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72681 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72682 void *data, int len, int *actual_length, int timeout);
72683 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72684 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72685 index e452ba6..78f8e80 100644
72686 --- a/include/linux/usb/renesas_usbhs.h
72687 +++ b/include/linux/usb/renesas_usbhs.h
72688 @@ -39,7 +39,7 @@ enum {
72689 */
72690 struct renesas_usbhs_driver_callback {
72691 int (*notify_hotplug)(struct platform_device *pdev);
72692 -};
72693 +} __no_const;
72694
72695 /*
72696 * callback functions for platform
72697 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72698 index 6f8fbcf..8259001 100644
72699 --- a/include/linux/vermagic.h
72700 +++ b/include/linux/vermagic.h
72701 @@ -25,9 +25,35 @@
72702 #define MODULE_ARCH_VERMAGIC ""
72703 #endif
72704
72705 +#ifdef CONFIG_PAX_REFCOUNT
72706 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72707 +#else
72708 +#define MODULE_PAX_REFCOUNT ""
72709 +#endif
72710 +
72711 +#ifdef CONSTIFY_PLUGIN
72712 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72713 +#else
72714 +#define MODULE_CONSTIFY_PLUGIN ""
72715 +#endif
72716 +
72717 +#ifdef STACKLEAK_PLUGIN
72718 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72719 +#else
72720 +#define MODULE_STACKLEAK_PLUGIN ""
72721 +#endif
72722 +
72723 +#ifdef CONFIG_GRKERNSEC
72724 +#define MODULE_GRSEC "GRSEC "
72725 +#else
72726 +#define MODULE_GRSEC ""
72727 +#endif
72728 +
72729 #define VERMAGIC_STRING \
72730 UTS_RELEASE " " \
72731 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72732 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72733 - MODULE_ARCH_VERMAGIC
72734 + MODULE_ARCH_VERMAGIC \
72735 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72736 + MODULE_GRSEC
72737
72738 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72739 index 7d5773a..541c01c 100644
72740 --- a/include/linux/vmalloc.h
72741 +++ b/include/linux/vmalloc.h
72742 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72743 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72744 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72745 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72746 +
72747 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72748 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72749 +#endif
72750 +
72751 /* bits [20..32] reserved for arch specific ioremap internals */
72752
72753 /*
72754 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
72755 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72756 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72757 unsigned long start, unsigned long end, gfp_t gfp_mask,
72758 - pgprot_t prot, int node, const void *caller);
72759 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72760 extern void vfree(const void *addr);
72761
72762 extern void *vmap(struct page **pages, unsigned int count,
72763 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72764 extern void free_vm_area(struct vm_struct *area);
72765
72766 /* for /dev/kmem */
72767 -extern long vread(char *buf, char *addr, unsigned long count);
72768 -extern long vwrite(char *buf, char *addr, unsigned long count);
72769 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72770 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72771
72772 /*
72773 * Internals. Dont't use..
72774 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72775 index c586679..f06b389 100644
72776 --- a/include/linux/vmstat.h
72777 +++ b/include/linux/vmstat.h
72778 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
72779 /*
72780 * Zone based page accounting with per cpu differentials.
72781 */
72782 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72783 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72784
72785 static inline void zone_page_state_add(long x, struct zone *zone,
72786 enum zone_stat_item item)
72787 {
72788 - atomic_long_add(x, &zone->vm_stat[item]);
72789 - atomic_long_add(x, &vm_stat[item]);
72790 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72791 + atomic_long_add_unchecked(x, &vm_stat[item]);
72792 }
72793
72794 static inline unsigned long global_page_state(enum zone_stat_item item)
72795 {
72796 - long x = atomic_long_read(&vm_stat[item]);
72797 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72798 #ifdef CONFIG_SMP
72799 if (x < 0)
72800 x = 0;
72801 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72802 static inline unsigned long zone_page_state(struct zone *zone,
72803 enum zone_stat_item item)
72804 {
72805 - long x = atomic_long_read(&zone->vm_stat[item]);
72806 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72807 #ifdef CONFIG_SMP
72808 if (x < 0)
72809 x = 0;
72810 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72811 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72812 enum zone_stat_item item)
72813 {
72814 - long x = atomic_long_read(&zone->vm_stat[item]);
72815 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72816
72817 #ifdef CONFIG_SMP
72818 int cpu;
72819 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72820
72821 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72822 {
72823 - atomic_long_inc(&zone->vm_stat[item]);
72824 - atomic_long_inc(&vm_stat[item]);
72825 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72826 + atomic_long_inc_unchecked(&vm_stat[item]);
72827 }
72828
72829 static inline void __inc_zone_page_state(struct page *page,
72830 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
72831
72832 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72833 {
72834 - atomic_long_dec(&zone->vm_stat[item]);
72835 - atomic_long_dec(&vm_stat[item]);
72836 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72837 + atomic_long_dec_unchecked(&vm_stat[item]);
72838 }
72839
72840 static inline void __dec_zone_page_state(struct page *page,
72841 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72842 index fdbafc6..49dfe4f 100644
72843 --- a/include/linux/xattr.h
72844 +++ b/include/linux/xattr.h
72845 @@ -28,7 +28,7 @@ struct xattr_handler {
72846 size_t size, int handler_flags);
72847 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72848 size_t size, int flags, int handler_flags);
72849 -};
72850 +} __do_const;
72851
72852 struct xattr {
72853 char *name;
72854 @@ -37,6 +37,9 @@ struct xattr {
72855 };
72856
72857 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72858 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72859 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72860 +#endif
72861 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72862 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72863 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72864 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72865 index 9c5a6b4..09c9438 100644
72866 --- a/include/linux/zlib.h
72867 +++ b/include/linux/zlib.h
72868 @@ -31,6 +31,7 @@
72869 #define _ZLIB_H
72870
72871 #include <linux/zconf.h>
72872 +#include <linux/compiler.h>
72873
72874 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72875 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72876 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72877
72878 /* basic functions */
72879
72880 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72881 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72882 /*
72883 Returns the number of bytes that needs to be allocated for a per-
72884 stream workspace with the specified parameters. A pointer to this
72885 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72886 index 95d1c91..6798cca 100644
72887 --- a/include/media/v4l2-dev.h
72888 +++ b/include/media/v4l2-dev.h
72889 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72890 int (*mmap) (struct file *, struct vm_area_struct *);
72891 int (*open) (struct file *);
72892 int (*release) (struct file *);
72893 -};
72894 +} __do_const;
72895
72896 /*
72897 * Newer version of video_device, handled by videodev2.c
72898 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72899 index adcbb20..62c2559 100644
72900 --- a/include/net/9p/transport.h
72901 +++ b/include/net/9p/transport.h
72902 @@ -57,7 +57,7 @@ struct p9_trans_module {
72903 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72904 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72905 char *, char *, int , int, int, int);
72906 -};
72907 +} __do_const;
72908
72909 void v9fs_register_trans(struct p9_trans_module *m);
72910 void v9fs_unregister_trans(struct p9_trans_module *m);
72911 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72912 index fb94cf1..7c0c987 100644
72913 --- a/include/net/bluetooth/l2cap.h
72914 +++ b/include/net/bluetooth/l2cap.h
72915 @@ -551,7 +551,7 @@ struct l2cap_ops {
72916 void (*defer) (struct l2cap_chan *chan);
72917 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72918 unsigned long len, int nb);
72919 -};
72920 +} __do_const;
72921
72922 struct l2cap_conn {
72923 struct hci_conn *hcon;
72924 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72925 index f2ae33d..c457cf0 100644
72926 --- a/include/net/caif/cfctrl.h
72927 +++ b/include/net/caif/cfctrl.h
72928 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72929 void (*radioset_rsp)(void);
72930 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72931 struct cflayer *client_layer);
72932 -};
72933 +} __no_const;
72934
72935 /* Link Setup Parameters for CAIF-Links. */
72936 struct cfctrl_link_param {
72937 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72938 struct cfctrl {
72939 struct cfsrvl serv;
72940 struct cfctrl_rsp res;
72941 - atomic_t req_seq_no;
72942 - atomic_t rsp_seq_no;
72943 + atomic_unchecked_t req_seq_no;
72944 + atomic_unchecked_t rsp_seq_no;
72945 struct list_head list;
72946 /* Protects from simultaneous access to first_req list */
72947 spinlock_t info_list_lock;
72948 diff --git a/include/net/flow.h b/include/net/flow.h
72949 index 628e11b..4c475df 100644
72950 --- a/include/net/flow.h
72951 +++ b/include/net/flow.h
72952 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72953
72954 extern void flow_cache_flush(void);
72955 extern void flow_cache_flush_deferred(void);
72956 -extern atomic_t flow_cache_genid;
72957 +extern atomic_unchecked_t flow_cache_genid;
72958
72959 #endif
72960 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72961 index 93024a4..eeb6b6e 100644
72962 --- a/include/net/genetlink.h
72963 +++ b/include/net/genetlink.h
72964 @@ -119,7 +119,7 @@ struct genl_ops {
72965 struct netlink_callback *cb);
72966 int (*done)(struct netlink_callback *cb);
72967 struct list_head ops_list;
72968 -};
72969 +} __do_const;
72970
72971 extern int genl_register_family(struct genl_family *family);
72972 extern int genl_register_family_with_ops(struct genl_family *family,
72973 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72974 index 734d9b5..48a9a4b 100644
72975 --- a/include/net/gro_cells.h
72976 +++ b/include/net/gro_cells.h
72977 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72978 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72979
72980 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72981 - atomic_long_inc(&dev->rx_dropped);
72982 + atomic_long_inc_unchecked(&dev->rx_dropped);
72983 kfree_skb(skb);
72984 return;
72985 }
72986 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72987 index de2c785..0588a6b 100644
72988 --- a/include/net/inet_connection_sock.h
72989 +++ b/include/net/inet_connection_sock.h
72990 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72991 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72992 int (*bind_conflict)(const struct sock *sk,
72993 const struct inet_bind_bucket *tb, bool relax);
72994 -};
72995 +} __do_const;
72996
72997 /** inet_connection_sock - INET connection oriented sock
72998 *
72999 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
73000 index 53f464d..ba76aaa 100644
73001 --- a/include/net/inetpeer.h
73002 +++ b/include/net/inetpeer.h
73003 @@ -47,8 +47,8 @@ struct inet_peer {
73004 */
73005 union {
73006 struct {
73007 - atomic_t rid; /* Frag reception counter */
73008 - atomic_t ip_id_count; /* IP ID for the next packet */
73009 + atomic_unchecked_t rid; /* Frag reception counter */
73010 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
73011 };
73012 struct rcu_head rcu;
73013 struct inet_peer *gc_next;
73014 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
73015 more++;
73016 inet_peer_refcheck(p);
73017 do {
73018 - old = atomic_read(&p->ip_id_count);
73019 + old = atomic_read_unchecked(&p->ip_id_count);
73020 new = old + more;
73021 if (!new)
73022 new = 1;
73023 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
73024 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
73025 return new;
73026 }
73027
73028 diff --git a/include/net/ip.h b/include/net/ip.h
73029 index a68f838..74518ab 100644
73030 --- a/include/net/ip.h
73031 +++ b/include/net/ip.h
73032 @@ -202,7 +202,7 @@ extern struct local_ports {
73033 } sysctl_local_ports;
73034 extern void inet_get_local_port_range(int *low, int *high);
73035
73036 -extern unsigned long *sysctl_local_reserved_ports;
73037 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
73038 static inline int inet_is_reserved_local_port(int port)
73039 {
73040 return test_bit(port, sysctl_local_reserved_ports);
73041 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
73042 index e49db91..76a81de 100644
73043 --- a/include/net/ip_fib.h
73044 +++ b/include/net/ip_fib.h
73045 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
73046
73047 #define FIB_RES_SADDR(net, res) \
73048 ((FIB_RES_NH(res).nh_saddr_genid == \
73049 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
73050 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
73051 FIB_RES_NH(res).nh_saddr : \
73052 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
73053 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
73054 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
73055 index 4c062cc..3562c31 100644
73056 --- a/include/net/ip_vs.h
73057 +++ b/include/net/ip_vs.h
73058 @@ -612,7 +612,7 @@ struct ip_vs_conn {
73059 struct ip_vs_conn *control; /* Master control connection */
73060 atomic_t n_control; /* Number of controlled ones */
73061 struct ip_vs_dest *dest; /* real server */
73062 - atomic_t in_pkts; /* incoming packet counter */
73063 + atomic_unchecked_t in_pkts; /* incoming packet counter */
73064
73065 /* packet transmitter for different forwarding methods. If it
73066 mangles the packet, it must return NF_DROP or better NF_STOLEN,
73067 @@ -761,7 +761,7 @@ struct ip_vs_dest {
73068 __be16 port; /* port number of the server */
73069 union nf_inet_addr addr; /* IP address of the server */
73070 volatile unsigned int flags; /* dest status flags */
73071 - atomic_t conn_flags; /* flags to copy to conn */
73072 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
73073 atomic_t weight; /* server weight */
73074
73075 atomic_t refcnt; /* reference counter */
73076 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
73077 /* ip_vs_lblc */
73078 int sysctl_lblc_expiration;
73079 struct ctl_table_header *lblc_ctl_header;
73080 - struct ctl_table *lblc_ctl_table;
73081 + ctl_table_no_const *lblc_ctl_table;
73082 /* ip_vs_lblcr */
73083 int sysctl_lblcr_expiration;
73084 struct ctl_table_header *lblcr_ctl_header;
73085 - struct ctl_table *lblcr_ctl_table;
73086 + ctl_table_no_const *lblcr_ctl_table;
73087 /* ip_vs_est */
73088 struct list_head est_list; /* estimator list */
73089 spinlock_t est_lock;
73090 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
73091 index 80ffde3..968b0f4 100644
73092 --- a/include/net/irda/ircomm_tty.h
73093 +++ b/include/net/irda/ircomm_tty.h
73094 @@ -35,6 +35,7 @@
73095 #include <linux/termios.h>
73096 #include <linux/timer.h>
73097 #include <linux/tty.h> /* struct tty_struct */
73098 +#include <asm/local.h>
73099
73100 #include <net/irda/irias_object.h>
73101 #include <net/irda/ircomm_core.h>
73102 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
73103 index 714cc9a..ea05f3e 100644
73104 --- a/include/net/iucv/af_iucv.h
73105 +++ b/include/net/iucv/af_iucv.h
73106 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
73107 struct iucv_sock_list {
73108 struct hlist_head head;
73109 rwlock_t lock;
73110 - atomic_t autobind_name;
73111 + atomic_unchecked_t autobind_name;
73112 };
73113
73114 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73115 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73116 index df83f69..9b640b8 100644
73117 --- a/include/net/llc_c_ac.h
73118 +++ b/include/net/llc_c_ac.h
73119 @@ -87,7 +87,7 @@
73120 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73121 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73122
73123 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73124 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73125
73126 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73127 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73128 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73129 index 6ca3113..f8026dd 100644
73130 --- a/include/net/llc_c_ev.h
73131 +++ b/include/net/llc_c_ev.h
73132 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73133 return (struct llc_conn_state_ev *)skb->cb;
73134 }
73135
73136 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73137 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73138 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73139 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73140
73141 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73142 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73143 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73144 index 0e79cfb..f46db31 100644
73145 --- a/include/net/llc_c_st.h
73146 +++ b/include/net/llc_c_st.h
73147 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73148 u8 next_state;
73149 llc_conn_ev_qfyr_t *ev_qualifiers;
73150 llc_conn_action_t *ev_actions;
73151 -};
73152 +} __do_const;
73153
73154 struct llc_conn_state {
73155 u8 current_state;
73156 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73157 index 37a3bbd..55a4241 100644
73158 --- a/include/net/llc_s_ac.h
73159 +++ b/include/net/llc_s_ac.h
73160 @@ -23,7 +23,7 @@
73161 #define SAP_ACT_TEST_IND 9
73162
73163 /* All action functions must look like this */
73164 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73165 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73166
73167 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73168 struct sk_buff *skb);
73169 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73170 index 567c681..cd73ac0 100644
73171 --- a/include/net/llc_s_st.h
73172 +++ b/include/net/llc_s_st.h
73173 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73174 llc_sap_ev_t ev;
73175 u8 next_state;
73176 llc_sap_action_t *ev_actions;
73177 -};
73178 +} __do_const;
73179
73180 struct llc_sap_state {
73181 u8 curr_state;
73182 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73183 index 885898a..cdace34 100644
73184 --- a/include/net/mac80211.h
73185 +++ b/include/net/mac80211.h
73186 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
73187 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73188 struct dentry *dir);
73189 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73190 -};
73191 +} __do_const;
73192
73193 static inline int rate_supported(struct ieee80211_sta *sta,
73194 enum ieee80211_band band,
73195 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73196 index 7e748ad..5c6229b 100644
73197 --- a/include/net/neighbour.h
73198 +++ b/include/net/neighbour.h
73199 @@ -123,7 +123,7 @@ struct neigh_ops {
73200 void (*error_report)(struct neighbour *, struct sk_buff *);
73201 int (*output)(struct neighbour *, struct sk_buff *);
73202 int (*connected_output)(struct neighbour *, struct sk_buff *);
73203 -};
73204 +} __do_const;
73205
73206 struct pneigh_entry {
73207 struct pneigh_entry *next;
73208 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73209 index b176978..ea169f4 100644
73210 --- a/include/net/net_namespace.h
73211 +++ b/include/net/net_namespace.h
73212 @@ -117,7 +117,7 @@ struct net {
73213 #endif
73214 struct netns_ipvs *ipvs;
73215 struct sock *diag_nlsk;
73216 - atomic_t rt_genid;
73217 + atomic_unchecked_t rt_genid;
73218 };
73219
73220 /*
73221 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73222 #define __net_init __init
73223 #define __net_exit __exit_refok
73224 #define __net_initdata __initdata
73225 +#ifdef CONSTIFY_PLUGIN
73226 #define __net_initconst __initconst
73227 +#else
73228 +#define __net_initconst __initdata
73229 +#endif
73230 #endif
73231
73232 struct pernet_operations {
73233 @@ -284,7 +288,7 @@ struct pernet_operations {
73234 void (*exit_batch)(struct list_head *net_exit_list);
73235 int *id;
73236 size_t size;
73237 -};
73238 +} __do_const;
73239
73240 /*
73241 * Use these carefully. If you implement a network device and it
73242 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73243
73244 static inline int rt_genid(struct net *net)
73245 {
73246 - return atomic_read(&net->rt_genid);
73247 + return atomic_read_unchecked(&net->rt_genid);
73248 }
73249
73250 static inline void rt_genid_bump(struct net *net)
73251 {
73252 - atomic_inc(&net->rt_genid);
73253 + atomic_inc_unchecked(&net->rt_genid);
73254 }
73255
73256 #endif /* __NET_NET_NAMESPACE_H */
73257 diff --git a/include/net/netdma.h b/include/net/netdma.h
73258 index 8ba8ce2..99b7fff 100644
73259 --- a/include/net/netdma.h
73260 +++ b/include/net/netdma.h
73261 @@ -24,7 +24,7 @@
73262 #include <linux/dmaengine.h>
73263 #include <linux/skbuff.h>
73264
73265 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73266 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73267 struct sk_buff *skb, int offset, struct iovec *to,
73268 size_t len, struct dma_pinned_list *pinned_list);
73269
73270 diff --git a/include/net/netlink.h b/include/net/netlink.h
73271 index 9690b0f..87aded7 100644
73272 --- a/include/net/netlink.h
73273 +++ b/include/net/netlink.h
73274 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73275 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73276 {
73277 if (mark)
73278 - skb_trim(skb, (unsigned char *) mark - skb->data);
73279 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73280 }
73281
73282 /**
73283 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73284 index c9c0c53..53f24c3 100644
73285 --- a/include/net/netns/conntrack.h
73286 +++ b/include/net/netns/conntrack.h
73287 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73288 struct nf_proto_net {
73289 #ifdef CONFIG_SYSCTL
73290 struct ctl_table_header *ctl_table_header;
73291 - struct ctl_table *ctl_table;
73292 + ctl_table_no_const *ctl_table;
73293 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73294 struct ctl_table_header *ctl_compat_header;
73295 - struct ctl_table *ctl_compat_table;
73296 + ctl_table_no_const *ctl_compat_table;
73297 #endif
73298 #endif
73299 unsigned int users;
73300 @@ -58,7 +58,7 @@ struct nf_ip_net {
73301 struct nf_icmp_net icmpv6;
73302 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73303 struct ctl_table_header *ctl_table_header;
73304 - struct ctl_table *ctl_table;
73305 + ctl_table_no_const *ctl_table;
73306 #endif
73307 };
73308
73309 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73310 index 2ba9de8..47bd6c7 100644
73311 --- a/include/net/netns/ipv4.h
73312 +++ b/include/net/netns/ipv4.h
73313 @@ -67,7 +67,7 @@ struct netns_ipv4 {
73314 kgid_t sysctl_ping_group_range[2];
73315 long sysctl_tcp_mem[3];
73316
73317 - atomic_t dev_addr_genid;
73318 + atomic_unchecked_t dev_addr_genid;
73319
73320 #ifdef CONFIG_IP_MROUTE
73321 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73322 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
73323 index 005e2c2..023d340 100644
73324 --- a/include/net/netns/ipv6.h
73325 +++ b/include/net/netns/ipv6.h
73326 @@ -71,7 +71,7 @@ struct netns_ipv6 {
73327 struct fib_rules_ops *mr6_rules_ops;
73328 #endif
73329 #endif
73330 - atomic_t dev_addr_genid;
73331 + atomic_unchecked_t dev_addr_genid;
73332 };
73333
73334 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
73335 diff --git a/include/net/protocol.h b/include/net/protocol.h
73336 index 047c047..b9dad15 100644
73337 --- a/include/net/protocol.h
73338 +++ b/include/net/protocol.h
73339 @@ -44,7 +44,7 @@ struct net_protocol {
73340 void (*err_handler)(struct sk_buff *skb, u32 info);
73341 unsigned int no_policy:1,
73342 netns_ok:1;
73343 -};
73344 +} __do_const;
73345
73346 #if IS_ENABLED(CONFIG_IPV6)
73347 struct inet6_protocol {
73348 @@ -57,7 +57,7 @@ struct inet6_protocol {
73349 u8 type, u8 code, int offset,
73350 __be32 info);
73351 unsigned int flags; /* INET6_PROTO_xxx */
73352 -};
73353 +} __do_const;
73354
73355 #define INET6_PROTO_NOPOLICY 0x1
73356 #define INET6_PROTO_FINAL 0x2
73357 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73358 index 7026648..584cc8c 100644
73359 --- a/include/net/rtnetlink.h
73360 +++ b/include/net/rtnetlink.h
73361 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73362 const struct net_device *dev);
73363 unsigned int (*get_num_tx_queues)(void);
73364 unsigned int (*get_num_rx_queues)(void);
73365 -};
73366 +} __do_const;
73367
73368 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73369 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73370 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73371 index cd89510..d67810f 100644
73372 --- a/include/net/sctp/sctp.h
73373 +++ b/include/net/sctp/sctp.h
73374 @@ -330,9 +330,9 @@ do { \
73375
73376 #else /* SCTP_DEBUG */
73377
73378 -#define SCTP_DEBUG_PRINTK(whatever...)
73379 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73380 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73381 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73382 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73383 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73384 #define SCTP_ENABLE_DEBUG
73385 #define SCTP_DISABLE_DEBUG
73386 #define SCTP_ASSERT(expr, str, func)
73387 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73388 index 2a82d13..62a31c2 100644
73389 --- a/include/net/sctp/sm.h
73390 +++ b/include/net/sctp/sm.h
73391 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73392 typedef struct {
73393 sctp_state_fn_t *fn;
73394 const char *name;
73395 -} sctp_sm_table_entry_t;
73396 +} __do_const sctp_sm_table_entry_t;
73397
73398 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73399 * currently in use.
73400 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73401 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73402
73403 /* Extern declarations for major data structures. */
73404 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73405 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73406
73407
73408 /* Get the size of a DATA chunk payload. */
73409 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73410 index 1bd4c41..9250b5b 100644
73411 --- a/include/net/sctp/structs.h
73412 +++ b/include/net/sctp/structs.h
73413 @@ -516,7 +516,7 @@ struct sctp_pf {
73414 struct sctp_association *asoc);
73415 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73416 struct sctp_af *af;
73417 -};
73418 +} __do_const;
73419
73420
73421 /* Structure to track chunk fragments that have been acked, but peer
73422 diff --git a/include/net/sock.h b/include/net/sock.h
73423 index 66772cf..25bc45b 100644
73424 --- a/include/net/sock.h
73425 +++ b/include/net/sock.h
73426 @@ -325,7 +325,7 @@ struct sock {
73427 #ifdef CONFIG_RPS
73428 __u32 sk_rxhash;
73429 #endif
73430 - atomic_t sk_drops;
73431 + atomic_unchecked_t sk_drops;
73432 int sk_rcvbuf;
73433
73434 struct sk_filter __rcu *sk_filter;
73435 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73436 }
73437
73438 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73439 - char __user *from, char *to,
73440 + char __user *from, unsigned char *to,
73441 int copy, int offset)
73442 {
73443 if (skb->ip_summed == CHECKSUM_NONE) {
73444 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73445 }
73446 }
73447
73448 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73449 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73450
73451 /**
73452 * sk_page_frag - return an appropriate page_frag
73453 diff --git a/include/net/tcp.h b/include/net/tcp.h
73454 index 5bba80f..8520a82 100644
73455 --- a/include/net/tcp.h
73456 +++ b/include/net/tcp.h
73457 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73458 extern void tcp_xmit_retransmit_queue(struct sock *);
73459 extern void tcp_simple_retransmit(struct sock *);
73460 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73461 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73462 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73463
73464 extern void tcp_send_probe0(struct sock *);
73465 extern void tcp_send_partial(struct sock *);
73466 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
73467 struct inet6_skb_parm h6;
73468 #endif
73469 } header; /* For incoming frames */
73470 - __u32 seq; /* Starting sequence number */
73471 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73472 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73473 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73474 __u32 when; /* used to compute rtt's */
73475 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73476
73477 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
73478
73479 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73480 /* 1 byte hole */
73481 - __u32 ack_seq; /* Sequence number ACK'd */
73482 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73483 };
73484
73485 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73486 diff --git a/include/net/udp.h b/include/net/udp.h
73487 index 065f379..ad99eed 100644
73488 --- a/include/net/udp.h
73489 +++ b/include/net/udp.h
73490 @@ -181,6 +181,7 @@ extern int udp_get_port(struct sock *sk, unsigned short snum,
73491 extern void udp_err(struct sk_buff *, u32);
73492 extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
73493 struct msghdr *msg, size_t len);
73494 +extern int udp_push_pending_frames(struct sock *sk);
73495 extern void udp_flush_pending_frames(struct sock *sk);
73496 extern int udp_rcv(struct sk_buff *skb);
73497 extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
73498 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73499 index 94ce082..62b278d 100644
73500 --- a/include/net/xfrm.h
73501 +++ b/include/net/xfrm.h
73502 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
73503 struct net_device *dev,
73504 const struct flowi *fl);
73505 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73506 -};
73507 +} __do_const;
73508
73509 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73510 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73511 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
73512 struct sk_buff *skb);
73513 int (*transport_finish)(struct sk_buff *skb,
73514 int async);
73515 -};
73516 +} __do_const;
73517
73518 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73519 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73520 @@ -424,7 +424,7 @@ struct xfrm_mode {
73521 struct module *owner;
73522 unsigned int encap;
73523 int flags;
73524 -};
73525 +} __do_const;
73526
73527 /* Flags for xfrm_mode. */
73528 enum {
73529 @@ -521,7 +521,7 @@ struct xfrm_policy {
73530 struct timer_list timer;
73531
73532 struct flow_cache_object flo;
73533 - atomic_t genid;
73534 + atomic_unchecked_t genid;
73535 u32 priority;
73536 u32 index;
73537 struct xfrm_mark mark;
73538 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73539 index 1a046b1..ee0bef0 100644
73540 --- a/include/rdma/iw_cm.h
73541 +++ b/include/rdma/iw_cm.h
73542 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73543 int backlog);
73544
73545 int (*destroy_listen)(struct iw_cm_id *cm_id);
73546 -};
73547 +} __no_const;
73548
73549 /**
73550 * iw_create_cm_id - Create an IW CM identifier.
73551 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73552 index e1379b4..67eafbe 100644
73553 --- a/include/scsi/libfc.h
73554 +++ b/include/scsi/libfc.h
73555 @@ -762,6 +762,7 @@ struct libfc_function_template {
73556 */
73557 void (*disc_stop_final) (struct fc_lport *);
73558 };
73559 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73560
73561 /**
73562 * struct fc_disc - Discovery context
73563 @@ -866,7 +867,7 @@ struct fc_lport {
73564 struct fc_vport *vport;
73565
73566 /* Operational Information */
73567 - struct libfc_function_template tt;
73568 + libfc_function_template_no_const tt;
73569 u8 link_up;
73570 u8 qfull;
73571 enum fc_lport_state state;
73572 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73573 index cc64587..608f523 100644
73574 --- a/include/scsi/scsi_device.h
73575 +++ b/include/scsi/scsi_device.h
73576 @@ -171,9 +171,9 @@ struct scsi_device {
73577 unsigned int max_device_blocked; /* what device_blocked counts down from */
73578 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73579
73580 - atomic_t iorequest_cnt;
73581 - atomic_t iodone_cnt;
73582 - atomic_t ioerr_cnt;
73583 + atomic_unchecked_t iorequest_cnt;
73584 + atomic_unchecked_t iodone_cnt;
73585 + atomic_unchecked_t ioerr_cnt;
73586
73587 struct device sdev_gendev,
73588 sdev_dev;
73589 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73590 index b797e8f..8e2c3aa 100644
73591 --- a/include/scsi/scsi_transport_fc.h
73592 +++ b/include/scsi/scsi_transport_fc.h
73593 @@ -751,7 +751,8 @@ struct fc_function_template {
73594 unsigned long show_host_system_hostname:1;
73595
73596 unsigned long disable_target_scan:1;
73597 -};
73598 +} __do_const;
73599 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73600
73601
73602 /**
73603 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73604 index 9031a26..750d592 100644
73605 --- a/include/sound/compress_driver.h
73606 +++ b/include/sound/compress_driver.h
73607 @@ -128,7 +128,7 @@ struct snd_compr_ops {
73608 struct snd_compr_caps *caps);
73609 int (*get_codec_caps) (struct snd_compr_stream *stream,
73610 struct snd_compr_codec_caps *codec);
73611 -};
73612 +} __no_const;
73613
73614 /**
73615 * struct snd_compr: Compressed device
73616 diff --git a/include/sound/soc.h b/include/sound/soc.h
73617 index 85c1522..f44bad1 100644
73618 --- a/include/sound/soc.h
73619 +++ b/include/sound/soc.h
73620 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
73621 /* probe ordering - for components with runtime dependencies */
73622 int probe_order;
73623 int remove_order;
73624 -};
73625 +} __do_const;
73626
73627 /* SoC platform interface */
73628 struct snd_soc_platform_driver {
73629 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
73630 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73631 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73632 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73633 -};
73634 +} __do_const;
73635
73636 struct snd_soc_platform {
73637 const char *name;
73638 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73639 index 4ea4f98..a63629b 100644
73640 --- a/include/target/target_core_base.h
73641 +++ b/include/target/target_core_base.h
73642 @@ -653,7 +653,7 @@ struct se_device {
73643 spinlock_t stats_lock;
73644 /* Active commands on this virtual SE device */
73645 atomic_t simple_cmds;
73646 - atomic_t dev_ordered_id;
73647 + atomic_unchecked_t dev_ordered_id;
73648 atomic_t dev_ordered_sync;
73649 atomic_t dev_qf_count;
73650 int export_count;
73651 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73652 new file mode 100644
73653 index 0000000..fb634b7
73654 --- /dev/null
73655 +++ b/include/trace/events/fs.h
73656 @@ -0,0 +1,53 @@
73657 +#undef TRACE_SYSTEM
73658 +#define TRACE_SYSTEM fs
73659 +
73660 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73661 +#define _TRACE_FS_H
73662 +
73663 +#include <linux/fs.h>
73664 +#include <linux/tracepoint.h>
73665 +
73666 +TRACE_EVENT(do_sys_open,
73667 +
73668 + TP_PROTO(const char *filename, int flags, int mode),
73669 +
73670 + TP_ARGS(filename, flags, mode),
73671 +
73672 + TP_STRUCT__entry(
73673 + __string( filename, filename )
73674 + __field( int, flags )
73675 + __field( int, mode )
73676 + ),
73677 +
73678 + TP_fast_assign(
73679 + __assign_str(filename, filename);
73680 + __entry->flags = flags;
73681 + __entry->mode = mode;
73682 + ),
73683 +
73684 + TP_printk("\"%s\" %x %o",
73685 + __get_str(filename), __entry->flags, __entry->mode)
73686 +);
73687 +
73688 +TRACE_EVENT(open_exec,
73689 +
73690 + TP_PROTO(const char *filename),
73691 +
73692 + TP_ARGS(filename),
73693 +
73694 + TP_STRUCT__entry(
73695 + __string( filename, filename )
73696 + ),
73697 +
73698 + TP_fast_assign(
73699 + __assign_str(filename, filename);
73700 + ),
73701 +
73702 + TP_printk("\"%s\"",
73703 + __get_str(filename))
73704 +);
73705 +
73706 +#endif /* _TRACE_FS_H */
73707 +
73708 +/* This part must be outside protection */
73709 +#include <trace/define_trace.h>
73710 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73711 index 1c09820..7f5ec79 100644
73712 --- a/include/trace/events/irq.h
73713 +++ b/include/trace/events/irq.h
73714 @@ -36,7 +36,7 @@ struct softirq_action;
73715 */
73716 TRACE_EVENT(irq_handler_entry,
73717
73718 - TP_PROTO(int irq, struct irqaction *action),
73719 + TP_PROTO(int irq, const struct irqaction *action),
73720
73721 TP_ARGS(irq, action),
73722
73723 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73724 */
73725 TRACE_EVENT(irq_handler_exit,
73726
73727 - TP_PROTO(int irq, struct irqaction *action, int ret),
73728 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73729
73730 TP_ARGS(irq, action, ret),
73731
73732 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73733 index 7caf44c..23c6f27 100644
73734 --- a/include/uapi/linux/a.out.h
73735 +++ b/include/uapi/linux/a.out.h
73736 @@ -39,6 +39,14 @@ enum machine_type {
73737 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73738 };
73739
73740 +/* Constants for the N_FLAGS field */
73741 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73742 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73743 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73744 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73745 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73746 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73747 +
73748 #if !defined (N_MAGIC)
73749 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73750 #endif
73751 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73752 index d876736..ccce5c0 100644
73753 --- a/include/uapi/linux/byteorder/little_endian.h
73754 +++ b/include/uapi/linux/byteorder/little_endian.h
73755 @@ -42,51 +42,51 @@
73756
73757 static inline __le64 __cpu_to_le64p(const __u64 *p)
73758 {
73759 - return (__force __le64)*p;
73760 + return (__force const __le64)*p;
73761 }
73762 -static inline __u64 __le64_to_cpup(const __le64 *p)
73763 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73764 {
73765 - return (__force __u64)*p;
73766 + return (__force const __u64)*p;
73767 }
73768 static inline __le32 __cpu_to_le32p(const __u32 *p)
73769 {
73770 - return (__force __le32)*p;
73771 + return (__force const __le32)*p;
73772 }
73773 static inline __u32 __le32_to_cpup(const __le32 *p)
73774 {
73775 - return (__force __u32)*p;
73776 + return (__force const __u32)*p;
73777 }
73778 static inline __le16 __cpu_to_le16p(const __u16 *p)
73779 {
73780 - return (__force __le16)*p;
73781 + return (__force const __le16)*p;
73782 }
73783 static inline __u16 __le16_to_cpup(const __le16 *p)
73784 {
73785 - return (__force __u16)*p;
73786 + return (__force const __u16)*p;
73787 }
73788 static inline __be64 __cpu_to_be64p(const __u64 *p)
73789 {
73790 - return (__force __be64)__swab64p(p);
73791 + return (__force const __be64)__swab64p(p);
73792 }
73793 static inline __u64 __be64_to_cpup(const __be64 *p)
73794 {
73795 - return __swab64p((__u64 *)p);
73796 + return __swab64p((const __u64 *)p);
73797 }
73798 static inline __be32 __cpu_to_be32p(const __u32 *p)
73799 {
73800 - return (__force __be32)__swab32p(p);
73801 + return (__force const __be32)__swab32p(p);
73802 }
73803 -static inline __u32 __be32_to_cpup(const __be32 *p)
73804 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73805 {
73806 - return __swab32p((__u32 *)p);
73807 + return __swab32p((const __u32 *)p);
73808 }
73809 static inline __be16 __cpu_to_be16p(const __u16 *p)
73810 {
73811 - return (__force __be16)__swab16p(p);
73812 + return (__force const __be16)__swab16p(p);
73813 }
73814 static inline __u16 __be16_to_cpup(const __be16 *p)
73815 {
73816 - return __swab16p((__u16 *)p);
73817 + return __swab16p((const __u16 *)p);
73818 }
73819 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73820 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73821 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73822 index ef6103b..d4e65dd 100644
73823 --- a/include/uapi/linux/elf.h
73824 +++ b/include/uapi/linux/elf.h
73825 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73826 #define PT_GNU_EH_FRAME 0x6474e550
73827
73828 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73829 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73830 +
73831 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73832 +
73833 +/* Constants for the e_flags field */
73834 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73835 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73836 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73837 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73838 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73839 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73840
73841 /*
73842 * Extended Numbering
73843 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73844 #define DT_DEBUG 21
73845 #define DT_TEXTREL 22
73846 #define DT_JMPREL 23
73847 +#define DT_FLAGS 30
73848 + #define DF_TEXTREL 0x00000004
73849 #define DT_ENCODING 32
73850 #define OLD_DT_LOOS 0x60000000
73851 #define DT_LOOS 0x6000000d
73852 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73853 #define PF_W 0x2
73854 #define PF_X 0x1
73855
73856 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73857 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73858 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73859 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73860 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73861 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73862 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73863 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73864 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73865 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73866 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73867 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73868 +
73869 typedef struct elf32_phdr{
73870 Elf32_Word p_type;
73871 Elf32_Off p_offset;
73872 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73873 #define EI_OSABI 7
73874 #define EI_PAD 8
73875
73876 +#define EI_PAX 14
73877 +
73878 #define ELFMAG0 0x7f /* EI_MAG */
73879 #define ELFMAG1 'E'
73880 #define ELFMAG2 'L'
73881 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73882 index aa169c4..6a2771d 100644
73883 --- a/include/uapi/linux/personality.h
73884 +++ b/include/uapi/linux/personality.h
73885 @@ -30,6 +30,7 @@ enum {
73886 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73887 ADDR_NO_RANDOMIZE | \
73888 ADDR_COMPAT_LAYOUT | \
73889 + ADDR_LIMIT_3GB | \
73890 MMAP_PAGE_ZERO)
73891
73892 /*
73893 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73894 index 7530e74..e714828 100644
73895 --- a/include/uapi/linux/screen_info.h
73896 +++ b/include/uapi/linux/screen_info.h
73897 @@ -43,7 +43,8 @@ struct screen_info {
73898 __u16 pages; /* 0x32 */
73899 __u16 vesa_attributes; /* 0x34 */
73900 __u32 capabilities; /* 0x36 */
73901 - __u8 _reserved[6]; /* 0x3a */
73902 + __u16 vesapm_size; /* 0x3a */
73903 + __u8 _reserved[4]; /* 0x3c */
73904 } __attribute__((packed));
73905
73906 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73907 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73908 index 0e011eb..82681b1 100644
73909 --- a/include/uapi/linux/swab.h
73910 +++ b/include/uapi/linux/swab.h
73911 @@ -43,7 +43,7 @@
73912 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73913 */
73914
73915 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73916 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73917 {
73918 #ifdef __HAVE_BUILTIN_BSWAP16__
73919 return __builtin_bswap16(val);
73920 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73921 #endif
73922 }
73923
73924 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73925 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73926 {
73927 #ifdef __HAVE_BUILTIN_BSWAP32__
73928 return __builtin_bswap32(val);
73929 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73930 #endif
73931 }
73932
73933 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73934 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73935 {
73936 #ifdef __HAVE_BUILTIN_BSWAP64__
73937 return __builtin_bswap64(val);
73938 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73939 index 6d67213..8dab561 100644
73940 --- a/include/uapi/linux/sysctl.h
73941 +++ b/include/uapi/linux/sysctl.h
73942 @@ -155,7 +155,11 @@ enum
73943 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73944 };
73945
73946 -
73947 +#ifdef CONFIG_PAX_SOFTMODE
73948 +enum {
73949 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73950 +};
73951 +#endif
73952
73953 /* CTL_VM names: */
73954 enum
73955 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73956 index e4629b9..6958086 100644
73957 --- a/include/uapi/linux/xattr.h
73958 +++ b/include/uapi/linux/xattr.h
73959 @@ -63,5 +63,9 @@
73960 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73961 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73962
73963 +/* User namespace */
73964 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73965 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73966 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73967
73968 #endif /* _UAPI_LINUX_XATTR_H */
73969 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73970 index f9466fa..f4e2b81 100644
73971 --- a/include/video/udlfb.h
73972 +++ b/include/video/udlfb.h
73973 @@ -53,10 +53,10 @@ struct dlfb_data {
73974 u32 pseudo_palette[256];
73975 int blank_mode; /*one of FB_BLANK_ */
73976 /* blit-only rendering path metrics, exposed through sysfs */
73977 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73978 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73979 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73980 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73981 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73982 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73983 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73984 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73985 };
73986
73987 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73988 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73989 index 1a91850..28573f8 100644
73990 --- a/include/video/uvesafb.h
73991 +++ b/include/video/uvesafb.h
73992 @@ -122,6 +122,7 @@ struct uvesafb_par {
73993 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73994 u8 pmi_setpal; /* PMI for palette changes */
73995 u16 *pmi_base; /* protected mode interface location */
73996 + u8 *pmi_code; /* protected mode code location */
73997 void *pmi_start;
73998 void *pmi_pal;
73999 u8 *vbe_state_orig; /*
74000 diff --git a/init/Kconfig b/init/Kconfig
74001 index 2d9b831..ae4c8ac 100644
74002 --- a/init/Kconfig
74003 +++ b/init/Kconfig
74004 @@ -1029,6 +1029,7 @@ endif # CGROUPS
74005
74006 config CHECKPOINT_RESTORE
74007 bool "Checkpoint/restore support" if EXPERT
74008 + depends on !GRKERNSEC
74009 default n
74010 help
74011 Enables additional kernel features in a sake of checkpoint/restore.
74012 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
74013
74014 config COMPAT_BRK
74015 bool "Disable heap randomization"
74016 - default y
74017 + default n
74018 help
74019 Randomizing heap placement makes heap exploits harder, but it
74020 also breaks ancient binaries (including anything libc5 based).
74021 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
74022 config STOP_MACHINE
74023 bool
74024 default y
74025 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
74026 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
74027 help
74028 Need stop_machine() primitive.
74029
74030 diff --git a/init/Makefile b/init/Makefile
74031 index 7bc47ee..6da2dc7 100644
74032 --- a/init/Makefile
74033 +++ b/init/Makefile
74034 @@ -2,6 +2,9 @@
74035 # Makefile for the linux kernel.
74036 #
74037
74038 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
74039 +asflags-y := $(GCC_PLUGINS_AFLAGS)
74040 +
74041 obj-y := main.o version.o mounts.o
74042 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
74043 obj-y += noinitramfs.o
74044 diff --git a/init/do_mounts.c b/init/do_mounts.c
74045 index a2b49f2..03a0e17c 100644
74046 --- a/init/do_mounts.c
74047 +++ b/init/do_mounts.c
74048 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
74049 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
74050 {
74051 struct super_block *s;
74052 - int err = sys_mount(name, "/root", fs, flags, data);
74053 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
74054 if (err)
74055 return err;
74056
74057 - sys_chdir("/root");
74058 + sys_chdir((const char __force_user *)"/root");
74059 s = current->fs->pwd.dentry->d_sb;
74060 ROOT_DEV = s->s_dev;
74061 printk(KERN_INFO
74062 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
74063 va_start(args, fmt);
74064 vsprintf(buf, fmt, args);
74065 va_end(args);
74066 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
74067 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
74068 if (fd >= 0) {
74069 sys_ioctl(fd, FDEJECT, 0);
74070 sys_close(fd);
74071 }
74072 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
74073 - fd = sys_open("/dev/console", O_RDWR, 0);
74074 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
74075 if (fd >= 0) {
74076 sys_ioctl(fd, TCGETS, (long)&termios);
74077 termios.c_lflag &= ~ICANON;
74078 sys_ioctl(fd, TCSETSF, (long)&termios);
74079 - sys_read(fd, &c, 1);
74080 + sys_read(fd, (char __user *)&c, 1);
74081 termios.c_lflag |= ICANON;
74082 sys_ioctl(fd, TCSETSF, (long)&termios);
74083 sys_close(fd);
74084 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
74085 mount_root();
74086 out:
74087 devtmpfs_mount("dev");
74088 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74089 - sys_chroot(".");
74090 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74091 + sys_chroot((const char __force_user *)".");
74092 }
74093 diff --git a/init/do_mounts.h b/init/do_mounts.h
74094 index f5b978a..69dbfe8 100644
74095 --- a/init/do_mounts.h
74096 +++ b/init/do_mounts.h
74097 @@ -15,15 +15,15 @@ extern int root_mountflags;
74098
74099 static inline int create_dev(char *name, dev_t dev)
74100 {
74101 - sys_unlink(name);
74102 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
74103 + sys_unlink((char __force_user *)name);
74104 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
74105 }
74106
74107 #if BITS_PER_LONG == 32
74108 static inline u32 bstat(char *name)
74109 {
74110 struct stat64 stat;
74111 - if (sys_stat64(name, &stat) != 0)
74112 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
74113 return 0;
74114 if (!S_ISBLK(stat.st_mode))
74115 return 0;
74116 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
74117 static inline u32 bstat(char *name)
74118 {
74119 struct stat stat;
74120 - if (sys_newstat(name, &stat) != 0)
74121 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
74122 return 0;
74123 if (!S_ISBLK(stat.st_mode))
74124 return 0;
74125 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74126 index 3e0878e..8a9d7a0 100644
74127 --- a/init/do_mounts_initrd.c
74128 +++ b/init/do_mounts_initrd.c
74129 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
74130 {
74131 sys_unshare(CLONE_FS | CLONE_FILES);
74132 /* stdin/stdout/stderr for /linuxrc */
74133 - sys_open("/dev/console", O_RDWR, 0);
74134 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
74135 sys_dup(0);
74136 sys_dup(0);
74137 /* move initrd over / and chdir/chroot in initrd root */
74138 - sys_chdir("/root");
74139 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74140 - sys_chroot(".");
74141 + sys_chdir((const char __force_user *)"/root");
74142 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74143 + sys_chroot((const char __force_user *)".");
74144 sys_setsid();
74145 return 0;
74146 }
74147 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
74148 create_dev("/dev/root.old", Root_RAM0);
74149 /* mount initrd on rootfs' /root */
74150 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74151 - sys_mkdir("/old", 0700);
74152 - sys_chdir("/old");
74153 + sys_mkdir((const char __force_user *)"/old", 0700);
74154 + sys_chdir((const char __force_user *)"/old");
74155
74156 /* try loading default modules from initrd */
74157 load_default_modules();
74158 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
74159 current->flags &= ~PF_FREEZER_SKIP;
74160
74161 /* move initrd to rootfs' /old */
74162 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74163 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74164 /* switch root and cwd back to / of rootfs */
74165 - sys_chroot("..");
74166 + sys_chroot((const char __force_user *)"..");
74167
74168 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74169 - sys_chdir("/old");
74170 + sys_chdir((const char __force_user *)"/old");
74171 return;
74172 }
74173
74174 - sys_chdir("/");
74175 + sys_chdir((const char __force_user *)"/");
74176 ROOT_DEV = new_decode_dev(real_root_dev);
74177 mount_root();
74178
74179 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74180 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74181 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74182 if (!error)
74183 printk("okay\n");
74184 else {
74185 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74186 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74187 if (error == -ENOENT)
74188 printk("/initrd does not exist. Ignored.\n");
74189 else
74190 printk("failed\n");
74191 printk(KERN_NOTICE "Unmounting old root\n");
74192 - sys_umount("/old", MNT_DETACH);
74193 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74194 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74195 if (fd < 0) {
74196 error = fd;
74197 @@ -127,11 +127,11 @@ int __init initrd_load(void)
74198 * mounted in the normal path.
74199 */
74200 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74201 - sys_unlink("/initrd.image");
74202 + sys_unlink((const char __force_user *)"/initrd.image");
74203 handle_initrd();
74204 return 1;
74205 }
74206 }
74207 - sys_unlink("/initrd.image");
74208 + sys_unlink((const char __force_user *)"/initrd.image");
74209 return 0;
74210 }
74211 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74212 index 8cb6db5..d729f50 100644
74213 --- a/init/do_mounts_md.c
74214 +++ b/init/do_mounts_md.c
74215 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74216 partitioned ? "_d" : "", minor,
74217 md_setup_args[ent].device_names);
74218
74219 - fd = sys_open(name, 0, 0);
74220 + fd = sys_open((char __force_user *)name, 0, 0);
74221 if (fd < 0) {
74222 printk(KERN_ERR "md: open failed - cannot start "
74223 "array %s\n", name);
74224 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
74225 * array without it
74226 */
74227 sys_close(fd);
74228 - fd = sys_open(name, 0, 0);
74229 + fd = sys_open((char __force_user *)name, 0, 0);
74230 sys_ioctl(fd, BLKRRPART, 0);
74231 }
74232 sys_close(fd);
74233 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
74234
74235 wait_for_device_probe();
74236
74237 - fd = sys_open("/dev/md0", 0, 0);
74238 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
74239 if (fd >= 0) {
74240 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
74241 sys_close(fd);
74242 diff --git a/init/init_task.c b/init/init_task.c
74243 index ba0a7f36..2bcf1d5 100644
74244 --- a/init/init_task.c
74245 +++ b/init/init_task.c
74246 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
74247 * Initial thread structure. Alignment of this is handled by a special
74248 * linker map entry.
74249 */
74250 +#ifdef CONFIG_X86
74251 +union thread_union init_thread_union __init_task_data;
74252 +#else
74253 union thread_union init_thread_union __init_task_data =
74254 { INIT_THREAD_INFO(init_task) };
74255 +#endif
74256 diff --git a/init/initramfs.c b/init/initramfs.c
74257 index a67ef9d..2d17ed9 100644
74258 --- a/init/initramfs.c
74259 +++ b/init/initramfs.c
74260 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74261 }
74262 }
74263
74264 -static long __init do_utime(char *filename, time_t mtime)
74265 +static long __init do_utime(char __force_user *filename, time_t mtime)
74266 {
74267 struct timespec t[2];
74268
74269 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74270 struct dir_entry *de, *tmp;
74271 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74272 list_del(&de->list);
74273 - do_utime(de->name, de->mtime);
74274 + do_utime((char __force_user *)de->name, de->mtime);
74275 kfree(de->name);
74276 kfree(de);
74277 }
74278 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74279 if (nlink >= 2) {
74280 char *old = find_link(major, minor, ino, mode, collected);
74281 if (old)
74282 - return (sys_link(old, collected) < 0) ? -1 : 1;
74283 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74284 }
74285 return 0;
74286 }
74287 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74288 {
74289 struct stat st;
74290
74291 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74292 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74293 if (S_ISDIR(st.st_mode))
74294 - sys_rmdir(path);
74295 + sys_rmdir((char __force_user *)path);
74296 else
74297 - sys_unlink(path);
74298 + sys_unlink((char __force_user *)path);
74299 }
74300 }
74301
74302 @@ -315,7 +315,7 @@ static int __init do_name(void)
74303 int openflags = O_WRONLY|O_CREAT;
74304 if (ml != 1)
74305 openflags |= O_TRUNC;
74306 - wfd = sys_open(collected, openflags, mode);
74307 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74308
74309 if (wfd >= 0) {
74310 sys_fchown(wfd, uid, gid);
74311 @@ -327,17 +327,17 @@ static int __init do_name(void)
74312 }
74313 }
74314 } else if (S_ISDIR(mode)) {
74315 - sys_mkdir(collected, mode);
74316 - sys_chown(collected, uid, gid);
74317 - sys_chmod(collected, mode);
74318 + sys_mkdir((char __force_user *)collected, mode);
74319 + sys_chown((char __force_user *)collected, uid, gid);
74320 + sys_chmod((char __force_user *)collected, mode);
74321 dir_add(collected, mtime);
74322 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74323 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74324 if (maybe_link() == 0) {
74325 - sys_mknod(collected, mode, rdev);
74326 - sys_chown(collected, uid, gid);
74327 - sys_chmod(collected, mode);
74328 - do_utime(collected, mtime);
74329 + sys_mknod((char __force_user *)collected, mode, rdev);
74330 + sys_chown((char __force_user *)collected, uid, gid);
74331 + sys_chmod((char __force_user *)collected, mode);
74332 + do_utime((char __force_user *)collected, mtime);
74333 }
74334 }
74335 return 0;
74336 @@ -346,15 +346,15 @@ static int __init do_name(void)
74337 static int __init do_copy(void)
74338 {
74339 if (count >= body_len) {
74340 - sys_write(wfd, victim, body_len);
74341 + sys_write(wfd, (char __force_user *)victim, body_len);
74342 sys_close(wfd);
74343 - do_utime(vcollected, mtime);
74344 + do_utime((char __force_user *)vcollected, mtime);
74345 kfree(vcollected);
74346 eat(body_len);
74347 state = SkipIt;
74348 return 0;
74349 } else {
74350 - sys_write(wfd, victim, count);
74351 + sys_write(wfd, (char __force_user *)victim, count);
74352 body_len -= count;
74353 eat(count);
74354 return 1;
74355 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74356 {
74357 collected[N_ALIGN(name_len) + body_len] = '\0';
74358 clean_path(collected, 0);
74359 - sys_symlink(collected + N_ALIGN(name_len), collected);
74360 - sys_lchown(collected, uid, gid);
74361 - do_utime(collected, mtime);
74362 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74363 + sys_lchown((char __force_user *)collected, uid, gid);
74364 + do_utime((char __force_user *)collected, mtime);
74365 state = SkipIt;
74366 next_state = Reset;
74367 return 0;
74368 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
74369 {
74370 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
74371 if (err)
74372 - panic(err); /* Failed to decompress INTERNAL initramfs */
74373 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
74374 if (initrd_start) {
74375 #ifdef CONFIG_BLK_DEV_RAM
74376 int fd;
74377 diff --git a/init/main.c b/init/main.c
74378 index 9484f4b..4c01430 100644
74379 --- a/init/main.c
74380 +++ b/init/main.c
74381 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
74382 extern void tc_init(void);
74383 #endif
74384
74385 +extern void grsecurity_init(void);
74386 +
74387 /*
74388 * Debug helper: via this flag we know that we are in 'early bootup code'
74389 * where only the boot processor is running with IRQ disabled. This means
74390 @@ -153,6 +155,64 @@ static int __init set_reset_devices(char *str)
74391
74392 __setup("reset_devices", set_reset_devices);
74393
74394 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74395 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74396 +static int __init setup_grsec_proc_gid(char *str)
74397 +{
74398 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74399 + return 1;
74400 +}
74401 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74402 +#endif
74403 +
74404 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74405 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
74406 +EXPORT_SYMBOL(pax_user_shadow_base);
74407 +extern char pax_enter_kernel_user[];
74408 +extern char pax_exit_kernel_user[];
74409 +extern pgdval_t clone_pgd_mask;
74410 +#endif
74411 +
74412 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74413 +static int __init setup_pax_nouderef(char *str)
74414 +{
74415 +#ifdef CONFIG_X86_32
74416 + unsigned int cpu;
74417 + struct desc_struct *gdt;
74418 +
74419 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74420 + gdt = get_cpu_gdt_table(cpu);
74421 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74422 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74423 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74424 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74425 + }
74426 + loadsegment(ds, __KERNEL_DS);
74427 + loadsegment(es, __KERNEL_DS);
74428 + loadsegment(ss, __KERNEL_DS);
74429 +#else
74430 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74431 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74432 + clone_pgd_mask = ~(pgdval_t)0UL;
74433 + pax_user_shadow_base = 0UL;
74434 +#endif
74435 +
74436 + return 0;
74437 +}
74438 +early_param("pax_nouderef", setup_pax_nouderef);
74439 +#endif
74440 +
74441 +#ifdef CONFIG_PAX_SOFTMODE
74442 +int pax_softmode;
74443 +
74444 +static int __init setup_pax_softmode(char *str)
74445 +{
74446 + get_option(&str, &pax_softmode);
74447 + return 1;
74448 +}
74449 +__setup("pax_softmode=", setup_pax_softmode);
74450 +#endif
74451 +
74452 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74453 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74454 static const char *panic_later, *panic_param;
74455 @@ -655,8 +715,6 @@ static void __init do_ctors(void)
74456 bool initcall_debug;
74457 core_param(initcall_debug, initcall_debug, bool, 0644);
74458
74459 -static char msgbuf[64];
74460 -
74461 static int __init_or_module do_one_initcall_debug(initcall_t fn)
74462 {
74463 ktime_t calltime, delta, rettime;
74464 @@ -679,23 +737,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
74465 {
74466 int count = preempt_count();
74467 int ret;
74468 + const char *msg1 = "", *msg2 = "";
74469
74470 if (initcall_debug)
74471 ret = do_one_initcall_debug(fn);
74472 else
74473 ret = fn();
74474
74475 - msgbuf[0] = 0;
74476 -
74477 if (preempt_count() != count) {
74478 - sprintf(msgbuf, "preemption imbalance ");
74479 + msg1 = " preemption imbalance";
74480 preempt_count() = count;
74481 }
74482 if (irqs_disabled()) {
74483 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74484 + msg2 = " disabled interrupts";
74485 local_irq_enable();
74486 }
74487 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
74488 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
74489
74490 return ret;
74491 }
74492 @@ -748,8 +805,14 @@ static void __init do_initcall_level(int level)
74493 level, level,
74494 &repair_env_string);
74495
74496 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74497 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74498 do_one_initcall(*fn);
74499 +
74500 +#ifdef LATENT_ENTROPY_PLUGIN
74501 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74502 +#endif
74503 +
74504 + }
74505 }
74506
74507 static void __init do_initcalls(void)
74508 @@ -783,8 +846,14 @@ static void __init do_pre_smp_initcalls(void)
74509 {
74510 initcall_t *fn;
74511
74512 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74513 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74514 do_one_initcall(*fn);
74515 +
74516 +#ifdef LATENT_ENTROPY_PLUGIN
74517 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74518 +#endif
74519 +
74520 + }
74521 }
74522
74523 /*
74524 @@ -802,8 +871,8 @@ static int run_init_process(const char *init_filename)
74525 {
74526 argv_init[0] = init_filename;
74527 return do_execve(init_filename,
74528 - (const char __user *const __user *)argv_init,
74529 - (const char __user *const __user *)envp_init);
74530 + (const char __user *const __force_user *)argv_init,
74531 + (const char __user *const __force_user *)envp_init);
74532 }
74533
74534 static noinline void __init kernel_init_freeable(void);
74535 @@ -880,7 +949,7 @@ static noinline void __init kernel_init_freeable(void)
74536 do_basic_setup();
74537
74538 /* Open the /dev/console on the rootfs, this should never fail */
74539 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74540 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74541 pr_err("Warning: unable to open an initial console.\n");
74542
74543 (void) sys_dup(0);
74544 @@ -893,11 +962,13 @@ static noinline void __init kernel_init_freeable(void)
74545 if (!ramdisk_execute_command)
74546 ramdisk_execute_command = "/init";
74547
74548 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74549 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74550 ramdisk_execute_command = NULL;
74551 prepare_namespace();
74552 }
74553
74554 + grsecurity_init();
74555 +
74556 /*
74557 * Ok, we have completed the initial bootup, and
74558 * we're essentially up and running. Get rid of the
74559 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74560 index 130dfec..cc88451 100644
74561 --- a/ipc/ipc_sysctl.c
74562 +++ b/ipc/ipc_sysctl.c
74563 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74564 static int proc_ipc_dointvec(ctl_table *table, int write,
74565 void __user *buffer, size_t *lenp, loff_t *ppos)
74566 {
74567 - struct ctl_table ipc_table;
74568 + ctl_table_no_const ipc_table;
74569
74570 memcpy(&ipc_table, table, sizeof(ipc_table));
74571 ipc_table.data = get_ipc(table);
74572 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74573 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74574 void __user *buffer, size_t *lenp, loff_t *ppos)
74575 {
74576 - struct ctl_table ipc_table;
74577 + ctl_table_no_const ipc_table;
74578
74579 memcpy(&ipc_table, table, sizeof(ipc_table));
74580 ipc_table.data = get_ipc(table);
74581 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74582 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74583 void __user *buffer, size_t *lenp, loff_t *ppos)
74584 {
74585 - struct ctl_table ipc_table;
74586 + ctl_table_no_const ipc_table;
74587 size_t lenp_bef = *lenp;
74588 int rc;
74589
74590 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74591 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74592 void __user *buffer, size_t *lenp, loff_t *ppos)
74593 {
74594 - struct ctl_table ipc_table;
74595 + ctl_table_no_const ipc_table;
74596 memcpy(&ipc_table, table, sizeof(ipc_table));
74597 ipc_table.data = get_ipc(table);
74598
74599 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74600 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74601 void __user *buffer, size_t *lenp, loff_t *ppos)
74602 {
74603 - struct ctl_table ipc_table;
74604 + ctl_table_no_const ipc_table;
74605 size_t lenp_bef = *lenp;
74606 int oldval;
74607 int rc;
74608 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74609 index 383d638..943fdbb 100644
74610 --- a/ipc/mq_sysctl.c
74611 +++ b/ipc/mq_sysctl.c
74612 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74613 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74614 void __user *buffer, size_t *lenp, loff_t *ppos)
74615 {
74616 - struct ctl_table mq_table;
74617 + ctl_table_no_const mq_table;
74618 memcpy(&mq_table, table, sizeof(mq_table));
74619 mq_table.data = get_mq(table);
74620
74621 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74622 index e4e47f6..a85e0ad 100644
74623 --- a/ipc/mqueue.c
74624 +++ b/ipc/mqueue.c
74625 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74626 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74627 info->attr.mq_msgsize);
74628
74629 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74630 spin_lock(&mq_lock);
74631 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74632 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74633 diff --git a/ipc/msg.c b/ipc/msg.c
74634 index d0c6d96..69a893c 100644
74635 --- a/ipc/msg.c
74636 +++ b/ipc/msg.c
74637 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74638 return security_msg_queue_associate(msq, msgflg);
74639 }
74640
74641 +static struct ipc_ops msg_ops = {
74642 + .getnew = newque,
74643 + .associate = msg_security,
74644 + .more_checks = NULL
74645 +};
74646 +
74647 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74648 {
74649 struct ipc_namespace *ns;
74650 - struct ipc_ops msg_ops;
74651 struct ipc_params msg_params;
74652
74653 ns = current->nsproxy->ipc_ns;
74654
74655 - msg_ops.getnew = newque;
74656 - msg_ops.associate = msg_security;
74657 - msg_ops.more_checks = NULL;
74658 -
74659 msg_params.key = key;
74660 msg_params.flg = msgflg;
74661
74662 diff --git a/ipc/sem.c b/ipc/sem.c
74663 index 70480a3..f4e8262 100644
74664 --- a/ipc/sem.c
74665 +++ b/ipc/sem.c
74666 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74667 return 0;
74668 }
74669
74670 +static struct ipc_ops sem_ops = {
74671 + .getnew = newary,
74672 + .associate = sem_security,
74673 + .more_checks = sem_more_checks
74674 +};
74675 +
74676 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74677 {
74678 struct ipc_namespace *ns;
74679 - struct ipc_ops sem_ops;
74680 struct ipc_params sem_params;
74681
74682 ns = current->nsproxy->ipc_ns;
74683 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74684 if (nsems < 0 || nsems > ns->sc_semmsl)
74685 return -EINVAL;
74686
74687 - sem_ops.getnew = newary;
74688 - sem_ops.associate = sem_security;
74689 - sem_ops.more_checks = sem_more_checks;
74690 -
74691 sem_params.key = key;
74692 sem_params.flg = semflg;
74693 sem_params.u.nsems = nsems;
74694 diff --git a/ipc/shm.c b/ipc/shm.c
74695 index 7e199fa..180a1ca 100644
74696 --- a/ipc/shm.c
74697 +++ b/ipc/shm.c
74698 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74699 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74700 #endif
74701
74702 +#ifdef CONFIG_GRKERNSEC
74703 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74704 + const time_t shm_createtime, const kuid_t cuid,
74705 + const int shmid);
74706 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74707 + const time_t shm_createtime);
74708 +#endif
74709 +
74710 void shm_init_ns(struct ipc_namespace *ns)
74711 {
74712 ns->shm_ctlmax = SHMMAX;
74713 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74714 shp->shm_lprid = 0;
74715 shp->shm_atim = shp->shm_dtim = 0;
74716 shp->shm_ctim = get_seconds();
74717 +#ifdef CONFIG_GRKERNSEC
74718 + {
74719 + struct timespec timeval;
74720 + do_posix_clock_monotonic_gettime(&timeval);
74721 +
74722 + shp->shm_createtime = timeval.tv_sec;
74723 + }
74724 +#endif
74725 shp->shm_segsz = size;
74726 shp->shm_nattch = 0;
74727 shp->shm_file = file;
74728 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74729 return 0;
74730 }
74731
74732 +static struct ipc_ops shm_ops = {
74733 + .getnew = newseg,
74734 + .associate = shm_security,
74735 + .more_checks = shm_more_checks
74736 +};
74737 +
74738 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74739 {
74740 struct ipc_namespace *ns;
74741 - struct ipc_ops shm_ops;
74742 struct ipc_params shm_params;
74743
74744 ns = current->nsproxy->ipc_ns;
74745
74746 - shm_ops.getnew = newseg;
74747 - shm_ops.associate = shm_security;
74748 - shm_ops.more_checks = shm_more_checks;
74749 -
74750 shm_params.key = key;
74751 shm_params.flg = shmflg;
74752 shm_params.u.size = size;
74753 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74754 f_mode = FMODE_READ | FMODE_WRITE;
74755 }
74756 if (shmflg & SHM_EXEC) {
74757 +
74758 +#ifdef CONFIG_PAX_MPROTECT
74759 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74760 + goto out;
74761 +#endif
74762 +
74763 prot |= PROT_EXEC;
74764 acc_mode |= S_IXUGO;
74765 }
74766 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74767 if (err)
74768 goto out_unlock;
74769
74770 +#ifdef CONFIG_GRKERNSEC
74771 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74772 + shp->shm_perm.cuid, shmid) ||
74773 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74774 + err = -EACCES;
74775 + goto out_unlock;
74776 + }
74777 +#endif
74778 +
74779 path = shp->shm_file->f_path;
74780 path_get(&path);
74781 shp->shm_nattch++;
74782 +#ifdef CONFIG_GRKERNSEC
74783 + shp->shm_lapid = current->pid;
74784 +#endif
74785 size = i_size_read(path.dentry->d_inode);
74786 shm_unlock(shp);
74787
74788 diff --git a/kernel/acct.c b/kernel/acct.c
74789 index 8d6e145..33e0b1e 100644
74790 --- a/kernel/acct.c
74791 +++ b/kernel/acct.c
74792 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74793 */
74794 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74795 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74796 - file->f_op->write(file, (char *)&ac,
74797 + file->f_op->write(file, (char __force_user *)&ac,
74798 sizeof(acct_t), &file->f_pos);
74799 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74800 set_fs(fs);
74801 diff --git a/kernel/audit.c b/kernel/audit.c
74802 index 91e53d0..d9e3ec4 100644
74803 --- a/kernel/audit.c
74804 +++ b/kernel/audit.c
74805 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
74806 3) suppressed due to audit_rate_limit
74807 4) suppressed due to audit_backlog_limit
74808 */
74809 -static atomic_t audit_lost = ATOMIC_INIT(0);
74810 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74811
74812 /* The netlink socket. */
74813 static struct sock *audit_sock;
74814 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
74815 unsigned long now;
74816 int print;
74817
74818 - atomic_inc(&audit_lost);
74819 + atomic_inc_unchecked(&audit_lost);
74820
74821 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74822
74823 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
74824 printk(KERN_WARNING
74825 "audit: audit_lost=%d audit_rate_limit=%d "
74826 "audit_backlog_limit=%d\n",
74827 - atomic_read(&audit_lost),
74828 + atomic_read_unchecked(&audit_lost),
74829 audit_rate_limit,
74830 audit_backlog_limit);
74831 audit_panic(message);
74832 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74833 status_set.pid = audit_pid;
74834 status_set.rate_limit = audit_rate_limit;
74835 status_set.backlog_limit = audit_backlog_limit;
74836 - status_set.lost = atomic_read(&audit_lost);
74837 + status_set.lost = atomic_read_unchecked(&audit_lost);
74838 status_set.backlog = skb_queue_len(&audit_skb_queue);
74839 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74840 &status_set, sizeof(status_set));
74841 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
74842 index 6bd4a90..0ee9eff 100644
74843 --- a/kernel/auditfilter.c
74844 +++ b/kernel/auditfilter.c
74845 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
74846 f->lsm_rule = NULL;
74847
74848 /* Support legacy tests for a valid loginuid */
74849 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
74850 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
74851 f->type = AUDIT_LOGINUID_SET;
74852 f->val = 0;
74853 }
74854 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74855 index 3c8a601..3a416f6 100644
74856 --- a/kernel/auditsc.c
74857 +++ b/kernel/auditsc.c
74858 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74859 }
74860
74861 /* global counter which is incremented every time something logs in */
74862 -static atomic_t session_id = ATOMIC_INIT(0);
74863 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74864
74865 /**
74866 * audit_set_loginuid - set current task's audit_context loginuid
74867 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
74868 return -EPERM;
74869 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74870
74871 - sessionid = atomic_inc_return(&session_id);
74872 + sessionid = atomic_inc_return_unchecked(&session_id);
74873 if (context && context->in_syscall) {
74874 struct audit_buffer *ab;
74875
74876 diff --git a/kernel/capability.c b/kernel/capability.c
74877 index f6c2ce5..982c0f9 100644
74878 --- a/kernel/capability.c
74879 +++ b/kernel/capability.c
74880 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74881 * before modification is attempted and the application
74882 * fails.
74883 */
74884 + if (tocopy > ARRAY_SIZE(kdata))
74885 + return -EFAULT;
74886 +
74887 if (copy_to_user(dataptr, kdata, tocopy
74888 * sizeof(struct __user_cap_data_struct))) {
74889 return -EFAULT;
74890 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74891 int ret;
74892
74893 rcu_read_lock();
74894 - ret = security_capable(__task_cred(t), ns, cap);
74895 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74896 + gr_task_is_capable(t, __task_cred(t), cap);
74897 rcu_read_unlock();
74898
74899 - return (ret == 0);
74900 + return ret;
74901 }
74902
74903 /**
74904 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74905 int ret;
74906
74907 rcu_read_lock();
74908 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74909 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74910 rcu_read_unlock();
74911
74912 - return (ret == 0);
74913 + return ret;
74914 }
74915
74916 /**
74917 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74918 BUG();
74919 }
74920
74921 - if (security_capable(current_cred(), ns, cap) == 0) {
74922 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74923 current->flags |= PF_SUPERPRIV;
74924 return true;
74925 }
74926 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74927 }
74928 EXPORT_SYMBOL(ns_capable);
74929
74930 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74931 +{
74932 + if (unlikely(!cap_valid(cap))) {
74933 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74934 + BUG();
74935 + }
74936 +
74937 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74938 + current->flags |= PF_SUPERPRIV;
74939 + return true;
74940 + }
74941 + return false;
74942 +}
74943 +EXPORT_SYMBOL(ns_capable_nolog);
74944 +
74945 /**
74946 * file_ns_capable - Determine if the file's opener had a capability in effect
74947 * @file: The file we want to check
74948 @@ -432,6 +451,12 @@ bool capable(int cap)
74949 }
74950 EXPORT_SYMBOL(capable);
74951
74952 +bool capable_nolog(int cap)
74953 +{
74954 + return ns_capable_nolog(&init_user_ns, cap);
74955 +}
74956 +EXPORT_SYMBOL(capable_nolog);
74957 +
74958 /**
74959 * nsown_capable - Check superior capability to one's own user_ns
74960 * @cap: The capability in question
74961 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74962
74963 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74964 }
74965 +
74966 +bool inode_capable_nolog(const struct inode *inode, int cap)
74967 +{
74968 + struct user_namespace *ns = current_user_ns();
74969 +
74970 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74971 +}
74972 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74973 index a7c9e6d..a16aa75 100644
74974 --- a/kernel/cgroup.c
74975 +++ b/kernel/cgroup.c
74976 @@ -5378,7 +5378,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74977 struct css_set *cg = link->cg;
74978 struct task_struct *task;
74979 int count = 0;
74980 - seq_printf(seq, "css_set %p\n", cg);
74981 + seq_printf(seq, "css_set %pK\n", cg);
74982 list_for_each_entry(task, &cg->tasks, cg_list) {
74983 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74984 seq_puts(seq, " ...\n");
74985 diff --git a/kernel/compat.c b/kernel/compat.c
74986 index 0a09e48..f44f3f0 100644
74987 --- a/kernel/compat.c
74988 +++ b/kernel/compat.c
74989 @@ -13,6 +13,7 @@
74990
74991 #include <linux/linkage.h>
74992 #include <linux/compat.h>
74993 +#include <linux/module.h>
74994 #include <linux/errno.h>
74995 #include <linux/time.h>
74996 #include <linux/signal.h>
74997 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74998 mm_segment_t oldfs;
74999 long ret;
75000
75001 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
75002 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
75003 oldfs = get_fs();
75004 set_fs(KERNEL_DS);
75005 ret = hrtimer_nanosleep_restart(restart);
75006 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
75007 oldfs = get_fs();
75008 set_fs(KERNEL_DS);
75009 ret = hrtimer_nanosleep(&tu,
75010 - rmtp ? (struct timespec __user *)&rmt : NULL,
75011 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
75012 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
75013 set_fs(oldfs);
75014
75015 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
75016 mm_segment_t old_fs = get_fs();
75017
75018 set_fs(KERNEL_DS);
75019 - ret = sys_sigpending((old_sigset_t __user *) &s);
75020 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
75021 set_fs(old_fs);
75022 if (ret == 0)
75023 ret = put_user(s, set);
75024 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
75025 mm_segment_t old_fs = get_fs();
75026
75027 set_fs(KERNEL_DS);
75028 - ret = sys_old_getrlimit(resource, &r);
75029 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
75030 set_fs(old_fs);
75031
75032 if (!ret) {
75033 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
75034 set_fs (KERNEL_DS);
75035 ret = sys_wait4(pid,
75036 (stat_addr ?
75037 - (unsigned int __user *) &status : NULL),
75038 - options, (struct rusage __user *) &r);
75039 + (unsigned int __force_user *) &status : NULL),
75040 + options, (struct rusage __force_user *) &r);
75041 set_fs (old_fs);
75042
75043 if (ret > 0) {
75044 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
75045 memset(&info, 0, sizeof(info));
75046
75047 set_fs(KERNEL_DS);
75048 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
75049 - uru ? (struct rusage __user *)&ru : NULL);
75050 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
75051 + uru ? (struct rusage __force_user *)&ru : NULL);
75052 set_fs(old_fs);
75053
75054 if ((ret < 0) || (info.si_signo == 0))
75055 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
75056 oldfs = get_fs();
75057 set_fs(KERNEL_DS);
75058 err = sys_timer_settime(timer_id, flags,
75059 - (struct itimerspec __user *) &newts,
75060 - (struct itimerspec __user *) &oldts);
75061 + (struct itimerspec __force_user *) &newts,
75062 + (struct itimerspec __force_user *) &oldts);
75063 set_fs(oldfs);
75064 if (!err && old && put_compat_itimerspec(old, &oldts))
75065 return -EFAULT;
75066 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
75067 oldfs = get_fs();
75068 set_fs(KERNEL_DS);
75069 err = sys_timer_gettime(timer_id,
75070 - (struct itimerspec __user *) &ts);
75071 + (struct itimerspec __force_user *) &ts);
75072 set_fs(oldfs);
75073 if (!err && put_compat_itimerspec(setting, &ts))
75074 return -EFAULT;
75075 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
75076 oldfs = get_fs();
75077 set_fs(KERNEL_DS);
75078 err = sys_clock_settime(which_clock,
75079 - (struct timespec __user *) &ts);
75080 + (struct timespec __force_user *) &ts);
75081 set_fs(oldfs);
75082 return err;
75083 }
75084 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
75085 oldfs = get_fs();
75086 set_fs(KERNEL_DS);
75087 err = sys_clock_gettime(which_clock,
75088 - (struct timespec __user *) &ts);
75089 + (struct timespec __force_user *) &ts);
75090 set_fs(oldfs);
75091 if (!err && put_compat_timespec(&ts, tp))
75092 return -EFAULT;
75093 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
75094
75095 oldfs = get_fs();
75096 set_fs(KERNEL_DS);
75097 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
75098 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
75099 set_fs(oldfs);
75100
75101 err = compat_put_timex(utp, &txc);
75102 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
75103 oldfs = get_fs();
75104 set_fs(KERNEL_DS);
75105 err = sys_clock_getres(which_clock,
75106 - (struct timespec __user *) &ts);
75107 + (struct timespec __force_user *) &ts);
75108 set_fs(oldfs);
75109 if (!err && tp && put_compat_timespec(&ts, tp))
75110 return -EFAULT;
75111 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
75112 long err;
75113 mm_segment_t oldfs;
75114 struct timespec tu;
75115 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
75116 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
75117
75118 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
75119 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
75120 oldfs = get_fs();
75121 set_fs(KERNEL_DS);
75122 err = clock_nanosleep_restart(restart);
75123 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
75124 oldfs = get_fs();
75125 set_fs(KERNEL_DS);
75126 err = sys_clock_nanosleep(which_clock, flags,
75127 - (struct timespec __user *) &in,
75128 - (struct timespec __user *) &out);
75129 + (struct timespec __force_user *) &in,
75130 + (struct timespec __force_user *) &out);
75131 set_fs(oldfs);
75132
75133 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75134 diff --git a/kernel/configs.c b/kernel/configs.c
75135 index c18b1f1..b9a0132 100644
75136 --- a/kernel/configs.c
75137 +++ b/kernel/configs.c
75138 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75139 struct proc_dir_entry *entry;
75140
75141 /* create the current config file */
75142 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75143 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75144 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75145 + &ikconfig_file_ops);
75146 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75147 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75148 + &ikconfig_file_ops);
75149 +#endif
75150 +#else
75151 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75152 &ikconfig_file_ops);
75153 +#endif
75154 +
75155 if (!entry)
75156 return -ENOMEM;
75157
75158 diff --git a/kernel/cred.c b/kernel/cred.c
75159 index e0573a4..3874e41 100644
75160 --- a/kernel/cred.c
75161 +++ b/kernel/cred.c
75162 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75163 validate_creds(cred);
75164 alter_cred_subscribers(cred, -1);
75165 put_cred(cred);
75166 +
75167 +#ifdef CONFIG_GRKERNSEC_SETXID
75168 + cred = (struct cred *) tsk->delayed_cred;
75169 + if (cred != NULL) {
75170 + tsk->delayed_cred = NULL;
75171 + validate_creds(cred);
75172 + alter_cred_subscribers(cred, -1);
75173 + put_cred(cred);
75174 + }
75175 +#endif
75176 }
75177
75178 /**
75179 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75180 * Always returns 0 thus allowing this function to be tail-called at the end
75181 * of, say, sys_setgid().
75182 */
75183 -int commit_creds(struct cred *new)
75184 +static int __commit_creds(struct cred *new)
75185 {
75186 struct task_struct *task = current;
75187 const struct cred *old = task->real_cred;
75188 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75189
75190 get_cred(new); /* we will require a ref for the subj creds too */
75191
75192 + gr_set_role_label(task, new->uid, new->gid);
75193 +
75194 /* dumpability changes */
75195 if (!uid_eq(old->euid, new->euid) ||
75196 !gid_eq(old->egid, new->egid) ||
75197 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75198 put_cred(old);
75199 return 0;
75200 }
75201 +#ifdef CONFIG_GRKERNSEC_SETXID
75202 +extern int set_user(struct cred *new);
75203 +
75204 +void gr_delayed_cred_worker(void)
75205 +{
75206 + const struct cred *new = current->delayed_cred;
75207 + struct cred *ncred;
75208 +
75209 + current->delayed_cred = NULL;
75210 +
75211 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75212 + // from doing get_cred on it when queueing this
75213 + put_cred(new);
75214 + return;
75215 + } else if (new == NULL)
75216 + return;
75217 +
75218 + ncred = prepare_creds();
75219 + if (!ncred)
75220 + goto die;
75221 + // uids
75222 + ncred->uid = new->uid;
75223 + ncred->euid = new->euid;
75224 + ncred->suid = new->suid;
75225 + ncred->fsuid = new->fsuid;
75226 + // gids
75227 + ncred->gid = new->gid;
75228 + ncred->egid = new->egid;
75229 + ncred->sgid = new->sgid;
75230 + ncred->fsgid = new->fsgid;
75231 + // groups
75232 + if (set_groups(ncred, new->group_info) < 0) {
75233 + abort_creds(ncred);
75234 + goto die;
75235 + }
75236 + // caps
75237 + ncred->securebits = new->securebits;
75238 + ncred->cap_inheritable = new->cap_inheritable;
75239 + ncred->cap_permitted = new->cap_permitted;
75240 + ncred->cap_effective = new->cap_effective;
75241 + ncred->cap_bset = new->cap_bset;
75242 +
75243 + if (set_user(ncred)) {
75244 + abort_creds(ncred);
75245 + goto die;
75246 + }
75247 +
75248 + // from doing get_cred on it when queueing this
75249 + put_cred(new);
75250 +
75251 + __commit_creds(ncred);
75252 + return;
75253 +die:
75254 + // from doing get_cred on it when queueing this
75255 + put_cred(new);
75256 + do_group_exit(SIGKILL);
75257 +}
75258 +#endif
75259 +
75260 +int commit_creds(struct cred *new)
75261 +{
75262 +#ifdef CONFIG_GRKERNSEC_SETXID
75263 + int ret;
75264 + int schedule_it = 0;
75265 + struct task_struct *t;
75266 +
75267 + /* we won't get called with tasklist_lock held for writing
75268 + and interrupts disabled as the cred struct in that case is
75269 + init_cred
75270 + */
75271 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75272 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75273 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75274 + schedule_it = 1;
75275 + }
75276 + ret = __commit_creds(new);
75277 + if (schedule_it) {
75278 + rcu_read_lock();
75279 + read_lock(&tasklist_lock);
75280 + for (t = next_thread(current); t != current;
75281 + t = next_thread(t)) {
75282 + if (t->delayed_cred == NULL) {
75283 + t->delayed_cred = get_cred(new);
75284 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75285 + set_tsk_need_resched(t);
75286 + }
75287 + }
75288 + read_unlock(&tasklist_lock);
75289 + rcu_read_unlock();
75290 + }
75291 + return ret;
75292 +#else
75293 + return __commit_creds(new);
75294 +#endif
75295 +}
75296 +
75297 EXPORT_SYMBOL(commit_creds);
75298
75299 /**
75300 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75301 index 0506d44..2c20034 100644
75302 --- a/kernel/debug/debug_core.c
75303 +++ b/kernel/debug/debug_core.c
75304 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75305 */
75306 static atomic_t masters_in_kgdb;
75307 static atomic_t slaves_in_kgdb;
75308 -static atomic_t kgdb_break_tasklet_var;
75309 +static atomic_unchecked_t kgdb_break_tasklet_var;
75310 atomic_t kgdb_setting_breakpoint;
75311
75312 struct task_struct *kgdb_usethread;
75313 @@ -133,7 +133,7 @@ int kgdb_single_step;
75314 static pid_t kgdb_sstep_pid;
75315
75316 /* to keep track of the CPU which is doing the single stepping*/
75317 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75318 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75319
75320 /*
75321 * If you are debugging a problem where roundup (the collection of
75322 @@ -541,7 +541,7 @@ return_normal:
75323 * kernel will only try for the value of sstep_tries before
75324 * giving up and continuing on.
75325 */
75326 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75327 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75328 (kgdb_info[cpu].task &&
75329 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75330 atomic_set(&kgdb_active, -1);
75331 @@ -635,8 +635,8 @@ cpu_master_loop:
75332 }
75333
75334 kgdb_restore:
75335 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75336 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75337 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75338 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75339 if (kgdb_info[sstep_cpu].task)
75340 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75341 else
75342 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
75343 static void kgdb_tasklet_bpt(unsigned long ing)
75344 {
75345 kgdb_breakpoint();
75346 - atomic_set(&kgdb_break_tasklet_var, 0);
75347 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75348 }
75349
75350 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75351
75352 void kgdb_schedule_breakpoint(void)
75353 {
75354 - if (atomic_read(&kgdb_break_tasklet_var) ||
75355 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75356 atomic_read(&kgdb_active) != -1 ||
75357 atomic_read(&kgdb_setting_breakpoint))
75358 return;
75359 - atomic_inc(&kgdb_break_tasklet_var);
75360 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75361 tasklet_schedule(&kgdb_tasklet_breakpoint);
75362 }
75363 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75364 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75365 index 00eb8f7..d7e3244 100644
75366 --- a/kernel/debug/kdb/kdb_main.c
75367 +++ b/kernel/debug/kdb/kdb_main.c
75368 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75369 continue;
75370
75371 kdb_printf("%-20s%8u 0x%p ", mod->name,
75372 - mod->core_size, (void *)mod);
75373 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75374 #ifdef CONFIG_MODULE_UNLOAD
75375 kdb_printf("%4ld ", module_refcount(mod));
75376 #endif
75377 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75378 kdb_printf(" (Loading)");
75379 else
75380 kdb_printf(" (Live)");
75381 - kdb_printf(" 0x%p", mod->module_core);
75382 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75383
75384 #ifdef CONFIG_MODULE_UNLOAD
75385 {
75386 diff --git a/kernel/events/core.c b/kernel/events/core.c
75387 index b391907..a0e2372 100644
75388 --- a/kernel/events/core.c
75389 +++ b/kernel/events/core.c
75390 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
75391 * 0 - disallow raw tracepoint access for unpriv
75392 * 1 - disallow cpu events for unpriv
75393 * 2 - disallow kernel profiling for unpriv
75394 + * 3 - disallow all unpriv perf event use
75395 */
75396 -int sysctl_perf_event_paranoid __read_mostly = 1;
75397 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75398 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
75399 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
75400 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
75401 +#else
75402 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
75403 +#endif
75404
75405 /* Minimum for 512 kiB + 1 user control page */
75406 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
75407 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75408 return 0;
75409 }
75410
75411 -static atomic64_t perf_event_id;
75412 +static atomic64_unchecked_t perf_event_id;
75413
75414 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75415 enum event_type_t event_type);
75416 @@ -2725,7 +2732,7 @@ static void __perf_event_read(void *info)
75417
75418 static inline u64 perf_event_count(struct perf_event *event)
75419 {
75420 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75421 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75422 }
75423
75424 static u64 perf_event_read(struct perf_event *event)
75425 @@ -3071,9 +3078,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75426 mutex_lock(&event->child_mutex);
75427 total += perf_event_read(event);
75428 *enabled += event->total_time_enabled +
75429 - atomic64_read(&event->child_total_time_enabled);
75430 + atomic64_read_unchecked(&event->child_total_time_enabled);
75431 *running += event->total_time_running +
75432 - atomic64_read(&event->child_total_time_running);
75433 + atomic64_read_unchecked(&event->child_total_time_running);
75434
75435 list_for_each_entry(child, &event->child_list, child_list) {
75436 total += perf_event_read(child);
75437 @@ -3459,10 +3466,10 @@ void perf_event_update_userpage(struct perf_event *event)
75438 userpg->offset -= local64_read(&event->hw.prev_count);
75439
75440 userpg->time_enabled = enabled +
75441 - atomic64_read(&event->child_total_time_enabled);
75442 + atomic64_read_unchecked(&event->child_total_time_enabled);
75443
75444 userpg->time_running = running +
75445 - atomic64_read(&event->child_total_time_running);
75446 + atomic64_read_unchecked(&event->child_total_time_running);
75447
75448 arch_perf_update_userpage(userpg, now);
75449
75450 @@ -4012,7 +4019,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
75451
75452 /* Data. */
75453 sp = perf_user_stack_pointer(regs);
75454 - rem = __output_copy_user(handle, (void *) sp, dump_size);
75455 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
75456 dyn_size = dump_size - rem;
75457
75458 perf_output_skip(handle, rem);
75459 @@ -4100,11 +4107,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75460 values[n++] = perf_event_count(event);
75461 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75462 values[n++] = enabled +
75463 - atomic64_read(&event->child_total_time_enabled);
75464 + atomic64_read_unchecked(&event->child_total_time_enabled);
75465 }
75466 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75467 values[n++] = running +
75468 - atomic64_read(&event->child_total_time_running);
75469 + atomic64_read_unchecked(&event->child_total_time_running);
75470 }
75471 if (read_format & PERF_FORMAT_ID)
75472 values[n++] = primary_event_id(event);
75473 @@ -4813,12 +4820,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75474 * need to add enough zero bytes after the string to handle
75475 * the 64bit alignment we do later.
75476 */
75477 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75478 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75479 if (!buf) {
75480 name = strncpy(tmp, "//enomem", sizeof(tmp));
75481 goto got_name;
75482 }
75483 - name = d_path(&file->f_path, buf, PATH_MAX);
75484 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75485 if (IS_ERR(name)) {
75486 name = strncpy(tmp, "//toolong", sizeof(tmp));
75487 goto got_name;
75488 @@ -6240,7 +6247,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75489 event->parent = parent_event;
75490
75491 event->ns = get_pid_ns(task_active_pid_ns(current));
75492 - event->id = atomic64_inc_return(&perf_event_id);
75493 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75494
75495 event->state = PERF_EVENT_STATE_INACTIVE;
75496
75497 @@ -6550,6 +6557,11 @@ SYSCALL_DEFINE5(perf_event_open,
75498 if (flags & ~PERF_FLAG_ALL)
75499 return -EINVAL;
75500
75501 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75502 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75503 + return -EACCES;
75504 +#endif
75505 +
75506 err = perf_copy_attr(attr_uptr, &attr);
75507 if (err)
75508 return err;
75509 @@ -6882,10 +6894,10 @@ static void sync_child_event(struct perf_event *child_event,
75510 /*
75511 * Add back the child's count to the parent's count:
75512 */
75513 - atomic64_add(child_val, &parent_event->child_count);
75514 - atomic64_add(child_event->total_time_enabled,
75515 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75516 + atomic64_add_unchecked(child_event->total_time_enabled,
75517 &parent_event->child_total_time_enabled);
75518 - atomic64_add(child_event->total_time_running,
75519 + atomic64_add_unchecked(child_event->total_time_running,
75520 &parent_event->child_total_time_running);
75521
75522 /*
75523 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75524 index ca65997..cc8cee4 100644
75525 --- a/kernel/events/internal.h
75526 +++ b/kernel/events/internal.h
75527 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75528 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75529 }
75530
75531 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75532 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75533 static inline unsigned int \
75534 func_name(struct perf_output_handle *handle, \
75535 - const void *buf, unsigned int len) \
75536 + const void user *buf, unsigned int len) \
75537 { \
75538 unsigned long size, written; \
75539 \
75540 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75541 return n;
75542 }
75543
75544 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75545 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75546
75547 #define MEMCPY_SKIP(dst, src, n) (n)
75548
75549 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75550 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75551
75552 #ifndef arch_perf_out_copy_user
75553 #define arch_perf_out_copy_user __copy_from_user_inatomic
75554 #endif
75555
75556 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75557 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75558
75559 /* Callchain handling */
75560 extern struct perf_callchain_entry *
75561 diff --git a/kernel/exit.c b/kernel/exit.c
75562 index 7bb73f9..d7978ed 100644
75563 --- a/kernel/exit.c
75564 +++ b/kernel/exit.c
75565 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75566 struct task_struct *leader;
75567 int zap_leader;
75568 repeat:
75569 +#ifdef CONFIG_NET
75570 + gr_del_task_from_ip_table(p);
75571 +#endif
75572 +
75573 /* don't need to get the RCU readlock here - the process is dead and
75574 * can't be modifying its own credentials. But shut RCU-lockdep up */
75575 rcu_read_lock();
75576 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75577 * know it'll be handled, so that they don't get converted to
75578 * SIGKILL or just silently dropped.
75579 */
75580 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75581 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75582 recalc_sigpending();
75583 spin_unlock_irq(&current->sighand->siglock);
75584 return 0;
75585 @@ -709,6 +713,8 @@ void do_exit(long code)
75586 struct task_struct *tsk = current;
75587 int group_dead;
75588
75589 + set_fs(USER_DS);
75590 +
75591 profile_task_exit(tsk);
75592
75593 WARN_ON(blk_needs_flush_plug(tsk));
75594 @@ -725,7 +731,6 @@ void do_exit(long code)
75595 * mm_release()->clear_child_tid() from writing to a user-controlled
75596 * kernel address.
75597 */
75598 - set_fs(USER_DS);
75599
75600 ptrace_event(PTRACE_EVENT_EXIT, code);
75601
75602 @@ -784,6 +789,9 @@ void do_exit(long code)
75603 tsk->exit_code = code;
75604 taskstats_exit(tsk, group_dead);
75605
75606 + gr_acl_handle_psacct(tsk, code);
75607 + gr_acl_handle_exit();
75608 +
75609 exit_mm(tsk);
75610
75611 if (group_dead)
75612 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75613 * Take down every thread in the group. This is called by fatal signals
75614 * as well as by sys_exit_group (below).
75615 */
75616 -void
75617 +__noreturn void
75618 do_group_exit(int exit_code)
75619 {
75620 struct signal_struct *sig = current->signal;
75621 diff --git a/kernel/fork.c b/kernel/fork.c
75622 index 987b28a..4e03c05 100644
75623 --- a/kernel/fork.c
75624 +++ b/kernel/fork.c
75625 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75626 *stackend = STACK_END_MAGIC; /* for overflow detection */
75627
75628 #ifdef CONFIG_CC_STACKPROTECTOR
75629 - tsk->stack_canary = get_random_int();
75630 + tsk->stack_canary = pax_get_random_long();
75631 #endif
75632
75633 /*
75634 @@ -345,13 +345,81 @@ free_tsk:
75635 }
75636
75637 #ifdef CONFIG_MMU
75638 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75639 +{
75640 + struct vm_area_struct *tmp;
75641 + unsigned long charge;
75642 + struct mempolicy *pol;
75643 + struct file *file;
75644 +
75645 + charge = 0;
75646 + if (mpnt->vm_flags & VM_ACCOUNT) {
75647 + unsigned long len = vma_pages(mpnt);
75648 +
75649 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75650 + goto fail_nomem;
75651 + charge = len;
75652 + }
75653 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75654 + if (!tmp)
75655 + goto fail_nomem;
75656 + *tmp = *mpnt;
75657 + tmp->vm_mm = mm;
75658 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75659 + pol = mpol_dup(vma_policy(mpnt));
75660 + if (IS_ERR(pol))
75661 + goto fail_nomem_policy;
75662 + vma_set_policy(tmp, pol);
75663 + if (anon_vma_fork(tmp, mpnt))
75664 + goto fail_nomem_anon_vma_fork;
75665 + tmp->vm_flags &= ~VM_LOCKED;
75666 + tmp->vm_next = tmp->vm_prev = NULL;
75667 + tmp->vm_mirror = NULL;
75668 + file = tmp->vm_file;
75669 + if (file) {
75670 + struct inode *inode = file_inode(file);
75671 + struct address_space *mapping = file->f_mapping;
75672 +
75673 + get_file(file);
75674 + if (tmp->vm_flags & VM_DENYWRITE)
75675 + atomic_dec(&inode->i_writecount);
75676 + mutex_lock(&mapping->i_mmap_mutex);
75677 + if (tmp->vm_flags & VM_SHARED)
75678 + mapping->i_mmap_writable++;
75679 + flush_dcache_mmap_lock(mapping);
75680 + /* insert tmp into the share list, just after mpnt */
75681 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75682 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75683 + else
75684 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75685 + flush_dcache_mmap_unlock(mapping);
75686 + mutex_unlock(&mapping->i_mmap_mutex);
75687 + }
75688 +
75689 + /*
75690 + * Clear hugetlb-related page reserves for children. This only
75691 + * affects MAP_PRIVATE mappings. Faults generated by the child
75692 + * are not guaranteed to succeed, even if read-only
75693 + */
75694 + if (is_vm_hugetlb_page(tmp))
75695 + reset_vma_resv_huge_pages(tmp);
75696 +
75697 + return tmp;
75698 +
75699 +fail_nomem_anon_vma_fork:
75700 + mpol_put(pol);
75701 +fail_nomem_policy:
75702 + kmem_cache_free(vm_area_cachep, tmp);
75703 +fail_nomem:
75704 + vm_unacct_memory(charge);
75705 + return NULL;
75706 +}
75707 +
75708 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75709 {
75710 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75711 struct rb_node **rb_link, *rb_parent;
75712 int retval;
75713 - unsigned long charge;
75714 - struct mempolicy *pol;
75715
75716 uprobe_start_dup_mmap();
75717 down_write(&oldmm->mmap_sem);
75718 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75719 mm->locked_vm = 0;
75720 mm->mmap = NULL;
75721 mm->mmap_cache = NULL;
75722 - mm->free_area_cache = oldmm->mmap_base;
75723 - mm->cached_hole_size = ~0UL;
75724 + mm->free_area_cache = oldmm->free_area_cache;
75725 + mm->cached_hole_size = oldmm->cached_hole_size;
75726 mm->map_count = 0;
75727 cpumask_clear(mm_cpumask(mm));
75728 mm->mm_rb = RB_ROOT;
75729 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75730
75731 prev = NULL;
75732 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75733 - struct file *file;
75734 -
75735 if (mpnt->vm_flags & VM_DONTCOPY) {
75736 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75737 -vma_pages(mpnt));
75738 continue;
75739 }
75740 - charge = 0;
75741 - if (mpnt->vm_flags & VM_ACCOUNT) {
75742 - unsigned long len = vma_pages(mpnt);
75743 -
75744 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75745 - goto fail_nomem;
75746 - charge = len;
75747 - }
75748 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75749 - if (!tmp)
75750 - goto fail_nomem;
75751 - *tmp = *mpnt;
75752 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75753 - pol = mpol_dup(vma_policy(mpnt));
75754 - retval = PTR_ERR(pol);
75755 - if (IS_ERR(pol))
75756 - goto fail_nomem_policy;
75757 - vma_set_policy(tmp, pol);
75758 - tmp->vm_mm = mm;
75759 - if (anon_vma_fork(tmp, mpnt))
75760 - goto fail_nomem_anon_vma_fork;
75761 - tmp->vm_flags &= ~VM_LOCKED;
75762 - tmp->vm_next = tmp->vm_prev = NULL;
75763 - file = tmp->vm_file;
75764 - if (file) {
75765 - struct inode *inode = file_inode(file);
75766 - struct address_space *mapping = file->f_mapping;
75767 -
75768 - get_file(file);
75769 - if (tmp->vm_flags & VM_DENYWRITE)
75770 - atomic_dec(&inode->i_writecount);
75771 - mutex_lock(&mapping->i_mmap_mutex);
75772 - if (tmp->vm_flags & VM_SHARED)
75773 - mapping->i_mmap_writable++;
75774 - flush_dcache_mmap_lock(mapping);
75775 - /* insert tmp into the share list, just after mpnt */
75776 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75777 - vma_nonlinear_insert(tmp,
75778 - &mapping->i_mmap_nonlinear);
75779 - else
75780 - vma_interval_tree_insert_after(tmp, mpnt,
75781 - &mapping->i_mmap);
75782 - flush_dcache_mmap_unlock(mapping);
75783 - mutex_unlock(&mapping->i_mmap_mutex);
75784 + tmp = dup_vma(mm, oldmm, mpnt);
75785 + if (!tmp) {
75786 + retval = -ENOMEM;
75787 + goto out;
75788 }
75789
75790 /*
75791 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75792 if (retval)
75793 goto out;
75794 }
75795 +
75796 +#ifdef CONFIG_PAX_SEGMEXEC
75797 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75798 + struct vm_area_struct *mpnt_m;
75799 +
75800 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75801 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75802 +
75803 + if (!mpnt->vm_mirror)
75804 + continue;
75805 +
75806 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75807 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75808 + mpnt->vm_mirror = mpnt_m;
75809 + } else {
75810 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75811 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75812 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75813 + mpnt->vm_mirror->vm_mirror = mpnt;
75814 + }
75815 + }
75816 + BUG_ON(mpnt_m);
75817 + }
75818 +#endif
75819 +
75820 /* a new mm has just been created */
75821 arch_dup_mmap(oldmm, mm);
75822 retval = 0;
75823 @@ -473,14 +524,6 @@ out:
75824 up_write(&oldmm->mmap_sem);
75825 uprobe_end_dup_mmap();
75826 return retval;
75827 -fail_nomem_anon_vma_fork:
75828 - mpol_put(pol);
75829 -fail_nomem_policy:
75830 - kmem_cache_free(vm_area_cachep, tmp);
75831 -fail_nomem:
75832 - retval = -ENOMEM;
75833 - vm_unacct_memory(charge);
75834 - goto out;
75835 }
75836
75837 static inline int mm_alloc_pgd(struct mm_struct *mm)
75838 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75839 return ERR_PTR(err);
75840
75841 mm = get_task_mm(task);
75842 - if (mm && mm != current->mm &&
75843 - !ptrace_may_access(task, mode)) {
75844 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75845 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75846 mmput(mm);
75847 mm = ERR_PTR(-EACCES);
75848 }
75849 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75850 spin_unlock(&fs->lock);
75851 return -EAGAIN;
75852 }
75853 - fs->users++;
75854 + atomic_inc(&fs->users);
75855 spin_unlock(&fs->lock);
75856 return 0;
75857 }
75858 tsk->fs = copy_fs_struct(fs);
75859 if (!tsk->fs)
75860 return -ENOMEM;
75861 + /* Carry through gr_chroot_dentry and is_chrooted instead
75862 + of recomputing it here. Already copied when the task struct
75863 + is duplicated. This allows pivot_root to not be treated as
75864 + a chroot
75865 + */
75866 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75867 +
75868 return 0;
75869 }
75870
75871 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75872 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75873 #endif
75874 retval = -EAGAIN;
75875 +
75876 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75877 +
75878 if (atomic_read(&p->real_cred->user->processes) >=
75879 task_rlimit(p, RLIMIT_NPROC)) {
75880 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75881 - p->real_cred->user != INIT_USER)
75882 + if (p->real_cred->user != INIT_USER &&
75883 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
75884 goto bad_fork_free;
75885 }
75886 current->flags &= ~PF_NPROC_EXCEEDED;
75887 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75888 goto bad_fork_free_pid;
75889 }
75890
75891 + /* synchronizes with gr_set_acls()
75892 + we need to call this past the point of no return for fork()
75893 + */
75894 + gr_copy_label(p);
75895 +
75896 if (clone_flags & CLONE_THREAD) {
75897 current->signal->nr_threads++;
75898 atomic_inc(&current->signal->live);
75899 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
75900 bad_fork_free:
75901 free_task(p);
75902 fork_out:
75903 + gr_log_forkfail(retval);
75904 +
75905 return ERR_PTR(retval);
75906 }
75907
75908 @@ -1579,6 +1639,23 @@ long do_fork(unsigned long clone_flags,
75909 return -EINVAL;
75910 }
75911
75912 +#ifdef CONFIG_GRKERNSEC
75913 + if (clone_flags & CLONE_NEWUSER) {
75914 + /*
75915 + * This doesn't really inspire confidence:
75916 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75917 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75918 + * Increases kernel attack surface in areas developers
75919 + * previously cared little about ("low importance due
75920 + * to requiring "root" capability")
75921 + * To be removed when this code receives *proper* review
75922 + */
75923 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75924 + !capable(CAP_SETGID))
75925 + return -EPERM;
75926 + }
75927 +#endif
75928 +
75929 /*
75930 * Determine whether and which event to report to ptracer. When
75931 * called from kernel_thread or CLONE_UNTRACED is explicitly
75932 @@ -1613,6 +1690,8 @@ long do_fork(unsigned long clone_flags,
75933 if (clone_flags & CLONE_PARENT_SETTID)
75934 put_user(nr, parent_tidptr);
75935
75936 + gr_handle_brute_check();
75937 +
75938 if (clone_flags & CLONE_VFORK) {
75939 p->vfork_done = &vfork;
75940 init_completion(&vfork);
75941 @@ -1763,7 +1842,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75942 return 0;
75943
75944 /* don't need lock here; in the worst case we'll do useless copy */
75945 - if (fs->users == 1)
75946 + if (atomic_read(&fs->users) == 1)
75947 return 0;
75948
75949 *new_fsp = copy_fs_struct(fs);
75950 @@ -1875,7 +1954,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75951 fs = current->fs;
75952 spin_lock(&fs->lock);
75953 current->fs = new_fs;
75954 - if (--fs->users)
75955 + gr_set_chroot_entries(current, &current->fs->root);
75956 + if (atomic_dec_return(&fs->users))
75957 new_fs = NULL;
75958 else
75959 new_fs = fs;
75960 diff --git a/kernel/futex.c b/kernel/futex.c
75961 index b26dcfc..39e266a 100644
75962 --- a/kernel/futex.c
75963 +++ b/kernel/futex.c
75964 @@ -54,6 +54,7 @@
75965 #include <linux/mount.h>
75966 #include <linux/pagemap.h>
75967 #include <linux/syscalls.h>
75968 +#include <linux/ptrace.h>
75969 #include <linux/signal.h>
75970 #include <linux/export.h>
75971 #include <linux/magic.h>
75972 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75973 struct page *page, *page_head;
75974 int err, ro = 0;
75975
75976 +#ifdef CONFIG_PAX_SEGMEXEC
75977 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75978 + return -EFAULT;
75979 +#endif
75980 +
75981 /*
75982 * The futex address must be "naturally" aligned.
75983 */
75984 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75985 {
75986 u32 curval;
75987 int i;
75988 + mm_segment_t oldfs;
75989
75990 /*
75991 * This will fail and we want it. Some arch implementations do
75992 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75993 * implementation, the non-functional ones will return
75994 * -ENOSYS.
75995 */
75996 + oldfs = get_fs();
75997 + set_fs(USER_DS);
75998 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75999 futex_cmpxchg_enabled = 1;
76000 + set_fs(oldfs);
76001
76002 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
76003 plist_head_init(&futex_queues[i].chain);
76004 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
76005 index f9f44fd..29885e4 100644
76006 --- a/kernel/futex_compat.c
76007 +++ b/kernel/futex_compat.c
76008 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
76009 return 0;
76010 }
76011
76012 -static void __user *futex_uaddr(struct robust_list __user *entry,
76013 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
76014 compat_long_t futex_offset)
76015 {
76016 compat_uptr_t base = ptr_to_compat(entry);
76017 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
76018 index 9b22d03..6295b62 100644
76019 --- a/kernel/gcov/base.c
76020 +++ b/kernel/gcov/base.c
76021 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
76022 }
76023
76024 #ifdef CONFIG_MODULES
76025 -static inline int within(void *addr, void *start, unsigned long size)
76026 -{
76027 - return ((addr >= start) && (addr < start + size));
76028 -}
76029 -
76030 /* Update list and generate events when modules are unloaded. */
76031 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76032 void *data)
76033 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76034 prev = NULL;
76035 /* Remove entries located in module from linked list. */
76036 for (info = gcov_info_head; info; info = info->next) {
76037 - if (within(info, mod->module_core, mod->core_size)) {
76038 + if (within_module_core_rw((unsigned long)info, mod)) {
76039 if (prev)
76040 prev->next = info->next;
76041 else
76042 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
76043 index fd4b13b..09a5ccb 100644
76044 --- a/kernel/hrtimer.c
76045 +++ b/kernel/hrtimer.c
76046 @@ -1430,7 +1430,7 @@ void hrtimer_peek_ahead_timers(void)
76047 local_irq_restore(flags);
76048 }
76049
76050 -static void run_hrtimer_softirq(struct softirq_action *h)
76051 +static void run_hrtimer_softirq(void)
76052 {
76053 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
76054
76055 @@ -1772,7 +1772,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
76056 return NOTIFY_OK;
76057 }
76058
76059 -static struct notifier_block __cpuinitdata hrtimers_nb = {
76060 +static struct notifier_block hrtimers_nb = {
76061 .notifier_call = hrtimer_cpu_notify,
76062 };
76063
76064 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
76065 index 55fcce6..0e4cf34 100644
76066 --- a/kernel/irq_work.c
76067 +++ b/kernel/irq_work.c
76068 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
76069 return NOTIFY_OK;
76070 }
76071
76072 -static struct notifier_block cpu_notify;
76073 +static struct notifier_block cpu_notify = {
76074 + .notifier_call = irq_work_cpu_notify,
76075 + .priority = 0,
76076 +};
76077
76078 static __init int irq_work_init_cpu_notifier(void)
76079 {
76080 - cpu_notify.notifier_call = irq_work_cpu_notify;
76081 - cpu_notify.priority = 0;
76082 register_cpu_notifier(&cpu_notify);
76083 return 0;
76084 }
76085 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
76086 index 60f48fa..7f3a770 100644
76087 --- a/kernel/jump_label.c
76088 +++ b/kernel/jump_label.c
76089 @@ -13,6 +13,7 @@
76090 #include <linux/sort.h>
76091 #include <linux/err.h>
76092 #include <linux/static_key.h>
76093 +#include <linux/mm.h>
76094
76095 #ifdef HAVE_JUMP_LABEL
76096
76097 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
76098
76099 size = (((unsigned long)stop - (unsigned long)start)
76100 / sizeof(struct jump_entry));
76101 + pax_open_kernel();
76102 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
76103 + pax_close_kernel();
76104 }
76105
76106 static void jump_label_update(struct static_key *key, int enable);
76107 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
76108 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
76109 struct jump_entry *iter;
76110
76111 + pax_open_kernel();
76112 for (iter = iter_start; iter < iter_stop; iter++) {
76113 if (within_module_init(iter->code, mod))
76114 iter->code = 0;
76115 }
76116 + pax_close_kernel();
76117 }
76118
76119 static int
76120 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
76121 index 3127ad5..159d880 100644
76122 --- a/kernel/kallsyms.c
76123 +++ b/kernel/kallsyms.c
76124 @@ -11,6 +11,9 @@
76125 * Changed the compression method from stem compression to "table lookup"
76126 * compression (see scripts/kallsyms.c for a more complete description)
76127 */
76128 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76129 +#define __INCLUDED_BY_HIDESYM 1
76130 +#endif
76131 #include <linux/kallsyms.h>
76132 #include <linux/module.h>
76133 #include <linux/init.h>
76134 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76135
76136 static inline int is_kernel_inittext(unsigned long addr)
76137 {
76138 + if (system_state != SYSTEM_BOOTING)
76139 + return 0;
76140 +
76141 if (addr >= (unsigned long)_sinittext
76142 && addr <= (unsigned long)_einittext)
76143 return 1;
76144 return 0;
76145 }
76146
76147 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76148 +#ifdef CONFIG_MODULES
76149 +static inline int is_module_text(unsigned long addr)
76150 +{
76151 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76152 + return 1;
76153 +
76154 + addr = ktla_ktva(addr);
76155 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76156 +}
76157 +#else
76158 +static inline int is_module_text(unsigned long addr)
76159 +{
76160 + return 0;
76161 +}
76162 +#endif
76163 +#endif
76164 +
76165 static inline int is_kernel_text(unsigned long addr)
76166 {
76167 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76168 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76169
76170 static inline int is_kernel(unsigned long addr)
76171 {
76172 +
76173 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76174 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76175 + return 1;
76176 +
76177 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76178 +#else
76179 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76180 +#endif
76181 +
76182 return 1;
76183 return in_gate_area_no_mm(addr);
76184 }
76185
76186 static int is_ksym_addr(unsigned long addr)
76187 {
76188 +
76189 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76190 + if (is_module_text(addr))
76191 + return 0;
76192 +#endif
76193 +
76194 if (all_var)
76195 return is_kernel(addr);
76196
76197 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76198
76199 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76200 {
76201 - iter->name[0] = '\0';
76202 iter->nameoff = get_symbol_offset(new_pos);
76203 iter->pos = new_pos;
76204 }
76205 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
76206 {
76207 struct kallsym_iter *iter = m->private;
76208
76209 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76210 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76211 + return 0;
76212 +#endif
76213 +
76214 /* Some debugging symbols have no name. Ignore them. */
76215 if (!iter->name[0])
76216 return 0;
76217 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
76218 */
76219 type = iter->exported ? toupper(iter->type) :
76220 tolower(iter->type);
76221 +
76222 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
76223 type, iter->name, iter->module_name);
76224 } else
76225 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
76226 struct kallsym_iter *iter;
76227 int ret;
76228
76229 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
76230 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
76231 if (!iter)
76232 return -ENOMEM;
76233 reset_iter(iter, 0);
76234 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
76235 index e30ac0f..3528cac 100644
76236 --- a/kernel/kcmp.c
76237 +++ b/kernel/kcmp.c
76238 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
76239 struct task_struct *task1, *task2;
76240 int ret;
76241
76242 +#ifdef CONFIG_GRKERNSEC
76243 + return -ENOSYS;
76244 +#endif
76245 +
76246 rcu_read_lock();
76247
76248 /*
76249 diff --git a/kernel/kexec.c b/kernel/kexec.c
76250 index 59f7b55..4022f65 100644
76251 --- a/kernel/kexec.c
76252 +++ b/kernel/kexec.c
76253 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
76254 unsigned long flags)
76255 {
76256 struct compat_kexec_segment in;
76257 - struct kexec_segment out, __user *ksegments;
76258 + struct kexec_segment out;
76259 + struct kexec_segment __user *ksegments;
76260 unsigned long i, result;
76261
76262 /* Don't allow clients that don't understand the native
76263 diff --git a/kernel/kmod.c b/kernel/kmod.c
76264 index 8241906..d625f2c 100644
76265 --- a/kernel/kmod.c
76266 +++ b/kernel/kmod.c
76267 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76268 kfree(info->argv);
76269 }
76270
76271 -static int call_modprobe(char *module_name, int wait)
76272 +static int call_modprobe(char *module_name, char *module_param, int wait)
76273 {
76274 struct subprocess_info *info;
76275 static char *envp[] = {
76276 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
76277 NULL
76278 };
76279
76280 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76281 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76282 if (!argv)
76283 goto out;
76284
76285 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
76286 argv[1] = "-q";
76287 argv[2] = "--";
76288 argv[3] = module_name; /* check free_modprobe_argv() */
76289 - argv[4] = NULL;
76290 + argv[4] = module_param;
76291 + argv[5] = NULL;
76292
76293 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
76294 NULL, free_modprobe_argv, NULL);
76295 @@ -129,9 +130,8 @@ out:
76296 * If module auto-loading support is disabled then this function
76297 * becomes a no-operation.
76298 */
76299 -int __request_module(bool wait, const char *fmt, ...)
76300 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76301 {
76302 - va_list args;
76303 char module_name[MODULE_NAME_LEN];
76304 unsigned int max_modprobes;
76305 int ret;
76306 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
76307 */
76308 WARN_ON_ONCE(wait && current_is_async());
76309
76310 - va_start(args, fmt);
76311 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76312 - va_end(args);
76313 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76314 if (ret >= MODULE_NAME_LEN)
76315 return -ENAMETOOLONG;
76316
76317 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
76318 if (ret)
76319 return ret;
76320
76321 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76322 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76323 + /* hack to workaround consolekit/udisks stupidity */
76324 + read_lock(&tasklist_lock);
76325 + if (!strcmp(current->comm, "mount") &&
76326 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76327 + read_unlock(&tasklist_lock);
76328 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76329 + return -EPERM;
76330 + }
76331 + read_unlock(&tasklist_lock);
76332 + }
76333 +#endif
76334 +
76335 /* If modprobe needs a service that is in a module, we get a recursive
76336 * loop. Limit the number of running kmod threads to max_threads/2 or
76337 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76338 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
76339
76340 trace_module_request(module_name, wait, _RET_IP_);
76341
76342 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76343 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76344
76345 atomic_dec(&kmod_concurrent);
76346 return ret;
76347 }
76348 +
76349 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76350 +{
76351 + va_list args;
76352 + int ret;
76353 +
76354 + va_start(args, fmt);
76355 + ret = ____request_module(wait, module_param, fmt, args);
76356 + va_end(args);
76357 +
76358 + return ret;
76359 +}
76360 +
76361 +int __request_module(bool wait, const char *fmt, ...)
76362 +{
76363 + va_list args;
76364 + int ret;
76365 +
76366 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76367 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76368 + char module_param[MODULE_NAME_LEN];
76369 +
76370 + memset(module_param, 0, sizeof(module_param));
76371 +
76372 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76373 +
76374 + va_start(args, fmt);
76375 + ret = ____request_module(wait, module_param, fmt, args);
76376 + va_end(args);
76377 +
76378 + return ret;
76379 + }
76380 +#endif
76381 +
76382 + va_start(args, fmt);
76383 + ret = ____request_module(wait, NULL, fmt, args);
76384 + va_end(args);
76385 +
76386 + return ret;
76387 +}
76388 +
76389 EXPORT_SYMBOL(__request_module);
76390 #endif /* CONFIG_MODULES */
76391
76392 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
76393 *
76394 * Thus the __user pointer cast is valid here.
76395 */
76396 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76397 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76398
76399 /*
76400 * If ret is 0, either ____call_usermodehelper failed and the
76401 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
76402 static int proc_cap_handler(struct ctl_table *table, int write,
76403 void __user *buffer, size_t *lenp, loff_t *ppos)
76404 {
76405 - struct ctl_table t;
76406 + ctl_table_no_const t;
76407 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76408 kernel_cap_t new_cap;
76409 int err, i;
76410 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76411 index bddf3b2..07b90dd 100644
76412 --- a/kernel/kprobes.c
76413 +++ b/kernel/kprobes.c
76414 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76415 * kernel image and loaded module images reside. This is required
76416 * so x86_64 can correctly handle the %rip-relative fixups.
76417 */
76418 - kip->insns = module_alloc(PAGE_SIZE);
76419 + kip->insns = module_alloc_exec(PAGE_SIZE);
76420 if (!kip->insns) {
76421 kfree(kip);
76422 return NULL;
76423 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76424 */
76425 if (!list_is_singular(&kip->list)) {
76426 list_del(&kip->list);
76427 - module_free(NULL, kip->insns);
76428 + module_free_exec(NULL, kip->insns);
76429 kfree(kip);
76430 }
76431 return 1;
76432 @@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
76433 {
76434 int i, err = 0;
76435 unsigned long offset = 0, size = 0;
76436 - char *modname, namebuf[128];
76437 + char *modname, namebuf[KSYM_NAME_LEN];
76438 const char *symbol_name;
76439 void *addr;
76440 struct kprobe_blackpoint *kb;
76441 @@ -2168,11 +2168,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76442 kprobe_type = "k";
76443
76444 if (sym)
76445 - seq_printf(pi, "%p %s %s+0x%x %s ",
76446 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76447 p->addr, kprobe_type, sym, offset,
76448 (modname ? modname : " "));
76449 else
76450 - seq_printf(pi, "%p %s %p ",
76451 + seq_printf(pi, "%pK %s %pK ",
76452 p->addr, kprobe_type, p->addr);
76453
76454 if (!pp)
76455 @@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76456 const char *sym = NULL;
76457 unsigned int i = *(loff_t *) v;
76458 unsigned long offset = 0;
76459 - char *modname, namebuf[128];
76460 + char *modname, namebuf[KSYM_NAME_LEN];
76461
76462 head = &kprobe_table[i];
76463 preempt_disable();
76464 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76465 index 6ada93c..dce7d5d 100644
76466 --- a/kernel/ksysfs.c
76467 +++ b/kernel/ksysfs.c
76468 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76469 {
76470 if (count+1 > UEVENT_HELPER_PATH_LEN)
76471 return -ENOENT;
76472 + if (!capable(CAP_SYS_ADMIN))
76473 + return -EPERM;
76474 memcpy(uevent_helper, buf, count);
76475 uevent_helper[count] = '\0';
76476 if (count && uevent_helper[count-1] == '\n')
76477 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76478 return count;
76479 }
76480
76481 -static struct bin_attribute notes_attr = {
76482 +static bin_attribute_no_const notes_attr __read_only = {
76483 .attr = {
76484 .name = "notes",
76485 .mode = S_IRUGO,
76486 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76487 index 1f3186b..bb7dbc6 100644
76488 --- a/kernel/lockdep.c
76489 +++ b/kernel/lockdep.c
76490 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
76491 end = (unsigned long) &_end,
76492 addr = (unsigned long) obj;
76493
76494 +#ifdef CONFIG_PAX_KERNEXEC
76495 + start = ktla_ktva(start);
76496 +#endif
76497 +
76498 /*
76499 * static variable?
76500 */
76501 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76502 if (!static_obj(lock->key)) {
76503 debug_locks_off();
76504 printk("INFO: trying to register non-static key.\n");
76505 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76506 printk("the code is fine but needs lockdep annotation.\n");
76507 printk("turning off the locking correctness validator.\n");
76508 dump_stack();
76509 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76510 if (!class)
76511 return 0;
76512 }
76513 - atomic_inc((atomic_t *)&class->ops);
76514 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76515 if (very_verbose(class)) {
76516 printk("\nacquire class [%p] %s", class->key, class->name);
76517 if (class->name_version > 1)
76518 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76519 index b2c71c5..7b88d63 100644
76520 --- a/kernel/lockdep_proc.c
76521 +++ b/kernel/lockdep_proc.c
76522 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76523 return 0;
76524 }
76525
76526 - seq_printf(m, "%p", class->key);
76527 + seq_printf(m, "%pK", class->key);
76528 #ifdef CONFIG_DEBUG_LOCKDEP
76529 seq_printf(m, " OPS:%8ld", class->ops);
76530 #endif
76531 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76532
76533 list_for_each_entry(entry, &class->locks_after, entry) {
76534 if (entry->distance == 1) {
76535 - seq_printf(m, " -> [%p] ", entry->class->key);
76536 + seq_printf(m, " -> [%pK] ", entry->class->key);
76537 print_name(m, entry->class);
76538 seq_puts(m, "\n");
76539 }
76540 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76541 if (!class->key)
76542 continue;
76543
76544 - seq_printf(m, "[%p] ", class->key);
76545 + seq_printf(m, "[%pK] ", class->key);
76546 print_name(m, class);
76547 seq_puts(m, "\n");
76548 }
76549 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76550 if (!i)
76551 seq_line(m, '-', 40-namelen, namelen);
76552
76553 - snprintf(ip, sizeof(ip), "[<%p>]",
76554 + snprintf(ip, sizeof(ip), "[<%pK>]",
76555 (void *)class->contention_point[i]);
76556 seq_printf(m, "%40s %14lu %29s %pS\n",
76557 name, stats->contention_point[i],
76558 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76559 if (!i)
76560 seq_line(m, '-', 40-namelen, namelen);
76561
76562 - snprintf(ip, sizeof(ip), "[<%p>]",
76563 + snprintf(ip, sizeof(ip), "[<%pK>]",
76564 (void *)class->contending_point[i]);
76565 seq_printf(m, "%40s %14lu %29s %pS\n",
76566 name, stats->contending_point[i],
76567 diff --git a/kernel/module.c b/kernel/module.c
76568 index cab4bce..2025a6e 100644
76569 --- a/kernel/module.c
76570 +++ b/kernel/module.c
76571 @@ -61,6 +61,7 @@
76572 #include <linux/pfn.h>
76573 #include <linux/bsearch.h>
76574 #include <linux/fips.h>
76575 +#include <linux/grsecurity.h>
76576 #include <uapi/linux/module.h>
76577 #include "module-internal.h"
76578
76579 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76580
76581 /* Bounds of module allocation, for speeding __module_address.
76582 * Protected by module_mutex. */
76583 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76584 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76585 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76586
76587 int register_module_notifier(struct notifier_block * nb)
76588 {
76589 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76590 return true;
76591
76592 list_for_each_entry_rcu(mod, &modules, list) {
76593 - struct symsearch arr[] = {
76594 + struct symsearch modarr[] = {
76595 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76596 NOT_GPL_ONLY, false },
76597 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76598 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76599 if (mod->state == MODULE_STATE_UNFORMED)
76600 continue;
76601
76602 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76603 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76604 return true;
76605 }
76606 return false;
76607 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76608 static int percpu_modalloc(struct module *mod,
76609 unsigned long size, unsigned long align)
76610 {
76611 - if (align > PAGE_SIZE) {
76612 + if (align-1 >= PAGE_SIZE) {
76613 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76614 mod->name, align, PAGE_SIZE);
76615 align = PAGE_SIZE;
76616 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76617 static ssize_t show_coresize(struct module_attribute *mattr,
76618 struct module_kobject *mk, char *buffer)
76619 {
76620 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76621 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76622 }
76623
76624 static struct module_attribute modinfo_coresize =
76625 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76626 static ssize_t show_initsize(struct module_attribute *mattr,
76627 struct module_kobject *mk, char *buffer)
76628 {
76629 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76630 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76631 }
76632
76633 static struct module_attribute modinfo_initsize =
76634 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
76635 */
76636 #ifdef CONFIG_SYSFS
76637
76638 -#ifdef CONFIG_KALLSYMS
76639 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76640 static inline bool sect_empty(const Elf_Shdr *sect)
76641 {
76642 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76643 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76644 {
76645 unsigned int notes, loaded, i;
76646 struct module_notes_attrs *notes_attrs;
76647 - struct bin_attribute *nattr;
76648 + bin_attribute_no_const *nattr;
76649
76650 /* failed to create section attributes, so can't create notes */
76651 if (!mod->sect_attrs)
76652 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
76653 static int module_add_modinfo_attrs(struct module *mod)
76654 {
76655 struct module_attribute *attr;
76656 - struct module_attribute *temp_attr;
76657 + module_attribute_no_const *temp_attr;
76658 int error = 0;
76659 int i;
76660
76661 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
76662
76663 static void unset_module_core_ro_nx(struct module *mod)
76664 {
76665 - set_page_attributes(mod->module_core + mod->core_text_size,
76666 - mod->module_core + mod->core_size,
76667 + set_page_attributes(mod->module_core_rw,
76668 + mod->module_core_rw + mod->core_size_rw,
76669 set_memory_x);
76670 - set_page_attributes(mod->module_core,
76671 - mod->module_core + mod->core_ro_size,
76672 + set_page_attributes(mod->module_core_rx,
76673 + mod->module_core_rx + mod->core_size_rx,
76674 set_memory_rw);
76675 }
76676
76677 static void unset_module_init_ro_nx(struct module *mod)
76678 {
76679 - set_page_attributes(mod->module_init + mod->init_text_size,
76680 - mod->module_init + mod->init_size,
76681 + set_page_attributes(mod->module_init_rw,
76682 + mod->module_init_rw + mod->init_size_rw,
76683 set_memory_x);
76684 - set_page_attributes(mod->module_init,
76685 - mod->module_init + mod->init_ro_size,
76686 + set_page_attributes(mod->module_init_rx,
76687 + mod->module_init_rx + mod->init_size_rx,
76688 set_memory_rw);
76689 }
76690
76691 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
76692 list_for_each_entry_rcu(mod, &modules, list) {
76693 if (mod->state == MODULE_STATE_UNFORMED)
76694 continue;
76695 - if ((mod->module_core) && (mod->core_text_size)) {
76696 - set_page_attributes(mod->module_core,
76697 - mod->module_core + mod->core_text_size,
76698 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76699 + set_page_attributes(mod->module_core_rx,
76700 + mod->module_core_rx + mod->core_size_rx,
76701 set_memory_rw);
76702 }
76703 - if ((mod->module_init) && (mod->init_text_size)) {
76704 - set_page_attributes(mod->module_init,
76705 - mod->module_init + mod->init_text_size,
76706 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76707 + set_page_attributes(mod->module_init_rx,
76708 + mod->module_init_rx + mod->init_size_rx,
76709 set_memory_rw);
76710 }
76711 }
76712 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
76713 list_for_each_entry_rcu(mod, &modules, list) {
76714 if (mod->state == MODULE_STATE_UNFORMED)
76715 continue;
76716 - if ((mod->module_core) && (mod->core_text_size)) {
76717 - set_page_attributes(mod->module_core,
76718 - mod->module_core + mod->core_text_size,
76719 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76720 + set_page_attributes(mod->module_core_rx,
76721 + mod->module_core_rx + mod->core_size_rx,
76722 set_memory_ro);
76723 }
76724 - if ((mod->module_init) && (mod->init_text_size)) {
76725 - set_page_attributes(mod->module_init,
76726 - mod->module_init + mod->init_text_size,
76727 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76728 + set_page_attributes(mod->module_init_rx,
76729 + mod->module_init_rx + mod->init_size_rx,
76730 set_memory_ro);
76731 }
76732 }
76733 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
76734
76735 /* This may be NULL, but that's OK */
76736 unset_module_init_ro_nx(mod);
76737 - module_free(mod, mod->module_init);
76738 + module_free(mod, mod->module_init_rw);
76739 + module_free_exec(mod, mod->module_init_rx);
76740 kfree(mod->args);
76741 percpu_modfree(mod);
76742
76743 /* Free lock-classes: */
76744 - lockdep_free_key_range(mod->module_core, mod->core_size);
76745 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76746 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76747
76748 /* Finally, free the core (containing the module structure) */
76749 unset_module_core_ro_nx(mod);
76750 - module_free(mod, mod->module_core);
76751 + module_free_exec(mod, mod->module_core_rx);
76752 + module_free(mod, mod->module_core_rw);
76753
76754 #ifdef CONFIG_MPU
76755 update_protections(current->mm);
76756 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76757 int ret = 0;
76758 const struct kernel_symbol *ksym;
76759
76760 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76761 + int is_fs_load = 0;
76762 + int register_filesystem_found = 0;
76763 + char *p;
76764 +
76765 + p = strstr(mod->args, "grsec_modharden_fs");
76766 + if (p) {
76767 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76768 + /* copy \0 as well */
76769 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76770 + is_fs_load = 1;
76771 + }
76772 +#endif
76773 +
76774 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76775 const char *name = info->strtab + sym[i].st_name;
76776
76777 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76778 + /* it's a real shame this will never get ripped and copied
76779 + upstream! ;(
76780 + */
76781 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76782 + register_filesystem_found = 1;
76783 +#endif
76784 +
76785 switch (sym[i].st_shndx) {
76786 case SHN_COMMON:
76787 /* We compiled with -fno-common. These are not
76788 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76789 ksym = resolve_symbol_wait(mod, info, name);
76790 /* Ok if resolved. */
76791 if (ksym && !IS_ERR(ksym)) {
76792 + pax_open_kernel();
76793 sym[i].st_value = ksym->value;
76794 + pax_close_kernel();
76795 break;
76796 }
76797
76798 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76799 secbase = (unsigned long)mod_percpu(mod);
76800 else
76801 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76802 + pax_open_kernel();
76803 sym[i].st_value += secbase;
76804 + pax_close_kernel();
76805 break;
76806 }
76807 }
76808
76809 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76810 + if (is_fs_load && !register_filesystem_found) {
76811 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76812 + ret = -EPERM;
76813 + }
76814 +#endif
76815 +
76816 return ret;
76817 }
76818
76819 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76820 || s->sh_entsize != ~0UL
76821 || strstarts(sname, ".init"))
76822 continue;
76823 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76824 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76825 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76826 + else
76827 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76828 pr_debug("\t%s\n", sname);
76829 }
76830 - switch (m) {
76831 - case 0: /* executable */
76832 - mod->core_size = debug_align(mod->core_size);
76833 - mod->core_text_size = mod->core_size;
76834 - break;
76835 - case 1: /* RO: text and ro-data */
76836 - mod->core_size = debug_align(mod->core_size);
76837 - mod->core_ro_size = mod->core_size;
76838 - break;
76839 - case 3: /* whole core */
76840 - mod->core_size = debug_align(mod->core_size);
76841 - break;
76842 - }
76843 }
76844
76845 pr_debug("Init section allocation order:\n");
76846 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76847 || s->sh_entsize != ~0UL
76848 || !strstarts(sname, ".init"))
76849 continue;
76850 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76851 - | INIT_OFFSET_MASK);
76852 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76853 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76854 + else
76855 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76856 + s->sh_entsize |= INIT_OFFSET_MASK;
76857 pr_debug("\t%s\n", sname);
76858 }
76859 - switch (m) {
76860 - case 0: /* executable */
76861 - mod->init_size = debug_align(mod->init_size);
76862 - mod->init_text_size = mod->init_size;
76863 - break;
76864 - case 1: /* RO: text and ro-data */
76865 - mod->init_size = debug_align(mod->init_size);
76866 - mod->init_ro_size = mod->init_size;
76867 - break;
76868 - case 3: /* whole init */
76869 - mod->init_size = debug_align(mod->init_size);
76870 - break;
76871 - }
76872 }
76873 }
76874
76875 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76876
76877 /* Put symbol section at end of init part of module. */
76878 symsect->sh_flags |= SHF_ALLOC;
76879 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76880 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76881 info->index.sym) | INIT_OFFSET_MASK;
76882 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76883
76884 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76885 }
76886
76887 /* Append room for core symbols at end of core part. */
76888 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76889 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76890 - mod->core_size += strtab_size;
76891 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76892 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76893 + mod->core_size_rx += strtab_size;
76894
76895 /* Put string table section at end of init part of module. */
76896 strsect->sh_flags |= SHF_ALLOC;
76897 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76898 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76899 info->index.str) | INIT_OFFSET_MASK;
76900 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76901 }
76902 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76903 /* Make sure we get permanent strtab: don't use info->strtab. */
76904 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76905
76906 + pax_open_kernel();
76907 +
76908 /* Set types up while we still have access to sections. */
76909 for (i = 0; i < mod->num_symtab; i++)
76910 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76911
76912 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76913 - mod->core_strtab = s = mod->module_core + info->stroffs;
76914 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76915 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76916 src = mod->symtab;
76917 for (ndst = i = 0; i < mod->num_symtab; i++) {
76918 if (i == 0 ||
76919 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76920 }
76921 }
76922 mod->core_num_syms = ndst;
76923 +
76924 + pax_close_kernel();
76925 }
76926 #else
76927 static inline void layout_symtab(struct module *mod, struct load_info *info)
76928 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
76929 return vmalloc_exec(size);
76930 }
76931
76932 -static void *module_alloc_update_bounds(unsigned long size)
76933 +static void *module_alloc_update_bounds_rw(unsigned long size)
76934 {
76935 void *ret = module_alloc(size);
76936
76937 if (ret) {
76938 mutex_lock(&module_mutex);
76939 /* Update module bounds. */
76940 - if ((unsigned long)ret < module_addr_min)
76941 - module_addr_min = (unsigned long)ret;
76942 - if ((unsigned long)ret + size > module_addr_max)
76943 - module_addr_max = (unsigned long)ret + size;
76944 + if ((unsigned long)ret < module_addr_min_rw)
76945 + module_addr_min_rw = (unsigned long)ret;
76946 + if ((unsigned long)ret + size > module_addr_max_rw)
76947 + module_addr_max_rw = (unsigned long)ret + size;
76948 + mutex_unlock(&module_mutex);
76949 + }
76950 + return ret;
76951 +}
76952 +
76953 +static void *module_alloc_update_bounds_rx(unsigned long size)
76954 +{
76955 + void *ret = module_alloc_exec(size);
76956 +
76957 + if (ret) {
76958 + mutex_lock(&module_mutex);
76959 + /* Update module bounds. */
76960 + if ((unsigned long)ret < module_addr_min_rx)
76961 + module_addr_min_rx = (unsigned long)ret;
76962 + if ((unsigned long)ret + size > module_addr_max_rx)
76963 + module_addr_max_rx = (unsigned long)ret + size;
76964 mutex_unlock(&module_mutex);
76965 }
76966 return ret;
76967 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76968 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76969 {
76970 const char *modmagic = get_modinfo(info, "vermagic");
76971 + const char *license = get_modinfo(info, "license");
76972 int err;
76973
76974 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76975 + if (!license || !license_is_gpl_compatible(license))
76976 + return -ENOEXEC;
76977 +#endif
76978 +
76979 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76980 modmagic = NULL;
76981
76982 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76983 }
76984
76985 /* Set up license info based on the info section */
76986 - set_license(mod, get_modinfo(info, "license"));
76987 + set_license(mod, license);
76988
76989 return 0;
76990 }
76991 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
76992 void *ptr;
76993
76994 /* Do the allocs. */
76995 - ptr = module_alloc_update_bounds(mod->core_size);
76996 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76997 /*
76998 * The pointer to this block is stored in the module structure
76999 * which is inside the block. Just mark it as not being a
77000 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
77001 if (!ptr)
77002 return -ENOMEM;
77003
77004 - memset(ptr, 0, mod->core_size);
77005 - mod->module_core = ptr;
77006 + memset(ptr, 0, mod->core_size_rw);
77007 + mod->module_core_rw = ptr;
77008
77009 - if (mod->init_size) {
77010 - ptr = module_alloc_update_bounds(mod->init_size);
77011 + if (mod->init_size_rw) {
77012 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
77013 /*
77014 * The pointer to this block is stored in the module structure
77015 * which is inside the block. This block doesn't need to be
77016 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
77017 */
77018 kmemleak_ignore(ptr);
77019 if (!ptr) {
77020 - module_free(mod, mod->module_core);
77021 + module_free(mod, mod->module_core_rw);
77022 return -ENOMEM;
77023 }
77024 - memset(ptr, 0, mod->init_size);
77025 - mod->module_init = ptr;
77026 + memset(ptr, 0, mod->init_size_rw);
77027 + mod->module_init_rw = ptr;
77028 } else
77029 - mod->module_init = NULL;
77030 + mod->module_init_rw = NULL;
77031 +
77032 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
77033 + kmemleak_not_leak(ptr);
77034 + if (!ptr) {
77035 + if (mod->module_init_rw)
77036 + module_free(mod, mod->module_init_rw);
77037 + module_free(mod, mod->module_core_rw);
77038 + return -ENOMEM;
77039 + }
77040 +
77041 + pax_open_kernel();
77042 + memset(ptr, 0, mod->core_size_rx);
77043 + pax_close_kernel();
77044 + mod->module_core_rx = ptr;
77045 +
77046 + if (mod->init_size_rx) {
77047 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
77048 + kmemleak_ignore(ptr);
77049 + if (!ptr && mod->init_size_rx) {
77050 + module_free_exec(mod, mod->module_core_rx);
77051 + if (mod->module_init_rw)
77052 + module_free(mod, mod->module_init_rw);
77053 + module_free(mod, mod->module_core_rw);
77054 + return -ENOMEM;
77055 + }
77056 +
77057 + pax_open_kernel();
77058 + memset(ptr, 0, mod->init_size_rx);
77059 + pax_close_kernel();
77060 + mod->module_init_rx = ptr;
77061 + } else
77062 + mod->module_init_rx = NULL;
77063
77064 /* Transfer each section which specifies SHF_ALLOC */
77065 pr_debug("final section addresses:\n");
77066 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
77067 if (!(shdr->sh_flags & SHF_ALLOC))
77068 continue;
77069
77070 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
77071 - dest = mod->module_init
77072 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77073 - else
77074 - dest = mod->module_core + shdr->sh_entsize;
77075 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
77076 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77077 + dest = mod->module_init_rw
77078 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77079 + else
77080 + dest = mod->module_init_rx
77081 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77082 + } else {
77083 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77084 + dest = mod->module_core_rw + shdr->sh_entsize;
77085 + else
77086 + dest = mod->module_core_rx + shdr->sh_entsize;
77087 + }
77088 +
77089 + if (shdr->sh_type != SHT_NOBITS) {
77090 +
77091 +#ifdef CONFIG_PAX_KERNEXEC
77092 +#ifdef CONFIG_X86_64
77093 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
77094 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
77095 +#endif
77096 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
77097 + pax_open_kernel();
77098 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77099 + pax_close_kernel();
77100 + } else
77101 +#endif
77102
77103 - if (shdr->sh_type != SHT_NOBITS)
77104 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77105 + }
77106 /* Update sh_addr to point to copy in image. */
77107 - shdr->sh_addr = (unsigned long)dest;
77108 +
77109 +#ifdef CONFIG_PAX_KERNEXEC
77110 + if (shdr->sh_flags & SHF_EXECINSTR)
77111 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
77112 + else
77113 +#endif
77114 +
77115 + shdr->sh_addr = (unsigned long)dest;
77116 pr_debug("\t0x%lx %s\n",
77117 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
77118 }
77119 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
77120 * Do it before processing of module parameters, so the module
77121 * can provide parameter accessor functions of its own.
77122 */
77123 - if (mod->module_init)
77124 - flush_icache_range((unsigned long)mod->module_init,
77125 - (unsigned long)mod->module_init
77126 - + mod->init_size);
77127 - flush_icache_range((unsigned long)mod->module_core,
77128 - (unsigned long)mod->module_core + mod->core_size);
77129 + if (mod->module_init_rx)
77130 + flush_icache_range((unsigned long)mod->module_init_rx,
77131 + (unsigned long)mod->module_init_rx
77132 + + mod->init_size_rx);
77133 + flush_icache_range((unsigned long)mod->module_core_rx,
77134 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77135
77136 set_fs(old_fs);
77137 }
77138 @@ -2980,8 +3085,10 @@ out:
77139 static void module_deallocate(struct module *mod, struct load_info *info)
77140 {
77141 percpu_modfree(mod);
77142 - module_free(mod, mod->module_init);
77143 - module_free(mod, mod->module_core);
77144 + module_free_exec(mod, mod->module_init_rx);
77145 + module_free_exec(mod, mod->module_core_rx);
77146 + module_free(mod, mod->module_init_rw);
77147 + module_free(mod, mod->module_core_rw);
77148 }
77149
77150 int __weak module_finalize(const Elf_Ehdr *hdr,
77151 @@ -2994,7 +3101,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77152 static int post_relocation(struct module *mod, const struct load_info *info)
77153 {
77154 /* Sort exception table now relocations are done. */
77155 + pax_open_kernel();
77156 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77157 + pax_close_kernel();
77158
77159 /* Copy relocated percpu area over. */
77160 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77161 @@ -3048,16 +3157,16 @@ static int do_init_module(struct module *mod)
77162 MODULE_STATE_COMING, mod);
77163
77164 /* Set RO and NX regions for core */
77165 - set_section_ro_nx(mod->module_core,
77166 - mod->core_text_size,
77167 - mod->core_ro_size,
77168 - mod->core_size);
77169 + set_section_ro_nx(mod->module_core_rx,
77170 + mod->core_size_rx,
77171 + mod->core_size_rx,
77172 + mod->core_size_rx);
77173
77174 /* Set RO and NX regions for init */
77175 - set_section_ro_nx(mod->module_init,
77176 - mod->init_text_size,
77177 - mod->init_ro_size,
77178 - mod->init_size);
77179 + set_section_ro_nx(mod->module_init_rx,
77180 + mod->init_size_rx,
77181 + mod->init_size_rx,
77182 + mod->init_size_rx);
77183
77184 do_mod_ctors(mod);
77185 /* Start the module */
77186 @@ -3119,11 +3228,12 @@ static int do_init_module(struct module *mod)
77187 mod->strtab = mod->core_strtab;
77188 #endif
77189 unset_module_init_ro_nx(mod);
77190 - module_free(mod, mod->module_init);
77191 - mod->module_init = NULL;
77192 - mod->init_size = 0;
77193 - mod->init_ro_size = 0;
77194 - mod->init_text_size = 0;
77195 + module_free(mod, mod->module_init_rw);
77196 + module_free_exec(mod, mod->module_init_rx);
77197 + mod->module_init_rw = NULL;
77198 + mod->module_init_rx = NULL;
77199 + mod->init_size_rw = 0;
77200 + mod->init_size_rx = 0;
77201 mutex_unlock(&module_mutex);
77202 wake_up_all(&module_wq);
77203
77204 @@ -3250,9 +3360,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
77205 if (err)
77206 goto free_unload;
77207
77208 + /* Now copy in args */
77209 + mod->args = strndup_user(uargs, ~0UL >> 1);
77210 + if (IS_ERR(mod->args)) {
77211 + err = PTR_ERR(mod->args);
77212 + goto free_unload;
77213 + }
77214 +
77215 /* Set up MODINFO_ATTR fields */
77216 setup_modinfo(mod, info);
77217
77218 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77219 + {
77220 + char *p, *p2;
77221 +
77222 + if (strstr(mod->args, "grsec_modharden_netdev")) {
77223 + 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);
77224 + err = -EPERM;
77225 + goto free_modinfo;
77226 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
77227 + p += sizeof("grsec_modharden_normal") - 1;
77228 + p2 = strstr(p, "_");
77229 + if (p2) {
77230 + *p2 = '\0';
77231 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
77232 + *p2 = '_';
77233 + }
77234 + err = -EPERM;
77235 + goto free_modinfo;
77236 + }
77237 + }
77238 +#endif
77239 +
77240 /* Fix up syms, so that st_value is a pointer to location. */
77241 err = simplify_symbols(mod, info);
77242 if (err < 0)
77243 @@ -3268,13 +3407,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
77244
77245 flush_module_icache(mod);
77246
77247 - /* Now copy in args */
77248 - mod->args = strndup_user(uargs, ~0UL >> 1);
77249 - if (IS_ERR(mod->args)) {
77250 - err = PTR_ERR(mod->args);
77251 - goto free_arch_cleanup;
77252 - }
77253 -
77254 dynamic_debug_setup(info->debug, info->num_debug);
77255
77256 /* Finally it's fully formed, ready to start executing. */
77257 @@ -3309,11 +3441,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
77258 ddebug_cleanup:
77259 dynamic_debug_remove(info->debug);
77260 synchronize_sched();
77261 - kfree(mod->args);
77262 - free_arch_cleanup:
77263 module_arch_cleanup(mod);
77264 free_modinfo:
77265 free_modinfo(mod);
77266 + kfree(mod->args);
77267 free_unload:
77268 module_unload_free(mod);
77269 unlink_mod:
77270 @@ -3396,10 +3527,16 @@ static const char *get_ksymbol(struct module *mod,
77271 unsigned long nextval;
77272
77273 /* At worse, next value is at end of module */
77274 - if (within_module_init(addr, mod))
77275 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77276 + if (within_module_init_rx(addr, mod))
77277 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77278 + else if (within_module_init_rw(addr, mod))
77279 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77280 + else if (within_module_core_rx(addr, mod))
77281 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77282 + else if (within_module_core_rw(addr, mod))
77283 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77284 else
77285 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77286 + return NULL;
77287
77288 /* Scan for closest preceding symbol, and next symbol. (ELF
77289 starts real symbols at 1). */
77290 @@ -3652,7 +3789,7 @@ static int m_show(struct seq_file *m, void *p)
77291 return 0;
77292
77293 seq_printf(m, "%s %u",
77294 - mod->name, mod->init_size + mod->core_size);
77295 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77296 print_unload_info(m, mod);
77297
77298 /* Informative for users. */
77299 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
77300 mod->state == MODULE_STATE_COMING ? "Loading":
77301 "Live");
77302 /* Used by oprofile and other similar tools. */
77303 - seq_printf(m, " 0x%pK", mod->module_core);
77304 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77305
77306 /* Taints info */
77307 if (mod->taints)
77308 @@ -3697,7 +3834,17 @@ static const struct file_operations proc_modules_operations = {
77309
77310 static int __init proc_modules_init(void)
77311 {
77312 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77313 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77314 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77315 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77316 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77317 +#else
77318 proc_create("modules", 0, NULL, &proc_modules_operations);
77319 +#endif
77320 +#else
77321 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77322 +#endif
77323 return 0;
77324 }
77325 module_init(proc_modules_init);
77326 @@ -3758,14 +3905,14 @@ struct module *__module_address(unsigned long addr)
77327 {
77328 struct module *mod;
77329
77330 - if (addr < module_addr_min || addr > module_addr_max)
77331 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77332 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77333 return NULL;
77334
77335 list_for_each_entry_rcu(mod, &modules, list) {
77336 if (mod->state == MODULE_STATE_UNFORMED)
77337 continue;
77338 - if (within_module_core(addr, mod)
77339 - || within_module_init(addr, mod))
77340 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77341 return mod;
77342 }
77343 return NULL;
77344 @@ -3800,11 +3947,20 @@ bool is_module_text_address(unsigned long addr)
77345 */
77346 struct module *__module_text_address(unsigned long addr)
77347 {
77348 - struct module *mod = __module_address(addr);
77349 + struct module *mod;
77350 +
77351 +#ifdef CONFIG_X86_32
77352 + addr = ktla_ktva(addr);
77353 +#endif
77354 +
77355 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77356 + return NULL;
77357 +
77358 + mod = __module_address(addr);
77359 +
77360 if (mod) {
77361 /* Make sure it's within the text section. */
77362 - if (!within(addr, mod->module_init, mod->init_text_size)
77363 - && !within(addr, mod->module_core, mod->core_text_size))
77364 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77365 mod = NULL;
77366 }
77367 return mod;
77368 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77369 index 7e3443f..b2a1e6b 100644
77370 --- a/kernel/mutex-debug.c
77371 +++ b/kernel/mutex-debug.c
77372 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77373 }
77374
77375 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77376 - struct thread_info *ti)
77377 + struct task_struct *task)
77378 {
77379 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77380
77381 /* Mark the current thread as blocked on the lock: */
77382 - ti->task->blocked_on = waiter;
77383 + task->blocked_on = waiter;
77384 }
77385
77386 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77387 - struct thread_info *ti)
77388 + struct task_struct *task)
77389 {
77390 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77391 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77392 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77393 - ti->task->blocked_on = NULL;
77394 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77395 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77396 + task->blocked_on = NULL;
77397
77398 list_del_init(&waiter->list);
77399 waiter->task = NULL;
77400 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77401 index 0799fd3..d06ae3b 100644
77402 --- a/kernel/mutex-debug.h
77403 +++ b/kernel/mutex-debug.h
77404 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77405 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77406 extern void debug_mutex_add_waiter(struct mutex *lock,
77407 struct mutex_waiter *waiter,
77408 - struct thread_info *ti);
77409 + struct task_struct *task);
77410 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77411 - struct thread_info *ti);
77412 + struct task_struct *task);
77413 extern void debug_mutex_unlock(struct mutex *lock);
77414 extern void debug_mutex_init(struct mutex *lock, const char *name,
77415 struct lock_class_key *key);
77416 diff --git a/kernel/mutex.c b/kernel/mutex.c
77417 index ad53a66..f1bf8bc 100644
77418 --- a/kernel/mutex.c
77419 +++ b/kernel/mutex.c
77420 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
77421 node->locked = 1;
77422 return;
77423 }
77424 - ACCESS_ONCE(prev->next) = node;
77425 + ACCESS_ONCE_RW(prev->next) = node;
77426 smp_wmb();
77427 /* Wait until the lock holder passes the lock down */
77428 while (!ACCESS_ONCE(node->locked))
77429 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
77430 while (!(next = ACCESS_ONCE(node->next)))
77431 arch_mutex_cpu_relax();
77432 }
77433 - ACCESS_ONCE(next->locked) = 1;
77434 + ACCESS_ONCE_RW(next->locked) = 1;
77435 smp_wmb();
77436 }
77437
77438 @@ -341,7 +341,7 @@ slowpath:
77439 spin_lock_mutex(&lock->wait_lock, flags);
77440
77441 debug_mutex_lock_common(lock, &waiter);
77442 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77443 + debug_mutex_add_waiter(lock, &waiter, task);
77444
77445 /* add waiting tasks to the end of the waitqueue (FIFO): */
77446 list_add_tail(&waiter.list, &lock->wait_list);
77447 @@ -371,8 +371,7 @@ slowpath:
77448 * TASK_UNINTERRUPTIBLE case.)
77449 */
77450 if (unlikely(signal_pending_state(state, task))) {
77451 - mutex_remove_waiter(lock, &waiter,
77452 - task_thread_info(task));
77453 + mutex_remove_waiter(lock, &waiter, task);
77454 mutex_release(&lock->dep_map, 1, ip);
77455 spin_unlock_mutex(&lock->wait_lock, flags);
77456
77457 @@ -391,7 +390,7 @@ slowpath:
77458 done:
77459 lock_acquired(&lock->dep_map, ip);
77460 /* got the lock - rejoice! */
77461 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77462 + mutex_remove_waiter(lock, &waiter, task);
77463 mutex_set_owner(lock);
77464
77465 /* set it to 0 if there are no waiters left: */
77466 diff --git a/kernel/notifier.c b/kernel/notifier.c
77467 index 2d5cc4c..d9ea600 100644
77468 --- a/kernel/notifier.c
77469 +++ b/kernel/notifier.c
77470 @@ -5,6 +5,7 @@
77471 #include <linux/rcupdate.h>
77472 #include <linux/vmalloc.h>
77473 #include <linux/reboot.h>
77474 +#include <linux/mm.h>
77475
77476 /*
77477 * Notifier list for kernel code which wants to be called
77478 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77479 while ((*nl) != NULL) {
77480 if (n->priority > (*nl)->priority)
77481 break;
77482 - nl = &((*nl)->next);
77483 + nl = (struct notifier_block **)&((*nl)->next);
77484 }
77485 - n->next = *nl;
77486 + pax_open_kernel();
77487 + *(const void **)&n->next = *nl;
77488 rcu_assign_pointer(*nl, n);
77489 + pax_close_kernel();
77490 return 0;
77491 }
77492
77493 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77494 return 0;
77495 if (n->priority > (*nl)->priority)
77496 break;
77497 - nl = &((*nl)->next);
77498 + nl = (struct notifier_block **)&((*nl)->next);
77499 }
77500 - n->next = *nl;
77501 + pax_open_kernel();
77502 + *(const void **)&n->next = *nl;
77503 rcu_assign_pointer(*nl, n);
77504 + pax_close_kernel();
77505 return 0;
77506 }
77507
77508 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77509 {
77510 while ((*nl) != NULL) {
77511 if ((*nl) == n) {
77512 + pax_open_kernel();
77513 rcu_assign_pointer(*nl, n->next);
77514 + pax_close_kernel();
77515 return 0;
77516 }
77517 - nl = &((*nl)->next);
77518 + nl = (struct notifier_block **)&((*nl)->next);
77519 }
77520 return -ENOENT;
77521 }
77522 diff --git a/kernel/panic.c b/kernel/panic.c
77523 index 167ec09..0dda5f9 100644
77524 --- a/kernel/panic.c
77525 +++ b/kernel/panic.c
77526 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77527 unsigned taint, struct slowpath_args *args)
77528 {
77529 printk(KERN_WARNING "------------[ cut here ]------------\n");
77530 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77531 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77532
77533 if (args)
77534 vprintk(args->fmt, args->args);
77535 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77536 */
77537 void __stack_chk_fail(void)
77538 {
77539 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77540 + dump_stack();
77541 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77542 __builtin_return_address(0));
77543 }
77544 EXPORT_SYMBOL(__stack_chk_fail);
77545 diff --git a/kernel/pid.c b/kernel/pid.c
77546 index 0db3e79..95b9dc2 100644
77547 --- a/kernel/pid.c
77548 +++ b/kernel/pid.c
77549 @@ -33,6 +33,7 @@
77550 #include <linux/rculist.h>
77551 #include <linux/bootmem.h>
77552 #include <linux/hash.h>
77553 +#include <linux/security.h>
77554 #include <linux/pid_namespace.h>
77555 #include <linux/init_task.h>
77556 #include <linux/syscalls.h>
77557 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77558
77559 int pid_max = PID_MAX_DEFAULT;
77560
77561 -#define RESERVED_PIDS 300
77562 +#define RESERVED_PIDS 500
77563
77564 int pid_max_min = RESERVED_PIDS + 1;
77565 int pid_max_max = PID_MAX_LIMIT;
77566 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
77567 */
77568 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77569 {
77570 + struct task_struct *task;
77571 +
77572 rcu_lockdep_assert(rcu_read_lock_held(),
77573 "find_task_by_pid_ns() needs rcu_read_lock()"
77574 " protection");
77575 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77576 +
77577 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77578 +
77579 + if (gr_pid_is_chrooted(task))
77580 + return NULL;
77581 +
77582 + return task;
77583 }
77584
77585 struct task_struct *find_task_by_vpid(pid_t vnr)
77586 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77587 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77588 }
77589
77590 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77591 +{
77592 + rcu_lockdep_assert(rcu_read_lock_held(),
77593 + "find_task_by_pid_ns() needs rcu_read_lock()"
77594 + " protection");
77595 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77596 +}
77597 +
77598 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77599 {
77600 struct pid *pid;
77601 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77602 index 6917e8e..9909aeb 100644
77603 --- a/kernel/pid_namespace.c
77604 +++ b/kernel/pid_namespace.c
77605 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77606 void __user *buffer, size_t *lenp, loff_t *ppos)
77607 {
77608 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77609 - struct ctl_table tmp = *table;
77610 + ctl_table_no_const tmp = *table;
77611
77612 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77613 return -EPERM;
77614 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77615 index 42670e9..8719c2f 100644
77616 --- a/kernel/posix-cpu-timers.c
77617 +++ b/kernel/posix-cpu-timers.c
77618 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
77619
77620 static __init int init_posix_cpu_timers(void)
77621 {
77622 - struct k_clock process = {
77623 + static struct k_clock process = {
77624 .clock_getres = process_cpu_clock_getres,
77625 .clock_get = process_cpu_clock_get,
77626 .timer_create = process_cpu_timer_create,
77627 .nsleep = process_cpu_nsleep,
77628 .nsleep_restart = process_cpu_nsleep_restart,
77629 };
77630 - struct k_clock thread = {
77631 + static struct k_clock thread = {
77632 .clock_getres = thread_cpu_clock_getres,
77633 .clock_get = thread_cpu_clock_get,
77634 .timer_create = thread_cpu_timer_create,
77635 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77636 index 424c2d4..a9194f7 100644
77637 --- a/kernel/posix-timers.c
77638 +++ b/kernel/posix-timers.c
77639 @@ -43,6 +43,7 @@
77640 #include <linux/hash.h>
77641 #include <linux/posix-clock.h>
77642 #include <linux/posix-timers.h>
77643 +#include <linux/grsecurity.h>
77644 #include <linux/syscalls.h>
77645 #include <linux/wait.h>
77646 #include <linux/workqueue.h>
77647 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
77648 * which we beg off on and pass to do_sys_settimeofday().
77649 */
77650
77651 -static struct k_clock posix_clocks[MAX_CLOCKS];
77652 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77653
77654 /*
77655 * These ones are defined below.
77656 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
77657 */
77658 static __init int init_posix_timers(void)
77659 {
77660 - struct k_clock clock_realtime = {
77661 + static struct k_clock clock_realtime = {
77662 .clock_getres = hrtimer_get_res,
77663 .clock_get = posix_clock_realtime_get,
77664 .clock_set = posix_clock_realtime_set,
77665 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
77666 .timer_get = common_timer_get,
77667 .timer_del = common_timer_del,
77668 };
77669 - struct k_clock clock_monotonic = {
77670 + static struct k_clock clock_monotonic = {
77671 .clock_getres = hrtimer_get_res,
77672 .clock_get = posix_ktime_get_ts,
77673 .nsleep = common_nsleep,
77674 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
77675 .timer_get = common_timer_get,
77676 .timer_del = common_timer_del,
77677 };
77678 - struct k_clock clock_monotonic_raw = {
77679 + static struct k_clock clock_monotonic_raw = {
77680 .clock_getres = hrtimer_get_res,
77681 .clock_get = posix_get_monotonic_raw,
77682 };
77683 - struct k_clock clock_realtime_coarse = {
77684 + static struct k_clock clock_realtime_coarse = {
77685 .clock_getres = posix_get_coarse_res,
77686 .clock_get = posix_get_realtime_coarse,
77687 };
77688 - struct k_clock clock_monotonic_coarse = {
77689 + static struct k_clock clock_monotonic_coarse = {
77690 .clock_getres = posix_get_coarse_res,
77691 .clock_get = posix_get_monotonic_coarse,
77692 };
77693 - struct k_clock clock_tai = {
77694 + static struct k_clock clock_tai = {
77695 .clock_getres = hrtimer_get_res,
77696 .clock_get = posix_get_tai,
77697 .nsleep = common_nsleep,
77698 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
77699 .timer_get = common_timer_get,
77700 .timer_del = common_timer_del,
77701 };
77702 - struct k_clock clock_boottime = {
77703 + static struct k_clock clock_boottime = {
77704 .clock_getres = hrtimer_get_res,
77705 .clock_get = posix_get_boottime,
77706 .nsleep = common_nsleep,
77707 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77708 return;
77709 }
77710
77711 - posix_clocks[clock_id] = *new_clock;
77712 + posix_clocks[clock_id] = new_clock;
77713 }
77714 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77715
77716 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77717 return (id & CLOCKFD_MASK) == CLOCKFD ?
77718 &clock_posix_dynamic : &clock_posix_cpu;
77719
77720 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77721 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77722 return NULL;
77723 - return &posix_clocks[id];
77724 + return posix_clocks[id];
77725 }
77726
77727 static int common_timer_create(struct k_itimer *new_timer)
77728 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77729 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77730 return -EFAULT;
77731
77732 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77733 + have their clock_set fptr set to a nosettime dummy function
77734 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77735 + call common_clock_set, which calls do_sys_settimeofday, which
77736 + we hook
77737 + */
77738 +
77739 return kc->clock_set(which_clock, &new_tp);
77740 }
77741
77742 diff --git a/kernel/power/process.c b/kernel/power/process.c
77743 index 98088e0..aaf95c0 100644
77744 --- a/kernel/power/process.c
77745 +++ b/kernel/power/process.c
77746 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77747 u64 elapsed_csecs64;
77748 unsigned int elapsed_csecs;
77749 bool wakeup = false;
77750 + bool timedout = false;
77751
77752 do_gettimeofday(&start);
77753
77754 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77755
77756 while (true) {
77757 todo = 0;
77758 + if (time_after(jiffies, end_time))
77759 + timedout = true;
77760 read_lock(&tasklist_lock);
77761 do_each_thread(g, p) {
77762 if (p == current || !freeze_task(p))
77763 continue;
77764
77765 - if (!freezer_should_skip(p))
77766 + if (!freezer_should_skip(p)) {
77767 todo++;
77768 + if (timedout) {
77769 + printk(KERN_ERR "Task refusing to freeze:\n");
77770 + sched_show_task(p);
77771 + }
77772 + }
77773 } while_each_thread(g, p);
77774 read_unlock(&tasklist_lock);
77775
77776 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77777 todo += wq_busy;
77778 }
77779
77780 - if (!todo || time_after(jiffies, end_time))
77781 + if (!todo || timedout)
77782 break;
77783
77784 if (pm_wakeup_pending()) {
77785 diff --git a/kernel/printk.c b/kernel/printk.c
77786 index 8212c1a..eb61021 100644
77787 --- a/kernel/printk.c
77788 +++ b/kernel/printk.c
77789 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
77790 if (from_file && type != SYSLOG_ACTION_OPEN)
77791 return 0;
77792
77793 +#ifdef CONFIG_GRKERNSEC_DMESG
77794 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77795 + return -EPERM;
77796 +#endif
77797 +
77798 if (syslog_action_restricted(type)) {
77799 if (capable(CAP_SYSLOG))
77800 return 0;
77801 diff --git a/kernel/profile.c b/kernel/profile.c
77802 index 0bf4007..6234708 100644
77803 --- a/kernel/profile.c
77804 +++ b/kernel/profile.c
77805 @@ -37,7 +37,7 @@ struct profile_hit {
77806 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77807 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77808
77809 -static atomic_t *prof_buffer;
77810 +static atomic_unchecked_t *prof_buffer;
77811 static unsigned long prof_len, prof_shift;
77812
77813 int prof_on __read_mostly;
77814 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77815 hits[i].pc = 0;
77816 continue;
77817 }
77818 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77819 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77820 hits[i].hits = hits[i].pc = 0;
77821 }
77822 }
77823 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77824 * Add the current hit(s) and flush the write-queue out
77825 * to the global buffer:
77826 */
77827 - atomic_add(nr_hits, &prof_buffer[pc]);
77828 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77829 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77830 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77831 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77832 hits[i].pc = hits[i].hits = 0;
77833 }
77834 out:
77835 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77836 {
77837 unsigned long pc;
77838 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77839 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77840 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77841 }
77842 #endif /* !CONFIG_SMP */
77843
77844 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77845 return -EFAULT;
77846 buf++; p++; count--; read++;
77847 }
77848 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77849 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77850 if (copy_to_user(buf, (void *)pnt, count))
77851 return -EFAULT;
77852 read += count;
77853 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77854 }
77855 #endif
77856 profile_discard_flip_buffers();
77857 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77858 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77859 return count;
77860 }
77861
77862 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77863 index 335a7ae..3bbbceb 100644
77864 --- a/kernel/ptrace.c
77865 +++ b/kernel/ptrace.c
77866 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77867 if (seize)
77868 flags |= PT_SEIZED;
77869 rcu_read_lock();
77870 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77871 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77872 flags |= PT_PTRACE_CAP;
77873 rcu_read_unlock();
77874 task->ptrace = flags;
77875 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77876 break;
77877 return -EIO;
77878 }
77879 - if (copy_to_user(dst, buf, retval))
77880 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77881 return -EFAULT;
77882 copied += retval;
77883 src += retval;
77884 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
77885 bool seized = child->ptrace & PT_SEIZED;
77886 int ret = -EIO;
77887 siginfo_t siginfo, *si;
77888 - void __user *datavp = (void __user *) data;
77889 + void __user *datavp = (__force void __user *) data;
77890 unsigned long __user *datalp = datavp;
77891 unsigned long flags;
77892
77893 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77894 goto out;
77895 }
77896
77897 + if (gr_handle_ptrace(child, request)) {
77898 + ret = -EPERM;
77899 + goto out_put_task_struct;
77900 + }
77901 +
77902 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77903 ret = ptrace_attach(child, request, addr, data);
77904 /*
77905 * Some architectures need to do book-keeping after
77906 * a ptrace attach.
77907 */
77908 - if (!ret)
77909 + if (!ret) {
77910 arch_ptrace_attach(child);
77911 + gr_audit_ptrace(child);
77912 + }
77913 goto out_put_task_struct;
77914 }
77915
77916 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77917 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77918 if (copied != sizeof(tmp))
77919 return -EIO;
77920 - return put_user(tmp, (unsigned long __user *)data);
77921 + return put_user(tmp, (__force unsigned long __user *)data);
77922 }
77923
77924 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77925 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77926 }
77927
77928 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77929 - compat_long_t addr, compat_long_t data)
77930 + compat_ulong_t addr, compat_ulong_t data)
77931 {
77932 struct task_struct *child;
77933 long ret;
77934 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77935 goto out;
77936 }
77937
77938 + if (gr_handle_ptrace(child, request)) {
77939 + ret = -EPERM;
77940 + goto out_put_task_struct;
77941 + }
77942 +
77943 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77944 ret = ptrace_attach(child, request, addr, data);
77945 /*
77946 * Some architectures need to do book-keeping after
77947 * a ptrace attach.
77948 */
77949 - if (!ret)
77950 + if (!ret) {
77951 arch_ptrace_attach(child);
77952 + gr_audit_ptrace(child);
77953 + }
77954 goto out_put_task_struct;
77955 }
77956
77957 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77958 index 48ab703..07561d4 100644
77959 --- a/kernel/rcupdate.c
77960 +++ b/kernel/rcupdate.c
77961 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77962 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77963 */
77964 if (till_stall_check < 3) {
77965 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77966 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77967 till_stall_check = 3;
77968 } else if (till_stall_check > 300) {
77969 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77970 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77971 till_stall_check = 300;
77972 }
77973 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77974 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77975 index a0714a5..2ab5e34 100644
77976 --- a/kernel/rcutiny.c
77977 +++ b/kernel/rcutiny.c
77978 @@ -46,7 +46,7 @@
77979 struct rcu_ctrlblk;
77980 static void invoke_rcu_callbacks(void);
77981 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77982 -static void rcu_process_callbacks(struct softirq_action *unused);
77983 +static void rcu_process_callbacks(void);
77984 static void __call_rcu(struct rcu_head *head,
77985 void (*func)(struct rcu_head *rcu),
77986 struct rcu_ctrlblk *rcp);
77987 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77988 rcu_is_callbacks_kthread()));
77989 }
77990
77991 -static void rcu_process_callbacks(struct softirq_action *unused)
77992 +static void rcu_process_callbacks(void)
77993 {
77994 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77995 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77996 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77997 index 8a23300..4255818 100644
77998 --- a/kernel/rcutiny_plugin.h
77999 +++ b/kernel/rcutiny_plugin.h
78000 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
78001 have_rcu_kthread_work = morework;
78002 local_irq_restore(flags);
78003 if (work)
78004 - rcu_process_callbacks(NULL);
78005 + rcu_process_callbacks();
78006 schedule_timeout_interruptible(1); /* Leave CPU for others. */
78007 }
78008
78009 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
78010 index e1f3a8c..42c94a2 100644
78011 --- a/kernel/rcutorture.c
78012 +++ b/kernel/rcutorture.c
78013 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
78014 { 0 };
78015 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
78016 { 0 };
78017 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78018 -static atomic_t n_rcu_torture_alloc;
78019 -static atomic_t n_rcu_torture_alloc_fail;
78020 -static atomic_t n_rcu_torture_free;
78021 -static atomic_t n_rcu_torture_mberror;
78022 -static atomic_t n_rcu_torture_error;
78023 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78024 +static atomic_unchecked_t n_rcu_torture_alloc;
78025 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
78026 +static atomic_unchecked_t n_rcu_torture_free;
78027 +static atomic_unchecked_t n_rcu_torture_mberror;
78028 +static atomic_unchecked_t n_rcu_torture_error;
78029 static long n_rcu_torture_barrier_error;
78030 static long n_rcu_torture_boost_ktrerror;
78031 static long n_rcu_torture_boost_rterror;
78032 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
78033
78034 spin_lock_bh(&rcu_torture_lock);
78035 if (list_empty(&rcu_torture_freelist)) {
78036 - atomic_inc(&n_rcu_torture_alloc_fail);
78037 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
78038 spin_unlock_bh(&rcu_torture_lock);
78039 return NULL;
78040 }
78041 - atomic_inc(&n_rcu_torture_alloc);
78042 + atomic_inc_unchecked(&n_rcu_torture_alloc);
78043 p = rcu_torture_freelist.next;
78044 list_del_init(p);
78045 spin_unlock_bh(&rcu_torture_lock);
78046 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
78047 static void
78048 rcu_torture_free(struct rcu_torture *p)
78049 {
78050 - atomic_inc(&n_rcu_torture_free);
78051 + atomic_inc_unchecked(&n_rcu_torture_free);
78052 spin_lock_bh(&rcu_torture_lock);
78053 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
78054 spin_unlock_bh(&rcu_torture_lock);
78055 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
78056 i = rp->rtort_pipe_count;
78057 if (i > RCU_TORTURE_PIPE_LEN)
78058 i = RCU_TORTURE_PIPE_LEN;
78059 - atomic_inc(&rcu_torture_wcount[i]);
78060 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78061 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78062 rp->rtort_mbtest = 0;
78063 rcu_torture_free(rp);
78064 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
78065 i = rp->rtort_pipe_count;
78066 if (i > RCU_TORTURE_PIPE_LEN)
78067 i = RCU_TORTURE_PIPE_LEN;
78068 - atomic_inc(&rcu_torture_wcount[i]);
78069 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78070 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78071 rp->rtort_mbtest = 0;
78072 list_del(&rp->rtort_free);
78073 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
78074 i = old_rp->rtort_pipe_count;
78075 if (i > RCU_TORTURE_PIPE_LEN)
78076 i = RCU_TORTURE_PIPE_LEN;
78077 - atomic_inc(&rcu_torture_wcount[i]);
78078 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78079 old_rp->rtort_pipe_count++;
78080 cur_ops->deferred_free(old_rp);
78081 }
78082 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
78083 return;
78084 }
78085 if (p->rtort_mbtest == 0)
78086 - atomic_inc(&n_rcu_torture_mberror);
78087 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78088 spin_lock(&rand_lock);
78089 cur_ops->read_delay(&rand);
78090 n_rcu_torture_timers++;
78091 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
78092 continue;
78093 }
78094 if (p->rtort_mbtest == 0)
78095 - atomic_inc(&n_rcu_torture_mberror);
78096 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78097 cur_ops->read_delay(&rand);
78098 preempt_disable();
78099 pipe_count = p->rtort_pipe_count;
78100 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
78101 rcu_torture_current,
78102 rcu_torture_current_version,
78103 list_empty(&rcu_torture_freelist),
78104 - atomic_read(&n_rcu_torture_alloc),
78105 - atomic_read(&n_rcu_torture_alloc_fail),
78106 - atomic_read(&n_rcu_torture_free));
78107 + atomic_read_unchecked(&n_rcu_torture_alloc),
78108 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
78109 + atomic_read_unchecked(&n_rcu_torture_free));
78110 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
78111 - atomic_read(&n_rcu_torture_mberror),
78112 + atomic_read_unchecked(&n_rcu_torture_mberror),
78113 n_rcu_torture_boost_ktrerror,
78114 n_rcu_torture_boost_rterror);
78115 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
78116 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
78117 n_barrier_attempts,
78118 n_rcu_torture_barrier_error);
78119 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
78120 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
78121 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
78122 n_rcu_torture_barrier_error != 0 ||
78123 n_rcu_torture_boost_ktrerror != 0 ||
78124 n_rcu_torture_boost_rterror != 0 ||
78125 n_rcu_torture_boost_failure != 0 ||
78126 i > 1) {
78127 cnt += sprintf(&page[cnt], "!!! ");
78128 - atomic_inc(&n_rcu_torture_error);
78129 + atomic_inc_unchecked(&n_rcu_torture_error);
78130 WARN_ON_ONCE(1);
78131 }
78132 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78133 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
78134 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78135 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78136 cnt += sprintf(&page[cnt], " %d",
78137 - atomic_read(&rcu_torture_wcount[i]));
78138 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78139 }
78140 cnt += sprintf(&page[cnt], "\n");
78141 if (cur_ops->stats)
78142 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
78143
78144 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78145
78146 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78147 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78148 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78149 else if (n_online_successes != n_online_attempts ||
78150 n_offline_successes != n_offline_attempts)
78151 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
78152
78153 rcu_torture_current = NULL;
78154 rcu_torture_current_version = 0;
78155 - atomic_set(&n_rcu_torture_alloc, 0);
78156 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78157 - atomic_set(&n_rcu_torture_free, 0);
78158 - atomic_set(&n_rcu_torture_mberror, 0);
78159 - atomic_set(&n_rcu_torture_error, 0);
78160 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78161 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78162 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78163 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78164 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78165 n_rcu_torture_barrier_error = 0;
78166 n_rcu_torture_boost_ktrerror = 0;
78167 n_rcu_torture_boost_rterror = 0;
78168 n_rcu_torture_boost_failure = 0;
78169 n_rcu_torture_boosts = 0;
78170 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78171 - atomic_set(&rcu_torture_wcount[i], 0);
78172 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78173 for_each_possible_cpu(cpu) {
78174 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78175 per_cpu(rcu_torture_count, cpu)[i] = 0;
78176 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78177 index 3538001..e379e0b 100644
78178 --- a/kernel/rcutree.c
78179 +++ b/kernel/rcutree.c
78180 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78181 rcu_prepare_for_idle(smp_processor_id());
78182 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78183 smp_mb__before_atomic_inc(); /* See above. */
78184 - atomic_inc(&rdtp->dynticks);
78185 + atomic_inc_unchecked(&rdtp->dynticks);
78186 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78187 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78188 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78189
78190 /*
78191 * It is illegal to enter an extended quiescent state while
78192 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78193 int user)
78194 {
78195 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78196 - atomic_inc(&rdtp->dynticks);
78197 + atomic_inc_unchecked(&rdtp->dynticks);
78198 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78199 smp_mb__after_atomic_inc(); /* See above. */
78200 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78201 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78202 rcu_cleanup_after_idle(smp_processor_id());
78203 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78204 if (!user && !is_idle_task(current)) {
78205 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
78206 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78207
78208 if (rdtp->dynticks_nmi_nesting == 0 &&
78209 - (atomic_read(&rdtp->dynticks) & 0x1))
78210 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78211 return;
78212 rdtp->dynticks_nmi_nesting++;
78213 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
78214 - atomic_inc(&rdtp->dynticks);
78215 + atomic_inc_unchecked(&rdtp->dynticks);
78216 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78217 smp_mb__after_atomic_inc(); /* See above. */
78218 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78219 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78220 }
78221
78222 /**
78223 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
78224 return;
78225 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78226 smp_mb__before_atomic_inc(); /* See above. */
78227 - atomic_inc(&rdtp->dynticks);
78228 + atomic_inc_unchecked(&rdtp->dynticks);
78229 smp_mb__after_atomic_inc(); /* Force delay to next write. */
78230 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78231 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78232 }
78233
78234 /**
78235 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
78236 int ret;
78237
78238 preempt_disable();
78239 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78240 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78241 preempt_enable();
78242 return ret;
78243 }
78244 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
78245 */
78246 static int dyntick_save_progress_counter(struct rcu_data *rdp)
78247 {
78248 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
78249 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78250 return (rdp->dynticks_snap & 0x1) == 0;
78251 }
78252
78253 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
78254 unsigned int curr;
78255 unsigned int snap;
78256
78257 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
78258 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78259 snap = (unsigned int)rdp->dynticks_snap;
78260
78261 /*
78262 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
78263 rdp = this_cpu_ptr(rsp->rda);
78264 rcu_preempt_check_blocked_tasks(rnp);
78265 rnp->qsmask = rnp->qsmaskinit;
78266 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
78267 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
78268 WARN_ON_ONCE(rnp->completed != rsp->completed);
78269 - ACCESS_ONCE(rnp->completed) = rsp->completed;
78270 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
78271 if (rnp == rdp->mynode)
78272 rcu_start_gp_per_cpu(rsp, rnp, rdp);
78273 rcu_preempt_boost_start_gp(rnp);
78274 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
78275 */
78276 rcu_for_each_node_breadth_first(rsp, rnp) {
78277 raw_spin_lock_irq(&rnp->lock);
78278 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
78279 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
78280 rdp = this_cpu_ptr(rsp->rda);
78281 if (rnp == rdp->mynode)
78282 __rcu_process_gp_end(rsp, rnp, rdp);
78283 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
78284 rsp->qlen += rdp->qlen;
78285 rdp->n_cbs_orphaned += rdp->qlen;
78286 rdp->qlen_lazy = 0;
78287 - ACCESS_ONCE(rdp->qlen) = 0;
78288 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78289 }
78290
78291 /*
78292 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
78293 }
78294 smp_mb(); /* List handling before counting for rcu_barrier(). */
78295 rdp->qlen_lazy -= count_lazy;
78296 - ACCESS_ONCE(rdp->qlen) -= count;
78297 + ACCESS_ONCE_RW(rdp->qlen) -= count;
78298 rdp->n_cbs_invoked += count;
78299
78300 /* Reinstate batch limit if we have worked down the excess. */
78301 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
78302 /*
78303 * Do RCU core processing for the current CPU.
78304 */
78305 -static void rcu_process_callbacks(struct softirq_action *unused)
78306 +static void rcu_process_callbacks(void)
78307 {
78308 struct rcu_state *rsp;
78309
78310 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78311 local_irq_restore(flags);
78312 return;
78313 }
78314 - ACCESS_ONCE(rdp->qlen)++;
78315 + ACCESS_ONCE_RW(rdp->qlen)++;
78316 if (lazy)
78317 rdp->qlen_lazy++;
78318 else
78319 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
78320 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78321 * course be required on a 64-bit system.
78322 */
78323 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78324 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78325 (ulong)atomic_long_read(&rsp->expedited_done) +
78326 ULONG_MAX / 8)) {
78327 synchronize_sched();
78328 - atomic_long_inc(&rsp->expedited_wrap);
78329 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78330 return;
78331 }
78332
78333 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
78334 * Take a ticket. Note that atomic_inc_return() implies a
78335 * full memory barrier.
78336 */
78337 - snap = atomic_long_inc_return(&rsp->expedited_start);
78338 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78339 firstsnap = snap;
78340 get_online_cpus();
78341 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78342 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
78343 synchronize_sched_expedited_cpu_stop,
78344 NULL) == -EAGAIN) {
78345 put_online_cpus();
78346 - atomic_long_inc(&rsp->expedited_tryfail);
78347 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78348
78349 /* Check to see if someone else did our work for us. */
78350 s = atomic_long_read(&rsp->expedited_done);
78351 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78352 /* ensure test happens before caller kfree */
78353 smp_mb__before_atomic_inc(); /* ^^^ */
78354 - atomic_long_inc(&rsp->expedited_workdone1);
78355 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78356 return;
78357 }
78358
78359 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
78360 udelay(trycount * num_online_cpus());
78361 } else {
78362 wait_rcu_gp(call_rcu_sched);
78363 - atomic_long_inc(&rsp->expedited_normal);
78364 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78365 return;
78366 }
78367
78368 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
78369 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78370 /* ensure test happens before caller kfree */
78371 smp_mb__before_atomic_inc(); /* ^^^ */
78372 - atomic_long_inc(&rsp->expedited_workdone2);
78373 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78374 return;
78375 }
78376
78377 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
78378 * period works for us.
78379 */
78380 get_online_cpus();
78381 - snap = atomic_long_read(&rsp->expedited_start);
78382 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78383 smp_mb(); /* ensure read is before try_stop_cpus(). */
78384 }
78385 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78386 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78387
78388 /*
78389 * Everyone up to our most recent fetch is covered by our grace
78390 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
78391 * than we did already did their update.
78392 */
78393 do {
78394 - atomic_long_inc(&rsp->expedited_done_tries);
78395 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78396 s = atomic_long_read(&rsp->expedited_done);
78397 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78398 /* ensure test happens before caller kfree */
78399 smp_mb__before_atomic_inc(); /* ^^^ */
78400 - atomic_long_inc(&rsp->expedited_done_lost);
78401 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78402 break;
78403 }
78404 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78405 - atomic_long_inc(&rsp->expedited_done_exit);
78406 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78407
78408 put_online_cpus();
78409 }
78410 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78411 * ACCESS_ONCE() to prevent the compiler from speculating
78412 * the increment to precede the early-exit check.
78413 */
78414 - ACCESS_ONCE(rsp->n_barrier_done)++;
78415 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78416 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78417 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78418 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78419 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78420
78421 /* Increment ->n_barrier_done to prevent duplicate work. */
78422 smp_mb(); /* Keep increment after above mechanism. */
78423 - ACCESS_ONCE(rsp->n_barrier_done)++;
78424 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78425 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78426 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78427 smp_mb(); /* Keep increment before caller's subsequent code. */
78428 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78429 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78430 init_callback_list(rdp);
78431 rdp->qlen_lazy = 0;
78432 - ACCESS_ONCE(rdp->qlen) = 0;
78433 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78434 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78435 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78436 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78437 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78438 rdp->cpu = cpu;
78439 rdp->rsp = rsp;
78440 rcu_boot_init_nocb_percpu_data(rdp);
78441 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78442 rdp->blimit = blimit;
78443 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78444 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78445 - atomic_set(&rdp->dynticks->dynticks,
78446 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78447 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78448 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78449 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78450
78451 /* Add CPU to rcu_node bitmasks. */
78452 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
78453 struct task_struct *t;
78454
78455 for_each_rcu_flavor(rsp) {
78456 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
78457 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
78458 BUG_ON(IS_ERR(t));
78459 rnp = rcu_get_root(rsp);
78460 raw_spin_lock_irqsave(&rnp->lock, flags);
78461 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78462 index 4df5034..5ee93f2 100644
78463 --- a/kernel/rcutree.h
78464 +++ b/kernel/rcutree.h
78465 @@ -87,7 +87,7 @@ struct rcu_dynticks {
78466 long long dynticks_nesting; /* Track irq/process nesting level. */
78467 /* Process level is worth LLONG_MAX/2. */
78468 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78469 - atomic_t dynticks; /* Even value for idle, else odd. */
78470 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78471 #ifdef CONFIG_RCU_FAST_NO_HZ
78472 bool all_lazy; /* Are all CPU's CBs lazy? */
78473 unsigned long nonlazy_posted;
78474 @@ -414,17 +414,17 @@ struct rcu_state {
78475 /* _rcu_barrier(). */
78476 /* End of fields guarded by barrier_mutex. */
78477
78478 - atomic_long_t expedited_start; /* Starting ticket. */
78479 - atomic_long_t expedited_done; /* Done ticket. */
78480 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78481 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78482 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78483 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78484 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78485 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78486 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78487 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78488 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78489 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78490 + atomic_long_t expedited_done; /* Done ticket. */
78491 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78492 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78493 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78494 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78495 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78496 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78497 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78498 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78499 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78500
78501 unsigned long jiffies_force_qs; /* Time at which to invoke */
78502 /* force_quiescent_state(). */
78503 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78504 index 3db5a37..b395fb35 100644
78505 --- a/kernel/rcutree_plugin.h
78506 +++ b/kernel/rcutree_plugin.h
78507 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
78508
78509 /* Clean up and exit. */
78510 smp_mb(); /* ensure expedited GP seen before counter increment. */
78511 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78512 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78513 unlock_mb_ret:
78514 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78515 mb_ret:
78516 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78517 free_cpumask_var(cm);
78518 }
78519
78520 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78521 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78522 .store = &rcu_cpu_kthread_task,
78523 .thread_should_run = rcu_cpu_kthread_should_run,
78524 .thread_fn = rcu_cpu_kthread,
78525 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78526 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78527 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
78528 cpu, ticks_value, ticks_title,
78529 - atomic_read(&rdtp->dynticks) & 0xfff,
78530 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78531 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78532 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
78533 fast_no_hz);
78534 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78535
78536 /* Enqueue the callback on the nocb list and update counts. */
78537 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78538 - ACCESS_ONCE(*old_rhpp) = rhp;
78539 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78540 atomic_long_add(rhcount, &rdp->nocb_q_count);
78541 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78542
78543 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
78544 * Extract queued callbacks, update counts, and wait
78545 * for a grace period to elapse.
78546 */
78547 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78548 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78549 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78550 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78551 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78552 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78553 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78554 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78555 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78556 rcu_nocb_wait_gp(rdp);
78557
78558 /* Each pass through the following loop invokes a callback. */
78559 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
78560 list = next;
78561 }
78562 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78563 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78564 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78565 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78566 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78567 rdp->n_nocbs_invoked += c;
78568 }
78569 return 0;
78570 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78571 t = kthread_run(rcu_nocb_kthread, rdp,
78572 "rcuo%c/%d", rsp->abbr, cpu);
78573 BUG_ON(IS_ERR(t));
78574 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78575 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78576 }
78577 }
78578
78579 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78580 index cf6c174..a8f4b50 100644
78581 --- a/kernel/rcutree_trace.c
78582 +++ b/kernel/rcutree_trace.c
78583 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78584 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78585 rdp->passed_quiesce, rdp->qs_pending);
78586 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78587 - atomic_read(&rdp->dynticks->dynticks),
78588 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78589 rdp->dynticks->dynticks_nesting,
78590 rdp->dynticks->dynticks_nmi_nesting,
78591 rdp->dynticks_fqs);
78592 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78593 struct rcu_state *rsp = (struct rcu_state *)m->private;
78594
78595 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",
78596 - atomic_long_read(&rsp->expedited_start),
78597 + atomic_long_read_unchecked(&rsp->expedited_start),
78598 atomic_long_read(&rsp->expedited_done),
78599 - atomic_long_read(&rsp->expedited_wrap),
78600 - atomic_long_read(&rsp->expedited_tryfail),
78601 - atomic_long_read(&rsp->expedited_workdone1),
78602 - atomic_long_read(&rsp->expedited_workdone2),
78603 - atomic_long_read(&rsp->expedited_normal),
78604 - atomic_long_read(&rsp->expedited_stoppedcpus),
78605 - atomic_long_read(&rsp->expedited_done_tries),
78606 - atomic_long_read(&rsp->expedited_done_lost),
78607 - atomic_long_read(&rsp->expedited_done_exit));
78608 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78609 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78610 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78611 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78612 + atomic_long_read_unchecked(&rsp->expedited_normal),
78613 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78614 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78615 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78616 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78617 return 0;
78618 }
78619
78620 diff --git a/kernel/resource.c b/kernel/resource.c
78621 index d738698..5f8e60a 100644
78622 --- a/kernel/resource.c
78623 +++ b/kernel/resource.c
78624 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
78625
78626 static int __init ioresources_init(void)
78627 {
78628 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78629 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78630 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78631 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78632 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78633 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78634 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78635 +#endif
78636 +#else
78637 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78638 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78639 +#endif
78640 return 0;
78641 }
78642 __initcall(ioresources_init);
78643 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78644 index 1d96dd0..994ff19 100644
78645 --- a/kernel/rtmutex-tester.c
78646 +++ b/kernel/rtmutex-tester.c
78647 @@ -22,7 +22,7 @@
78648 #define MAX_RT_TEST_MUTEXES 8
78649
78650 static spinlock_t rttest_lock;
78651 -static atomic_t rttest_event;
78652 +static atomic_unchecked_t rttest_event;
78653
78654 struct test_thread_data {
78655 int opcode;
78656 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78657
78658 case RTTEST_LOCKCONT:
78659 td->mutexes[td->opdata] = 1;
78660 - td->event = atomic_add_return(1, &rttest_event);
78661 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78662 return 0;
78663
78664 case RTTEST_RESET:
78665 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78666 return 0;
78667
78668 case RTTEST_RESETEVENT:
78669 - atomic_set(&rttest_event, 0);
78670 + atomic_set_unchecked(&rttest_event, 0);
78671 return 0;
78672
78673 default:
78674 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78675 return ret;
78676
78677 td->mutexes[id] = 1;
78678 - td->event = atomic_add_return(1, &rttest_event);
78679 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78680 rt_mutex_lock(&mutexes[id]);
78681 - td->event = atomic_add_return(1, &rttest_event);
78682 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78683 td->mutexes[id] = 4;
78684 return 0;
78685
78686 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78687 return ret;
78688
78689 td->mutexes[id] = 1;
78690 - td->event = atomic_add_return(1, &rttest_event);
78691 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78692 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78693 - td->event = atomic_add_return(1, &rttest_event);
78694 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78695 td->mutexes[id] = ret ? 0 : 4;
78696 return ret ? -EINTR : 0;
78697
78698 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78699 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78700 return ret;
78701
78702 - td->event = atomic_add_return(1, &rttest_event);
78703 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78704 rt_mutex_unlock(&mutexes[id]);
78705 - td->event = atomic_add_return(1, &rttest_event);
78706 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78707 td->mutexes[id] = 0;
78708 return 0;
78709
78710 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78711 break;
78712
78713 td->mutexes[dat] = 2;
78714 - td->event = atomic_add_return(1, &rttest_event);
78715 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78716 break;
78717
78718 default:
78719 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78720 return;
78721
78722 td->mutexes[dat] = 3;
78723 - td->event = atomic_add_return(1, &rttest_event);
78724 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78725 break;
78726
78727 case RTTEST_LOCKNOWAIT:
78728 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78729 return;
78730
78731 td->mutexes[dat] = 1;
78732 - td->event = atomic_add_return(1, &rttest_event);
78733 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78734 return;
78735
78736 default:
78737 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78738 index 64de5f8..7735e12 100644
78739 --- a/kernel/sched/auto_group.c
78740 +++ b/kernel/sched/auto_group.c
78741 @@ -11,7 +11,7 @@
78742
78743 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78744 static struct autogroup autogroup_default;
78745 -static atomic_t autogroup_seq_nr;
78746 +static atomic_unchecked_t autogroup_seq_nr;
78747
78748 void __init autogroup_init(struct task_struct *init_task)
78749 {
78750 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78751
78752 kref_init(&ag->kref);
78753 init_rwsem(&ag->lock);
78754 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78755 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78756 ag->tg = tg;
78757 #ifdef CONFIG_RT_GROUP_SCHED
78758 /*
78759 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78760 index e8b3350..d83d44e 100644
78761 --- a/kernel/sched/core.c
78762 +++ b/kernel/sched/core.c
78763 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78764 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78765 * positive (at least 1, or number of jiffies left till timeout) if completed.
78766 */
78767 -long __sched
78768 +long __sched __intentional_overflow(-1)
78769 wait_for_completion_interruptible_timeout(struct completion *x,
78770 unsigned long timeout)
78771 {
78772 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78773 *
78774 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78775 */
78776 -int __sched wait_for_completion_killable(struct completion *x)
78777 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78778 {
78779 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78780 if (t == -ERESTARTSYS)
78781 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78782 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78783 * positive (at least 1, or number of jiffies left till timeout) if completed.
78784 */
78785 -long __sched
78786 +long __sched __intentional_overflow(-1)
78787 wait_for_completion_killable_timeout(struct completion *x,
78788 unsigned long timeout)
78789 {
78790 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
78791 /* convert nice value [19,-20] to rlimit style value [1,40] */
78792 int nice_rlim = 20 - nice;
78793
78794 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78795 +
78796 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78797 capable(CAP_SYS_NICE));
78798 }
78799 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78800 if (nice > 19)
78801 nice = 19;
78802
78803 - if (increment < 0 && !can_nice(current, nice))
78804 + if (increment < 0 && (!can_nice(current, nice) ||
78805 + gr_handle_chroot_nice()))
78806 return -EPERM;
78807
78808 retval = security_task_setnice(current, nice);
78809 @@ -3891,6 +3894,7 @@ recheck:
78810 unsigned long rlim_rtprio =
78811 task_rlimit(p, RLIMIT_RTPRIO);
78812
78813 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78814 /* can't set/change the rt policy */
78815 if (policy != p->policy && !rlim_rtprio)
78816 return -EPERM;
78817 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78818
78819 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78820
78821 -static struct ctl_table sd_ctl_dir[] = {
78822 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78823 {
78824 .procname = "sched_domain",
78825 .mode = 0555,
78826 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
78827 {}
78828 };
78829
78830 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78831 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78832 {
78833 - struct ctl_table *entry =
78834 + ctl_table_no_const *entry =
78835 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78836
78837 return entry;
78838 }
78839
78840 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78841 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78842 {
78843 - struct ctl_table *entry;
78844 + ctl_table_no_const *entry;
78845
78846 /*
78847 * In the intermediate directories, both the child directory and
78848 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78849 * will always be set. In the lowest directory the names are
78850 * static strings and all have proc handlers.
78851 */
78852 - for (entry = *tablep; entry->mode; entry++) {
78853 - if (entry->child)
78854 - sd_free_ctl_entry(&entry->child);
78855 + for (entry = tablep; entry->mode; entry++) {
78856 + if (entry->child) {
78857 + sd_free_ctl_entry(entry->child);
78858 + pax_open_kernel();
78859 + entry->child = NULL;
78860 + pax_close_kernel();
78861 + }
78862 if (entry->proc_handler == NULL)
78863 kfree(entry->procname);
78864 }
78865
78866 - kfree(*tablep);
78867 - *tablep = NULL;
78868 + kfree(tablep);
78869 }
78870
78871 static int min_load_idx = 0;
78872 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78873
78874 static void
78875 -set_table_entry(struct ctl_table *entry,
78876 +set_table_entry(ctl_table_no_const *entry,
78877 const char *procname, void *data, int maxlen,
78878 umode_t mode, proc_handler *proc_handler,
78879 bool load_idx)
78880 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
78881 static struct ctl_table *
78882 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78883 {
78884 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78885 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78886
78887 if (table == NULL)
78888 return NULL;
78889 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78890 return table;
78891 }
78892
78893 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78894 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78895 {
78896 - struct ctl_table *entry, *table;
78897 + ctl_table_no_const *entry, *table;
78898 struct sched_domain *sd;
78899 int domain_num = 0, i;
78900 char buf[32];
78901 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
78902 static void register_sched_domain_sysctl(void)
78903 {
78904 int i, cpu_num = num_possible_cpus();
78905 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78906 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78907 char buf[32];
78908
78909 WARN_ON(sd_ctl_dir[0].child);
78910 + pax_open_kernel();
78911 sd_ctl_dir[0].child = entry;
78912 + pax_close_kernel();
78913
78914 if (entry == NULL)
78915 return;
78916 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
78917 if (sd_sysctl_header)
78918 unregister_sysctl_table(sd_sysctl_header);
78919 sd_sysctl_header = NULL;
78920 - if (sd_ctl_dir[0].child)
78921 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78922 + if (sd_ctl_dir[0].child) {
78923 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78924 + pax_open_kernel();
78925 + sd_ctl_dir[0].child = NULL;
78926 + pax_close_kernel();
78927 + }
78928 }
78929 #else
78930 static void register_sched_domain_sysctl(void)
78931 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78932 * happens before everything else. This has to be lower priority than
78933 * the notifier in the perf_event subsystem, though.
78934 */
78935 -static struct notifier_block __cpuinitdata migration_notifier = {
78936 +static struct notifier_block migration_notifier = {
78937 .notifier_call = migration_call,
78938 .priority = CPU_PRI_MIGRATION,
78939 };
78940 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78941 index c61a614..d7f3d7e 100644
78942 --- a/kernel/sched/fair.c
78943 +++ b/kernel/sched/fair.c
78944 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78945
78946 static void reset_ptenuma_scan(struct task_struct *p)
78947 {
78948 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78949 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78950 p->mm->numa_scan_offset = 0;
78951 }
78952
78953 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78954 * run_rebalance_domains is triggered when needed from the scheduler tick.
78955 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78956 */
78957 -static void run_rebalance_domains(struct softirq_action *h)
78958 +static void run_rebalance_domains(void)
78959 {
78960 int this_cpu = smp_processor_id();
78961 struct rq *this_rq = cpu_rq(this_cpu);
78962 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
78963 index ce39224..0e09343 100644
78964 --- a/kernel/sched/sched.h
78965 +++ b/kernel/sched/sched.h
78966 @@ -1009,7 +1009,7 @@ struct sched_class {
78967 #ifdef CONFIG_FAIR_GROUP_SCHED
78968 void (*task_move_group) (struct task_struct *p, int on_rq);
78969 #endif
78970 -};
78971 +} __do_const;
78972
78973 #define sched_class_highest (&stop_sched_class)
78974 #define for_each_class(class) \
78975 diff --git a/kernel/signal.c b/kernel/signal.c
78976 index 113411b..17190e2 100644
78977 --- a/kernel/signal.c
78978 +++ b/kernel/signal.c
78979 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
78980
78981 int print_fatal_signals __read_mostly;
78982
78983 -static void __user *sig_handler(struct task_struct *t, int sig)
78984 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78985 {
78986 return t->sighand->action[sig - 1].sa.sa_handler;
78987 }
78988
78989 -static int sig_handler_ignored(void __user *handler, int sig)
78990 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78991 {
78992 /* Is it explicitly or implicitly ignored? */
78993 return handler == SIG_IGN ||
78994 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78995
78996 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78997 {
78998 - void __user *handler;
78999 + __sighandler_t handler;
79000
79001 handler = sig_handler(t, sig);
79002
79003 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
79004 atomic_inc(&user->sigpending);
79005 rcu_read_unlock();
79006
79007 + if (!override_rlimit)
79008 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
79009 +
79010 if (override_rlimit ||
79011 atomic_read(&user->sigpending) <=
79012 task_rlimit(t, RLIMIT_SIGPENDING)) {
79013 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
79014
79015 int unhandled_signal(struct task_struct *tsk, int sig)
79016 {
79017 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
79018 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
79019 if (is_global_init(tsk))
79020 return 1;
79021 if (handler != SIG_IGN && handler != SIG_DFL)
79022 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
79023 }
79024 }
79025
79026 + /* allow glibc communication via tgkill to other threads in our
79027 + thread group */
79028 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
79029 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
79030 + && gr_handle_signal(t, sig))
79031 + return -EPERM;
79032 +
79033 return security_task_kill(t, info, sig, 0);
79034 }
79035
79036 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79037 return send_signal(sig, info, p, 1);
79038 }
79039
79040 -static int
79041 +int
79042 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79043 {
79044 return send_signal(sig, info, t, 0);
79045 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79046 unsigned long int flags;
79047 int ret, blocked, ignored;
79048 struct k_sigaction *action;
79049 + int is_unhandled = 0;
79050
79051 spin_lock_irqsave(&t->sighand->siglock, flags);
79052 action = &t->sighand->action[sig-1];
79053 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79054 }
79055 if (action->sa.sa_handler == SIG_DFL)
79056 t->signal->flags &= ~SIGNAL_UNKILLABLE;
79057 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
79058 + is_unhandled = 1;
79059 ret = specific_send_sig_info(sig, info, t);
79060 spin_unlock_irqrestore(&t->sighand->siglock, flags);
79061
79062 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
79063 + normal operation */
79064 + if (is_unhandled) {
79065 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
79066 + gr_handle_crash(t, sig);
79067 + }
79068 +
79069 return ret;
79070 }
79071
79072 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79073 ret = check_kill_permission(sig, info, p);
79074 rcu_read_unlock();
79075
79076 - if (!ret && sig)
79077 + if (!ret && sig) {
79078 ret = do_send_sig_info(sig, info, p, true);
79079 + if (!ret)
79080 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
79081 + }
79082
79083 return ret;
79084 }
79085 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
79086 int error = -ESRCH;
79087
79088 rcu_read_lock();
79089 - p = find_task_by_vpid(pid);
79090 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79091 + /* allow glibc communication via tgkill to other threads in our
79092 + thread group */
79093 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
79094 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
79095 + p = find_task_by_vpid_unrestricted(pid);
79096 + else
79097 +#endif
79098 + p = find_task_by_vpid(pid);
79099 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
79100 error = check_kill_permission(sig, info, p);
79101 /*
79102 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
79103 }
79104 seg = get_fs();
79105 set_fs(KERNEL_DS);
79106 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
79107 - (stack_t __force __user *) &uoss,
79108 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
79109 + (stack_t __force_user *) &uoss,
79110 compat_user_stack_pointer());
79111 set_fs(seg);
79112 if (ret >= 0 && uoss_ptr) {
79113 diff --git a/kernel/smp.c b/kernel/smp.c
79114 index 4dba0f7..fe9f773 100644
79115 --- a/kernel/smp.c
79116 +++ b/kernel/smp.c
79117 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
79118 return NOTIFY_OK;
79119 }
79120
79121 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
79122 +static struct notifier_block hotplug_cfd_notifier = {
79123 .notifier_call = hotplug_cfd,
79124 };
79125
79126 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
79127 index 02fc5c9..e54c335 100644
79128 --- a/kernel/smpboot.c
79129 +++ b/kernel/smpboot.c
79130 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
79131 }
79132 smpboot_unpark_thread(plug_thread, cpu);
79133 }
79134 - list_add(&plug_thread->list, &hotplug_threads);
79135 + pax_list_add(&plug_thread->list, &hotplug_threads);
79136 out:
79137 mutex_unlock(&smpboot_threads_lock);
79138 return ret;
79139 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79140 {
79141 get_online_cpus();
79142 mutex_lock(&smpboot_threads_lock);
79143 - list_del(&plug_thread->list);
79144 + pax_list_del(&plug_thread->list);
79145 smpboot_destroy_threads(plug_thread);
79146 mutex_unlock(&smpboot_threads_lock);
79147 put_online_cpus();
79148 diff --git a/kernel/softirq.c b/kernel/softirq.c
79149 index 3d6833f..da6d93d 100644
79150 --- a/kernel/softirq.c
79151 +++ b/kernel/softirq.c
79152 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79153 EXPORT_SYMBOL(irq_stat);
79154 #endif
79155
79156 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79157 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79158
79159 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79160
79161 -char *softirq_to_name[NR_SOFTIRQS] = {
79162 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79163 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79164 "TASKLET", "SCHED", "HRTIMER", "RCU"
79165 };
79166 @@ -250,7 +250,7 @@ restart:
79167 kstat_incr_softirqs_this_cpu(vec_nr);
79168
79169 trace_softirq_entry(vec_nr);
79170 - h->action(h);
79171 + h->action();
79172 trace_softirq_exit(vec_nr);
79173 if (unlikely(prev_count != preempt_count())) {
79174 printk(KERN_ERR "huh, entered softirq %u %s %p"
79175 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79176 or_softirq_pending(1UL << nr);
79177 }
79178
79179 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79180 +void __init open_softirq(int nr, void (*action)(void))
79181 {
79182 softirq_vec[nr].action = action;
79183 }
79184 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79185
79186 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79187
79188 -static void tasklet_action(struct softirq_action *a)
79189 +static void tasklet_action(void)
79190 {
79191 struct tasklet_struct *list;
79192
79193 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
79194 }
79195 }
79196
79197 -static void tasklet_hi_action(struct softirq_action *a)
79198 +static void tasklet_hi_action(void)
79199 {
79200 struct tasklet_struct *list;
79201
79202 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79203 return NOTIFY_OK;
79204 }
79205
79206 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79207 +static struct notifier_block remote_softirq_cpu_notifier = {
79208 .notifier_call = remote_softirq_cpu_notify,
79209 };
79210
79211 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
79212 return NOTIFY_OK;
79213 }
79214
79215 -static struct notifier_block __cpuinitdata cpu_nfb = {
79216 +static struct notifier_block cpu_nfb = {
79217 .notifier_call = cpu_callback
79218 };
79219
79220 -static struct smp_hotplug_thread softirq_threads = {
79221 +static struct smp_hotplug_thread softirq_threads __read_only = {
79222 .store = &ksoftirqd,
79223 .thread_should_run = ksoftirqd_should_run,
79224 .thread_fn = run_ksoftirqd,
79225 diff --git a/kernel/srcu.c b/kernel/srcu.c
79226 index 01d5ccb..cdcbee6 100644
79227 --- a/kernel/srcu.c
79228 +++ b/kernel/srcu.c
79229 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
79230
79231 idx = ACCESS_ONCE(sp->completed) & 0x1;
79232 preempt_disable();
79233 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79234 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79235 smp_mb(); /* B */ /* Avoid leaking the critical section. */
79236 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79237 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79238 preempt_enable();
79239 return idx;
79240 }
79241 diff --git a/kernel/sys.c b/kernel/sys.c
79242 index 2bbd9a7..0875671 100644
79243 --- a/kernel/sys.c
79244 +++ b/kernel/sys.c
79245 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
79246 error = -EACCES;
79247 goto out;
79248 }
79249 +
79250 + if (gr_handle_chroot_setpriority(p, niceval)) {
79251 + error = -EACCES;
79252 + goto out;
79253 + }
79254 +
79255 no_nice = security_task_setnice(p, niceval);
79256 if (no_nice) {
79257 error = no_nice;
79258 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
79259 goto error;
79260 }
79261
79262 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
79263 + goto error;
79264 +
79265 if (rgid != (gid_t) -1 ||
79266 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
79267 new->sgid = new->egid;
79268 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
79269 old = current_cred();
79270
79271 retval = -EPERM;
79272 +
79273 + if (gr_check_group_change(kgid, kgid, kgid))
79274 + goto error;
79275 +
79276 if (nsown_capable(CAP_SETGID))
79277 new->gid = new->egid = new->sgid = new->fsgid = kgid;
79278 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
79279 @@ -678,7 +691,7 @@ error:
79280 /*
79281 * change the user struct in a credentials set to match the new UID
79282 */
79283 -static int set_user(struct cred *new)
79284 +int set_user(struct cred *new)
79285 {
79286 struct user_struct *new_user;
79287
79288 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
79289 goto error;
79290 }
79291
79292 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
79293 + goto error;
79294 +
79295 if (!uid_eq(new->uid, old->uid)) {
79296 retval = set_user(new);
79297 if (retval < 0)
79298 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
79299 old = current_cred();
79300
79301 retval = -EPERM;
79302 +
79303 + if (gr_check_crash_uid(kuid))
79304 + goto error;
79305 + if (gr_check_user_change(kuid, kuid, kuid))
79306 + goto error;
79307 +
79308 if (nsown_capable(CAP_SETUID)) {
79309 new->suid = new->uid = kuid;
79310 if (!uid_eq(kuid, old->uid)) {
79311 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
79312 goto error;
79313 }
79314
79315 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
79316 + goto error;
79317 +
79318 if (ruid != (uid_t) -1) {
79319 new->uid = kruid;
79320 if (!uid_eq(kruid, old->uid)) {
79321 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79322 goto error;
79323 }
79324
79325 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79326 + goto error;
79327 +
79328 if (rgid != (gid_t) -1)
79329 new->gid = krgid;
79330 if (egid != (gid_t) -1)
79331 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79332 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79333 nsown_capable(CAP_SETUID)) {
79334 if (!uid_eq(kuid, old->fsuid)) {
79335 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79336 + goto error;
79337 +
79338 new->fsuid = kuid;
79339 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79340 goto change_okay;
79341 }
79342 }
79343
79344 +error:
79345 abort_creds(new);
79346 return old_fsuid;
79347
79348 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79349 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79350 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79351 nsown_capable(CAP_SETGID)) {
79352 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79353 + goto error;
79354 +
79355 if (!gid_eq(kgid, old->fsgid)) {
79356 new->fsgid = kgid;
79357 goto change_okay;
79358 }
79359 }
79360
79361 +error:
79362 abort_creds(new);
79363 return old_fsgid;
79364
79365 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79366 return -EFAULT;
79367
79368 down_read(&uts_sem);
79369 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79370 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79371 __OLD_UTS_LEN);
79372 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79373 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79374 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79375 __OLD_UTS_LEN);
79376 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79377 - error |= __copy_to_user(&name->release, &utsname()->release,
79378 + error |= __copy_to_user(name->release, &utsname()->release,
79379 __OLD_UTS_LEN);
79380 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79381 - error |= __copy_to_user(&name->version, &utsname()->version,
79382 + error |= __copy_to_user(name->version, &utsname()->version,
79383 __OLD_UTS_LEN);
79384 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79385 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79386 + error |= __copy_to_user(name->machine, &utsname()->machine,
79387 __OLD_UTS_LEN);
79388 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79389 up_read(&uts_sem);
79390 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79391 */
79392 new_rlim->rlim_cur = 1;
79393 }
79394 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79395 + is changed to a lower value. Since tasks can be created by the same
79396 + user in between this limit change and an execve by this task, force
79397 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79398 + */
79399 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
79400 + tsk->flags |= PF_NPROC_EXCEEDED;
79401 }
79402 if (!retval) {
79403 if (old_rlim)
79404 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79405 index 9edcf45..713c960 100644
79406 --- a/kernel/sysctl.c
79407 +++ b/kernel/sysctl.c
79408 @@ -93,7 +93,6 @@
79409
79410
79411 #if defined(CONFIG_SYSCTL)
79412 -
79413 /* External variables not in a header file. */
79414 extern int sysctl_overcommit_memory;
79415 extern int sysctl_overcommit_ratio;
79416 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
79417
79418 /* Constants used for minimum and maximum */
79419 #ifdef CONFIG_LOCKUP_DETECTOR
79420 -static int sixty = 60;
79421 -static int neg_one = -1;
79422 +static int sixty __read_only = 60;
79423 #endif
79424
79425 -static int zero;
79426 -static int __maybe_unused one = 1;
79427 -static int __maybe_unused two = 2;
79428 -static int __maybe_unused three = 3;
79429 -static unsigned long one_ul = 1;
79430 -static int one_hundred = 100;
79431 +static int neg_one __read_only = -1;
79432 +static int zero __read_only = 0;
79433 +static int __maybe_unused one __read_only = 1;
79434 +static int __maybe_unused two __read_only = 2;
79435 +static int __maybe_unused three __read_only = 3;
79436 +static unsigned long one_ul __read_only = 1;
79437 +static int one_hundred __read_only = 100;
79438 #ifdef CONFIG_PRINTK
79439 -static int ten_thousand = 10000;
79440 +static int ten_thousand __read_only = 10000;
79441 #endif
79442
79443 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
79444 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
79445 void __user *buffer, size_t *lenp, loff_t *ppos);
79446 #endif
79447
79448 -#ifdef CONFIG_PRINTK
79449 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79450 void __user *buffer, size_t *lenp, loff_t *ppos);
79451 -#endif
79452
79453 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79454 void __user *buffer, size_t *lenp, loff_t *ppos);
79455 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79456
79457 #endif
79458
79459 +extern struct ctl_table grsecurity_table[];
79460 +
79461 static struct ctl_table kern_table[];
79462 static struct ctl_table vm_table[];
79463 static struct ctl_table fs_table[];
79464 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
79465 int sysctl_legacy_va_layout;
79466 #endif
79467
79468 +#ifdef CONFIG_PAX_SOFTMODE
79469 +static ctl_table pax_table[] = {
79470 + {
79471 + .procname = "softmode",
79472 + .data = &pax_softmode,
79473 + .maxlen = sizeof(unsigned int),
79474 + .mode = 0600,
79475 + .proc_handler = &proc_dointvec,
79476 + },
79477 +
79478 + { }
79479 +};
79480 +#endif
79481 +
79482 /* The default sysctl tables: */
79483
79484 static struct ctl_table sysctl_base_table[] = {
79485 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
79486 #endif
79487
79488 static struct ctl_table kern_table[] = {
79489 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79490 + {
79491 + .procname = "grsecurity",
79492 + .mode = 0500,
79493 + .child = grsecurity_table,
79494 + },
79495 +#endif
79496 +
79497 +#ifdef CONFIG_PAX_SOFTMODE
79498 + {
79499 + .procname = "pax",
79500 + .mode = 0500,
79501 + .child = pax_table,
79502 + },
79503 +#endif
79504 +
79505 {
79506 .procname = "sched_child_runs_first",
79507 .data = &sysctl_sched_child_runs_first,
79508 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
79509 .data = &modprobe_path,
79510 .maxlen = KMOD_PATH_LEN,
79511 .mode = 0644,
79512 - .proc_handler = proc_dostring,
79513 + .proc_handler = proc_dostring_modpriv,
79514 },
79515 {
79516 .procname = "modules_disabled",
79517 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
79518 .extra1 = &zero,
79519 .extra2 = &one,
79520 },
79521 +#endif
79522 {
79523 .procname = "kptr_restrict",
79524 .data = &kptr_restrict,
79525 .maxlen = sizeof(int),
79526 .mode = 0644,
79527 .proc_handler = proc_dointvec_minmax_sysadmin,
79528 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79529 + .extra1 = &two,
79530 +#else
79531 .extra1 = &zero,
79532 +#endif
79533 .extra2 = &two,
79534 },
79535 -#endif
79536 {
79537 .procname = "ngroups_max",
79538 .data = &ngroups_max,
79539 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
79540 */
79541 {
79542 .procname = "perf_event_paranoid",
79543 - .data = &sysctl_perf_event_paranoid,
79544 - .maxlen = sizeof(sysctl_perf_event_paranoid),
79545 + .data = &sysctl_perf_event_legitimately_concerned,
79546 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
79547 .mode = 0644,
79548 - .proc_handler = proc_dointvec,
79549 + /* go ahead, be a hero */
79550 + .proc_handler = proc_dointvec_minmax_sysadmin,
79551 + .extra1 = &neg_one,
79552 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79553 + .extra2 = &three,
79554 +#else
79555 + .extra2 = &two,
79556 +#endif
79557 },
79558 {
79559 .procname = "perf_event_mlock_kb",
79560 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
79561 .proc_handler = proc_dointvec_minmax,
79562 .extra1 = &zero,
79563 },
79564 + {
79565 + .procname = "heap_stack_gap",
79566 + .data = &sysctl_heap_stack_gap,
79567 + .maxlen = sizeof(sysctl_heap_stack_gap),
79568 + .mode = 0644,
79569 + .proc_handler = proc_doulongvec_minmax,
79570 + },
79571 #else
79572 {
79573 .procname = "nr_trim_pages",
79574 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
79575 buffer, lenp, ppos);
79576 }
79577
79578 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79579 + void __user *buffer, size_t *lenp, loff_t *ppos)
79580 +{
79581 + if (write && !capable(CAP_SYS_MODULE))
79582 + return -EPERM;
79583 +
79584 + return _proc_do_string(table->data, table->maxlen, write,
79585 + buffer, lenp, ppos);
79586 +}
79587 +
79588 static size_t proc_skip_spaces(char **buf)
79589 {
79590 size_t ret;
79591 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79592 len = strlen(tmp);
79593 if (len > *size)
79594 len = *size;
79595 + if (len > sizeof(tmp))
79596 + len = sizeof(tmp);
79597 if (copy_to_user(*buf, tmp, len))
79598 return -EFAULT;
79599 *size -= len;
79600 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79601 static int proc_taint(struct ctl_table *table, int write,
79602 void __user *buffer, size_t *lenp, loff_t *ppos)
79603 {
79604 - struct ctl_table t;
79605 + ctl_table_no_const t;
79606 unsigned long tmptaint = get_taint();
79607 int err;
79608
79609 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
79610 return err;
79611 }
79612
79613 -#ifdef CONFIG_PRINTK
79614 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79615 void __user *buffer, size_t *lenp, loff_t *ppos)
79616 {
79617 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79618
79619 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79620 }
79621 -#endif
79622
79623 struct do_proc_dointvec_minmax_conv_param {
79624 int *min;
79625 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79626 *i = val;
79627 } else {
79628 val = convdiv * (*i) / convmul;
79629 - if (!first)
79630 + if (!first) {
79631 err = proc_put_char(&buffer, &left, '\t');
79632 + if (err)
79633 + break;
79634 + }
79635 err = proc_put_long(&buffer, &left, val, false);
79636 if (err)
79637 break;
79638 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
79639 return -ENOSYS;
79640 }
79641
79642 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79643 + void __user *buffer, size_t *lenp, loff_t *ppos)
79644 +{
79645 + return -ENOSYS;
79646 +}
79647 +
79648 int proc_dointvec(struct ctl_table *table, int write,
79649 void __user *buffer, size_t *lenp, loff_t *ppos)
79650 {
79651 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79652 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79653 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79654 EXPORT_SYMBOL(proc_dostring);
79655 +EXPORT_SYMBOL(proc_dostring_modpriv);
79656 EXPORT_SYMBOL(proc_doulongvec_minmax);
79657 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79658 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79659 index 145bb4d..b2aa969 100644
79660 --- a/kernel/taskstats.c
79661 +++ b/kernel/taskstats.c
79662 @@ -28,9 +28,12 @@
79663 #include <linux/fs.h>
79664 #include <linux/file.h>
79665 #include <linux/pid_namespace.h>
79666 +#include <linux/grsecurity.h>
79667 #include <net/genetlink.h>
79668 #include <linux/atomic.h>
79669
79670 +extern int gr_is_taskstats_denied(int pid);
79671 +
79672 /*
79673 * Maximum length of a cpumask that can be specified in
79674 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79675 @@ -570,6 +573,9 @@ err:
79676
79677 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79678 {
79679 + if (gr_is_taskstats_denied(current->pid))
79680 + return -EACCES;
79681 +
79682 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79683 return cmd_attr_register_cpumask(info);
79684 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79685 diff --git a/kernel/time.c b/kernel/time.c
79686 index d3617db..c98bbe9 100644
79687 --- a/kernel/time.c
79688 +++ b/kernel/time.c
79689 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79690 return error;
79691
79692 if (tz) {
79693 + /* we log in do_settimeofday called below, so don't log twice
79694 + */
79695 + if (!tv)
79696 + gr_log_timechange();
79697 +
79698 sys_tz = *tz;
79699 update_vsyscall_tz();
79700 if (firsttime) {
79701 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79702 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79703 * value to a scaled second value.
79704 */
79705 -unsigned long
79706 +unsigned long __intentional_overflow(-1)
79707 timespec_to_jiffies(const struct timespec *value)
79708 {
79709 unsigned long sec = value->tv_sec;
79710 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79711 index f11d83b..d016d91 100644
79712 --- a/kernel/time/alarmtimer.c
79713 +++ b/kernel/time/alarmtimer.c
79714 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79715 struct platform_device *pdev;
79716 int error = 0;
79717 int i;
79718 - struct k_clock alarm_clock = {
79719 + static struct k_clock alarm_clock = {
79720 .clock_getres = alarm_clock_getres,
79721 .clock_get = alarm_clock_get,
79722 .timer_create = alarm_timer_create,
79723 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79724 index 20d6fba..09e103a 100644
79725 --- a/kernel/time/tick-broadcast.c
79726 +++ b/kernel/time/tick-broadcast.c
79727 @@ -147,7 +147,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79728 * then clear the broadcast bit.
79729 */
79730 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79731 - int cpu = smp_processor_id();
79732 + cpu = smp_processor_id();
79733 cpumask_clear_cpu(cpu, tick_broadcast_mask);
79734 tick_broadcast_clear_oneshot(cpu);
79735 } else {
79736 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79737 index baeeb5c..c22704a 100644
79738 --- a/kernel/time/timekeeping.c
79739 +++ b/kernel/time/timekeeping.c
79740 @@ -15,6 +15,7 @@
79741 #include <linux/init.h>
79742 #include <linux/mm.h>
79743 #include <linux/sched.h>
79744 +#include <linux/grsecurity.h>
79745 #include <linux/syscore_ops.h>
79746 #include <linux/clocksource.h>
79747 #include <linux/jiffies.h>
79748 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
79749 if (!timespec_valid_strict(tv))
79750 return -EINVAL;
79751
79752 + gr_log_timechange();
79753 +
79754 raw_spin_lock_irqsave(&timekeeper_lock, flags);
79755 write_seqcount_begin(&timekeeper_seq);
79756
79757 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79758 index 3bdf283..cc68d83 100644
79759 --- a/kernel/time/timer_list.c
79760 +++ b/kernel/time/timer_list.c
79761 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79762
79763 static void print_name_offset(struct seq_file *m, void *sym)
79764 {
79765 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79766 + SEQ_printf(m, "<%p>", NULL);
79767 +#else
79768 char symname[KSYM_NAME_LEN];
79769
79770 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79771 SEQ_printf(m, "<%pK>", sym);
79772 else
79773 SEQ_printf(m, "%s", symname);
79774 +#endif
79775 }
79776
79777 static void
79778 @@ -119,7 +123,11 @@ next_one:
79779 static void
79780 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79781 {
79782 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79783 + SEQ_printf(m, " .base: %p\n", NULL);
79784 +#else
79785 SEQ_printf(m, " .base: %pK\n", base);
79786 +#endif
79787 SEQ_printf(m, " .index: %d\n",
79788 base->index);
79789 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79790 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
79791 {
79792 struct proc_dir_entry *pe;
79793
79794 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79795 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79796 +#else
79797 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79798 +#endif
79799 if (!pe)
79800 return -ENOMEM;
79801 return 0;
79802 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79803 index 0b537f2..40d6c20 100644
79804 --- a/kernel/time/timer_stats.c
79805 +++ b/kernel/time/timer_stats.c
79806 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79807 static unsigned long nr_entries;
79808 static struct entry entries[MAX_ENTRIES];
79809
79810 -static atomic_t overflow_count;
79811 +static atomic_unchecked_t overflow_count;
79812
79813 /*
79814 * The entries are in a hash-table, for fast lookup:
79815 @@ -140,7 +140,7 @@ static void reset_entries(void)
79816 nr_entries = 0;
79817 memset(entries, 0, sizeof(entries));
79818 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79819 - atomic_set(&overflow_count, 0);
79820 + atomic_set_unchecked(&overflow_count, 0);
79821 }
79822
79823 static struct entry *alloc_entry(void)
79824 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79825 if (likely(entry))
79826 entry->count++;
79827 else
79828 - atomic_inc(&overflow_count);
79829 + atomic_inc_unchecked(&overflow_count);
79830
79831 out_unlock:
79832 raw_spin_unlock_irqrestore(lock, flags);
79833 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79834
79835 static void print_name_offset(struct seq_file *m, unsigned long addr)
79836 {
79837 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79838 + seq_printf(m, "<%p>", NULL);
79839 +#else
79840 char symname[KSYM_NAME_LEN];
79841
79842 if (lookup_symbol_name(addr, symname) < 0)
79843 - seq_printf(m, "<%p>", (void *)addr);
79844 + seq_printf(m, "<%pK>", (void *)addr);
79845 else
79846 seq_printf(m, "%s", symname);
79847 +#endif
79848 }
79849
79850 static int tstats_show(struct seq_file *m, void *v)
79851 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79852
79853 seq_puts(m, "Timer Stats Version: v0.2\n");
79854 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79855 - if (atomic_read(&overflow_count))
79856 + if (atomic_read_unchecked(&overflow_count))
79857 seq_printf(m, "Overflow: %d entries\n",
79858 - atomic_read(&overflow_count));
79859 + atomic_read_unchecked(&overflow_count));
79860
79861 for (i = 0; i < nr_entries; i++) {
79862 entry = entries + i;
79863 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79864 {
79865 struct proc_dir_entry *pe;
79866
79867 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79868 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79869 +#else
79870 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79871 +#endif
79872 if (!pe)
79873 return -ENOMEM;
79874 return 0;
79875 diff --git a/kernel/timer.c b/kernel/timer.c
79876 index 15ffdb3..62d885c 100644
79877 --- a/kernel/timer.c
79878 +++ b/kernel/timer.c
79879 @@ -1364,7 +1364,7 @@ void update_process_times(int user_tick)
79880 /*
79881 * This function runs timers and the timer-tq in bottom half context.
79882 */
79883 -static void run_timer_softirq(struct softirq_action *h)
79884 +static void run_timer_softirq(void)
79885 {
79886 struct tvec_base *base = __this_cpu_read(tvec_bases);
79887
79888 @@ -1427,7 +1427,7 @@ static void process_timeout(unsigned long __data)
79889 *
79890 * In all cases the return value is guaranteed to be non-negative.
79891 */
79892 -signed long __sched schedule_timeout(signed long timeout)
79893 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79894 {
79895 struct timer_list timer;
79896 unsigned long expire;
79897 @@ -1633,7 +1633,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79898 return NOTIFY_OK;
79899 }
79900
79901 -static struct notifier_block __cpuinitdata timers_nb = {
79902 +static struct notifier_block timers_nb = {
79903 .notifier_call = timer_cpu_notify,
79904 };
79905
79906 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79907 index b8b8560..75b1a09 100644
79908 --- a/kernel/trace/blktrace.c
79909 +++ b/kernel/trace/blktrace.c
79910 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79911 struct blk_trace *bt = filp->private_data;
79912 char buf[16];
79913
79914 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79915 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79916
79917 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79918 }
79919 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79920 return 1;
79921
79922 bt = buf->chan->private_data;
79923 - atomic_inc(&bt->dropped);
79924 + atomic_inc_unchecked(&bt->dropped);
79925 return 0;
79926 }
79927
79928 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79929
79930 bt->dir = dir;
79931 bt->dev = dev;
79932 - atomic_set(&bt->dropped, 0);
79933 + atomic_set_unchecked(&bt->dropped, 0);
79934
79935 ret = -EIO;
79936 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79937 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79938 index 6c508ff..ee55a13 100644
79939 --- a/kernel/trace/ftrace.c
79940 +++ b/kernel/trace/ftrace.c
79941 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79942 if (unlikely(ftrace_disabled))
79943 return 0;
79944
79945 + ret = ftrace_arch_code_modify_prepare();
79946 + FTRACE_WARN_ON(ret);
79947 + if (ret)
79948 + return 0;
79949 +
79950 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79951 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79952 if (ret) {
79953 ftrace_bug(ret, ip);
79954 - return 0;
79955 }
79956 - return 1;
79957 + return ret ? 0 : 1;
79958 }
79959
79960 /*
79961 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
79962 if (!count)
79963 return 0;
79964
79965 + pax_open_kernel();
79966 sort(start, count, sizeof(*start),
79967 ftrace_cmp_ips, ftrace_swap_ips);
79968 + pax_close_kernel();
79969
79970 start_pg = ftrace_allocate_pages(count);
79971 if (!start_pg)
79972 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79973 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79974
79975 static int ftrace_graph_active;
79976 -static struct notifier_block ftrace_suspend_notifier;
79977 -
79978 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79979 {
79980 return 0;
79981 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79982 return NOTIFY_DONE;
79983 }
79984
79985 +static struct notifier_block ftrace_suspend_notifier = {
79986 + .notifier_call = ftrace_suspend_notifier_call
79987 +};
79988 +
79989 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79990 trace_func_graph_ent_t entryfunc)
79991 {
79992 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79993 goto out;
79994 }
79995
79996 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79997 register_pm_notifier(&ftrace_suspend_notifier);
79998
79999 ftrace_graph_active++;
80000 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
80001 index e444ff8..438b8f4 100644
80002 --- a/kernel/trace/ring_buffer.c
80003 +++ b/kernel/trace/ring_buffer.c
80004 @@ -352,9 +352,9 @@ struct buffer_data_page {
80005 */
80006 struct buffer_page {
80007 struct list_head list; /* list of buffer pages */
80008 - local_t write; /* index for next write */
80009 + local_unchecked_t write; /* index for next write */
80010 unsigned read; /* index for next read */
80011 - local_t entries; /* entries on this page */
80012 + local_unchecked_t entries; /* entries on this page */
80013 unsigned long real_end; /* real end of data */
80014 struct buffer_data_page *page; /* Actual data page */
80015 };
80016 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
80017 unsigned long last_overrun;
80018 local_t entries_bytes;
80019 local_t entries;
80020 - local_t overrun;
80021 - local_t commit_overrun;
80022 + local_unchecked_t overrun;
80023 + local_unchecked_t commit_overrun;
80024 local_t dropped_events;
80025 local_t committing;
80026 local_t commits;
80027 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80028 *
80029 * We add a counter to the write field to denote this.
80030 */
80031 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
80032 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
80033 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
80034 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
80035
80036 /*
80037 * Just make sure we have seen our old_write and synchronize
80038 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80039 * cmpxchg to only update if an interrupt did not already
80040 * do it for us. If the cmpxchg fails, we don't care.
80041 */
80042 - (void)local_cmpxchg(&next_page->write, old_write, val);
80043 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
80044 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
80045 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
80046
80047 /*
80048 * No need to worry about races with clearing out the commit.
80049 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
80050
80051 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
80052 {
80053 - return local_read(&bpage->entries) & RB_WRITE_MASK;
80054 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
80055 }
80056
80057 static inline unsigned long rb_page_write(struct buffer_page *bpage)
80058 {
80059 - return local_read(&bpage->write) & RB_WRITE_MASK;
80060 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
80061 }
80062
80063 static int
80064 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
80065 * bytes consumed in ring buffer from here.
80066 * Increment overrun to account for the lost events.
80067 */
80068 - local_add(page_entries, &cpu_buffer->overrun);
80069 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
80070 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80071 }
80072
80073 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
80074 * it is our responsibility to update
80075 * the counters.
80076 */
80077 - local_add(entries, &cpu_buffer->overrun);
80078 + local_add_unchecked(entries, &cpu_buffer->overrun);
80079 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80080
80081 /*
80082 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80083 if (tail == BUF_PAGE_SIZE)
80084 tail_page->real_end = 0;
80085
80086 - local_sub(length, &tail_page->write);
80087 + local_sub_unchecked(length, &tail_page->write);
80088 return;
80089 }
80090
80091 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80092 rb_event_set_padding(event);
80093
80094 /* Set the write back to the previous setting */
80095 - local_sub(length, &tail_page->write);
80096 + local_sub_unchecked(length, &tail_page->write);
80097 return;
80098 }
80099
80100 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80101
80102 /* Set write to end of buffer */
80103 length = (tail + length) - BUF_PAGE_SIZE;
80104 - local_sub(length, &tail_page->write);
80105 + local_sub_unchecked(length, &tail_page->write);
80106 }
80107
80108 /*
80109 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80110 * about it.
80111 */
80112 if (unlikely(next_page == commit_page)) {
80113 - local_inc(&cpu_buffer->commit_overrun);
80114 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80115 goto out_reset;
80116 }
80117
80118 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80119 cpu_buffer->tail_page) &&
80120 (cpu_buffer->commit_page ==
80121 cpu_buffer->reader_page))) {
80122 - local_inc(&cpu_buffer->commit_overrun);
80123 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80124 goto out_reset;
80125 }
80126 }
80127 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80128 length += RB_LEN_TIME_EXTEND;
80129
80130 tail_page = cpu_buffer->tail_page;
80131 - write = local_add_return(length, &tail_page->write);
80132 + write = local_add_return_unchecked(length, &tail_page->write);
80133
80134 /* set write to only the index of the write */
80135 write &= RB_WRITE_MASK;
80136 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80137 kmemcheck_annotate_bitfield(event, bitfield);
80138 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80139
80140 - local_inc(&tail_page->entries);
80141 + local_inc_unchecked(&tail_page->entries);
80142
80143 /*
80144 * If this is the first commit on the page, then update
80145 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80146
80147 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80148 unsigned long write_mask =
80149 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80150 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80151 unsigned long event_length = rb_event_length(event);
80152 /*
80153 * This is on the tail page. It is possible that
80154 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80155 */
80156 old_index += write_mask;
80157 new_index += write_mask;
80158 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80159 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80160 if (index == old_index) {
80161 /* update counters */
80162 local_sub(event_length, &cpu_buffer->entries_bytes);
80163 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80164
80165 /* Do the likely case first */
80166 if (likely(bpage->page == (void *)addr)) {
80167 - local_dec(&bpage->entries);
80168 + local_dec_unchecked(&bpage->entries);
80169 return;
80170 }
80171
80172 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80173 start = bpage;
80174 do {
80175 if (bpage->page == (void *)addr) {
80176 - local_dec(&bpage->entries);
80177 + local_dec_unchecked(&bpage->entries);
80178 return;
80179 }
80180 rb_inc_page(cpu_buffer, &bpage);
80181 @@ -3138,7 +3138,7 @@ static inline unsigned long
80182 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80183 {
80184 return local_read(&cpu_buffer->entries) -
80185 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80186 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80187 }
80188
80189 /**
80190 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80191 return 0;
80192
80193 cpu_buffer = buffer->buffers[cpu];
80194 - ret = local_read(&cpu_buffer->overrun);
80195 + ret = local_read_unchecked(&cpu_buffer->overrun);
80196
80197 return ret;
80198 }
80199 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80200 return 0;
80201
80202 cpu_buffer = buffer->buffers[cpu];
80203 - ret = local_read(&cpu_buffer->commit_overrun);
80204 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80205
80206 return ret;
80207 }
80208 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80209 /* if you care about this being correct, lock the buffer */
80210 for_each_buffer_cpu(buffer, cpu) {
80211 cpu_buffer = buffer->buffers[cpu];
80212 - overruns += local_read(&cpu_buffer->overrun);
80213 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80214 }
80215
80216 return overruns;
80217 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80218 /*
80219 * Reset the reader page to size zero.
80220 */
80221 - local_set(&cpu_buffer->reader_page->write, 0);
80222 - local_set(&cpu_buffer->reader_page->entries, 0);
80223 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80224 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80225 local_set(&cpu_buffer->reader_page->page->commit, 0);
80226 cpu_buffer->reader_page->real_end = 0;
80227
80228 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80229 * want to compare with the last_overrun.
80230 */
80231 smp_mb();
80232 - overwrite = local_read(&(cpu_buffer->overrun));
80233 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
80234
80235 /*
80236 * Here's the tricky part.
80237 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80238
80239 cpu_buffer->head_page
80240 = list_entry(cpu_buffer->pages, struct buffer_page, list);
80241 - local_set(&cpu_buffer->head_page->write, 0);
80242 - local_set(&cpu_buffer->head_page->entries, 0);
80243 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
80244 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
80245 local_set(&cpu_buffer->head_page->page->commit, 0);
80246
80247 cpu_buffer->head_page->read = 0;
80248 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80249
80250 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
80251 INIT_LIST_HEAD(&cpu_buffer->new_pages);
80252 - local_set(&cpu_buffer->reader_page->write, 0);
80253 - local_set(&cpu_buffer->reader_page->entries, 0);
80254 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80255 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80256 local_set(&cpu_buffer->reader_page->page->commit, 0);
80257 cpu_buffer->reader_page->read = 0;
80258
80259 local_set(&cpu_buffer->entries_bytes, 0);
80260 - local_set(&cpu_buffer->overrun, 0);
80261 - local_set(&cpu_buffer->commit_overrun, 0);
80262 + local_set_unchecked(&cpu_buffer->overrun, 0);
80263 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
80264 local_set(&cpu_buffer->dropped_events, 0);
80265 local_set(&cpu_buffer->entries, 0);
80266 local_set(&cpu_buffer->committing, 0);
80267 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
80268 rb_init_page(bpage);
80269 bpage = reader->page;
80270 reader->page = *data_page;
80271 - local_set(&reader->write, 0);
80272 - local_set(&reader->entries, 0);
80273 + local_set_unchecked(&reader->write, 0);
80274 + local_set_unchecked(&reader->entries, 0);
80275 reader->read = 0;
80276 *data_page = bpage;
80277
80278 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
80279 index e71a8be..948710a 100644
80280 --- a/kernel/trace/trace.c
80281 +++ b/kernel/trace/trace.c
80282 @@ -3201,7 +3201,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
80283 return 0;
80284 }
80285
80286 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
80287 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
80288 {
80289 /* do nothing if flag is already set */
80290 if (!!(trace_flags & mask) == !!enabled)
80291 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
80292 index 20572ed..fe55cf3 100644
80293 --- a/kernel/trace/trace.h
80294 +++ b/kernel/trace/trace.h
80295 @@ -1030,7 +1030,7 @@ extern const char *__stop___trace_bprintk_fmt[];
80296 void trace_printk_init_buffers(void);
80297 void trace_printk_start_comm(void);
80298 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
80299 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
80300 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
80301
80302 /*
80303 * Normal trace_printk() and friends allocates special buffers
80304 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80305 index 27963e2..5a6936f 100644
80306 --- a/kernel/trace/trace_events.c
80307 +++ b/kernel/trace/trace_events.c
80308 @@ -1637,10 +1637,6 @@ static LIST_HEAD(ftrace_module_file_list);
80309 struct ftrace_module_file_ops {
80310 struct list_head list;
80311 struct module *mod;
80312 - struct file_operations id;
80313 - struct file_operations enable;
80314 - struct file_operations format;
80315 - struct file_operations filter;
80316 };
80317
80318 static struct ftrace_module_file_ops *
80319 @@ -1681,17 +1677,12 @@ trace_create_file_ops(struct module *mod)
80320
80321 file_ops->mod = mod;
80322
80323 - file_ops->id = ftrace_event_id_fops;
80324 - file_ops->id.owner = mod;
80325 -
80326 - file_ops->enable = ftrace_enable_fops;
80327 - file_ops->enable.owner = mod;
80328 -
80329 - file_ops->filter = ftrace_event_filter_fops;
80330 - file_ops->filter.owner = mod;
80331 -
80332 - file_ops->format = ftrace_event_format_fops;
80333 - file_ops->format.owner = mod;
80334 + pax_open_kernel();
80335 + mod->trace_id.owner = mod;
80336 + mod->trace_enable.owner = mod;
80337 + mod->trace_filter.owner = mod;
80338 + mod->trace_format.owner = mod;
80339 + pax_close_kernel();
80340
80341 list_add(&file_ops->list, &ftrace_module_file_list);
80342
80343 @@ -1782,8 +1773,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
80344 struct ftrace_module_file_ops *file_ops)
80345 {
80346 return __trace_add_new_event(call, tr,
80347 - &file_ops->id, &file_ops->enable,
80348 - &file_ops->filter, &file_ops->format);
80349 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
80350 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
80351 }
80352
80353 #else
80354 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80355 index a5e8f48..a9690d2 100644
80356 --- a/kernel/trace/trace_mmiotrace.c
80357 +++ b/kernel/trace/trace_mmiotrace.c
80358 @@ -24,7 +24,7 @@ struct header_iter {
80359 static struct trace_array *mmio_trace_array;
80360 static bool overrun_detected;
80361 static unsigned long prev_overruns;
80362 -static atomic_t dropped_count;
80363 +static atomic_unchecked_t dropped_count;
80364
80365 static void mmio_reset_data(struct trace_array *tr)
80366 {
80367 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80368
80369 static unsigned long count_overruns(struct trace_iterator *iter)
80370 {
80371 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80372 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80373 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
80374
80375 if (over > prev_overruns)
80376 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80377 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80378 sizeof(*entry), 0, pc);
80379 if (!event) {
80380 - atomic_inc(&dropped_count);
80381 + atomic_inc_unchecked(&dropped_count);
80382 return;
80383 }
80384 entry = ring_buffer_event_data(event);
80385 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80386 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80387 sizeof(*entry), 0, pc);
80388 if (!event) {
80389 - atomic_inc(&dropped_count);
80390 + atomic_inc_unchecked(&dropped_count);
80391 return;
80392 }
80393 entry = ring_buffer_event_data(event);
80394 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80395 index bb922d9..2a54a257 100644
80396 --- a/kernel/trace/trace_output.c
80397 +++ b/kernel/trace/trace_output.c
80398 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80399
80400 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80401 if (!IS_ERR(p)) {
80402 - p = mangle_path(s->buffer + s->len, p, "\n");
80403 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80404 if (p) {
80405 s->len = p - s->buffer;
80406 return 1;
80407 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
80408 goto out;
80409 }
80410
80411 + pax_open_kernel();
80412 if (event->funcs->trace == NULL)
80413 - event->funcs->trace = trace_nop_print;
80414 + *(void **)&event->funcs->trace = trace_nop_print;
80415 if (event->funcs->raw == NULL)
80416 - event->funcs->raw = trace_nop_print;
80417 + *(void **)&event->funcs->raw = trace_nop_print;
80418 if (event->funcs->hex == NULL)
80419 - event->funcs->hex = trace_nop_print;
80420 + *(void **)&event->funcs->hex = trace_nop_print;
80421 if (event->funcs->binary == NULL)
80422 - event->funcs->binary = trace_nop_print;
80423 + *(void **)&event->funcs->binary = trace_nop_print;
80424 + pax_close_kernel();
80425
80426 key = event->type & (EVENT_HASHSIZE - 1);
80427
80428 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80429 index b20428c..4845a10 100644
80430 --- a/kernel/trace/trace_stack.c
80431 +++ b/kernel/trace/trace_stack.c
80432 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80433 return;
80434
80435 /* we do not handle interrupt stacks yet */
80436 - if (!object_is_on_stack(stack))
80437 + if (!object_starts_on_stack(stack))
80438 return;
80439
80440 local_irq_save(flags);
80441 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80442 index d8c30db..e065e89 100644
80443 --- a/kernel/user_namespace.c
80444 +++ b/kernel/user_namespace.c
80445 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80446 if (atomic_read(&current->mm->mm_users) > 1)
80447 return -EINVAL;
80448
80449 - if (current->fs->users != 1)
80450 + if (atomic_read(&current->fs->users) != 1)
80451 return -EINVAL;
80452
80453 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80454 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80455 index 4f69f9a..7c6f8f8 100644
80456 --- a/kernel/utsname_sysctl.c
80457 +++ b/kernel/utsname_sysctl.c
80458 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80459 static int proc_do_uts_string(ctl_table *table, int write,
80460 void __user *buffer, size_t *lenp, loff_t *ppos)
80461 {
80462 - struct ctl_table uts_table;
80463 + ctl_table_no_const uts_table;
80464 int r;
80465 memcpy(&uts_table, table, sizeof(uts_table));
80466 uts_table.data = get_uts(table, write);
80467 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80468 index 05039e3..17490c7 100644
80469 --- a/kernel/watchdog.c
80470 +++ b/kernel/watchdog.c
80471 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80472 }
80473 #endif /* CONFIG_SYSCTL */
80474
80475 -static struct smp_hotplug_thread watchdog_threads = {
80476 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80477 .store = &softlockup_watchdog,
80478 .thread_should_run = watchdog_should_run,
80479 .thread_fn = watchdog,
80480 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
80481 index ee8e29a..410568e 100644
80482 --- a/kernel/workqueue.c
80483 +++ b/kernel/workqueue.c
80484 @@ -4584,7 +4584,7 @@ static void rebind_workers(struct worker_pool *pool)
80485 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
80486 worker_flags |= WORKER_REBOUND;
80487 worker_flags &= ~WORKER_UNBOUND;
80488 - ACCESS_ONCE(worker->flags) = worker_flags;
80489 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
80490 }
80491
80492 spin_unlock_irq(&pool->lock);
80493 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80494 index 566cf2b..fdaa52c 100644
80495 --- a/lib/Kconfig.debug
80496 +++ b/lib/Kconfig.debug
80497 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
80498
80499 config DEBUG_LOCK_ALLOC
80500 bool "Lock debugging: detect incorrect freeing of live locks"
80501 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80502 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80503 select DEBUG_SPINLOCK
80504 select DEBUG_MUTEXES
80505 select LOCKDEP
80506 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
80507
80508 config PROVE_LOCKING
80509 bool "Lock debugging: prove locking correctness"
80510 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80511 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80512 select LOCKDEP
80513 select DEBUG_SPINLOCK
80514 select DEBUG_MUTEXES
80515 @@ -614,7 +614,7 @@ config LOCKDEP
80516
80517 config LOCK_STAT
80518 bool "Lock usage statistics"
80519 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80520 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80521 select LOCKDEP
80522 select DEBUG_SPINLOCK
80523 select DEBUG_MUTEXES
80524 @@ -1282,6 +1282,7 @@ config LATENCYTOP
80525 depends on DEBUG_KERNEL
80526 depends on STACKTRACE_SUPPORT
80527 depends on PROC_FS
80528 + depends on !GRKERNSEC_HIDESYM
80529 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80530 select KALLSYMS
80531 select KALLSYMS_ALL
80532 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80533 config DEBUG_STRICT_USER_COPY_CHECKS
80534 bool "Strict user copy size checks"
80535 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80536 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
80537 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
80538 help
80539 Enabling this option turns a certain set of sanity checks for user
80540 copy operations into compile time failures.
80541 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
80542
80543 config PROVIDE_OHCI1394_DMA_INIT
80544 bool "Remote debugging over FireWire early on boot"
80545 - depends on PCI && X86
80546 + depends on PCI && X86 && !GRKERNSEC
80547 help
80548 If you want to debug problems which hang or crash the kernel early
80549 on boot and the crashing machine has a FireWire port, you can use
80550 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80551
80552 config FIREWIRE_OHCI_REMOTE_DMA
80553 bool "Remote debugging over FireWire with firewire-ohci"
80554 - depends on FIREWIRE_OHCI
80555 + depends on FIREWIRE_OHCI && !GRKERNSEC
80556 help
80557 This option lets you use the FireWire bus for remote debugging
80558 with help of the firewire-ohci driver. It enables unfiltered
80559 diff --git a/lib/Makefile b/lib/Makefile
80560 index c55a037..fb46e3b 100644
80561 --- a/lib/Makefile
80562 +++ b/lib/Makefile
80563 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80564
80565 obj-$(CONFIG_BTREE) += btree.o
80566 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80567 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80568 +obj-y += list_debug.o
80569 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80570
80571 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80572 diff --git a/lib/bitmap.c b/lib/bitmap.c
80573 index 06f7e4f..f3cf2b0 100644
80574 --- a/lib/bitmap.c
80575 +++ b/lib/bitmap.c
80576 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80577 {
80578 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80579 u32 chunk;
80580 - const char __user __force *ubuf = (const char __user __force *)buf;
80581 + const char __user *ubuf = (const char __force_user *)buf;
80582
80583 bitmap_zero(maskp, nmaskbits);
80584
80585 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80586 {
80587 if (!access_ok(VERIFY_READ, ubuf, ulen))
80588 return -EFAULT;
80589 - return __bitmap_parse((const char __force *)ubuf,
80590 + return __bitmap_parse((const char __force_kernel *)ubuf,
80591 ulen, 1, maskp, nmaskbits);
80592
80593 }
80594 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80595 {
80596 unsigned a, b;
80597 int c, old_c, totaldigits;
80598 - const char __user __force *ubuf = (const char __user __force *)buf;
80599 + const char __user *ubuf = (const char __force_user *)buf;
80600 int exp_digit, in_range;
80601
80602 totaldigits = c = 0;
80603 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80604 {
80605 if (!access_ok(VERIFY_READ, ubuf, ulen))
80606 return -EFAULT;
80607 - return __bitmap_parselist((const char __force *)ubuf,
80608 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80609 ulen, 1, maskp, nmaskbits);
80610 }
80611 EXPORT_SYMBOL(bitmap_parselist_user);
80612 diff --git a/lib/bug.c b/lib/bug.c
80613 index 1686034..a9c00c8 100644
80614 --- a/lib/bug.c
80615 +++ b/lib/bug.c
80616 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80617 return BUG_TRAP_TYPE_NONE;
80618
80619 bug = find_bug(bugaddr);
80620 + if (!bug)
80621 + return BUG_TRAP_TYPE_NONE;
80622
80623 file = NULL;
80624 line = 0;
80625 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80626 index 37061ed..da83f48 100644
80627 --- a/lib/debugobjects.c
80628 +++ b/lib/debugobjects.c
80629 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80630 if (limit > 4)
80631 return;
80632
80633 - is_on_stack = object_is_on_stack(addr);
80634 + is_on_stack = object_starts_on_stack(addr);
80635 if (is_on_stack == onstack)
80636 return;
80637
80638 diff --git a/lib/devres.c b/lib/devres.c
80639 index 8235331..5881053 100644
80640 --- a/lib/devres.c
80641 +++ b/lib/devres.c
80642 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80643 void devm_iounmap(struct device *dev, void __iomem *addr)
80644 {
80645 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80646 - (void *)addr));
80647 + (void __force *)addr));
80648 iounmap(addr);
80649 }
80650 EXPORT_SYMBOL(devm_iounmap);
80651 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80652 {
80653 ioport_unmap(addr);
80654 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80655 - devm_ioport_map_match, (void *)addr));
80656 + devm_ioport_map_match, (void __force *)addr));
80657 }
80658 EXPORT_SYMBOL(devm_ioport_unmap);
80659 #endif /* CONFIG_HAS_IOPORT */
80660 diff --git a/lib/div64.c b/lib/div64.c
80661 index a163b6c..9618fa5 100644
80662 --- a/lib/div64.c
80663 +++ b/lib/div64.c
80664 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80665 EXPORT_SYMBOL(__div64_32);
80666
80667 #ifndef div_s64_rem
80668 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80669 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80670 {
80671 u64 quotient;
80672
80673 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80674 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80675 */
80676 #ifndef div64_u64
80677 -u64 div64_u64(u64 dividend, u64 divisor)
80678 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80679 {
80680 u32 high = divisor >> 32;
80681 u64 quot;
80682 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80683 index d87a17a..ac0d79a 100644
80684 --- a/lib/dma-debug.c
80685 +++ b/lib/dma-debug.c
80686 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80687
80688 void dma_debug_add_bus(struct bus_type *bus)
80689 {
80690 - struct notifier_block *nb;
80691 + notifier_block_no_const *nb;
80692
80693 if (global_disable)
80694 return;
80695 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80696
80697 static void check_for_stack(struct device *dev, void *addr)
80698 {
80699 - if (object_is_on_stack(addr))
80700 + if (object_starts_on_stack(addr))
80701 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80702 "stack [addr=%p]\n", addr);
80703 }
80704 diff --git a/lib/inflate.c b/lib/inflate.c
80705 index 013a761..c28f3fc 100644
80706 --- a/lib/inflate.c
80707 +++ b/lib/inflate.c
80708 @@ -269,7 +269,7 @@ static void free(void *where)
80709 malloc_ptr = free_mem_ptr;
80710 }
80711 #else
80712 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80713 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80714 #define free(a) kfree(a)
80715 #endif
80716
80717 diff --git a/lib/ioremap.c b/lib/ioremap.c
80718 index 0c9216c..863bd89 100644
80719 --- a/lib/ioremap.c
80720 +++ b/lib/ioremap.c
80721 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80722 unsigned long next;
80723
80724 phys_addr -= addr;
80725 - pmd = pmd_alloc(&init_mm, pud, addr);
80726 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80727 if (!pmd)
80728 return -ENOMEM;
80729 do {
80730 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80731 unsigned long next;
80732
80733 phys_addr -= addr;
80734 - pud = pud_alloc(&init_mm, pgd, addr);
80735 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80736 if (!pud)
80737 return -ENOMEM;
80738 do {
80739 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80740 index bd2bea9..6b3c95e 100644
80741 --- a/lib/is_single_threaded.c
80742 +++ b/lib/is_single_threaded.c
80743 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80744 struct task_struct *p, *t;
80745 bool ret;
80746
80747 + if (!mm)
80748 + return true;
80749 +
80750 if (atomic_read(&task->signal->live) != 1)
80751 return false;
80752
80753 diff --git a/lib/kobject.c b/lib/kobject.c
80754 index b7e29a6..2f3ca75 100644
80755 --- a/lib/kobject.c
80756 +++ b/lib/kobject.c
80757 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
80758 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
80759 if (!kset)
80760 return NULL;
80761 - retval = kobject_set_name(&kset->kobj, name);
80762 + retval = kobject_set_name(&kset->kobj, "%s", name);
80763 if (retval) {
80764 kfree(kset);
80765 return NULL;
80766 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80767
80768
80769 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80770 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80771 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80772
80773 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80774 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80775 {
80776 enum kobj_ns_type type = ops->type;
80777 int error;
80778 diff --git a/lib/list_debug.c b/lib/list_debug.c
80779 index c24c2f7..06e070b 100644
80780 --- a/lib/list_debug.c
80781 +++ b/lib/list_debug.c
80782 @@ -11,7 +11,9 @@
80783 #include <linux/bug.h>
80784 #include <linux/kernel.h>
80785 #include <linux/rculist.h>
80786 +#include <linux/mm.h>
80787
80788 +#ifdef CONFIG_DEBUG_LIST
80789 /*
80790 * Insert a new entry between two known consecutive entries.
80791 *
80792 @@ -19,21 +21,32 @@
80793 * the prev/next entries already!
80794 */
80795
80796 -void __list_add(struct list_head *new,
80797 - struct list_head *prev,
80798 - struct list_head *next)
80799 +static bool __list_add_debug(struct list_head *new,
80800 + struct list_head *prev,
80801 + struct list_head *next)
80802 {
80803 - WARN(next->prev != prev,
80804 + if (WARN(next->prev != prev,
80805 "list_add corruption. next->prev should be "
80806 "prev (%p), but was %p. (next=%p).\n",
80807 - prev, next->prev, next);
80808 - WARN(prev->next != next,
80809 + prev, next->prev, next) ||
80810 + WARN(prev->next != next,
80811 "list_add corruption. prev->next should be "
80812 "next (%p), but was %p. (prev=%p).\n",
80813 - next, prev->next, prev);
80814 - WARN(new == prev || new == next,
80815 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80816 - new, prev, next);
80817 + next, prev->next, prev) ||
80818 + WARN(new == prev || new == next,
80819 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80820 + new, prev, next))
80821 + return false;
80822 + return true;
80823 +}
80824 +
80825 +void __list_add(struct list_head *new,
80826 + struct list_head *prev,
80827 + struct list_head *next)
80828 +{
80829 + if (!__list_add_debug(new, prev, next))
80830 + return;
80831 +
80832 next->prev = new;
80833 new->next = next;
80834 new->prev = prev;
80835 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80836 }
80837 EXPORT_SYMBOL(__list_add);
80838
80839 -void __list_del_entry(struct list_head *entry)
80840 +static bool __list_del_entry_debug(struct list_head *entry)
80841 {
80842 struct list_head *prev, *next;
80843
80844 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80845 WARN(next->prev != entry,
80846 "list_del corruption. next->prev should be %p, "
80847 "but was %p\n", entry, next->prev))
80848 + return false;
80849 + return true;
80850 +}
80851 +
80852 +void __list_del_entry(struct list_head *entry)
80853 +{
80854 + if (!__list_del_entry_debug(entry))
80855 return;
80856
80857 - __list_del(prev, next);
80858 + __list_del(entry->prev, entry->next);
80859 }
80860 EXPORT_SYMBOL(__list_del_entry);
80861
80862 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80863 void __list_add_rcu(struct list_head *new,
80864 struct list_head *prev, struct list_head *next)
80865 {
80866 - WARN(next->prev != prev,
80867 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80868 - prev, next->prev, next);
80869 - WARN(prev->next != next,
80870 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80871 - next, prev->next, prev);
80872 + if (!__list_add_debug(new, prev, next))
80873 + return;
80874 +
80875 new->next = next;
80876 new->prev = prev;
80877 rcu_assign_pointer(list_next_rcu(prev), new);
80878 next->prev = new;
80879 }
80880 EXPORT_SYMBOL(__list_add_rcu);
80881 +#endif
80882 +
80883 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80884 +{
80885 +#ifdef CONFIG_DEBUG_LIST
80886 + if (!__list_add_debug(new, prev, next))
80887 + return;
80888 +#endif
80889 +
80890 + pax_open_kernel();
80891 + next->prev = new;
80892 + new->next = next;
80893 + new->prev = prev;
80894 + prev->next = new;
80895 + pax_close_kernel();
80896 +}
80897 +EXPORT_SYMBOL(__pax_list_add);
80898 +
80899 +void pax_list_del(struct list_head *entry)
80900 +{
80901 +#ifdef CONFIG_DEBUG_LIST
80902 + if (!__list_del_entry_debug(entry))
80903 + return;
80904 +#endif
80905 +
80906 + pax_open_kernel();
80907 + __list_del(entry->prev, entry->next);
80908 + entry->next = LIST_POISON1;
80909 + entry->prev = LIST_POISON2;
80910 + pax_close_kernel();
80911 +}
80912 +EXPORT_SYMBOL(pax_list_del);
80913 +
80914 +void pax_list_del_init(struct list_head *entry)
80915 +{
80916 + pax_open_kernel();
80917 + __list_del(entry->prev, entry->next);
80918 + INIT_LIST_HEAD(entry);
80919 + pax_close_kernel();
80920 +}
80921 +EXPORT_SYMBOL(pax_list_del_init);
80922 +
80923 +void __pax_list_add_rcu(struct list_head *new,
80924 + struct list_head *prev, struct list_head *next)
80925 +{
80926 +#ifdef CONFIG_DEBUG_LIST
80927 + if (!__list_add_debug(new, prev, next))
80928 + return;
80929 +#endif
80930 +
80931 + pax_open_kernel();
80932 + new->next = next;
80933 + new->prev = prev;
80934 + rcu_assign_pointer(list_next_rcu(prev), new);
80935 + next->prev = new;
80936 + pax_close_kernel();
80937 +}
80938 +EXPORT_SYMBOL(__pax_list_add_rcu);
80939 +
80940 +void pax_list_del_rcu(struct list_head *entry)
80941 +{
80942 +#ifdef CONFIG_DEBUG_LIST
80943 + if (!__list_del_entry_debug(entry))
80944 + return;
80945 +#endif
80946 +
80947 + pax_open_kernel();
80948 + __list_del(entry->prev, entry->next);
80949 + entry->next = LIST_POISON1;
80950 + entry->prev = LIST_POISON2;
80951 + pax_close_kernel();
80952 +}
80953 +EXPORT_SYMBOL(pax_list_del_rcu);
80954 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80955 index e796429..6e38f9f 100644
80956 --- a/lib/radix-tree.c
80957 +++ b/lib/radix-tree.c
80958 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80959 int nr;
80960 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80961 };
80962 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80963 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80964
80965 static inline void *ptr_to_indirect(void *ptr)
80966 {
80967 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80968 index bb2b201..46abaf9 100644
80969 --- a/lib/strncpy_from_user.c
80970 +++ b/lib/strncpy_from_user.c
80971 @@ -21,7 +21,7 @@
80972 */
80973 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80974 {
80975 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80976 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80977 long res = 0;
80978
80979 /*
80980 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80981 index a28df52..3d55877 100644
80982 --- a/lib/strnlen_user.c
80983 +++ b/lib/strnlen_user.c
80984 @@ -26,7 +26,7 @@
80985 */
80986 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80987 {
80988 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80989 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80990 long align, res = 0;
80991 unsigned long c;
80992
80993 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80994 index d23762e..e21eab2 100644
80995 --- a/lib/swiotlb.c
80996 +++ b/lib/swiotlb.c
80997 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80998
80999 void
81000 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
81001 - dma_addr_t dev_addr)
81002 + dma_addr_t dev_addr, struct dma_attrs *attrs)
81003 {
81004 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
81005
81006 diff --git a/lib/usercopy.c b/lib/usercopy.c
81007 index 4f5b1dd..7cab418 100644
81008 --- a/lib/usercopy.c
81009 +++ b/lib/usercopy.c
81010 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
81011 WARN(1, "Buffer overflow detected!\n");
81012 }
81013 EXPORT_SYMBOL(copy_from_user_overflow);
81014 +
81015 +void copy_to_user_overflow(void)
81016 +{
81017 + WARN(1, "Buffer overflow detected!\n");
81018 +}
81019 +EXPORT_SYMBOL(copy_to_user_overflow);
81020 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81021 index e149c64..24aa71a 100644
81022 --- a/lib/vsprintf.c
81023 +++ b/lib/vsprintf.c
81024 @@ -16,6 +16,9 @@
81025 * - scnprintf and vscnprintf
81026 */
81027
81028 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81029 +#define __INCLUDED_BY_HIDESYM 1
81030 +#endif
81031 #include <stdarg.h>
81032 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
81033 #include <linux/types.h>
81034 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
81035 return number(buf, end, *(const netdev_features_t *)addr, spec);
81036 }
81037
81038 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81039 +int kptr_restrict __read_mostly = 2;
81040 +#else
81041 int kptr_restrict __read_mostly;
81042 +#endif
81043
81044 /*
81045 * Show a '%p' thing. A kernel extension is that the '%p' is followed
81046 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
81047 * - 'f' For simple symbolic function names without offset
81048 * - 'S' For symbolic direct pointers with offset
81049 * - 's' For symbolic direct pointers without offset
81050 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
81051 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
81052 * - 'B' For backtraced symbolic direct pointers with offset
81053 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
81054 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81055
81056 if (!ptr && *fmt != 'K') {
81057 /*
81058 - * Print (null) with the same width as a pointer so it makes
81059 + * Print (nil) with the same width as a pointer so it makes
81060 * tabular output look nice.
81061 */
81062 if (spec.field_width == -1)
81063 spec.field_width = default_width;
81064 - return string(buf, end, "(null)", spec);
81065 + return string(buf, end, "(nil)", spec);
81066 }
81067
81068 switch (*fmt) {
81069 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81070 /* Fallthrough */
81071 case 'S':
81072 case 's':
81073 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81074 + break;
81075 +#else
81076 + return symbol_string(buf, end, ptr, spec, fmt);
81077 +#endif
81078 + case 'A':
81079 case 'B':
81080 return symbol_string(buf, end, ptr, spec, fmt);
81081 case 'R':
81082 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81083 va_end(va);
81084 return buf;
81085 }
81086 + case 'P':
81087 + break;
81088 case 'K':
81089 /*
81090 * %pK cannot be used in IRQ context because its test
81091 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81092 return number(buf, end,
81093 (unsigned long long) *((phys_addr_t *)ptr), spec);
81094 }
81095 +
81096 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81097 + /* 'P' = approved pointers to copy to userland,
81098 + as in the /proc/kallsyms case, as we make it display nothing
81099 + for non-root users, and the real contents for root users
81100 + Also ignore 'K' pointers, since we force their NULLing for non-root users
81101 + above
81102 + */
81103 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
81104 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
81105 + dump_stack();
81106 + ptr = NULL;
81107 + }
81108 +#endif
81109 +
81110 spec.flags |= SMALL;
81111 if (spec.field_width == -1) {
81112 spec.field_width = default_width;
81113 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81114 typeof(type) value; \
81115 if (sizeof(type) == 8) { \
81116 args = PTR_ALIGN(args, sizeof(u32)); \
81117 - *(u32 *)&value = *(u32 *)args; \
81118 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
81119 + *(u32 *)&value = *(const u32 *)args; \
81120 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
81121 } else { \
81122 args = PTR_ALIGN(args, sizeof(type)); \
81123 - value = *(typeof(type) *)args; \
81124 + value = *(const typeof(type) *)args; \
81125 } \
81126 args += sizeof(type); \
81127 value; \
81128 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81129 case FORMAT_TYPE_STR: {
81130 const char *str_arg = args;
81131 args += strlen(str_arg) + 1;
81132 - str = string(str, end, (char *)str_arg, spec);
81133 + str = string(str, end, str_arg, spec);
81134 break;
81135 }
81136
81137 diff --git a/localversion-grsec b/localversion-grsec
81138 new file mode 100644
81139 index 0000000..7cd6065
81140 --- /dev/null
81141 +++ b/localversion-grsec
81142 @@ -0,0 +1 @@
81143 +-grsec
81144 diff --git a/mm/Kconfig b/mm/Kconfig
81145 index e742d06..c56fdd8 100644
81146 --- a/mm/Kconfig
81147 +++ b/mm/Kconfig
81148 @@ -317,10 +317,10 @@ config KSM
81149 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81150
81151 config DEFAULT_MMAP_MIN_ADDR
81152 - int "Low address space to protect from user allocation"
81153 + int "Low address space to protect from user allocation"
81154 depends on MMU
81155 - default 4096
81156 - help
81157 + default 65536
81158 + help
81159 This is the portion of low virtual memory which should be protected
81160 from userspace allocation. Keeping a user from writing to low pages
81161 can help reduce the impact of kernel NULL pointer bugs.
81162 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
81163
81164 config HWPOISON_INJECT
81165 tristate "HWPoison pages injector"
81166 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81167 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81168 select PROC_PAGE_MONITOR
81169
81170 config NOMMU_INITIAL_TRIM_EXCESS
81171 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
81172 index 5025174..9fc1c5c 100644
81173 --- a/mm/backing-dev.c
81174 +++ b/mm/backing-dev.c
81175 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
81176 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81177 unsigned int cap)
81178 {
81179 - char tmp[32];
81180 int err;
81181
81182 bdi->name = name;
81183 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81184 if (err)
81185 return err;
81186
81187 - sprintf(tmp, "%.28s%s", name, "-%d");
81188 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
81189 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
81190 if (err) {
81191 bdi_destroy(bdi);
81192 return err;
81193 diff --git a/mm/filemap.c b/mm/filemap.c
81194 index 7905fe7..e60faa8 100644
81195 --- a/mm/filemap.c
81196 +++ b/mm/filemap.c
81197 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81198 struct address_space *mapping = file->f_mapping;
81199
81200 if (!mapping->a_ops->readpage)
81201 - return -ENOEXEC;
81202 + return -ENODEV;
81203 file_accessed(file);
81204 vma->vm_ops = &generic_file_vm_ops;
81205 return 0;
81206 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81207 *pos = i_size_read(inode);
81208
81209 if (limit != RLIM_INFINITY) {
81210 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
81211 if (*pos >= limit) {
81212 send_sig(SIGXFSZ, current, 0);
81213 return -EFBIG;
81214 diff --git a/mm/fremap.c b/mm/fremap.c
81215 index 87da359..3f41cb1 100644
81216 --- a/mm/fremap.c
81217 +++ b/mm/fremap.c
81218 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
81219 retry:
81220 vma = find_vma(mm, start);
81221
81222 +#ifdef CONFIG_PAX_SEGMEXEC
81223 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
81224 + goto out;
81225 +#endif
81226 +
81227 /*
81228 * Make sure the vma is shared, that it supports prefaulting,
81229 * and that the remapped range is valid and fully within
81230 diff --git a/mm/highmem.c b/mm/highmem.c
81231 index b32b70c..e512eb0 100644
81232 --- a/mm/highmem.c
81233 +++ b/mm/highmem.c
81234 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
81235 * So no dangers, even with speculative execution.
81236 */
81237 page = pte_page(pkmap_page_table[i]);
81238 + pax_open_kernel();
81239 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
81240 -
81241 + pax_close_kernel();
81242 set_page_address(page, NULL);
81243 need_flush = 1;
81244 }
81245 @@ -198,9 +199,11 @@ start:
81246 }
81247 }
81248 vaddr = PKMAP_ADDR(last_pkmap_nr);
81249 +
81250 + pax_open_kernel();
81251 set_pte_at(&init_mm, vaddr,
81252 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
81253 -
81254 + pax_close_kernel();
81255 pkmap_count[last_pkmap_nr] = 1;
81256 set_page_address(page, (void *)vaddr);
81257
81258 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
81259 index e2bfbf7..aa59ead 100644
81260 --- a/mm/hugetlb.c
81261 +++ b/mm/hugetlb.c
81262 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
81263 struct hstate *h = &default_hstate;
81264 unsigned long tmp;
81265 int ret;
81266 + ctl_table_no_const hugetlb_table;
81267
81268 tmp = h->max_huge_pages;
81269
81270 if (write && h->order >= MAX_ORDER)
81271 return -EINVAL;
81272
81273 - table->data = &tmp;
81274 - table->maxlen = sizeof(unsigned long);
81275 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81276 + hugetlb_table = *table;
81277 + hugetlb_table.data = &tmp;
81278 + hugetlb_table.maxlen = sizeof(unsigned long);
81279 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81280 if (ret)
81281 goto out;
81282
81283 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
81284 struct hstate *h = &default_hstate;
81285 unsigned long tmp;
81286 int ret;
81287 + ctl_table_no_const hugetlb_table;
81288
81289 tmp = h->nr_overcommit_huge_pages;
81290
81291 if (write && h->order >= MAX_ORDER)
81292 return -EINVAL;
81293
81294 - table->data = &tmp;
81295 - table->maxlen = sizeof(unsigned long);
81296 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81297 + hugetlb_table = *table;
81298 + hugetlb_table.data = &tmp;
81299 + hugetlb_table.maxlen = sizeof(unsigned long);
81300 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81301 if (ret)
81302 goto out;
81303
81304 @@ -2528,6 +2532,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
81305 return 1;
81306 }
81307
81308 +#ifdef CONFIG_PAX_SEGMEXEC
81309 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
81310 +{
81311 + struct mm_struct *mm = vma->vm_mm;
81312 + struct vm_area_struct *vma_m;
81313 + unsigned long address_m;
81314 + pte_t *ptep_m;
81315 +
81316 + vma_m = pax_find_mirror_vma(vma);
81317 + if (!vma_m)
81318 + return;
81319 +
81320 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81321 + address_m = address + SEGMEXEC_TASK_SIZE;
81322 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
81323 + get_page(page_m);
81324 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81325 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81326 +}
81327 +#endif
81328 +
81329 /*
81330 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81331 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81332 @@ -2646,6 +2671,11 @@ retry_avoidcopy:
81333 make_huge_pte(vma, new_page, 1));
81334 page_remove_rmap(old_page);
81335 hugepage_add_new_anon_rmap(new_page, vma, address);
81336 +
81337 +#ifdef CONFIG_PAX_SEGMEXEC
81338 + pax_mirror_huge_pte(vma, address, new_page);
81339 +#endif
81340 +
81341 /* Make the old page be freed below */
81342 new_page = old_page;
81343 }
81344 @@ -2804,6 +2834,10 @@ retry:
81345 && (vma->vm_flags & VM_SHARED)));
81346 set_huge_pte_at(mm, address, ptep, new_pte);
81347
81348 +#ifdef CONFIG_PAX_SEGMEXEC
81349 + pax_mirror_huge_pte(vma, address, page);
81350 +#endif
81351 +
81352 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81353 /* Optimization, do the COW without a second fault */
81354 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81355 @@ -2833,6 +2867,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81356 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81357 struct hstate *h = hstate_vma(vma);
81358
81359 +#ifdef CONFIG_PAX_SEGMEXEC
81360 + struct vm_area_struct *vma_m;
81361 +#endif
81362 +
81363 address &= huge_page_mask(h);
81364
81365 ptep = huge_pte_offset(mm, address);
81366 @@ -2846,6 +2884,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81367 VM_FAULT_SET_HINDEX(hstate_index(h));
81368 }
81369
81370 +#ifdef CONFIG_PAX_SEGMEXEC
81371 + vma_m = pax_find_mirror_vma(vma);
81372 + if (vma_m) {
81373 + unsigned long address_m;
81374 +
81375 + if (vma->vm_start > vma_m->vm_start) {
81376 + address_m = address;
81377 + address -= SEGMEXEC_TASK_SIZE;
81378 + vma = vma_m;
81379 + h = hstate_vma(vma);
81380 + } else
81381 + address_m = address + SEGMEXEC_TASK_SIZE;
81382 +
81383 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81384 + return VM_FAULT_OOM;
81385 + address_m &= HPAGE_MASK;
81386 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81387 + }
81388 +#endif
81389 +
81390 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81391 if (!ptep)
81392 return VM_FAULT_OOM;
81393 diff --git a/mm/internal.h b/mm/internal.h
81394 index 8562de0..7fdfe92 100644
81395 --- a/mm/internal.h
81396 +++ b/mm/internal.h
81397 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81398 * in mm/page_alloc.c
81399 */
81400 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81401 +extern void free_compound_page(struct page *page);
81402 extern void prep_compound_page(struct page *page, unsigned long order);
81403 #ifdef CONFIG_MEMORY_FAILURE
81404 extern bool is_free_buddy_page(struct page *page);
81405 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81406 index c8d7f31..2dbeffd 100644
81407 --- a/mm/kmemleak.c
81408 +++ b/mm/kmemleak.c
81409 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81410
81411 for (i = 0; i < object->trace_len; i++) {
81412 void *ptr = (void *)object->trace[i];
81413 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81414 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81415 }
81416 }
81417
81418 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
81419 return -ENOMEM;
81420 }
81421
81422 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81423 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81424 &kmemleak_fops);
81425 if (!dentry)
81426 pr_warning("Failed to create the debugfs kmemleak file\n");
81427 diff --git a/mm/maccess.c b/mm/maccess.c
81428 index d53adf9..03a24bf 100644
81429 --- a/mm/maccess.c
81430 +++ b/mm/maccess.c
81431 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81432 set_fs(KERNEL_DS);
81433 pagefault_disable();
81434 ret = __copy_from_user_inatomic(dst,
81435 - (__force const void __user *)src, size);
81436 + (const void __force_user *)src, size);
81437 pagefault_enable();
81438 set_fs(old_fs);
81439
81440 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81441
81442 set_fs(KERNEL_DS);
81443 pagefault_disable();
81444 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81445 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81446 pagefault_enable();
81447 set_fs(old_fs);
81448
81449 diff --git a/mm/madvise.c b/mm/madvise.c
81450 index 7055883..4e8c835 100644
81451 --- a/mm/madvise.c
81452 +++ b/mm/madvise.c
81453 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81454 pgoff_t pgoff;
81455 unsigned long new_flags = vma->vm_flags;
81456
81457 +#ifdef CONFIG_PAX_SEGMEXEC
81458 + struct vm_area_struct *vma_m;
81459 +#endif
81460 +
81461 switch (behavior) {
81462 case MADV_NORMAL:
81463 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81464 @@ -126,6 +130,13 @@ success:
81465 /*
81466 * vm_flags is protected by the mmap_sem held in write mode.
81467 */
81468 +
81469 +#ifdef CONFIG_PAX_SEGMEXEC
81470 + vma_m = pax_find_mirror_vma(vma);
81471 + if (vma_m)
81472 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81473 +#endif
81474 +
81475 vma->vm_flags = new_flags;
81476
81477 out:
81478 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81479 struct vm_area_struct ** prev,
81480 unsigned long start, unsigned long end)
81481 {
81482 +
81483 +#ifdef CONFIG_PAX_SEGMEXEC
81484 + struct vm_area_struct *vma_m;
81485 +#endif
81486 +
81487 *prev = vma;
81488 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81489 return -EINVAL;
81490 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81491 zap_page_range(vma, start, end - start, &details);
81492 } else
81493 zap_page_range(vma, start, end - start, NULL);
81494 +
81495 +#ifdef CONFIG_PAX_SEGMEXEC
81496 + vma_m = pax_find_mirror_vma(vma);
81497 + if (vma_m) {
81498 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81499 + struct zap_details details = {
81500 + .nonlinear_vma = vma_m,
81501 + .last_index = ULONG_MAX,
81502 + };
81503 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81504 + } else
81505 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81506 + }
81507 +#endif
81508 +
81509 return 0;
81510 }
81511
81512 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81513 if (end < start)
81514 return error;
81515
81516 +#ifdef CONFIG_PAX_SEGMEXEC
81517 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81518 + if (end > SEGMEXEC_TASK_SIZE)
81519 + goto out;
81520 + } else
81521 +#endif
81522 +
81523 + if (end > TASK_SIZE)
81524 + goto out;
81525 +
81526 error = 0;
81527 if (end == start)
81528 return error;
81529 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
81530 index 1947218..15b0409 100644
81531 --- a/mm/memcontrol.c
81532 +++ b/mm/memcontrol.c
81533 @@ -6296,16 +6296,6 @@ mem_cgroup_css_online(struct cgroup *cont)
81534
81535 error = memcg_init_kmem(memcg, &mem_cgroup_subsys);
81536 mutex_unlock(&memcg_create_mutex);
81537 - if (error) {
81538 - /*
81539 - * We call put now because our (and parent's) refcnts
81540 - * are already in place. mem_cgroup_put() will internally
81541 - * call __mem_cgroup_free, so return directly
81542 - */
81543 - mem_cgroup_put(memcg);
81544 - if (parent->use_hierarchy)
81545 - mem_cgroup_put(parent);
81546 - }
81547 return error;
81548 }
81549
81550 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81551 index ceb0c7f..b2b8e94 100644
81552 --- a/mm/memory-failure.c
81553 +++ b/mm/memory-failure.c
81554 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81555
81556 int sysctl_memory_failure_recovery __read_mostly = 1;
81557
81558 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81559 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81560
81561 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81562
81563 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81564 pfn, t->comm, t->pid);
81565 si.si_signo = SIGBUS;
81566 si.si_errno = 0;
81567 - si.si_addr = (void *)addr;
81568 + si.si_addr = (void __user *)addr;
81569 #ifdef __ARCH_SI_TRAPNO
81570 si.si_trapno = trapno;
81571 #endif
81572 @@ -760,7 +760,7 @@ static struct page_state {
81573 unsigned long res;
81574 char *msg;
81575 int (*action)(struct page *p, unsigned long pfn);
81576 -} error_states[] = {
81577 +} __do_const error_states[] = {
81578 { reserved, reserved, "reserved kernel", me_kernel },
81579 /*
81580 * free pages are specially detected outside this table:
81581 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81582 nr_pages = 1 << compound_order(hpage);
81583 else /* normal page or thp */
81584 nr_pages = 1;
81585 - atomic_long_add(nr_pages, &num_poisoned_pages);
81586 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
81587
81588 /*
81589 * We need/can do nothing about count=0 pages.
81590 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81591 if (!PageHWPoison(hpage)
81592 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81593 || (p != hpage && TestSetPageHWPoison(hpage))) {
81594 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81595 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81596 return 0;
81597 }
81598 set_page_hwpoison_huge_page(hpage);
81599 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81600 }
81601 if (hwpoison_filter(p)) {
81602 if (TestClearPageHWPoison(p))
81603 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81604 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81605 unlock_page(hpage);
81606 put_page(hpage);
81607 return 0;
81608 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
81609 return 0;
81610 }
81611 if (TestClearPageHWPoison(p))
81612 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81613 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81614 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81615 return 0;
81616 }
81617 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81618 */
81619 if (TestClearPageHWPoison(page)) {
81620 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81621 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81622 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81623 freeit = 1;
81624 if (PageHuge(page))
81625 clear_page_hwpoison_huge_page(page);
81626 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81627 } else {
81628 set_page_hwpoison_huge_page(hpage);
81629 dequeue_hwpoisoned_huge_page(hpage);
81630 - atomic_long_add(1 << compound_trans_order(hpage),
81631 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81632 &num_poisoned_pages);
81633 }
81634 /* keep elevated page count for bad page */
81635 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81636 if (PageHuge(page)) {
81637 set_page_hwpoison_huge_page(hpage);
81638 dequeue_hwpoisoned_huge_page(hpage);
81639 - atomic_long_add(1 << compound_trans_order(hpage),
81640 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81641 &num_poisoned_pages);
81642 } else {
81643 SetPageHWPoison(page);
81644 - atomic_long_inc(&num_poisoned_pages);
81645 + atomic_long_inc_unchecked(&num_poisoned_pages);
81646 }
81647 }
81648 /* keep elevated page count for bad page */
81649 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81650 put_page(page);
81651 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81652 SetPageHWPoison(page);
81653 - atomic_long_inc(&num_poisoned_pages);
81654 + atomic_long_inc_unchecked(&num_poisoned_pages);
81655 return 0;
81656 }
81657
81658 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81659 ret = -EIO;
81660 } else {
81661 SetPageHWPoison(page);
81662 - atomic_long_inc(&num_poisoned_pages);
81663 + atomic_long_inc_unchecked(&num_poisoned_pages);
81664 }
81665 } else {
81666 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81667 diff --git a/mm/memory.c b/mm/memory.c
81668 index 61a262b..77a94d1 100644
81669 --- a/mm/memory.c
81670 +++ b/mm/memory.c
81671 @@ -429,6 +429,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81672 free_pte_range(tlb, pmd, addr);
81673 } while (pmd++, addr = next, addr != end);
81674
81675 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81676 start &= PUD_MASK;
81677 if (start < floor)
81678 return;
81679 @@ -443,6 +444,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81680 pmd = pmd_offset(pud, start);
81681 pud_clear(pud);
81682 pmd_free_tlb(tlb, pmd, start);
81683 +#endif
81684 +
81685 }
81686
81687 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81688 @@ -462,6 +465,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81689 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81690 } while (pud++, addr = next, addr != end);
81691
81692 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81693 start &= PGDIR_MASK;
81694 if (start < floor)
81695 return;
81696 @@ -476,6 +480,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81697 pud = pud_offset(pgd, start);
81698 pgd_clear(pgd);
81699 pud_free_tlb(tlb, pud, start);
81700 +#endif
81701 +
81702 }
81703
81704 /*
81705 @@ -1635,12 +1641,6 @@ no_page_table:
81706 return page;
81707 }
81708
81709 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81710 -{
81711 - return stack_guard_page_start(vma, addr) ||
81712 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81713 -}
81714 -
81715 /**
81716 * __get_user_pages() - pin user pages in memory
81717 * @tsk: task_struct of target task
81718 @@ -1727,10 +1727,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81719
81720 i = 0;
81721
81722 - do {
81723 + while (nr_pages) {
81724 struct vm_area_struct *vma;
81725
81726 - vma = find_extend_vma(mm, start);
81727 + vma = find_vma(mm, start);
81728 if (!vma && in_gate_area(mm, start)) {
81729 unsigned long pg = start & PAGE_MASK;
81730 pgd_t *pgd;
81731 @@ -1779,7 +1779,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81732 goto next_page;
81733 }
81734
81735 - if (!vma ||
81736 + if (!vma || start < vma->vm_start ||
81737 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81738 !(vm_flags & vma->vm_flags))
81739 return i ? : -EFAULT;
81740 @@ -1808,11 +1808,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81741 int ret;
81742 unsigned int fault_flags = 0;
81743
81744 - /* For mlock, just skip the stack guard page. */
81745 - if (foll_flags & FOLL_MLOCK) {
81746 - if (stack_guard_page(vma, start))
81747 - goto next_page;
81748 - }
81749 if (foll_flags & FOLL_WRITE)
81750 fault_flags |= FAULT_FLAG_WRITE;
81751 if (nonblocking)
81752 @@ -1892,7 +1887,7 @@ next_page:
81753 start += page_increm * PAGE_SIZE;
81754 nr_pages -= page_increm;
81755 } while (nr_pages && start < vma->vm_end);
81756 - } while (nr_pages);
81757 + }
81758 return i;
81759 }
81760 EXPORT_SYMBOL(__get_user_pages);
81761 @@ -2099,6 +2094,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81762 page_add_file_rmap(page);
81763 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81764
81765 +#ifdef CONFIG_PAX_SEGMEXEC
81766 + pax_mirror_file_pte(vma, addr, page, ptl);
81767 +#endif
81768 +
81769 retval = 0;
81770 pte_unmap_unlock(pte, ptl);
81771 return retval;
81772 @@ -2143,9 +2142,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81773 if (!page_count(page))
81774 return -EINVAL;
81775 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81776 +
81777 +#ifdef CONFIG_PAX_SEGMEXEC
81778 + struct vm_area_struct *vma_m;
81779 +#endif
81780 +
81781 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81782 BUG_ON(vma->vm_flags & VM_PFNMAP);
81783 vma->vm_flags |= VM_MIXEDMAP;
81784 +
81785 +#ifdef CONFIG_PAX_SEGMEXEC
81786 + vma_m = pax_find_mirror_vma(vma);
81787 + if (vma_m)
81788 + vma_m->vm_flags |= VM_MIXEDMAP;
81789 +#endif
81790 +
81791 }
81792 return insert_page(vma, addr, page, vma->vm_page_prot);
81793 }
81794 @@ -2228,6 +2239,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81795 unsigned long pfn)
81796 {
81797 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81798 + BUG_ON(vma->vm_mirror);
81799
81800 if (addr < vma->vm_start || addr >= vma->vm_end)
81801 return -EFAULT;
81802 @@ -2475,7 +2487,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81803
81804 BUG_ON(pud_huge(*pud));
81805
81806 - pmd = pmd_alloc(mm, pud, addr);
81807 + pmd = (mm == &init_mm) ?
81808 + pmd_alloc_kernel(mm, pud, addr) :
81809 + pmd_alloc(mm, pud, addr);
81810 if (!pmd)
81811 return -ENOMEM;
81812 do {
81813 @@ -2495,7 +2509,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81814 unsigned long next;
81815 int err;
81816
81817 - pud = pud_alloc(mm, pgd, addr);
81818 + pud = (mm == &init_mm) ?
81819 + pud_alloc_kernel(mm, pgd, addr) :
81820 + pud_alloc(mm, pgd, addr);
81821 if (!pud)
81822 return -ENOMEM;
81823 do {
81824 @@ -2583,6 +2599,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81825 copy_user_highpage(dst, src, va, vma);
81826 }
81827
81828 +#ifdef CONFIG_PAX_SEGMEXEC
81829 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81830 +{
81831 + struct mm_struct *mm = vma->vm_mm;
81832 + spinlock_t *ptl;
81833 + pte_t *pte, entry;
81834 +
81835 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81836 + entry = *pte;
81837 + if (!pte_present(entry)) {
81838 + if (!pte_none(entry)) {
81839 + BUG_ON(pte_file(entry));
81840 + free_swap_and_cache(pte_to_swp_entry(entry));
81841 + pte_clear_not_present_full(mm, address, pte, 0);
81842 + }
81843 + } else {
81844 + struct page *page;
81845 +
81846 + flush_cache_page(vma, address, pte_pfn(entry));
81847 + entry = ptep_clear_flush(vma, address, pte);
81848 + BUG_ON(pte_dirty(entry));
81849 + page = vm_normal_page(vma, address, entry);
81850 + if (page) {
81851 + update_hiwater_rss(mm);
81852 + if (PageAnon(page))
81853 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81854 + else
81855 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81856 + page_remove_rmap(page);
81857 + page_cache_release(page);
81858 + }
81859 + }
81860 + pte_unmap_unlock(pte, ptl);
81861 +}
81862 +
81863 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81864 + *
81865 + * the ptl of the lower mapped page is held on entry and is not released on exit
81866 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81867 + */
81868 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81869 +{
81870 + struct mm_struct *mm = vma->vm_mm;
81871 + unsigned long address_m;
81872 + spinlock_t *ptl_m;
81873 + struct vm_area_struct *vma_m;
81874 + pmd_t *pmd_m;
81875 + pte_t *pte_m, entry_m;
81876 +
81877 + BUG_ON(!page_m || !PageAnon(page_m));
81878 +
81879 + vma_m = pax_find_mirror_vma(vma);
81880 + if (!vma_m)
81881 + return;
81882 +
81883 + BUG_ON(!PageLocked(page_m));
81884 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81885 + address_m = address + SEGMEXEC_TASK_SIZE;
81886 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81887 + pte_m = pte_offset_map(pmd_m, address_m);
81888 + ptl_m = pte_lockptr(mm, pmd_m);
81889 + if (ptl != ptl_m) {
81890 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81891 + if (!pte_none(*pte_m))
81892 + goto out;
81893 + }
81894 +
81895 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81896 + page_cache_get(page_m);
81897 + page_add_anon_rmap(page_m, vma_m, address_m);
81898 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81899 + set_pte_at(mm, address_m, pte_m, entry_m);
81900 + update_mmu_cache(vma_m, address_m, pte_m);
81901 +out:
81902 + if (ptl != ptl_m)
81903 + spin_unlock(ptl_m);
81904 + pte_unmap(pte_m);
81905 + unlock_page(page_m);
81906 +}
81907 +
81908 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81909 +{
81910 + struct mm_struct *mm = vma->vm_mm;
81911 + unsigned long address_m;
81912 + spinlock_t *ptl_m;
81913 + struct vm_area_struct *vma_m;
81914 + pmd_t *pmd_m;
81915 + pte_t *pte_m, entry_m;
81916 +
81917 + BUG_ON(!page_m || PageAnon(page_m));
81918 +
81919 + vma_m = pax_find_mirror_vma(vma);
81920 + if (!vma_m)
81921 + return;
81922 +
81923 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81924 + address_m = address + SEGMEXEC_TASK_SIZE;
81925 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81926 + pte_m = pte_offset_map(pmd_m, address_m);
81927 + ptl_m = pte_lockptr(mm, pmd_m);
81928 + if (ptl != ptl_m) {
81929 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81930 + if (!pte_none(*pte_m))
81931 + goto out;
81932 + }
81933 +
81934 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81935 + page_cache_get(page_m);
81936 + page_add_file_rmap(page_m);
81937 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81938 + set_pte_at(mm, address_m, pte_m, entry_m);
81939 + update_mmu_cache(vma_m, address_m, pte_m);
81940 +out:
81941 + if (ptl != ptl_m)
81942 + spin_unlock(ptl_m);
81943 + pte_unmap(pte_m);
81944 +}
81945 +
81946 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81947 +{
81948 + struct mm_struct *mm = vma->vm_mm;
81949 + unsigned long address_m;
81950 + spinlock_t *ptl_m;
81951 + struct vm_area_struct *vma_m;
81952 + pmd_t *pmd_m;
81953 + pte_t *pte_m, entry_m;
81954 +
81955 + vma_m = pax_find_mirror_vma(vma);
81956 + if (!vma_m)
81957 + return;
81958 +
81959 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81960 + address_m = address + SEGMEXEC_TASK_SIZE;
81961 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81962 + pte_m = pte_offset_map(pmd_m, address_m);
81963 + ptl_m = pte_lockptr(mm, pmd_m);
81964 + if (ptl != ptl_m) {
81965 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81966 + if (!pte_none(*pte_m))
81967 + goto out;
81968 + }
81969 +
81970 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81971 + set_pte_at(mm, address_m, pte_m, entry_m);
81972 +out:
81973 + if (ptl != ptl_m)
81974 + spin_unlock(ptl_m);
81975 + pte_unmap(pte_m);
81976 +}
81977 +
81978 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81979 +{
81980 + struct page *page_m;
81981 + pte_t entry;
81982 +
81983 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81984 + goto out;
81985 +
81986 + entry = *pte;
81987 + page_m = vm_normal_page(vma, address, entry);
81988 + if (!page_m)
81989 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81990 + else if (PageAnon(page_m)) {
81991 + if (pax_find_mirror_vma(vma)) {
81992 + pte_unmap_unlock(pte, ptl);
81993 + lock_page(page_m);
81994 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81995 + if (pte_same(entry, *pte))
81996 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81997 + else
81998 + unlock_page(page_m);
81999 + }
82000 + } else
82001 + pax_mirror_file_pte(vma, address, page_m, ptl);
82002 +
82003 +out:
82004 + pte_unmap_unlock(pte, ptl);
82005 +}
82006 +#endif
82007 +
82008 /*
82009 * This routine handles present pages, when users try to write
82010 * to a shared page. It is done by copying the page to a new address
82011 @@ -2799,6 +2995,12 @@ gotten:
82012 */
82013 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82014 if (likely(pte_same(*page_table, orig_pte))) {
82015 +
82016 +#ifdef CONFIG_PAX_SEGMEXEC
82017 + if (pax_find_mirror_vma(vma))
82018 + BUG_ON(!trylock_page(new_page));
82019 +#endif
82020 +
82021 if (old_page) {
82022 if (!PageAnon(old_page)) {
82023 dec_mm_counter_fast(mm, MM_FILEPAGES);
82024 @@ -2850,6 +3052,10 @@ gotten:
82025 page_remove_rmap(old_page);
82026 }
82027
82028 +#ifdef CONFIG_PAX_SEGMEXEC
82029 + pax_mirror_anon_pte(vma, address, new_page, ptl);
82030 +#endif
82031 +
82032 /* Free the old page.. */
82033 new_page = old_page;
82034 ret |= VM_FAULT_WRITE;
82035 @@ -3125,6 +3331,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82036 swap_free(entry);
82037 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
82038 try_to_free_swap(page);
82039 +
82040 +#ifdef CONFIG_PAX_SEGMEXEC
82041 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
82042 +#endif
82043 +
82044 unlock_page(page);
82045 if (page != swapcache) {
82046 /*
82047 @@ -3148,6 +3359,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82048
82049 /* No need to invalidate - it was non-present before */
82050 update_mmu_cache(vma, address, page_table);
82051 +
82052 +#ifdef CONFIG_PAX_SEGMEXEC
82053 + pax_mirror_anon_pte(vma, address, page, ptl);
82054 +#endif
82055 +
82056 unlock:
82057 pte_unmap_unlock(page_table, ptl);
82058 out:
82059 @@ -3167,40 +3383,6 @@ out_release:
82060 }
82061
82062 /*
82063 - * This is like a special single-page "expand_{down|up}wards()",
82064 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
82065 - * doesn't hit another vma.
82066 - */
82067 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
82068 -{
82069 - address &= PAGE_MASK;
82070 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
82071 - struct vm_area_struct *prev = vma->vm_prev;
82072 -
82073 - /*
82074 - * Is there a mapping abutting this one below?
82075 - *
82076 - * That's only ok if it's the same stack mapping
82077 - * that has gotten split..
82078 - */
82079 - if (prev && prev->vm_end == address)
82080 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
82081 -
82082 - expand_downwards(vma, address - PAGE_SIZE);
82083 - }
82084 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
82085 - struct vm_area_struct *next = vma->vm_next;
82086 -
82087 - /* As VM_GROWSDOWN but s/below/above/ */
82088 - if (next && next->vm_start == address + PAGE_SIZE)
82089 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
82090 -
82091 - expand_upwards(vma, address + PAGE_SIZE);
82092 - }
82093 - return 0;
82094 -}
82095 -
82096 -/*
82097 * We enter with non-exclusive mmap_sem (to exclude vma changes,
82098 * but allow concurrent faults), and pte mapped but not yet locked.
82099 * We return with mmap_sem still held, but pte unmapped and unlocked.
82100 @@ -3209,27 +3391,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82101 unsigned long address, pte_t *page_table, pmd_t *pmd,
82102 unsigned int flags)
82103 {
82104 - struct page *page;
82105 + struct page *page = NULL;
82106 spinlock_t *ptl;
82107 pte_t entry;
82108
82109 - pte_unmap(page_table);
82110 -
82111 - /* Check if we need to add a guard page to the stack */
82112 - if (check_stack_guard_page(vma, address) < 0)
82113 - return VM_FAULT_SIGBUS;
82114 -
82115 - /* Use the zero-page for reads */
82116 if (!(flags & FAULT_FLAG_WRITE)) {
82117 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
82118 vma->vm_page_prot));
82119 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82120 + ptl = pte_lockptr(mm, pmd);
82121 + spin_lock(ptl);
82122 if (!pte_none(*page_table))
82123 goto unlock;
82124 goto setpte;
82125 }
82126
82127 /* Allocate our own private page. */
82128 + pte_unmap(page_table);
82129 +
82130 if (unlikely(anon_vma_prepare(vma)))
82131 goto oom;
82132 page = alloc_zeroed_user_highpage_movable(vma, address);
82133 @@ -3253,6 +3431,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82134 if (!pte_none(*page_table))
82135 goto release;
82136
82137 +#ifdef CONFIG_PAX_SEGMEXEC
82138 + if (pax_find_mirror_vma(vma))
82139 + BUG_ON(!trylock_page(page));
82140 +#endif
82141 +
82142 inc_mm_counter_fast(mm, MM_ANONPAGES);
82143 page_add_new_anon_rmap(page, vma, address);
82144 setpte:
82145 @@ -3260,6 +3443,12 @@ setpte:
82146
82147 /* No need to invalidate - it was non-present before */
82148 update_mmu_cache(vma, address, page_table);
82149 +
82150 +#ifdef CONFIG_PAX_SEGMEXEC
82151 + if (page)
82152 + pax_mirror_anon_pte(vma, address, page, ptl);
82153 +#endif
82154 +
82155 unlock:
82156 pte_unmap_unlock(page_table, ptl);
82157 return 0;
82158 @@ -3403,6 +3592,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82159 */
82160 /* Only go through if we didn't race with anybody else... */
82161 if (likely(pte_same(*page_table, orig_pte))) {
82162 +
82163 +#ifdef CONFIG_PAX_SEGMEXEC
82164 + if (anon && pax_find_mirror_vma(vma))
82165 + BUG_ON(!trylock_page(page));
82166 +#endif
82167 +
82168 flush_icache_page(vma, page);
82169 entry = mk_pte(page, vma->vm_page_prot);
82170 if (flags & FAULT_FLAG_WRITE)
82171 @@ -3422,6 +3617,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82172
82173 /* no need to invalidate: a not-present page won't be cached */
82174 update_mmu_cache(vma, address, page_table);
82175 +
82176 +#ifdef CONFIG_PAX_SEGMEXEC
82177 + if (anon)
82178 + pax_mirror_anon_pte(vma, address, page, ptl);
82179 + else
82180 + pax_mirror_file_pte(vma, address, page, ptl);
82181 +#endif
82182 +
82183 } else {
82184 if (cow_page)
82185 mem_cgroup_uncharge_page(cow_page);
82186 @@ -3743,6 +3946,12 @@ int handle_pte_fault(struct mm_struct *mm,
82187 if (flags & FAULT_FLAG_WRITE)
82188 flush_tlb_fix_spurious_fault(vma, address);
82189 }
82190 +
82191 +#ifdef CONFIG_PAX_SEGMEXEC
82192 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82193 + return 0;
82194 +#endif
82195 +
82196 unlock:
82197 pte_unmap_unlock(pte, ptl);
82198 return 0;
82199 @@ -3759,6 +3968,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82200 pmd_t *pmd;
82201 pte_t *pte;
82202
82203 +#ifdef CONFIG_PAX_SEGMEXEC
82204 + struct vm_area_struct *vma_m;
82205 +#endif
82206 +
82207 __set_current_state(TASK_RUNNING);
82208
82209 count_vm_event(PGFAULT);
82210 @@ -3770,6 +3983,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82211 if (unlikely(is_vm_hugetlb_page(vma)))
82212 return hugetlb_fault(mm, vma, address, flags);
82213
82214 +#ifdef CONFIG_PAX_SEGMEXEC
82215 + vma_m = pax_find_mirror_vma(vma);
82216 + if (vma_m) {
82217 + unsigned long address_m;
82218 + pgd_t *pgd_m;
82219 + pud_t *pud_m;
82220 + pmd_t *pmd_m;
82221 +
82222 + if (vma->vm_start > vma_m->vm_start) {
82223 + address_m = address;
82224 + address -= SEGMEXEC_TASK_SIZE;
82225 + vma = vma_m;
82226 + } else
82227 + address_m = address + SEGMEXEC_TASK_SIZE;
82228 +
82229 + pgd_m = pgd_offset(mm, address_m);
82230 + pud_m = pud_alloc(mm, pgd_m, address_m);
82231 + if (!pud_m)
82232 + return VM_FAULT_OOM;
82233 + pmd_m = pmd_alloc(mm, pud_m, address_m);
82234 + if (!pmd_m)
82235 + return VM_FAULT_OOM;
82236 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
82237 + return VM_FAULT_OOM;
82238 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
82239 + }
82240 +#endif
82241 +
82242 retry:
82243 pgd = pgd_offset(mm, address);
82244 pud = pud_alloc(mm, pgd, address);
82245 @@ -3868,6 +4109,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82246 spin_unlock(&mm->page_table_lock);
82247 return 0;
82248 }
82249 +
82250 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82251 +{
82252 + pud_t *new = pud_alloc_one(mm, address);
82253 + if (!new)
82254 + return -ENOMEM;
82255 +
82256 + smp_wmb(); /* See comment in __pte_alloc */
82257 +
82258 + spin_lock(&mm->page_table_lock);
82259 + if (pgd_present(*pgd)) /* Another has populated it */
82260 + pud_free(mm, new);
82261 + else
82262 + pgd_populate_kernel(mm, pgd, new);
82263 + spin_unlock(&mm->page_table_lock);
82264 + return 0;
82265 +}
82266 #endif /* __PAGETABLE_PUD_FOLDED */
82267
82268 #ifndef __PAGETABLE_PMD_FOLDED
82269 @@ -3898,6 +4156,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
82270 spin_unlock(&mm->page_table_lock);
82271 return 0;
82272 }
82273 +
82274 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
82275 +{
82276 + pmd_t *new = pmd_alloc_one(mm, address);
82277 + if (!new)
82278 + return -ENOMEM;
82279 +
82280 + smp_wmb(); /* See comment in __pte_alloc */
82281 +
82282 + spin_lock(&mm->page_table_lock);
82283 +#ifndef __ARCH_HAS_4LEVEL_HACK
82284 + if (pud_present(*pud)) /* Another has populated it */
82285 + pmd_free(mm, new);
82286 + else
82287 + pud_populate_kernel(mm, pud, new);
82288 +#else
82289 + if (pgd_present(*pud)) /* Another has populated it */
82290 + pmd_free(mm, new);
82291 + else
82292 + pgd_populate_kernel(mm, pud, new);
82293 +#endif /* __ARCH_HAS_4LEVEL_HACK */
82294 + spin_unlock(&mm->page_table_lock);
82295 + return 0;
82296 +}
82297 #endif /* __PAGETABLE_PMD_FOLDED */
82298
82299 #if !defined(__HAVE_ARCH_GATE_AREA)
82300 @@ -3911,7 +4193,7 @@ static int __init gate_vma_init(void)
82301 gate_vma.vm_start = FIXADDR_USER_START;
82302 gate_vma.vm_end = FIXADDR_USER_END;
82303 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
82304 - gate_vma.vm_page_prot = __P101;
82305 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
82306
82307 return 0;
82308 }
82309 @@ -4045,8 +4327,8 @@ out:
82310 return ret;
82311 }
82312
82313 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82314 - void *buf, int len, int write)
82315 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82316 + void *buf, size_t len, int write)
82317 {
82318 resource_size_t phys_addr;
82319 unsigned long prot = 0;
82320 @@ -4071,8 +4353,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82321 * Access another process' address space as given in mm. If non-NULL, use the
82322 * given task for page fault accounting.
82323 */
82324 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82325 - unsigned long addr, void *buf, int len, int write)
82326 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82327 + unsigned long addr, void *buf, size_t len, int write)
82328 {
82329 struct vm_area_struct *vma;
82330 void *old_buf = buf;
82331 @@ -4080,7 +4362,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82332 down_read(&mm->mmap_sem);
82333 /* ignore errors, just check how much was successfully transferred */
82334 while (len) {
82335 - int bytes, ret, offset;
82336 + ssize_t bytes, ret, offset;
82337 void *maddr;
82338 struct page *page = NULL;
82339
82340 @@ -4139,8 +4421,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82341 *
82342 * The caller must hold a reference on @mm.
82343 */
82344 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82345 - void *buf, int len, int write)
82346 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82347 + void *buf, size_t len, int write)
82348 {
82349 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82350 }
82351 @@ -4150,11 +4432,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82352 * Source/target buffer must be kernel space,
82353 * Do not walk the page table directly, use get_user_pages
82354 */
82355 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82356 - void *buf, int len, int write)
82357 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82358 + void *buf, size_t len, int write)
82359 {
82360 struct mm_struct *mm;
82361 - int ret;
82362 + ssize_t ret;
82363
82364 mm = get_task_mm(tsk);
82365 if (!mm)
82366 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82367 index 7431001..0f8344e 100644
82368 --- a/mm/mempolicy.c
82369 +++ b/mm/mempolicy.c
82370 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82371 unsigned long vmstart;
82372 unsigned long vmend;
82373
82374 +#ifdef CONFIG_PAX_SEGMEXEC
82375 + struct vm_area_struct *vma_m;
82376 +#endif
82377 +
82378 vma = find_vma(mm, start);
82379 if (!vma || vma->vm_start > start)
82380 return -EFAULT;
82381 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82382 if (err)
82383 goto out;
82384 }
82385 +
82386 err = vma_replace_policy(vma, new_pol);
82387 if (err)
82388 goto out;
82389 +
82390 +#ifdef CONFIG_PAX_SEGMEXEC
82391 + vma_m = pax_find_mirror_vma(vma);
82392 + if (vma_m) {
82393 + err = vma_replace_policy(vma_m, new_pol);
82394 + if (err)
82395 + goto out;
82396 + }
82397 +#endif
82398 +
82399 }
82400
82401 out:
82402 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82403
82404 if (end < start)
82405 return -EINVAL;
82406 +
82407 +#ifdef CONFIG_PAX_SEGMEXEC
82408 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82409 + if (end > SEGMEXEC_TASK_SIZE)
82410 + return -EINVAL;
82411 + } else
82412 +#endif
82413 +
82414 + if (end > TASK_SIZE)
82415 + return -EINVAL;
82416 +
82417 if (end == start)
82418 return 0;
82419
82420 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82421 */
82422 tcred = __task_cred(task);
82423 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82424 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82425 - !capable(CAP_SYS_NICE)) {
82426 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82427 rcu_read_unlock();
82428 err = -EPERM;
82429 goto out_put;
82430 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82431 goto out;
82432 }
82433
82434 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82435 + if (mm != current->mm &&
82436 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82437 + mmput(mm);
82438 + err = -EPERM;
82439 + goto out;
82440 + }
82441 +#endif
82442 +
82443 err = do_migrate_pages(mm, old, new,
82444 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82445
82446 diff --git a/mm/migrate.c b/mm/migrate.c
82447 index 6f0c244..6d1ae32 100644
82448 --- a/mm/migrate.c
82449 +++ b/mm/migrate.c
82450 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82451 */
82452 tcred = __task_cred(task);
82453 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82454 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82455 - !capable(CAP_SYS_NICE)) {
82456 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82457 rcu_read_unlock();
82458 err = -EPERM;
82459 goto out;
82460 diff --git a/mm/mlock.c b/mm/mlock.c
82461 index 79b7cf7..9944291 100644
82462 --- a/mm/mlock.c
82463 +++ b/mm/mlock.c
82464 @@ -13,6 +13,7 @@
82465 #include <linux/pagemap.h>
82466 #include <linux/mempolicy.h>
82467 #include <linux/syscalls.h>
82468 +#include <linux/security.h>
82469 #include <linux/sched.h>
82470 #include <linux/export.h>
82471 #include <linux/rmap.h>
82472 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82473 {
82474 unsigned long nstart, end, tmp;
82475 struct vm_area_struct * vma, * prev;
82476 - int error;
82477 + int error = 0;
82478
82479 VM_BUG_ON(start & ~PAGE_MASK);
82480 VM_BUG_ON(len != PAGE_ALIGN(len));
82481 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82482 return -EINVAL;
82483 if (end == start)
82484 return 0;
82485 + if (end > TASK_SIZE)
82486 + return -EINVAL;
82487 +
82488 vma = find_vma(current->mm, start);
82489 if (!vma || vma->vm_start > start)
82490 return -ENOMEM;
82491 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82492 for (nstart = start ; ; ) {
82493 vm_flags_t newflags;
82494
82495 +#ifdef CONFIG_PAX_SEGMEXEC
82496 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82497 + break;
82498 +#endif
82499 +
82500 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82501
82502 newflags = vma->vm_flags & ~VM_LOCKED;
82503 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82504 lock_limit >>= PAGE_SHIFT;
82505
82506 /* check against resource limits */
82507 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82508 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82509 error = do_mlock(start, len, 1);
82510 up_write(&current->mm->mmap_sem);
82511 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
82512 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82513 vm_flags_t newflags;
82514
82515 +#ifdef CONFIG_PAX_SEGMEXEC
82516 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82517 + break;
82518 +#endif
82519 +
82520 newflags = vma->vm_flags & ~VM_LOCKED;
82521 if (flags & MCL_CURRENT)
82522 newflags |= VM_LOCKED;
82523 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82524 lock_limit >>= PAGE_SHIFT;
82525
82526 ret = -ENOMEM;
82527 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82528 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82529 capable(CAP_IPC_LOCK))
82530 ret = do_mlockall(flags);
82531 diff --git a/mm/mmap.c b/mm/mmap.c
82532 index f681e18..4c2577f 100644
82533 --- a/mm/mmap.c
82534 +++ b/mm/mmap.c
82535 @@ -36,6 +36,7 @@
82536 #include <linux/sched/sysctl.h>
82537 #include <linux/notifier.h>
82538 #include <linux/memory.h>
82539 +#include <linux/random.h>
82540
82541 #include <asm/uaccess.h>
82542 #include <asm/cacheflush.h>
82543 @@ -52,6 +53,16 @@
82544 #define arch_rebalance_pgtables(addr, len) (addr)
82545 #endif
82546
82547 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82548 +{
82549 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82550 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82551 + up_read(&mm->mmap_sem);
82552 + BUG();
82553 + }
82554 +#endif
82555 +}
82556 +
82557 static void unmap_region(struct mm_struct *mm,
82558 struct vm_area_struct *vma, struct vm_area_struct *prev,
82559 unsigned long start, unsigned long end);
82560 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
82561 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82562 *
82563 */
82564 -pgprot_t protection_map[16] = {
82565 +pgprot_t protection_map[16] __read_only = {
82566 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82567 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82568 };
82569
82570 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82571 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82572 {
82573 - return __pgprot(pgprot_val(protection_map[vm_flags &
82574 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82575 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82576 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82577 +
82578 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82579 + if (!(__supported_pte_mask & _PAGE_NX) &&
82580 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82581 + (vm_flags & (VM_READ | VM_WRITE)))
82582 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82583 +#endif
82584 +
82585 + return prot;
82586 }
82587 EXPORT_SYMBOL(vm_get_page_prot);
82588
82589 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82590 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82591 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
82592 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
82593 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82594 /*
82595 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82596 * other variables. It can be updated by several CPUs frequently.
82597 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82598 struct vm_area_struct *next = vma->vm_next;
82599
82600 might_sleep();
82601 + BUG_ON(vma->vm_mirror);
82602 if (vma->vm_ops && vma->vm_ops->close)
82603 vma->vm_ops->close(vma);
82604 if (vma->vm_file)
82605 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82606 * not page aligned -Ram Gupta
82607 */
82608 rlim = rlimit(RLIMIT_DATA);
82609 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82610 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82611 (mm->end_data - mm->start_data) > rlim)
82612 goto out;
82613 @@ -933,6 +956,12 @@ static int
82614 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82615 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82616 {
82617 +
82618 +#ifdef CONFIG_PAX_SEGMEXEC
82619 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82620 + return 0;
82621 +#endif
82622 +
82623 if (is_mergeable_vma(vma, file, vm_flags) &&
82624 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82625 if (vma->vm_pgoff == vm_pgoff)
82626 @@ -952,6 +981,12 @@ static int
82627 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82628 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82629 {
82630 +
82631 +#ifdef CONFIG_PAX_SEGMEXEC
82632 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82633 + return 0;
82634 +#endif
82635 +
82636 if (is_mergeable_vma(vma, file, vm_flags) &&
82637 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82638 pgoff_t vm_pglen;
82639 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82640 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82641 struct vm_area_struct *prev, unsigned long addr,
82642 unsigned long end, unsigned long vm_flags,
82643 - struct anon_vma *anon_vma, struct file *file,
82644 + struct anon_vma *anon_vma, struct file *file,
82645 pgoff_t pgoff, struct mempolicy *policy)
82646 {
82647 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82648 struct vm_area_struct *area, *next;
82649 int err;
82650
82651 +#ifdef CONFIG_PAX_SEGMEXEC
82652 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82653 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82654 +
82655 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82656 +#endif
82657 +
82658 /*
82659 * We later require that vma->vm_flags == vm_flags,
82660 * so this tests vma->vm_flags & VM_SPECIAL, too.
82661 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82662 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82663 next = next->vm_next;
82664
82665 +#ifdef CONFIG_PAX_SEGMEXEC
82666 + if (prev)
82667 + prev_m = pax_find_mirror_vma(prev);
82668 + if (area)
82669 + area_m = pax_find_mirror_vma(area);
82670 + if (next)
82671 + next_m = pax_find_mirror_vma(next);
82672 +#endif
82673 +
82674 /*
82675 * Can it merge with the predecessor?
82676 */
82677 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82678 /* cases 1, 6 */
82679 err = vma_adjust(prev, prev->vm_start,
82680 next->vm_end, prev->vm_pgoff, NULL);
82681 - } else /* cases 2, 5, 7 */
82682 +
82683 +#ifdef CONFIG_PAX_SEGMEXEC
82684 + if (!err && prev_m)
82685 + err = vma_adjust(prev_m, prev_m->vm_start,
82686 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82687 +#endif
82688 +
82689 + } else { /* cases 2, 5, 7 */
82690 err = vma_adjust(prev, prev->vm_start,
82691 end, prev->vm_pgoff, NULL);
82692 +
82693 +#ifdef CONFIG_PAX_SEGMEXEC
82694 + if (!err && prev_m)
82695 + err = vma_adjust(prev_m, prev_m->vm_start,
82696 + end_m, prev_m->vm_pgoff, NULL);
82697 +#endif
82698 +
82699 + }
82700 if (err)
82701 return NULL;
82702 khugepaged_enter_vma_merge(prev);
82703 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82704 mpol_equal(policy, vma_policy(next)) &&
82705 can_vma_merge_before(next, vm_flags,
82706 anon_vma, file, pgoff+pglen)) {
82707 - if (prev && addr < prev->vm_end) /* case 4 */
82708 + if (prev && addr < prev->vm_end) { /* case 4 */
82709 err = vma_adjust(prev, prev->vm_start,
82710 addr, prev->vm_pgoff, NULL);
82711 - else /* cases 3, 8 */
82712 +
82713 +#ifdef CONFIG_PAX_SEGMEXEC
82714 + if (!err && prev_m)
82715 + err = vma_adjust(prev_m, prev_m->vm_start,
82716 + addr_m, prev_m->vm_pgoff, NULL);
82717 +#endif
82718 +
82719 + } else { /* cases 3, 8 */
82720 err = vma_adjust(area, addr, next->vm_end,
82721 next->vm_pgoff - pglen, NULL);
82722 +
82723 +#ifdef CONFIG_PAX_SEGMEXEC
82724 + if (!err && area_m)
82725 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82726 + next_m->vm_pgoff - pglen, NULL);
82727 +#endif
82728 +
82729 + }
82730 if (err)
82731 return NULL;
82732 khugepaged_enter_vma_merge(area);
82733 @@ -1165,8 +1246,10 @@ none:
82734 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82735 struct file *file, long pages)
82736 {
82737 - const unsigned long stack_flags
82738 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82739 +
82740 +#ifdef CONFIG_PAX_RANDMMAP
82741 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82742 +#endif
82743
82744 mm->total_vm += pages;
82745
82746 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82747 mm->shared_vm += pages;
82748 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82749 mm->exec_vm += pages;
82750 - } else if (flags & stack_flags)
82751 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82752 mm->stack_vm += pages;
82753 }
82754 #endif /* CONFIG_PROC_FS */
82755 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82756 * (the exception is when the underlying filesystem is noexec
82757 * mounted, in which case we dont add PROT_EXEC.)
82758 */
82759 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82760 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82761 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82762 prot |= PROT_EXEC;
82763
82764 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82765 /* Obtain the address to map to. we verify (or select) it and ensure
82766 * that it represents a valid section of the address space.
82767 */
82768 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82769 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82770 if (addr & ~PAGE_MASK)
82771 return addr;
82772
82773 @@ -1250,6 +1333,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82774 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82775 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82776
82777 +#ifdef CONFIG_PAX_MPROTECT
82778 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82779 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82780 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82781 + gr_log_rwxmmap(file);
82782 +
82783 +#ifdef CONFIG_PAX_EMUPLT
82784 + vm_flags &= ~VM_EXEC;
82785 +#else
82786 + return -EPERM;
82787 +#endif
82788 +
82789 + }
82790 +
82791 + if (!(vm_flags & VM_EXEC))
82792 + vm_flags &= ~VM_MAYEXEC;
82793 +#else
82794 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82795 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82796 +#endif
82797 + else
82798 + vm_flags &= ~VM_MAYWRITE;
82799 + }
82800 +#endif
82801 +
82802 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82803 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82804 + vm_flags &= ~VM_PAGEEXEC;
82805 +#endif
82806 +
82807 if (flags & MAP_LOCKED)
82808 if (!can_do_mlock())
82809 return -EPERM;
82810 @@ -1261,6 +1374,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82811 locked += mm->locked_vm;
82812 lock_limit = rlimit(RLIMIT_MEMLOCK);
82813 lock_limit >>= PAGE_SHIFT;
82814 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82815 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82816 return -EAGAIN;
82817 }
82818 @@ -1341,6 +1455,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82819 vm_flags |= VM_NORESERVE;
82820 }
82821
82822 + if (!gr_acl_handle_mmap(file, prot))
82823 + return -EACCES;
82824 +
82825 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82826 if (!IS_ERR_VALUE(addr) &&
82827 ((vm_flags & VM_LOCKED) ||
82828 @@ -1432,7 +1549,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82829 vm_flags_t vm_flags = vma->vm_flags;
82830
82831 /* If it was private or non-writable, the write bit is already clear */
82832 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82833 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82834 return 0;
82835
82836 /* The backer wishes to know when pages are first written to? */
82837 @@ -1480,7 +1597,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82838 unsigned long charged = 0;
82839 struct inode *inode = file ? file_inode(file) : NULL;
82840
82841 +#ifdef CONFIG_PAX_SEGMEXEC
82842 + struct vm_area_struct *vma_m = NULL;
82843 +#endif
82844 +
82845 + /*
82846 + * mm->mmap_sem is required to protect against another thread
82847 + * changing the mappings in case we sleep.
82848 + */
82849 + verify_mm_writelocked(mm);
82850 +
82851 /* Check against address space limit. */
82852 +
82853 +#ifdef CONFIG_PAX_RANDMMAP
82854 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82855 +#endif
82856 +
82857 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
82858 unsigned long nr_pages;
82859
82860 @@ -1499,11 +1631,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82861
82862 /* Clear old maps */
82863 error = -ENOMEM;
82864 -munmap_back:
82865 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82866 if (do_munmap(mm, addr, len))
82867 return -ENOMEM;
82868 - goto munmap_back;
82869 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82870 }
82871
82872 /*
82873 @@ -1534,6 +1665,16 @@ munmap_back:
82874 goto unacct_error;
82875 }
82876
82877 +#ifdef CONFIG_PAX_SEGMEXEC
82878 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82879 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82880 + if (!vma_m) {
82881 + error = -ENOMEM;
82882 + goto free_vma;
82883 + }
82884 + }
82885 +#endif
82886 +
82887 vma->vm_mm = mm;
82888 vma->vm_start = addr;
82889 vma->vm_end = addr + len;
82890 @@ -1558,6 +1699,13 @@ munmap_back:
82891 if (error)
82892 goto unmap_and_free_vma;
82893
82894 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82895 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82896 + vma->vm_flags |= VM_PAGEEXEC;
82897 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82898 + }
82899 +#endif
82900 +
82901 /* Can addr have changed??
82902 *
82903 * Answer: Yes, several device drivers can do it in their
82904 @@ -1596,6 +1744,11 @@ munmap_back:
82905 vma_link(mm, vma, prev, rb_link, rb_parent);
82906 file = vma->vm_file;
82907
82908 +#ifdef CONFIG_PAX_SEGMEXEC
82909 + if (vma_m)
82910 + BUG_ON(pax_mirror_vma(vma_m, vma));
82911 +#endif
82912 +
82913 /* Once vma denies write, undo our temporary denial count */
82914 if (correct_wcount)
82915 atomic_inc(&inode->i_writecount);
82916 @@ -1603,6 +1756,7 @@ out:
82917 perf_event_mmap(vma);
82918
82919 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82920 + track_exec_limit(mm, addr, addr + len, vm_flags);
82921 if (vm_flags & VM_LOCKED) {
82922 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82923 vma == get_gate_vma(current->mm)))
82924 @@ -1626,6 +1780,12 @@ unmap_and_free_vma:
82925 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82926 charged = 0;
82927 free_vma:
82928 +
82929 +#ifdef CONFIG_PAX_SEGMEXEC
82930 + if (vma_m)
82931 + kmem_cache_free(vm_area_cachep, vma_m);
82932 +#endif
82933 +
82934 kmem_cache_free(vm_area_cachep, vma);
82935 unacct_error:
82936 if (charged)
82937 @@ -1633,7 +1793,63 @@ unacct_error:
82938 return error;
82939 }
82940
82941 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82942 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82943 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82944 +{
82945 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82946 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
82947 +
82948 + return 0;
82949 +}
82950 +#endif
82951 +
82952 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82953 +{
82954 + if (!vma) {
82955 +#ifdef CONFIG_STACK_GROWSUP
82956 + if (addr > sysctl_heap_stack_gap)
82957 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82958 + else
82959 + vma = find_vma(current->mm, 0);
82960 + if (vma && (vma->vm_flags & VM_GROWSUP))
82961 + return false;
82962 +#endif
82963 + return true;
82964 + }
82965 +
82966 + if (addr + len > vma->vm_start)
82967 + return false;
82968 +
82969 + if (vma->vm_flags & VM_GROWSDOWN)
82970 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82971 +#ifdef CONFIG_STACK_GROWSUP
82972 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82973 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
82974 +#endif
82975 + else if (offset)
82976 + return offset <= vma->vm_start - addr - len;
82977 +
82978 + return true;
82979 +}
82980 +
82981 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82982 +{
82983 + if (vma->vm_start < len)
82984 + return -ENOMEM;
82985 +
82986 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82987 + if (offset <= vma->vm_start - len)
82988 + return vma->vm_start - len - offset;
82989 + else
82990 + return -ENOMEM;
82991 + }
82992 +
82993 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82994 + return vma->vm_start - len - sysctl_heap_stack_gap;
82995 + return -ENOMEM;
82996 +}
82997 +
82998 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
82999 {
83000 /*
83001 * We implement the search by looking for an rbtree node that
83002 @@ -1681,11 +1897,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83003 }
83004 }
83005
83006 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
83007 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
83008 check_current:
83009 /* Check if current node has a suitable gap */
83010 if (gap_start > high_limit)
83011 return -ENOMEM;
83012 +
83013 + if (gap_end - gap_start > info->threadstack_offset)
83014 + gap_start += info->threadstack_offset;
83015 + else
83016 + gap_start = gap_end;
83017 +
83018 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83019 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83020 + gap_start += sysctl_heap_stack_gap;
83021 + else
83022 + gap_start = gap_end;
83023 + }
83024 + if (vma->vm_flags & VM_GROWSDOWN) {
83025 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83026 + gap_end -= sysctl_heap_stack_gap;
83027 + else
83028 + gap_end = gap_start;
83029 + }
83030 if (gap_end >= low_limit && gap_end - gap_start >= length)
83031 goto found;
83032
83033 @@ -1735,7 +1969,7 @@ found:
83034 return gap_start;
83035 }
83036
83037 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
83038 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
83039 {
83040 struct mm_struct *mm = current->mm;
83041 struct vm_area_struct *vma;
83042 @@ -1789,6 +2023,24 @@ check_current:
83043 gap_end = vma->vm_start;
83044 if (gap_end < low_limit)
83045 return -ENOMEM;
83046 +
83047 + if (gap_end - gap_start > info->threadstack_offset)
83048 + gap_end -= info->threadstack_offset;
83049 + else
83050 + gap_end = gap_start;
83051 +
83052 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83053 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83054 + gap_start += sysctl_heap_stack_gap;
83055 + else
83056 + gap_start = gap_end;
83057 + }
83058 + if (vma->vm_flags & VM_GROWSDOWN) {
83059 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83060 + gap_end -= sysctl_heap_stack_gap;
83061 + else
83062 + gap_end = gap_start;
83063 + }
83064 if (gap_start <= high_limit && gap_end - gap_start >= length)
83065 goto found;
83066
83067 @@ -1852,6 +2104,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83068 struct mm_struct *mm = current->mm;
83069 struct vm_area_struct *vma;
83070 struct vm_unmapped_area_info info;
83071 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83072
83073 if (len > TASK_SIZE)
83074 return -ENOMEM;
83075 @@ -1859,29 +2112,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83076 if (flags & MAP_FIXED)
83077 return addr;
83078
83079 +#ifdef CONFIG_PAX_RANDMMAP
83080 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83081 +#endif
83082 +
83083 if (addr) {
83084 addr = PAGE_ALIGN(addr);
83085 vma = find_vma(mm, addr);
83086 - if (TASK_SIZE - len >= addr &&
83087 - (!vma || addr + len <= vma->vm_start))
83088 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83089 return addr;
83090 }
83091
83092 info.flags = 0;
83093 info.length = len;
83094 info.low_limit = TASK_UNMAPPED_BASE;
83095 +
83096 +#ifdef CONFIG_PAX_RANDMMAP
83097 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83098 + info.low_limit += mm->delta_mmap;
83099 +#endif
83100 +
83101 info.high_limit = TASK_SIZE;
83102 info.align_mask = 0;
83103 + info.threadstack_offset = offset;
83104 return vm_unmapped_area(&info);
83105 }
83106 #endif
83107
83108 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
83109 {
83110 +
83111 +#ifdef CONFIG_PAX_SEGMEXEC
83112 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83113 + return;
83114 +#endif
83115 +
83116 /*
83117 * Is this a new hole at the lowest possible address?
83118 */
83119 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
83120 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
83121 mm->free_area_cache = addr;
83122 }
83123
83124 @@ -1899,6 +2168,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83125 struct mm_struct *mm = current->mm;
83126 unsigned long addr = addr0;
83127 struct vm_unmapped_area_info info;
83128 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83129
83130 /* requested length too big for entire address space */
83131 if (len > TASK_SIZE)
83132 @@ -1907,12 +2177,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83133 if (flags & MAP_FIXED)
83134 return addr;
83135
83136 +#ifdef CONFIG_PAX_RANDMMAP
83137 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83138 +#endif
83139 +
83140 /* requesting a specific address */
83141 if (addr) {
83142 addr = PAGE_ALIGN(addr);
83143 vma = find_vma(mm, addr);
83144 - if (TASK_SIZE - len >= addr &&
83145 - (!vma || addr + len <= vma->vm_start))
83146 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83147 return addr;
83148 }
83149
83150 @@ -1921,6 +2194,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83151 info.low_limit = PAGE_SIZE;
83152 info.high_limit = mm->mmap_base;
83153 info.align_mask = 0;
83154 + info.threadstack_offset = offset;
83155 addr = vm_unmapped_area(&info);
83156
83157 /*
83158 @@ -1933,6 +2207,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83159 VM_BUG_ON(addr != -ENOMEM);
83160 info.flags = 0;
83161 info.low_limit = TASK_UNMAPPED_BASE;
83162 +
83163 +#ifdef CONFIG_PAX_RANDMMAP
83164 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83165 + info.low_limit += mm->delta_mmap;
83166 +#endif
83167 +
83168 info.high_limit = TASK_SIZE;
83169 addr = vm_unmapped_area(&info);
83170 }
83171 @@ -1943,6 +2223,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83172
83173 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83174 {
83175 +
83176 +#ifdef CONFIG_PAX_SEGMEXEC
83177 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83178 + return;
83179 +#endif
83180 +
83181 /*
83182 * Is this a new hole at the highest possible address?
83183 */
83184 @@ -1950,8 +2236,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83185 mm->free_area_cache = addr;
83186
83187 /* dont allow allocations above current base */
83188 - if (mm->free_area_cache > mm->mmap_base)
83189 + if (mm->free_area_cache > mm->mmap_base) {
83190 mm->free_area_cache = mm->mmap_base;
83191 + mm->cached_hole_size = ~0UL;
83192 + }
83193 }
83194
83195 unsigned long
83196 @@ -2047,6 +2335,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83197 return vma;
83198 }
83199
83200 +#ifdef CONFIG_PAX_SEGMEXEC
83201 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83202 +{
83203 + struct vm_area_struct *vma_m;
83204 +
83205 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83206 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83207 + BUG_ON(vma->vm_mirror);
83208 + return NULL;
83209 + }
83210 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83211 + vma_m = vma->vm_mirror;
83212 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83213 + BUG_ON(vma->vm_file != vma_m->vm_file);
83214 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83215 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83216 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83217 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83218 + return vma_m;
83219 +}
83220 +#endif
83221 +
83222 /*
83223 * Verify that the stack growth is acceptable and
83224 * update accounting. This is shared with both the
83225 @@ -2063,6 +2373,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83226 return -ENOMEM;
83227
83228 /* Stack limit test */
83229 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
83230 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
83231 return -ENOMEM;
83232
83233 @@ -2073,6 +2384,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83234 locked = mm->locked_vm + grow;
83235 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
83236 limit >>= PAGE_SHIFT;
83237 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83238 if (locked > limit && !capable(CAP_IPC_LOCK))
83239 return -ENOMEM;
83240 }
83241 @@ -2102,37 +2414,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83242 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
83243 * vma is the last one with address > vma->vm_end. Have to extend vma.
83244 */
83245 +#ifndef CONFIG_IA64
83246 +static
83247 +#endif
83248 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83249 {
83250 int error;
83251 + bool locknext;
83252
83253 if (!(vma->vm_flags & VM_GROWSUP))
83254 return -EFAULT;
83255
83256 + /* Also guard against wrapping around to address 0. */
83257 + if (address < PAGE_ALIGN(address+1))
83258 + address = PAGE_ALIGN(address+1);
83259 + else
83260 + return -ENOMEM;
83261 +
83262 /*
83263 * We must make sure the anon_vma is allocated
83264 * so that the anon_vma locking is not a noop.
83265 */
83266 if (unlikely(anon_vma_prepare(vma)))
83267 return -ENOMEM;
83268 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
83269 + if (locknext && anon_vma_prepare(vma->vm_next))
83270 + return -ENOMEM;
83271 vma_lock_anon_vma(vma);
83272 + if (locknext)
83273 + vma_lock_anon_vma(vma->vm_next);
83274
83275 /*
83276 * vma->vm_start/vm_end cannot change under us because the caller
83277 * is required to hold the mmap_sem in read mode. We need the
83278 - * anon_vma lock to serialize against concurrent expand_stacks.
83279 - * Also guard against wrapping around to address 0.
83280 + * anon_vma locks to serialize against concurrent expand_stacks
83281 + * and expand_upwards.
83282 */
83283 - if (address < PAGE_ALIGN(address+4))
83284 - address = PAGE_ALIGN(address+4);
83285 - else {
83286 - vma_unlock_anon_vma(vma);
83287 - return -ENOMEM;
83288 - }
83289 error = 0;
83290
83291 /* Somebody else might have raced and expanded it already */
83292 - if (address > vma->vm_end) {
83293 + 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)
83294 + error = -ENOMEM;
83295 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
83296 unsigned long size, grow;
83297
83298 size = address - vma->vm_start;
83299 @@ -2167,6 +2490,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83300 }
83301 }
83302 }
83303 + if (locknext)
83304 + vma_unlock_anon_vma(vma->vm_next);
83305 vma_unlock_anon_vma(vma);
83306 khugepaged_enter_vma_merge(vma);
83307 validate_mm(vma->vm_mm);
83308 @@ -2181,6 +2506,8 @@ int expand_downwards(struct vm_area_struct *vma,
83309 unsigned long address)
83310 {
83311 int error;
83312 + bool lockprev = false;
83313 + struct vm_area_struct *prev;
83314
83315 /*
83316 * We must make sure the anon_vma is allocated
83317 @@ -2194,6 +2521,15 @@ int expand_downwards(struct vm_area_struct *vma,
83318 if (error)
83319 return error;
83320
83321 + prev = vma->vm_prev;
83322 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
83323 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
83324 +#endif
83325 + if (lockprev && anon_vma_prepare(prev))
83326 + return -ENOMEM;
83327 + if (lockprev)
83328 + vma_lock_anon_vma(prev);
83329 +
83330 vma_lock_anon_vma(vma);
83331
83332 /*
83333 @@ -2203,9 +2539,17 @@ int expand_downwards(struct vm_area_struct *vma,
83334 */
83335
83336 /* Somebody else might have raced and expanded it already */
83337 - if (address < vma->vm_start) {
83338 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
83339 + error = -ENOMEM;
83340 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
83341 unsigned long size, grow;
83342
83343 +#ifdef CONFIG_PAX_SEGMEXEC
83344 + struct vm_area_struct *vma_m;
83345 +
83346 + vma_m = pax_find_mirror_vma(vma);
83347 +#endif
83348 +
83349 size = vma->vm_end - address;
83350 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83351
83352 @@ -2230,13 +2574,27 @@ int expand_downwards(struct vm_area_struct *vma,
83353 vma->vm_pgoff -= grow;
83354 anon_vma_interval_tree_post_update_vma(vma);
83355 vma_gap_update(vma);
83356 +
83357 +#ifdef CONFIG_PAX_SEGMEXEC
83358 + if (vma_m) {
83359 + anon_vma_interval_tree_pre_update_vma(vma_m);
83360 + vma_m->vm_start -= grow << PAGE_SHIFT;
83361 + vma_m->vm_pgoff -= grow;
83362 + anon_vma_interval_tree_post_update_vma(vma_m);
83363 + vma_gap_update(vma_m);
83364 + }
83365 +#endif
83366 +
83367 spin_unlock(&vma->vm_mm->page_table_lock);
83368
83369 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83370 perf_event_mmap(vma);
83371 }
83372 }
83373 }
83374 vma_unlock_anon_vma(vma);
83375 + if (lockprev)
83376 + vma_unlock_anon_vma(prev);
83377 khugepaged_enter_vma_merge(vma);
83378 validate_mm(vma->vm_mm);
83379 return error;
83380 @@ -2334,6 +2692,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83381 do {
83382 long nrpages = vma_pages(vma);
83383
83384 +#ifdef CONFIG_PAX_SEGMEXEC
83385 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83386 + vma = remove_vma(vma);
83387 + continue;
83388 + }
83389 +#endif
83390 +
83391 if (vma->vm_flags & VM_ACCOUNT)
83392 nr_accounted += nrpages;
83393 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83394 @@ -2379,6 +2744,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83395 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83396 vma->vm_prev = NULL;
83397 do {
83398 +
83399 +#ifdef CONFIG_PAX_SEGMEXEC
83400 + if (vma->vm_mirror) {
83401 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83402 + vma->vm_mirror->vm_mirror = NULL;
83403 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83404 + vma->vm_mirror = NULL;
83405 + }
83406 +#endif
83407 +
83408 vma_rb_erase(vma, &mm->mm_rb);
83409 mm->map_count--;
83410 tail_vma = vma;
83411 @@ -2410,14 +2785,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83412 struct vm_area_struct *new;
83413 int err = -ENOMEM;
83414
83415 +#ifdef CONFIG_PAX_SEGMEXEC
83416 + struct vm_area_struct *vma_m, *new_m = NULL;
83417 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83418 +#endif
83419 +
83420 if (is_vm_hugetlb_page(vma) && (addr &
83421 ~(huge_page_mask(hstate_vma(vma)))))
83422 return -EINVAL;
83423
83424 +#ifdef CONFIG_PAX_SEGMEXEC
83425 + vma_m = pax_find_mirror_vma(vma);
83426 +#endif
83427 +
83428 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83429 if (!new)
83430 goto out_err;
83431
83432 +#ifdef CONFIG_PAX_SEGMEXEC
83433 + if (vma_m) {
83434 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83435 + if (!new_m) {
83436 + kmem_cache_free(vm_area_cachep, new);
83437 + goto out_err;
83438 + }
83439 + }
83440 +#endif
83441 +
83442 /* most fields are the same, copy all, and then fixup */
83443 *new = *vma;
83444
83445 @@ -2430,6 +2824,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83446 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83447 }
83448
83449 +#ifdef CONFIG_PAX_SEGMEXEC
83450 + if (vma_m) {
83451 + *new_m = *vma_m;
83452 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83453 + new_m->vm_mirror = new;
83454 + new->vm_mirror = new_m;
83455 +
83456 + if (new_below)
83457 + new_m->vm_end = addr_m;
83458 + else {
83459 + new_m->vm_start = addr_m;
83460 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83461 + }
83462 + }
83463 +#endif
83464 +
83465 pol = mpol_dup(vma_policy(vma));
83466 if (IS_ERR(pol)) {
83467 err = PTR_ERR(pol);
83468 @@ -2452,6 +2862,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83469 else
83470 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83471
83472 +#ifdef CONFIG_PAX_SEGMEXEC
83473 + if (!err && vma_m) {
83474 + if (anon_vma_clone(new_m, vma_m))
83475 + goto out_free_mpol;
83476 +
83477 + mpol_get(pol);
83478 + vma_set_policy(new_m, pol);
83479 +
83480 + if (new_m->vm_file)
83481 + get_file(new_m->vm_file);
83482 +
83483 + if (new_m->vm_ops && new_m->vm_ops->open)
83484 + new_m->vm_ops->open(new_m);
83485 +
83486 + if (new_below)
83487 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83488 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83489 + else
83490 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83491 +
83492 + if (err) {
83493 + if (new_m->vm_ops && new_m->vm_ops->close)
83494 + new_m->vm_ops->close(new_m);
83495 + if (new_m->vm_file)
83496 + fput(new_m->vm_file);
83497 + mpol_put(pol);
83498 + }
83499 + }
83500 +#endif
83501 +
83502 /* Success. */
83503 if (!err)
83504 return 0;
83505 @@ -2461,10 +2901,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83506 new->vm_ops->close(new);
83507 if (new->vm_file)
83508 fput(new->vm_file);
83509 - unlink_anon_vmas(new);
83510 out_free_mpol:
83511 mpol_put(pol);
83512 out_free_vma:
83513 +
83514 +#ifdef CONFIG_PAX_SEGMEXEC
83515 + if (new_m) {
83516 + unlink_anon_vmas(new_m);
83517 + kmem_cache_free(vm_area_cachep, new_m);
83518 + }
83519 +#endif
83520 +
83521 + unlink_anon_vmas(new);
83522 kmem_cache_free(vm_area_cachep, new);
83523 out_err:
83524 return err;
83525 @@ -2477,6 +2925,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83526 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83527 unsigned long addr, int new_below)
83528 {
83529 +
83530 +#ifdef CONFIG_PAX_SEGMEXEC
83531 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83532 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83533 + if (mm->map_count >= sysctl_max_map_count-1)
83534 + return -ENOMEM;
83535 + } else
83536 +#endif
83537 +
83538 if (mm->map_count >= sysctl_max_map_count)
83539 return -ENOMEM;
83540
83541 @@ -2488,11 +2945,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83542 * work. This now handles partial unmappings.
83543 * Jeremy Fitzhardinge <jeremy@goop.org>
83544 */
83545 +#ifdef CONFIG_PAX_SEGMEXEC
83546 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83547 {
83548 + int ret = __do_munmap(mm, start, len);
83549 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83550 + return ret;
83551 +
83552 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83553 +}
83554 +
83555 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83556 +#else
83557 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83558 +#endif
83559 +{
83560 unsigned long end;
83561 struct vm_area_struct *vma, *prev, *last;
83562
83563 + /*
83564 + * mm->mmap_sem is required to protect against another thread
83565 + * changing the mappings in case we sleep.
83566 + */
83567 + verify_mm_writelocked(mm);
83568 +
83569 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83570 return -EINVAL;
83571
83572 @@ -2567,6 +3043,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83573 /* Fix up all other VM information */
83574 remove_vma_list(mm, vma);
83575
83576 + track_exec_limit(mm, start, end, 0UL);
83577 +
83578 return 0;
83579 }
83580
83581 @@ -2575,6 +3053,13 @@ int vm_munmap(unsigned long start, size_t len)
83582 int ret;
83583 struct mm_struct *mm = current->mm;
83584
83585 +
83586 +#ifdef CONFIG_PAX_SEGMEXEC
83587 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83588 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83589 + return -EINVAL;
83590 +#endif
83591 +
83592 down_write(&mm->mmap_sem);
83593 ret = do_munmap(mm, start, len);
83594 up_write(&mm->mmap_sem);
83595 @@ -2588,16 +3073,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83596 return vm_munmap(addr, len);
83597 }
83598
83599 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83600 -{
83601 -#ifdef CONFIG_DEBUG_VM
83602 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83603 - WARN_ON(1);
83604 - up_read(&mm->mmap_sem);
83605 - }
83606 -#endif
83607 -}
83608 -
83609 /*
83610 * this is really a simplified "do_mmap". it only handles
83611 * anonymous maps. eventually we may be able to do some
83612 @@ -2611,6 +3086,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83613 struct rb_node ** rb_link, * rb_parent;
83614 pgoff_t pgoff = addr >> PAGE_SHIFT;
83615 int error;
83616 + unsigned long charged;
83617
83618 len = PAGE_ALIGN(len);
83619 if (!len)
83620 @@ -2618,16 +3094,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83621
83622 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83623
83624 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83625 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83626 + flags &= ~VM_EXEC;
83627 +
83628 +#ifdef CONFIG_PAX_MPROTECT
83629 + if (mm->pax_flags & MF_PAX_MPROTECT)
83630 + flags &= ~VM_MAYEXEC;
83631 +#endif
83632 +
83633 + }
83634 +#endif
83635 +
83636 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83637 if (error & ~PAGE_MASK)
83638 return error;
83639
83640 + charged = len >> PAGE_SHIFT;
83641 +
83642 /*
83643 * mlock MCL_FUTURE?
83644 */
83645 if (mm->def_flags & VM_LOCKED) {
83646 unsigned long locked, lock_limit;
83647 - locked = len >> PAGE_SHIFT;
83648 + locked = charged;
83649 locked += mm->locked_vm;
83650 lock_limit = rlimit(RLIMIT_MEMLOCK);
83651 lock_limit >>= PAGE_SHIFT;
83652 @@ -2644,21 +3134,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83653 /*
83654 * Clear old maps. this also does some error checking for us
83655 */
83656 - munmap_back:
83657 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83658 if (do_munmap(mm, addr, len))
83659 return -ENOMEM;
83660 - goto munmap_back;
83661 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83662 }
83663
83664 /* Check against address space limits *after* clearing old maps... */
83665 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83666 + if (!may_expand_vm(mm, charged))
83667 return -ENOMEM;
83668
83669 if (mm->map_count > sysctl_max_map_count)
83670 return -ENOMEM;
83671
83672 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83673 + if (security_vm_enough_memory_mm(mm, charged))
83674 return -ENOMEM;
83675
83676 /* Can we just expand an old private anonymous mapping? */
83677 @@ -2672,7 +3161,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83678 */
83679 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83680 if (!vma) {
83681 - vm_unacct_memory(len >> PAGE_SHIFT);
83682 + vm_unacct_memory(charged);
83683 return -ENOMEM;
83684 }
83685
83686 @@ -2686,9 +3175,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83687 vma_link(mm, vma, prev, rb_link, rb_parent);
83688 out:
83689 perf_event_mmap(vma);
83690 - mm->total_vm += len >> PAGE_SHIFT;
83691 + mm->total_vm += charged;
83692 if (flags & VM_LOCKED)
83693 - mm->locked_vm += (len >> PAGE_SHIFT);
83694 + mm->locked_vm += charged;
83695 + track_exec_limit(mm, addr, addr + len, flags);
83696 return addr;
83697 }
83698
83699 @@ -2750,6 +3240,7 @@ void exit_mmap(struct mm_struct *mm)
83700 while (vma) {
83701 if (vma->vm_flags & VM_ACCOUNT)
83702 nr_accounted += vma_pages(vma);
83703 + vma->vm_mirror = NULL;
83704 vma = remove_vma(vma);
83705 }
83706 vm_unacct_memory(nr_accounted);
83707 @@ -2766,6 +3257,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83708 struct vm_area_struct *prev;
83709 struct rb_node **rb_link, *rb_parent;
83710
83711 +#ifdef CONFIG_PAX_SEGMEXEC
83712 + struct vm_area_struct *vma_m = NULL;
83713 +#endif
83714 +
83715 + if (security_mmap_addr(vma->vm_start))
83716 + return -EPERM;
83717 +
83718 /*
83719 * The vm_pgoff of a purely anonymous vma should be irrelevant
83720 * until its first write fault, when page's anon_vma and index
83721 @@ -2789,7 +3287,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83722 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83723 return -ENOMEM;
83724
83725 +#ifdef CONFIG_PAX_SEGMEXEC
83726 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83727 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83728 + if (!vma_m)
83729 + return -ENOMEM;
83730 + }
83731 +#endif
83732 +
83733 vma_link(mm, vma, prev, rb_link, rb_parent);
83734 +
83735 +#ifdef CONFIG_PAX_SEGMEXEC
83736 + if (vma_m)
83737 + BUG_ON(pax_mirror_vma(vma_m, vma));
83738 +#endif
83739 +
83740 return 0;
83741 }
83742
83743 @@ -2809,6 +3321,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83744 struct mempolicy *pol;
83745 bool faulted_in_anon_vma = true;
83746
83747 + BUG_ON(vma->vm_mirror);
83748 +
83749 /*
83750 * If anonymous vma has not yet been faulted, update new pgoff
83751 * to match new location, to increase its chance of merging.
83752 @@ -2875,6 +3389,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83753 return NULL;
83754 }
83755
83756 +#ifdef CONFIG_PAX_SEGMEXEC
83757 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83758 +{
83759 + struct vm_area_struct *prev_m;
83760 + struct rb_node **rb_link_m, *rb_parent_m;
83761 + struct mempolicy *pol_m;
83762 +
83763 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83764 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83765 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83766 + *vma_m = *vma;
83767 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83768 + if (anon_vma_clone(vma_m, vma))
83769 + return -ENOMEM;
83770 + pol_m = vma_policy(vma_m);
83771 + mpol_get(pol_m);
83772 + vma_set_policy(vma_m, pol_m);
83773 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83774 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83775 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83776 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83777 + if (vma_m->vm_file)
83778 + get_file(vma_m->vm_file);
83779 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83780 + vma_m->vm_ops->open(vma_m);
83781 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83782 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83783 + vma_m->vm_mirror = vma;
83784 + vma->vm_mirror = vma_m;
83785 + return 0;
83786 +}
83787 +#endif
83788 +
83789 /*
83790 * Return true if the calling process may expand its vm space by the passed
83791 * number of pages
83792 @@ -2886,6 +3433,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83793
83794 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83795
83796 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83797 if (cur + npages > lim)
83798 return 0;
83799 return 1;
83800 @@ -2956,6 +3504,22 @@ int install_special_mapping(struct mm_struct *mm,
83801 vma->vm_start = addr;
83802 vma->vm_end = addr + len;
83803
83804 +#ifdef CONFIG_PAX_MPROTECT
83805 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83806 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83807 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83808 + return -EPERM;
83809 + if (!(vm_flags & VM_EXEC))
83810 + vm_flags &= ~VM_MAYEXEC;
83811 +#else
83812 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83813 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83814 +#endif
83815 + else
83816 + vm_flags &= ~VM_MAYWRITE;
83817 + }
83818 +#endif
83819 +
83820 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83821 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83822
83823 diff --git a/mm/mprotect.c b/mm/mprotect.c
83824 index 94722a4..07d9926 100644
83825 --- a/mm/mprotect.c
83826 +++ b/mm/mprotect.c
83827 @@ -23,10 +23,18 @@
83828 #include <linux/mmu_notifier.h>
83829 #include <linux/migrate.h>
83830 #include <linux/perf_event.h>
83831 +#include <linux/sched/sysctl.h>
83832 +
83833 +#ifdef CONFIG_PAX_MPROTECT
83834 +#include <linux/elf.h>
83835 +#include <linux/binfmts.h>
83836 +#endif
83837 +
83838 #include <asm/uaccess.h>
83839 #include <asm/pgtable.h>
83840 #include <asm/cacheflush.h>
83841 #include <asm/tlbflush.h>
83842 +#include <asm/mmu_context.h>
83843
83844 #ifndef pgprot_modify
83845 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83846 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83847 return pages;
83848 }
83849
83850 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83851 +/* called while holding the mmap semaphor for writing except stack expansion */
83852 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83853 +{
83854 + unsigned long oldlimit, newlimit = 0UL;
83855 +
83856 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83857 + return;
83858 +
83859 + spin_lock(&mm->page_table_lock);
83860 + oldlimit = mm->context.user_cs_limit;
83861 + if ((prot & VM_EXEC) && oldlimit < end)
83862 + /* USER_CS limit moved up */
83863 + newlimit = end;
83864 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83865 + /* USER_CS limit moved down */
83866 + newlimit = start;
83867 +
83868 + if (newlimit) {
83869 + mm->context.user_cs_limit = newlimit;
83870 +
83871 +#ifdef CONFIG_SMP
83872 + wmb();
83873 + cpus_clear(mm->context.cpu_user_cs_mask);
83874 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83875 +#endif
83876 +
83877 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83878 + }
83879 + spin_unlock(&mm->page_table_lock);
83880 + if (newlimit == end) {
83881 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83882 +
83883 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83884 + if (is_vm_hugetlb_page(vma))
83885 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83886 + else
83887 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83888 + }
83889 +}
83890 +#endif
83891 +
83892 int
83893 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83894 unsigned long start, unsigned long end, unsigned long newflags)
83895 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83896 int error;
83897 int dirty_accountable = 0;
83898
83899 +#ifdef CONFIG_PAX_SEGMEXEC
83900 + struct vm_area_struct *vma_m = NULL;
83901 + unsigned long start_m, end_m;
83902 +
83903 + start_m = start + SEGMEXEC_TASK_SIZE;
83904 + end_m = end + SEGMEXEC_TASK_SIZE;
83905 +#endif
83906 +
83907 if (newflags == oldflags) {
83908 *pprev = vma;
83909 return 0;
83910 }
83911
83912 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83913 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83914 +
83915 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83916 + return -ENOMEM;
83917 +
83918 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83919 + return -ENOMEM;
83920 + }
83921 +
83922 /*
83923 * If we make a private mapping writable we increase our commit;
83924 * but (without finer accounting) cannot reduce our commit if we
83925 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83926 }
83927 }
83928
83929 +#ifdef CONFIG_PAX_SEGMEXEC
83930 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83931 + if (start != vma->vm_start) {
83932 + error = split_vma(mm, vma, start, 1);
83933 + if (error)
83934 + goto fail;
83935 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83936 + *pprev = (*pprev)->vm_next;
83937 + }
83938 +
83939 + if (end != vma->vm_end) {
83940 + error = split_vma(mm, vma, end, 0);
83941 + if (error)
83942 + goto fail;
83943 + }
83944 +
83945 + if (pax_find_mirror_vma(vma)) {
83946 + error = __do_munmap(mm, start_m, end_m - start_m);
83947 + if (error)
83948 + goto fail;
83949 + } else {
83950 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83951 + if (!vma_m) {
83952 + error = -ENOMEM;
83953 + goto fail;
83954 + }
83955 + vma->vm_flags = newflags;
83956 + error = pax_mirror_vma(vma_m, vma);
83957 + if (error) {
83958 + vma->vm_flags = oldflags;
83959 + goto fail;
83960 + }
83961 + }
83962 + }
83963 +#endif
83964 +
83965 /*
83966 * First try to merge with previous and/or next vma.
83967 */
83968 @@ -296,9 +400,21 @@ success:
83969 * vm_flags and vm_page_prot are protected by the mmap_sem
83970 * held in write mode.
83971 */
83972 +
83973 +#ifdef CONFIG_PAX_SEGMEXEC
83974 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83975 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83976 +#endif
83977 +
83978 vma->vm_flags = newflags;
83979 +
83980 +#ifdef CONFIG_PAX_MPROTECT
83981 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83982 + mm->binfmt->handle_mprotect(vma, newflags);
83983 +#endif
83984 +
83985 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83986 - vm_get_page_prot(newflags));
83987 + vm_get_page_prot(vma->vm_flags));
83988
83989 if (vma_wants_writenotify(vma)) {
83990 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83991 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83992 end = start + len;
83993 if (end <= start)
83994 return -ENOMEM;
83995 +
83996 +#ifdef CONFIG_PAX_SEGMEXEC
83997 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83998 + if (end > SEGMEXEC_TASK_SIZE)
83999 + return -EINVAL;
84000 + } else
84001 +#endif
84002 +
84003 + if (end > TASK_SIZE)
84004 + return -EINVAL;
84005 +
84006 if (!arch_validate_prot(prot))
84007 return -EINVAL;
84008
84009 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84010 /*
84011 * Does the application expect PROT_READ to imply PROT_EXEC:
84012 */
84013 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
84014 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
84015 prot |= PROT_EXEC;
84016
84017 vm_flags = calc_vm_prot_bits(prot);
84018 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84019 if (start > vma->vm_start)
84020 prev = vma;
84021
84022 +#ifdef CONFIG_PAX_MPROTECT
84023 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
84024 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
84025 +#endif
84026 +
84027 for (nstart = start ; ; ) {
84028 unsigned long newflags;
84029
84030 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84031
84032 /* newflags >> 4 shift VM_MAY% in place of VM_% */
84033 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
84034 + if (prot & (PROT_WRITE | PROT_EXEC))
84035 + gr_log_rwxmprotect(vma->vm_file);
84036 +
84037 + error = -EACCES;
84038 + goto out;
84039 + }
84040 +
84041 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
84042 error = -EACCES;
84043 goto out;
84044 }
84045 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84046 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
84047 if (error)
84048 goto out;
84049 +
84050 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
84051 +
84052 nstart = tmp;
84053
84054 if (nstart < prev->vm_end)
84055 diff --git a/mm/mremap.c b/mm/mremap.c
84056 index 463a257..c0c7a92 100644
84057 --- a/mm/mremap.c
84058 +++ b/mm/mremap.c
84059 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
84060 continue;
84061 pte = ptep_get_and_clear(mm, old_addr, old_pte);
84062 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
84063 +
84064 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84065 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
84066 + pte = pte_exprotect(pte);
84067 +#endif
84068 +
84069 set_pte_at(mm, new_addr, new_pte, pte);
84070 }
84071
84072 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
84073 if (is_vm_hugetlb_page(vma))
84074 goto Einval;
84075
84076 +#ifdef CONFIG_PAX_SEGMEXEC
84077 + if (pax_find_mirror_vma(vma))
84078 + goto Einval;
84079 +#endif
84080 +
84081 /* We can't remap across vm area boundaries */
84082 if (old_len > vma->vm_end - addr)
84083 goto Efault;
84084 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
84085 unsigned long ret = -EINVAL;
84086 unsigned long charged = 0;
84087 unsigned long map_flags;
84088 + unsigned long pax_task_size = TASK_SIZE;
84089
84090 if (new_addr & ~PAGE_MASK)
84091 goto out;
84092
84093 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
84094 +#ifdef CONFIG_PAX_SEGMEXEC
84095 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84096 + pax_task_size = SEGMEXEC_TASK_SIZE;
84097 +#endif
84098 +
84099 + pax_task_size -= PAGE_SIZE;
84100 +
84101 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
84102 goto out;
84103
84104 /* Check if the location we're moving into overlaps the
84105 * old location at all, and fail if it does.
84106 */
84107 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
84108 - goto out;
84109 -
84110 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
84111 + if (addr + old_len > new_addr && new_addr + new_len > addr)
84112 goto out;
84113
84114 ret = do_munmap(mm, new_addr, new_len);
84115 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84116 unsigned long ret = -EINVAL;
84117 unsigned long charged = 0;
84118 bool locked = false;
84119 + unsigned long pax_task_size = TASK_SIZE;
84120
84121 down_write(&current->mm->mmap_sem);
84122
84123 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84124 if (!new_len)
84125 goto out;
84126
84127 +#ifdef CONFIG_PAX_SEGMEXEC
84128 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84129 + pax_task_size = SEGMEXEC_TASK_SIZE;
84130 +#endif
84131 +
84132 + pax_task_size -= PAGE_SIZE;
84133 +
84134 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
84135 + old_len > pax_task_size || addr > pax_task_size-old_len)
84136 + goto out;
84137 +
84138 if (flags & MREMAP_FIXED) {
84139 if (flags & MREMAP_MAYMOVE)
84140 ret = mremap_to(addr, old_len, new_addr, new_len,
84141 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84142 new_addr = addr;
84143 }
84144 ret = addr;
84145 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
84146 goto out;
84147 }
84148 }
84149 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84150 goto out;
84151 }
84152
84153 + map_flags = vma->vm_flags;
84154 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
84155 + if (!(ret & ~PAGE_MASK)) {
84156 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84157 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84158 + }
84159 }
84160 out:
84161 if (ret & ~PAGE_MASK)
84162 diff --git a/mm/nommu.c b/mm/nommu.c
84163 index 298884d..5f74980 100644
84164 --- a/mm/nommu.c
84165 +++ b/mm/nommu.c
84166 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84167 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84168 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
84169 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
84170 -int heap_stack_gap = 0;
84171
84172 atomic_long_t mmap_pages_allocated;
84173
84174 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84175 EXPORT_SYMBOL(find_vma);
84176
84177 /*
84178 - * find a VMA
84179 - * - we don't extend stack VMAs under NOMMU conditions
84180 - */
84181 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84182 -{
84183 - return find_vma(mm, addr);
84184 -}
84185 -
84186 -/*
84187 * expand a stack to a given address
84188 * - not supported under NOMMU conditions
84189 */
84190 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84191
84192 /* most fields are the same, copy all, and then fixup */
84193 *new = *vma;
84194 + INIT_LIST_HEAD(&new->anon_vma_chain);
84195 *region = *vma->vm_region;
84196 new->vm_region = region;
84197
84198 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84199 }
84200 EXPORT_SYMBOL(generic_file_remap_pages);
84201
84202 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84203 - unsigned long addr, void *buf, int len, int write)
84204 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84205 + unsigned long addr, void *buf, size_t len, int write)
84206 {
84207 struct vm_area_struct *vma;
84208
84209 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84210 *
84211 * The caller must hold a reference on @mm.
84212 */
84213 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84214 - void *buf, int len, int write)
84215 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84216 + void *buf, size_t len, int write)
84217 {
84218 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84219 }
84220 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84221 * Access another process' address space.
84222 * - source/target buffer must be kernel space
84223 */
84224 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84225 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84226 {
84227 struct mm_struct *mm;
84228
84229 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
84230 index 4514ad7..92eaa1c 100644
84231 --- a/mm/page-writeback.c
84232 +++ b/mm/page-writeback.c
84233 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
84234 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
84235 * - the bdi dirty thresh drops quickly due to change of JBOD workload
84236 */
84237 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
84238 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
84239 unsigned long thresh,
84240 unsigned long bg_thresh,
84241 unsigned long dirty,
84242 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
84243 }
84244 }
84245
84246 -static struct notifier_block __cpuinitdata ratelimit_nb = {
84247 +static struct notifier_block ratelimit_nb = {
84248 .notifier_call = ratelimit_handler,
84249 .next = NULL,
84250 };
84251 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
84252 index c3edb62..2d60097 100644
84253 --- a/mm/page_alloc.c
84254 +++ b/mm/page_alloc.c
84255 @@ -60,6 +60,7 @@
84256 #include <linux/page-debug-flags.h>
84257 #include <linux/hugetlb.h>
84258 #include <linux/sched/rt.h>
84259 +#include <linux/random.h>
84260
84261 #include <asm/tlbflush.h>
84262 #include <asm/div64.h>
84263 @@ -345,7 +346,7 @@ out:
84264 * This usage means that zero-order pages may not be compound.
84265 */
84266
84267 -static void free_compound_page(struct page *page)
84268 +void free_compound_page(struct page *page)
84269 {
84270 __free_pages_ok(page, compound_order(page));
84271 }
84272 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84273 int i;
84274 int bad = 0;
84275
84276 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84277 + unsigned long index = 1UL << order;
84278 +#endif
84279 +
84280 trace_mm_page_free(page, order);
84281 kmemcheck_free_shadow(page, order);
84282
84283 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84284 debug_check_no_obj_freed(page_address(page),
84285 PAGE_SIZE << order);
84286 }
84287 +
84288 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84289 + for (; index; --index)
84290 + sanitize_highpage(page + index - 1);
84291 +#endif
84292 +
84293 arch_free_page(page, order);
84294 kernel_map_pages(page, 1 << order, 0);
84295
84296 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
84297 local_irq_restore(flags);
84298 }
84299
84300 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84301 +bool __meminitdata extra_latent_entropy;
84302 +
84303 +static int __init setup_pax_extra_latent_entropy(char *str)
84304 +{
84305 + extra_latent_entropy = true;
84306 + return 0;
84307 +}
84308 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
84309 +
84310 +volatile u64 latent_entropy;
84311 +#endif
84312 +
84313 /*
84314 * Read access to zone->managed_pages is safe because it's unsigned long,
84315 * but we still need to serialize writers. Currently all callers of
84316 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
84317 set_page_count(p, 0);
84318 }
84319
84320 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84321 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
84322 + u64 hash = 0;
84323 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
84324 + const u64 *data = lowmem_page_address(page);
84325 +
84326 + for (index = 0; index < end; index++)
84327 + hash ^= hash + data[index];
84328 + latent_entropy ^= hash;
84329 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
84330 + }
84331 +#endif
84332 +
84333 page_zone(page)->managed_pages += 1 << order;
84334 set_page_refcounted(page);
84335 __free_pages(page, order);
84336 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
84337 arch_alloc_page(page, order);
84338 kernel_map_pages(page, 1 << order, 1);
84339
84340 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
84341 if (gfp_flags & __GFP_ZERO)
84342 prep_zero_page(page, order, gfp_flags);
84343 +#endif
84344
84345 if (order && (gfp_flags & __GFP_COMP))
84346 prep_compound_page(page, order);
84347 diff --git a/mm/page_io.c b/mm/page_io.c
84348 index a8a3ef4..7260a60 100644
84349 --- a/mm/page_io.c
84350 +++ b/mm/page_io.c
84351 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
84352 struct file *swap_file = sis->swap_file;
84353 struct address_space *mapping = swap_file->f_mapping;
84354 struct iovec iov = {
84355 - .iov_base = kmap(page),
84356 + .iov_base = (void __force_user *)kmap(page),
84357 .iov_len = PAGE_SIZE,
84358 };
84359
84360 diff --git a/mm/percpu.c b/mm/percpu.c
84361 index 8c8e08f..73a5cda 100644
84362 --- a/mm/percpu.c
84363 +++ b/mm/percpu.c
84364 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84365 static unsigned int pcpu_high_unit_cpu __read_mostly;
84366
84367 /* the address of the first chunk which starts with the kernel static area */
84368 -void *pcpu_base_addr __read_mostly;
84369 +void *pcpu_base_addr __read_only;
84370 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84371
84372 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84373 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84374 index fd26d04..0cea1b0 100644
84375 --- a/mm/process_vm_access.c
84376 +++ b/mm/process_vm_access.c
84377 @@ -13,6 +13,7 @@
84378 #include <linux/uio.h>
84379 #include <linux/sched.h>
84380 #include <linux/highmem.h>
84381 +#include <linux/security.h>
84382 #include <linux/ptrace.h>
84383 #include <linux/slab.h>
84384 #include <linux/syscalls.h>
84385 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84386 size_t iov_l_curr_offset = 0;
84387 ssize_t iov_len;
84388
84389 + return -ENOSYS; // PaX: until properly audited
84390 +
84391 /*
84392 * Work out how many pages of struct pages we're going to need
84393 * when eventually calling get_user_pages
84394 */
84395 for (i = 0; i < riovcnt; i++) {
84396 iov_len = rvec[i].iov_len;
84397 - if (iov_len > 0) {
84398 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84399 - + iov_len)
84400 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84401 - / PAGE_SIZE + 1;
84402 - nr_pages = max(nr_pages, nr_pages_iov);
84403 - }
84404 + if (iov_len <= 0)
84405 + continue;
84406 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84407 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84408 + nr_pages = max(nr_pages, nr_pages_iov);
84409 }
84410
84411 if (nr_pages == 0)
84412 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84413 goto free_proc_pages;
84414 }
84415
84416 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84417 + rc = -EPERM;
84418 + goto put_task_struct;
84419 + }
84420 +
84421 mm = mm_access(task, PTRACE_MODE_ATTACH);
84422 if (!mm || IS_ERR(mm)) {
84423 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84424 diff --git a/mm/rmap.c b/mm/rmap.c
84425 index 6280da8..ecce194 100644
84426 --- a/mm/rmap.c
84427 +++ b/mm/rmap.c
84428 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84429 struct anon_vma *anon_vma = vma->anon_vma;
84430 struct anon_vma_chain *avc;
84431
84432 +#ifdef CONFIG_PAX_SEGMEXEC
84433 + struct anon_vma_chain *avc_m = NULL;
84434 +#endif
84435 +
84436 might_sleep();
84437 if (unlikely(!anon_vma)) {
84438 struct mm_struct *mm = vma->vm_mm;
84439 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84440 if (!avc)
84441 goto out_enomem;
84442
84443 +#ifdef CONFIG_PAX_SEGMEXEC
84444 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84445 + if (!avc_m)
84446 + goto out_enomem_free_avc;
84447 +#endif
84448 +
84449 anon_vma = find_mergeable_anon_vma(vma);
84450 allocated = NULL;
84451 if (!anon_vma) {
84452 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84453 /* page_table_lock to protect against threads */
84454 spin_lock(&mm->page_table_lock);
84455 if (likely(!vma->anon_vma)) {
84456 +
84457 +#ifdef CONFIG_PAX_SEGMEXEC
84458 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84459 +
84460 + if (vma_m) {
84461 + BUG_ON(vma_m->anon_vma);
84462 + vma_m->anon_vma = anon_vma;
84463 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84464 + avc_m = NULL;
84465 + }
84466 +#endif
84467 +
84468 vma->anon_vma = anon_vma;
84469 anon_vma_chain_link(vma, avc, anon_vma);
84470 allocated = NULL;
84471 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84472
84473 if (unlikely(allocated))
84474 put_anon_vma(allocated);
84475 +
84476 +#ifdef CONFIG_PAX_SEGMEXEC
84477 + if (unlikely(avc_m))
84478 + anon_vma_chain_free(avc_m);
84479 +#endif
84480 +
84481 if (unlikely(avc))
84482 anon_vma_chain_free(avc);
84483 }
84484 return 0;
84485
84486 out_enomem_free_avc:
84487 +
84488 +#ifdef CONFIG_PAX_SEGMEXEC
84489 + if (avc_m)
84490 + anon_vma_chain_free(avc_m);
84491 +#endif
84492 +
84493 anon_vma_chain_free(avc);
84494 out_enomem:
84495 return -ENOMEM;
84496 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84497 * Attach the anon_vmas from src to dst.
84498 * Returns 0 on success, -ENOMEM on failure.
84499 */
84500 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84501 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84502 {
84503 struct anon_vma_chain *avc, *pavc;
84504 struct anon_vma *root = NULL;
84505 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84506 * the corresponding VMA in the parent process is attached to.
84507 * Returns 0 on success, non-zero on failure.
84508 */
84509 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84510 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84511 {
84512 struct anon_vma_chain *avc;
84513 struct anon_vma *anon_vma;
84514 diff --git a/mm/shmem.c b/mm/shmem.c
84515 index 5e6a842..b41916e 100644
84516 --- a/mm/shmem.c
84517 +++ b/mm/shmem.c
84518 @@ -33,7 +33,7 @@
84519 #include <linux/swap.h>
84520 #include <linux/aio.h>
84521
84522 -static struct vfsmount *shm_mnt;
84523 +struct vfsmount *shm_mnt;
84524
84525 #ifdef CONFIG_SHMEM
84526 /*
84527 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
84528 #define BOGO_DIRENT_SIZE 20
84529
84530 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84531 -#define SHORT_SYMLINK_LEN 128
84532 +#define SHORT_SYMLINK_LEN 64
84533
84534 /*
84535 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84536 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84537 static int shmem_xattr_validate(const char *name)
84538 {
84539 struct { const char *prefix; size_t len; } arr[] = {
84540 +
84541 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84542 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84543 +#endif
84544 +
84545 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84546 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84547 };
84548 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84549 if (err)
84550 return err;
84551
84552 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84553 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84554 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84555 + return -EOPNOTSUPP;
84556 + if (size > 8)
84557 + return -EINVAL;
84558 + }
84559 +#endif
84560 +
84561 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84562 }
84563
84564 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84565 int err = -ENOMEM;
84566
84567 /* Round up to L1_CACHE_BYTES to resist false sharing */
84568 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84569 - L1_CACHE_BYTES), GFP_KERNEL);
84570 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84571 if (!sbinfo)
84572 return -ENOMEM;
84573
84574 diff --git a/mm/slab.c b/mm/slab.c
84575 index 8ccd296..012fe4e 100644
84576 --- a/mm/slab.c
84577 +++ b/mm/slab.c
84578 @@ -366,10 +366,10 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
84579 if ((x)->max_freeable < i) \
84580 (x)->max_freeable = i; \
84581 } while (0)
84582 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84583 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84584 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84585 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84586 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84587 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84588 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84589 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84590 #else
84591 #define STATS_INC_ACTIVE(x) do { } while (0)
84592 #define STATS_DEC_ACTIVE(x) do { } while (0)
84593 @@ -477,7 +477,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84594 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84595 */
84596 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84597 - const struct slab *slab, void *obj)
84598 + const struct slab *slab, const void *obj)
84599 {
84600 u32 offset = (obj - slab->s_mem);
84601 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84602 @@ -1384,7 +1384,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84603 return notifier_from_errno(err);
84604 }
84605
84606 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84607 +static struct notifier_block cpucache_notifier = {
84608 &cpuup_callback, NULL, 0
84609 };
84610
84611 @@ -1565,12 +1565,12 @@ void __init kmem_cache_init(void)
84612 */
84613
84614 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
84615 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
84616 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
84617
84618 if (INDEX_AC != INDEX_NODE)
84619 kmalloc_caches[INDEX_NODE] =
84620 create_kmalloc_cache("kmalloc-node",
84621 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
84622 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
84623
84624 slab_early_init = 0;
84625
84626 @@ -3800,6 +3800,7 @@ void kfree(const void *objp)
84627
84628 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84629 return;
84630 + VM_BUG_ON(!virt_addr_valid(objp));
84631 local_irq_save(flags);
84632 kfree_debugcheck(objp);
84633 c = virt_to_cache(objp);
84634 @@ -4241,10 +4242,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84635 }
84636 /* cpu stats */
84637 {
84638 - unsigned long allochit = atomic_read(&cachep->allochit);
84639 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84640 - unsigned long freehit = atomic_read(&cachep->freehit);
84641 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84642 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84643 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84644 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84645 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84646
84647 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84648 allochit, allocmiss, freehit, freemiss);
84649 @@ -4476,13 +4477,71 @@ static const struct file_operations proc_slabstats_operations = {
84650 static int __init slab_proc_init(void)
84651 {
84652 #ifdef CONFIG_DEBUG_SLAB_LEAK
84653 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84654 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84655 #endif
84656 return 0;
84657 }
84658 module_init(slab_proc_init);
84659 #endif
84660
84661 +bool is_usercopy_object(const void *ptr)
84662 +{
84663 + struct page *page;
84664 + struct kmem_cache *cachep;
84665 +
84666 + if (ZERO_OR_NULL_PTR(ptr))
84667 + return false;
84668 +
84669 + if (!slab_is_available())
84670 + return false;
84671 +
84672 + if (!virt_addr_valid(ptr))
84673 + return false;
84674 +
84675 + page = virt_to_head_page(ptr);
84676 +
84677 + if (!PageSlab(page))
84678 + return false;
84679 +
84680 + cachep = page->slab_cache;
84681 + return cachep->flags & SLAB_USERCOPY;
84682 +}
84683 +
84684 +#ifdef CONFIG_PAX_USERCOPY
84685 +const char *check_heap_object(const void *ptr, unsigned long n)
84686 +{
84687 + struct page *page;
84688 + struct kmem_cache *cachep;
84689 + struct slab *slabp;
84690 + unsigned int objnr;
84691 + unsigned long offset;
84692 +
84693 + if (ZERO_OR_NULL_PTR(ptr))
84694 + return "<null>";
84695 +
84696 + if (!virt_addr_valid(ptr))
84697 + return NULL;
84698 +
84699 + page = virt_to_head_page(ptr);
84700 +
84701 + if (!PageSlab(page))
84702 + return NULL;
84703 +
84704 + cachep = page->slab_cache;
84705 + if (!(cachep->flags & SLAB_USERCOPY))
84706 + return cachep->name;
84707 +
84708 + slabp = page->slab_page;
84709 + objnr = obj_to_index(cachep, slabp, ptr);
84710 + BUG_ON(objnr >= cachep->num);
84711 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84712 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84713 + return NULL;
84714 +
84715 + return cachep->name;
84716 +}
84717 +#endif
84718 +
84719 /**
84720 * ksize - get the actual amount of memory allocated for a given object
84721 * @objp: Pointer to the object
84722 diff --git a/mm/slab.h b/mm/slab.h
84723 index f96b49e..5634e90 100644
84724 --- a/mm/slab.h
84725 +++ b/mm/slab.h
84726 @@ -67,7 +67,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84727
84728 /* Legal flag mask for kmem_cache_create(), for various configurations */
84729 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84730 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84731 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84732
84733 #if defined(CONFIG_DEBUG_SLAB)
84734 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84735 @@ -229,6 +229,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84736 return s;
84737
84738 page = virt_to_head_page(x);
84739 +
84740 + BUG_ON(!PageSlab(page));
84741 +
84742 cachep = page->slab_cache;
84743 if (slab_equal_or_root(cachep, s))
84744 return cachep;
84745 diff --git a/mm/slab_common.c b/mm/slab_common.c
84746 index 2d41450..e22088e 100644
84747 --- a/mm/slab_common.c
84748 +++ b/mm/slab_common.c
84749 @@ -22,7 +22,7 @@
84750
84751 #include "slab.h"
84752
84753 -enum slab_state slab_state;
84754 +enum slab_state slab_state __read_only;
84755 LIST_HEAD(slab_caches);
84756 DEFINE_MUTEX(slab_mutex);
84757 struct kmem_cache *kmem_cache;
84758 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84759
84760 err = __kmem_cache_create(s, flags);
84761 if (!err) {
84762 - s->refcount = 1;
84763 + atomic_set(&s->refcount, 1);
84764 list_add(&s->list, &slab_caches);
84765 memcg_cache_list_add(memcg, s);
84766 } else {
84767 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84768
84769 get_online_cpus();
84770 mutex_lock(&slab_mutex);
84771 - s->refcount--;
84772 - if (!s->refcount) {
84773 + if (atomic_dec_and_test(&s->refcount)) {
84774 list_del(&s->list);
84775
84776 if (!__kmem_cache_shutdown(s)) {
84777 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84778 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
84779 name, size, err);
84780
84781 - s->refcount = -1; /* Exempt from merging for now */
84782 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84783 }
84784
84785 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84786 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84787
84788 create_boot_cache(s, name, size, flags);
84789 list_add(&s->list, &slab_caches);
84790 - s->refcount = 1;
84791 + atomic_set(&s->refcount, 1);
84792 return s;
84793 }
84794
84795 @@ -327,6 +326,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
84796 EXPORT_SYMBOL(kmalloc_dma_caches);
84797 #endif
84798
84799 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84800 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
84801 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
84802 +#endif
84803 +
84804 /*
84805 * Conversion table for small slabs sizes / 8 to the index in the
84806 * kmalloc array. This is necessary for slabs < 192 since we have non power
84807 @@ -391,6 +395,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
84808 return kmalloc_dma_caches[index];
84809
84810 #endif
84811 +
84812 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84813 + if (unlikely((flags & GFP_USERCOPY)))
84814 + return kmalloc_usercopy_caches[index];
84815 +
84816 +#endif
84817 +
84818 return kmalloc_caches[index];
84819 }
84820
84821 @@ -447,7 +458,7 @@ void __init create_kmalloc_caches(unsigned long flags)
84822 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
84823 if (!kmalloc_caches[i]) {
84824 kmalloc_caches[i] = create_kmalloc_cache(NULL,
84825 - 1 << i, flags);
84826 + 1 << i, SLAB_USERCOPY | flags);
84827 }
84828
84829 /*
84830 @@ -456,10 +467,10 @@ void __init create_kmalloc_caches(unsigned long flags)
84831 * earlier power of two caches
84832 */
84833 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
84834 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
84835 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
84836
84837 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
84838 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
84839 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
84840 }
84841
84842 /* Kmalloc array is now usable */
84843 @@ -492,6 +503,23 @@ void __init create_kmalloc_caches(unsigned long flags)
84844 }
84845 }
84846 #endif
84847 +
84848 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84849 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
84850 + struct kmem_cache *s = kmalloc_caches[i];
84851 +
84852 + if (s) {
84853 + int size = kmalloc_size(i);
84854 + char *n = kasprintf(GFP_NOWAIT,
84855 + "usercopy-kmalloc-%d", size);
84856 +
84857 + BUG_ON(!n);
84858 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
84859 + size, SLAB_USERCOPY | flags);
84860 + }
84861 + }
84862 +#endif
84863 +
84864 }
84865 #endif /* !CONFIG_SLOB */
84866
84867 diff --git a/mm/slob.c b/mm/slob.c
84868 index eeed4a0..6ee34ec 100644
84869 --- a/mm/slob.c
84870 +++ b/mm/slob.c
84871 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84872 /*
84873 * Return the size of a slob block.
84874 */
84875 -static slobidx_t slob_units(slob_t *s)
84876 +static slobidx_t slob_units(const slob_t *s)
84877 {
84878 if (s->units > 0)
84879 return s->units;
84880 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84881 /*
84882 * Return the next free slob block pointer after this one.
84883 */
84884 -static slob_t *slob_next(slob_t *s)
84885 +static slob_t *slob_next(const slob_t *s)
84886 {
84887 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84888 slobidx_t next;
84889 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84890 /*
84891 * Returns true if s is the last free block in its page.
84892 */
84893 -static int slob_last(slob_t *s)
84894 +static int slob_last(const slob_t *s)
84895 {
84896 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84897 }
84898
84899 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84900 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84901 {
84902 - void *page;
84903 + struct page *page;
84904
84905 #ifdef CONFIG_NUMA
84906 if (node != NUMA_NO_NODE)
84907 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84908 if (!page)
84909 return NULL;
84910
84911 - return page_address(page);
84912 + __SetPageSlab(page);
84913 + return page;
84914 }
84915
84916 -static void slob_free_pages(void *b, int order)
84917 +static void slob_free_pages(struct page *sp, int order)
84918 {
84919 if (current->reclaim_state)
84920 current->reclaim_state->reclaimed_slab += 1 << order;
84921 - free_pages((unsigned long)b, order);
84922 + __ClearPageSlab(sp);
84923 + reset_page_mapcount(sp);
84924 + sp->private = 0;
84925 + __free_pages(sp, order);
84926 }
84927
84928 /*
84929 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84930
84931 /* Not enough space: must allocate a new page */
84932 if (!b) {
84933 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84934 - if (!b)
84935 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84936 + if (!sp)
84937 return NULL;
84938 - sp = virt_to_page(b);
84939 - __SetPageSlab(sp);
84940 + b = page_address(sp);
84941
84942 spin_lock_irqsave(&slob_lock, flags);
84943 sp->units = SLOB_UNITS(PAGE_SIZE);
84944 sp->freelist = b;
84945 + sp->private = 0;
84946 INIT_LIST_HEAD(&sp->list);
84947 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84948 set_slob_page_free(sp, slob_list);
84949 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84950 if (slob_page_free(sp))
84951 clear_slob_page_free(sp);
84952 spin_unlock_irqrestore(&slob_lock, flags);
84953 - __ClearPageSlab(sp);
84954 - page_mapcount_reset(sp);
84955 - slob_free_pages(b, 0);
84956 + slob_free_pages(sp, 0);
84957 return;
84958 }
84959
84960 @@ -424,11 +426,10 @@ out:
84961 */
84962
84963 static __always_inline void *
84964 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84965 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84966 {
84967 - unsigned int *m;
84968 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84969 - void *ret;
84970 + slob_t *m;
84971 + void *ret = NULL;
84972
84973 gfp &= gfp_allowed_mask;
84974
84975 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84976
84977 if (!m)
84978 return NULL;
84979 - *m = size;
84980 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84981 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84982 + m[0].units = size;
84983 + m[1].units = align;
84984 ret = (void *)m + align;
84985
84986 trace_kmalloc_node(caller, ret,
84987 size, size + align, gfp, node);
84988 } else {
84989 unsigned int order = get_order(size);
84990 + struct page *page;
84991
84992 if (likely(order))
84993 gfp |= __GFP_COMP;
84994 - ret = slob_new_pages(gfp, order, node);
84995 + page = slob_new_pages(gfp, order, node);
84996 + if (page) {
84997 + ret = page_address(page);
84998 + page->private = size;
84999 + }
85000
85001 trace_kmalloc_node(caller, ret,
85002 size, PAGE_SIZE << order, gfp, node);
85003 }
85004
85005 - kmemleak_alloc(ret, size, 1, gfp);
85006 + return ret;
85007 +}
85008 +
85009 +static __always_inline void *
85010 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85011 +{
85012 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85013 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
85014 +
85015 + if (!ZERO_OR_NULL_PTR(ret))
85016 + kmemleak_alloc(ret, size, 1, gfp);
85017 return ret;
85018 }
85019
85020 @@ -493,34 +512,112 @@ void kfree(const void *block)
85021 return;
85022 kmemleak_free(block);
85023
85024 + VM_BUG_ON(!virt_addr_valid(block));
85025 sp = virt_to_page(block);
85026 - if (PageSlab(sp)) {
85027 + VM_BUG_ON(!PageSlab(sp));
85028 + if (!sp->private) {
85029 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85030 - unsigned int *m = (unsigned int *)(block - align);
85031 - slob_free(m, *m + align);
85032 - } else
85033 + slob_t *m = (slob_t *)(block - align);
85034 + slob_free(m, m[0].units + align);
85035 + } else {
85036 + __ClearPageSlab(sp);
85037 + reset_page_mapcount(sp);
85038 + sp->private = 0;
85039 __free_pages(sp, compound_order(sp));
85040 + }
85041 }
85042 EXPORT_SYMBOL(kfree);
85043
85044 +bool is_usercopy_object(const void *ptr)
85045 +{
85046 + if (!slab_is_available())
85047 + return false;
85048 +
85049 + // PAX: TODO
85050 +
85051 + return false;
85052 +}
85053 +
85054 +#ifdef CONFIG_PAX_USERCOPY
85055 +const char *check_heap_object(const void *ptr, unsigned long n)
85056 +{
85057 + struct page *page;
85058 + const slob_t *free;
85059 + const void *base;
85060 + unsigned long flags;
85061 +
85062 + if (ZERO_OR_NULL_PTR(ptr))
85063 + return "<null>";
85064 +
85065 + if (!virt_addr_valid(ptr))
85066 + return NULL;
85067 +
85068 + page = virt_to_head_page(ptr);
85069 + if (!PageSlab(page))
85070 + return NULL;
85071 +
85072 + if (page->private) {
85073 + base = page;
85074 + if (base <= ptr && n <= page->private - (ptr - base))
85075 + return NULL;
85076 + return "<slob>";
85077 + }
85078 +
85079 + /* some tricky double walking to find the chunk */
85080 + spin_lock_irqsave(&slob_lock, flags);
85081 + base = (void *)((unsigned long)ptr & PAGE_MASK);
85082 + free = page->freelist;
85083 +
85084 + while (!slob_last(free) && (void *)free <= ptr) {
85085 + base = free + slob_units(free);
85086 + free = slob_next(free);
85087 + }
85088 +
85089 + while (base < (void *)free) {
85090 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
85091 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
85092 + int offset;
85093 +
85094 + if (ptr < base + align)
85095 + break;
85096 +
85097 + offset = ptr - base - align;
85098 + if (offset >= m) {
85099 + base += size;
85100 + continue;
85101 + }
85102 +
85103 + if (n > m - offset)
85104 + break;
85105 +
85106 + spin_unlock_irqrestore(&slob_lock, flags);
85107 + return NULL;
85108 + }
85109 +
85110 + spin_unlock_irqrestore(&slob_lock, flags);
85111 + return "<slob>";
85112 +}
85113 +#endif
85114 +
85115 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
85116 size_t ksize(const void *block)
85117 {
85118 struct page *sp;
85119 int align;
85120 - unsigned int *m;
85121 + slob_t *m;
85122
85123 BUG_ON(!block);
85124 if (unlikely(block == ZERO_SIZE_PTR))
85125 return 0;
85126
85127 sp = virt_to_page(block);
85128 - if (unlikely(!PageSlab(sp)))
85129 - return PAGE_SIZE << compound_order(sp);
85130 + VM_BUG_ON(!PageSlab(sp));
85131 + if (sp->private)
85132 + return sp->private;
85133
85134 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85135 - m = (unsigned int *)(block - align);
85136 - return SLOB_UNITS(*m) * SLOB_UNIT;
85137 + m = (slob_t *)(block - align);
85138 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
85139 }
85140 EXPORT_SYMBOL(ksize);
85141
85142 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
85143
85144 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
85145 {
85146 - void *b;
85147 + void *b = NULL;
85148
85149 flags &= gfp_allowed_mask;
85150
85151 lockdep_trace_alloc(flags);
85152
85153 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85154 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
85155 +#else
85156 if (c->size < PAGE_SIZE) {
85157 b = slob_alloc(c->size, flags, c->align, node);
85158 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85159 SLOB_UNITS(c->size) * SLOB_UNIT,
85160 flags, node);
85161 } else {
85162 - b = slob_new_pages(flags, get_order(c->size), node);
85163 + struct page *sp;
85164 +
85165 + sp = slob_new_pages(flags, get_order(c->size), node);
85166 + if (sp) {
85167 + b = page_address(sp);
85168 + sp->private = c->size;
85169 + }
85170 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85171 PAGE_SIZE << get_order(c->size),
85172 flags, node);
85173 }
85174 +#endif
85175
85176 if (c->ctor)
85177 c->ctor(b);
85178 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
85179
85180 static void __kmem_cache_free(void *b, int size)
85181 {
85182 - if (size < PAGE_SIZE)
85183 + struct page *sp;
85184 +
85185 + sp = virt_to_page(b);
85186 + BUG_ON(!PageSlab(sp));
85187 + if (!sp->private)
85188 slob_free(b, size);
85189 else
85190 - slob_free_pages(b, get_order(size));
85191 + slob_free_pages(sp, get_order(size));
85192 }
85193
85194 static void kmem_rcu_free(struct rcu_head *head)
85195 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
85196
85197 void kmem_cache_free(struct kmem_cache *c, void *b)
85198 {
85199 + int size = c->size;
85200 +
85201 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85202 + if (size + c->align < PAGE_SIZE) {
85203 + size += c->align;
85204 + b -= c->align;
85205 + }
85206 +#endif
85207 +
85208 kmemleak_free_recursive(b, c->flags);
85209 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
85210 struct slob_rcu *slob_rcu;
85211 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
85212 - slob_rcu->size = c->size;
85213 + slob_rcu = b + (size - sizeof(struct slob_rcu));
85214 + slob_rcu->size = size;
85215 call_rcu(&slob_rcu->head, kmem_rcu_free);
85216 } else {
85217 - __kmem_cache_free(b, c->size);
85218 + __kmem_cache_free(b, size);
85219 }
85220
85221 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85222 + trace_kfree(_RET_IP_, b);
85223 +#else
85224 trace_kmem_cache_free(_RET_IP_, b);
85225 +#endif
85226 +
85227 }
85228 EXPORT_SYMBOL(kmem_cache_free);
85229
85230 diff --git a/mm/slub.c b/mm/slub.c
85231 index 57707f0..c28619b 100644
85232 --- a/mm/slub.c
85233 +++ b/mm/slub.c
85234 @@ -198,7 +198,7 @@ struct track {
85235
85236 enum track_item { TRACK_ALLOC, TRACK_FREE };
85237
85238 -#ifdef CONFIG_SYSFS
85239 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85240 static int sysfs_slab_add(struct kmem_cache *);
85241 static int sysfs_slab_alias(struct kmem_cache *, const char *);
85242 static void sysfs_slab_remove(struct kmem_cache *);
85243 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
85244 if (!t->addr)
85245 return;
85246
85247 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
85248 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
85249 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
85250 #ifdef CONFIG_STACKTRACE
85251 {
85252 @@ -2661,7 +2661,7 @@ static int slub_min_objects;
85253 * Merge control. If this is set then no merging of slab caches will occur.
85254 * (Could be removed. This was introduced to pacify the merge skeptics.)
85255 */
85256 -static int slub_nomerge;
85257 +static int slub_nomerge = 1;
85258
85259 /*
85260 * Calculate the order of allocation given an slab object size.
85261 @@ -3283,6 +3283,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
85262 EXPORT_SYMBOL(__kmalloc_node);
85263 #endif
85264
85265 +bool is_usercopy_object(const void *ptr)
85266 +{
85267 + struct page *page;
85268 + struct kmem_cache *s;
85269 +
85270 + if (ZERO_OR_NULL_PTR(ptr))
85271 + return false;
85272 +
85273 + if (!slab_is_available())
85274 + return false;
85275 +
85276 + if (!virt_addr_valid(ptr))
85277 + return false;
85278 +
85279 + page = virt_to_head_page(ptr);
85280 +
85281 + if (!PageSlab(page))
85282 + return false;
85283 +
85284 + s = page->slab_cache;
85285 + return s->flags & SLAB_USERCOPY;
85286 +}
85287 +
85288 +#ifdef CONFIG_PAX_USERCOPY
85289 +const char *check_heap_object(const void *ptr, unsigned long n)
85290 +{
85291 + struct page *page;
85292 + struct kmem_cache *s;
85293 + unsigned long offset;
85294 +
85295 + if (ZERO_OR_NULL_PTR(ptr))
85296 + return "<null>";
85297 +
85298 + if (!virt_addr_valid(ptr))
85299 + return NULL;
85300 +
85301 + page = virt_to_head_page(ptr);
85302 +
85303 + if (!PageSlab(page))
85304 + return NULL;
85305 +
85306 + s = page->slab_cache;
85307 + if (!(s->flags & SLAB_USERCOPY))
85308 + return s->name;
85309 +
85310 + offset = (ptr - page_address(page)) % s->size;
85311 + if (offset <= s->object_size && n <= s->object_size - offset)
85312 + return NULL;
85313 +
85314 + return s->name;
85315 +}
85316 +#endif
85317 +
85318 size_t ksize(const void *object)
85319 {
85320 struct page *page;
85321 @@ -3347,6 +3400,7 @@ void kfree(const void *x)
85322 if (unlikely(ZERO_OR_NULL_PTR(x)))
85323 return;
85324
85325 + VM_BUG_ON(!virt_addr_valid(x));
85326 page = virt_to_head_page(x);
85327 if (unlikely(!PageSlab(page))) {
85328 BUG_ON(!PageCompound(page));
85329 @@ -3652,7 +3706,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85330 /*
85331 * We may have set a slab to be unmergeable during bootstrap.
85332 */
85333 - if (s->refcount < 0)
85334 + if (atomic_read(&s->refcount) < 0)
85335 return 1;
85336
85337 return 0;
85338 @@ -3710,7 +3764,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85339
85340 s = find_mergeable(memcg, size, align, flags, name, ctor);
85341 if (s) {
85342 - s->refcount++;
85343 + atomic_inc(&s->refcount);
85344 /*
85345 * Adjust the object sizes so that we clear
85346 * the complete object on kzalloc.
85347 @@ -3719,7 +3773,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85348 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85349
85350 if (sysfs_slab_alias(s, name)) {
85351 - s->refcount--;
85352 + atomic_dec(&s->refcount);
85353 s = NULL;
85354 }
85355 }
85356 @@ -3781,7 +3835,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85357 return NOTIFY_OK;
85358 }
85359
85360 -static struct notifier_block __cpuinitdata slab_notifier = {
85361 +static struct notifier_block slab_notifier = {
85362 .notifier_call = slab_cpuup_callback
85363 };
85364
85365 @@ -3839,7 +3893,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85366 }
85367 #endif
85368
85369 -#ifdef CONFIG_SYSFS
85370 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85371 static int count_inuse(struct page *page)
85372 {
85373 return page->inuse;
85374 @@ -4226,12 +4280,12 @@ static void resiliency_test(void)
85375 validate_slab_cache(kmalloc_caches[9]);
85376 }
85377 #else
85378 -#ifdef CONFIG_SYSFS
85379 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85380 static void resiliency_test(void) {};
85381 #endif
85382 #endif
85383
85384 -#ifdef CONFIG_SYSFS
85385 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85386 enum slab_stat_type {
85387 SL_ALL, /* All slabs */
85388 SL_PARTIAL, /* Only partially allocated slabs */
85389 @@ -4475,7 +4529,7 @@ SLAB_ATTR_RO(ctor);
85390
85391 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85392 {
85393 - return sprintf(buf, "%d\n", s->refcount - 1);
85394 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85395 }
85396 SLAB_ATTR_RO(aliases);
85397
85398 @@ -4563,6 +4617,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
85399 SLAB_ATTR_RO(cache_dma);
85400 #endif
85401
85402 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85403 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
85404 +{
85405 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
85406 +}
85407 +SLAB_ATTR_RO(usercopy);
85408 +#endif
85409 +
85410 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
85411 {
85412 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
85413 @@ -4897,6 +4959,9 @@ static struct attribute *slab_attrs[] = {
85414 #ifdef CONFIG_ZONE_DMA
85415 &cache_dma_attr.attr,
85416 #endif
85417 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85418 + &usercopy_attr.attr,
85419 +#endif
85420 #ifdef CONFIG_NUMA
85421 &remote_node_defrag_ratio_attr.attr,
85422 #endif
85423 @@ -5128,6 +5193,7 @@ static char *create_unique_id(struct kmem_cache *s)
85424 return name;
85425 }
85426
85427 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85428 static int sysfs_slab_add(struct kmem_cache *s)
85429 {
85430 int err;
85431 @@ -5151,7 +5217,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
85432 }
85433
85434 s->kobj.kset = slab_kset;
85435 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
85436 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
85437 if (err) {
85438 kobject_put(&s->kobj);
85439 return err;
85440 @@ -5185,6 +5251,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85441 kobject_del(&s->kobj);
85442 kobject_put(&s->kobj);
85443 }
85444 +#endif
85445
85446 /*
85447 * Need to buffer aliases during bootup until sysfs becomes
85448 @@ -5198,6 +5265,7 @@ struct saved_alias {
85449
85450 static struct saved_alias *alias_list;
85451
85452 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85453 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85454 {
85455 struct saved_alias *al;
85456 @@ -5220,6 +5288,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85457 alias_list = al;
85458 return 0;
85459 }
85460 +#endif
85461
85462 static int __init slab_sysfs_init(void)
85463 {
85464 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85465 index 27eeab3..7c3f7f2 100644
85466 --- a/mm/sparse-vmemmap.c
85467 +++ b/mm/sparse-vmemmap.c
85468 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85469 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85470 if (!p)
85471 return NULL;
85472 - pud_populate(&init_mm, pud, p);
85473 + pud_populate_kernel(&init_mm, pud, p);
85474 }
85475 return pud;
85476 }
85477 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85478 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85479 if (!p)
85480 return NULL;
85481 - pgd_populate(&init_mm, pgd, p);
85482 + pgd_populate_kernel(&init_mm, pgd, p);
85483 }
85484 return pgd;
85485 }
85486 diff --git a/mm/sparse.c b/mm/sparse.c
85487 index 1c91f0d3..485470a 100644
85488 --- a/mm/sparse.c
85489 +++ b/mm/sparse.c
85490 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85491
85492 for (i = 0; i < PAGES_PER_SECTION; i++) {
85493 if (PageHWPoison(&memmap[i])) {
85494 - atomic_long_sub(1, &num_poisoned_pages);
85495 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
85496 ClearPageHWPoison(&memmap[i]);
85497 }
85498 }
85499 diff --git a/mm/swap.c b/mm/swap.c
85500 index dfd7d71..ccdf688 100644
85501 --- a/mm/swap.c
85502 +++ b/mm/swap.c
85503 @@ -31,6 +31,7 @@
85504 #include <linux/memcontrol.h>
85505 #include <linux/gfp.h>
85506 #include <linux/uio.h>
85507 +#include <linux/hugetlb.h>
85508
85509 #include "internal.h"
85510
85511 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
85512
85513 __page_cache_release(page);
85514 dtor = get_compound_page_dtor(page);
85515 + if (!PageHuge(page))
85516 + BUG_ON(dtor != free_compound_page);
85517 (*dtor)(page);
85518 }
85519
85520 diff --git a/mm/swapfile.c b/mm/swapfile.c
85521 index 746af55b..7ac94ae 100644
85522 --- a/mm/swapfile.c
85523 +++ b/mm/swapfile.c
85524 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
85525
85526 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85527 /* Activity counter to indicate that a swapon or swapoff has occurred */
85528 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85529 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85530
85531 static inline unsigned char swap_count(unsigned char ent)
85532 {
85533 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85534 }
85535 filp_close(swap_file, NULL);
85536 err = 0;
85537 - atomic_inc(&proc_poll_event);
85538 + atomic_inc_unchecked(&proc_poll_event);
85539 wake_up_interruptible(&proc_poll_wait);
85540
85541 out_dput:
85542 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85543
85544 poll_wait(file, &proc_poll_wait, wait);
85545
85546 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85547 - seq->poll_event = atomic_read(&proc_poll_event);
85548 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85549 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85550 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85551 }
85552
85553 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85554 return ret;
85555
85556 seq = file->private_data;
85557 - seq->poll_event = atomic_read(&proc_poll_event);
85558 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85559 return 0;
85560 }
85561
85562 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85563 (frontswap_map) ? "FS" : "");
85564
85565 mutex_unlock(&swapon_mutex);
85566 - atomic_inc(&proc_poll_event);
85567 + atomic_inc_unchecked(&proc_poll_event);
85568 wake_up_interruptible(&proc_poll_wait);
85569
85570 if (S_ISREG(inode->i_mode))
85571 diff --git a/mm/util.c b/mm/util.c
85572 index ab1424d..7c5bd5a 100644
85573 --- a/mm/util.c
85574 +++ b/mm/util.c
85575 @@ -294,6 +294,12 @@ done:
85576 void arch_pick_mmap_layout(struct mm_struct *mm)
85577 {
85578 mm->mmap_base = TASK_UNMAPPED_BASE;
85579 +
85580 +#ifdef CONFIG_PAX_RANDMMAP
85581 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85582 + mm->mmap_base += mm->delta_mmap;
85583 +#endif
85584 +
85585 mm->get_unmapped_area = arch_get_unmapped_area;
85586 mm->unmap_area = arch_unmap_area;
85587 }
85588 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85589 index d365724..6cae7c2 100644
85590 --- a/mm/vmalloc.c
85591 +++ b/mm/vmalloc.c
85592 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85593
85594 pte = pte_offset_kernel(pmd, addr);
85595 do {
85596 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85597 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85598 +
85599 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85600 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85601 + BUG_ON(!pte_exec(*pte));
85602 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85603 + continue;
85604 + }
85605 +#endif
85606 +
85607 + {
85608 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85609 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85610 + }
85611 } while (pte++, addr += PAGE_SIZE, addr != end);
85612 }
85613
85614 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85615 pte = pte_alloc_kernel(pmd, addr);
85616 if (!pte)
85617 return -ENOMEM;
85618 +
85619 + pax_open_kernel();
85620 do {
85621 struct page *page = pages[*nr];
85622
85623 - if (WARN_ON(!pte_none(*pte)))
85624 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85625 + if (pgprot_val(prot) & _PAGE_NX)
85626 +#endif
85627 +
85628 + if (!pte_none(*pte)) {
85629 + pax_close_kernel();
85630 + WARN_ON(1);
85631 return -EBUSY;
85632 - if (WARN_ON(!page))
85633 + }
85634 + if (!page) {
85635 + pax_close_kernel();
85636 + WARN_ON(1);
85637 return -ENOMEM;
85638 + }
85639 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85640 (*nr)++;
85641 } while (pte++, addr += PAGE_SIZE, addr != end);
85642 + pax_close_kernel();
85643 return 0;
85644 }
85645
85646 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85647 pmd_t *pmd;
85648 unsigned long next;
85649
85650 - pmd = pmd_alloc(&init_mm, pud, addr);
85651 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85652 if (!pmd)
85653 return -ENOMEM;
85654 do {
85655 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85656 pud_t *pud;
85657 unsigned long next;
85658
85659 - pud = pud_alloc(&init_mm, pgd, addr);
85660 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85661 if (!pud)
85662 return -ENOMEM;
85663 do {
85664 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
85665 if (addr >= MODULES_VADDR && addr < MODULES_END)
85666 return 1;
85667 #endif
85668 +
85669 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85670 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85671 + return 1;
85672 +#endif
85673 +
85674 return is_vmalloc_addr(x);
85675 }
85676
85677 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85678
85679 if (!pgd_none(*pgd)) {
85680 pud_t *pud = pud_offset(pgd, addr);
85681 +#ifdef CONFIG_X86
85682 + if (!pud_large(*pud))
85683 +#endif
85684 if (!pud_none(*pud)) {
85685 pmd_t *pmd = pmd_offset(pud, addr);
85686 +#ifdef CONFIG_X86
85687 + if (!pmd_large(*pmd))
85688 +#endif
85689 if (!pmd_none(*pmd)) {
85690 pte_t *ptep, pte;
85691
85692 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
85693 * Allocate a region of KVA of the specified size and alignment, within the
85694 * vstart and vend.
85695 */
85696 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85697 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85698 unsigned long align,
85699 unsigned long vstart, unsigned long vend,
85700 int node, gfp_t gfp_mask)
85701 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85702 struct vm_struct *area;
85703
85704 BUG_ON(in_interrupt());
85705 +
85706 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85707 + if (flags & VM_KERNEXEC) {
85708 + if (start != VMALLOC_START || end != VMALLOC_END)
85709 + return NULL;
85710 + start = (unsigned long)MODULES_EXEC_VADDR;
85711 + end = (unsigned long)MODULES_EXEC_END;
85712 + }
85713 +#endif
85714 +
85715 if (flags & VM_IOREMAP) {
85716 int bit = fls(size);
85717
85718 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
85719 if (count > totalram_pages)
85720 return NULL;
85721
85722 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85723 + if (!(pgprot_val(prot) & _PAGE_NX))
85724 + flags |= VM_KERNEXEC;
85725 +#endif
85726 +
85727 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85728 __builtin_return_address(0));
85729 if (!area)
85730 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85731 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85732 goto fail;
85733
85734 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85735 + if (!(pgprot_val(prot) & _PAGE_NX))
85736 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85737 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85738 + else
85739 +#endif
85740 +
85741 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85742 start, end, node, gfp_mask, caller);
85743 if (!area)
85744 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
85745 * For tight control over page level allocator and protection flags
85746 * use __vmalloc() instead.
85747 */
85748 -
85749 void *vmalloc_exec(unsigned long size)
85750 {
85751 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85752 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85753 NUMA_NO_NODE, __builtin_return_address(0));
85754 }
85755
85756 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85757 unsigned long uaddr = vma->vm_start;
85758 unsigned long usize = vma->vm_end - vma->vm_start;
85759
85760 + BUG_ON(vma->vm_mirror);
85761 +
85762 if ((PAGE_SIZE-1) & (unsigned long)addr)
85763 return -EINVAL;
85764
85765 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
85766 v->addr, v->addr + v->size, v->size);
85767
85768 if (v->caller)
85769 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85770 + seq_printf(m, " %pK", v->caller);
85771 +#else
85772 seq_printf(m, " %pS", v->caller);
85773 +#endif
85774
85775 if (v->nr_pages)
85776 seq_printf(m, " pages=%d", v->nr_pages);
85777 diff --git a/mm/vmstat.c b/mm/vmstat.c
85778 index f42745e..62f8346 100644
85779 --- a/mm/vmstat.c
85780 +++ b/mm/vmstat.c
85781 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
85782 *
85783 * vm_stat contains the global counters
85784 */
85785 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85786 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85787 EXPORT_SYMBOL(vm_stat);
85788
85789 #ifdef CONFIG_SMP
85790 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
85791 v = p->vm_stat_diff[i];
85792 p->vm_stat_diff[i] = 0;
85793 local_irq_restore(flags);
85794 - atomic_long_add(v, &zone->vm_stat[i]);
85795 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85796 global_diff[i] += v;
85797 #ifdef CONFIG_NUMA
85798 /* 3 seconds idle till flush */
85799 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
85800
85801 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85802 if (global_diff[i])
85803 - atomic_long_add(global_diff[i], &vm_stat[i]);
85804 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85805 }
85806
85807 /*
85808 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85809 if (pset->vm_stat_diff[i]) {
85810 int v = pset->vm_stat_diff[i];
85811 pset->vm_stat_diff[i] = 0;
85812 - atomic_long_add(v, &zone->vm_stat[i]);
85813 - atomic_long_add(v, &vm_stat[i]);
85814 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85815 + atomic_long_add_unchecked(v, &vm_stat[i]);
85816 }
85817 }
85818 #endif
85819 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85820 return NOTIFY_OK;
85821 }
85822
85823 -static struct notifier_block __cpuinitdata vmstat_notifier =
85824 +static struct notifier_block vmstat_notifier =
85825 { &vmstat_cpuup_callback, NULL, 0 };
85826 #endif
85827
85828 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
85829 start_cpu_timer(cpu);
85830 #endif
85831 #ifdef CONFIG_PROC_FS
85832 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85833 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85834 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85835 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85836 + {
85837 + mode_t gr_mode = S_IRUGO;
85838 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85839 + gr_mode = S_IRUSR;
85840 +#endif
85841 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85842 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85843 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85844 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85845 +#else
85846 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85847 +#endif
85848 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85849 + }
85850 #endif
85851 return 0;
85852 }
85853 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85854 index 9424f37..6aabf19 100644
85855 --- a/net/8021q/vlan.c
85856 +++ b/net/8021q/vlan.c
85857 @@ -469,7 +469,7 @@ out:
85858 return NOTIFY_DONE;
85859 }
85860
85861 -static struct notifier_block vlan_notifier_block __read_mostly = {
85862 +static struct notifier_block vlan_notifier_block = {
85863 .notifier_call = vlan_device_event,
85864 };
85865
85866 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85867 err = -EPERM;
85868 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85869 break;
85870 - if ((args.u.name_type >= 0) &&
85871 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85872 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85873 struct vlan_net *vn;
85874
85875 vn = net_generic(net, vlan_net_id);
85876 diff --git a/net/9p/mod.c b/net/9p/mod.c
85877 index 6ab36ae..6f1841b 100644
85878 --- a/net/9p/mod.c
85879 +++ b/net/9p/mod.c
85880 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85881 void v9fs_register_trans(struct p9_trans_module *m)
85882 {
85883 spin_lock(&v9fs_trans_lock);
85884 - list_add_tail(&m->list, &v9fs_trans_list);
85885 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85886 spin_unlock(&v9fs_trans_lock);
85887 }
85888 EXPORT_SYMBOL(v9fs_register_trans);
85889 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85890 void v9fs_unregister_trans(struct p9_trans_module *m)
85891 {
85892 spin_lock(&v9fs_trans_lock);
85893 - list_del_init(&m->list);
85894 + pax_list_del_init((struct list_head *)&m->list);
85895 spin_unlock(&v9fs_trans_lock);
85896 }
85897 EXPORT_SYMBOL(v9fs_unregister_trans);
85898 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85899 index 02efb25..41541a9 100644
85900 --- a/net/9p/trans_fd.c
85901 +++ b/net/9p/trans_fd.c
85902 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85903 oldfs = get_fs();
85904 set_fs(get_ds());
85905 /* The cast to a user pointer is valid due to the set_fs() */
85906 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85907 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85908 set_fs(oldfs);
85909
85910 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85911 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85912 index 876fbe8..8bbea9f 100644
85913 --- a/net/atm/atm_misc.c
85914 +++ b/net/atm/atm_misc.c
85915 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85916 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85917 return 1;
85918 atm_return(vcc, truesize);
85919 - atomic_inc(&vcc->stats->rx_drop);
85920 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85921 return 0;
85922 }
85923 EXPORT_SYMBOL(atm_charge);
85924 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85925 }
85926 }
85927 atm_return(vcc, guess);
85928 - atomic_inc(&vcc->stats->rx_drop);
85929 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85930 return NULL;
85931 }
85932 EXPORT_SYMBOL(atm_alloc_charge);
85933 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85934
85935 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85936 {
85937 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85938 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85939 __SONET_ITEMS
85940 #undef __HANDLE_ITEM
85941 }
85942 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85943
85944 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85945 {
85946 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85947 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85948 __SONET_ITEMS
85949 #undef __HANDLE_ITEM
85950 }
85951 diff --git a/net/atm/lec.h b/net/atm/lec.h
85952 index 4149db1..f2ab682 100644
85953 --- a/net/atm/lec.h
85954 +++ b/net/atm/lec.h
85955 @@ -48,7 +48,7 @@ struct lane2_ops {
85956 const u8 *tlvs, u32 sizeoftlvs);
85957 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85958 const u8 *tlvs, u32 sizeoftlvs);
85959 -};
85960 +} __no_const;
85961
85962 /*
85963 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85964 diff --git a/net/atm/proc.c b/net/atm/proc.c
85965 index bbb6461..cf04016 100644
85966 --- a/net/atm/proc.c
85967 +++ b/net/atm/proc.c
85968 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85969 const struct k_atm_aal_stats *stats)
85970 {
85971 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85972 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85973 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85974 - atomic_read(&stats->rx_drop));
85975 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85976 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85977 + atomic_read_unchecked(&stats->rx_drop));
85978 }
85979
85980 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85981 diff --git a/net/atm/resources.c b/net/atm/resources.c
85982 index 0447d5d..3cf4728 100644
85983 --- a/net/atm/resources.c
85984 +++ b/net/atm/resources.c
85985 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85986 static void copy_aal_stats(struct k_atm_aal_stats *from,
85987 struct atm_aal_stats *to)
85988 {
85989 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85990 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85991 __AAL_STAT_ITEMS
85992 #undef __HANDLE_ITEM
85993 }
85994 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85995 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85996 struct atm_aal_stats *to)
85997 {
85998 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85999 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
86000 __AAL_STAT_ITEMS
86001 #undef __HANDLE_ITEM
86002 }
86003 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
86004 index d5744b7..506bae3 100644
86005 --- a/net/ax25/sysctl_net_ax25.c
86006 +++ b/net/ax25/sysctl_net_ax25.c
86007 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
86008 {
86009 char path[sizeof("net/ax25/") + IFNAMSIZ];
86010 int k;
86011 - struct ctl_table *table;
86012 + ctl_table_no_const *table;
86013
86014 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
86015 if (!table)
86016 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
86017 index f680ee1..97e3542 100644
86018 --- a/net/batman-adv/bat_iv_ogm.c
86019 +++ b/net/batman-adv/bat_iv_ogm.c
86020 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
86021
86022 /* randomize initial seqno to avoid collision */
86023 get_random_bytes(&random_seqno, sizeof(random_seqno));
86024 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86025 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86026
86027 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
86028 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
86029 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
86030 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
86031
86032 /* change sequence number to network order */
86033 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
86034 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
86035 batadv_ogm_packet->seqno = htonl(seqno);
86036 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
86037 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
86038
86039 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
86040 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
86041 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
86042 return;
86043
86044 /* could be changed by schedule_own_packet() */
86045 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
86046 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
86047
86048 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
86049 has_directlink_flag = 1;
86050 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
86051 index 522243a..b48c0ef 100644
86052 --- a/net/batman-adv/hard-interface.c
86053 +++ b/net/batman-adv/hard-interface.c
86054 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
86055 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
86056 dev_add_pack(&hard_iface->batman_adv_ptype);
86057
86058 - atomic_set(&hard_iface->frag_seqno, 1);
86059 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
86060 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
86061 hard_iface->net_dev->name);
86062
86063 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
86064 /* This can't be called via a bat_priv callback because
86065 * we have no bat_priv yet.
86066 */
86067 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
86068 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
86069 hard_iface->bat_iv.ogm_buff = NULL;
86070
86071 return hard_iface;
86072 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
86073 index 819dfb0..9a672d1 100644
86074 --- a/net/batman-adv/soft-interface.c
86075 +++ b/net/batman-adv/soft-interface.c
86076 @@ -253,7 +253,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
86077 primary_if->net_dev->dev_addr, ETH_ALEN);
86078
86079 /* set broadcast sequence number */
86080 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
86081 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
86082 bcast_packet->seqno = htonl(seqno);
86083
86084 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
86085 @@ -472,7 +472,7 @@ static int batadv_softif_init_late(struct net_device *dev)
86086 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
86087
86088 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
86089 - atomic_set(&bat_priv->bcast_seqno, 1);
86090 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
86091 atomic_set(&bat_priv->tt.vn, 0);
86092 atomic_set(&bat_priv->tt.local_changes, 0);
86093 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
86094 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
86095 index aba8364..50fcbb8 100644
86096 --- a/net/batman-adv/types.h
86097 +++ b/net/batman-adv/types.h
86098 @@ -51,7 +51,7 @@
86099 struct batadv_hard_iface_bat_iv {
86100 unsigned char *ogm_buff;
86101 int ogm_buff_len;
86102 - atomic_t ogm_seqno;
86103 + atomic_unchecked_t ogm_seqno;
86104 };
86105
86106 /**
86107 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
86108 int16_t if_num;
86109 char if_status;
86110 struct net_device *net_dev;
86111 - atomic_t frag_seqno;
86112 + atomic_unchecked_t frag_seqno;
86113 struct kobject *hardif_obj;
86114 atomic_t refcount;
86115 struct packet_type batman_adv_ptype;
86116 @@ -558,7 +558,7 @@ struct batadv_priv {
86117 #ifdef CONFIG_BATMAN_ADV_DEBUG
86118 atomic_t log_level;
86119 #endif
86120 - atomic_t bcast_seqno;
86121 + atomic_unchecked_t bcast_seqno;
86122 atomic_t bcast_queue_left;
86123 atomic_t batman_queue_left;
86124 char num_ifaces;
86125 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
86126 index 0bb3b59..ffcbf2f 100644
86127 --- a/net/batman-adv/unicast.c
86128 +++ b/net/batman-adv/unicast.c
86129 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
86130 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
86131 frag2->flags = large_tail;
86132
86133 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
86134 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
86135 frag1->seqno = htons(seqno - 1);
86136 frag2->seqno = htons(seqno);
86137
86138 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
86139 index ace5e55..a65a1c0 100644
86140 --- a/net/bluetooth/hci_core.c
86141 +++ b/net/bluetooth/hci_core.c
86142 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
86143 list_add(&hdev->list, &hci_dev_list);
86144 write_unlock(&hci_dev_list_lock);
86145
86146 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
86147 - WQ_MEM_RECLAIM, 1);
86148 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
86149 + WQ_MEM_RECLAIM, 1, hdev->name);
86150 if (!hdev->workqueue) {
86151 error = -ENOMEM;
86152 goto err;
86153 }
86154
86155 - hdev->req_workqueue = alloc_workqueue(hdev->name,
86156 + hdev->req_workqueue = alloc_workqueue("%s",
86157 WQ_HIGHPRI | WQ_UNBOUND |
86158 - WQ_MEM_RECLAIM, 1);
86159 + WQ_MEM_RECLAIM, 1, hdev->name);
86160 if (!hdev->req_workqueue) {
86161 destroy_workqueue(hdev->workqueue);
86162 error = -ENOMEM;
86163 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
86164 index 9bd7d95..6c4884f 100644
86165 --- a/net/bluetooth/hci_sock.c
86166 +++ b/net/bluetooth/hci_sock.c
86167 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
86168 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
86169 }
86170
86171 - len = min_t(unsigned int, len, sizeof(uf));
86172 + len = min((size_t)len, sizeof(uf));
86173 if (copy_from_user(&uf, optval, len)) {
86174 err = -EFAULT;
86175 break;
86176 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
86177 index 68843a2..30e9342 100644
86178 --- a/net/bluetooth/l2cap_core.c
86179 +++ b/net/bluetooth/l2cap_core.c
86180 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
86181 break;
86182
86183 case L2CAP_CONF_RFC:
86184 - if (olen == sizeof(rfc))
86185 - memcpy(&rfc, (void *)val, olen);
86186 + if (olen != sizeof(rfc))
86187 + break;
86188 +
86189 + memcpy(&rfc, (void *)val, olen);
86190
86191 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
86192 rfc.mode != chan->mode)
86193 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
86194 index 36fed40..be2eeb2 100644
86195 --- a/net/bluetooth/l2cap_sock.c
86196 +++ b/net/bluetooth/l2cap_sock.c
86197 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86198 struct sock *sk = sock->sk;
86199 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
86200 struct l2cap_options opts;
86201 - int len, err = 0;
86202 + int err = 0;
86203 + size_t len = optlen;
86204 u32 opt;
86205
86206 BT_DBG("sk %p", sk);
86207 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86208 opts.max_tx = chan->max_tx;
86209 opts.txwin_size = chan->tx_win;
86210
86211 - len = min_t(unsigned int, sizeof(opts), optlen);
86212 + len = min(sizeof(opts), len);
86213 if (copy_from_user((char *) &opts, optval, len)) {
86214 err = -EFAULT;
86215 break;
86216 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86217 struct bt_security sec;
86218 struct bt_power pwr;
86219 struct l2cap_conn *conn;
86220 - int len, err = 0;
86221 + int err = 0;
86222 + size_t len = optlen;
86223 u32 opt;
86224
86225 BT_DBG("sk %p", sk);
86226 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86227
86228 sec.level = BT_SECURITY_LOW;
86229
86230 - len = min_t(unsigned int, sizeof(sec), optlen);
86231 + len = min(sizeof(sec), len);
86232 if (copy_from_user((char *) &sec, optval, len)) {
86233 err = -EFAULT;
86234 break;
86235 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86236
86237 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
86238
86239 - len = min_t(unsigned int, sizeof(pwr), optlen);
86240 + len = min(sizeof(pwr), len);
86241 if (copy_from_user((char *) &pwr, optval, len)) {
86242 err = -EFAULT;
86243 break;
86244 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
86245 index 30b3721..c1bd0a0 100644
86246 --- a/net/bluetooth/rfcomm/sock.c
86247 +++ b/net/bluetooth/rfcomm/sock.c
86248 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86249 struct sock *sk = sock->sk;
86250 struct bt_security sec;
86251 int err = 0;
86252 - size_t len;
86253 + size_t len = optlen;
86254 u32 opt;
86255
86256 BT_DBG("sk %p", sk);
86257 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86258
86259 sec.level = BT_SECURITY_LOW;
86260
86261 - len = min_t(unsigned int, sizeof(sec), optlen);
86262 + len = min(sizeof(sec), len);
86263 if (copy_from_user((char *) &sec, optval, len)) {
86264 err = -EFAULT;
86265 break;
86266 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
86267 index b6e44ad..5b0d514 100644
86268 --- a/net/bluetooth/rfcomm/tty.c
86269 +++ b/net/bluetooth/rfcomm/tty.c
86270 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
86271 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
86272
86273 spin_lock_irqsave(&dev->port.lock, flags);
86274 - if (dev->port.count > 0) {
86275 + if (atomic_read(&dev->port.count) > 0) {
86276 spin_unlock_irqrestore(&dev->port.lock, flags);
86277 return;
86278 }
86279 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
86280 return -ENODEV;
86281
86282 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
86283 - dev->channel, dev->port.count);
86284 + dev->channel, atomic_read(&dev->port.count));
86285
86286 spin_lock_irqsave(&dev->port.lock, flags);
86287 - if (++dev->port.count > 1) {
86288 + if (atomic_inc_return(&dev->port.count) > 1) {
86289 spin_unlock_irqrestore(&dev->port.lock, flags);
86290 return 0;
86291 }
86292 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
86293 return;
86294
86295 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
86296 - dev->port.count);
86297 + atomic_read(&dev->port.count));
86298
86299 spin_lock_irqsave(&dev->port.lock, flags);
86300 - if (!--dev->port.count) {
86301 + if (!atomic_dec_return(&dev->port.count)) {
86302 spin_unlock_irqrestore(&dev->port.lock, flags);
86303 if (dev->tty_dev->parent)
86304 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86305 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86306 index 3d110c4..4e1b2eb 100644
86307 --- a/net/bridge/netfilter/ebtables.c
86308 +++ b/net/bridge/netfilter/ebtables.c
86309 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86310 tmp.valid_hooks = t->table->valid_hooks;
86311 }
86312 mutex_unlock(&ebt_mutex);
86313 - if (copy_to_user(user, &tmp, *len) != 0){
86314 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86315 BUGPRINT("c2u Didn't work\n");
86316 ret = -EFAULT;
86317 break;
86318 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86319 goto out;
86320 tmp.valid_hooks = t->valid_hooks;
86321
86322 - if (copy_to_user(user, &tmp, *len) != 0) {
86323 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86324 ret = -EFAULT;
86325 break;
86326 }
86327 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86328 tmp.entries_size = t->table->entries_size;
86329 tmp.valid_hooks = t->table->valid_hooks;
86330
86331 - if (copy_to_user(user, &tmp, *len) != 0) {
86332 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86333 ret = -EFAULT;
86334 break;
86335 }
86336 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86337 index 2bd4b58..0dc30a1 100644
86338 --- a/net/caif/cfctrl.c
86339 +++ b/net/caif/cfctrl.c
86340 @@ -10,6 +10,7 @@
86341 #include <linux/spinlock.h>
86342 #include <linux/slab.h>
86343 #include <linux/pkt_sched.h>
86344 +#include <linux/sched.h>
86345 #include <net/caif/caif_layer.h>
86346 #include <net/caif/cfpkt.h>
86347 #include <net/caif/cfctrl.h>
86348 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86349 memset(&dev_info, 0, sizeof(dev_info));
86350 dev_info.id = 0xff;
86351 cfsrvl_init(&this->serv, 0, &dev_info, false);
86352 - atomic_set(&this->req_seq_no, 1);
86353 - atomic_set(&this->rsp_seq_no, 1);
86354 + atomic_set_unchecked(&this->req_seq_no, 1);
86355 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86356 this->serv.layer.receive = cfctrl_recv;
86357 sprintf(this->serv.layer.name, "ctrl");
86358 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86359 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86360 struct cfctrl_request_info *req)
86361 {
86362 spin_lock_bh(&ctrl->info_list_lock);
86363 - atomic_inc(&ctrl->req_seq_no);
86364 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86365 + atomic_inc_unchecked(&ctrl->req_seq_no);
86366 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86367 list_add_tail(&req->list, &ctrl->list);
86368 spin_unlock_bh(&ctrl->info_list_lock);
86369 }
86370 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86371 if (p != first)
86372 pr_warn("Requests are not received in order\n");
86373
86374 - atomic_set(&ctrl->rsp_seq_no,
86375 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86376 p->sequence_no);
86377 list_del(&p->list);
86378 goto out;
86379 diff --git a/net/can/af_can.c b/net/can/af_can.c
86380 index c4e5085..aa9efdf 100644
86381 --- a/net/can/af_can.c
86382 +++ b/net/can/af_can.c
86383 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
86384 };
86385
86386 /* notifier block for netdevice event */
86387 -static struct notifier_block can_netdev_notifier __read_mostly = {
86388 +static struct notifier_block can_netdev_notifier = {
86389 .notifier_call = can_notifier,
86390 };
86391
86392 diff --git a/net/can/gw.c b/net/can/gw.c
86393 index 3ee690e..00d581b 100644
86394 --- a/net/can/gw.c
86395 +++ b/net/can/gw.c
86396 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
86397 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
86398
86399 static HLIST_HEAD(cgw_list);
86400 -static struct notifier_block notifier;
86401
86402 static struct kmem_cache *cgw_cache __read_mostly;
86403
86404 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
86405 return err;
86406 }
86407
86408 +static struct notifier_block notifier = {
86409 + .notifier_call = cgw_notifier
86410 +};
86411 +
86412 static __init int cgw_module_init(void)
86413 {
86414 /* sanitize given module parameter */
86415 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
86416 return -ENOMEM;
86417
86418 /* set notifier */
86419 - notifier.notifier_call = cgw_notifier;
86420 register_netdevice_notifier(&notifier);
86421
86422 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86423 diff --git a/net/ceph/auth_none.c b/net/ceph/auth_none.c
86424 index 925ca58..8c93fa8 100644
86425 --- a/net/ceph/auth_none.c
86426 +++ b/net/ceph/auth_none.c
86427 @@ -39,6 +39,11 @@ static int should_authenticate(struct ceph_auth_client *ac)
86428 return xi->starting;
86429 }
86430
86431 +static int build_request(struct ceph_auth_client *ac, void *buf, void *end)
86432 +{
86433 + return 0;
86434 +}
86435 +
86436 /*
86437 * the generic auth code decode the global_id, and we carry no actual
86438 * authenticate state, so nothing happens here.
86439 @@ -106,6 +111,7 @@ static const struct ceph_auth_client_ops ceph_auth_none_ops = {
86440 .destroy = destroy,
86441 .is_authenticated = is_authenticated,
86442 .should_authenticate = should_authenticate,
86443 + .build_request = build_request,
86444 .handle_reply = handle_reply,
86445 .create_authorizer = ceph_auth_none_create_authorizer,
86446 .destroy_authorizer = ceph_auth_none_destroy_authorizer,
86447 diff --git a/net/compat.c b/net/compat.c
86448 index f0a1ba6..0541331 100644
86449 --- a/net/compat.c
86450 +++ b/net/compat.c
86451 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86452 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86453 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86454 return -EFAULT;
86455 - kmsg->msg_name = compat_ptr(tmp1);
86456 - kmsg->msg_iov = compat_ptr(tmp2);
86457 - kmsg->msg_control = compat_ptr(tmp3);
86458 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86459 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86460 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86461 return 0;
86462 }
86463
86464 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86465
86466 if (kern_msg->msg_namelen) {
86467 if (mode == VERIFY_READ) {
86468 - int err = move_addr_to_kernel(kern_msg->msg_name,
86469 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86470 kern_msg->msg_namelen,
86471 kern_address);
86472 if (err < 0)
86473 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86474 kern_msg->msg_name = NULL;
86475
86476 tot_len = iov_from_user_compat_to_kern(kern_iov,
86477 - (struct compat_iovec __user *)kern_msg->msg_iov,
86478 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86479 kern_msg->msg_iovlen);
86480 if (tot_len >= 0)
86481 kern_msg->msg_iov = kern_iov;
86482 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86483
86484 #define CMSG_COMPAT_FIRSTHDR(msg) \
86485 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86486 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86487 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86488 (struct compat_cmsghdr __user *)NULL)
86489
86490 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86491 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86492 (ucmlen) <= (unsigned long) \
86493 ((mhdr)->msg_controllen - \
86494 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86495 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86496
86497 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86498 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86499 {
86500 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86501 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86502 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86503 msg->msg_controllen)
86504 return NULL;
86505 return (struct compat_cmsghdr __user *)ptr;
86506 @@ -219,7 +219,7 @@ Efault:
86507
86508 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86509 {
86510 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86511 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86512 struct compat_cmsghdr cmhdr;
86513 struct compat_timeval ctv;
86514 struct compat_timespec cts[3];
86515 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86516
86517 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86518 {
86519 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86520 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86521 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86522 int fdnum = scm->fp->count;
86523 struct file **fp = scm->fp->fp;
86524 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86525 return -EFAULT;
86526 old_fs = get_fs();
86527 set_fs(KERNEL_DS);
86528 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86529 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86530 set_fs(old_fs);
86531
86532 return err;
86533 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86534 len = sizeof(ktime);
86535 old_fs = get_fs();
86536 set_fs(KERNEL_DS);
86537 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86538 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86539 set_fs(old_fs);
86540
86541 if (!err) {
86542 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86543 case MCAST_JOIN_GROUP:
86544 case MCAST_LEAVE_GROUP:
86545 {
86546 - struct compat_group_req __user *gr32 = (void *)optval;
86547 + struct compat_group_req __user *gr32 = (void __user *)optval;
86548 struct group_req __user *kgr =
86549 compat_alloc_user_space(sizeof(struct group_req));
86550 u32 interface;
86551 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86552 case MCAST_BLOCK_SOURCE:
86553 case MCAST_UNBLOCK_SOURCE:
86554 {
86555 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86556 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86557 struct group_source_req __user *kgsr = compat_alloc_user_space(
86558 sizeof(struct group_source_req));
86559 u32 interface;
86560 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86561 }
86562 case MCAST_MSFILTER:
86563 {
86564 - struct compat_group_filter __user *gf32 = (void *)optval;
86565 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86566 struct group_filter __user *kgf;
86567 u32 interface, fmode, numsrc;
86568
86569 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86570 char __user *optval, int __user *optlen,
86571 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86572 {
86573 - struct compat_group_filter __user *gf32 = (void *)optval;
86574 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86575 struct group_filter __user *kgf;
86576 int __user *koptlen;
86577 u32 interface, fmode, numsrc;
86578 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86579
86580 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86581 return -EINVAL;
86582 - if (copy_from_user(a, args, nas[call]))
86583 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86584 return -EFAULT;
86585 a0 = a[0];
86586 a1 = a[1];
86587 diff --git a/net/core/datagram.c b/net/core/datagram.c
86588 index b71423d..0360434 100644
86589 --- a/net/core/datagram.c
86590 +++ b/net/core/datagram.c
86591 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86592 }
86593
86594 kfree_skb(skb);
86595 - atomic_inc(&sk->sk_drops);
86596 + atomic_inc_unchecked(&sk->sk_drops);
86597 sk_mem_reclaim_partial(sk);
86598
86599 return err;
86600 diff --git a/net/core/dev.c b/net/core/dev.c
86601 index faebb39..a38fb42 100644
86602 --- a/net/core/dev.c
86603 +++ b/net/core/dev.c
86604 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86605 {
86606 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86607 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86608 - atomic_long_inc(&dev->rx_dropped);
86609 + atomic_long_inc_unchecked(&dev->rx_dropped);
86610 kfree_skb(skb);
86611 return NET_RX_DROP;
86612 }
86613 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86614 skb_orphan(skb);
86615
86616 if (unlikely(!is_skb_forwardable(dev, skb))) {
86617 - atomic_long_inc(&dev->rx_dropped);
86618 + atomic_long_inc_unchecked(&dev->rx_dropped);
86619 kfree_skb(skb);
86620 return NET_RX_DROP;
86621 }
86622 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86623
86624 struct dev_gso_cb {
86625 void (*destructor)(struct sk_buff *skb);
86626 -};
86627 +} __no_const;
86628
86629 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86630
86631 @@ -3139,7 +3139,7 @@ enqueue:
86632
86633 local_irq_restore(flags);
86634
86635 - atomic_long_inc(&skb->dev->rx_dropped);
86636 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86637 kfree_skb(skb);
86638 return NET_RX_DROP;
86639 }
86640 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
86641 }
86642 EXPORT_SYMBOL(netif_rx_ni);
86643
86644 -static void net_tx_action(struct softirq_action *h)
86645 +static void net_tx_action(void)
86646 {
86647 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86648
86649 @@ -3538,7 +3538,7 @@ ncls:
86650 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86651 } else {
86652 drop:
86653 - atomic_long_inc(&skb->dev->rx_dropped);
86654 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86655 kfree_skb(skb);
86656 /* Jamal, now you will not able to escape explaining
86657 * me how you were going to use this. :-)
86658 @@ -4146,7 +4146,7 @@ void netif_napi_del(struct napi_struct *napi)
86659 }
86660 EXPORT_SYMBOL(netif_napi_del);
86661
86662 -static void net_rx_action(struct softirq_action *h)
86663 +static void net_rx_action(void)
86664 {
86665 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86666 unsigned long time_limit = jiffies + 2;
86667 @@ -5583,7 +5583,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86668 } else {
86669 netdev_stats_to_stats64(storage, &dev->stats);
86670 }
86671 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86672 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86673 return storage;
86674 }
86675 EXPORT_SYMBOL(dev_get_stats);
86676 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86677 index 5b7d0e1..cb960fc 100644
86678 --- a/net/core/dev_ioctl.c
86679 +++ b/net/core/dev_ioctl.c
86680 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
86681 if (no_module && capable(CAP_NET_ADMIN))
86682 no_module = request_module("netdev-%s", name);
86683 if (no_module && capable(CAP_SYS_MODULE)) {
86684 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86685 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86686 +#else
86687 if (!request_module("%s", name))
86688 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86689 name);
86690 +#endif
86691 }
86692 }
86693 EXPORT_SYMBOL(dev_load);
86694 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
86695 index ce91766..3b71cdb 100644
86696 --- a/net/core/ethtool.c
86697 +++ b/net/core/ethtool.c
86698 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
86699 if (ret)
86700 return ret;
86701
86702 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
86703 + len = min(tmp.len, dump.len);
86704 if (!len)
86705 return -EFAULT;
86706
86707 + /* Don't ever let the driver think there's more space available
86708 + * than it requested with .get_dump_flag().
86709 + */
86710 + dump.len = len;
86711 +
86712 + /* Always allocate enough space to hold the whole thing so that the
86713 + * driver does not need to check the length and bother with partial
86714 + * dumping.
86715 + */
86716 data = vzalloc(tmp.len);
86717 if (!data)
86718 return -ENOMEM;
86719 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
86720 if (ret)
86721 goto out;
86722
86723 + /* There are two sane possibilities:
86724 + * 1. The driver's .get_dump_data() does not touch dump.len.
86725 + * 2. Or it may set dump.len to how much it really writes, which
86726 + * should be tmp.len (or len if it can do a partial dump).
86727 + * In any case respond to userspace with the actual length of data
86728 + * it's receiving.
86729 + */
86730 + WARN_ON(dump.len != len && dump.len != tmp.len);
86731 + dump.len = len;
86732 +
86733 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
86734 ret = -EFAULT;
86735 goto out;
86736 diff --git a/net/core/flow.c b/net/core/flow.c
86737 index 7102f16..146b4bd 100644
86738 --- a/net/core/flow.c
86739 +++ b/net/core/flow.c
86740 @@ -61,7 +61,7 @@ struct flow_cache {
86741 struct timer_list rnd_timer;
86742 };
86743
86744 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86745 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86746 EXPORT_SYMBOL(flow_cache_genid);
86747 static struct flow_cache flow_cache_global;
86748 static struct kmem_cache *flow_cachep __read_mostly;
86749 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86750
86751 static int flow_entry_valid(struct flow_cache_entry *fle)
86752 {
86753 - if (atomic_read(&flow_cache_genid) != fle->genid)
86754 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86755 return 0;
86756 if (fle->object && !fle->object->ops->check(fle->object))
86757 return 0;
86758 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86759 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86760 fcp->hash_count++;
86761 }
86762 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86763 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86764 flo = fle->object;
86765 if (!flo)
86766 goto ret_object;
86767 @@ -279,7 +279,7 @@ nocache:
86768 }
86769 flo = resolver(net, key, family, dir, flo, ctx);
86770 if (fle) {
86771 - fle->genid = atomic_read(&flow_cache_genid);
86772 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86773 if (!IS_ERR(flo))
86774 fle->object = flo;
86775 else
86776 diff --git a/net/core/iovec.c b/net/core/iovec.c
86777 index de178e4..1dabd8b 100644
86778 --- a/net/core/iovec.c
86779 +++ b/net/core/iovec.c
86780 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86781 if (m->msg_namelen) {
86782 if (mode == VERIFY_READ) {
86783 void __user *namep;
86784 - namep = (void __user __force *) m->msg_name;
86785 + namep = (void __force_user *) m->msg_name;
86786 err = move_addr_to_kernel(namep, m->msg_namelen,
86787 address);
86788 if (err < 0)
86789 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86790 }
86791
86792 size = m->msg_iovlen * sizeof(struct iovec);
86793 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86794 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86795 return -EFAULT;
86796
86797 m->msg_iov = iov;
86798 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86799 index 5c56b21..8766fbf 100644
86800 --- a/net/core/neighbour.c
86801 +++ b/net/core/neighbour.c
86802 @@ -2769,7 +2769,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86803 size_t *lenp, loff_t *ppos)
86804 {
86805 int size, ret;
86806 - ctl_table tmp = *ctl;
86807 + ctl_table_no_const tmp = *ctl;
86808
86809 tmp.extra1 = &zero;
86810 tmp.extra2 = &unres_qlen_max;
86811 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86812 index 569d355..79cf2d0 100644
86813 --- a/net/core/net-procfs.c
86814 +++ b/net/core/net-procfs.c
86815 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86816 else
86817 seq_printf(seq, "%04x", ntohs(pt->type));
86818
86819 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86820 + seq_printf(seq, " %-8s %pf\n",
86821 + pt->dev ? pt->dev->name : "", NULL);
86822 +#else
86823 seq_printf(seq, " %-8s %pf\n",
86824 pt->dev ? pt->dev->name : "", pt->func);
86825 +#endif
86826 }
86827
86828 return 0;
86829 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86830 index 981fed3..536af34 100644
86831 --- a/net/core/net-sysfs.c
86832 +++ b/net/core/net-sysfs.c
86833 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86834 }
86835 EXPORT_SYMBOL(netdev_class_remove_file);
86836
86837 -int netdev_kobject_init(void)
86838 +int __init netdev_kobject_init(void)
86839 {
86840 kobj_ns_type_register(&net_ns_type_operations);
86841 return class_register(&net_class);
86842 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86843 index f9765203..9feaef8 100644
86844 --- a/net/core/net_namespace.c
86845 +++ b/net/core/net_namespace.c
86846 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
86847 int error;
86848 LIST_HEAD(net_exit_list);
86849
86850 - list_add_tail(&ops->list, list);
86851 + pax_list_add_tail((struct list_head *)&ops->list, list);
86852 if (ops->init || (ops->id && ops->size)) {
86853 for_each_net(net) {
86854 error = ops_init(ops, net);
86855 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
86856
86857 out_undo:
86858 /* If I have an error cleanup all namespaces I initialized */
86859 - list_del(&ops->list);
86860 + pax_list_del((struct list_head *)&ops->list);
86861 ops_exit_list(ops, &net_exit_list);
86862 ops_free_list(ops, &net_exit_list);
86863 return error;
86864 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86865 struct net *net;
86866 LIST_HEAD(net_exit_list);
86867
86868 - list_del(&ops->list);
86869 + pax_list_del((struct list_head *)&ops->list);
86870 for_each_net(net)
86871 list_add_tail(&net->exit_list, &net_exit_list);
86872 ops_exit_list(ops, &net_exit_list);
86873 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
86874 mutex_lock(&net_mutex);
86875 error = register_pernet_operations(&pernet_list, ops);
86876 if (!error && (first_device == &pernet_list))
86877 - first_device = &ops->list;
86878 + first_device = (struct list_head *)&ops->list;
86879 mutex_unlock(&net_mutex);
86880 return error;
86881 }
86882 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86883 index a08bd2b..4e8f43c 100644
86884 --- a/net/core/rtnetlink.c
86885 +++ b/net/core/rtnetlink.c
86886 @@ -58,7 +58,7 @@ struct rtnl_link {
86887 rtnl_doit_func doit;
86888 rtnl_dumpit_func dumpit;
86889 rtnl_calcit_func calcit;
86890 -};
86891 +} __no_const;
86892
86893 static DEFINE_MUTEX(rtnl_mutex);
86894
86895 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86896 if (rtnl_link_ops_get(ops->kind))
86897 return -EEXIST;
86898
86899 - if (!ops->dellink)
86900 - ops->dellink = unregister_netdevice_queue;
86901 + if (!ops->dellink) {
86902 + pax_open_kernel();
86903 + *(void **)&ops->dellink = unregister_netdevice_queue;
86904 + pax_close_kernel();
86905 + }
86906
86907 - list_add_tail(&ops->list, &link_ops);
86908 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86909 return 0;
86910 }
86911 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86912 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86913 for_each_net(net) {
86914 __rtnl_kill_links(net, ops);
86915 }
86916 - list_del(&ops->list);
86917 + pax_list_del((struct list_head *)&ops->list);
86918 }
86919 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86920
86921 diff --git a/net/core/scm.c b/net/core/scm.c
86922 index 03795d0..eaf7368 100644
86923 --- a/net/core/scm.c
86924 +++ b/net/core/scm.c
86925 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
86926 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86927 {
86928 struct cmsghdr __user *cm
86929 - = (__force struct cmsghdr __user *)msg->msg_control;
86930 + = (struct cmsghdr __force_user *)msg->msg_control;
86931 struct cmsghdr cmhdr;
86932 int cmlen = CMSG_LEN(len);
86933 int err;
86934 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86935 err = -EFAULT;
86936 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86937 goto out;
86938 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86939 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86940 goto out;
86941 cmlen = CMSG_SPACE(len);
86942 if (msg->msg_controllen < cmlen)
86943 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
86944 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86945 {
86946 struct cmsghdr __user *cm
86947 - = (__force struct cmsghdr __user*)msg->msg_control;
86948 + = (struct cmsghdr __force_user *)msg->msg_control;
86949
86950 int fdmax = 0;
86951 int fdnum = scm->fp->count;
86952 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86953 if (fdnum < fdmax)
86954 fdmax = fdnum;
86955
86956 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86957 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86958 i++, cmfptr++)
86959 {
86960 struct socket *sock;
86961 diff --git a/net/core/sock.c b/net/core/sock.c
86962 index d6d024c..6ea7ab4 100644
86963 --- a/net/core/sock.c
86964 +++ b/net/core/sock.c
86965 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86966 struct sk_buff_head *list = &sk->sk_receive_queue;
86967
86968 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86969 - atomic_inc(&sk->sk_drops);
86970 + atomic_inc_unchecked(&sk->sk_drops);
86971 trace_sock_rcvqueue_full(sk, skb);
86972 return -ENOMEM;
86973 }
86974 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86975 return err;
86976
86977 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86978 - atomic_inc(&sk->sk_drops);
86979 + atomic_inc_unchecked(&sk->sk_drops);
86980 return -ENOBUFS;
86981 }
86982
86983 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86984 skb_dst_force(skb);
86985
86986 spin_lock_irqsave(&list->lock, flags);
86987 - skb->dropcount = atomic_read(&sk->sk_drops);
86988 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86989 __skb_queue_tail(list, skb);
86990 spin_unlock_irqrestore(&list->lock, flags);
86991
86992 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86993 skb->dev = NULL;
86994
86995 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86996 - atomic_inc(&sk->sk_drops);
86997 + atomic_inc_unchecked(&sk->sk_drops);
86998 goto discard_and_relse;
86999 }
87000 if (nested)
87001 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
87002 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
87003 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
87004 bh_unlock_sock(sk);
87005 - atomic_inc(&sk->sk_drops);
87006 + atomic_inc_unchecked(&sk->sk_drops);
87007 goto discard_and_relse;
87008 }
87009
87010 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87011 struct timeval tm;
87012 } v;
87013
87014 - int lv = sizeof(int);
87015 - int len;
87016 + unsigned int lv = sizeof(int);
87017 + unsigned int len;
87018
87019 if (get_user(len, optlen))
87020 return -EFAULT;
87021 - if (len < 0)
87022 + if (len > INT_MAX)
87023 return -EINVAL;
87024
87025 memset(&v, 0, sizeof(v));
87026 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87027
87028 case SO_PEERNAME:
87029 {
87030 - char address[128];
87031 + char address[_K_SS_MAXSIZE];
87032
87033 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
87034 return -ENOTCONN;
87035 - if (lv < len)
87036 + if (lv < len || sizeof address < len)
87037 return -EINVAL;
87038 if (copy_to_user(optval, address, len))
87039 return -EFAULT;
87040 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87041
87042 if (len > lv)
87043 len = lv;
87044 - if (copy_to_user(optval, &v, len))
87045 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
87046 return -EFAULT;
87047 lenout:
87048 if (put_user(len, optlen))
87049 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
87050 */
87051 smp_wmb();
87052 atomic_set(&sk->sk_refcnt, 1);
87053 - atomic_set(&sk->sk_drops, 0);
87054 + atomic_set_unchecked(&sk->sk_drops, 0);
87055 }
87056 EXPORT_SYMBOL(sock_init_data);
87057
87058 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
87059 index a0e9cf6..ef7f9ed 100644
87060 --- a/net/core/sock_diag.c
87061 +++ b/net/core/sock_diag.c
87062 @@ -9,26 +9,33 @@
87063 #include <linux/inet_diag.h>
87064 #include <linux/sock_diag.h>
87065
87066 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
87067 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
87068 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
87069 static DEFINE_MUTEX(sock_diag_table_mutex);
87070
87071 int sock_diag_check_cookie(void *sk, __u32 *cookie)
87072 {
87073 +#ifndef CONFIG_GRKERNSEC_HIDESYM
87074 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
87075 cookie[1] != INET_DIAG_NOCOOKIE) &&
87076 ((u32)(unsigned long)sk != cookie[0] ||
87077 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
87078 return -ESTALE;
87079 else
87080 +#endif
87081 return 0;
87082 }
87083 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
87084
87085 void sock_diag_save_cookie(void *sk, __u32 *cookie)
87086 {
87087 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87088 + cookie[0] = 0;
87089 + cookie[1] = 0;
87090 +#else
87091 cookie[0] = (u32)(unsigned long)sk;
87092 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
87093 +#endif
87094 }
87095 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
87096
87097 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
87098 mutex_lock(&sock_diag_table_mutex);
87099 if (sock_diag_handlers[hndl->family])
87100 err = -EBUSY;
87101 - else
87102 + else {
87103 + pax_open_kernel();
87104 sock_diag_handlers[hndl->family] = hndl;
87105 + pax_close_kernel();
87106 + }
87107 mutex_unlock(&sock_diag_table_mutex);
87108
87109 return err;
87110 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
87111
87112 mutex_lock(&sock_diag_table_mutex);
87113 BUG_ON(sock_diag_handlers[family] != hnld);
87114 + pax_open_kernel();
87115 sock_diag_handlers[family] = NULL;
87116 + pax_close_kernel();
87117 mutex_unlock(&sock_diag_table_mutex);
87118 }
87119 EXPORT_SYMBOL_GPL(sock_diag_unregister);
87120 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
87121 index cfdb46a..cef55e1 100644
87122 --- a/net/core/sysctl_net_core.c
87123 +++ b/net/core/sysctl_net_core.c
87124 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
87125 {
87126 unsigned int orig_size, size;
87127 int ret, i;
87128 - ctl_table tmp = {
87129 + ctl_table_no_const tmp = {
87130 .data = &size,
87131 .maxlen = sizeof(size),
87132 .mode = table->mode
87133 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
87134
87135 static __net_init int sysctl_core_net_init(struct net *net)
87136 {
87137 - struct ctl_table *tbl;
87138 + ctl_table_no_const *tbl = NULL;
87139
87140 net->core.sysctl_somaxconn = SOMAXCONN;
87141
87142 - tbl = netns_core_table;
87143 if (!net_eq(net, &init_net)) {
87144 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
87145 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
87146 if (tbl == NULL)
87147 goto err_dup;
87148
87149 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
87150 if (net->user_ns != &init_user_ns) {
87151 tbl[0].procname = NULL;
87152 }
87153 - }
87154 -
87155 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87156 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87157 + } else
87158 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
87159 if (net->core.sysctl_hdr == NULL)
87160 goto err_reg;
87161
87162 return 0;
87163
87164 err_reg:
87165 - if (tbl != netns_core_table)
87166 - kfree(tbl);
87167 + kfree(tbl);
87168 err_dup:
87169 return -ENOMEM;
87170 }
87171 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
87172 kfree(tbl);
87173 }
87174
87175 -static __net_initdata struct pernet_operations sysctl_core_ops = {
87176 +static __net_initconst struct pernet_operations sysctl_core_ops = {
87177 .init = sysctl_core_net_init,
87178 .exit = sysctl_core_net_exit,
87179 };
87180 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
87181 index c21f200..bc4565b 100644
87182 --- a/net/decnet/af_decnet.c
87183 +++ b/net/decnet/af_decnet.c
87184 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
87185 .sysctl_rmem = sysctl_decnet_rmem,
87186 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
87187 .obj_size = sizeof(struct dn_sock),
87188 + .slab_flags = SLAB_USERCOPY,
87189 };
87190
87191 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
87192 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
87193 index a55eecc..dd8428c 100644
87194 --- a/net/decnet/sysctl_net_decnet.c
87195 +++ b/net/decnet/sysctl_net_decnet.c
87196 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
87197
87198 if (len > *lenp) len = *lenp;
87199
87200 - if (copy_to_user(buffer, addr, len))
87201 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
87202 return -EFAULT;
87203
87204 *lenp = len;
87205 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
87206
87207 if (len > *lenp) len = *lenp;
87208
87209 - if (copy_to_user(buffer, devname, len))
87210 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
87211 return -EFAULT;
87212
87213 *lenp = len;
87214 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
87215 index d01be2a..8976537 100644
87216 --- a/net/ipv4/af_inet.c
87217 +++ b/net/ipv4/af_inet.c
87218 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
87219
87220 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
87221
87222 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
87223 - if (!sysctl_local_reserved_ports)
87224 - goto out;
87225 -
87226 rc = proto_register(&tcp_prot, 1);
87227 if (rc)
87228 - goto out_free_reserved_ports;
87229 + goto out;
87230
87231 rc = proto_register(&udp_prot, 1);
87232 if (rc)
87233 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
87234 proto_unregister(&udp_prot);
87235 out_unregister_tcp_proto:
87236 proto_unregister(&tcp_prot);
87237 -out_free_reserved_ports:
87238 - kfree(sysctl_local_reserved_ports);
87239 goto out;
87240 }
87241
87242 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
87243 index 2e7f194..0fa4d6d 100644
87244 --- a/net/ipv4/ah4.c
87245 +++ b/net/ipv4/ah4.c
87246 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
87247 return;
87248
87249 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87250 - atomic_inc(&flow_cache_genid);
87251 + atomic_inc_unchecked(&flow_cache_genid);
87252 rt_genid_bump(net);
87253
87254 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
87255 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
87256 index dfc39d4..0b82c4d 100644
87257 --- a/net/ipv4/devinet.c
87258 +++ b/net/ipv4/devinet.c
87259 @@ -1529,7 +1529,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
87260 idx = 0;
87261 head = &net->dev_index_head[h];
87262 rcu_read_lock();
87263 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87264 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87265 net->dev_base_seq;
87266 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87267 if (idx < s_idx)
87268 @@ -1840,7 +1840,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
87269 idx = 0;
87270 head = &net->dev_index_head[h];
87271 rcu_read_lock();
87272 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87273 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87274 net->dev_base_seq;
87275 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87276 if (idx < s_idx)
87277 @@ -2065,7 +2065,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
87278 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
87279 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
87280
87281 -static struct devinet_sysctl_table {
87282 +static const struct devinet_sysctl_table {
87283 struct ctl_table_header *sysctl_header;
87284 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
87285 } devinet_sysctl = {
87286 @@ -2183,7 +2183,7 @@ static __net_init int devinet_init_net(struct net *net)
87287 int err;
87288 struct ipv4_devconf *all, *dflt;
87289 #ifdef CONFIG_SYSCTL
87290 - struct ctl_table *tbl = ctl_forward_entry;
87291 + ctl_table_no_const *tbl = NULL;
87292 struct ctl_table_header *forw_hdr;
87293 #endif
87294
87295 @@ -2201,7 +2201,7 @@ static __net_init int devinet_init_net(struct net *net)
87296 goto err_alloc_dflt;
87297
87298 #ifdef CONFIG_SYSCTL
87299 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
87300 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
87301 if (tbl == NULL)
87302 goto err_alloc_ctl;
87303
87304 @@ -2221,7 +2221,10 @@ static __net_init int devinet_init_net(struct net *net)
87305 goto err_reg_dflt;
87306
87307 err = -ENOMEM;
87308 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87309 + if (!net_eq(net, &init_net))
87310 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87311 + else
87312 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
87313 if (forw_hdr == NULL)
87314 goto err_reg_ctl;
87315 net->ipv4.forw_hdr = forw_hdr;
87316 @@ -2237,8 +2240,7 @@ err_reg_ctl:
87317 err_reg_dflt:
87318 __devinet_sysctl_unregister(all);
87319 err_reg_all:
87320 - if (tbl != ctl_forward_entry)
87321 - kfree(tbl);
87322 + kfree(tbl);
87323 err_alloc_ctl:
87324 #endif
87325 if (dflt != &ipv4_devconf_dflt)
87326 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87327 index 4cfe34d..a6ba66e 100644
87328 --- a/net/ipv4/esp4.c
87329 +++ b/net/ipv4/esp4.c
87330 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87331 return;
87332
87333 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87334 - atomic_inc(&flow_cache_genid);
87335 + atomic_inc_unchecked(&flow_cache_genid);
87336 rt_genid_bump(net);
87337
87338 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87339 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87340 index c7629a2..b62d139 100644
87341 --- a/net/ipv4/fib_frontend.c
87342 +++ b/net/ipv4/fib_frontend.c
87343 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87344 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87345 fib_sync_up(dev);
87346 #endif
87347 - atomic_inc(&net->ipv4.dev_addr_genid);
87348 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87349 rt_cache_flush(dev_net(dev));
87350 break;
87351 case NETDEV_DOWN:
87352 fib_del_ifaddr(ifa, NULL);
87353 - atomic_inc(&net->ipv4.dev_addr_genid);
87354 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87355 if (ifa->ifa_dev->ifa_list == NULL) {
87356 /* Last address was deleted from this interface.
87357 * Disable IP.
87358 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87359 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87360 fib_sync_up(dev);
87361 #endif
87362 - atomic_inc(&net->ipv4.dev_addr_genid);
87363 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87364 rt_cache_flush(net);
87365 break;
87366 case NETDEV_DOWN:
87367 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87368 index 8f6cb7a..34507f9 100644
87369 --- a/net/ipv4/fib_semantics.c
87370 +++ b/net/ipv4/fib_semantics.c
87371 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87372 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87373 nh->nh_gw,
87374 nh->nh_parent->fib_scope);
87375 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87376 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87377
87378 return nh->nh_saddr;
87379 }
87380 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87381 index 6acb541..9ea617d 100644
87382 --- a/net/ipv4/inet_connection_sock.c
87383 +++ b/net/ipv4/inet_connection_sock.c
87384 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87385 .range = { 32768, 61000 },
87386 };
87387
87388 -unsigned long *sysctl_local_reserved_ports;
87389 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87390 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87391
87392 void inet_get_local_port_range(int *low, int *high)
87393 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87394 index 6af375a..c493c74 100644
87395 --- a/net/ipv4/inet_hashtables.c
87396 +++ b/net/ipv4/inet_hashtables.c
87397 @@ -18,12 +18,15 @@
87398 #include <linux/sched.h>
87399 #include <linux/slab.h>
87400 #include <linux/wait.h>
87401 +#include <linux/security.h>
87402
87403 #include <net/inet_connection_sock.h>
87404 #include <net/inet_hashtables.h>
87405 #include <net/secure_seq.h>
87406 #include <net/ip.h>
87407
87408 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87409 +
87410 /*
87411 * Allocate and initialize a new local port bind bucket.
87412 * The bindhash mutex for snum's hash chain must be held here.
87413 @@ -554,6 +557,8 @@ ok:
87414 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87415 spin_unlock(&head->lock);
87416
87417 + gr_update_task_in_ip_table(current, inet_sk(sk));
87418 +
87419 if (tw) {
87420 inet_twsk_deschedule(tw, death_row);
87421 while (twrefcnt) {
87422 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87423 index 000e3d2..5472da3 100644
87424 --- a/net/ipv4/inetpeer.c
87425 +++ b/net/ipv4/inetpeer.c
87426 @@ -503,8 +503,8 @@ relookup:
87427 if (p) {
87428 p->daddr = *daddr;
87429 atomic_set(&p->refcnt, 1);
87430 - atomic_set(&p->rid, 0);
87431 - atomic_set(&p->ip_id_count,
87432 + atomic_set_unchecked(&p->rid, 0);
87433 + atomic_set_unchecked(&p->ip_id_count,
87434 (daddr->family == AF_INET) ?
87435 secure_ip_id(daddr->addr.a4) :
87436 secure_ipv6_id(daddr->addr.a6));
87437 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87438 index b66910a..cfe416e 100644
87439 --- a/net/ipv4/ip_fragment.c
87440 +++ b/net/ipv4/ip_fragment.c
87441 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87442 return 0;
87443
87444 start = qp->rid;
87445 - end = atomic_inc_return(&peer->rid);
87446 + end = atomic_inc_return_unchecked(&peer->rid);
87447 qp->rid = end;
87448
87449 rc = qp->q.fragments && (end - start) > max;
87450 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87451
87452 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87453 {
87454 - struct ctl_table *table;
87455 + ctl_table_no_const *table = NULL;
87456 struct ctl_table_header *hdr;
87457
87458 - table = ip4_frags_ns_ctl_table;
87459 if (!net_eq(net, &init_net)) {
87460 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87461 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87462 if (table == NULL)
87463 goto err_alloc;
87464
87465 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87466 /* Don't export sysctls to unprivileged users */
87467 if (net->user_ns != &init_user_ns)
87468 table[0].procname = NULL;
87469 - }
87470 + hdr = register_net_sysctl(net, "net/ipv4", table);
87471 + } else
87472 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87473
87474 - hdr = register_net_sysctl(net, "net/ipv4", table);
87475 if (hdr == NULL)
87476 goto err_reg;
87477
87478 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87479 return 0;
87480
87481 err_reg:
87482 - if (!net_eq(net, &init_net))
87483 - kfree(table);
87484 + kfree(table);
87485 err_alloc:
87486 return -ENOMEM;
87487 }
87488 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87489 index 2a83591..68e7458 100644
87490 --- a/net/ipv4/ip_gre.c
87491 +++ b/net/ipv4/ip_gre.c
87492 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
87493 module_param(log_ecn_error, bool, 0644);
87494 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87495
87496 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87497 +static struct rtnl_link_ops ipgre_link_ops;
87498 static int ipgre_tunnel_init(struct net_device *dev);
87499
87500 static int ipgre_net_id __read_mostly;
87501 @@ -503,10 +503,11 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
87502
87503 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
87504 return -EFAULT;
87505 - if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
87506 - p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
87507 - ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING))) {
87508 - return -EINVAL;
87509 + if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
87510 + if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
87511 + p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
87512 + ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING)))
87513 + return -EINVAL;
87514 }
87515 p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
87516 p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
87517 @@ -918,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87518 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87519 };
87520
87521 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87522 +static struct rtnl_link_ops ipgre_link_ops = {
87523 .kind = "gre",
87524 .maxtype = IFLA_GRE_MAX,
87525 .policy = ipgre_policy,
87526 @@ -932,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87527 .fill_info = ipgre_fill_info,
87528 };
87529
87530 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87531 +static struct rtnl_link_ops ipgre_tap_ops = {
87532 .kind = "gretap",
87533 .maxtype = IFLA_GRE_MAX,
87534 .policy = ipgre_policy,
87535 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87536 index d9c4f11..02b82dbc 100644
87537 --- a/net/ipv4/ip_sockglue.c
87538 +++ b/net/ipv4/ip_sockglue.c
87539 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87540 len = min_t(unsigned int, len, opt->optlen);
87541 if (put_user(len, optlen))
87542 return -EFAULT;
87543 - if (copy_to_user(optval, opt->__data, len))
87544 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87545 + copy_to_user(optval, opt->__data, len))
87546 return -EFAULT;
87547 return 0;
87548 }
87549 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87550 if (sk->sk_type != SOCK_STREAM)
87551 return -ENOPROTOOPT;
87552
87553 - msg.msg_control = optval;
87554 + msg.msg_control = (void __force_kernel *)optval;
87555 msg.msg_controllen = len;
87556 msg.msg_flags = flags;
87557
87558 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87559 index c118f6b..63856c4 100644
87560 --- a/net/ipv4/ip_vti.c
87561 +++ b/net/ipv4/ip_vti.c
87562 @@ -47,7 +47,7 @@
87563 #define HASH_SIZE 16
87564 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87565
87566 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87567 +static struct rtnl_link_ops vti_link_ops;
87568
87569 static int vti_net_id __read_mostly;
87570 struct vti_net {
87571 @@ -606,17 +606,10 @@ static int __net_init vti_fb_tunnel_init(struct net_device *dev)
87572 struct iphdr *iph = &tunnel->parms.iph;
87573 struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);
87574
87575 - tunnel->dev = dev;
87576 - strcpy(tunnel->parms.name, dev->name);
87577 -
87578 iph->version = 4;
87579 iph->protocol = IPPROTO_IPIP;
87580 iph->ihl = 5;
87581
87582 - dev->tstats = alloc_percpu(struct pcpu_tstats);
87583 - if (!dev->tstats)
87584 - return -ENOMEM;
87585 -
87586 dev_hold(dev);
87587 rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
87588 return 0;
87589 @@ -847,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87590 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87591 };
87592
87593 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87594 +static struct rtnl_link_ops vti_link_ops = {
87595 .kind = "vti",
87596 .maxtype = IFLA_VTI_MAX,
87597 .policy = vti_policy,
87598 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87599 index 59cb8c7..a72160c 100644
87600 --- a/net/ipv4/ipcomp.c
87601 +++ b/net/ipv4/ipcomp.c
87602 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87603 return;
87604
87605 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87606 - atomic_inc(&flow_cache_genid);
87607 + atomic_inc_unchecked(&flow_cache_genid);
87608 rt_genid_bump(net);
87609
87610 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87611 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87612 index efa1138..20dbba0 100644
87613 --- a/net/ipv4/ipconfig.c
87614 +++ b/net/ipv4/ipconfig.c
87615 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87616
87617 mm_segment_t oldfs = get_fs();
87618 set_fs(get_ds());
87619 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87620 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87621 set_fs(oldfs);
87622 return res;
87623 }
87624 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87625
87626 mm_segment_t oldfs = get_fs();
87627 set_fs(get_ds());
87628 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87629 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87630 set_fs(oldfs);
87631 return res;
87632 }
87633 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87634
87635 mm_segment_t oldfs = get_fs();
87636 set_fs(get_ds());
87637 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87638 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87639 set_fs(oldfs);
87640 return res;
87641 }
87642 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87643 index 77bfcce..64a55d4 100644
87644 --- a/net/ipv4/ipip.c
87645 +++ b/net/ipv4/ipip.c
87646 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87647 static int ipip_net_id __read_mostly;
87648
87649 static int ipip_tunnel_init(struct net_device *dev);
87650 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87651 +static struct rtnl_link_ops ipip_link_ops;
87652
87653 static int ipip_err(struct sk_buff *skb, u32 info)
87654 {
87655 @@ -404,7 +404,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87656 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87657 };
87658
87659 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87660 +static struct rtnl_link_ops ipip_link_ops = {
87661 .kind = "ipip",
87662 .maxtype = IFLA_IPTUN_MAX,
87663 .policy = ipip_policy,
87664 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87665 index 85a4f21..1beb1f5 100644
87666 --- a/net/ipv4/netfilter/arp_tables.c
87667 +++ b/net/ipv4/netfilter/arp_tables.c
87668 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
87669 #endif
87670
87671 static int get_info(struct net *net, void __user *user,
87672 - const int *len, int compat)
87673 + int len, int compat)
87674 {
87675 char name[XT_TABLE_MAXNAMELEN];
87676 struct xt_table *t;
87677 int ret;
87678
87679 - if (*len != sizeof(struct arpt_getinfo)) {
87680 - duprintf("length %u != %Zu\n", *len,
87681 + if (len != sizeof(struct arpt_getinfo)) {
87682 + duprintf("length %u != %Zu\n", len,
87683 sizeof(struct arpt_getinfo));
87684 return -EINVAL;
87685 }
87686 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
87687 info.size = private->size;
87688 strcpy(info.name, name);
87689
87690 - if (copy_to_user(user, &info, *len) != 0)
87691 + if (copy_to_user(user, &info, len) != 0)
87692 ret = -EFAULT;
87693 else
87694 ret = 0;
87695 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87696
87697 switch (cmd) {
87698 case ARPT_SO_GET_INFO:
87699 - ret = get_info(sock_net(sk), user, len, 1);
87700 + ret = get_info(sock_net(sk), user, *len, 1);
87701 break;
87702 case ARPT_SO_GET_ENTRIES:
87703 ret = compat_get_entries(sock_net(sk), user, len);
87704 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87705
87706 switch (cmd) {
87707 case ARPT_SO_GET_INFO:
87708 - ret = get_info(sock_net(sk), user, len, 0);
87709 + ret = get_info(sock_net(sk), user, *len, 0);
87710 break;
87711
87712 case ARPT_SO_GET_ENTRIES:
87713 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87714 index d23118d..6ad7277 100644
87715 --- a/net/ipv4/netfilter/ip_tables.c
87716 +++ b/net/ipv4/netfilter/ip_tables.c
87717 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87718 #endif
87719
87720 static int get_info(struct net *net, void __user *user,
87721 - const int *len, int compat)
87722 + int len, int compat)
87723 {
87724 char name[XT_TABLE_MAXNAMELEN];
87725 struct xt_table *t;
87726 int ret;
87727
87728 - if (*len != sizeof(struct ipt_getinfo)) {
87729 - duprintf("length %u != %zu\n", *len,
87730 + if (len != sizeof(struct ipt_getinfo)) {
87731 + duprintf("length %u != %zu\n", len,
87732 sizeof(struct ipt_getinfo));
87733 return -EINVAL;
87734 }
87735 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87736 info.size = private->size;
87737 strcpy(info.name, name);
87738
87739 - if (copy_to_user(user, &info, *len) != 0)
87740 + if (copy_to_user(user, &info, len) != 0)
87741 ret = -EFAULT;
87742 else
87743 ret = 0;
87744 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87745
87746 switch (cmd) {
87747 case IPT_SO_GET_INFO:
87748 - ret = get_info(sock_net(sk), user, len, 1);
87749 + ret = get_info(sock_net(sk), user, *len, 1);
87750 break;
87751 case IPT_SO_GET_ENTRIES:
87752 ret = compat_get_entries(sock_net(sk), user, len);
87753 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87754
87755 switch (cmd) {
87756 case IPT_SO_GET_INFO:
87757 - ret = get_info(sock_net(sk), user, len, 0);
87758 + ret = get_info(sock_net(sk), user, *len, 0);
87759 break;
87760
87761 case IPT_SO_GET_ENTRIES:
87762 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87763 index 7d93d62..cbbf2a3 100644
87764 --- a/net/ipv4/ping.c
87765 +++ b/net/ipv4/ping.c
87766 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87767 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87768 0, sock_i_ino(sp),
87769 atomic_read(&sp->sk_refcnt), sp,
87770 - atomic_read(&sp->sk_drops), len);
87771 + atomic_read_unchecked(&sp->sk_drops), len);
87772 }
87773
87774 static int ping_seq_show(struct seq_file *seq, void *v)
87775 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87776 index dd44e0a..06dcca4 100644
87777 --- a/net/ipv4/raw.c
87778 +++ b/net/ipv4/raw.c
87779 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87780 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87781 {
87782 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87783 - atomic_inc(&sk->sk_drops);
87784 + atomic_inc_unchecked(&sk->sk_drops);
87785 kfree_skb(skb);
87786 return NET_RX_DROP;
87787 }
87788 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87789
87790 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87791 {
87792 + struct icmp_filter filter;
87793 +
87794 if (optlen > sizeof(struct icmp_filter))
87795 optlen = sizeof(struct icmp_filter);
87796 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87797 + if (copy_from_user(&filter, optval, optlen))
87798 return -EFAULT;
87799 + raw_sk(sk)->filter = filter;
87800 return 0;
87801 }
87802
87803 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87804 {
87805 int len, ret = -EFAULT;
87806 + struct icmp_filter filter;
87807
87808 if (get_user(len, optlen))
87809 goto out;
87810 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87811 if (len > sizeof(struct icmp_filter))
87812 len = sizeof(struct icmp_filter);
87813 ret = -EFAULT;
87814 - if (put_user(len, optlen) ||
87815 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87816 + filter = raw_sk(sk)->filter;
87817 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87818 goto out;
87819 ret = 0;
87820 out: return ret;
87821 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87822 0, 0L, 0,
87823 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87824 0, sock_i_ino(sp),
87825 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87826 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87827 }
87828
87829 static int raw_seq_show(struct seq_file *seq, void *v)
87830 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87831 index d35bbf0..faa3ab8 100644
87832 --- a/net/ipv4/route.c
87833 +++ b/net/ipv4/route.c
87834 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87835 .maxlen = sizeof(int),
87836 .mode = 0200,
87837 .proc_handler = ipv4_sysctl_rtcache_flush,
87838 + .extra1 = &init_net,
87839 },
87840 { },
87841 };
87842
87843 static __net_init int sysctl_route_net_init(struct net *net)
87844 {
87845 - struct ctl_table *tbl;
87846 + ctl_table_no_const *tbl = NULL;
87847
87848 - tbl = ipv4_route_flush_table;
87849 if (!net_eq(net, &init_net)) {
87850 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87851 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87852 if (tbl == NULL)
87853 goto err_dup;
87854
87855 /* Don't export sysctls to unprivileged users */
87856 if (net->user_ns != &init_user_ns)
87857 tbl[0].procname = NULL;
87858 - }
87859 - tbl[0].extra1 = net;
87860 + tbl[0].extra1 = net;
87861 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87862 + } else
87863 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87864
87865 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87866 if (net->ipv4.route_hdr == NULL)
87867 goto err_reg;
87868 return 0;
87869
87870 err_reg:
87871 - if (tbl != ipv4_route_flush_table)
87872 - kfree(tbl);
87873 + kfree(tbl);
87874 err_dup:
87875 return -ENOMEM;
87876 }
87877 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87878
87879 static __net_init int rt_genid_init(struct net *net)
87880 {
87881 - atomic_set(&net->rt_genid, 0);
87882 + atomic_set_unchecked(&net->rt_genid, 0);
87883 get_random_bytes(&net->ipv4.dev_addr_genid,
87884 sizeof(net->ipv4.dev_addr_genid));
87885 return 0;
87886 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87887 index fa2f63f..6554815 100644
87888 --- a/net/ipv4/sysctl_net_ipv4.c
87889 +++ b/net/ipv4/sysctl_net_ipv4.c
87890 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87891 {
87892 int ret;
87893 int range[2];
87894 - ctl_table tmp = {
87895 + ctl_table_no_const tmp = {
87896 .data = &range,
87897 .maxlen = sizeof(range),
87898 .mode = table->mode,
87899 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87900 int ret;
87901 gid_t urange[2];
87902 kgid_t low, high;
87903 - ctl_table tmp = {
87904 + ctl_table_no_const tmp = {
87905 .data = &urange,
87906 .maxlen = sizeof(urange),
87907 .mode = table->mode,
87908 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87909 void __user *buffer, size_t *lenp, loff_t *ppos)
87910 {
87911 char val[TCP_CA_NAME_MAX];
87912 - ctl_table tbl = {
87913 + ctl_table_no_const tbl = {
87914 .data = val,
87915 .maxlen = TCP_CA_NAME_MAX,
87916 };
87917 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87918 void __user *buffer, size_t *lenp,
87919 loff_t *ppos)
87920 {
87921 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87922 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87923 int ret;
87924
87925 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87926 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87927 void __user *buffer, size_t *lenp,
87928 loff_t *ppos)
87929 {
87930 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87931 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87932 int ret;
87933
87934 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87935 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87936 struct mem_cgroup *memcg;
87937 #endif
87938
87939 - ctl_table tmp = {
87940 + ctl_table_no_const tmp = {
87941 .data = &vec,
87942 .maxlen = sizeof(vec),
87943 .mode = ctl->mode,
87944 };
87945
87946 if (!write) {
87947 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87948 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87949 + ctl_table_no_const tcp_mem = *ctl;
87950 +
87951 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87952 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87953 }
87954
87955 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87956 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87957 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87958 size_t *lenp, loff_t *ppos)
87959 {
87960 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87961 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87962 struct tcp_fastopen_context *ctxt;
87963 int ret;
87964 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87965 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87966 },
87967 {
87968 .procname = "ip_local_reserved_ports",
87969 - .data = NULL, /* initialized in sysctl_ipv4_init */
87970 + .data = sysctl_local_reserved_ports,
87971 .maxlen = 65536,
87972 .mode = 0644,
87973 .proc_handler = proc_do_large_bitmap,
87974 @@ -842,11 +844,10 @@ static struct ctl_table ipv4_net_table[] = {
87975
87976 static __net_init int ipv4_sysctl_init_net(struct net *net)
87977 {
87978 - struct ctl_table *table;
87979 + ctl_table_no_const *table = NULL;
87980
87981 - table = ipv4_net_table;
87982 if (!net_eq(net, &init_net)) {
87983 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87984 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87985 if (table == NULL)
87986 goto err_alloc;
87987
87988 @@ -881,15 +882,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87989
87990 tcp_init_mem(net);
87991
87992 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87993 + if (!net_eq(net, &init_net))
87994 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87995 + else
87996 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87997 if (net->ipv4.ipv4_hdr == NULL)
87998 goto err_reg;
87999
88000 return 0;
88001
88002 err_reg:
88003 - if (!net_eq(net, &init_net))
88004 - kfree(table);
88005 + kfree(table);
88006 err_alloc:
88007 return -ENOMEM;
88008 }
88009 @@ -911,16 +914,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
88010 static __init int sysctl_ipv4_init(void)
88011 {
88012 struct ctl_table_header *hdr;
88013 - struct ctl_table *i;
88014 -
88015 - for (i = ipv4_table; i->procname; i++) {
88016 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
88017 - i->data = sysctl_local_reserved_ports;
88018 - break;
88019 - }
88020 - }
88021 - if (!i->procname)
88022 - return -EINVAL;
88023
88024 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
88025 if (hdr == NULL)
88026 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
88027 index 9c62257..651cc27 100644
88028 --- a/net/ipv4/tcp_input.c
88029 +++ b/net/ipv4/tcp_input.c
88030 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
88031 * simplifies code)
88032 */
88033 static void
88034 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88035 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88036 struct sk_buff *head, struct sk_buff *tail,
88037 u32 start, u32 end)
88038 {
88039 @@ -5522,6 +5522,7 @@ discard:
88040 tcp_paws_reject(&tp->rx_opt, 0))
88041 goto discard_and_undo;
88042
88043 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
88044 if (th->syn) {
88045 /* We see SYN without ACK. It is attempt of
88046 * simultaneous connect with crossed SYNs.
88047 @@ -5572,6 +5573,7 @@ discard:
88048 goto discard;
88049 #endif
88050 }
88051 +#endif
88052 /* "fifth, if neither of the SYN or RST bits is set then
88053 * drop the segment and return."
88054 */
88055 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
88056 goto discard;
88057
88058 if (th->syn) {
88059 - if (th->fin)
88060 + if (th->fin || th->urg || th->psh)
88061 goto discard;
88062 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
88063 return 1;
88064 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
88065 index 7999fc5..c812f42 100644
88066 --- a/net/ipv4/tcp_ipv4.c
88067 +++ b/net/ipv4/tcp_ipv4.c
88068 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
88069 EXPORT_SYMBOL(sysctl_tcp_low_latency);
88070
88071
88072 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88073 +extern int grsec_enable_blackhole;
88074 +#endif
88075 +
88076 #ifdef CONFIG_TCP_MD5SIG
88077 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
88078 __be32 daddr, __be32 saddr, const struct tcphdr *th);
88079 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
88080 return 0;
88081
88082 reset:
88083 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88084 + if (!grsec_enable_blackhole)
88085 +#endif
88086 tcp_v4_send_reset(rsk, skb);
88087 discard:
88088 kfree_skb(skb);
88089 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
88090 TCP_SKB_CB(skb)->sacked = 0;
88091
88092 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88093 - if (!sk)
88094 + if (!sk) {
88095 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88096 + ret = 1;
88097 +#endif
88098 goto no_tcp_socket;
88099 -
88100 + }
88101 process:
88102 - if (sk->sk_state == TCP_TIME_WAIT)
88103 + if (sk->sk_state == TCP_TIME_WAIT) {
88104 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88105 + ret = 2;
88106 +#endif
88107 goto do_time_wait;
88108 + }
88109
88110 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
88111 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88112 @@ -2058,6 +2072,10 @@ csum_error:
88113 bad_packet:
88114 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88115 } else {
88116 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88117 + if (!grsec_enable_blackhole || (ret == 1 &&
88118 + (skb->dev->flags & IFF_LOOPBACK)))
88119 +#endif
88120 tcp_v4_send_reset(NULL, skb);
88121 }
88122
88123 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
88124 index 0f01788..d52a859 100644
88125 --- a/net/ipv4/tcp_minisocks.c
88126 +++ b/net/ipv4/tcp_minisocks.c
88127 @@ -27,6 +27,10 @@
88128 #include <net/inet_common.h>
88129 #include <net/xfrm.h>
88130
88131 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88132 +extern int grsec_enable_blackhole;
88133 +#endif
88134 +
88135 int sysctl_tcp_syncookies __read_mostly = 1;
88136 EXPORT_SYMBOL(sysctl_tcp_syncookies);
88137
88138 @@ -717,7 +721,10 @@ embryonic_reset:
88139 * avoid becoming vulnerable to outside attack aiming at
88140 * resetting legit local connections.
88141 */
88142 - req->rsk_ops->send_reset(sk, skb);
88143 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88144 + if (!grsec_enable_blackhole)
88145 +#endif
88146 + req->rsk_ops->send_reset(sk, skb);
88147 } else if (fastopen) { /* received a valid RST pkt */
88148 reqsk_fastopen_remove(sk, req, true);
88149 tcp_reset(sk);
88150 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
88151 index d4943f6..e7a74a5 100644
88152 --- a/net/ipv4/tcp_probe.c
88153 +++ b/net/ipv4/tcp_probe.c
88154 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
88155 if (cnt + width >= len)
88156 break;
88157
88158 - if (copy_to_user(buf + cnt, tbuf, width))
88159 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
88160 return -EFAULT;
88161 cnt += width;
88162 }
88163 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
88164 index 4b85e6f..22f9ac9 100644
88165 --- a/net/ipv4/tcp_timer.c
88166 +++ b/net/ipv4/tcp_timer.c
88167 @@ -22,6 +22,10 @@
88168 #include <linux/gfp.h>
88169 #include <net/tcp.h>
88170
88171 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88172 +extern int grsec_lastack_retries;
88173 +#endif
88174 +
88175 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
88176 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
88177 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
88178 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
88179 }
88180 }
88181
88182 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88183 + if ((sk->sk_state == TCP_LAST_ACK) &&
88184 + (grsec_lastack_retries > 0) &&
88185 + (grsec_lastack_retries < retry_until))
88186 + retry_until = grsec_lastack_retries;
88187 +#endif
88188 +
88189 if (retransmits_timed_out(sk, retry_until,
88190 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
88191 /* Has it gone just too far? */
88192 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
88193 index 0bf5d399..5a2dd92 100644
88194 --- a/net/ipv4/udp.c
88195 +++ b/net/ipv4/udp.c
88196 @@ -87,6 +87,7 @@
88197 #include <linux/types.h>
88198 #include <linux/fcntl.h>
88199 #include <linux/module.h>
88200 +#include <linux/security.h>
88201 #include <linux/socket.h>
88202 #include <linux/sockios.h>
88203 #include <linux/igmp.h>
88204 @@ -111,6 +112,10 @@
88205 #include <trace/events/skb.h>
88206 #include "udp_impl.h"
88207
88208 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88209 +extern int grsec_enable_blackhole;
88210 +#endif
88211 +
88212 struct udp_table udp_table __read_mostly;
88213 EXPORT_SYMBOL(udp_table);
88214
88215 @@ -594,6 +599,9 @@ found:
88216 return s;
88217 }
88218
88219 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
88220 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
88221 +
88222 /*
88223 * This routine is called by the ICMP module when it gets some
88224 * sort of error condition. If err < 0 then the socket should
88225 @@ -799,7 +807,7 @@ send:
88226 /*
88227 * Push out all pending data as one UDP datagram. Socket is locked.
88228 */
88229 -static int udp_push_pending_frames(struct sock *sk)
88230 +int udp_push_pending_frames(struct sock *sk)
88231 {
88232 struct udp_sock *up = udp_sk(sk);
88233 struct inet_sock *inet = inet_sk(sk);
88234 @@ -818,6 +826,7 @@ out:
88235 up->pending = 0;
88236 return err;
88237 }
88238 +EXPORT_SYMBOL(udp_push_pending_frames);
88239
88240 int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
88241 size_t len)
88242 @@ -889,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
88243 dport = usin->sin_port;
88244 if (dport == 0)
88245 return -EINVAL;
88246 +
88247 + err = gr_search_udp_sendmsg(sk, usin);
88248 + if (err)
88249 + return err;
88250 } else {
88251 if (sk->sk_state != TCP_ESTABLISHED)
88252 return -EDESTADDRREQ;
88253 +
88254 + err = gr_search_udp_sendmsg(sk, NULL);
88255 + if (err)
88256 + return err;
88257 +
88258 daddr = inet->inet_daddr;
88259 dport = inet->inet_dport;
88260 /* Open fast path for connected socket.
88261 @@ -1135,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
88262 IS_UDPLITE(sk));
88263 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88264 IS_UDPLITE(sk));
88265 - atomic_inc(&sk->sk_drops);
88266 + atomic_inc_unchecked(&sk->sk_drops);
88267 __skb_unlink(skb, rcvq);
88268 __skb_queue_tail(&list_kill, skb);
88269 }
88270 @@ -1221,6 +1239,10 @@ try_again:
88271 if (!skb)
88272 goto out;
88273
88274 + err = gr_search_udp_recvmsg(sk, skb);
88275 + if (err)
88276 + goto out_free;
88277 +
88278 ulen = skb->len - sizeof(struct udphdr);
88279 copied = len;
88280 if (copied > ulen)
88281 @@ -1254,7 +1276,7 @@ try_again:
88282 if (unlikely(err)) {
88283 trace_kfree_skb(skb, udp_recvmsg);
88284 if (!peeked) {
88285 - atomic_inc(&sk->sk_drops);
88286 + atomic_inc_unchecked(&sk->sk_drops);
88287 UDP_INC_STATS_USER(sock_net(sk),
88288 UDP_MIB_INERRORS, is_udplite);
88289 }
88290 @@ -1541,7 +1563,7 @@ csum_error:
88291 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88292 drop:
88293 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88294 - atomic_inc(&sk->sk_drops);
88295 + atomic_inc_unchecked(&sk->sk_drops);
88296 kfree_skb(skb);
88297 return -1;
88298 }
88299 @@ -1560,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88300 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88301
88302 if (!skb1) {
88303 - atomic_inc(&sk->sk_drops);
88304 + atomic_inc_unchecked(&sk->sk_drops);
88305 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88306 IS_UDPLITE(sk));
88307 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88308 @@ -1729,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88309 goto csum_error;
88310
88311 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88312 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88313 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88314 +#endif
88315 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
88316
88317 /*
88318 @@ -2159,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
88319 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88320 0, sock_i_ino(sp),
88321 atomic_read(&sp->sk_refcnt), sp,
88322 - atomic_read(&sp->sk_drops), len);
88323 + atomic_read_unchecked(&sp->sk_drops), len);
88324 }
88325
88326 int udp4_seq_show(struct seq_file *seq, void *v)
88327 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
88328 index 9a459be..086b866 100644
88329 --- a/net/ipv4/xfrm4_policy.c
88330 +++ b/net/ipv4/xfrm4_policy.c
88331 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
88332
88333 static int __net_init xfrm4_net_init(struct net *net)
88334 {
88335 - struct ctl_table *table;
88336 + ctl_table_no_const *table = NULL;
88337 struct ctl_table_header *hdr;
88338
88339 - table = xfrm4_policy_table;
88340 if (!net_eq(net, &init_net)) {
88341 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88342 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88343 if (!table)
88344 goto err_alloc;
88345
88346 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
88347 - }
88348 -
88349 - hdr = register_net_sysctl(net, "net/ipv4", table);
88350 + hdr = register_net_sysctl(net, "net/ipv4", table);
88351 + } else
88352 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
88353 if (!hdr)
88354 goto err_reg;
88355
88356 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
88357 return 0;
88358
88359 err_reg:
88360 - if (!net_eq(net, &init_net))
88361 - kfree(table);
88362 + kfree(table);
88363 err_alloc:
88364 return -ENOMEM;
88365 }
88366 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88367 index 4ab4c38..1533b2d 100644
88368 --- a/net/ipv6/addrconf.c
88369 +++ b/net/ipv6/addrconf.c
88370 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
88371 idx = 0;
88372 head = &net->dev_index_head[h];
88373 rcu_read_lock();
88374 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
88375 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
88376 net->dev_base_seq;
88377 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88378 if (idx < s_idx)
88379 @@ -2372,7 +2372,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88380 p.iph.ihl = 5;
88381 p.iph.protocol = IPPROTO_IPV6;
88382 p.iph.ttl = 64;
88383 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88384 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88385
88386 if (ops->ndo_do_ioctl) {
88387 mm_segment_t oldfs = get_fs();
88388 @@ -3994,7 +3994,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
88389 s_ip_idx = ip_idx = cb->args[2];
88390
88391 rcu_read_lock();
88392 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88393 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88394 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
88395 idx = 0;
88396 head = &net->dev_index_head[h];
88397 @@ -4579,7 +4579,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88398 dst_free(&ifp->rt->dst);
88399 break;
88400 }
88401 - atomic_inc(&net->ipv6.dev_addr_genid);
88402 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
88403 }
88404
88405 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88406 @@ -4599,7 +4599,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88407 int *valp = ctl->data;
88408 int val = *valp;
88409 loff_t pos = *ppos;
88410 - ctl_table lctl;
88411 + ctl_table_no_const lctl;
88412 int ret;
88413
88414 /*
88415 @@ -4681,7 +4681,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88416 int *valp = ctl->data;
88417 int val = *valp;
88418 loff_t pos = *ppos;
88419 - ctl_table lctl;
88420 + ctl_table_no_const lctl;
88421 int ret;
88422
88423 /*
88424 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88425 index b4ff0a4..db9b764 100644
88426 --- a/net/ipv6/icmp.c
88427 +++ b/net/ipv6/icmp.c
88428 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
88429
88430 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88431 {
88432 - struct ctl_table *table;
88433 + ctl_table_no_const *table;
88434
88435 table = kmemdup(ipv6_icmp_table_template,
88436 sizeof(ipv6_icmp_table_template),
88437 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88438 index ecd6073..58162ae 100644
88439 --- a/net/ipv6/ip6_gre.c
88440 +++ b/net/ipv6/ip6_gre.c
88441 @@ -74,7 +74,7 @@ struct ip6gre_net {
88442 struct net_device *fb_tunnel_dev;
88443 };
88444
88445 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88446 +static struct rtnl_link_ops ip6gre_link_ops;
88447 static int ip6gre_tunnel_init(struct net_device *dev);
88448 static void ip6gre_tunnel_setup(struct net_device *dev);
88449 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88450 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88451 }
88452
88453
88454 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88455 +static struct inet6_protocol ip6gre_protocol = {
88456 .handler = ip6gre_rcv,
88457 .err_handler = ip6gre_err,
88458 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88459 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88460 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88461 };
88462
88463 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88464 +static struct rtnl_link_ops ip6gre_link_ops = {
88465 .kind = "ip6gre",
88466 .maxtype = IFLA_GRE_MAX,
88467 .policy = ip6gre_policy,
88468 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88469 .fill_info = ip6gre_fill_info,
88470 };
88471
88472 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88473 +static struct rtnl_link_ops ip6gre_tap_ops = {
88474 .kind = "ip6gretap",
88475 .maxtype = IFLA_GRE_MAX,
88476 .policy = ip6gre_policy,
88477 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
88478 index d5d20cd..6e3ddf8 100644
88479 --- a/net/ipv6/ip6_output.c
88480 +++ b/net/ipv6/ip6_output.c
88481 @@ -1098,11 +1098,12 @@ static inline struct ipv6_rt_hdr *ip6_rthdr_dup(struct ipv6_rt_hdr *src,
88482 return src ? kmemdup(src, (src->hdrlen + 1) * 8, gfp) : NULL;
88483 }
88484
88485 -static void ip6_append_data_mtu(int *mtu,
88486 +static void ip6_append_data_mtu(unsigned int *mtu,
88487 int *maxfraglen,
88488 unsigned int fragheaderlen,
88489 struct sk_buff *skb,
88490 - struct rt6_info *rt)
88491 + struct rt6_info *rt,
88492 + bool pmtuprobe)
88493 {
88494 if (!(rt->dst.flags & DST_XFRM_TUNNEL)) {
88495 if (skb == NULL) {
88496 @@ -1114,7 +1115,9 @@ static void ip6_append_data_mtu(int *mtu,
88497 * this fragment is not first, the headers
88498 * space is regarded as data space.
88499 */
88500 - *mtu = dst_mtu(rt->dst.path);
88501 + *mtu = min(*mtu, pmtuprobe ?
88502 + rt->dst.dev->mtu :
88503 + dst_mtu(rt->dst.path));
88504 }
88505 *maxfraglen = ((*mtu - fragheaderlen) & ~7)
88506 + fragheaderlen - sizeof(struct frag_hdr);
88507 @@ -1131,11 +1134,10 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
88508 struct ipv6_pinfo *np = inet6_sk(sk);
88509 struct inet_cork *cork;
88510 struct sk_buff *skb, *skb_prev = NULL;
88511 - unsigned int maxfraglen, fragheaderlen;
88512 + unsigned int maxfraglen, fragheaderlen, mtu;
88513 int exthdrlen;
88514 int dst_exthdrlen;
88515 int hh_len;
88516 - int mtu;
88517 int copy;
88518 int err;
88519 int offset = 0;
88520 @@ -1292,7 +1294,9 @@ alloc_new_skb:
88521 /* update mtu and maxfraglen if necessary */
88522 if (skb == NULL || skb_prev == NULL)
88523 ip6_append_data_mtu(&mtu, &maxfraglen,
88524 - fragheaderlen, skb, rt);
88525 + fragheaderlen, skb, rt,
88526 + np->pmtudisc ==
88527 + IPV6_PMTUDISC_PROBE);
88528
88529 skb_prev = skb;
88530
88531 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88532 index 1e55866..b398dab 100644
88533 --- a/net/ipv6/ip6_tunnel.c
88534 +++ b/net/ipv6/ip6_tunnel.c
88535 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88536
88537 static int ip6_tnl_dev_init(struct net_device *dev);
88538 static void ip6_tnl_dev_setup(struct net_device *dev);
88539 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88540 +static struct rtnl_link_ops ip6_link_ops;
88541
88542 static int ip6_tnl_net_id __read_mostly;
88543 struct ip6_tnl_net {
88544 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88545 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88546 };
88547
88548 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88549 +static struct rtnl_link_ops ip6_link_ops = {
88550 .kind = "ip6tnl",
88551 .maxtype = IFLA_IPTUN_MAX,
88552 .policy = ip6_tnl_policy,
88553 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88554 index d1e2e8e..51c19ae 100644
88555 --- a/net/ipv6/ipv6_sockglue.c
88556 +++ b/net/ipv6/ipv6_sockglue.c
88557 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88558 if (sk->sk_type != SOCK_STREAM)
88559 return -ENOPROTOOPT;
88560
88561 - msg.msg_control = optval;
88562 + msg.msg_control = (void __force_kernel *)optval;
88563 msg.msg_controllen = len;
88564 msg.msg_flags = flags;
88565
88566 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88567 index 44400c2..8e11f52 100644
88568 --- a/net/ipv6/netfilter/ip6_tables.c
88569 +++ b/net/ipv6/netfilter/ip6_tables.c
88570 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
88571 #endif
88572
88573 static int get_info(struct net *net, void __user *user,
88574 - const int *len, int compat)
88575 + int len, int compat)
88576 {
88577 char name[XT_TABLE_MAXNAMELEN];
88578 struct xt_table *t;
88579 int ret;
88580
88581 - if (*len != sizeof(struct ip6t_getinfo)) {
88582 - duprintf("length %u != %zu\n", *len,
88583 + if (len != sizeof(struct ip6t_getinfo)) {
88584 + duprintf("length %u != %zu\n", len,
88585 sizeof(struct ip6t_getinfo));
88586 return -EINVAL;
88587 }
88588 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
88589 info.size = private->size;
88590 strcpy(info.name, name);
88591
88592 - if (copy_to_user(user, &info, *len) != 0)
88593 + if (copy_to_user(user, &info, len) != 0)
88594 ret = -EFAULT;
88595 else
88596 ret = 0;
88597 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88598
88599 switch (cmd) {
88600 case IP6T_SO_GET_INFO:
88601 - ret = get_info(sock_net(sk), user, len, 1);
88602 + ret = get_info(sock_net(sk), user, *len, 1);
88603 break;
88604 case IP6T_SO_GET_ENTRIES:
88605 ret = compat_get_entries(sock_net(sk), user, len);
88606 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88607
88608 switch (cmd) {
88609 case IP6T_SO_GET_INFO:
88610 - ret = get_info(sock_net(sk), user, len, 0);
88611 + ret = get_info(sock_net(sk), user, *len, 0);
88612 break;
88613
88614 case IP6T_SO_GET_ENTRIES:
88615 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88616 index dffdc1a..ccc6678 100644
88617 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88618 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88619 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88620
88621 static int nf_ct_frag6_sysctl_register(struct net *net)
88622 {
88623 - struct ctl_table *table;
88624 + ctl_table_no_const *table = NULL;
88625 struct ctl_table_header *hdr;
88626
88627 - table = nf_ct_frag6_sysctl_table;
88628 if (!net_eq(net, &init_net)) {
88629 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88630 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88631 GFP_KERNEL);
88632 if (table == NULL)
88633 goto err_alloc;
88634 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88635 table[0].data = &net->nf_frag.frags.timeout;
88636 table[1].data = &net->nf_frag.frags.low_thresh;
88637 table[2].data = &net->nf_frag.frags.high_thresh;
88638 - }
88639 -
88640 - hdr = register_net_sysctl(net, "net/netfilter", table);
88641 + hdr = register_net_sysctl(net, "net/netfilter", table);
88642 + } else
88643 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88644 if (hdr == NULL)
88645 goto err_reg;
88646
88647 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88648 return 0;
88649
88650 err_reg:
88651 - if (!net_eq(net, &init_net))
88652 - kfree(table);
88653 + kfree(table);
88654 err_alloc:
88655 return -ENOMEM;
88656 }
88657 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88658 index eedff8c..6e13a47 100644
88659 --- a/net/ipv6/raw.c
88660 +++ b/net/ipv6/raw.c
88661 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88662 {
88663 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88664 skb_checksum_complete(skb)) {
88665 - atomic_inc(&sk->sk_drops);
88666 + atomic_inc_unchecked(&sk->sk_drops);
88667 kfree_skb(skb);
88668 return NET_RX_DROP;
88669 }
88670 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88671 struct raw6_sock *rp = raw6_sk(sk);
88672
88673 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88674 - atomic_inc(&sk->sk_drops);
88675 + atomic_inc_unchecked(&sk->sk_drops);
88676 kfree_skb(skb);
88677 return NET_RX_DROP;
88678 }
88679 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88680
88681 if (inet->hdrincl) {
88682 if (skb_checksum_complete(skb)) {
88683 - atomic_inc(&sk->sk_drops);
88684 + atomic_inc_unchecked(&sk->sk_drops);
88685 kfree_skb(skb);
88686 return NET_RX_DROP;
88687 }
88688 @@ -602,7 +602,7 @@ out:
88689 return err;
88690 }
88691
88692 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88693 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88694 struct flowi6 *fl6, struct dst_entry **dstp,
88695 unsigned int flags)
88696 {
88697 @@ -914,12 +914,15 @@ do_confirm:
88698 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88699 char __user *optval, int optlen)
88700 {
88701 + struct icmp6_filter filter;
88702 +
88703 switch (optname) {
88704 case ICMPV6_FILTER:
88705 if (optlen > sizeof(struct icmp6_filter))
88706 optlen = sizeof(struct icmp6_filter);
88707 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88708 + if (copy_from_user(&filter, optval, optlen))
88709 return -EFAULT;
88710 + raw6_sk(sk)->filter = filter;
88711 return 0;
88712 default:
88713 return -ENOPROTOOPT;
88714 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88715 char __user *optval, int __user *optlen)
88716 {
88717 int len;
88718 + struct icmp6_filter filter;
88719
88720 switch (optname) {
88721 case ICMPV6_FILTER:
88722 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88723 len = sizeof(struct icmp6_filter);
88724 if (put_user(len, optlen))
88725 return -EFAULT;
88726 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88727 + filter = raw6_sk(sk)->filter;
88728 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88729 return -EFAULT;
88730 return 0;
88731 default:
88732 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88733 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88734 0,
88735 sock_i_ino(sp),
88736 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88737 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88738 }
88739
88740 static int raw6_seq_show(struct seq_file *seq, void *v)
88741 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88742 index 790d9f4..68ae078 100644
88743 --- a/net/ipv6/reassembly.c
88744 +++ b/net/ipv6/reassembly.c
88745 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88746
88747 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88748 {
88749 - struct ctl_table *table;
88750 + ctl_table_no_const *table = NULL;
88751 struct ctl_table_header *hdr;
88752
88753 - table = ip6_frags_ns_ctl_table;
88754 if (!net_eq(net, &init_net)) {
88755 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88756 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88757 if (table == NULL)
88758 goto err_alloc;
88759
88760 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88761 /* Don't export sysctls to unprivileged users */
88762 if (net->user_ns != &init_user_ns)
88763 table[0].procname = NULL;
88764 - }
88765 + hdr = register_net_sysctl(net, "net/ipv6", table);
88766 + } else
88767 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88768
88769 - hdr = register_net_sysctl(net, "net/ipv6", table);
88770 if (hdr == NULL)
88771 goto err_reg;
88772
88773 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88774 return 0;
88775
88776 err_reg:
88777 - if (!net_eq(net, &init_net))
88778 - kfree(table);
88779 + kfree(table);
88780 err_alloc:
88781 return -ENOMEM;
88782 }
88783 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88784 index ad0aa6b..beaef03 100644
88785 --- a/net/ipv6/route.c
88786 +++ b/net/ipv6/route.c
88787 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88788
88789 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88790 {
88791 - struct ctl_table *table;
88792 + ctl_table_no_const *table;
88793
88794 table = kmemdup(ipv6_route_table_template,
88795 sizeof(ipv6_route_table_template),
88796 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88797 index 3353634..3d5084a 100644
88798 --- a/net/ipv6/sit.c
88799 +++ b/net/ipv6/sit.c
88800 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88801 static void ipip6_dev_free(struct net_device *dev);
88802 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88803 __be32 *v4dst);
88804 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88805 +static struct rtnl_link_ops sit_link_ops;
88806
88807 static int sit_net_id __read_mostly;
88808 struct sit_net {
88809 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88810 #endif
88811 };
88812
88813 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88814 +static struct rtnl_link_ops sit_link_ops = {
88815 .kind = "sit",
88816 .maxtype = IFLA_IPTUN_MAX,
88817 .policy = ipip6_policy,
88818 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88819 index e85c48b..b8268d3 100644
88820 --- a/net/ipv6/sysctl_net_ipv6.c
88821 +++ b/net/ipv6/sysctl_net_ipv6.c
88822 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88823
88824 static int __net_init ipv6_sysctl_net_init(struct net *net)
88825 {
88826 - struct ctl_table *ipv6_table;
88827 + ctl_table_no_const *ipv6_table;
88828 struct ctl_table *ipv6_route_table;
88829 struct ctl_table *ipv6_icmp_table;
88830 int err;
88831 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88832 index 0a17ed9..2526cc3 100644
88833 --- a/net/ipv6/tcp_ipv6.c
88834 +++ b/net/ipv6/tcp_ipv6.c
88835 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88836 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88837 }
88838
88839 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88840 +extern int grsec_enable_blackhole;
88841 +#endif
88842 +
88843 static void tcp_v6_hash(struct sock *sk)
88844 {
88845 if (sk->sk_state != TCP_CLOSE) {
88846 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88847 return 0;
88848
88849 reset:
88850 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88851 + if (!grsec_enable_blackhole)
88852 +#endif
88853 tcp_v6_send_reset(sk, skb);
88854 discard:
88855 if (opt_skb)
88856 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88857 TCP_SKB_CB(skb)->sacked = 0;
88858
88859 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88860 - if (!sk)
88861 + if (!sk) {
88862 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88863 + ret = 1;
88864 +#endif
88865 goto no_tcp_socket;
88866 + }
88867
88868 process:
88869 - if (sk->sk_state == TCP_TIME_WAIT)
88870 + if (sk->sk_state == TCP_TIME_WAIT) {
88871 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88872 + ret = 2;
88873 +#endif
88874 goto do_time_wait;
88875 + }
88876
88877 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88878 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88879 @@ -1536,6 +1551,10 @@ csum_error:
88880 bad_packet:
88881 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88882 } else {
88883 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88884 + if (!grsec_enable_blackhole || (ret == 1 &&
88885 + (skb->dev->flags & IFF_LOOPBACK)))
88886 +#endif
88887 tcp_v6_send_reset(NULL, skb);
88888 }
88889
88890 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88891 index 42923b1..d09c290 100644
88892 --- a/net/ipv6/udp.c
88893 +++ b/net/ipv6/udp.c
88894 @@ -52,6 +52,10 @@
88895 #include <trace/events/skb.h>
88896 #include "udp_impl.h"
88897
88898 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88899 +extern int grsec_enable_blackhole;
88900 +#endif
88901 +
88902 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88903 {
88904 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88905 @@ -419,7 +423,7 @@ try_again:
88906 if (unlikely(err)) {
88907 trace_kfree_skb(skb, udpv6_recvmsg);
88908 if (!peeked) {
88909 - atomic_inc(&sk->sk_drops);
88910 + atomic_inc_unchecked(&sk->sk_drops);
88911 if (is_udp4)
88912 UDP_INC_STATS_USER(sock_net(sk),
88913 UDP_MIB_INERRORS,
88914 @@ -665,7 +669,7 @@ csum_error:
88915 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88916 drop:
88917 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88918 - atomic_inc(&sk->sk_drops);
88919 + atomic_inc_unchecked(&sk->sk_drops);
88920 kfree_skb(skb);
88921 return -1;
88922 }
88923 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88924 if (likely(skb1 == NULL))
88925 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88926 if (!skb1) {
88927 - atomic_inc(&sk->sk_drops);
88928 + atomic_inc_unchecked(&sk->sk_drops);
88929 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88930 IS_UDPLITE(sk));
88931 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88932 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88933 goto csum_error;
88934
88935 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88936 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88937 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88938 +#endif
88939 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88940
88941 kfree_skb(skb);
88942 @@ -955,11 +962,16 @@ static int udp_v6_push_pending_frames(struct sock *sk)
88943 struct udphdr *uh;
88944 struct udp_sock *up = udp_sk(sk);
88945 struct inet_sock *inet = inet_sk(sk);
88946 - struct flowi6 *fl6 = &inet->cork.fl.u.ip6;
88947 + struct flowi6 *fl6;
88948 int err = 0;
88949 int is_udplite = IS_UDPLITE(sk);
88950 __wsum csum = 0;
88951
88952 + if (up->pending == AF_INET)
88953 + return udp_push_pending_frames(sk);
88954 +
88955 + fl6 = &inet->cork.fl.u.ip6;
88956 +
88957 /* Grab the skbuff where UDP header space exists. */
88958 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
88959 goto out;
88960 @@ -1387,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88961 0,
88962 sock_i_ino(sp),
88963 atomic_read(&sp->sk_refcnt), sp,
88964 - atomic_read(&sp->sk_drops));
88965 + atomic_read_unchecked(&sp->sk_drops));
88966 }
88967
88968 int udp6_seq_show(struct seq_file *seq, void *v)
88969 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88970 index 23ed03d..465a71d 100644
88971 --- a/net/ipv6/xfrm6_policy.c
88972 +++ b/net/ipv6/xfrm6_policy.c
88973 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88974
88975 static int __net_init xfrm6_net_init(struct net *net)
88976 {
88977 - struct ctl_table *table;
88978 + ctl_table_no_const *table = NULL;
88979 struct ctl_table_header *hdr;
88980
88981 - table = xfrm6_policy_table;
88982 if (!net_eq(net, &init_net)) {
88983 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88984 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88985 if (!table)
88986 goto err_alloc;
88987
88988 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
88989 - }
88990 + hdr = register_net_sysctl(net, "net/ipv6", table);
88991 + } else
88992 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
88993
88994 - hdr = register_net_sysctl(net, "net/ipv6", table);
88995 if (!hdr)
88996 goto err_reg;
88997
88998 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
88999 return 0;
89000
89001 err_reg:
89002 - if (!net_eq(net, &init_net))
89003 - kfree(table);
89004 + kfree(table);
89005 err_alloc:
89006 return -ENOMEM;
89007 }
89008 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
89009 index 41ac7938..75e3bb1 100644
89010 --- a/net/irda/ircomm/ircomm_tty.c
89011 +++ b/net/irda/ircomm/ircomm_tty.c
89012 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89013 add_wait_queue(&port->open_wait, &wait);
89014
89015 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
89016 - __FILE__, __LINE__, tty->driver->name, port->count);
89017 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89018
89019 spin_lock_irqsave(&port->lock, flags);
89020 if (!tty_hung_up_p(filp))
89021 - port->count--;
89022 + atomic_dec(&port->count);
89023 port->blocked_open++;
89024 spin_unlock_irqrestore(&port->lock, flags);
89025
89026 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89027 }
89028
89029 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
89030 - __FILE__, __LINE__, tty->driver->name, port->count);
89031 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89032
89033 schedule();
89034 }
89035 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89036
89037 spin_lock_irqsave(&port->lock, flags);
89038 if (!tty_hung_up_p(filp))
89039 - port->count++;
89040 + atomic_inc(&port->count);
89041 port->blocked_open--;
89042 spin_unlock_irqrestore(&port->lock, flags);
89043
89044 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
89045 - __FILE__, __LINE__, tty->driver->name, port->count);
89046 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89047
89048 if (!retval)
89049 port->flags |= ASYNC_NORMAL_ACTIVE;
89050 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
89051
89052 /* ++ is not atomic, so this should be protected - Jean II */
89053 spin_lock_irqsave(&self->port.lock, flags);
89054 - self->port.count++;
89055 + atomic_inc(&self->port.count);
89056 spin_unlock_irqrestore(&self->port.lock, flags);
89057 tty_port_tty_set(&self->port, tty);
89058
89059 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
89060 - self->line, self->port.count);
89061 + self->line, atomic_read(&self->port.count));
89062
89063 /* Not really used by us, but lets do it anyway */
89064 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
89065 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
89066 tty_kref_put(port->tty);
89067 }
89068 port->tty = NULL;
89069 - port->count = 0;
89070 + atomic_set(&port->count, 0);
89071 spin_unlock_irqrestore(&port->lock, flags);
89072
89073 wake_up_interruptible(&port->open_wait);
89074 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
89075 seq_putc(m, '\n');
89076
89077 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
89078 - seq_printf(m, "Open count: %d\n", self->port.count);
89079 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
89080 seq_printf(m, "Max data size: %d\n", self->max_data_size);
89081 seq_printf(m, "Max header size: %d\n", self->max_header_size);
89082
89083 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
89084 index ae69165..c8b82d8 100644
89085 --- a/net/iucv/af_iucv.c
89086 +++ b/net/iucv/af_iucv.c
89087 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
89088
89089 write_lock_bh(&iucv_sk_list.lock);
89090
89091 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
89092 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89093 while (__iucv_get_sock_by_name(name)) {
89094 sprintf(name, "%08x",
89095 - atomic_inc_return(&iucv_sk_list.autobind_name));
89096 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89097 }
89098
89099 write_unlock_bh(&iucv_sk_list.lock);
89100 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
89101 index 4fe76ff..426a904 100644
89102 --- a/net/iucv/iucv.c
89103 +++ b/net/iucv/iucv.c
89104 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
89105 return NOTIFY_OK;
89106 }
89107
89108 -static struct notifier_block __refdata iucv_cpu_notifier = {
89109 +static struct notifier_block iucv_cpu_notifier = {
89110 .notifier_call = iucv_cpu_notify,
89111 };
89112
89113 diff --git a/net/key/af_key.c b/net/key/af_key.c
89114 index 9da8620..97070ad 100644
89115 --- a/net/key/af_key.c
89116 +++ b/net/key/af_key.c
89117 @@ -3047,10 +3047,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
89118 static u32 get_acqseq(void)
89119 {
89120 u32 res;
89121 - static atomic_t acqseq;
89122 + static atomic_unchecked_t acqseq;
89123
89124 do {
89125 - res = atomic_inc_return(&acqseq);
89126 + res = atomic_inc_return_unchecked(&acqseq);
89127 } while (!res);
89128 return res;
89129 }
89130 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
89131 index 8dec687..5ebee2d 100644
89132 --- a/net/l2tp/l2tp_ppp.c
89133 +++ b/net/l2tp/l2tp_ppp.c
89134 @@ -1793,7 +1793,8 @@ static const struct proto_ops pppol2tp_ops = {
89135
89136 static const struct pppox_proto pppol2tp_proto = {
89137 .create = pppol2tp_create,
89138 - .ioctl = pppol2tp_ioctl
89139 + .ioctl = pppol2tp_ioctl,
89140 + .owner = THIS_MODULE,
89141 };
89142
89143 #ifdef CONFIG_L2TP_V3
89144 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
89145 index 4fdb306e..920086a 100644
89146 --- a/net/mac80211/cfg.c
89147 +++ b/net/mac80211/cfg.c
89148 @@ -804,7 +804,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
89149 ret = ieee80211_vif_use_channel(sdata, chandef,
89150 IEEE80211_CHANCTX_EXCLUSIVE);
89151 }
89152 - } else if (local->open_count == local->monitors) {
89153 + } else if (local_read(&local->open_count) == local->monitors) {
89154 local->_oper_chandef = *chandef;
89155 ieee80211_hw_config(local, 0);
89156 }
89157 @@ -2920,7 +2920,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
89158 else
89159 local->probe_req_reg--;
89160
89161 - if (!local->open_count)
89162 + if (!local_read(&local->open_count))
89163 break;
89164
89165 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
89166 @@ -3383,8 +3383,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
89167 if (chanctx_conf) {
89168 *chandef = chanctx_conf->def;
89169 ret = 0;
89170 - } else if (local->open_count > 0 &&
89171 - local->open_count == local->monitors &&
89172 + } else if (local_read(&local->open_count) > 0 &&
89173 + local_read(&local->open_count) == local->monitors &&
89174 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
89175 if (local->use_chanctx)
89176 *chandef = local->monitor_chandef;
89177 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
89178 index 9ca8e32..48e4a9b 100644
89179 --- a/net/mac80211/ieee80211_i.h
89180 +++ b/net/mac80211/ieee80211_i.h
89181 @@ -28,6 +28,7 @@
89182 #include <net/ieee80211_radiotap.h>
89183 #include <net/cfg80211.h>
89184 #include <net/mac80211.h>
89185 +#include <asm/local.h>
89186 #include "key.h"
89187 #include "sta_info.h"
89188 #include "debug.h"
89189 @@ -891,7 +892,7 @@ struct ieee80211_local {
89190 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
89191 spinlock_t queue_stop_reason_lock;
89192
89193 - int open_count;
89194 + local_t open_count;
89195 int monitors, cooked_mntrs;
89196 /* number of interfaces with corresponding FIF_ flags */
89197 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
89198 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
89199 index 98d20c0..586675b 100644
89200 --- a/net/mac80211/iface.c
89201 +++ b/net/mac80211/iface.c
89202 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89203 break;
89204 }
89205
89206 - if (local->open_count == 0) {
89207 + if (local_read(&local->open_count) == 0) {
89208 res = drv_start(local);
89209 if (res)
89210 goto err_del_bss;
89211 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89212 break;
89213 }
89214
89215 - if (local->monitors == 0 && local->open_count == 0) {
89216 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
89217 res = ieee80211_add_virtual_monitor(local);
89218 if (res)
89219 goto err_stop;
89220 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89221 atomic_inc(&local->iff_promiscs);
89222
89223 if (coming_up)
89224 - local->open_count++;
89225 + local_inc(&local->open_count);
89226
89227 if (hw_reconf_flags)
89228 ieee80211_hw_config(local, hw_reconf_flags);
89229 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89230 err_del_interface:
89231 drv_remove_interface(local, sdata);
89232 err_stop:
89233 - if (!local->open_count)
89234 + if (!local_read(&local->open_count))
89235 drv_stop(local);
89236 err_del_bss:
89237 sdata->bss = NULL;
89238 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89239 }
89240
89241 if (going_down)
89242 - local->open_count--;
89243 + local_dec(&local->open_count);
89244
89245 switch (sdata->vif.type) {
89246 case NL80211_IFTYPE_AP_VLAN:
89247 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89248 }
89249 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
89250
89251 - if (local->open_count == 0)
89252 + if (local_read(&local->open_count) == 0)
89253 ieee80211_clear_tx_pending(local);
89254
89255 /*
89256 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89257
89258 ieee80211_recalc_ps(local, -1);
89259
89260 - if (local->open_count == 0) {
89261 + if (local_read(&local->open_count) == 0) {
89262 ieee80211_stop_device(local);
89263
89264 /* no reconfiguring after stop! */
89265 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89266 ieee80211_configure_filter(local);
89267 ieee80211_hw_config(local, hw_reconf_flags);
89268
89269 - if (local->monitors == local->open_count)
89270 + if (local->monitors == local_read(&local->open_count))
89271 ieee80211_add_virtual_monitor(local);
89272 }
89273
89274 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
89275 index 8a7bfc4..4407cd0 100644
89276 --- a/net/mac80211/main.c
89277 +++ b/net/mac80211/main.c
89278 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
89279 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
89280 IEEE80211_CONF_CHANGE_POWER);
89281
89282 - if (changed && local->open_count) {
89283 + if (changed && local_read(&local->open_count)) {
89284 ret = drv_config(local, changed);
89285 /*
89286 * Goal:
89287 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
89288 index 7fc5d0d..07ea536 100644
89289 --- a/net/mac80211/pm.c
89290 +++ b/net/mac80211/pm.c
89291 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89292 struct ieee80211_sub_if_data *sdata;
89293 struct sta_info *sta;
89294
89295 - if (!local->open_count)
89296 + if (!local_read(&local->open_count))
89297 goto suspend;
89298
89299 ieee80211_scan_cancel(local);
89300 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89301 cancel_work_sync(&local->dynamic_ps_enable_work);
89302 del_timer_sync(&local->dynamic_ps_timer);
89303
89304 - local->wowlan = wowlan && local->open_count;
89305 + local->wowlan = wowlan && local_read(&local->open_count);
89306 if (local->wowlan) {
89307 int err = drv_suspend(local, wowlan);
89308 if (err < 0) {
89309 @@ -113,7 +113,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89310 WARN_ON(!list_empty(&local->chanctx_list));
89311
89312 /* stop hardware - this must stop RX */
89313 - if (local->open_count)
89314 + if (local_read(&local->open_count))
89315 ieee80211_stop_device(local);
89316
89317 suspend:
89318 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
89319 index a02bef3..f2f38dd 100644
89320 --- a/net/mac80211/rate.c
89321 +++ b/net/mac80211/rate.c
89322 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
89323
89324 ASSERT_RTNL();
89325
89326 - if (local->open_count)
89327 + if (local_read(&local->open_count))
89328 return -EBUSY;
89329
89330 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
89331 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
89332 index c97a065..ff61928 100644
89333 --- a/net/mac80211/rc80211_pid_debugfs.c
89334 +++ b/net/mac80211/rc80211_pid_debugfs.c
89335 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
89336
89337 spin_unlock_irqrestore(&events->lock, status);
89338
89339 - if (copy_to_user(buf, pb, p))
89340 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
89341 return -EFAULT;
89342
89343 return p;
89344 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
89345 index 72e6292..e6319eb 100644
89346 --- a/net/mac80211/util.c
89347 +++ b/net/mac80211/util.c
89348 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
89349 }
89350 #endif
89351 /* everything else happens only if HW was up & running */
89352 - if (!local->open_count)
89353 + if (!local_read(&local->open_count))
89354 goto wake_up;
89355
89356 /*
89357 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
89358 local->in_reconfig = false;
89359 barrier();
89360
89361 - if (local->monitors == local->open_count && local->monitors > 0)
89362 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
89363 ieee80211_add_virtual_monitor(local);
89364
89365 /*
89366 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
89367 index 56d22ca..87c778f 100644
89368 --- a/net/netfilter/Kconfig
89369 +++ b/net/netfilter/Kconfig
89370 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
89371
89372 To compile it as a module, choose M here. If unsure, say N.
89373
89374 +config NETFILTER_XT_MATCH_GRADM
89375 + tristate '"gradm" match support'
89376 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
89377 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
89378 + ---help---
89379 + The gradm match allows to match on grsecurity RBAC being enabled.
89380 + It is useful when iptables rules are applied early on bootup to
89381 + prevent connections to the machine (except from a trusted host)
89382 + while the RBAC system is disabled.
89383 +
89384 config NETFILTER_XT_MATCH_HASHLIMIT
89385 tristate '"hashlimit" match support'
89386 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
89387 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
89388 index a1abf87..dbcb7ee 100644
89389 --- a/net/netfilter/Makefile
89390 +++ b/net/netfilter/Makefile
89391 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
89392 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
89393 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
89394 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
89395 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
89396 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
89397 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
89398 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
89399 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
89400 index f771390..145b765 100644
89401 --- a/net/netfilter/ipset/ip_set_core.c
89402 +++ b/net/netfilter/ipset/ip_set_core.c
89403 @@ -1820,7 +1820,7 @@ done:
89404 return ret;
89405 }
89406
89407 -static struct nf_sockopt_ops so_set __read_mostly = {
89408 +static struct nf_sockopt_ops so_set = {
89409 .pf = PF_INET,
89410 .get_optmin = SO_IP_SET,
89411 .get_optmax = SO_IP_SET + 1,
89412 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
89413 index a083bda..da661c3 100644
89414 --- a/net/netfilter/ipvs/ip_vs_conn.c
89415 +++ b/net/netfilter/ipvs/ip_vs_conn.c
89416 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
89417 /* Increase the refcnt counter of the dest */
89418 ip_vs_dest_hold(dest);
89419
89420 - conn_flags = atomic_read(&dest->conn_flags);
89421 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
89422 if (cp->protocol != IPPROTO_UDP)
89423 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
89424 flags = cp->flags;
89425 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
89426
89427 cp->control = NULL;
89428 atomic_set(&cp->n_control, 0);
89429 - atomic_set(&cp->in_pkts, 0);
89430 + atomic_set_unchecked(&cp->in_pkts, 0);
89431
89432 cp->packet_xmit = NULL;
89433 cp->app = NULL;
89434 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89435
89436 /* Don't drop the entry if its number of incoming packets is not
89437 located in [0, 8] */
89438 - i = atomic_read(&cp->in_pkts);
89439 + i = atomic_read_unchecked(&cp->in_pkts);
89440 if (i > 8 || i < 0) return 0;
89441
89442 if (!todrop_rate[i]) return 0;
89443 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89444 index 23b8eb5..48a8959 100644
89445 --- a/net/netfilter/ipvs/ip_vs_core.c
89446 +++ b/net/netfilter/ipvs/ip_vs_core.c
89447 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89448 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89449 /* do not touch skb anymore */
89450
89451 - atomic_inc(&cp->in_pkts);
89452 + atomic_inc_unchecked(&cp->in_pkts);
89453 ip_vs_conn_put(cp);
89454 return ret;
89455 }
89456 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89457 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89458 pkts = sysctl_sync_threshold(ipvs);
89459 else
89460 - pkts = atomic_add_return(1, &cp->in_pkts);
89461 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89462
89463 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89464 ip_vs_sync_conn(net, cp, pkts);
89465 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89466 index 9e6c2a0..28552e2 100644
89467 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89468 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89469 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89470 */
89471 ip_vs_rs_hash(ipvs, dest);
89472 }
89473 - atomic_set(&dest->conn_flags, conn_flags);
89474 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89475
89476 /* bind the service */
89477 if (!dest->svc) {
89478 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89479 * align with netns init in ip_vs_control_net_init()
89480 */
89481
89482 -static struct ctl_table vs_vars[] = {
89483 +static ctl_table_no_const vs_vars[] __read_only = {
89484 {
89485 .procname = "amemthresh",
89486 .maxlen = sizeof(int),
89487 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89488 " %-7s %-6d %-10d %-10d\n",
89489 &dest->addr.in6,
89490 ntohs(dest->port),
89491 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89492 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89493 atomic_read(&dest->weight),
89494 atomic_read(&dest->activeconns),
89495 atomic_read(&dest->inactconns));
89496 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89497 "%-7s %-6d %-10d %-10d\n",
89498 ntohl(dest->addr.ip),
89499 ntohs(dest->port),
89500 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89501 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89502 atomic_read(&dest->weight),
89503 atomic_read(&dest->activeconns),
89504 atomic_read(&dest->inactconns));
89505 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89506
89507 entry.addr = dest->addr.ip;
89508 entry.port = dest->port;
89509 - entry.conn_flags = atomic_read(&dest->conn_flags);
89510 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89511 entry.weight = atomic_read(&dest->weight);
89512 entry.u_threshold = dest->u_threshold;
89513 entry.l_threshold = dest->l_threshold;
89514 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89515 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89516 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89517 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89518 - (atomic_read(&dest->conn_flags) &
89519 + (atomic_read_unchecked(&dest->conn_flags) &
89520 IP_VS_CONN_F_FWD_MASK)) ||
89521 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89522 atomic_read(&dest->weight)) ||
89523 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89524 {
89525 int idx;
89526 struct netns_ipvs *ipvs = net_ipvs(net);
89527 - struct ctl_table *tbl;
89528 + ctl_table_no_const *tbl;
89529
89530 atomic_set(&ipvs->dropentry, 0);
89531 spin_lock_init(&ipvs->dropentry_lock);
89532 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89533 index 5ea26bd..c9bc65f 100644
89534 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89535 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89536 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
89537 * IPVS LBLC sysctl table
89538 */
89539 #ifdef CONFIG_SYSCTL
89540 -static ctl_table vs_vars_table[] = {
89541 +static ctl_table_no_const vs_vars_table[] __read_only = {
89542 {
89543 .procname = "lblc_expiration",
89544 .data = NULL,
89545 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89546 index 50123c2..067c773 100644
89547 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89548 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89549 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
89550 * IPVS LBLCR sysctl table
89551 */
89552
89553 -static ctl_table vs_vars_table[] = {
89554 +static ctl_table_no_const vs_vars_table[] __read_only = {
89555 {
89556 .procname = "lblcr_expiration",
89557 .data = NULL,
89558 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89559 index f6046d9..4f10cfd 100644
89560 --- a/net/netfilter/ipvs/ip_vs_sync.c
89561 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89562 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89563 cp = cp->control;
89564 if (cp) {
89565 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89566 - pkts = atomic_add_return(1, &cp->in_pkts);
89567 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89568 else
89569 pkts = sysctl_sync_threshold(ipvs);
89570 ip_vs_sync_conn(net, cp->control, pkts);
89571 @@ -758,7 +758,7 @@ control:
89572 if (!cp)
89573 return;
89574 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89575 - pkts = atomic_add_return(1, &cp->in_pkts);
89576 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89577 else
89578 pkts = sysctl_sync_threshold(ipvs);
89579 goto sloop;
89580 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89581
89582 if (opt)
89583 memcpy(&cp->in_seq, opt, sizeof(*opt));
89584 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89585 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89586 cp->state = state;
89587 cp->old_state = cp->state;
89588 /*
89589 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89590 index b75ff64..0c51bbe 100644
89591 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89592 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89593 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89594 else
89595 rc = NF_ACCEPT;
89596 /* do not touch skb anymore */
89597 - atomic_inc(&cp->in_pkts);
89598 + atomic_inc_unchecked(&cp->in_pkts);
89599 goto out;
89600 }
89601
89602 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89603 else
89604 rc = NF_ACCEPT;
89605 /* do not touch skb anymore */
89606 - atomic_inc(&cp->in_pkts);
89607 + atomic_inc_unchecked(&cp->in_pkts);
89608 goto out;
89609 }
89610
89611 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89612 index 2d3030a..7ba1c0a 100644
89613 --- a/net/netfilter/nf_conntrack_acct.c
89614 +++ b/net/netfilter/nf_conntrack_acct.c
89615 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89616 #ifdef CONFIG_SYSCTL
89617 static int nf_conntrack_acct_init_sysctl(struct net *net)
89618 {
89619 - struct ctl_table *table;
89620 + ctl_table_no_const *table;
89621
89622 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89623 GFP_KERNEL);
89624 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89625 index 0283bae..5febcb0 100644
89626 --- a/net/netfilter/nf_conntrack_core.c
89627 +++ b/net/netfilter/nf_conntrack_core.c
89628 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
89629 #define DYING_NULLS_VAL ((1<<30)+1)
89630 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89631
89632 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89633 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89634 +#endif
89635 +
89636 int nf_conntrack_init_net(struct net *net)
89637 {
89638 int ret;
89639 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
89640 goto err_stat;
89641 }
89642
89643 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89644 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89645 +#else
89646 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89647 +#endif
89648 if (!net->ct.slabname) {
89649 ret = -ENOMEM;
89650 goto err_slabname;
89651 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89652 index 1df1761..ce8b88a 100644
89653 --- a/net/netfilter/nf_conntrack_ecache.c
89654 +++ b/net/netfilter/nf_conntrack_ecache.c
89655 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89656 #ifdef CONFIG_SYSCTL
89657 static int nf_conntrack_event_init_sysctl(struct net *net)
89658 {
89659 - struct ctl_table *table;
89660 + ctl_table_no_const *table;
89661
89662 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89663 GFP_KERNEL);
89664 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89665 index 974a2a4..52cc6ff 100644
89666 --- a/net/netfilter/nf_conntrack_helper.c
89667 +++ b/net/netfilter/nf_conntrack_helper.c
89668 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
89669
89670 static int nf_conntrack_helper_init_sysctl(struct net *net)
89671 {
89672 - struct ctl_table *table;
89673 + ctl_table_no_const *table;
89674
89675 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89676 GFP_KERNEL);
89677 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89678 index 0ab9636..cea3c6a 100644
89679 --- a/net/netfilter/nf_conntrack_proto.c
89680 +++ b/net/netfilter/nf_conntrack_proto.c
89681 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
89682
89683 static void
89684 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89685 - struct ctl_table **table,
89686 + ctl_table_no_const **table,
89687 unsigned int users)
89688 {
89689 if (users > 0)
89690 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
89691 index a99b6c3..3841268 100644
89692 --- a/net/netfilter/nf_conntrack_proto_dccp.c
89693 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
89694 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
89695 out_invalid:
89696 if (LOG_INVALID(net, IPPROTO_DCCP))
89697 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
89698 - NULL, msg);
89699 + NULL, "%s", msg);
89700 return false;
89701 }
89702
89703 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
89704
89705 out_invalid:
89706 if (LOG_INVALID(net, IPPROTO_DCCP))
89707 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
89708 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
89709 return -NF_ACCEPT;
89710 }
89711
89712 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89713 index bd700b4..4a3dc61 100644
89714 --- a/net/netfilter/nf_conntrack_standalone.c
89715 +++ b/net/netfilter/nf_conntrack_standalone.c
89716 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89717
89718 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89719 {
89720 - struct ctl_table *table;
89721 + ctl_table_no_const *table;
89722
89723 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
89724 GFP_KERNEL);
89725 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89726 index 902fb0a..87f7fdb 100644
89727 --- a/net/netfilter/nf_conntrack_timestamp.c
89728 +++ b/net/netfilter/nf_conntrack_timestamp.c
89729 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89730 #ifdef CONFIG_SYSCTL
89731 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89732 {
89733 - struct ctl_table *table;
89734 + ctl_table_no_const *table;
89735
89736 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89737 GFP_KERNEL);
89738 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89739 index 3b18dd1..f79e0ca 100644
89740 --- a/net/netfilter/nf_log.c
89741 +++ b/net/netfilter/nf_log.c
89742 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
89743
89744 #ifdef CONFIG_SYSCTL
89745 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89746 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89747 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89748
89749 static int nf_log_proc_dostring(ctl_table *table, int write,
89750 void __user *buffer, size_t *lenp, loff_t *ppos)
89751 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89752 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
89753 mutex_unlock(&nf_log_mutex);
89754 } else {
89755 + ctl_table_no_const nf_log_table = *table;
89756 +
89757 mutex_lock(&nf_log_mutex);
89758 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
89759 lockdep_is_held(&nf_log_mutex));
89760 if (!logger)
89761 - table->data = "NONE";
89762 + nf_log_table.data = "NONE";
89763 else
89764 - table->data = logger->name;
89765 - r = proc_dostring(table, write, buffer, lenp, ppos);
89766 + nf_log_table.data = logger->name;
89767 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89768 mutex_unlock(&nf_log_mutex);
89769 }
89770
89771 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89772 index f042ae5..30ea486 100644
89773 --- a/net/netfilter/nf_sockopt.c
89774 +++ b/net/netfilter/nf_sockopt.c
89775 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89776 }
89777 }
89778
89779 - list_add(&reg->list, &nf_sockopts);
89780 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89781 out:
89782 mutex_unlock(&nf_sockopt_mutex);
89783 return ret;
89784 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89785 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89786 {
89787 mutex_lock(&nf_sockopt_mutex);
89788 - list_del(&reg->list);
89789 + pax_list_del((struct list_head *)&reg->list);
89790 mutex_unlock(&nf_sockopt_mutex);
89791 }
89792 EXPORT_SYMBOL(nf_unregister_sockopt);
89793 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89794 index 962e979..d4ae2e9 100644
89795 --- a/net/netfilter/nfnetlink_log.c
89796 +++ b/net/netfilter/nfnetlink_log.c
89797 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
89798 struct nfnl_log_net {
89799 spinlock_t instances_lock;
89800 struct hlist_head instance_table[INSTANCE_BUCKETS];
89801 - atomic_t global_seq;
89802 + atomic_unchecked_t global_seq;
89803 };
89804
89805 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
89806 @@ -559,7 +559,7 @@ __build_packet_message(struct nfnl_log_net *log,
89807 /* global sequence number */
89808 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89809 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89810 - htonl(atomic_inc_return(&log->global_seq))))
89811 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
89812 goto nla_put_failure;
89813
89814 if (data_len) {
89815 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89816 new file mode 100644
89817 index 0000000..c566332
89818 --- /dev/null
89819 +++ b/net/netfilter/xt_gradm.c
89820 @@ -0,0 +1,51 @@
89821 +/*
89822 + * gradm match for netfilter
89823 + * Copyright © Zbigniew Krzystolik, 2010
89824 + *
89825 + * This program is free software; you can redistribute it and/or modify
89826 + * it under the terms of the GNU General Public License; either version
89827 + * 2 or 3 as published by the Free Software Foundation.
89828 + */
89829 +#include <linux/module.h>
89830 +#include <linux/moduleparam.h>
89831 +#include <linux/skbuff.h>
89832 +#include <linux/netfilter/x_tables.h>
89833 +#include <linux/grsecurity.h>
89834 +#include <linux/netfilter/xt_gradm.h>
89835 +
89836 +static bool
89837 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89838 +{
89839 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89840 + bool retval = false;
89841 + if (gr_acl_is_enabled())
89842 + retval = true;
89843 + return retval ^ info->invflags;
89844 +}
89845 +
89846 +static struct xt_match gradm_mt_reg __read_mostly = {
89847 + .name = "gradm",
89848 + .revision = 0,
89849 + .family = NFPROTO_UNSPEC,
89850 + .match = gradm_mt,
89851 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89852 + .me = THIS_MODULE,
89853 +};
89854 +
89855 +static int __init gradm_mt_init(void)
89856 +{
89857 + return xt_register_match(&gradm_mt_reg);
89858 +}
89859 +
89860 +static void __exit gradm_mt_exit(void)
89861 +{
89862 + xt_unregister_match(&gradm_mt_reg);
89863 +}
89864 +
89865 +module_init(gradm_mt_init);
89866 +module_exit(gradm_mt_exit);
89867 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89868 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89869 +MODULE_LICENSE("GPL");
89870 +MODULE_ALIAS("ipt_gradm");
89871 +MODULE_ALIAS("ip6t_gradm");
89872 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89873 index 4fe4fb4..87a89e5 100644
89874 --- a/net/netfilter/xt_statistic.c
89875 +++ b/net/netfilter/xt_statistic.c
89876 @@ -19,7 +19,7 @@
89877 #include <linux/module.h>
89878
89879 struct xt_statistic_priv {
89880 - atomic_t count;
89881 + atomic_unchecked_t count;
89882 } ____cacheline_aligned_in_smp;
89883
89884 MODULE_LICENSE("GPL");
89885 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89886 break;
89887 case XT_STATISTIC_MODE_NTH:
89888 do {
89889 - oval = atomic_read(&info->master->count);
89890 + oval = atomic_read_unchecked(&info->master->count);
89891 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89892 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89893 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89894 if (nval == 0)
89895 ret = !ret;
89896 break;
89897 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89898 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89899 if (info->master == NULL)
89900 return -ENOMEM;
89901 - atomic_set(&info->master->count, info->u.nth.count);
89902 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89903
89904 return 0;
89905 }
89906 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89907 index 57ee84d..8b99cf5 100644
89908 --- a/net/netlink/af_netlink.c
89909 +++ b/net/netlink/af_netlink.c
89910 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
89911 sk->sk_error_report(sk);
89912 }
89913 }
89914 - atomic_inc(&sk->sk_drops);
89915 + atomic_inc_unchecked(&sk->sk_drops);
89916 }
89917
89918 static void netlink_rcv_wake(struct sock *sk)
89919 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89920 sk_wmem_alloc_get(s),
89921 nlk->cb,
89922 atomic_read(&s->sk_refcnt),
89923 - atomic_read(&s->sk_drops),
89924 + atomic_read_unchecked(&s->sk_drops),
89925 sock_i_ino(s)
89926 );
89927
89928 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89929 index 2fd6dbe..1032269 100644
89930 --- a/net/netlink/genetlink.c
89931 +++ b/net/netlink/genetlink.c
89932 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89933 goto errout;
89934 }
89935
89936 + pax_open_kernel();
89937 if (ops->dumpit)
89938 - ops->flags |= GENL_CMD_CAP_DUMP;
89939 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89940 if (ops->doit)
89941 - ops->flags |= GENL_CMD_CAP_DO;
89942 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89943 if (ops->policy)
89944 - ops->flags |= GENL_CMD_CAP_HASPOL;
89945 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89946 + pax_close_kernel();
89947
89948 genl_lock_all();
89949 - list_add_tail(&ops->ops_list, &family->ops_list);
89950 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89951 genl_unlock_all();
89952
89953 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89954 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89955 err = 0;
89956 errout:
89957 return err;
89958 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89959 genl_lock_all();
89960 list_for_each_entry(rc, &family->ops_list, ops_list) {
89961 if (rc == ops) {
89962 - list_del(&ops->ops_list);
89963 + pax_list_del((struct list_head *)&ops->ops_list);
89964 genl_unlock_all();
89965 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89966 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89967 return 0;
89968 }
89969 }
89970 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89971 index ec0c80f..41e1830 100644
89972 --- a/net/netrom/af_netrom.c
89973 +++ b/net/netrom/af_netrom.c
89974 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89975 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89976 } else {
89977 sax->fsa_ax25.sax25_family = AF_NETROM;
89978 - sax->fsa_ax25.sax25_ndigis = 0;
89979 sax->fsa_ax25.sax25_call = nr->source_addr;
89980 *uaddr_len = sizeof(struct sockaddr_ax25);
89981 }
89982 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89983 index 20a1bd0..bb8f1c1 100644
89984 --- a/net/packet/af_packet.c
89985 +++ b/net/packet/af_packet.c
89986 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89987
89988 spin_lock(&sk->sk_receive_queue.lock);
89989 po->stats.stats1.tp_packets++;
89990 - skb->dropcount = atomic_read(&sk->sk_drops);
89991 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89992 __skb_queue_tail(&sk->sk_receive_queue, skb);
89993 spin_unlock(&sk->sk_receive_queue.lock);
89994 sk->sk_data_ready(sk, skb->len);
89995 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89996 drop_n_acct:
89997 spin_lock(&sk->sk_receive_queue.lock);
89998 po->stats.stats1.tp_drops++;
89999 - atomic_inc(&sk->sk_drops);
90000 + atomic_inc_unchecked(&sk->sk_drops);
90001 spin_unlock(&sk->sk_receive_queue.lock);
90002
90003 drop_n_restore:
90004 @@ -2640,6 +2640,7 @@ out:
90005
90006 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90007 {
90008 + struct sock_extended_err ee;
90009 struct sock_exterr_skb *serr;
90010 struct sk_buff *skb, *skb2;
90011 int copied, err;
90012 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90013 sock_recv_timestamp(msg, sk, skb);
90014
90015 serr = SKB_EXT_ERR(skb);
90016 + ee = serr->ee;
90017 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
90018 - sizeof(serr->ee), &serr->ee);
90019 + sizeof ee, &ee);
90020
90021 msg->msg_flags |= MSG_ERRQUEUE;
90022 err = copied;
90023 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90024 case PACKET_HDRLEN:
90025 if (len > sizeof(int))
90026 len = sizeof(int);
90027 - if (copy_from_user(&val, optval, len))
90028 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
90029 return -EFAULT;
90030 switch (val) {
90031 case TPACKET_V1:
90032 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90033 len = lv;
90034 if (put_user(len, optlen))
90035 return -EFAULT;
90036 - if (copy_to_user(optval, data, len))
90037 + if (len > sizeof(st) || copy_to_user(optval, data, len))
90038 return -EFAULT;
90039 return 0;
90040 }
90041 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
90042 index 5a940db..d6a502d 100644
90043 --- a/net/phonet/af_phonet.c
90044 +++ b/net/phonet/af_phonet.c
90045 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
90046 {
90047 int err = 0;
90048
90049 - if (protocol >= PHONET_NPROTO)
90050 + if (protocol < 0 || protocol >= PHONET_NPROTO)
90051 return -EINVAL;
90052
90053 err = proto_register(pp->prot, 1);
90054 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
90055 index e774117..900b8b7 100644
90056 --- a/net/phonet/pep.c
90057 +++ b/net/phonet/pep.c
90058 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90059
90060 case PNS_PEP_CTRL_REQ:
90061 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
90062 - atomic_inc(&sk->sk_drops);
90063 + atomic_inc_unchecked(&sk->sk_drops);
90064 break;
90065 }
90066 __skb_pull(skb, 4);
90067 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90068 }
90069
90070 if (pn->rx_credits == 0) {
90071 - atomic_inc(&sk->sk_drops);
90072 + atomic_inc_unchecked(&sk->sk_drops);
90073 err = -ENOBUFS;
90074 break;
90075 }
90076 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
90077 }
90078
90079 if (pn->rx_credits == 0) {
90080 - atomic_inc(&sk->sk_drops);
90081 + atomic_inc_unchecked(&sk->sk_drops);
90082 err = NET_RX_DROP;
90083 break;
90084 }
90085 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
90086 index 1afd138..0b42453 100644
90087 --- a/net/phonet/socket.c
90088 +++ b/net/phonet/socket.c
90089 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
90090 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
90091 sock_i_ino(sk),
90092 atomic_read(&sk->sk_refcnt), sk,
90093 - atomic_read(&sk->sk_drops), &len);
90094 + atomic_read_unchecked(&sk->sk_drops), &len);
90095 }
90096 seq_printf(seq, "%*s\n", 127 - len, "");
90097 return 0;
90098 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
90099 index d6bbbbd..61561e4 100644
90100 --- a/net/phonet/sysctl.c
90101 +++ b/net/phonet/sysctl.c
90102 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
90103 {
90104 int ret;
90105 int range[2] = {local_port_range[0], local_port_range[1]};
90106 - ctl_table tmp = {
90107 + ctl_table_no_const tmp = {
90108 .data = &range,
90109 .maxlen = sizeof(range),
90110 .mode = table->mode,
90111 diff --git a/net/rds/cong.c b/net/rds/cong.c
90112 index e5b65ac..f3b6fb7 100644
90113 --- a/net/rds/cong.c
90114 +++ b/net/rds/cong.c
90115 @@ -78,7 +78,7 @@
90116 * finds that the saved generation number is smaller than the global generation
90117 * number, it wakes up the process.
90118 */
90119 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
90120 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
90121
90122 /*
90123 * Congestion monitoring
90124 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
90125 rdsdebug("waking map %p for %pI4\n",
90126 map, &map->m_addr);
90127 rds_stats_inc(s_cong_update_received);
90128 - atomic_inc(&rds_cong_generation);
90129 + atomic_inc_unchecked(&rds_cong_generation);
90130 if (waitqueue_active(&map->m_waitq))
90131 wake_up(&map->m_waitq);
90132 if (waitqueue_active(&rds_poll_waitq))
90133 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
90134
90135 int rds_cong_updated_since(unsigned long *recent)
90136 {
90137 - unsigned long gen = atomic_read(&rds_cong_generation);
90138 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
90139
90140 if (likely(*recent == gen))
90141 return 0;
90142 diff --git a/net/rds/ib.h b/net/rds/ib.h
90143 index 7280ab8..e04f4ea 100644
90144 --- a/net/rds/ib.h
90145 +++ b/net/rds/ib.h
90146 @@ -128,7 +128,7 @@ struct rds_ib_connection {
90147 /* sending acks */
90148 unsigned long i_ack_flags;
90149 #ifdef KERNEL_HAS_ATOMIC64
90150 - atomic64_t i_ack_next; /* next ACK to send */
90151 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90152 #else
90153 spinlock_t i_ack_lock; /* protect i_ack_next */
90154 u64 i_ack_next; /* next ACK to send */
90155 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
90156 index 31b74f5..dc1fbfa 100644
90157 --- a/net/rds/ib_cm.c
90158 +++ b/net/rds/ib_cm.c
90159 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
90160 /* Clear the ACK state */
90161 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90162 #ifdef KERNEL_HAS_ATOMIC64
90163 - atomic64_set(&ic->i_ack_next, 0);
90164 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90165 #else
90166 ic->i_ack_next = 0;
90167 #endif
90168 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
90169 index 8eb9501..0c386ff 100644
90170 --- a/net/rds/ib_recv.c
90171 +++ b/net/rds/ib_recv.c
90172 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90173 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
90174 int ack_required)
90175 {
90176 - atomic64_set(&ic->i_ack_next, seq);
90177 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90178 if (ack_required) {
90179 smp_mb__before_clear_bit();
90180 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90181 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90182 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90183 smp_mb__after_clear_bit();
90184
90185 - return atomic64_read(&ic->i_ack_next);
90186 + return atomic64_read_unchecked(&ic->i_ack_next);
90187 }
90188 #endif
90189
90190 diff --git a/net/rds/iw.h b/net/rds/iw.h
90191 index 04ce3b1..48119a6 100644
90192 --- a/net/rds/iw.h
90193 +++ b/net/rds/iw.h
90194 @@ -134,7 +134,7 @@ struct rds_iw_connection {
90195 /* sending acks */
90196 unsigned long i_ack_flags;
90197 #ifdef KERNEL_HAS_ATOMIC64
90198 - atomic64_t i_ack_next; /* next ACK to send */
90199 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90200 #else
90201 spinlock_t i_ack_lock; /* protect i_ack_next */
90202 u64 i_ack_next; /* next ACK to send */
90203 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
90204 index a91e1db..cf3053f 100644
90205 --- a/net/rds/iw_cm.c
90206 +++ b/net/rds/iw_cm.c
90207 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
90208 /* Clear the ACK state */
90209 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90210 #ifdef KERNEL_HAS_ATOMIC64
90211 - atomic64_set(&ic->i_ack_next, 0);
90212 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90213 #else
90214 ic->i_ack_next = 0;
90215 #endif
90216 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
90217 index 4503335..db566b4 100644
90218 --- a/net/rds/iw_recv.c
90219 +++ b/net/rds/iw_recv.c
90220 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90221 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
90222 int ack_required)
90223 {
90224 - atomic64_set(&ic->i_ack_next, seq);
90225 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90226 if (ack_required) {
90227 smp_mb__before_clear_bit();
90228 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90229 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90230 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90231 smp_mb__after_clear_bit();
90232
90233 - return atomic64_read(&ic->i_ack_next);
90234 + return atomic64_read_unchecked(&ic->i_ack_next);
90235 }
90236 #endif
90237
90238 diff --git a/net/rds/rds.h b/net/rds/rds.h
90239 index ec1d731..90a3a8d 100644
90240 --- a/net/rds/rds.h
90241 +++ b/net/rds/rds.h
90242 @@ -449,7 +449,7 @@ struct rds_transport {
90243 void (*sync_mr)(void *trans_private, int direction);
90244 void (*free_mr)(void *trans_private, int invalidate);
90245 void (*flush_mrs)(void);
90246 -};
90247 +} __do_const;
90248
90249 struct rds_sock {
90250 struct sock rs_sk;
90251 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
90252 index edac9ef..16bcb98 100644
90253 --- a/net/rds/tcp.c
90254 +++ b/net/rds/tcp.c
90255 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
90256 int val = 1;
90257
90258 set_fs(KERNEL_DS);
90259 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
90260 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
90261 sizeof(val));
90262 set_fs(oldfs);
90263 }
90264 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
90265 index 81cf5a4..b5826ff 100644
90266 --- a/net/rds/tcp_send.c
90267 +++ b/net/rds/tcp_send.c
90268 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
90269
90270 oldfs = get_fs();
90271 set_fs(KERNEL_DS);
90272 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
90273 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
90274 sizeof(val));
90275 set_fs(oldfs);
90276 }
90277 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
90278 index e61aa60..f07cc89 100644
90279 --- a/net/rxrpc/af_rxrpc.c
90280 +++ b/net/rxrpc/af_rxrpc.c
90281 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
90282 __be32 rxrpc_epoch;
90283
90284 /* current debugging ID */
90285 -atomic_t rxrpc_debug_id;
90286 +atomic_unchecked_t rxrpc_debug_id;
90287
90288 /* count of skbs currently in use */
90289 atomic_t rxrpc_n_skbs;
90290 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
90291 index e4d9cbc..b229649 100644
90292 --- a/net/rxrpc/ar-ack.c
90293 +++ b/net/rxrpc/ar-ack.c
90294 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90295
90296 _enter("{%d,%d,%d,%d},",
90297 call->acks_hard, call->acks_unacked,
90298 - atomic_read(&call->sequence),
90299 + atomic_read_unchecked(&call->sequence),
90300 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
90301
90302 stop = 0;
90303 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90304
90305 /* each Tx packet has a new serial number */
90306 sp->hdr.serial =
90307 - htonl(atomic_inc_return(&call->conn->serial));
90308 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
90309
90310 hdr = (struct rxrpc_header *) txb->head;
90311 hdr->serial = sp->hdr.serial;
90312 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
90313 */
90314 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
90315 {
90316 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
90317 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
90318 }
90319
90320 /*
90321 @@ -629,7 +629,7 @@ process_further:
90322
90323 latest = ntohl(sp->hdr.serial);
90324 hard = ntohl(ack.firstPacket);
90325 - tx = atomic_read(&call->sequence);
90326 + tx = atomic_read_unchecked(&call->sequence);
90327
90328 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90329 latest,
90330 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
90331 goto maybe_reschedule;
90332
90333 send_ACK_with_skew:
90334 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
90335 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
90336 ntohl(ack.serial));
90337 send_ACK:
90338 mtu = call->conn->trans->peer->if_mtu;
90339 @@ -1173,7 +1173,7 @@ send_ACK:
90340 ackinfo.rxMTU = htonl(5692);
90341 ackinfo.jumbo_max = htonl(4);
90342
90343 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90344 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90345 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90346 ntohl(hdr.serial),
90347 ntohs(ack.maxSkew),
90348 @@ -1191,7 +1191,7 @@ send_ACK:
90349 send_message:
90350 _debug("send message");
90351
90352 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90353 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90354 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
90355 send_message_2:
90356
90357 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
90358 index a3bbb36..3341fb9 100644
90359 --- a/net/rxrpc/ar-call.c
90360 +++ b/net/rxrpc/ar-call.c
90361 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
90362 spin_lock_init(&call->lock);
90363 rwlock_init(&call->state_lock);
90364 atomic_set(&call->usage, 1);
90365 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
90366 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90367 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
90368
90369 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
90370 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
90371 index 4106ca9..a338d7a 100644
90372 --- a/net/rxrpc/ar-connection.c
90373 +++ b/net/rxrpc/ar-connection.c
90374 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
90375 rwlock_init(&conn->lock);
90376 spin_lock_init(&conn->state_lock);
90377 atomic_set(&conn->usage, 1);
90378 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
90379 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90380 conn->avail_calls = RXRPC_MAXCALLS;
90381 conn->size_align = 4;
90382 conn->header_size = sizeof(struct rxrpc_header);
90383 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
90384 index e7ed43a..6afa140 100644
90385 --- a/net/rxrpc/ar-connevent.c
90386 +++ b/net/rxrpc/ar-connevent.c
90387 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
90388
90389 len = iov[0].iov_len + iov[1].iov_len;
90390
90391 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90392 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90393 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
90394
90395 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90396 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
90397 index 529572f..c758ca7 100644
90398 --- a/net/rxrpc/ar-input.c
90399 +++ b/net/rxrpc/ar-input.c
90400 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
90401 /* track the latest serial number on this connection for ACK packet
90402 * information */
90403 serial = ntohl(sp->hdr.serial);
90404 - hi_serial = atomic_read(&call->conn->hi_serial);
90405 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90406 while (serial > hi_serial)
90407 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90408 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90409 serial);
90410
90411 /* request ACK generation for any ACK or DATA packet that requests
90412 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90413 index a693aca..81e7293 100644
90414 --- a/net/rxrpc/ar-internal.h
90415 +++ b/net/rxrpc/ar-internal.h
90416 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90417 int error; /* error code for local abort */
90418 int debug_id; /* debug ID for printks */
90419 unsigned int call_counter; /* call ID counter */
90420 - atomic_t serial; /* packet serial number counter */
90421 - atomic_t hi_serial; /* highest serial number received */
90422 + atomic_unchecked_t serial; /* packet serial number counter */
90423 + atomic_unchecked_t hi_serial; /* highest serial number received */
90424 u8 avail_calls; /* number of calls available */
90425 u8 size_align; /* data size alignment (for security) */
90426 u8 header_size; /* rxrpc + security header size */
90427 @@ -346,7 +346,7 @@ struct rxrpc_call {
90428 spinlock_t lock;
90429 rwlock_t state_lock; /* lock for state transition */
90430 atomic_t usage;
90431 - atomic_t sequence; /* Tx data packet sequence counter */
90432 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90433 u32 abort_code; /* local/remote abort code */
90434 enum { /* current state of call */
90435 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90436 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90437 */
90438 extern atomic_t rxrpc_n_skbs;
90439 extern __be32 rxrpc_epoch;
90440 -extern atomic_t rxrpc_debug_id;
90441 +extern atomic_unchecked_t rxrpc_debug_id;
90442 extern struct workqueue_struct *rxrpc_workqueue;
90443
90444 /*
90445 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90446 index 87f7135..74d3703 100644
90447 --- a/net/rxrpc/ar-local.c
90448 +++ b/net/rxrpc/ar-local.c
90449 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90450 spin_lock_init(&local->lock);
90451 rwlock_init(&local->services_lock);
90452 atomic_set(&local->usage, 1);
90453 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90454 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90455 memcpy(&local->srx, srx, sizeof(*srx));
90456 }
90457
90458 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90459 index e1ac183..b43e10e 100644
90460 --- a/net/rxrpc/ar-output.c
90461 +++ b/net/rxrpc/ar-output.c
90462 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90463 sp->hdr.cid = call->cid;
90464 sp->hdr.callNumber = call->call_id;
90465 sp->hdr.seq =
90466 - htonl(atomic_inc_return(&call->sequence));
90467 + htonl(atomic_inc_return_unchecked(&call->sequence));
90468 sp->hdr.serial =
90469 - htonl(atomic_inc_return(&conn->serial));
90470 + htonl(atomic_inc_return_unchecked(&conn->serial));
90471 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90472 sp->hdr.userStatus = 0;
90473 sp->hdr.securityIndex = conn->security_ix;
90474 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90475 index bebaa43..2644591 100644
90476 --- a/net/rxrpc/ar-peer.c
90477 +++ b/net/rxrpc/ar-peer.c
90478 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90479 INIT_LIST_HEAD(&peer->error_targets);
90480 spin_lock_init(&peer->lock);
90481 atomic_set(&peer->usage, 1);
90482 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90483 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90484 memcpy(&peer->srx, srx, sizeof(*srx));
90485
90486 rxrpc_assess_MTU_size(peer);
90487 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90488 index 38047f7..9f48511 100644
90489 --- a/net/rxrpc/ar-proc.c
90490 +++ b/net/rxrpc/ar-proc.c
90491 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90492 atomic_read(&conn->usage),
90493 rxrpc_conn_states[conn->state],
90494 key_serial(conn->key),
90495 - atomic_read(&conn->serial),
90496 - atomic_read(&conn->hi_serial));
90497 + atomic_read_unchecked(&conn->serial),
90498 + atomic_read_unchecked(&conn->hi_serial));
90499
90500 return 0;
90501 }
90502 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90503 index 92df566..87ec1bf 100644
90504 --- a/net/rxrpc/ar-transport.c
90505 +++ b/net/rxrpc/ar-transport.c
90506 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90507 spin_lock_init(&trans->client_lock);
90508 rwlock_init(&trans->conn_lock);
90509 atomic_set(&trans->usage, 1);
90510 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90511 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90512
90513 if (peer->srx.transport.family == AF_INET) {
90514 switch (peer->srx.transport_type) {
90515 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90516 index f226709..0e735a8 100644
90517 --- a/net/rxrpc/rxkad.c
90518 +++ b/net/rxrpc/rxkad.c
90519 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90520
90521 len = iov[0].iov_len + iov[1].iov_len;
90522
90523 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90524 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90525 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90526
90527 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90528 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90529
90530 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90531
90532 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90533 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90534 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90535
90536 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90537 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90538 index 391a245..296b3d7 100644
90539 --- a/net/sctp/ipv6.c
90540 +++ b/net/sctp/ipv6.c
90541 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90542 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90543 };
90544
90545 -static struct sctp_af sctp_af_inet6 = {
90546 +static struct sctp_af sctp_af_inet6 __read_only = {
90547 .sa_family = AF_INET6,
90548 .sctp_xmit = sctp_v6_xmit,
90549 .setsockopt = ipv6_setsockopt,
90550 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90551 #endif
90552 };
90553
90554 -static struct sctp_pf sctp_pf_inet6 = {
90555 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90556 .event_msgname = sctp_inet6_event_msgname,
90557 .skb_msgname = sctp_inet6_skb_msgname,
90558 .af_supported = sctp_inet6_af_supported,
90559 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90560
90561 void sctp_v6_pf_exit(void)
90562 {
90563 - list_del(&sctp_af_inet6.list);
90564 + pax_list_del(&sctp_af_inet6.list);
90565 }
90566
90567 /* Initialize IPv6 support and register with socket layer. */
90568 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90569 index 4e45ee3..e66a031 100644
90570 --- a/net/sctp/proc.c
90571 +++ b/net/sctp/proc.c
90572 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90573 seq_printf(seq,
90574 "%8pK %8pK %-3d %-3d %-2d %-4d "
90575 "%4d %8d %8d %7d %5lu %-5d %5d ",
90576 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90577 + assoc, sk,
90578 + sctp_sk(sk)->type, sk->sk_state,
90579 assoc->state, hash,
90580 assoc->assoc_id,
90581 assoc->sndbuf_used,
90582 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90583 index eaee00c..97c0afd 100644
90584 --- a/net/sctp/protocol.c
90585 +++ b/net/sctp/protocol.c
90586 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90587 return 0;
90588 }
90589
90590 + pax_open_kernel();
90591 INIT_LIST_HEAD(&af->list);
90592 - list_add_tail(&af->list, &sctp_address_families);
90593 + pax_close_kernel();
90594 + pax_list_add_tail(&af->list, &sctp_address_families);
90595 return 1;
90596 }
90597
90598 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90599
90600 static struct sctp_af sctp_af_inet;
90601
90602 -static struct sctp_pf sctp_pf_inet = {
90603 +static struct sctp_pf sctp_pf_inet __read_only = {
90604 .event_msgname = sctp_inet_event_msgname,
90605 .skb_msgname = sctp_inet_skb_msgname,
90606 .af_supported = sctp_inet_af_supported,
90607 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90608 };
90609
90610 /* IPv4 address related functions. */
90611 -static struct sctp_af sctp_af_inet = {
90612 +static struct sctp_af sctp_af_inet __read_only = {
90613 .sa_family = AF_INET,
90614 .sctp_xmit = sctp_v4_xmit,
90615 .setsockopt = ip_setsockopt,
90616 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90617
90618 static void sctp_v4_pf_exit(void)
90619 {
90620 - list_del(&sctp_af_inet.list);
90621 + pax_list_del(&sctp_af_inet.list);
90622 }
90623
90624 static int sctp_v4_protosw_init(void)
90625 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90626 index 8aab894..f6b7e7d 100644
90627 --- a/net/sctp/sm_sideeffect.c
90628 +++ b/net/sctp/sm_sideeffect.c
90629 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90630 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90631 }
90632
90633 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90634 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90635 NULL,
90636 sctp_generate_t1_cookie_event,
90637 sctp_generate_t1_init_event,
90638 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90639 index 6abb1ca..1678f8b 100644
90640 --- a/net/sctp/socket.c
90641 +++ b/net/sctp/socket.c
90642 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90643 {
90644 struct sctp_association *asoc;
90645 struct sctp_ulpevent *event;
90646 + struct sctp_event_subscribe subscribe;
90647
90648 if (optlen > sizeof(struct sctp_event_subscribe))
90649 return -EINVAL;
90650 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90651 + if (copy_from_user(&subscribe, optval, optlen))
90652 return -EFAULT;
90653 + sctp_sk(sk)->subscribe = subscribe;
90654
90655 /*
90656 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90657 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90658 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90659 int __user *optlen)
90660 {
90661 + struct sctp_event_subscribe subscribe;
90662 +
90663 if (len <= 0)
90664 return -EINVAL;
90665 if (len > sizeof(struct sctp_event_subscribe))
90666 len = sizeof(struct sctp_event_subscribe);
90667 if (put_user(len, optlen))
90668 return -EFAULT;
90669 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90670 + subscribe = sctp_sk(sk)->subscribe;
90671 + if (copy_to_user(optval, &subscribe, len))
90672 return -EFAULT;
90673 return 0;
90674 }
90675 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90676 */
90677 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90678 {
90679 + __u32 autoclose;
90680 +
90681 /* Applicable to UDP-style socket only */
90682 if (sctp_style(sk, TCP))
90683 return -EOPNOTSUPP;
90684 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90685 len = sizeof(int);
90686 if (put_user(len, optlen))
90687 return -EFAULT;
90688 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90689 + autoclose = sctp_sk(sk)->autoclose;
90690 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90691 return -EFAULT;
90692 return 0;
90693 }
90694 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90695 */
90696 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90697 {
90698 + struct sctp_initmsg initmsg;
90699 +
90700 if (len < sizeof(struct sctp_initmsg))
90701 return -EINVAL;
90702 len = sizeof(struct sctp_initmsg);
90703 if (put_user(len, optlen))
90704 return -EFAULT;
90705 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90706 + initmsg = sctp_sk(sk)->initmsg;
90707 + if (copy_to_user(optval, &initmsg, len))
90708 return -EFAULT;
90709 return 0;
90710 }
90711 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90712 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90713 if (space_left < addrlen)
90714 return -ENOMEM;
90715 + if (addrlen > sizeof(temp) || addrlen < 0)
90716 + return -EFAULT;
90717 if (copy_to_user(to, &temp, addrlen))
90718 return -EFAULT;
90719 to += addrlen;
90720 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90721 index bf3c6e8..376d8d0 100644
90722 --- a/net/sctp/sysctl.c
90723 +++ b/net/sctp/sysctl.c
90724 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90725 {
90726 struct net *net = current->nsproxy->net_ns;
90727 char tmp[8];
90728 - ctl_table tbl;
90729 + ctl_table_no_const tbl;
90730 int ret;
90731 int changed = 0;
90732 char *none = "none";
90733 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90734
90735 int sctp_sysctl_net_register(struct net *net)
90736 {
90737 - struct ctl_table *table;
90738 + ctl_table_no_const *table;
90739 int i;
90740
90741 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90742 diff --git a/net/socket.c b/net/socket.c
90743 index 4ca1526..df83e47 100644
90744 --- a/net/socket.c
90745 +++ b/net/socket.c
90746 @@ -88,6 +88,7 @@
90747 #include <linux/magic.h>
90748 #include <linux/slab.h>
90749 #include <linux/xattr.h>
90750 +#include <linux/in.h>
90751
90752 #include <asm/uaccess.h>
90753 #include <asm/unistd.h>
90754 @@ -105,6 +106,8 @@
90755 #include <linux/sockios.h>
90756 #include <linux/atalk.h>
90757
90758 +#include <linux/grsock.h>
90759 +
90760 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90761 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90762 unsigned long nr_segs, loff_t pos);
90763 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90764 &sockfs_dentry_operations, SOCKFS_MAGIC);
90765 }
90766
90767 -static struct vfsmount *sock_mnt __read_mostly;
90768 +struct vfsmount *sock_mnt __read_mostly;
90769
90770 static struct file_system_type sock_fs_type = {
90771 .name = "sockfs",
90772 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90773 return -EAFNOSUPPORT;
90774 if (type < 0 || type >= SOCK_MAX)
90775 return -EINVAL;
90776 + if (protocol < 0)
90777 + return -EINVAL;
90778
90779 /* Compatibility.
90780
90781 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90782 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90783 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90784
90785 + if(!gr_search_socket(family, type, protocol)) {
90786 + retval = -EACCES;
90787 + goto out;
90788 + }
90789 +
90790 + if (gr_handle_sock_all(family, type, protocol)) {
90791 + retval = -EACCES;
90792 + goto out;
90793 + }
90794 +
90795 retval = sock_create(family, type, protocol, &sock);
90796 if (retval < 0)
90797 goto out;
90798 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90799 if (sock) {
90800 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90801 if (err >= 0) {
90802 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90803 + err = -EACCES;
90804 + goto error;
90805 + }
90806 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90807 + if (err)
90808 + goto error;
90809 +
90810 err = security_socket_bind(sock,
90811 (struct sockaddr *)&address,
90812 addrlen);
90813 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90814 (struct sockaddr *)
90815 &address, addrlen);
90816 }
90817 +error:
90818 fput_light(sock->file, fput_needed);
90819 }
90820 return err;
90821 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90822 if ((unsigned int)backlog > somaxconn)
90823 backlog = somaxconn;
90824
90825 + if (gr_handle_sock_server_other(sock->sk)) {
90826 + err = -EPERM;
90827 + goto error;
90828 + }
90829 +
90830 + err = gr_search_listen(sock);
90831 + if (err)
90832 + goto error;
90833 +
90834 err = security_socket_listen(sock, backlog);
90835 if (!err)
90836 err = sock->ops->listen(sock, backlog);
90837
90838 +error:
90839 fput_light(sock->file, fput_needed);
90840 }
90841 return err;
90842 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90843 newsock->type = sock->type;
90844 newsock->ops = sock->ops;
90845
90846 + if (gr_handle_sock_server_other(sock->sk)) {
90847 + err = -EPERM;
90848 + sock_release(newsock);
90849 + goto out_put;
90850 + }
90851 +
90852 + err = gr_search_accept(sock);
90853 + if (err) {
90854 + sock_release(newsock);
90855 + goto out_put;
90856 + }
90857 +
90858 /*
90859 * We don't need try_module_get here, as the listening socket (sock)
90860 * has the protocol module (sock->ops->owner) held.
90861 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90862 fd_install(newfd, newfile);
90863 err = newfd;
90864
90865 + gr_attach_curr_ip(newsock->sk);
90866 +
90867 out_put:
90868 fput_light(sock->file, fput_needed);
90869 out:
90870 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90871 int, addrlen)
90872 {
90873 struct socket *sock;
90874 + struct sockaddr *sck;
90875 struct sockaddr_storage address;
90876 int err, fput_needed;
90877
90878 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90879 if (err < 0)
90880 goto out_put;
90881
90882 + sck = (struct sockaddr *)&address;
90883 +
90884 + if (gr_handle_sock_client(sck)) {
90885 + err = -EACCES;
90886 + goto out_put;
90887 + }
90888 +
90889 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90890 + if (err)
90891 + goto out_put;
90892 +
90893 err =
90894 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90895 if (err)
90896 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90897 * the protocol.
90898 */
90899
90900 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90901 +
90902 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90903 unsigned int, flags, struct sockaddr __user *, addr,
90904 int, addr_len)
90905 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90906 struct socket *sock;
90907 struct iovec iov;
90908 struct msghdr msg;
90909 - struct sockaddr_storage address;
90910 + struct sockaddr_storage address = { };
90911 int err, err2;
90912 int fput_needed;
90913
90914 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90915 * checking falls down on this.
90916 */
90917 if (copy_from_user(ctl_buf,
90918 - (void __user __force *)msg_sys->msg_control,
90919 + (void __force_user *)msg_sys->msg_control,
90920 ctl_len))
90921 goto out_freectl;
90922 msg_sys->msg_control = ctl_buf;
90923 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90924 int err, total_len, len;
90925
90926 /* kernel mode address */
90927 - struct sockaddr_storage addr;
90928 + struct sockaddr_storage addr = { };
90929
90930 /* user mode address pointers */
90931 struct sockaddr __user *uaddr;
90932 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90933 * kernel msghdr to use the kernel address space)
90934 */
90935
90936 - uaddr = (__force void __user *)msg_sys->msg_name;
90937 + uaddr = (void __force_user *)msg_sys->msg_name;
90938 uaddr_len = COMPAT_NAMELEN(msg);
90939 if (MSG_CMSG_COMPAT & flags) {
90940 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90941 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90942 old_fs = get_fs();
90943 set_fs(KERNEL_DS);
90944 err = dev_ioctl(net, cmd,
90945 - (struct ifreq __user __force *) &kifr);
90946 + (struct ifreq __force_user *) &kifr);
90947 set_fs(old_fs);
90948
90949 return err;
90950 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90951
90952 old_fs = get_fs();
90953 set_fs(KERNEL_DS);
90954 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90955 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90956 set_fs(old_fs);
90957
90958 if (cmd == SIOCGIFMAP && !err) {
90959 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90960 ret |= __get_user(rtdev, &(ur4->rt_dev));
90961 if (rtdev) {
90962 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90963 - r4.rt_dev = (char __user __force *)devname;
90964 + r4.rt_dev = (char __force_user *)devname;
90965 devname[15] = 0;
90966 } else
90967 r4.rt_dev = NULL;
90968 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90969 int __user *uoptlen;
90970 int err;
90971
90972 - uoptval = (char __user __force *) optval;
90973 - uoptlen = (int __user __force *) optlen;
90974 + uoptval = (char __force_user *) optval;
90975 + uoptlen = (int __force_user *) optlen;
90976
90977 set_fs(KERNEL_DS);
90978 if (level == SOL_SOCKET)
90979 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90980 char __user *uoptval;
90981 int err;
90982
90983 - uoptval = (char __user __force *) optval;
90984 + uoptval = (char __force_user *) optval;
90985
90986 set_fs(KERNEL_DS);
90987 if (level == SOL_SOCKET)
90988 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90989 index 5a750b9..ca5d7af 100644
90990 --- a/net/sunrpc/clnt.c
90991 +++ b/net/sunrpc/clnt.c
90992 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
90993 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90994
90995 /* Increment call count */
90996 - task->tk_msg.rpc_proc->p_count++;
90997 + pax_open_kernel();
90998 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90999 + pax_close_kernel();
91000 clnt->cl_stats->rpccnt++;
91001 task->tk_action = call_reserve;
91002 }
91003 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
91004 index 5356b12..c0f4c29 100644
91005 --- a/net/sunrpc/sched.c
91006 +++ b/net/sunrpc/sched.c
91007 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
91008 #ifdef RPC_DEBUG
91009 static void rpc_task_set_debuginfo(struct rpc_task *task)
91010 {
91011 - static atomic_t rpc_pid;
91012 + static atomic_unchecked_t rpc_pid;
91013
91014 - task->tk_pid = atomic_inc_return(&rpc_pid);
91015 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
91016 }
91017 #else
91018 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
91019 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
91020 index 89a588b..678ed90 100644
91021 --- a/net/sunrpc/svc.c
91022 +++ b/net/sunrpc/svc.c
91023 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
91024
91025 __module_get(serv->sv_module);
91026 task = kthread_create_on_node(serv->sv_function, rqstp,
91027 - node, serv->sv_name);
91028 + node, "%s", serv->sv_name);
91029 if (IS_ERR(task)) {
91030 error = PTR_ERR(task);
91031 module_put(serv->sv_module);
91032 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
91033 svc_putnl(resv, RPC_SUCCESS);
91034
91035 /* Bump per-procedure stats counter */
91036 - procp->pc_count++;
91037 + pax_open_kernel();
91038 + (*(unsigned int *)&procp->pc_count)++;
91039 + pax_close_kernel();
91040
91041 /* Initialize storage for argp and resp */
91042 memset(rqstp->rq_argp, 0, procp->pc_argsize);
91043 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
91044 index 8343737..677025e 100644
91045 --- a/net/sunrpc/xprtrdma/svc_rdma.c
91046 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
91047 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
91048 static unsigned int min_max_inline = 4096;
91049 static unsigned int max_max_inline = 65536;
91050
91051 -atomic_t rdma_stat_recv;
91052 -atomic_t rdma_stat_read;
91053 -atomic_t rdma_stat_write;
91054 -atomic_t rdma_stat_sq_starve;
91055 -atomic_t rdma_stat_rq_starve;
91056 -atomic_t rdma_stat_rq_poll;
91057 -atomic_t rdma_stat_rq_prod;
91058 -atomic_t rdma_stat_sq_poll;
91059 -atomic_t rdma_stat_sq_prod;
91060 +atomic_unchecked_t rdma_stat_recv;
91061 +atomic_unchecked_t rdma_stat_read;
91062 +atomic_unchecked_t rdma_stat_write;
91063 +atomic_unchecked_t rdma_stat_sq_starve;
91064 +atomic_unchecked_t rdma_stat_rq_starve;
91065 +atomic_unchecked_t rdma_stat_rq_poll;
91066 +atomic_unchecked_t rdma_stat_rq_prod;
91067 +atomic_unchecked_t rdma_stat_sq_poll;
91068 +atomic_unchecked_t rdma_stat_sq_prod;
91069
91070 /* Temporary NFS request map and context caches */
91071 struct kmem_cache *svc_rdma_map_cachep;
91072 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
91073 len -= *ppos;
91074 if (len > *lenp)
91075 len = *lenp;
91076 - if (len && copy_to_user(buffer, str_buf, len))
91077 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
91078 return -EFAULT;
91079 *lenp = len;
91080 *ppos += len;
91081 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
91082 {
91083 .procname = "rdma_stat_read",
91084 .data = &rdma_stat_read,
91085 - .maxlen = sizeof(atomic_t),
91086 + .maxlen = sizeof(atomic_unchecked_t),
91087 .mode = 0644,
91088 .proc_handler = read_reset_stat,
91089 },
91090 {
91091 .procname = "rdma_stat_recv",
91092 .data = &rdma_stat_recv,
91093 - .maxlen = sizeof(atomic_t),
91094 + .maxlen = sizeof(atomic_unchecked_t),
91095 .mode = 0644,
91096 .proc_handler = read_reset_stat,
91097 },
91098 {
91099 .procname = "rdma_stat_write",
91100 .data = &rdma_stat_write,
91101 - .maxlen = sizeof(atomic_t),
91102 + .maxlen = sizeof(atomic_unchecked_t),
91103 .mode = 0644,
91104 .proc_handler = read_reset_stat,
91105 },
91106 {
91107 .procname = "rdma_stat_sq_starve",
91108 .data = &rdma_stat_sq_starve,
91109 - .maxlen = sizeof(atomic_t),
91110 + .maxlen = sizeof(atomic_unchecked_t),
91111 .mode = 0644,
91112 .proc_handler = read_reset_stat,
91113 },
91114 {
91115 .procname = "rdma_stat_rq_starve",
91116 .data = &rdma_stat_rq_starve,
91117 - .maxlen = sizeof(atomic_t),
91118 + .maxlen = sizeof(atomic_unchecked_t),
91119 .mode = 0644,
91120 .proc_handler = read_reset_stat,
91121 },
91122 {
91123 .procname = "rdma_stat_rq_poll",
91124 .data = &rdma_stat_rq_poll,
91125 - .maxlen = sizeof(atomic_t),
91126 + .maxlen = sizeof(atomic_unchecked_t),
91127 .mode = 0644,
91128 .proc_handler = read_reset_stat,
91129 },
91130 {
91131 .procname = "rdma_stat_rq_prod",
91132 .data = &rdma_stat_rq_prod,
91133 - .maxlen = sizeof(atomic_t),
91134 + .maxlen = sizeof(atomic_unchecked_t),
91135 .mode = 0644,
91136 .proc_handler = read_reset_stat,
91137 },
91138 {
91139 .procname = "rdma_stat_sq_poll",
91140 .data = &rdma_stat_sq_poll,
91141 - .maxlen = sizeof(atomic_t),
91142 + .maxlen = sizeof(atomic_unchecked_t),
91143 .mode = 0644,
91144 .proc_handler = read_reset_stat,
91145 },
91146 {
91147 .procname = "rdma_stat_sq_prod",
91148 .data = &rdma_stat_sq_prod,
91149 - .maxlen = sizeof(atomic_t),
91150 + .maxlen = sizeof(atomic_unchecked_t),
91151 .mode = 0644,
91152 .proc_handler = read_reset_stat,
91153 },
91154 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91155 index 0ce7552..d074459 100644
91156 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91157 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91158 @@ -501,7 +501,7 @@ next_sge:
91159 svc_rdma_put_context(ctxt, 0);
91160 goto out;
91161 }
91162 - atomic_inc(&rdma_stat_read);
91163 + atomic_inc_unchecked(&rdma_stat_read);
91164
91165 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91166 chl_map->ch[ch_no].count -= read_wr.num_sge;
91167 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91168 dto_q);
91169 list_del_init(&ctxt->dto_q);
91170 } else {
91171 - atomic_inc(&rdma_stat_rq_starve);
91172 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91173 clear_bit(XPT_DATA, &xprt->xpt_flags);
91174 ctxt = NULL;
91175 }
91176 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91177 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91178 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91179 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91180 - atomic_inc(&rdma_stat_recv);
91181 + atomic_inc_unchecked(&rdma_stat_recv);
91182
91183 /* Build up the XDR from the receive buffers. */
91184 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91185 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91186 index c1d124d..acfc59e 100644
91187 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91188 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91189 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91190 write_wr.wr.rdma.remote_addr = to;
91191
91192 /* Post It */
91193 - atomic_inc(&rdma_stat_write);
91194 + atomic_inc_unchecked(&rdma_stat_write);
91195 if (svc_rdma_send(xprt, &write_wr))
91196 goto err;
91197 return 0;
91198 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91199 index 62e4f9b..dd3f2d7 100644
91200 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
91201 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91202 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91203 return;
91204
91205 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
91206 - atomic_inc(&rdma_stat_rq_poll);
91207 + atomic_inc_unchecked(&rdma_stat_rq_poll);
91208
91209 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
91210 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
91211 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91212 }
91213
91214 if (ctxt)
91215 - atomic_inc(&rdma_stat_rq_prod);
91216 + atomic_inc_unchecked(&rdma_stat_rq_prod);
91217
91218 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
91219 /*
91220 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91221 return;
91222
91223 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
91224 - atomic_inc(&rdma_stat_sq_poll);
91225 + atomic_inc_unchecked(&rdma_stat_sq_poll);
91226 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
91227 if (wc.status != IB_WC_SUCCESS)
91228 /* Close the transport */
91229 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91230 }
91231
91232 if (ctxt)
91233 - atomic_inc(&rdma_stat_sq_prod);
91234 + atomic_inc_unchecked(&rdma_stat_sq_prod);
91235 }
91236
91237 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
91238 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
91239 spin_lock_bh(&xprt->sc_lock);
91240 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
91241 spin_unlock_bh(&xprt->sc_lock);
91242 - atomic_inc(&rdma_stat_sq_starve);
91243 + atomic_inc_unchecked(&rdma_stat_sq_starve);
91244
91245 /* See if we can opportunistically reap SQ WR to make room */
91246 sq_cq_reap(xprt);
91247 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
91248 index 9bc6db0..47ac8c0 100644
91249 --- a/net/sysctl_net.c
91250 +++ b/net/sysctl_net.c
91251 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
91252 kgid_t root_gid = make_kgid(net->user_ns, 0);
91253
91254 /* Allow network administrator to have same access as root. */
91255 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
91256 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
91257 uid_eq(root_uid, current_uid())) {
91258 int mode = (table->mode >> 6) & 7;
91259 return (mode << 6) | (mode << 3) | mode;
91260 diff --git a/net/tipc/link.c b/net/tipc/link.c
91261 index a80feee..2bbbe70 100644
91262 --- a/net/tipc/link.c
91263 +++ b/net/tipc/link.c
91264 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
91265 struct tipc_msg fragm_hdr;
91266 struct sk_buff *buf, *buf_chain, *prev;
91267 u32 fragm_crs, fragm_rest, hsz, sect_rest;
91268 - const unchar *sect_crs;
91269 + const unchar __user *sect_crs;
91270 int curr_sect;
91271 u32 fragm_no;
91272
91273 @@ -1242,7 +1242,7 @@ again:
91274
91275 if (!sect_rest) {
91276 sect_rest = msg_sect[++curr_sect].iov_len;
91277 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
91278 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
91279 }
91280
91281 if (sect_rest < fragm_rest)
91282 @@ -1261,7 +1261,7 @@ error:
91283 }
91284 } else
91285 skb_copy_to_linear_data_offset(buf, fragm_crs,
91286 - sect_crs, sz);
91287 + (const void __force_kernel *)sect_crs, sz);
91288 sect_crs += sz;
91289 sect_rest -= sz;
91290 fragm_crs += sz;
91291 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
91292 index f2db8a8..9245aa4 100644
91293 --- a/net/tipc/msg.c
91294 +++ b/net/tipc/msg.c
91295 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
91296 msg_sect[cnt].iov_len);
91297 else
91298 skb_copy_to_linear_data_offset(*buf, pos,
91299 - msg_sect[cnt].iov_base,
91300 + (const void __force_kernel *)msg_sect[cnt].iov_base,
91301 msg_sect[cnt].iov_len);
91302 pos += msg_sect[cnt].iov_len;
91303 }
91304 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
91305 index 6b42d47..2ac24d5 100644
91306 --- a/net/tipc/subscr.c
91307 +++ b/net/tipc/subscr.c
91308 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
91309 {
91310 struct iovec msg_sect;
91311
91312 - msg_sect.iov_base = (void *)&sub->evt;
91313 + msg_sect.iov_base = (void __force_user *)&sub->evt;
91314 msg_sect.iov_len = sizeof(struct tipc_event);
91315
91316 sub->evt.event = htohl(event, sub->swap);
91317 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
91318 index 826e099..4fa8c93 100644
91319 --- a/net/unix/af_unix.c
91320 +++ b/net/unix/af_unix.c
91321 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
91322 err = -ECONNREFUSED;
91323 if (!S_ISSOCK(inode->i_mode))
91324 goto put_fail;
91325 +
91326 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
91327 + err = -EACCES;
91328 + goto put_fail;
91329 + }
91330 +
91331 u = unix_find_socket_byinode(inode);
91332 if (!u)
91333 goto put_fail;
91334 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
91335 if (u) {
91336 struct dentry *dentry;
91337 dentry = unix_sk(u)->path.dentry;
91338 +
91339 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
91340 + err = -EPERM;
91341 + sock_put(u);
91342 + goto fail;
91343 + }
91344 +
91345 if (dentry)
91346 touch_atime(&unix_sk(u)->path);
91347 } else
91348 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
91349 */
91350 err = security_path_mknod(&path, dentry, mode, 0);
91351 if (!err) {
91352 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
91353 + err = -EACCES;
91354 + goto out;
91355 + }
91356 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
91357 if (!err) {
91358 res->mnt = mntget(path.mnt);
91359 res->dentry = dget(dentry);
91360 + gr_handle_create(dentry, path.mnt);
91361 }
91362 }
91363 +out:
91364 done_path_create(&path, dentry);
91365 return err;
91366 }
91367 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91368 seq_puts(seq, "Num RefCount Protocol Flags Type St "
91369 "Inode Path\n");
91370 else {
91371 - struct sock *s = v;
91372 + struct sock *s = v, *peer;
91373 struct unix_sock *u = unix_sk(s);
91374 unix_state_lock(s);
91375 + peer = unix_peer(s);
91376 + unix_state_unlock(s);
91377 +
91378 + unix_state_double_lock(s, peer);
91379
91380 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91381 s,
91382 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91383 }
91384 for ( ; i < len; i++)
91385 seq_putc(seq, u->addr->name->sun_path[i]);
91386 - }
91387 - unix_state_unlock(s);
91388 + } else if (peer)
91389 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91390 +
91391 + unix_state_double_unlock(s, peer);
91392 seq_putc(seq, '\n');
91393 }
91394
91395 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91396 index 8800604..0526440 100644
91397 --- a/net/unix/sysctl_net_unix.c
91398 +++ b/net/unix/sysctl_net_unix.c
91399 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91400
91401 int __net_init unix_sysctl_register(struct net *net)
91402 {
91403 - struct ctl_table *table;
91404 + ctl_table_no_const *table;
91405
91406 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91407 if (table == NULL)
91408 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91409 index c8717c1..08539f5 100644
91410 --- a/net/wireless/wext-core.c
91411 +++ b/net/wireless/wext-core.c
91412 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91413 */
91414
91415 /* Support for very large requests */
91416 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91417 - (user_length > descr->max_tokens)) {
91418 + if (user_length > descr->max_tokens) {
91419 /* Allow userspace to GET more than max so
91420 * we can support any size GET requests.
91421 * There is still a limit : -ENOMEM.
91422 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91423 }
91424 }
91425
91426 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91427 - /*
91428 - * If this is a GET, but not NOMAX, it means that the extra
91429 - * data is not bounded by userspace, but by max_tokens. Thus
91430 - * set the length to max_tokens. This matches the extra data
91431 - * allocation.
91432 - * The driver should fill it with the number of tokens it
91433 - * provided, and it may check iwp->length rather than having
91434 - * knowledge of max_tokens. If the driver doesn't change the
91435 - * iwp->length, this ioctl just copies back max_token tokens
91436 - * filled with zeroes. Hopefully the driver isn't claiming
91437 - * them to be valid data.
91438 - */
91439 - iwp->length = descr->max_tokens;
91440 - }
91441 -
91442 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91443
91444 iwp->length += essid_compat;
91445 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91446 index ea970b8..c68edb9f 100644
91447 --- a/net/xfrm/xfrm_policy.c
91448 +++ b/net/xfrm/xfrm_policy.c
91449 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91450 {
91451 policy->walk.dead = 1;
91452
91453 - atomic_inc(&policy->genid);
91454 + atomic_inc_unchecked(&policy->genid);
91455
91456 del_timer(&policy->polq.hold_timer);
91457 xfrm_queue_purge(&policy->polq.hold_queue);
91458 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91459 hlist_add_head(&policy->bydst, chain);
91460 xfrm_pol_hold(policy);
91461 net->xfrm.policy_count[dir]++;
91462 - atomic_inc(&flow_cache_genid);
91463 + atomic_inc_unchecked(&flow_cache_genid);
91464 rt_genid_bump(net);
91465 if (delpol) {
91466 xfrm_policy_requeue(delpol, policy);
91467 @@ -1629,7 +1629,7 @@ free_dst:
91468 goto out;
91469 }
91470
91471 -static int inline
91472 +static inline int
91473 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91474 {
91475 if (!*target) {
91476 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91477 return 0;
91478 }
91479
91480 -static int inline
91481 +static inline int
91482 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91483 {
91484 #ifdef CONFIG_XFRM_SUB_POLICY
91485 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91486 #endif
91487 }
91488
91489 -static int inline
91490 +static inline int
91491 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91492 {
91493 #ifdef CONFIG_XFRM_SUB_POLICY
91494 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91495
91496 xdst->num_pols = num_pols;
91497 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91498 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91499 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91500
91501 return xdst;
91502 }
91503 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91504 if (xdst->xfrm_genid != dst->xfrm->genid)
91505 return 0;
91506 if (xdst->num_pols > 0 &&
91507 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91508 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91509 return 0;
91510
91511 mtu = dst_mtu(dst->child);
91512 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91513 dst_ops->link_failure = xfrm_link_failure;
91514 if (likely(dst_ops->neigh_lookup == NULL))
91515 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91516 - if (likely(afinfo->garbage_collect == NULL))
91517 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91518 + if (likely(afinfo->garbage_collect == NULL)) {
91519 + pax_open_kernel();
91520 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91521 + pax_close_kernel();
91522 + }
91523 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91524 }
91525 spin_unlock(&xfrm_policy_afinfo_lock);
91526 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91527 dst_ops->check = NULL;
91528 dst_ops->negative_advice = NULL;
91529 dst_ops->link_failure = NULL;
91530 - afinfo->garbage_collect = NULL;
91531 + pax_open_kernel();
91532 + *(void **)&afinfo->garbage_collect = NULL;
91533 + pax_close_kernel();
91534 }
91535 return err;
91536 }
91537 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91538 sizeof(pol->xfrm_vec[i].saddr));
91539 pol->xfrm_vec[i].encap_family = mp->new_family;
91540 /* flush bundles */
91541 - atomic_inc(&pol->genid);
91542 + atomic_inc_unchecked(&pol->genid);
91543 }
91544 }
91545
91546 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91547 index 78f66fa..9286768 100644
91548 --- a/net/xfrm/xfrm_state.c
91549 +++ b/net/xfrm/xfrm_state.c
91550 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91551
91552 if (unlikely(afinfo == NULL))
91553 return -EAFNOSUPPORT;
91554 - typemap = afinfo->type_map;
91555 + typemap = (const struct xfrm_type **)afinfo->type_map;
91556 spin_lock_bh(&xfrm_type_lock);
91557
91558 - if (likely(typemap[type->proto] == NULL))
91559 + if (likely(typemap[type->proto] == NULL)) {
91560 + pax_open_kernel();
91561 typemap[type->proto] = type;
91562 - else
91563 + pax_close_kernel();
91564 + } else
91565 err = -EEXIST;
91566 spin_unlock_bh(&xfrm_type_lock);
91567 xfrm_state_put_afinfo(afinfo);
91568 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91569
91570 if (unlikely(afinfo == NULL))
91571 return -EAFNOSUPPORT;
91572 - typemap = afinfo->type_map;
91573 + typemap = (const struct xfrm_type **)afinfo->type_map;
91574 spin_lock_bh(&xfrm_type_lock);
91575
91576 if (unlikely(typemap[type->proto] != type))
91577 err = -ENOENT;
91578 - else
91579 + else {
91580 + pax_open_kernel();
91581 typemap[type->proto] = NULL;
91582 + pax_close_kernel();
91583 + }
91584 spin_unlock_bh(&xfrm_type_lock);
91585 xfrm_state_put_afinfo(afinfo);
91586 return err;
91587 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91588 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91589 {
91590 struct xfrm_state_afinfo *afinfo;
91591 - const struct xfrm_type **typemap;
91592 const struct xfrm_type *type;
91593 int modload_attempted = 0;
91594
91595 @@ -222,9 +226,8 @@ retry:
91596 afinfo = xfrm_state_get_afinfo(family);
91597 if (unlikely(afinfo == NULL))
91598 return NULL;
91599 - typemap = afinfo->type_map;
91600
91601 - type = typemap[proto];
91602 + type = afinfo->type_map[proto];
91603 if (unlikely(type && !try_module_get(type->owner)))
91604 type = NULL;
91605 if (!type && !modload_attempted) {
91606 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91607 return -EAFNOSUPPORT;
91608
91609 err = -EEXIST;
91610 - modemap = afinfo->mode_map;
91611 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91612 spin_lock_bh(&xfrm_mode_lock);
91613 if (modemap[mode->encap])
91614 goto out;
91615 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91616 if (!try_module_get(afinfo->owner))
91617 goto out;
91618
91619 - mode->afinfo = afinfo;
91620 + pax_open_kernel();
91621 + *(const void **)&mode->afinfo = afinfo;
91622 modemap[mode->encap] = mode;
91623 + pax_close_kernel();
91624 err = 0;
91625
91626 out:
91627 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91628 return -EAFNOSUPPORT;
91629
91630 err = -ENOENT;
91631 - modemap = afinfo->mode_map;
91632 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91633 spin_lock_bh(&xfrm_mode_lock);
91634 if (likely(modemap[mode->encap] == mode)) {
91635 + pax_open_kernel();
91636 modemap[mode->encap] = NULL;
91637 + pax_close_kernel();
91638 module_put(mode->afinfo->owner);
91639 err = 0;
91640 }
91641 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91642 index 05a6e3d..6716ec9 100644
91643 --- a/net/xfrm/xfrm_sysctl.c
91644 +++ b/net/xfrm/xfrm_sysctl.c
91645 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91646
91647 int __net_init xfrm_sysctl_init(struct net *net)
91648 {
91649 - struct ctl_table *table;
91650 + ctl_table_no_const *table;
91651
91652 __xfrm_sysctl_init(net);
91653
91654 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91655 index d5d859c..781cbcb 100644
91656 --- a/scripts/Makefile.build
91657 +++ b/scripts/Makefile.build
91658 @@ -111,7 +111,7 @@ endif
91659 endif
91660
91661 # Do not include host rules unless needed
91662 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91663 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91664 include scripts/Makefile.host
91665 endif
91666
91667 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91668 index 686cb0d..9d653bf 100644
91669 --- a/scripts/Makefile.clean
91670 +++ b/scripts/Makefile.clean
91671 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91672 __clean-files := $(extra-y) $(always) \
91673 $(targets) $(clean-files) \
91674 $(host-progs) \
91675 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91676 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91677 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91678
91679 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91680
91681 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91682 index 1ac414f..38575f7 100644
91683 --- a/scripts/Makefile.host
91684 +++ b/scripts/Makefile.host
91685 @@ -31,6 +31,8 @@
91686 # Note: Shared libraries consisting of C++ files are not supported
91687
91688 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91689 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91690 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91691
91692 # C code
91693 # Executables compiled from a single .c file
91694 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91695 # Shared libaries (only .c supported)
91696 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91697 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91698 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91699 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91700 # Remove .so files from "xxx-objs"
91701 host-cobjs := $(filter-out %.so,$(host-cobjs))
91702 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91703
91704 -#Object (.o) files used by the shared libaries
91705 +# Object (.o) files used by the shared libaries
91706 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91707 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91708
91709 # output directory for programs/.o files
91710 # hostprogs-y := tools/build may have been specified. Retrieve directory
91711 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91712 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91713 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91714 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91715 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91716 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91717 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91718 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91719
91720 obj-dirs += $(host-objdirs)
91721 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91722 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91723 $(call if_changed_dep,host-cshobjs)
91724
91725 +# Compile .c file, create position independent .o file
91726 +# host-cxxshobjs -> .o
91727 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91728 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91729 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91730 + $(call if_changed_dep,host-cxxshobjs)
91731 +
91732 # Link a shared library, based on position independent .o files
91733 # *.o -> .so shared library (host-cshlib)
91734 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91735 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91736 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91737 $(call if_changed,host-cshlib)
91738
91739 +# Link a shared library, based on position independent .o files
91740 +# *.o -> .so shared library (host-cxxshlib)
91741 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91742 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91743 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91744 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91745 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91746 + $(call if_changed,host-cxxshlib)
91747 +
91748 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91749 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91750 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91751
91752 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91753 index 078fe1d..fbdb363 100644
91754 --- a/scripts/basic/fixdep.c
91755 +++ b/scripts/basic/fixdep.c
91756 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91757 /*
91758 * Lookup a value in the configuration string.
91759 */
91760 -static int is_defined_config(const char *name, int len, unsigned int hash)
91761 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91762 {
91763 struct item *aux;
91764
91765 @@ -211,10 +211,10 @@ static void clear_config(void)
91766 /*
91767 * Record the use of a CONFIG_* word.
91768 */
91769 -static void use_config(const char *m, int slen)
91770 +static void use_config(const char *m, unsigned int slen)
91771 {
91772 unsigned int hash = strhash(m, slen);
91773 - int c, i;
91774 + unsigned int c, i;
91775
91776 if (is_defined_config(m, slen, hash))
91777 return;
91778 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91779
91780 static void parse_config_file(const char *map, size_t len)
91781 {
91782 - const int *end = (const int *) (map + len);
91783 + const unsigned int *end = (const unsigned int *) (map + len);
91784 /* start at +1, so that p can never be < map */
91785 - const int *m = (const int *) map + 1;
91786 + const unsigned int *m = (const unsigned int *) map + 1;
91787 const char *p, *q;
91788
91789 for (; m < end; m++) {
91790 @@ -435,7 +435,7 @@ static void print_deps(void)
91791 static void traps(void)
91792 {
91793 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91794 - int *p = (int *)test;
91795 + unsigned int *p = (unsigned int *)test;
91796
91797 if (*p != INT_CONF) {
91798 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91799 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91800 new file mode 100644
91801 index 0000000..5e0222d
91802 --- /dev/null
91803 +++ b/scripts/gcc-plugin.sh
91804 @@ -0,0 +1,17 @@
91805 +#!/bin/bash
91806 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91807 +#include "gcc-plugin.h"
91808 +#include "tree.h"
91809 +#include "tm.h"
91810 +#include "rtl.h"
91811 +#ifdef ENABLE_BUILD_WITH_CXX
91812 +#warning $2
91813 +#else
91814 +#warning $1
91815 +#endif
91816 +EOF`
91817 +if [ $? -eq 0 ]
91818 +then
91819 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91820 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91821 +fi
91822 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
91823 index 643764f..c437ded 100644
91824 --- a/scripts/headers_install.sh
91825 +++ b/scripts/headers_install.sh
91826 @@ -29,6 +29,7 @@ do
91827 FILE="$(basename "$i")"
91828 sed -r \
91829 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
91830 + -e 's/__intentional_overflow\([ \t,0-9]*\)//g' \
91831 -e 's/__attribute_const__([ \t]|$)/\1/g' \
91832 -e 's@^#include <linux/compiler.h>@@' \
91833 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
91834 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91835 index 0149949..d482a0d 100644
91836 --- a/scripts/link-vmlinux.sh
91837 +++ b/scripts/link-vmlinux.sh
91838 @@ -158,7 +158,7 @@ else
91839 fi;
91840
91841 # final build of init/
91842 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91843 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91844
91845 kallsymso=""
91846 kallsyms_vmlinux=""
91847 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91848 index 45f9a33..e4194b3 100644
91849 --- a/scripts/mod/file2alias.c
91850 +++ b/scripts/mod/file2alias.c
91851 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91852 unsigned long size, unsigned long id_size,
91853 void *symval)
91854 {
91855 - int i;
91856 + unsigned int i;
91857
91858 if (size % id_size || size < id_size) {
91859 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91860 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91861 /* USB is special because the bcdDevice can be matched against a numeric range */
91862 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91863 static void do_usb_entry(void *symval,
91864 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91865 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91866 unsigned char range_lo, unsigned char range_hi,
91867 unsigned char max, struct module *mod)
91868 {
91869 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91870 {
91871 unsigned int devlo, devhi;
91872 unsigned char chi, clo, max;
91873 - int ndigits;
91874 + unsigned int ndigits;
91875
91876 DEF_FIELD(symval, usb_device_id, match_flags);
91877 DEF_FIELD(symval, usb_device_id, idVendor);
91878 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91879 for (i = 0; i < count; i++) {
91880 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91881 char acpi_id[sizeof(*id)];
91882 - int j;
91883 + unsigned int j;
91884
91885 buf_printf(&mod->dev_table_buf,
91886 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91887 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91888
91889 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91890 const char *id = (char *)(*devs)[j].id;
91891 - int i2, j2;
91892 + unsigned int i2, j2;
91893 int dup = 0;
91894
91895 if (!id[0])
91896 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91897 /* add an individual alias for every device entry */
91898 if (!dup) {
91899 char acpi_id[PNP_ID_LEN];
91900 - int k;
91901 + unsigned int k;
91902
91903 buf_printf(&mod->dev_table_buf,
91904 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91905 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91906 static int do_dmi_entry(const char *filename, void *symval,
91907 char *alias)
91908 {
91909 - int i, j;
91910 + unsigned int i, j;
91911 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91912 sprintf(alias, "dmi*");
91913
91914 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91915 index a4be8e1..6e8a5fb 100644
91916 --- a/scripts/mod/modpost.c
91917 +++ b/scripts/mod/modpost.c
91918 @@ -933,6 +933,7 @@ enum mismatch {
91919 ANY_INIT_TO_ANY_EXIT,
91920 ANY_EXIT_TO_ANY_INIT,
91921 EXPORT_TO_INIT_EXIT,
91922 + DATA_TO_TEXT
91923 };
91924
91925 struct sectioncheck {
91926 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
91927 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91928 .mismatch = EXPORT_TO_INIT_EXIT,
91929 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91930 +},
91931 +/* Do not reference code from writable data */
91932 +{
91933 + .fromsec = { DATA_SECTIONS, NULL },
91934 + .tosec = { TEXT_SECTIONS, NULL },
91935 + .mismatch = DATA_TO_TEXT
91936 }
91937 };
91938
91939 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91940 continue;
91941 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91942 continue;
91943 - if (sym->st_value == addr)
91944 - return sym;
91945 /* Find a symbol nearby - addr are maybe negative */
91946 d = sym->st_value - addr;
91947 + if (d == 0)
91948 + return sym;
91949 if (d < 0)
91950 d = addr - sym->st_value;
91951 if (d < distance) {
91952 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
91953 tosym, prl_to, prl_to, tosym);
91954 free(prl_to);
91955 break;
91956 + case DATA_TO_TEXT:
91957 +#if 0
91958 + fprintf(stderr,
91959 + "The %s %s:%s references\n"
91960 + "the %s %s:%s%s\n",
91961 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91962 +#endif
91963 + break;
91964 }
91965 fprintf(stderr, "\n");
91966 }
91967 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91968 static void check_sec_ref(struct module *mod, const char *modname,
91969 struct elf_info *elf)
91970 {
91971 - int i;
91972 + unsigned int i;
91973 Elf_Shdr *sechdrs = elf->sechdrs;
91974
91975 /* Walk through all sections */
91976 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91977 va_end(ap);
91978 }
91979
91980 -void buf_write(struct buffer *buf, const char *s, int len)
91981 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91982 {
91983 if (buf->size - buf->pos < len) {
91984 buf->size += len + SZ;
91985 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91986 if (fstat(fileno(file), &st) < 0)
91987 goto close_write;
91988
91989 - if (st.st_size != b->pos)
91990 + if (st.st_size != (off_t)b->pos)
91991 goto close_write;
91992
91993 tmp = NOFAIL(malloc(b->pos));
91994 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91995 index 51207e4..f7d603d 100644
91996 --- a/scripts/mod/modpost.h
91997 +++ b/scripts/mod/modpost.h
91998 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91999
92000 struct buffer {
92001 char *p;
92002 - int pos;
92003 - int size;
92004 + unsigned int pos;
92005 + unsigned int size;
92006 };
92007
92008 void __attribute__((format(printf, 2, 3)))
92009 buf_printf(struct buffer *buf, const char *fmt, ...);
92010
92011 void
92012 -buf_write(struct buffer *buf, const char *s, int len);
92013 +buf_write(struct buffer *buf, const char *s, unsigned int len);
92014
92015 struct module {
92016 struct module *next;
92017 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
92018 index 9dfcd6d..099068e 100644
92019 --- a/scripts/mod/sumversion.c
92020 +++ b/scripts/mod/sumversion.c
92021 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
92022 goto out;
92023 }
92024
92025 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
92026 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
92027 warn("writing sum in %s failed: %s\n",
92028 filename, strerror(errno));
92029 goto out;
92030 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
92031 index acb8650..b8c5f02 100644
92032 --- a/scripts/package/builddeb
92033 +++ b/scripts/package/builddeb
92034 @@ -246,6 +246,7 @@ fi
92035 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
92036 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
92037 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
92038 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
92039 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
92040 mkdir -p "$destdir"
92041 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
92042 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
92043 index 68bb4ef..2f419e1 100644
92044 --- a/scripts/pnmtologo.c
92045 +++ b/scripts/pnmtologo.c
92046 @@ -244,14 +244,14 @@ static void write_header(void)
92047 fprintf(out, " * Linux logo %s\n", logoname);
92048 fputs(" */\n\n", out);
92049 fputs("#include <linux/linux_logo.h>\n\n", out);
92050 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
92051 + fprintf(out, "static unsigned char %s_data[] = {\n",
92052 logoname);
92053 }
92054
92055 static void write_footer(void)
92056 {
92057 fputs("\n};\n\n", out);
92058 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
92059 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
92060 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
92061 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
92062 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
92063 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
92064 fputs("\n};\n\n", out);
92065
92066 /* write logo clut */
92067 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
92068 + fprintf(out, "static unsigned char %s_clut[] = {\n",
92069 logoname);
92070 write_hex_cnt = 0;
92071 for (i = 0; i < logo_clutsize; i++) {
92072 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
92073 index f5eb43d..1814de8 100644
92074 --- a/scripts/sortextable.h
92075 +++ b/scripts/sortextable.h
92076 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
92077 const char *secstrtab;
92078 const char *strtab;
92079 char *extab_image;
92080 - int extab_index = 0;
92081 - int i;
92082 - int idx;
92083 + unsigned int extab_index = 0;
92084 + unsigned int i;
92085 + unsigned int idx;
92086
92087 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
92088 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
92089 diff --git a/security/Kconfig b/security/Kconfig
92090 index e9c6ac7..66bf8e9 100644
92091 --- a/security/Kconfig
92092 +++ b/security/Kconfig
92093 @@ -4,6 +4,945 @@
92094
92095 menu "Security options"
92096
92097 +menu "Grsecurity"
92098 +
92099 + config ARCH_TRACK_EXEC_LIMIT
92100 + bool
92101 +
92102 + config PAX_KERNEXEC_PLUGIN
92103 + bool
92104 +
92105 + config PAX_PER_CPU_PGD
92106 + bool
92107 +
92108 + config TASK_SIZE_MAX_SHIFT
92109 + int
92110 + depends on X86_64
92111 + default 47 if !PAX_PER_CPU_PGD
92112 + default 42 if PAX_PER_CPU_PGD
92113 +
92114 + config PAX_ENABLE_PAE
92115 + bool
92116 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92117 +
92118 + config PAX_USERCOPY_SLABS
92119 + bool
92120 +
92121 +config GRKERNSEC
92122 + bool "Grsecurity"
92123 + select CRYPTO
92124 + select CRYPTO_SHA256
92125 + select PROC_FS
92126 + select STOP_MACHINE
92127 + select TTY
92128 + help
92129 + If you say Y here, you will be able to configure many features
92130 + that will enhance the security of your system. It is highly
92131 + recommended that you say Y here and read through the help
92132 + for each option so that you fully understand the features and
92133 + can evaluate their usefulness for your machine.
92134 +
92135 +choice
92136 + prompt "Configuration Method"
92137 + depends on GRKERNSEC
92138 + default GRKERNSEC_CONFIG_CUSTOM
92139 + help
92140 +
92141 +config GRKERNSEC_CONFIG_AUTO
92142 + bool "Automatic"
92143 + help
92144 + If you choose this configuration method, you'll be able to answer a small
92145 + number of simple questions about how you plan to use this kernel.
92146 + The settings of grsecurity and PaX will be automatically configured for
92147 + the highest commonly-used settings within the provided constraints.
92148 +
92149 + If you require additional configuration, custom changes can still be made
92150 + from the "custom configuration" menu.
92151 +
92152 +config GRKERNSEC_CONFIG_CUSTOM
92153 + bool "Custom"
92154 + help
92155 + If you choose this configuration method, you'll be able to configure all
92156 + grsecurity and PaX settings manually. Via this method, no options are
92157 + automatically enabled.
92158 +
92159 +endchoice
92160 +
92161 +choice
92162 + prompt "Usage Type"
92163 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92164 + default GRKERNSEC_CONFIG_SERVER
92165 + help
92166 +
92167 +config GRKERNSEC_CONFIG_SERVER
92168 + bool "Server"
92169 + help
92170 + Choose this option if you plan to use this kernel on a server.
92171 +
92172 +config GRKERNSEC_CONFIG_DESKTOP
92173 + bool "Desktop"
92174 + help
92175 + Choose this option if you plan to use this kernel on a desktop.
92176 +
92177 +endchoice
92178 +
92179 +choice
92180 + prompt "Virtualization Type"
92181 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92182 + default GRKERNSEC_CONFIG_VIRT_NONE
92183 + help
92184 +
92185 +config GRKERNSEC_CONFIG_VIRT_NONE
92186 + bool "None"
92187 + help
92188 + Choose this option if this kernel will be run on bare metal.
92189 +
92190 +config GRKERNSEC_CONFIG_VIRT_GUEST
92191 + bool "Guest"
92192 + help
92193 + Choose this option if this kernel will be run as a VM guest.
92194 +
92195 +config GRKERNSEC_CONFIG_VIRT_HOST
92196 + bool "Host"
92197 + help
92198 + Choose this option if this kernel will be run as a VM host.
92199 +
92200 +endchoice
92201 +
92202 +choice
92203 + prompt "Virtualization Hardware"
92204 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92205 + help
92206 +
92207 +config GRKERNSEC_CONFIG_VIRT_EPT
92208 + bool "EPT/RVI Processor Support"
92209 + depends on X86
92210 + help
92211 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
92212 + hardware virtualization. This allows for additional kernel hardening protections
92213 + to operate without additional performance impact.
92214 +
92215 + To see if your Intel processor supports EPT, see:
92216 + http://ark.intel.com/Products/VirtualizationTechnology
92217 + (Most Core i3/5/7 support EPT)
92218 +
92219 + To see if your AMD processor supports RVI, see:
92220 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
92221 +
92222 +config GRKERNSEC_CONFIG_VIRT_SOFT
92223 + bool "First-gen/No Hardware Virtualization"
92224 + help
92225 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
92226 + support hardware virtualization or doesn't support the EPT/RVI extensions.
92227 +
92228 +endchoice
92229 +
92230 +choice
92231 + prompt "Virtualization Software"
92232 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92233 + help
92234 +
92235 +config GRKERNSEC_CONFIG_VIRT_XEN
92236 + bool "Xen"
92237 + help
92238 + Choose this option if this kernel is running as a Xen guest or host.
92239 +
92240 +config GRKERNSEC_CONFIG_VIRT_VMWARE
92241 + bool "VMWare"
92242 + help
92243 + Choose this option if this kernel is running as a VMWare guest or host.
92244 +
92245 +config GRKERNSEC_CONFIG_VIRT_KVM
92246 + bool "KVM"
92247 + help
92248 + Choose this option if this kernel is running as a KVM guest or host.
92249 +
92250 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
92251 + bool "VirtualBox"
92252 + help
92253 + Choose this option if this kernel is running as a VirtualBox guest or host.
92254 +
92255 +endchoice
92256 +
92257 +choice
92258 + prompt "Required Priorities"
92259 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92260 + default GRKERNSEC_CONFIG_PRIORITY_PERF
92261 + help
92262 +
92263 +config GRKERNSEC_CONFIG_PRIORITY_PERF
92264 + bool "Performance"
92265 + help
92266 + Choose this option if performance is of highest priority for this deployment
92267 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
92268 + clearing of structures intended for userland, and freed memory sanitizing will
92269 + be disabled.
92270 +
92271 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
92272 + bool "Security"
92273 + help
92274 + Choose this option if security is of highest priority for this deployment of
92275 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
92276 + for userland, and freed memory sanitizing will be enabled for this kernel.
92277 + In a worst-case scenario, these features can introduce a 20% performance hit
92278 + (UDEREF on x64 contributing half of this hit).
92279 +
92280 +endchoice
92281 +
92282 +menu "Default Special Groups"
92283 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92284 +
92285 +config GRKERNSEC_PROC_GID
92286 + int "GID exempted from /proc restrictions"
92287 + default 1001
92288 + help
92289 + Setting this GID determines which group will be exempted from
92290 + grsecurity's /proc restrictions, allowing users of the specified
92291 + group to view network statistics and the existence of other users'
92292 + processes on the system. This GID may also be chosen at boot time
92293 + via "grsec_proc_gid=" on the kernel commandline.
92294 +
92295 +config GRKERNSEC_TPE_UNTRUSTED_GID
92296 + int "GID for TPE-untrusted users"
92297 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
92298 + default 1005
92299 + help
92300 + Setting this GID determines which group untrusted users should
92301 + be added to. These users will be placed under grsecurity's Trusted Path
92302 + Execution mechanism, preventing them from executing their own binaries.
92303 + The users will only be able to execute binaries in directories owned and
92304 + writable only by the root user. If the sysctl option is enabled, a sysctl
92305 + option with name "tpe_gid" is created.
92306 +
92307 +config GRKERNSEC_TPE_TRUSTED_GID
92308 + int "GID for TPE-trusted users"
92309 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
92310 + default 1005
92311 + help
92312 + Setting this GID determines what group TPE restrictions will be
92313 + *disabled* for. If the sysctl option is enabled, a sysctl option
92314 + with name "tpe_gid" is created.
92315 +
92316 +config GRKERNSEC_SYMLINKOWN_GID
92317 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
92318 + depends on GRKERNSEC_CONFIG_SERVER
92319 + default 1006
92320 + help
92321 + Setting this GID determines what group kernel-enforced
92322 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
92323 + is enabled, a sysctl option with name "symlinkown_gid" is created.
92324 +
92325 +
92326 +endmenu
92327 +
92328 +menu "Customize Configuration"
92329 +depends on GRKERNSEC
92330 +
92331 +menu "PaX"
92332 +
92333 +config PAX
92334 + bool "Enable various PaX features"
92335 + default y if GRKERNSEC_CONFIG_AUTO
92336 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
92337 + help
92338 + This allows you to enable various PaX features. PaX adds
92339 + intrusion prevention mechanisms to the kernel that reduce
92340 + the risks posed by exploitable memory corruption bugs.
92341 +
92342 +menu "PaX Control"
92343 + depends on PAX
92344 +
92345 +config PAX_SOFTMODE
92346 + bool 'Support soft mode'
92347 + help
92348 + Enabling this option will allow you to run PaX in soft mode, that
92349 + is, PaX features will not be enforced by default, only on executables
92350 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
92351 + support as they are the only way to mark executables for soft mode use.
92352 +
92353 + Soft mode can be activated by using the "pax_softmode=1" kernel command
92354 + line option on boot. Furthermore you can control various PaX features
92355 + at runtime via the entries in /proc/sys/kernel/pax.
92356 +
92357 +config PAX_EI_PAX
92358 + bool 'Use legacy ELF header marking'
92359 + default y if GRKERNSEC_CONFIG_AUTO
92360 + help
92361 + Enabling this option will allow you to control PaX features on
92362 + a per executable basis via the 'chpax' utility available at
92363 + http://pax.grsecurity.net/. The control flags will be read from
92364 + an otherwise reserved part of the ELF header. This marking has
92365 + numerous drawbacks (no support for soft-mode, toolchain does not
92366 + know about the non-standard use of the ELF header) therefore it
92367 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
92368 + support.
92369 +
92370 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92371 + support as well, they will override the legacy EI_PAX marks.
92372 +
92373 + If you enable none of the marking options then all applications
92374 + will run with PaX enabled on them by default.
92375 +
92376 +config PAX_PT_PAX_FLAGS
92377 + bool 'Use ELF program header marking'
92378 + default y if GRKERNSEC_CONFIG_AUTO
92379 + help
92380 + Enabling this option will allow you to control PaX features on
92381 + a per executable basis via the 'paxctl' utility available at
92382 + http://pax.grsecurity.net/. The control flags will be read from
92383 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92384 + has the benefits of supporting both soft mode and being fully
92385 + integrated into the toolchain (the binutils patch is available
92386 + from http://pax.grsecurity.net).
92387 +
92388 + Note that if you enable the legacy EI_PAX marking support as well,
92389 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92390 +
92391 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92392 + must make sure that the marks are the same if a binary has both marks.
92393 +
92394 + If you enable none of the marking options then all applications
92395 + will run with PaX enabled on them by default.
92396 +
92397 +config PAX_XATTR_PAX_FLAGS
92398 + bool 'Use filesystem extended attributes marking'
92399 + default y if GRKERNSEC_CONFIG_AUTO
92400 + select CIFS_XATTR if CIFS
92401 + select EXT2_FS_XATTR if EXT2_FS
92402 + select EXT3_FS_XATTR if EXT3_FS
92403 + select EXT4_FS_XATTR if EXT4_FS
92404 + select JFFS2_FS_XATTR if JFFS2_FS
92405 + select REISERFS_FS_XATTR if REISERFS_FS
92406 + select SQUASHFS_XATTR if SQUASHFS
92407 + select TMPFS_XATTR if TMPFS
92408 + select UBIFS_FS_XATTR if UBIFS_FS
92409 + help
92410 + Enabling this option will allow you to control PaX features on
92411 + a per executable basis via the 'setfattr' utility. The control
92412 + flags will be read from the user.pax.flags extended attribute of
92413 + the file. This marking has the benefit of supporting binary-only
92414 + applications that self-check themselves (e.g., skype) and would
92415 + not tolerate chpax/paxctl changes. The main drawback is that
92416 + extended attributes are not supported by some filesystems (e.g.,
92417 + isofs, udf, vfat) so copying files through such filesystems will
92418 + lose the extended attributes and these PaX markings.
92419 +
92420 + Note that if you enable the legacy EI_PAX marking support as well,
92421 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92422 +
92423 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92424 + must make sure that the marks are the same if a binary has both marks.
92425 +
92426 + If you enable none of the marking options then all applications
92427 + will run with PaX enabled on them by default.
92428 +
92429 +choice
92430 + prompt 'MAC system integration'
92431 + default PAX_HAVE_ACL_FLAGS
92432 + help
92433 + Mandatory Access Control systems have the option of controlling
92434 + PaX flags on a per executable basis, choose the method supported
92435 + by your particular system.
92436 +
92437 + - "none": if your MAC system does not interact with PaX,
92438 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92439 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92440 +
92441 + NOTE: this option is for developers/integrators only.
92442 +
92443 + config PAX_NO_ACL_FLAGS
92444 + bool 'none'
92445 +
92446 + config PAX_HAVE_ACL_FLAGS
92447 + bool 'direct'
92448 +
92449 + config PAX_HOOK_ACL_FLAGS
92450 + bool 'hook'
92451 +endchoice
92452 +
92453 +endmenu
92454 +
92455 +menu "Non-executable pages"
92456 + depends on PAX
92457 +
92458 +config PAX_NOEXEC
92459 + bool "Enforce non-executable pages"
92460 + default y if GRKERNSEC_CONFIG_AUTO
92461 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92462 + help
92463 + By design some architectures do not allow for protecting memory
92464 + pages against execution or even if they do, Linux does not make
92465 + use of this feature. In practice this means that if a page is
92466 + readable (such as the stack or heap) it is also executable.
92467 +
92468 + There is a well known exploit technique that makes use of this
92469 + fact and a common programming mistake where an attacker can
92470 + introduce code of his choice somewhere in the attacked program's
92471 + memory (typically the stack or the heap) and then execute it.
92472 +
92473 + If the attacked program was running with different (typically
92474 + higher) privileges than that of the attacker, then he can elevate
92475 + his own privilege level (e.g. get a root shell, write to files for
92476 + which he does not have write access to, etc).
92477 +
92478 + Enabling this option will let you choose from various features
92479 + that prevent the injection and execution of 'foreign' code in
92480 + a program.
92481 +
92482 + This will also break programs that rely on the old behaviour and
92483 + expect that dynamically allocated memory via the malloc() family
92484 + of functions is executable (which it is not). Notable examples
92485 + are the XFree86 4.x server, the java runtime and wine.
92486 +
92487 +config PAX_PAGEEXEC
92488 + bool "Paging based non-executable pages"
92489 + default y if GRKERNSEC_CONFIG_AUTO
92490 + 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)
92491 + select S390_SWITCH_AMODE if S390
92492 + select S390_EXEC_PROTECT if S390
92493 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92494 + help
92495 + This implementation is based on the paging feature of the CPU.
92496 + On i386 without hardware non-executable bit support there is a
92497 + variable but usually low performance impact, however on Intel's
92498 + P4 core based CPUs it is very high so you should not enable this
92499 + for kernels meant to be used on such CPUs.
92500 +
92501 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92502 + with hardware non-executable bit support there is no performance
92503 + impact, on ppc the impact is negligible.
92504 +
92505 + Note that several architectures require various emulations due to
92506 + badly designed userland ABIs, this will cause a performance impact
92507 + but will disappear as soon as userland is fixed. For example, ppc
92508 + userland MUST have been built with secure-plt by a recent toolchain.
92509 +
92510 +config PAX_SEGMEXEC
92511 + bool "Segmentation based non-executable pages"
92512 + default y if GRKERNSEC_CONFIG_AUTO
92513 + depends on PAX_NOEXEC && X86_32
92514 + help
92515 + This implementation is based on the segmentation feature of the
92516 + CPU and has a very small performance impact, however applications
92517 + will be limited to a 1.5 GB address space instead of the normal
92518 + 3 GB.
92519 +
92520 +config PAX_EMUTRAMP
92521 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92522 + default y if PARISC
92523 + help
92524 + There are some programs and libraries that for one reason or
92525 + another attempt to execute special small code snippets from
92526 + non-executable memory pages. Most notable examples are the
92527 + signal handler return code generated by the kernel itself and
92528 + the GCC trampolines.
92529 +
92530 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92531 + such programs will no longer work under your kernel.
92532 +
92533 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92534 + utilities to enable trampoline emulation for the affected programs
92535 + yet still have the protection provided by the non-executable pages.
92536 +
92537 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92538 + your system will not even boot.
92539 +
92540 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92541 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92542 + for the affected files.
92543 +
92544 + NOTE: enabling this feature *may* open up a loophole in the
92545 + protection provided by non-executable pages that an attacker
92546 + could abuse. Therefore the best solution is to not have any
92547 + files on your system that would require this option. This can
92548 + be achieved by not using libc5 (which relies on the kernel
92549 + signal handler return code) and not using or rewriting programs
92550 + that make use of the nested function implementation of GCC.
92551 + Skilled users can just fix GCC itself so that it implements
92552 + nested function calls in a way that does not interfere with PaX.
92553 +
92554 +config PAX_EMUSIGRT
92555 + bool "Automatically emulate sigreturn trampolines"
92556 + depends on PAX_EMUTRAMP && PARISC
92557 + default y
92558 + help
92559 + Enabling this option will have the kernel automatically detect
92560 + and emulate signal return trampolines executing on the stack
92561 + that would otherwise lead to task termination.
92562 +
92563 + This solution is intended as a temporary one for users with
92564 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92565 + Modula-3 runtime, etc) or executables linked to such, basically
92566 + everything that does not specify its own SA_RESTORER function in
92567 + normal executable memory like glibc 2.1+ does.
92568 +
92569 + On parisc you MUST enable this option, otherwise your system will
92570 + not even boot.
92571 +
92572 + NOTE: this feature cannot be disabled on a per executable basis
92573 + and since it *does* open up a loophole in the protection provided
92574 + by non-executable pages, the best solution is to not have any
92575 + files on your system that would require this option.
92576 +
92577 +config PAX_MPROTECT
92578 + bool "Restrict mprotect()"
92579 + default y if GRKERNSEC_CONFIG_AUTO
92580 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92581 + help
92582 + Enabling this option will prevent programs from
92583 + - changing the executable status of memory pages that were
92584 + not originally created as executable,
92585 + - making read-only executable pages writable again,
92586 + - creating executable pages from anonymous memory,
92587 + - making read-only-after-relocations (RELRO) data pages writable again.
92588 +
92589 + You should say Y here to complete the protection provided by
92590 + the enforcement of non-executable pages.
92591 +
92592 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92593 + this feature on a per file basis.
92594 +
92595 +config PAX_MPROTECT_COMPAT
92596 + bool "Use legacy/compat protection demoting (read help)"
92597 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92598 + depends on PAX_MPROTECT
92599 + help
92600 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92601 + by sending the proper error code to the application. For some broken
92602 + userland, this can cause problems with Python or other applications. The
92603 + current implementation however allows for applications like clamav to
92604 + detect if JIT compilation/execution is allowed and to fall back gracefully
92605 + to an interpreter-based mode if it does not. While we encourage everyone
92606 + to use the current implementation as-is and push upstream to fix broken
92607 + userland (note that the RWX logging option can assist with this), in some
92608 + environments this may not be possible. Having to disable MPROTECT
92609 + completely on certain binaries reduces the security benefit of PaX,
92610 + so this option is provided for those environments to revert to the old
92611 + behavior.
92612 +
92613 +config PAX_ELFRELOCS
92614 + bool "Allow ELF text relocations (read help)"
92615 + depends on PAX_MPROTECT
92616 + default n
92617 + help
92618 + Non-executable pages and mprotect() restrictions are effective
92619 + in preventing the introduction of new executable code into an
92620 + attacked task's address space. There remain only two venues
92621 + for this kind of attack: if the attacker can execute already
92622 + existing code in the attacked task then he can either have it
92623 + create and mmap() a file containing his code or have it mmap()
92624 + an already existing ELF library that does not have position
92625 + independent code in it and use mprotect() on it to make it
92626 + writable and copy his code there. While protecting against
92627 + the former approach is beyond PaX, the latter can be prevented
92628 + by having only PIC ELF libraries on one's system (which do not
92629 + need to relocate their code). If you are sure this is your case,
92630 + as is the case with all modern Linux distributions, then leave
92631 + this option disabled. You should say 'n' here.
92632 +
92633 +config PAX_ETEXECRELOCS
92634 + bool "Allow ELF ET_EXEC text relocations"
92635 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92636 + select PAX_ELFRELOCS
92637 + default y
92638 + help
92639 + On some architectures there are incorrectly created applications
92640 + that require text relocations and would not work without enabling
92641 + this option. If you are an alpha, ia64 or parisc user, you should
92642 + enable this option and disable it once you have made sure that
92643 + none of your applications need it.
92644 +
92645 +config PAX_EMUPLT
92646 + bool "Automatically emulate ELF PLT"
92647 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92648 + default y
92649 + help
92650 + Enabling this option will have the kernel automatically detect
92651 + and emulate the Procedure Linkage Table entries in ELF files.
92652 + On some architectures such entries are in writable memory, and
92653 + become non-executable leading to task termination. Therefore
92654 + it is mandatory that you enable this option on alpha, parisc,
92655 + sparc and sparc64, otherwise your system would not even boot.
92656 +
92657 + NOTE: this feature *does* open up a loophole in the protection
92658 + provided by the non-executable pages, therefore the proper
92659 + solution is to modify the toolchain to produce a PLT that does
92660 + not need to be writable.
92661 +
92662 +config PAX_DLRESOLVE
92663 + bool 'Emulate old glibc resolver stub'
92664 + depends on PAX_EMUPLT && SPARC
92665 + default n
92666 + help
92667 + This option is needed if userland has an old glibc (before 2.4)
92668 + that puts a 'save' instruction into the runtime generated resolver
92669 + stub that needs special emulation.
92670 +
92671 +config PAX_KERNEXEC
92672 + bool "Enforce non-executable kernel pages"
92673 + 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))
92674 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92675 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92676 + select PAX_KERNEXEC_PLUGIN if X86_64
92677 + help
92678 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92679 + that is, enabling this option will make it harder to inject
92680 + and execute 'foreign' code in kernel memory itself.
92681 +
92682 +choice
92683 + prompt "Return Address Instrumentation Method"
92684 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92685 + depends on PAX_KERNEXEC_PLUGIN
92686 + help
92687 + Select the method used to instrument function pointer dereferences.
92688 + Note that binary modules cannot be instrumented by this approach.
92689 +
92690 + Note that the implementation requires a gcc with plugin support,
92691 + i.e., gcc 4.5 or newer. You may need to install the supporting
92692 + headers explicitly in addition to the normal gcc package.
92693 +
92694 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92695 + bool "bts"
92696 + help
92697 + This method is compatible with binary only modules but has
92698 + a higher runtime overhead.
92699 +
92700 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92701 + bool "or"
92702 + depends on !PARAVIRT
92703 + help
92704 + This method is incompatible with binary only modules but has
92705 + a lower runtime overhead.
92706 +endchoice
92707 +
92708 +config PAX_KERNEXEC_PLUGIN_METHOD
92709 + string
92710 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92711 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92712 + default ""
92713 +
92714 +config PAX_KERNEXEC_MODULE_TEXT
92715 + int "Minimum amount of memory reserved for module code"
92716 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92717 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92718 + depends on PAX_KERNEXEC && X86_32
92719 + help
92720 + Due to implementation details the kernel must reserve a fixed
92721 + amount of memory for runtime allocated code (such as modules)
92722 + at compile time that cannot be changed at runtime. Here you
92723 + can specify the minimum amount in MB that will be reserved.
92724 + Due to the same implementation details this size will always
92725 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
92726 + the actually available memory for runtime allocated code will
92727 + usually be more than this minimum.
92728 +
92729 + The default 4 MB should be enough for most users but if you have
92730 + an excessive number of modules (e.g., most distribution configs
92731 + compile many drivers as modules) or use huge modules such as
92732 + nvidia's kernel driver, you will need to adjust this amount.
92733 + A good rule of thumb is to look at your currently loaded kernel
92734 + modules and add up their sizes.
92735 +
92736 +endmenu
92737 +
92738 +menu "Address Space Layout Randomization"
92739 + depends on PAX
92740 +
92741 +config PAX_ASLR
92742 + bool "Address Space Layout Randomization"
92743 + default y if GRKERNSEC_CONFIG_AUTO
92744 + help
92745 + Many if not most exploit techniques rely on the knowledge of
92746 + certain addresses in the attacked program. The following options
92747 + will allow the kernel to apply a certain amount of randomization
92748 + to specific parts of the program thereby forcing an attacker to
92749 + guess them in most cases. Any failed guess will most likely crash
92750 + the attacked program which allows the kernel to detect such attempts
92751 + and react on them. PaX itself provides no reaction mechanisms,
92752 + instead it is strongly encouraged that you make use of Nergal's
92753 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92754 + (http://www.grsecurity.net/) built-in crash detection features or
92755 + develop one yourself.
92756 +
92757 + By saying Y here you can choose to randomize the following areas:
92758 + - top of the task's kernel stack
92759 + - top of the task's userland stack
92760 + - base address for mmap() requests that do not specify one
92761 + (this includes all libraries)
92762 + - base address of the main executable
92763 +
92764 + It is strongly recommended to say Y here as address space layout
92765 + randomization has negligible impact on performance yet it provides
92766 + a very effective protection.
92767 +
92768 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92769 + this feature on a per file basis.
92770 +
92771 +config PAX_RANDKSTACK
92772 + bool "Randomize kernel stack base"
92773 + default y if GRKERNSEC_CONFIG_AUTO
92774 + depends on X86_TSC && X86
92775 + help
92776 + By saying Y here the kernel will randomize every task's kernel
92777 + stack on every system call. This will not only force an attacker
92778 + to guess it but also prevent him from making use of possible
92779 + leaked information about it.
92780 +
92781 + Since the kernel stack is a rather scarce resource, randomization
92782 + may cause unexpected stack overflows, therefore you should very
92783 + carefully test your system. Note that once enabled in the kernel
92784 + configuration, this feature cannot be disabled on a per file basis.
92785 +
92786 +config PAX_RANDUSTACK
92787 + bool "Randomize user stack base"
92788 + default y if GRKERNSEC_CONFIG_AUTO
92789 + depends on PAX_ASLR
92790 + help
92791 + By saying Y here the kernel will randomize every task's userland
92792 + stack. The randomization is done in two steps where the second
92793 + one may apply a big amount of shift to the top of the stack and
92794 + cause problems for programs that want to use lots of memory (more
92795 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92796 + For this reason the second step can be controlled by 'chpax' or
92797 + 'paxctl' on a per file basis.
92798 +
92799 +config PAX_RANDMMAP
92800 + bool "Randomize mmap() base"
92801 + default y if GRKERNSEC_CONFIG_AUTO
92802 + depends on PAX_ASLR
92803 + help
92804 + By saying Y here the kernel will use a randomized base address for
92805 + mmap() requests that do not specify one themselves. As a result
92806 + all dynamically loaded libraries will appear at random addresses
92807 + and therefore be harder to exploit by a technique where an attacker
92808 + attempts to execute library code for his purposes (e.g. spawn a
92809 + shell from an exploited program that is running at an elevated
92810 + privilege level).
92811 +
92812 + Furthermore, if a program is relinked as a dynamic ELF file, its
92813 + base address will be randomized as well, completing the full
92814 + randomization of the address space layout. Attacking such programs
92815 + becomes a guess game. You can find an example of doing this at
92816 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92817 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92818 +
92819 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92820 + feature on a per file basis.
92821 +
92822 +endmenu
92823 +
92824 +menu "Miscellaneous hardening features"
92825 +
92826 +config PAX_MEMORY_SANITIZE
92827 + bool "Sanitize all freed memory"
92828 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92829 + depends on !HIBERNATION
92830 + help
92831 + By saying Y here the kernel will erase memory pages as soon as they
92832 + are freed. This in turn reduces the lifetime of data stored in the
92833 + pages, making it less likely that sensitive information such as
92834 + passwords, cryptographic secrets, etc stay in memory for too long.
92835 +
92836 + This is especially useful for programs whose runtime is short, long
92837 + lived processes and the kernel itself benefit from this as long as
92838 + they operate on whole memory pages and ensure timely freeing of pages
92839 + that may hold sensitive information.
92840 +
92841 + The tradeoff is performance impact, on a single CPU system kernel
92842 + compilation sees a 3% slowdown, other systems and workloads may vary
92843 + and you are advised to test this feature on your expected workload
92844 + before deploying it.
92845 +
92846 + Note that this feature does not protect data stored in live pages,
92847 + e.g., process memory swapped to disk may stay there for a long time.
92848 +
92849 +config PAX_MEMORY_STACKLEAK
92850 + bool "Sanitize kernel stack"
92851 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92852 + depends on X86
92853 + help
92854 + By saying Y here the kernel will erase the kernel stack before it
92855 + returns from a system call. This in turn reduces the information
92856 + that a kernel stack leak bug can reveal.
92857 +
92858 + Note that such a bug can still leak information that was put on
92859 + the stack by the current system call (the one eventually triggering
92860 + the bug) but traces of earlier system calls on the kernel stack
92861 + cannot leak anymore.
92862 +
92863 + The tradeoff is performance impact: on a single CPU system kernel
92864 + compilation sees a 1% slowdown, other systems and workloads may vary
92865 + and you are advised to test this feature on your expected workload
92866 + before deploying it.
92867 +
92868 + Note that the full feature requires a gcc with plugin support,
92869 + i.e., gcc 4.5 or newer. You may need to install the supporting
92870 + headers explicitly in addition to the normal gcc package. Using
92871 + older gcc versions means that functions with large enough stack
92872 + frames may leave uninitialized memory behind that may be exposed
92873 + to a later syscall leaking the stack.
92874 +
92875 +config PAX_MEMORY_STRUCTLEAK
92876 + bool "Forcibly initialize local variables copied to userland"
92877 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92878 + help
92879 + By saying Y here the kernel will zero initialize some local
92880 + variables that are going to be copied to userland. This in
92881 + turn prevents unintended information leakage from the kernel
92882 + stack should later code forget to explicitly set all parts of
92883 + the copied variable.
92884 +
92885 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92886 + at a much smaller coverage.
92887 +
92888 + Note that the implementation requires a gcc with plugin support,
92889 + i.e., gcc 4.5 or newer. You may need to install the supporting
92890 + headers explicitly in addition to the normal gcc package.
92891 +
92892 +config PAX_MEMORY_UDEREF
92893 + bool "Prevent invalid userland pointer dereference"
92894 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92895 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92896 + select PAX_PER_CPU_PGD if X86_64
92897 + help
92898 + By saying Y here the kernel will be prevented from dereferencing
92899 + userland pointers in contexts where the kernel expects only kernel
92900 + pointers. This is both a useful runtime debugging feature and a
92901 + security measure that prevents exploiting a class of kernel bugs.
92902 +
92903 + The tradeoff is that some virtualization solutions may experience
92904 + a huge slowdown and therefore you should not enable this feature
92905 + for kernels meant to run in such environments. Whether a given VM
92906 + solution is affected or not is best determined by simply trying it
92907 + out, the performance impact will be obvious right on boot as this
92908 + mechanism engages from very early on. A good rule of thumb is that
92909 + VMs running on CPUs without hardware virtualization support (i.e.,
92910 + the majority of IA-32 CPUs) will likely experience the slowdown.
92911 +
92912 +config PAX_REFCOUNT
92913 + bool "Prevent various kernel object reference counter overflows"
92914 + default y if GRKERNSEC_CONFIG_AUTO
92915 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92916 + help
92917 + By saying Y here the kernel will detect and prevent overflowing
92918 + various (but not all) kinds of object reference counters. Such
92919 + overflows can normally occur due to bugs only and are often, if
92920 + not always, exploitable.
92921 +
92922 + The tradeoff is that data structures protected by an overflowed
92923 + refcount will never be freed and therefore will leak memory. Note
92924 + that this leak also happens even without this protection but in
92925 + that case the overflow can eventually trigger the freeing of the
92926 + data structure while it is still being used elsewhere, resulting
92927 + in the exploitable situation that this feature prevents.
92928 +
92929 + Since this has a negligible performance impact, you should enable
92930 + this feature.
92931 +
92932 +config PAX_CONSTIFY_PLUGIN
92933 + bool "Automatically constify eligible structures"
92934 + default y
92935 + depends on !UML && PAX_KERNEXEC
92936 + help
92937 + By saying Y here the compiler will automatically constify a class
92938 + of types that contain only function pointers. This reduces the
92939 + kernel's attack surface and also produces a better memory layout.
92940 +
92941 + Note that the implementation requires a gcc with plugin support,
92942 + i.e., gcc 4.5 or newer. You may need to install the supporting
92943 + headers explicitly in addition to the normal gcc package.
92944 +
92945 + Note that if some code really has to modify constified variables
92946 + then the source code will have to be patched to allow it. Examples
92947 + can be found in PaX itself (the no_const attribute) and for some
92948 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92949 +
92950 +config PAX_USERCOPY
92951 + bool "Harden heap object copies between kernel and userland"
92952 + default y if GRKERNSEC_CONFIG_AUTO
92953 + depends on ARM || IA64 || PPC || SPARC || X86
92954 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92955 + select PAX_USERCOPY_SLABS
92956 + help
92957 + By saying Y here the kernel will enforce the size of heap objects
92958 + when they are copied in either direction between the kernel and
92959 + userland, even if only a part of the heap object is copied.
92960 +
92961 + Specifically, this checking prevents information leaking from the
92962 + kernel heap during kernel to userland copies (if the kernel heap
92963 + object is otherwise fully initialized) and prevents kernel heap
92964 + overflows during userland to kernel copies.
92965 +
92966 + Note that the current implementation provides the strictest bounds
92967 + checks for the SLUB allocator.
92968 +
92969 + Enabling this option also enables per-slab cache protection against
92970 + data in a given cache being copied into/out of via userland
92971 + accessors. Though the whitelist of regions will be reduced over
92972 + time, it notably protects important data structures like task structs.
92973 +
92974 + If frame pointers are enabled on x86, this option will also restrict
92975 + copies into and out of the kernel stack to local variables within a
92976 + single frame.
92977 +
92978 + Since this has a negligible performance impact, you should enable
92979 + this feature.
92980 +
92981 +config PAX_USERCOPY_DEBUG
92982 + bool
92983 + depends on X86 && PAX_USERCOPY
92984 + default n
92985 +
92986 +config PAX_SIZE_OVERFLOW
92987 + bool "Prevent various integer overflows in function size parameters"
92988 + default y if GRKERNSEC_CONFIG_AUTO
92989 + depends on X86
92990 + help
92991 + By saying Y here the kernel recomputes expressions of function
92992 + arguments marked by a size_overflow attribute with double integer
92993 + precision (DImode/TImode for 32/64 bit integer types).
92994 +
92995 + The recomputed argument is checked against TYPE_MAX and an event
92996 + is logged on overflow and the triggering process is killed.
92997 +
92998 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92999 +
93000 + Note that the implementation requires a gcc with plugin support,
93001 + i.e., gcc 4.5 or newer. You may need to install the supporting
93002 + headers explicitly in addition to the normal gcc package.
93003 +
93004 +config PAX_LATENT_ENTROPY
93005 + bool "Generate some entropy during boot"
93006 + default y if GRKERNSEC_CONFIG_AUTO
93007 + help
93008 + By saying Y here the kernel will instrument early boot code to
93009 + extract some entropy from both original and artificially created
93010 + program state. This will help especially embedded systems where
93011 + there is little 'natural' source of entropy normally. The cost
93012 + is some slowdown of the boot process.
93013 +
93014 + When pax_extra_latent_entropy is passed on the kernel command line,
93015 + entropy will be extracted from up to the first 4GB of RAM while the
93016 + runtime memory allocator is being initialized. This costs even more
93017 + slowdown of the boot process.
93018 +
93019 + Note that the implementation requires a gcc with plugin support,
93020 + i.e., gcc 4.5 or newer. You may need to install the supporting
93021 + headers explicitly in addition to the normal gcc package.
93022 +
93023 + Note that entropy extracted this way is not cryptographically
93024 + secure!
93025 +
93026 +endmenu
93027 +
93028 +endmenu
93029 +
93030 +source grsecurity/Kconfig
93031 +
93032 +endmenu
93033 +
93034 +endmenu
93035 +
93036 source security/keys/Kconfig
93037
93038 config SECURITY_DMESG_RESTRICT
93039 @@ -103,7 +1042,7 @@ config INTEL_TXT
93040 config LSM_MMAP_MIN_ADDR
93041 int "Low address space for LSM to protect from user allocation"
93042 depends on SECURITY && SECURITY_SELINUX
93043 - default 32768 if ARM
93044 + default 32768 if ALPHA || ARM || PARISC || SPARC32
93045 default 65536
93046 help
93047 This is the portion of low virtual memory which should be protected
93048 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
93049 index 9b9013b..51ebf96 100644
93050 --- a/security/apparmor/Kconfig
93051 +++ b/security/apparmor/Kconfig
93052 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
93053 boot.
93054
93055 If you are unsure how to answer this question, answer 1.
93056 +
93057 +config SECURITY_APPARMOR_COMPAT_24
93058 + bool "Enable AppArmor 2.4 compatability"
93059 + depends on SECURITY_APPARMOR
93060 + default y
93061 + help
93062 + This option enables compatability with AppArmor 2.4. It is
93063 + recommended if compatability with older versions of AppArmor
93064 + is desired.
93065 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
93066 index 16c15ec..42b7c9f 100644
93067 --- a/security/apparmor/apparmorfs.c
93068 +++ b/security/apparmor/apparmorfs.c
93069 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
93070 .release = single_release,
93071 };
93072
93073 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93074 +/**
93075 + * __next_namespace - find the next namespace to list
93076 + * @root: root namespace to stop search at (NOT NULL)
93077 + * @ns: current ns position (NOT NULL)
93078 + *
93079 + * Find the next namespace from @ns under @root and handle all locking needed
93080 + * while switching current namespace.
93081 + *
93082 + * Returns: next namespace or NULL if at last namespace under @root
93083 + * NOTE: will not unlock root->lock
93084 + */
93085 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
93086 + struct aa_namespace *ns)
93087 +{
93088 + struct aa_namespace *parent;
93089 +
93090 + /* is next namespace a child */
93091 + if (!list_empty(&ns->sub_ns)) {
93092 + struct aa_namespace *next;
93093 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
93094 + read_lock(&next->lock);
93095 + return next;
93096 + }
93097 +
93098 + /* check if the next ns is a sibling, parent, gp, .. */
93099 + parent = ns->parent;
93100 + while (parent) {
93101 + read_unlock(&ns->lock);
93102 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
93103 + read_lock(&ns->lock);
93104 + return ns;
93105 + }
93106 + if (parent == root)
93107 + return NULL;
93108 + ns = parent;
93109 + parent = parent->parent;
93110 + }
93111 +
93112 + return NULL;
93113 +}
93114 +
93115 +/**
93116 + * __first_profile - find the first profile in a namespace
93117 + * @root: namespace that is root of profiles being displayed (NOT NULL)
93118 + * @ns: namespace to start in (NOT NULL)
93119 + *
93120 + * Returns: unrefcounted profile or NULL if no profile
93121 + */
93122 +static struct aa_profile *__first_profile(struct aa_namespace *root,
93123 + struct aa_namespace *ns)
93124 +{
93125 + for ( ; ns; ns = __next_namespace(root, ns)) {
93126 + if (!list_empty(&ns->base.profiles))
93127 + return list_first_entry(&ns->base.profiles,
93128 + struct aa_profile, base.list);
93129 + }
93130 + return NULL;
93131 +}
93132 +
93133 +/**
93134 + * __next_profile - step to the next profile in a profile tree
93135 + * @profile: current profile in tree (NOT NULL)
93136 + *
93137 + * Perform a depth first taversal on the profile tree in a namespace
93138 + *
93139 + * Returns: next profile or NULL if done
93140 + * Requires: profile->ns.lock to be held
93141 + */
93142 +static struct aa_profile *__next_profile(struct aa_profile *p)
93143 +{
93144 + struct aa_profile *parent;
93145 + struct aa_namespace *ns = p->ns;
93146 +
93147 + /* is next profile a child */
93148 + if (!list_empty(&p->base.profiles))
93149 + return list_first_entry(&p->base.profiles, typeof(*p),
93150 + base.list);
93151 +
93152 + /* is next profile a sibling, parent sibling, gp, subling, .. */
93153 + parent = p->parent;
93154 + while (parent) {
93155 + list_for_each_entry_continue(p, &parent->base.profiles,
93156 + base.list)
93157 + return p;
93158 + p = parent;
93159 + parent = parent->parent;
93160 + }
93161 +
93162 + /* is next another profile in the namespace */
93163 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
93164 + return p;
93165 +
93166 + return NULL;
93167 +}
93168 +
93169 +/**
93170 + * next_profile - step to the next profile in where ever it may be
93171 + * @root: root namespace (NOT NULL)
93172 + * @profile: current profile (NOT NULL)
93173 + *
93174 + * Returns: next profile or NULL if there isn't one
93175 + */
93176 +static struct aa_profile *next_profile(struct aa_namespace *root,
93177 + struct aa_profile *profile)
93178 +{
93179 + struct aa_profile *next = __next_profile(profile);
93180 + if (next)
93181 + return next;
93182 +
93183 + /* finished all profiles in namespace move to next namespace */
93184 + return __first_profile(root, __next_namespace(root, profile->ns));
93185 +}
93186 +
93187 +/**
93188 + * p_start - start a depth first traversal of profile tree
93189 + * @f: seq_file to fill
93190 + * @pos: current position
93191 + *
93192 + * Returns: first profile under current namespace or NULL if none found
93193 + *
93194 + * acquires first ns->lock
93195 + */
93196 +static void *p_start(struct seq_file *f, loff_t *pos)
93197 + __acquires(root->lock)
93198 +{
93199 + struct aa_profile *profile = NULL;
93200 + struct aa_namespace *root = aa_current_profile()->ns;
93201 + loff_t l = *pos;
93202 + f->private = aa_get_namespace(root);
93203 +
93204 +
93205 + /* find the first profile */
93206 + read_lock(&root->lock);
93207 + profile = __first_profile(root, root);
93208 +
93209 + /* skip to position */
93210 + for (; profile && l > 0; l--)
93211 + profile = next_profile(root, profile);
93212 +
93213 + return profile;
93214 +}
93215 +
93216 +/**
93217 + * p_next - read the next profile entry
93218 + * @f: seq_file to fill
93219 + * @p: profile previously returned
93220 + * @pos: current position
93221 + *
93222 + * Returns: next profile after @p or NULL if none
93223 + *
93224 + * may acquire/release locks in namespace tree as necessary
93225 + */
93226 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
93227 +{
93228 + struct aa_profile *profile = p;
93229 + struct aa_namespace *root = f->private;
93230 + (*pos)++;
93231 +
93232 + return next_profile(root, profile);
93233 +}
93234 +
93235 +/**
93236 + * p_stop - stop depth first traversal
93237 + * @f: seq_file we are filling
93238 + * @p: the last profile writen
93239 + *
93240 + * Release all locking done by p_start/p_next on namespace tree
93241 + */
93242 +static void p_stop(struct seq_file *f, void *p)
93243 + __releases(root->lock)
93244 +{
93245 + struct aa_profile *profile = p;
93246 + struct aa_namespace *root = f->private, *ns;
93247 +
93248 + if (profile) {
93249 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
93250 + read_unlock(&ns->lock);
93251 + }
93252 + read_unlock(&root->lock);
93253 + aa_put_namespace(root);
93254 +}
93255 +
93256 +/**
93257 + * seq_show_profile - show a profile entry
93258 + * @f: seq_file to file
93259 + * @p: current position (profile) (NOT NULL)
93260 + *
93261 + * Returns: error on failure
93262 + */
93263 +static int seq_show_profile(struct seq_file *f, void *p)
93264 +{
93265 + struct aa_profile *profile = (struct aa_profile *)p;
93266 + struct aa_namespace *root = f->private;
93267 +
93268 + if (profile->ns != root)
93269 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
93270 + seq_printf(f, "%s (%s)\n", profile->base.hname,
93271 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
93272 +
93273 + return 0;
93274 +}
93275 +
93276 +static const struct seq_operations aa_fs_profiles_op = {
93277 + .start = p_start,
93278 + .next = p_next,
93279 + .stop = p_stop,
93280 + .show = seq_show_profile,
93281 +};
93282 +
93283 +static int profiles_open(struct inode *inode, struct file *file)
93284 +{
93285 + return seq_open(file, &aa_fs_profiles_op);
93286 +}
93287 +
93288 +static int profiles_release(struct inode *inode, struct file *file)
93289 +{
93290 + return seq_release(inode, file);
93291 +}
93292 +
93293 +const struct file_operations aa_fs_profiles_fops = {
93294 + .open = profiles_open,
93295 + .read = seq_read,
93296 + .llseek = seq_lseek,
93297 + .release = profiles_release,
93298 +};
93299 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
93300 +
93301 /** Base file system setup **/
93302
93303 static struct aa_fs_entry aa_fs_entry_file[] = {
93304 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
93305 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
93306 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
93307 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
93308 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93309 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
93310 +#endif
93311 AA_FS_DIR("features", aa_fs_entry_features),
93312 { }
93313 };
93314 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
93315 index b21830e..a7d1a17 100644
93316 --- a/security/apparmor/lsm.c
93317 +++ b/security/apparmor/lsm.c
93318 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
93319 return error;
93320 }
93321
93322 -static struct security_operations apparmor_ops = {
93323 +static struct security_operations apparmor_ops __read_only = {
93324 .name = "apparmor",
93325
93326 .ptrace_access_check = apparmor_ptrace_access_check,
93327 diff --git a/security/commoncap.c b/security/commoncap.c
93328 index c44b6fe..932df30 100644
93329 --- a/security/commoncap.c
93330 +++ b/security/commoncap.c
93331 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
93332 return 0;
93333 }
93334
93335 +/* returns:
93336 + 1 for suid privilege
93337 + 2 for sgid privilege
93338 + 3 for fscap privilege
93339 +*/
93340 +int is_privileged_binary(const struct dentry *dentry)
93341 +{
93342 + struct cpu_vfs_cap_data capdata;
93343 + struct inode *inode = dentry->d_inode;
93344 +
93345 + if (!inode || S_ISDIR(inode->i_mode))
93346 + return 0;
93347 +
93348 + if (inode->i_mode & S_ISUID)
93349 + return 1;
93350 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
93351 + return 2;
93352 +
93353 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
93354 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
93355 + return 3;
93356 + }
93357 +
93358 + return 0;
93359 +}
93360 +
93361 /*
93362 * Attempt to get the on-exec apply capability sets for an executable file from
93363 * its xattrs and, if present, apply them to the proposed credentials being
93364 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
93365 const struct cred *cred = current_cred();
93366 kuid_t root_uid = make_kuid(cred->user_ns, 0);
93367
93368 + if (gr_acl_enable_at_secure())
93369 + return 1;
93370 +
93371 if (!uid_eq(cred->uid, root_uid)) {
93372 if (bprm->cap_effective)
93373 return 1;
93374 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93375 index a41c9c1..83da6dd 100644
93376 --- a/security/integrity/ima/ima.h
93377 +++ b/security/integrity/ima/ima.h
93378 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
93379 extern spinlock_t ima_queue_lock;
93380
93381 struct ima_h_table {
93382 - atomic_long_t len; /* number of stored measurements in the list */
93383 - atomic_long_t violations;
93384 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93385 + atomic_long_unchecked_t violations;
93386 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93387 };
93388 extern struct ima_h_table ima_htable;
93389 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93390 index 1c03e8f1..398a941 100644
93391 --- a/security/integrity/ima/ima_api.c
93392 +++ b/security/integrity/ima/ima_api.c
93393 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93394 int result;
93395
93396 /* can overflow, only indicator */
93397 - atomic_long_inc(&ima_htable.violations);
93398 + atomic_long_inc_unchecked(&ima_htable.violations);
93399
93400 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93401 if (!entry) {
93402 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93403 index 38477c9..87a60c7 100644
93404 --- a/security/integrity/ima/ima_fs.c
93405 +++ b/security/integrity/ima/ima_fs.c
93406 @@ -28,12 +28,12 @@
93407 static int valid_policy = 1;
93408 #define TMPBUFLEN 12
93409 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93410 - loff_t *ppos, atomic_long_t *val)
93411 + loff_t *ppos, atomic_long_unchecked_t *val)
93412 {
93413 char tmpbuf[TMPBUFLEN];
93414 ssize_t len;
93415
93416 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93417 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93418 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93419 }
93420
93421 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93422 index ff63fe0..809cd96 100644
93423 --- a/security/integrity/ima/ima_queue.c
93424 +++ b/security/integrity/ima/ima_queue.c
93425 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93426 INIT_LIST_HEAD(&qe->later);
93427 list_add_tail_rcu(&qe->later, &ima_measurements);
93428
93429 - atomic_long_inc(&ima_htable.len);
93430 + atomic_long_inc_unchecked(&ima_htable.len);
93431 key = ima_hash_key(entry->digest);
93432 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93433 return 0;
93434 diff --git a/security/keys/compat.c b/security/keys/compat.c
93435 index d65fa7f..cbfe366 100644
93436 --- a/security/keys/compat.c
93437 +++ b/security/keys/compat.c
93438 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93439 if (ret == 0)
93440 goto no_payload_free;
93441
93442 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93443 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93444 err:
93445 if (iov != iovstack)
93446 kfree(iov);
93447 diff --git a/security/keys/internal.h b/security/keys/internal.h
93448 index d4f1468..cc52f92 100644
93449 --- a/security/keys/internal.h
93450 +++ b/security/keys/internal.h
93451 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
93452 extern long keyctl_invalidate_key(key_serial_t);
93453
93454 extern long keyctl_instantiate_key_common(key_serial_t,
93455 - const struct iovec *,
93456 + const struct iovec __user *,
93457 unsigned, size_t, key_serial_t);
93458
93459 /*
93460 diff --git a/security/keys/key.c b/security/keys/key.c
93461 index 8fb7c7b..ba3610d 100644
93462 --- a/security/keys/key.c
93463 +++ b/security/keys/key.c
93464 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93465
93466 atomic_set(&key->usage, 1);
93467 init_rwsem(&key->sem);
93468 - lockdep_set_class(&key->sem, &type->lock_class);
93469 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93470 key->type = type;
93471 key->user = user;
93472 key->quotalen = quotalen;
93473 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93474 struct key_type *p;
93475 int ret;
93476
93477 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93478 + pax_open_kernel();
93479 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93480 + pax_close_kernel();
93481
93482 ret = -EEXIST;
93483 down_write(&key_types_sem);
93484 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93485 }
93486
93487 /* store the type */
93488 - list_add(&ktype->link, &key_types_list);
93489 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93490
93491 pr_notice("Key type %s registered\n", ktype->name);
93492 ret = 0;
93493 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93494 void unregister_key_type(struct key_type *ktype)
93495 {
93496 down_write(&key_types_sem);
93497 - list_del_init(&ktype->link);
93498 + pax_list_del_init((struct list_head *)&ktype->link);
93499 downgrade_write(&key_types_sem);
93500 key_gc_keytype(ktype);
93501 pr_notice("Key type %s unregistered\n", ktype->name);
93502 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93503 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93504
93505 /* add the special key types */
93506 - list_add_tail(&key_type_keyring.link, &key_types_list);
93507 - list_add_tail(&key_type_dead.link, &key_types_list);
93508 - list_add_tail(&key_type_user.link, &key_types_list);
93509 - list_add_tail(&key_type_logon.link, &key_types_list);
93510 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93511 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93512 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93513 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93514
93515 /* record the root user tracking */
93516 rb_link_node(&root_key_user.node,
93517 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93518 index 33cfd27..842fc5a 100644
93519 --- a/security/keys/keyctl.c
93520 +++ b/security/keys/keyctl.c
93521 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93522 /*
93523 * Copy the iovec data from userspace
93524 */
93525 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93526 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93527 unsigned ioc)
93528 {
93529 for (; ioc > 0; ioc--) {
93530 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93531 * If successful, 0 will be returned.
93532 */
93533 long keyctl_instantiate_key_common(key_serial_t id,
93534 - const struct iovec *payload_iov,
93535 + const struct iovec __user *payload_iov,
93536 unsigned ioc,
93537 size_t plen,
93538 key_serial_t ringid)
93539 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
93540 [0].iov_len = plen
93541 };
93542
93543 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93544 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93545 }
93546
93547 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93548 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93549 if (ret == 0)
93550 goto no_payload_free;
93551
93552 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93553 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93554 err:
93555 if (iov != iovstack)
93556 kfree(iov);
93557 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93558 index 6ece7f2..ecdb55c 100644
93559 --- a/security/keys/keyring.c
93560 +++ b/security/keys/keyring.c
93561 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93562 ret = -EFAULT;
93563
93564 for (loop = 0; loop < klist->nkeys; loop++) {
93565 + key_serial_t serial;
93566 key = rcu_deref_link_locked(klist, loop,
93567 keyring);
93568 + serial = key->serial;
93569
93570 tmp = sizeof(key_serial_t);
93571 if (tmp > buflen)
93572 tmp = buflen;
93573
93574 - if (copy_to_user(buffer,
93575 - &key->serial,
93576 - tmp) != 0)
93577 + if (copy_to_user(buffer, &serial, tmp))
93578 goto error;
93579
93580 buflen -= tmp;
93581 diff --git a/security/min_addr.c b/security/min_addr.c
93582 index f728728..6457a0c 100644
93583 --- a/security/min_addr.c
93584 +++ b/security/min_addr.c
93585 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93586 */
93587 static void update_mmap_min_addr(void)
93588 {
93589 +#ifndef SPARC
93590 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93591 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93592 mmap_min_addr = dac_mmap_min_addr;
93593 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93594 #else
93595 mmap_min_addr = dac_mmap_min_addr;
93596 #endif
93597 +#endif
93598 }
93599
93600 /*
93601 diff --git a/security/security.c b/security/security.c
93602 index a3dce87..9ca1435 100644
93603 --- a/security/security.c
93604 +++ b/security/security.c
93605 @@ -20,6 +20,7 @@
93606 #include <linux/ima.h>
93607 #include <linux/evm.h>
93608 #include <linux/fsnotify.h>
93609 +#include <linux/mm.h>
93610 #include <linux/mman.h>
93611 #include <linux/mount.h>
93612 #include <linux/personality.h>
93613 @@ -32,8 +33,8 @@
93614 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93615 CONFIG_DEFAULT_SECURITY;
93616
93617 -static struct security_operations *security_ops;
93618 -static struct security_operations default_security_ops = {
93619 +static struct security_operations *security_ops __read_only;
93620 +static struct security_operations default_security_ops __read_only = {
93621 .name = "default",
93622 };
93623
93624 @@ -74,7 +75,9 @@ int __init security_init(void)
93625
93626 void reset_security_ops(void)
93627 {
93628 + pax_open_kernel();
93629 security_ops = &default_security_ops;
93630 + pax_close_kernel();
93631 }
93632
93633 /* Save user chosen LSM */
93634 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93635 index 5c6f2cd..b4f945c 100644
93636 --- a/security/selinux/hooks.c
93637 +++ b/security/selinux/hooks.c
93638 @@ -96,8 +96,6 @@
93639
93640 #define NUM_SEL_MNT_OPTS 5
93641
93642 -extern struct security_operations *security_ops;
93643 -
93644 /* SECMARK reference count */
93645 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93646
93647 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93648
93649 #endif
93650
93651 -static struct security_operations selinux_ops = {
93652 +static struct security_operations selinux_ops __read_only = {
93653 .name = "selinux",
93654
93655 .ptrace_access_check = selinux_ptrace_access_check,
93656 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93657 index 65f67cb..3f141ef 100644
93658 --- a/security/selinux/include/xfrm.h
93659 +++ b/security/selinux/include/xfrm.h
93660 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93661
93662 static inline void selinux_xfrm_notify_policyload(void)
93663 {
93664 - atomic_inc(&flow_cache_genid);
93665 + atomic_inc_unchecked(&flow_cache_genid);
93666 rt_genid_bump(&init_net);
93667 }
93668 #else
93669 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93670 index d52c780..6431349 100644
93671 --- a/security/smack/smack_lsm.c
93672 +++ b/security/smack/smack_lsm.c
93673 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93674 return 0;
93675 }
93676
93677 -struct security_operations smack_ops = {
93678 +struct security_operations smack_ops __read_only = {
93679 .name = "smack",
93680
93681 .ptrace_access_check = smack_ptrace_access_check,
93682 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93683 index 390c646..f2f8db3 100644
93684 --- a/security/tomoyo/mount.c
93685 +++ b/security/tomoyo/mount.c
93686 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93687 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93688 need_dev = -1; /* dev_name is a directory */
93689 } else {
93690 + if (!capable(CAP_SYS_ADMIN)) {
93691 + error = -EPERM;
93692 + goto out;
93693 + }
93694 fstype = get_fs_type(type);
93695 if (!fstype) {
93696 error = -ENODEV;
93697 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93698 index f0b756e..b129202 100644
93699 --- a/security/tomoyo/tomoyo.c
93700 +++ b/security/tomoyo/tomoyo.c
93701 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93702 * tomoyo_security_ops is a "struct security_operations" which is used for
93703 * registering TOMOYO.
93704 */
93705 -static struct security_operations tomoyo_security_ops = {
93706 +static struct security_operations tomoyo_security_ops __read_only = {
93707 .name = "tomoyo",
93708 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93709 .cred_prepare = tomoyo_cred_prepare,
93710 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93711 index 20ef514..4182bed 100644
93712 --- a/security/yama/Kconfig
93713 +++ b/security/yama/Kconfig
93714 @@ -1,6 +1,6 @@
93715 config SECURITY_YAMA
93716 bool "Yama support"
93717 - depends on SECURITY
93718 + depends on SECURITY && !GRKERNSEC
93719 select SECURITYFS
93720 select SECURITY_PATH
93721 default n
93722 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93723 index 13c88fbc..f8c115e 100644
93724 --- a/security/yama/yama_lsm.c
93725 +++ b/security/yama/yama_lsm.c
93726 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93727 }
93728
93729 #ifndef CONFIG_SECURITY_YAMA_STACKED
93730 -static struct security_operations yama_ops = {
93731 +static struct security_operations yama_ops __read_only = {
93732 .name = "yama",
93733
93734 .ptrace_access_check = yama_ptrace_access_check,
93735 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
93736 #endif
93737
93738 #ifdef CONFIG_SYSCTL
93739 +static int zero __read_only;
93740 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93741 +
93742 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93743 void __user *buffer, size_t *lenp, loff_t *ppos)
93744 {
93745 - int rc;
93746 + ctl_table_no_const yama_table;
93747
93748 if (write && !capable(CAP_SYS_PTRACE))
93749 return -EPERM;
93750
93751 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93752 - if (rc)
93753 - return rc;
93754 -
93755 + yama_table = *table;
93756 /* Lock the max value if it ever gets set. */
93757 - if (write && *(int *)table->data == *(int *)table->extra2)
93758 - table->extra1 = table->extra2;
93759 -
93760 - return rc;
93761 + if (ptrace_scope == max_scope)
93762 + yama_table.extra1 = &max_scope;
93763 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93764 }
93765
93766 -static int zero;
93767 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93768 -
93769 struct ctl_path yama_sysctl_path[] = {
93770 { .procname = "kernel", },
93771 { .procname = "yama", },
93772 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93773 index 4cedc69..e59d8a3 100644
93774 --- a/sound/aoa/codecs/onyx.c
93775 +++ b/sound/aoa/codecs/onyx.c
93776 @@ -54,7 +54,7 @@ struct onyx {
93777 spdif_locked:1,
93778 analog_locked:1,
93779 original_mute:2;
93780 - int open_count;
93781 + local_t open_count;
93782 struct codec_info *codec_info;
93783
93784 /* mutex serializes concurrent access to the device
93785 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93786 struct onyx *onyx = cii->codec_data;
93787
93788 mutex_lock(&onyx->mutex);
93789 - onyx->open_count++;
93790 + local_inc(&onyx->open_count);
93791 mutex_unlock(&onyx->mutex);
93792
93793 return 0;
93794 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93795 struct onyx *onyx = cii->codec_data;
93796
93797 mutex_lock(&onyx->mutex);
93798 - onyx->open_count--;
93799 - if (!onyx->open_count)
93800 + if (local_dec_and_test(&onyx->open_count))
93801 onyx->spdif_locked = onyx->analog_locked = 0;
93802 mutex_unlock(&onyx->mutex);
93803
93804 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93805 index ffd2025..df062c9 100644
93806 --- a/sound/aoa/codecs/onyx.h
93807 +++ b/sound/aoa/codecs/onyx.h
93808 @@ -11,6 +11,7 @@
93809 #include <linux/i2c.h>
93810 #include <asm/pmac_low_i2c.h>
93811 #include <asm/prom.h>
93812 +#include <asm/local.h>
93813
93814 /* PCM3052 register definitions */
93815
93816 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93817 index 4c1cc51..16040040 100644
93818 --- a/sound/core/oss/pcm_oss.c
93819 +++ b/sound/core/oss/pcm_oss.c
93820 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93821 if (in_kernel) {
93822 mm_segment_t fs;
93823 fs = snd_enter_user();
93824 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93825 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93826 snd_leave_user(fs);
93827 } else {
93828 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93829 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93830 }
93831 if (ret != -EPIPE && ret != -ESTRPIPE)
93832 break;
93833 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93834 if (in_kernel) {
93835 mm_segment_t fs;
93836 fs = snd_enter_user();
93837 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93838 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93839 snd_leave_user(fs);
93840 } else {
93841 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93842 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93843 }
93844 if (ret == -EPIPE) {
93845 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93846 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93847 struct snd_pcm_plugin_channel *channels;
93848 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93849 if (!in_kernel) {
93850 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93851 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93852 return -EFAULT;
93853 buf = runtime->oss.buffer;
93854 }
93855 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93856 }
93857 } else {
93858 tmp = snd_pcm_oss_write2(substream,
93859 - (const char __force *)buf,
93860 + (const char __force_kernel *)buf,
93861 runtime->oss.period_bytes, 0);
93862 if (tmp <= 0)
93863 goto err;
93864 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93865 struct snd_pcm_runtime *runtime = substream->runtime;
93866 snd_pcm_sframes_t frames, frames1;
93867 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93868 - char __user *final_dst = (char __force __user *)buf;
93869 + char __user *final_dst = (char __force_user *)buf;
93870 if (runtime->oss.plugin_first) {
93871 struct snd_pcm_plugin_channel *channels;
93872 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93873 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93874 xfer += tmp;
93875 runtime->oss.buffer_used -= tmp;
93876 } else {
93877 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93878 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93879 runtime->oss.period_bytes, 0);
93880 if (tmp <= 0)
93881 goto err;
93882 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93883 size1);
93884 size1 /= runtime->channels; /* frames */
93885 fs = snd_enter_user();
93886 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93887 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93888 snd_leave_user(fs);
93889 }
93890 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93891 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93892 index af49721..e85058e 100644
93893 --- a/sound/core/pcm_compat.c
93894 +++ b/sound/core/pcm_compat.c
93895 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93896 int err;
93897
93898 fs = snd_enter_user();
93899 - err = snd_pcm_delay(substream, &delay);
93900 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93901 snd_leave_user(fs);
93902 if (err < 0)
93903 return err;
93904 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93905 index f928181..33fb83d 100644
93906 --- a/sound/core/pcm_native.c
93907 +++ b/sound/core/pcm_native.c
93908 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93909 switch (substream->stream) {
93910 case SNDRV_PCM_STREAM_PLAYBACK:
93911 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93912 - (void __user *)arg);
93913 + (void __force_user *)arg);
93914 break;
93915 case SNDRV_PCM_STREAM_CAPTURE:
93916 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93917 - (void __user *)arg);
93918 + (void __force_user *)arg);
93919 break;
93920 default:
93921 result = -EINVAL;
93922 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93923 index 040c60e..989a19a 100644
93924 --- a/sound/core/seq/seq_device.c
93925 +++ b/sound/core/seq/seq_device.c
93926 @@ -64,7 +64,7 @@ struct ops_list {
93927 int argsize; /* argument size */
93928
93929 /* operators */
93930 - struct snd_seq_dev_ops ops;
93931 + struct snd_seq_dev_ops *ops;
93932
93933 /* registered devices */
93934 struct list_head dev_list; /* list of devices */
93935 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93936
93937 mutex_lock(&ops->reg_mutex);
93938 /* copy driver operators */
93939 - ops->ops = *entry;
93940 + ops->ops = entry;
93941 ops->driver |= DRIVER_LOADED;
93942 ops->argsize = argsize;
93943
93944 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93945 dev->name, ops->id, ops->argsize, dev->argsize);
93946 return -EINVAL;
93947 }
93948 - if (ops->ops.init_device(dev) >= 0) {
93949 + if (ops->ops->init_device(dev) >= 0) {
93950 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93951 ops->num_init_devices++;
93952 } else {
93953 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93954 dev->name, ops->id, ops->argsize, dev->argsize);
93955 return -EINVAL;
93956 }
93957 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93958 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93959 dev->status = SNDRV_SEQ_DEVICE_FREE;
93960 dev->driver_data = NULL;
93961 ops->num_init_devices--;
93962 diff --git a/sound/core/sound.c b/sound/core/sound.c
93963 index f002bd9..c462985 100644
93964 --- a/sound/core/sound.c
93965 +++ b/sound/core/sound.c
93966 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
93967 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
93968 default: return;
93969 }
93970 - request_module(str);
93971 + request_module("%s", str);
93972 }
93973
93974 #endif /* modular kernel */
93975 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93976 index 4e0dd22..7a1f32c 100644
93977 --- a/sound/drivers/mts64.c
93978 +++ b/sound/drivers/mts64.c
93979 @@ -29,6 +29,7 @@
93980 #include <sound/initval.h>
93981 #include <sound/rawmidi.h>
93982 #include <sound/control.h>
93983 +#include <asm/local.h>
93984
93985 #define CARD_NAME "Miditerminal 4140"
93986 #define DRIVER_NAME "MTS64"
93987 @@ -67,7 +68,7 @@ struct mts64 {
93988 struct pardevice *pardev;
93989 int pardev_claimed;
93990
93991 - int open_count;
93992 + local_t open_count;
93993 int current_midi_output_port;
93994 int current_midi_input_port;
93995 u8 mode[MTS64_NUM_INPUT_PORTS];
93996 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93997 {
93998 struct mts64 *mts = substream->rmidi->private_data;
93999
94000 - if (mts->open_count == 0) {
94001 + if (local_read(&mts->open_count) == 0) {
94002 /* We don't need a spinlock here, because this is just called
94003 if the device has not been opened before.
94004 So there aren't any IRQs from the device */
94005 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94006
94007 msleep(50);
94008 }
94009 - ++(mts->open_count);
94010 + local_inc(&mts->open_count);
94011
94012 return 0;
94013 }
94014 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94015 struct mts64 *mts = substream->rmidi->private_data;
94016 unsigned long flags;
94017
94018 - --(mts->open_count);
94019 - if (mts->open_count == 0) {
94020 + if (local_dec_return(&mts->open_count) == 0) {
94021 /* We need the spinlock_irqsave here because we can still
94022 have IRQs at this point */
94023 spin_lock_irqsave(&mts->lock, flags);
94024 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94025
94026 msleep(500);
94027
94028 - } else if (mts->open_count < 0)
94029 - mts->open_count = 0;
94030 + } else if (local_read(&mts->open_count) < 0)
94031 + local_set(&mts->open_count, 0);
94032
94033 return 0;
94034 }
94035 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
94036 index b953fb4..1999c01 100644
94037 --- a/sound/drivers/opl4/opl4_lib.c
94038 +++ b/sound/drivers/opl4/opl4_lib.c
94039 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
94040 MODULE_DESCRIPTION("OPL4 driver");
94041 MODULE_LICENSE("GPL");
94042
94043 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
94044 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
94045 {
94046 int timeout = 10;
94047 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
94048 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
94049 index 991018d..8984740 100644
94050 --- a/sound/drivers/portman2x4.c
94051 +++ b/sound/drivers/portman2x4.c
94052 @@ -48,6 +48,7 @@
94053 #include <sound/initval.h>
94054 #include <sound/rawmidi.h>
94055 #include <sound/control.h>
94056 +#include <asm/local.h>
94057
94058 #define CARD_NAME "Portman 2x4"
94059 #define DRIVER_NAME "portman"
94060 @@ -85,7 +86,7 @@ struct portman {
94061 struct pardevice *pardev;
94062 int pardev_claimed;
94063
94064 - int open_count;
94065 + local_t open_count;
94066 int mode[PORTMAN_NUM_INPUT_PORTS];
94067 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
94068 };
94069 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
94070 index ea995af..f1bfa37 100644
94071 --- a/sound/firewire/amdtp.c
94072 +++ b/sound/firewire/amdtp.c
94073 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
94074 ptr = s->pcm_buffer_pointer + data_blocks;
94075 if (ptr >= pcm->runtime->buffer_size)
94076 ptr -= pcm->runtime->buffer_size;
94077 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
94078 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
94079
94080 s->pcm_period_pointer += data_blocks;
94081 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
94082 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
94083 */
94084 void amdtp_out_stream_update(struct amdtp_out_stream *s)
94085 {
94086 - ACCESS_ONCE(s->source_node_id_field) =
94087 + ACCESS_ONCE_RW(s->source_node_id_field) =
94088 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
94089 }
94090 EXPORT_SYMBOL(amdtp_out_stream_update);
94091 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
94092 index b680c5e..061b7a0 100644
94093 --- a/sound/firewire/amdtp.h
94094 +++ b/sound/firewire/amdtp.h
94095 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
94096 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
94097 struct snd_pcm_substream *pcm)
94098 {
94099 - ACCESS_ONCE(s->pcm) = pcm;
94100 + ACCESS_ONCE_RW(s->pcm) = pcm;
94101 }
94102
94103 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
94104 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
94105 index d428ffe..751ef78 100644
94106 --- a/sound/firewire/isight.c
94107 +++ b/sound/firewire/isight.c
94108 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
94109 ptr += count;
94110 if (ptr >= runtime->buffer_size)
94111 ptr -= runtime->buffer_size;
94112 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
94113 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
94114
94115 isight->period_counter += count;
94116 if (isight->period_counter >= runtime->period_size) {
94117 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
94118 if (err < 0)
94119 return err;
94120
94121 - ACCESS_ONCE(isight->pcm_active) = true;
94122 + ACCESS_ONCE_RW(isight->pcm_active) = true;
94123
94124 return 0;
94125 }
94126 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
94127 {
94128 struct isight *isight = substream->private_data;
94129
94130 - ACCESS_ONCE(isight->pcm_active) = false;
94131 + ACCESS_ONCE_RW(isight->pcm_active) = false;
94132
94133 mutex_lock(&isight->mutex);
94134 isight_stop_streaming(isight);
94135 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
94136
94137 switch (cmd) {
94138 case SNDRV_PCM_TRIGGER_START:
94139 - ACCESS_ONCE(isight->pcm_running) = true;
94140 + ACCESS_ONCE_RW(isight->pcm_running) = true;
94141 break;
94142 case SNDRV_PCM_TRIGGER_STOP:
94143 - ACCESS_ONCE(isight->pcm_running) = false;
94144 + ACCESS_ONCE_RW(isight->pcm_running) = false;
94145 break;
94146 default:
94147 return -EINVAL;
94148 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
94149 index 844a555..985ab83 100644
94150 --- a/sound/firewire/scs1x.c
94151 +++ b/sound/firewire/scs1x.c
94152 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
94153 {
94154 struct scs *scs = stream->rmidi->private_data;
94155
94156 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
94157 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
94158 if (up) {
94159 scs->output_idle = false;
94160 tasklet_schedule(&scs->tasklet);
94161 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
94162 {
94163 struct scs *scs = stream->rmidi->private_data;
94164
94165 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
94166 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
94167 }
94168
94169 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
94170 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
94171
94172 snd_card_disconnect(scs->card);
94173
94174 - ACCESS_ONCE(scs->output) = NULL;
94175 - ACCESS_ONCE(scs->input) = NULL;
94176 + ACCESS_ONCE_RW(scs->output) = NULL;
94177 + ACCESS_ONCE_RW(scs->input) = NULL;
94178
94179 wait_event(scs->idle_wait, scs->output_idle);
94180
94181 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
94182 index 048439a..3be9f6f 100644
94183 --- a/sound/oss/sb_audio.c
94184 +++ b/sound/oss/sb_audio.c
94185 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
94186 buf16 = (signed short *)(localbuf + localoffs);
94187 while (c)
94188 {
94189 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94190 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94191 if (copy_from_user(lbuf8,
94192 userbuf+useroffs + p,
94193 locallen))
94194 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
94195 index 7d8803a..559f8d0 100644
94196 --- a/sound/oss/swarm_cs4297a.c
94197 +++ b/sound/oss/swarm_cs4297a.c
94198 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
94199 {
94200 struct cs4297a_state *s;
94201 u32 pwr, id;
94202 - mm_segment_t fs;
94203 int rval;
94204 #ifndef CONFIG_BCM_CS4297A_CSWARM
94205 u64 cfg;
94206 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
94207 if (!rval) {
94208 char *sb1250_duart_present;
94209
94210 +#if 0
94211 + mm_segment_t fs;
94212 fs = get_fs();
94213 set_fs(KERNEL_DS);
94214 -#if 0
94215 val = SOUND_MASK_LINE;
94216 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
94217 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
94218 val = initvol[i].vol;
94219 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
94220 }
94221 + set_fs(fs);
94222 // cs4297a_write_ac97(s, 0x18, 0x0808);
94223 #else
94224 // cs4297a_write_ac97(s, 0x5e, 0x180);
94225 cs4297a_write_ac97(s, 0x02, 0x0808);
94226 cs4297a_write_ac97(s, 0x18, 0x0808);
94227 #endif
94228 - set_fs(fs);
94229
94230 list_add(&s->list, &cs4297a_devs);
94231
94232 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
94233 index 4631a23..001ae57 100644
94234 --- a/sound/pci/ymfpci/ymfpci.h
94235 +++ b/sound/pci/ymfpci/ymfpci.h
94236 @@ -358,7 +358,7 @@ struct snd_ymfpci {
94237 spinlock_t reg_lock;
94238 spinlock_t voice_lock;
94239 wait_queue_head_t interrupt_sleep;
94240 - atomic_t interrupt_sleep_count;
94241 + atomic_unchecked_t interrupt_sleep_count;
94242 struct snd_info_entry *proc_entry;
94243 const struct firmware *dsp_microcode;
94244 const struct firmware *controller_microcode;
94245 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
94246 index 22056c5..25d3244 100644
94247 --- a/sound/pci/ymfpci/ymfpci_main.c
94248 +++ b/sound/pci/ymfpci/ymfpci_main.c
94249 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
94250 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
94251 break;
94252 }
94253 - if (atomic_read(&chip->interrupt_sleep_count)) {
94254 - atomic_set(&chip->interrupt_sleep_count, 0);
94255 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94256 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94257 wake_up(&chip->interrupt_sleep);
94258 }
94259 __end:
94260 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
94261 continue;
94262 init_waitqueue_entry(&wait, current);
94263 add_wait_queue(&chip->interrupt_sleep, &wait);
94264 - atomic_inc(&chip->interrupt_sleep_count);
94265 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
94266 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
94267 remove_wait_queue(&chip->interrupt_sleep, &wait);
94268 }
94269 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
94270 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
94271 spin_unlock(&chip->reg_lock);
94272
94273 - if (atomic_read(&chip->interrupt_sleep_count)) {
94274 - atomic_set(&chip->interrupt_sleep_count, 0);
94275 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94276 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94277 wake_up(&chip->interrupt_sleep);
94278 }
94279 }
94280 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
94281 spin_lock_init(&chip->reg_lock);
94282 spin_lock_init(&chip->voice_lock);
94283 init_waitqueue_head(&chip->interrupt_sleep);
94284 - atomic_set(&chip->interrupt_sleep_count, 0);
94285 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94286 chip->card = card;
94287 chip->pci = pci;
94288 chip->irq = -1;
94289 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
94290 index 0f0bed6..c161e28 100644
94291 --- a/sound/soc/fsl/fsl_ssi.c
94292 +++ b/sound/soc/fsl/fsl_ssi.c
94293 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
94294 {
94295 struct fsl_ssi_private *ssi_private;
94296 int ret = 0;
94297 - struct device_attribute *dev_attr = NULL;
94298 + device_attribute_no_const *dev_attr = NULL;
94299 struct device_node *np = pdev->dev.of_node;
94300 const char *p, *sprop;
94301 const uint32_t *iprop;
94302 diff --git a/sound/sound_core.c b/sound/sound_core.c
94303 index 359753f..45759f4 100644
94304 --- a/sound/sound_core.c
94305 +++ b/sound/sound_core.c
94306 @@ -292,7 +292,7 @@ retry:
94307 }
94308
94309 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
94310 - NULL, s->name+6);
94311 + NULL, "%s", s->name+6);
94312 return s->unit_minor;
94313
94314 fail:
94315 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
94316 new file mode 100644
94317 index 0000000..50f2f2f
94318 --- /dev/null
94319 +++ b/tools/gcc/.gitignore
94320 @@ -0,0 +1 @@
94321 +size_overflow_hash.h
94322 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
94323 new file mode 100644
94324 index 0000000..144dbee
94325 --- /dev/null
94326 +++ b/tools/gcc/Makefile
94327 @@ -0,0 +1,45 @@
94328 +#CC := gcc
94329 +#PLUGIN_SOURCE_FILES := pax_plugin.c
94330 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
94331 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
94332 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
94333 +
94334 +ifeq ($(PLUGINCC),$(HOSTCC))
94335 +HOSTLIBS := hostlibs
94336 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
94337 +else
94338 +HOSTLIBS := hostcxxlibs
94339 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
94340 +endif
94341 +
94342 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
94343 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
94344 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
94345 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
94346 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
94347 +$(HOSTLIBS)-y += colorize_plugin.so
94348 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
94349 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
94350 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
94351 +
94352 +always := $($(HOSTLIBS)-y)
94353 +
94354 +constify_plugin-objs := constify_plugin.o
94355 +stackleak_plugin-objs := stackleak_plugin.o
94356 +kallocstat_plugin-objs := kallocstat_plugin.o
94357 +kernexec_plugin-objs := kernexec_plugin.o
94358 +checker_plugin-objs := checker_plugin.o
94359 +colorize_plugin-objs := colorize_plugin.o
94360 +size_overflow_plugin-objs := size_overflow_plugin.o
94361 +latent_entropy_plugin-objs := latent_entropy_plugin.o
94362 +structleak_plugin-objs := structleak_plugin.o
94363 +
94364 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
94365 +
94366 +quiet_cmd_build_size_overflow_hash = GENHASH $@
94367 + cmd_build_size_overflow_hash = \
94368 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
94369 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
94370 + $(call if_changed,build_size_overflow_hash)
94371 +
94372 +targets += size_overflow_hash.h
94373 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94374 new file mode 100644
94375 index 0000000..22f03c0
94376 --- /dev/null
94377 +++ b/tools/gcc/checker_plugin.c
94378 @@ -0,0 +1,172 @@
94379 +/*
94380 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94381 + * Licensed under the GPL v2
94382 + *
94383 + * Note: the choice of the license means that the compilation process is
94384 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94385 + * but for the kernel it doesn't matter since it doesn't link against
94386 + * any of the gcc libraries
94387 + *
94388 + * gcc plugin to implement various sparse (source code checker) features
94389 + *
94390 + * TODO:
94391 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94392 + *
94393 + * BUGS:
94394 + * - none known
94395 + */
94396 +#include "gcc-plugin.h"
94397 +#include "config.h"
94398 +#include "system.h"
94399 +#include "coretypes.h"
94400 +#include "tree.h"
94401 +#include "tree-pass.h"
94402 +#include "flags.h"
94403 +#include "intl.h"
94404 +#include "toplev.h"
94405 +#include "plugin.h"
94406 +//#include "expr.h" where are you...
94407 +#include "diagnostic.h"
94408 +#include "plugin-version.h"
94409 +#include "tm.h"
94410 +#include "function.h"
94411 +#include "basic-block.h"
94412 +#include "gimple.h"
94413 +#include "rtl.h"
94414 +#include "emit-rtl.h"
94415 +#include "tree-flow.h"
94416 +#include "target.h"
94417 +
94418 +extern void c_register_addr_space (const char *str, addr_space_t as);
94419 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94420 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94421 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94422 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94423 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94424 +
94425 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94426 +extern rtx emit_move_insn(rtx x, rtx y);
94427 +
94428 +int plugin_is_GPL_compatible;
94429 +
94430 +static struct plugin_info checker_plugin_info = {
94431 + .version = "201111150100",
94432 + .help = NULL,
94433 +};
94434 +
94435 +#define ADDR_SPACE_KERNEL 0
94436 +#define ADDR_SPACE_FORCE_KERNEL 1
94437 +#define ADDR_SPACE_USER 2
94438 +#define ADDR_SPACE_FORCE_USER 3
94439 +#define ADDR_SPACE_IOMEM 0
94440 +#define ADDR_SPACE_FORCE_IOMEM 0
94441 +#define ADDR_SPACE_PERCPU 0
94442 +#define ADDR_SPACE_FORCE_PERCPU 0
94443 +#define ADDR_SPACE_RCU 0
94444 +#define ADDR_SPACE_FORCE_RCU 0
94445 +
94446 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94447 +{
94448 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94449 +}
94450 +
94451 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94452 +{
94453 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94454 +}
94455 +
94456 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94457 +{
94458 + return default_addr_space_valid_pointer_mode(mode, as);
94459 +}
94460 +
94461 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94462 +{
94463 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94464 +}
94465 +
94466 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94467 +{
94468 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94469 +}
94470 +
94471 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94472 +{
94473 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94474 + return true;
94475 +
94476 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94477 + return true;
94478 +
94479 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94480 + return true;
94481 +
94482 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94483 + return true;
94484 +
94485 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94486 + return true;
94487 +
94488 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94489 + return true;
94490 +
94491 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94492 + return true;
94493 +
94494 + return subset == superset;
94495 +}
94496 +
94497 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94498 +{
94499 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94500 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94501 +
94502 + return op;
94503 +}
94504 +
94505 +static void register_checker_address_spaces(void *event_data, void *data)
94506 +{
94507 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94508 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94509 + c_register_addr_space("__user", ADDR_SPACE_USER);
94510 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94511 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94512 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94513 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94514 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94515 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94516 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94517 +
94518 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94519 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94520 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94521 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94522 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94523 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94524 + targetm.addr_space.convert = checker_addr_space_convert;
94525 +}
94526 +
94527 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94528 +{
94529 + const char * const plugin_name = plugin_info->base_name;
94530 + const int argc = plugin_info->argc;
94531 + const struct plugin_argument * const argv = plugin_info->argv;
94532 + int i;
94533 +
94534 + if (!plugin_default_version_check(version, &gcc_version)) {
94535 + error(G_("incompatible gcc/plugin versions"));
94536 + return 1;
94537 + }
94538 +
94539 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94540 +
94541 + for (i = 0; i < argc; ++i)
94542 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94543 +
94544 + if (TARGET_64BIT == 0)
94545 + return 0;
94546 +
94547 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94548 +
94549 + return 0;
94550 +}
94551 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94552 new file mode 100644
94553 index 0000000..414fe5e
94554 --- /dev/null
94555 +++ b/tools/gcc/colorize_plugin.c
94556 @@ -0,0 +1,151 @@
94557 +/*
94558 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94559 + * Licensed under the GPL v2
94560 + *
94561 + * Note: the choice of the license means that the compilation process is
94562 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94563 + * but for the kernel it doesn't matter since it doesn't link against
94564 + * any of the gcc libraries
94565 + *
94566 + * gcc plugin to colorize diagnostic output
94567 + *
94568 + */
94569 +
94570 +#include "gcc-plugin.h"
94571 +#include "config.h"
94572 +#include "system.h"
94573 +#include "coretypes.h"
94574 +#include "tree.h"
94575 +#include "tree-pass.h"
94576 +#include "flags.h"
94577 +#include "intl.h"
94578 +#include "toplev.h"
94579 +#include "plugin.h"
94580 +#include "diagnostic.h"
94581 +#include "plugin-version.h"
94582 +#include "tm.h"
94583 +
94584 +int plugin_is_GPL_compatible;
94585 +
94586 +static struct plugin_info colorize_plugin_info = {
94587 + .version = "201302112000",
94588 + .help = NULL,
94589 +};
94590 +
94591 +#define GREEN "\033[32m\033[2m"
94592 +#define LIGHTGREEN "\033[32m\033[1m"
94593 +#define YELLOW "\033[33m\033[2m"
94594 +#define LIGHTYELLOW "\033[33m\033[1m"
94595 +#define RED "\033[31m\033[2m"
94596 +#define LIGHTRED "\033[31m\033[1m"
94597 +#define BLUE "\033[34m\033[2m"
94598 +#define LIGHTBLUE "\033[34m\033[1m"
94599 +#define BRIGHT "\033[m\033[1m"
94600 +#define NORMAL "\033[m"
94601 +
94602 +static diagnostic_starter_fn old_starter;
94603 +static diagnostic_finalizer_fn old_finalizer;
94604 +
94605 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94606 +{
94607 + const char *color;
94608 + char *newprefix;
94609 +
94610 + switch (diagnostic->kind) {
94611 + case DK_NOTE:
94612 + color = LIGHTBLUE;
94613 + break;
94614 +
94615 + case DK_PEDWARN:
94616 + case DK_WARNING:
94617 + color = LIGHTYELLOW;
94618 + break;
94619 +
94620 + case DK_ERROR:
94621 + case DK_FATAL:
94622 + case DK_ICE:
94623 + case DK_PERMERROR:
94624 + case DK_SORRY:
94625 + color = LIGHTRED;
94626 + break;
94627 +
94628 + default:
94629 + color = NORMAL;
94630 + }
94631 +
94632 + old_starter(context, diagnostic);
94633 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94634 + return;
94635 + pp_destroy_prefix(context->printer);
94636 + pp_set_prefix(context->printer, newprefix);
94637 +}
94638 +
94639 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94640 +{
94641 + old_finalizer(context, diagnostic);
94642 +}
94643 +
94644 +static void colorize_arm(void)
94645 +{
94646 + old_starter = diagnostic_starter(global_dc);
94647 + old_finalizer = diagnostic_finalizer(global_dc);
94648 +
94649 + diagnostic_starter(global_dc) = start_colorize;
94650 + diagnostic_finalizer(global_dc) = finalize_colorize;
94651 +}
94652 +
94653 +static unsigned int execute_colorize_rearm(void)
94654 +{
94655 + if (diagnostic_starter(global_dc) == start_colorize)
94656 + return 0;
94657 +
94658 + colorize_arm();
94659 + return 0;
94660 +}
94661 +
94662 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94663 + .pass = {
94664 + .type = SIMPLE_IPA_PASS,
94665 + .name = "colorize_rearm",
94666 +#if BUILDING_GCC_VERSION >= 4008
94667 + .optinfo_flags = OPTGROUP_NONE,
94668 +#endif
94669 + .gate = NULL,
94670 + .execute = execute_colorize_rearm,
94671 + .sub = NULL,
94672 + .next = NULL,
94673 + .static_pass_number = 0,
94674 + .tv_id = TV_NONE,
94675 + .properties_required = 0,
94676 + .properties_provided = 0,
94677 + .properties_destroyed = 0,
94678 + .todo_flags_start = 0,
94679 + .todo_flags_finish = 0
94680 + }
94681 +};
94682 +
94683 +static void colorize_start_unit(void *gcc_data, void *user_data)
94684 +{
94685 + colorize_arm();
94686 +}
94687 +
94688 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94689 +{
94690 + const char * const plugin_name = plugin_info->base_name;
94691 + struct register_pass_info colorize_rearm_pass_info = {
94692 + .pass = &pass_ipa_colorize_rearm.pass,
94693 + .reference_pass_name = "*free_lang_data",
94694 + .ref_pass_instance_number = 1,
94695 + .pos_op = PASS_POS_INSERT_AFTER
94696 + };
94697 +
94698 + if (!plugin_default_version_check(version, &gcc_version)) {
94699 + error(G_("incompatible gcc/plugin versions"));
94700 + return 1;
94701 + }
94702 +
94703 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94704 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94705 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94706 + return 0;
94707 +}
94708 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94709 new file mode 100644
94710 index 0000000..c17312d
94711 --- /dev/null
94712 +++ b/tools/gcc/constify_plugin.c
94713 @@ -0,0 +1,560 @@
94714 +/*
94715 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94716 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94717 + * Licensed under the GPL v2, or (at your option) v3
94718 + *
94719 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94720 + *
94721 + * Homepage:
94722 + * http://www.grsecurity.net/~ephox/const_plugin/
94723 + *
94724 + * Usage:
94725 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94726 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94727 + */
94728 +
94729 +#include "gcc-plugin.h"
94730 +#include "config.h"
94731 +#include "system.h"
94732 +#include "coretypes.h"
94733 +#include "tree.h"
94734 +#include "tree-pass.h"
94735 +#include "flags.h"
94736 +#include "intl.h"
94737 +#include "toplev.h"
94738 +#include "plugin.h"
94739 +#include "diagnostic.h"
94740 +#include "plugin-version.h"
94741 +#include "tm.h"
94742 +#include "function.h"
94743 +#include "basic-block.h"
94744 +#include "gimple.h"
94745 +#include "rtl.h"
94746 +#include "emit-rtl.h"
94747 +#include "tree-flow.h"
94748 +#include "target.h"
94749 +#include "langhooks.h"
94750 +
94751 +// should come from c-tree.h if only it were installed for gcc 4.5...
94752 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94753 +
94754 +// unused type flag in all versions 4.5-4.8
94755 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94756 +
94757 +int plugin_is_GPL_compatible;
94758 +
94759 +static struct plugin_info const_plugin_info = {
94760 + .version = "201305231310",
94761 + .help = "no-constify\tturn off constification\n",
94762 +};
94763 +
94764 +typedef struct {
94765 + bool has_fptr_field;
94766 + bool has_writable_field;
94767 + bool has_do_const_field;
94768 + bool has_no_const_field;
94769 +} constify_info;
94770 +
94771 +static const_tree get_field_type(const_tree field)
94772 +{
94773 + return strip_array_types(TREE_TYPE(field));
94774 +}
94775 +
94776 +static bool is_fptr(const_tree field)
94777 +{
94778 + const_tree ptr = get_field_type(field);
94779 +
94780 + if (TREE_CODE(ptr) != POINTER_TYPE)
94781 + return false;
94782 +
94783 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94784 +}
94785 +
94786 +/*
94787 + * determine whether the given structure type meets the requirements for automatic constification,
94788 + * including the constification attributes on nested structure types
94789 + */
94790 +static void constifiable(const_tree node, constify_info *cinfo)
94791 +{
94792 + const_tree field;
94793 +
94794 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94795 +
94796 + // e.g., pointer to structure fields while still constructing the structure type
94797 + if (TYPE_FIELDS(node) == NULL_TREE)
94798 + return;
94799 +
94800 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94801 + const_tree type = get_field_type(field);
94802 + enum tree_code code = TREE_CODE(type);
94803 +
94804 + if (node == type)
94805 + continue;
94806 +
94807 + if (is_fptr(field))
94808 + cinfo->has_fptr_field = true;
94809 + else if (!TREE_READONLY(field))
94810 + cinfo->has_writable_field = true;
94811 +
94812 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94813 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94814 + cinfo->has_do_const_field = true;
94815 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94816 + cinfo->has_no_const_field = true;
94817 + else
94818 + constifiable(type, cinfo);
94819 + }
94820 + }
94821 +}
94822 +
94823 +static bool constified(const_tree node)
94824 +{
94825 + constify_info cinfo = {
94826 + .has_fptr_field = false,
94827 + .has_writable_field = false,
94828 + .has_do_const_field = false,
94829 + .has_no_const_field = false
94830 + };
94831 +
94832 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94833 +
94834 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94835 + gcc_assert(!TYPE_READONLY(node));
94836 + return false;
94837 + }
94838 +
94839 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94840 + gcc_assert(TYPE_READONLY(node));
94841 + return true;
94842 + }
94843 +
94844 + constifiable(node, &cinfo);
94845 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94846 + return false;
94847 +
94848 + return TYPE_READONLY(node);
94849 +}
94850 +
94851 +static void deconstify_tree(tree node);
94852 +
94853 +static void deconstify_type(tree type)
94854 +{
94855 + tree field;
94856 +
94857 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94858 +
94859 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94860 + const_tree fieldtype = get_field_type(field);
94861 +
94862 + // special case handling of simple ptr-to-same-array-type members
94863 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94864 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94865 +
94866 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94867 + continue;
94868 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94869 + continue;
94870 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94871 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94872 + TREE_TYPE(TREE_TYPE(field)) = type;
94873 + }
94874 + continue;
94875 + }
94876 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94877 + continue;
94878 + if (!constified(fieldtype))
94879 + continue;
94880 +
94881 + deconstify_tree(field);
94882 + TREE_READONLY(field) = 0;
94883 + }
94884 + TYPE_READONLY(type) = 0;
94885 + C_TYPE_FIELDS_READONLY(type) = 0;
94886 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94887 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94888 +}
94889 +
94890 +static void deconstify_tree(tree node)
94891 +{
94892 + tree old_type, new_type, field;
94893 +
94894 + old_type = TREE_TYPE(node);
94895 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94896 + node = TREE_TYPE(node) = copy_node(old_type);
94897 + old_type = TREE_TYPE(old_type);
94898 + }
94899 +
94900 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94901 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94902 +
94903 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94904 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94905 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94906 + DECL_FIELD_CONTEXT(field) = new_type;
94907 +
94908 + deconstify_type(new_type);
94909 +
94910 + TREE_TYPE(node) = new_type;
94911 +}
94912 +
94913 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94914 +{
94915 + tree type;
94916 + constify_info cinfo = {
94917 + .has_fptr_field = false,
94918 + .has_writable_field = false,
94919 + .has_do_const_field = false,
94920 + .has_no_const_field = false
94921 + };
94922 +
94923 + *no_add_attrs = true;
94924 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94925 + error("%qE attribute does not apply to functions", name);
94926 + return NULL_TREE;
94927 + }
94928 +
94929 + if (TREE_CODE(*node) == PARM_DECL) {
94930 + error("%qE attribute does not apply to function parameters", name);
94931 + return NULL_TREE;
94932 + }
94933 +
94934 + if (TREE_CODE(*node) == VAR_DECL) {
94935 + error("%qE attribute does not apply to variables", name);
94936 + return NULL_TREE;
94937 + }
94938 +
94939 + if (TYPE_P(*node)) {
94940 + *no_add_attrs = false;
94941 + type = *node;
94942 + } else {
94943 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94944 + type = TREE_TYPE(*node);
94945 + }
94946 +
94947 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94948 + error("%qE attribute applies to struct and union types only", name);
94949 + return NULL_TREE;
94950 + }
94951 +
94952 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94953 + error("%qE attribute is already applied to the type", name);
94954 + return NULL_TREE;
94955 + }
94956 +
94957 + if (TYPE_P(*node)) {
94958 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94959 + error("%qE attribute is incompatible with 'do_const'", name);
94960 + return NULL_TREE;
94961 + }
94962 +
94963 + constifiable(type, &cinfo);
94964 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94965 + deconstify_tree(*node);
94966 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94967 + return NULL_TREE;
94968 + }
94969 +
94970 + error("%qE attribute used on type that is not constified", name);
94971 + return NULL_TREE;
94972 +}
94973 +
94974 +static void constify_type(tree type)
94975 +{
94976 + TYPE_READONLY(type) = 1;
94977 + C_TYPE_FIELDS_READONLY(type) = 1;
94978 + TYPE_CONSTIFY_VISITED(type) = 1;
94979 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94980 +}
94981 +
94982 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94983 +{
94984 + *no_add_attrs = true;
94985 + if (!TYPE_P(*node)) {
94986 + error("%qE attribute applies to types only", name);
94987 + return NULL_TREE;
94988 + }
94989 +
94990 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94991 + error("%qE attribute applies to struct and union types only", name);
94992 + return NULL_TREE;
94993 + }
94994 +
94995 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94996 + error("%qE attribute is already applied to the type", name);
94997 + return NULL_TREE;
94998 + }
94999 +
95000 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
95001 + error("%qE attribute is incompatible with 'no_const'", name);
95002 + return NULL_TREE;
95003 + }
95004 +
95005 + *no_add_attrs = false;
95006 + return NULL_TREE;
95007 +}
95008 +
95009 +static struct attribute_spec no_const_attr = {
95010 + .name = "no_const",
95011 + .min_length = 0,
95012 + .max_length = 0,
95013 + .decl_required = false,
95014 + .type_required = false,
95015 + .function_type_required = false,
95016 + .handler = handle_no_const_attribute,
95017 +#if BUILDING_GCC_VERSION >= 4007
95018 + .affects_type_identity = true
95019 +#endif
95020 +};
95021 +
95022 +static struct attribute_spec do_const_attr = {
95023 + .name = "do_const",
95024 + .min_length = 0,
95025 + .max_length = 0,
95026 + .decl_required = false,
95027 + .type_required = false,
95028 + .function_type_required = false,
95029 + .handler = handle_do_const_attribute,
95030 +#if BUILDING_GCC_VERSION >= 4007
95031 + .affects_type_identity = true
95032 +#endif
95033 +};
95034 +
95035 +static void register_attributes(void *event_data, void *data)
95036 +{
95037 + register_attribute(&no_const_attr);
95038 + register_attribute(&do_const_attr);
95039 +}
95040 +
95041 +static void finish_type(void *event_data, void *data)
95042 +{
95043 + tree type = (tree)event_data;
95044 + constify_info cinfo = {
95045 + .has_fptr_field = false,
95046 + .has_writable_field = false,
95047 + .has_do_const_field = false,
95048 + .has_no_const_field = false
95049 + };
95050 +
95051 + if (type == NULL_TREE || type == error_mark_node)
95052 + return;
95053 +
95054 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
95055 + return;
95056 +
95057 + constifiable(type, &cinfo);
95058 +
95059 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
95060 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95061 + return;
95062 + if (cinfo.has_writable_field)
95063 + return;
95064 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
95065 + return;
95066 + }
95067 +
95068 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
95069 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
95070 + deconstify_type(type);
95071 + TYPE_CONSTIFY_VISITED(type) = 1;
95072 + } else
95073 + error("'no_const' attribute used on type that is not constified");
95074 + return;
95075 + }
95076 +
95077 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95078 + constify_type(type);
95079 + return;
95080 + }
95081 +
95082 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
95083 + constify_type(type);
95084 + return;
95085 + }
95086 +
95087 + deconstify_type(type);
95088 + TYPE_CONSTIFY_VISITED(type) = 1;
95089 +}
95090 +
95091 +static void check_global_variables(void)
95092 +{
95093 + struct varpool_node *node;
95094 +
95095 +#if BUILDING_GCC_VERSION <= 4007
95096 + for (node = varpool_nodes; node; node = node->next) {
95097 + tree var = node->decl;
95098 +#else
95099 + FOR_EACH_VARIABLE(node) {
95100 + tree var = node->symbol.decl;
95101 +#endif
95102 + tree type = TREE_TYPE(var);
95103 +
95104 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95105 + continue;
95106 +
95107 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95108 + continue;
95109 +
95110 + if (!TYPE_CONSTIFY_VISITED(type))
95111 + continue;
95112 +
95113 + if (DECL_EXTERNAL(var))
95114 + continue;
95115 +
95116 + if (DECL_INITIAL(var))
95117 + continue;
95118 +
95119 + // this works around a gcc bug/feature where uninitialized globals
95120 + // are moved into the .bss section regardless of any constification
95121 + DECL_INITIAL(var) = build_constructor(type, NULL);
95122 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
95123 + }
95124 +}
95125 +
95126 +static unsigned int check_local_variables(void)
95127 +{
95128 + unsigned int ret = 0;
95129 + tree var;
95130 +
95131 +#if BUILDING_GCC_VERSION == 4005
95132 + tree vars;
95133 +#else
95134 + unsigned int i;
95135 +#endif
95136 +
95137 +#if BUILDING_GCC_VERSION == 4005
95138 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
95139 + var = TREE_VALUE(vars);
95140 +#else
95141 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
95142 +#endif
95143 + tree type = TREE_TYPE(var);
95144 +
95145 + gcc_assert(DECL_P(var));
95146 + if (is_global_var(var))
95147 + continue;
95148 +
95149 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95150 + continue;
95151 +
95152 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95153 + continue;
95154 +
95155 + if (!TYPE_CONSTIFY_VISITED(type))
95156 + continue;
95157 +
95158 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
95159 + ret = 1;
95160 + }
95161 + return ret;
95162 +}
95163 +
95164 +static unsigned int check_variables(void)
95165 +{
95166 + check_global_variables();
95167 + return check_local_variables();
95168 +}
95169 +
95170 + unsigned int ret = 0;
95171 +static struct gimple_opt_pass pass_local_variable = {
95172 + {
95173 + .type = GIMPLE_PASS,
95174 + .name = "check_variables",
95175 +#if BUILDING_GCC_VERSION >= 4008
95176 + .optinfo_flags = OPTGROUP_NONE,
95177 +#endif
95178 + .gate = NULL,
95179 + .execute = check_variables,
95180 + .sub = NULL,
95181 + .next = NULL,
95182 + .static_pass_number = 0,
95183 + .tv_id = TV_NONE,
95184 + .properties_required = 0,
95185 + .properties_provided = 0,
95186 + .properties_destroyed = 0,
95187 + .todo_flags_start = 0,
95188 + .todo_flags_finish = 0
95189 + }
95190 +};
95191 +
95192 +static struct {
95193 + const char *name;
95194 + const char *asm_op;
95195 +} sections[] = {
95196 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
95197 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
95198 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
95199 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
95200 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
95201 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
95202 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
95203 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
95204 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
95205 +};
95206 +
95207 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
95208 +
95209 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
95210 +{
95211 + size_t i;
95212 +
95213 + for (i = 0; i < ARRAY_SIZE(sections); i++)
95214 + if (!strcmp(sections[i].name, name))
95215 + return 0;
95216 + return old_section_type_flags(decl, name, reloc);
95217 +}
95218 +
95219 +static void constify_start_unit(void *gcc_data, void *user_data)
95220 +{
95221 +// size_t i;
95222 +
95223 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
95224 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
95225 +// sections[i].section = get_section(sections[i].name, 0, NULL);
95226 +
95227 + old_section_type_flags = targetm.section_type_flags;
95228 + targetm.section_type_flags = constify_section_type_flags;
95229 +}
95230 +
95231 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95232 +{
95233 + const char * const plugin_name = plugin_info->base_name;
95234 + const int argc = plugin_info->argc;
95235 + const struct plugin_argument * const argv = plugin_info->argv;
95236 + int i;
95237 + bool constify = true;
95238 +
95239 + struct register_pass_info local_variable_pass_info = {
95240 + .pass = &pass_local_variable.pass,
95241 + .reference_pass_name = "ssa",
95242 + .ref_pass_instance_number = 1,
95243 + .pos_op = PASS_POS_INSERT_BEFORE
95244 + };
95245 +
95246 + if (!plugin_default_version_check(version, &gcc_version)) {
95247 + error(G_("incompatible gcc/plugin versions"));
95248 + return 1;
95249 + }
95250 +
95251 + for (i = 0; i < argc; ++i) {
95252 + if (!(strcmp(argv[i].key, "no-constify"))) {
95253 + constify = false;
95254 + continue;
95255 + }
95256 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95257 + }
95258 +
95259 + if (strcmp(lang_hooks.name, "GNU C")) {
95260 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
95261 + constify = false;
95262 + }
95263 +
95264 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
95265 + if (constify) {
95266 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
95267 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
95268 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
95269 + }
95270 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95271 +
95272 + return 0;
95273 +}
95274 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
95275 new file mode 100644
95276 index 0000000..e518932
95277 --- /dev/null
95278 +++ b/tools/gcc/generate_size_overflow_hash.sh
95279 @@ -0,0 +1,94 @@
95280 +#!/bin/bash
95281 +
95282 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
95283 +
95284 +header1="size_overflow_hash.h"
95285 +database="size_overflow_hash.data"
95286 +n=65536
95287 +
95288 +usage() {
95289 +cat <<EOF
95290 +usage: $0 options
95291 +OPTIONS:
95292 + -h|--help help
95293 + -o header file
95294 + -d database file
95295 + -n hash array size
95296 +EOF
95297 + return 0
95298 +}
95299 +
95300 +while true
95301 +do
95302 + case "$1" in
95303 + -h|--help) usage && exit 0;;
95304 + -n) n=$2; shift 2;;
95305 + -o) header1="$2"; shift 2;;
95306 + -d) database="$2"; shift 2;;
95307 + --) shift 1; break ;;
95308 + *) break ;;
95309 + esac
95310 +done
95311 +
95312 +create_defines() {
95313 + for i in `seq 0 31`
95314 + do
95315 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
95316 + done
95317 + echo >> "$header1"
95318 +}
95319 +
95320 +create_structs() {
95321 + rm -f "$header1"
95322 +
95323 + create_defines
95324 +
95325 + cat "$database" | while read data
95326 + do
95327 + data_array=($data)
95328 + struct_hash_name="${data_array[0]}"
95329 + funcn="${data_array[1]}"
95330 + params="${data_array[2]}"
95331 + next="${data_array[4]}"
95332 +
95333 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
95334 +
95335 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
95336 + echo -en "\t.param\t= " >> "$header1"
95337 + line=
95338 + for param_num in ${params//-/ };
95339 + do
95340 + line="${line}PARAM"$param_num"|"
95341 + done
95342 +
95343 + echo -e "${line%?},\n};\n" >> "$header1"
95344 + done
95345 +}
95346 +
95347 +create_headers() {
95348 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
95349 +}
95350 +
95351 +create_array_elements() {
95352 + index=0
95353 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
95354 + do
95355 + data_array=($data)
95356 + i="${data_array[3]}"
95357 + hash="${data_array[0]}"
95358 + while [[ $index -lt $i ]]
95359 + do
95360 + echo -e "\t["$index"]\t= NULL," >> "$header1"
95361 + index=$(($index + 1))
95362 + done
95363 + index=$(($index + 1))
95364 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
95365 + done
95366 + echo '};' >> $header1
95367 +}
95368 +
95369 +create_structs
95370 +create_headers
95371 +create_array_elements
95372 +
95373 +exit 0
95374 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95375 new file mode 100644
95376 index 0000000..568b360
95377 --- /dev/null
95378 +++ b/tools/gcc/kallocstat_plugin.c
95379 @@ -0,0 +1,170 @@
95380 +/*
95381 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95382 + * Licensed under the GPL v2
95383 + *
95384 + * Note: the choice of the license means that the compilation process is
95385 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95386 + * but for the kernel it doesn't matter since it doesn't link against
95387 + * any of the gcc libraries
95388 + *
95389 + * gcc plugin to find the distribution of k*alloc sizes
95390 + *
95391 + * TODO:
95392 + *
95393 + * BUGS:
95394 + * - none known
95395 + */
95396 +#include "gcc-plugin.h"
95397 +#include "config.h"
95398 +#include "system.h"
95399 +#include "coretypes.h"
95400 +#include "tree.h"
95401 +#include "tree-pass.h"
95402 +#include "flags.h"
95403 +#include "intl.h"
95404 +#include "toplev.h"
95405 +#include "plugin.h"
95406 +//#include "expr.h" where are you...
95407 +#include "diagnostic.h"
95408 +#include "plugin-version.h"
95409 +#include "tm.h"
95410 +#include "function.h"
95411 +#include "basic-block.h"
95412 +#include "gimple.h"
95413 +#include "rtl.h"
95414 +#include "emit-rtl.h"
95415 +
95416 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95417 +
95418 +int plugin_is_GPL_compatible;
95419 +
95420 +static const char * const kalloc_functions[] = {
95421 + "__kmalloc",
95422 + "kmalloc",
95423 + "kmalloc_large",
95424 + "kmalloc_node",
95425 + "kmalloc_order",
95426 + "kmalloc_order_trace",
95427 + "kmalloc_slab",
95428 + "kzalloc",
95429 + "kzalloc_node",
95430 +};
95431 +
95432 +static struct plugin_info kallocstat_plugin_info = {
95433 + .version = "201302112000",
95434 +};
95435 +
95436 +static unsigned int execute_kallocstat(void);
95437 +
95438 +static struct gimple_opt_pass kallocstat_pass = {
95439 + .pass = {
95440 + .type = GIMPLE_PASS,
95441 + .name = "kallocstat",
95442 +#if BUILDING_GCC_VERSION >= 4008
95443 + .optinfo_flags = OPTGROUP_NONE,
95444 +#endif
95445 + .gate = NULL,
95446 + .execute = execute_kallocstat,
95447 + .sub = NULL,
95448 + .next = NULL,
95449 + .static_pass_number = 0,
95450 + .tv_id = TV_NONE,
95451 + .properties_required = 0,
95452 + .properties_provided = 0,
95453 + .properties_destroyed = 0,
95454 + .todo_flags_start = 0,
95455 + .todo_flags_finish = 0
95456 + }
95457 +};
95458 +
95459 +static bool is_kalloc(const char *fnname)
95460 +{
95461 + size_t i;
95462 +
95463 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95464 + if (!strcmp(fnname, kalloc_functions[i]))
95465 + return true;
95466 + return false;
95467 +}
95468 +
95469 +static unsigned int execute_kallocstat(void)
95470 +{
95471 + basic_block bb;
95472 +
95473 + // 1. loop through BBs and GIMPLE statements
95474 + FOR_EACH_BB(bb) {
95475 + gimple_stmt_iterator gsi;
95476 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95477 + // gimple match:
95478 + tree fndecl, size;
95479 + gimple call_stmt;
95480 + const char *fnname;
95481 +
95482 + // is it a call
95483 + call_stmt = gsi_stmt(gsi);
95484 + if (!is_gimple_call(call_stmt))
95485 + continue;
95486 + fndecl = gimple_call_fndecl(call_stmt);
95487 + if (fndecl == NULL_TREE)
95488 + continue;
95489 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95490 + continue;
95491 +
95492 + // is it a call to k*alloc
95493 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95494 + if (!is_kalloc(fnname))
95495 + continue;
95496 +
95497 + // is the size arg the result of a simple const assignment
95498 + size = gimple_call_arg(call_stmt, 0);
95499 + while (true) {
95500 + gimple def_stmt;
95501 + expanded_location xloc;
95502 + size_t size_val;
95503 +
95504 + if (TREE_CODE(size) != SSA_NAME)
95505 + break;
95506 + def_stmt = SSA_NAME_DEF_STMT(size);
95507 + if (!def_stmt || !is_gimple_assign(def_stmt))
95508 + break;
95509 + if (gimple_num_ops(def_stmt) != 2)
95510 + break;
95511 + size = gimple_assign_rhs1(def_stmt);
95512 + if (!TREE_CONSTANT(size))
95513 + continue;
95514 + xloc = expand_location(gimple_location(def_stmt));
95515 + if (!xloc.file)
95516 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95517 + size_val = TREE_INT_CST_LOW(size);
95518 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95519 + break;
95520 + }
95521 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95522 +//debug_tree(gimple_call_fn(call_stmt));
95523 +//print_node(stderr, "pax", fndecl, 4);
95524 + }
95525 + }
95526 +
95527 + return 0;
95528 +}
95529 +
95530 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95531 +{
95532 + const char * const plugin_name = plugin_info->base_name;
95533 + struct register_pass_info kallocstat_pass_info = {
95534 + .pass = &kallocstat_pass.pass,
95535 + .reference_pass_name = "ssa",
95536 + .ref_pass_instance_number = 1,
95537 + .pos_op = PASS_POS_INSERT_AFTER
95538 + };
95539 +
95540 + if (!plugin_default_version_check(version, &gcc_version)) {
95541 + error(G_("incompatible gcc/plugin versions"));
95542 + return 1;
95543 + }
95544 +
95545 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95546 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95547 +
95548 + return 0;
95549 +}
95550 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95551 new file mode 100644
95552 index 0000000..0408e06
95553 --- /dev/null
95554 +++ b/tools/gcc/kernexec_plugin.c
95555 @@ -0,0 +1,465 @@
95556 +/*
95557 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95558 + * Licensed under the GPL v2
95559 + *
95560 + * Note: the choice of the license means that the compilation process is
95561 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95562 + * but for the kernel it doesn't matter since it doesn't link against
95563 + * any of the gcc libraries
95564 + *
95565 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95566 + *
95567 + * TODO:
95568 + *
95569 + * BUGS:
95570 + * - none known
95571 + */
95572 +#include "gcc-plugin.h"
95573 +#include "config.h"
95574 +#include "system.h"
95575 +#include "coretypes.h"
95576 +#include "tree.h"
95577 +#include "tree-pass.h"
95578 +#include "flags.h"
95579 +#include "intl.h"
95580 +#include "toplev.h"
95581 +#include "plugin.h"
95582 +//#include "expr.h" where are you...
95583 +#include "diagnostic.h"
95584 +#include "plugin-version.h"
95585 +#include "tm.h"
95586 +#include "function.h"
95587 +#include "basic-block.h"
95588 +#include "gimple.h"
95589 +#include "rtl.h"
95590 +#include "emit-rtl.h"
95591 +#include "tree-flow.h"
95592 +
95593 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95594 +extern rtx emit_move_insn(rtx x, rtx y);
95595 +
95596 +#if BUILDING_GCC_VERSION <= 4006
95597 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95598 +#endif
95599 +
95600 +#if BUILDING_GCC_VERSION >= 4008
95601 +#define TODO_dump_func 0
95602 +#endif
95603 +
95604 +int plugin_is_GPL_compatible;
95605 +
95606 +static struct plugin_info kernexec_plugin_info = {
95607 + .version = "201302112000",
95608 + .help = "method=[bts|or]\tinstrumentation method\n"
95609 +};
95610 +
95611 +static unsigned int execute_kernexec_reload(void);
95612 +static unsigned int execute_kernexec_fptr(void);
95613 +static unsigned int execute_kernexec_retaddr(void);
95614 +static bool kernexec_cmodel_check(void);
95615 +
95616 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95617 +static void (*kernexec_instrument_retaddr)(rtx);
95618 +
95619 +static struct gimple_opt_pass kernexec_reload_pass = {
95620 + .pass = {
95621 + .type = GIMPLE_PASS,
95622 + .name = "kernexec_reload",
95623 +#if BUILDING_GCC_VERSION >= 4008
95624 + .optinfo_flags = OPTGROUP_NONE,
95625 +#endif
95626 + .gate = kernexec_cmodel_check,
95627 + .execute = execute_kernexec_reload,
95628 + .sub = NULL,
95629 + .next = NULL,
95630 + .static_pass_number = 0,
95631 + .tv_id = TV_NONE,
95632 + .properties_required = 0,
95633 + .properties_provided = 0,
95634 + .properties_destroyed = 0,
95635 + .todo_flags_start = 0,
95636 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95637 + }
95638 +};
95639 +
95640 +static struct gimple_opt_pass kernexec_fptr_pass = {
95641 + .pass = {
95642 + .type = GIMPLE_PASS,
95643 + .name = "kernexec_fptr",
95644 +#if BUILDING_GCC_VERSION >= 4008
95645 + .optinfo_flags = OPTGROUP_NONE,
95646 +#endif
95647 + .gate = kernexec_cmodel_check,
95648 + .execute = execute_kernexec_fptr,
95649 + .sub = NULL,
95650 + .next = NULL,
95651 + .static_pass_number = 0,
95652 + .tv_id = TV_NONE,
95653 + .properties_required = 0,
95654 + .properties_provided = 0,
95655 + .properties_destroyed = 0,
95656 + .todo_flags_start = 0,
95657 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95658 + }
95659 +};
95660 +
95661 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95662 + .pass = {
95663 + .type = RTL_PASS,
95664 + .name = "kernexec_retaddr",
95665 +#if BUILDING_GCC_VERSION >= 4008
95666 + .optinfo_flags = OPTGROUP_NONE,
95667 +#endif
95668 + .gate = kernexec_cmodel_check,
95669 + .execute = execute_kernexec_retaddr,
95670 + .sub = NULL,
95671 + .next = NULL,
95672 + .static_pass_number = 0,
95673 + .tv_id = TV_NONE,
95674 + .properties_required = 0,
95675 + .properties_provided = 0,
95676 + .properties_destroyed = 0,
95677 + .todo_flags_start = 0,
95678 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95679 + }
95680 +};
95681 +
95682 +static bool kernexec_cmodel_check(void)
95683 +{
95684 + tree section;
95685 +
95686 + if (ix86_cmodel != CM_KERNEL)
95687 + return false;
95688 +
95689 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95690 + if (!section || !TREE_VALUE(section))
95691 + return true;
95692 +
95693 + section = TREE_VALUE(TREE_VALUE(section));
95694 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95695 + return true;
95696 +
95697 + return false;
95698 +}
95699 +
95700 +/*
95701 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95702 + */
95703 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95704 +{
95705 + gimple asm_movabs_stmt;
95706 +
95707 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95708 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95709 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95710 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95711 + update_stmt(asm_movabs_stmt);
95712 +}
95713 +
95714 +/*
95715 + * find all asm() stmts that clobber r10 and add a reload of r10
95716 + */
95717 +static unsigned int execute_kernexec_reload(void)
95718 +{
95719 + basic_block bb;
95720 +
95721 + // 1. loop through BBs and GIMPLE statements
95722 + FOR_EACH_BB(bb) {
95723 + gimple_stmt_iterator gsi;
95724 +
95725 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95726 + // gimple match: __asm__ ("" : : : "r10");
95727 + gimple asm_stmt;
95728 + size_t nclobbers;
95729 +
95730 + // is it an asm ...
95731 + asm_stmt = gsi_stmt(gsi);
95732 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95733 + continue;
95734 +
95735 + // ... clobbering r10
95736 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95737 + while (nclobbers--) {
95738 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95739 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95740 + continue;
95741 + kernexec_reload_fptr_mask(&gsi);
95742 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95743 + break;
95744 + }
95745 + }
95746 + }
95747 +
95748 + return 0;
95749 +}
95750 +
95751 +/*
95752 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95753 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95754 + */
95755 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95756 +{
95757 + gimple assign_intptr, assign_new_fptr, call_stmt;
95758 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95759 +
95760 + call_stmt = gsi_stmt(*gsi);
95761 + old_fptr = gimple_call_fn(call_stmt);
95762 +
95763 + // create temporary unsigned long variable used for bitops and cast fptr to it
95764 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95765 +#if BUILDING_GCC_VERSION <= 4007
95766 + add_referenced_var(intptr);
95767 + mark_sym_for_renaming(intptr);
95768 +#endif
95769 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95770 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95771 + update_stmt(assign_intptr);
95772 +
95773 + // apply logical or to temporary unsigned long and bitmask
95774 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95775 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95776 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95777 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95778 + update_stmt(assign_intptr);
95779 +
95780 + // cast temporary unsigned long back to a temporary fptr variable
95781 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95782 +#if BUILDING_GCC_VERSION <= 4007
95783 + add_referenced_var(new_fptr);
95784 + mark_sym_for_renaming(new_fptr);
95785 +#endif
95786 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95787 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95788 + update_stmt(assign_new_fptr);
95789 +
95790 + // replace call stmt fn with the new fptr
95791 + gimple_call_set_fn(call_stmt, new_fptr);
95792 + update_stmt(call_stmt);
95793 +}
95794 +
95795 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95796 +{
95797 + gimple asm_or_stmt, call_stmt;
95798 + tree old_fptr, new_fptr, input, output;
95799 +#if BUILDING_GCC_VERSION <= 4007
95800 + VEC(tree, gc) *inputs = NULL;
95801 + VEC(tree, gc) *outputs = NULL;
95802 +#else
95803 + vec<tree, va_gc> *inputs = NULL;
95804 + vec<tree, va_gc> *outputs = NULL;
95805 +#endif
95806 +
95807 + call_stmt = gsi_stmt(*gsi);
95808 + old_fptr = gimple_call_fn(call_stmt);
95809 +
95810 + // create temporary fptr variable
95811 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95812 +#if BUILDING_GCC_VERSION <= 4007
95813 + add_referenced_var(new_fptr);
95814 + mark_sym_for_renaming(new_fptr);
95815 +#endif
95816 +
95817 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95818 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95819 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95820 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95821 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95822 +#if BUILDING_GCC_VERSION <= 4007
95823 + VEC_safe_push(tree, gc, inputs, input);
95824 + VEC_safe_push(tree, gc, outputs, output);
95825 +#else
95826 + vec_safe_push(inputs, input);
95827 + vec_safe_push(outputs, output);
95828 +#endif
95829 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95830 + gimple_asm_set_volatile(asm_or_stmt, true);
95831 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95832 + update_stmt(asm_or_stmt);
95833 +
95834 + // replace call stmt fn with the new fptr
95835 + gimple_call_set_fn(call_stmt, new_fptr);
95836 + update_stmt(call_stmt);
95837 +}
95838 +
95839 +/*
95840 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95841 + */
95842 +static unsigned int execute_kernexec_fptr(void)
95843 +{
95844 + basic_block bb;
95845 +
95846 + // 1. loop through BBs and GIMPLE statements
95847 + FOR_EACH_BB(bb) {
95848 + gimple_stmt_iterator gsi;
95849 +
95850 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95851 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95852 + tree fn;
95853 + gimple call_stmt;
95854 +
95855 + // is it a call ...
95856 + call_stmt = gsi_stmt(gsi);
95857 + if (!is_gimple_call(call_stmt))
95858 + continue;
95859 + fn = gimple_call_fn(call_stmt);
95860 + if (TREE_CODE(fn) == ADDR_EXPR)
95861 + continue;
95862 + if (TREE_CODE(fn) != SSA_NAME)
95863 + gcc_unreachable();
95864 +
95865 + // ... through a function pointer
95866 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95867 + fn = SSA_NAME_VAR(fn);
95868 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95869 + debug_tree(fn);
95870 + gcc_unreachable();
95871 + }
95872 + }
95873 + fn = TREE_TYPE(fn);
95874 + if (TREE_CODE(fn) != POINTER_TYPE)
95875 + continue;
95876 + fn = TREE_TYPE(fn);
95877 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95878 + continue;
95879 +
95880 + kernexec_instrument_fptr(&gsi);
95881 +
95882 +//debug_tree(gimple_call_fn(call_stmt));
95883 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95884 + }
95885 + }
95886 +
95887 + return 0;
95888 +}
95889 +
95890 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95891 +static void kernexec_instrument_retaddr_bts(rtx insn)
95892 +{
95893 + rtx btsq;
95894 + rtvec argvec, constraintvec, labelvec;
95895 + int line;
95896 +
95897 + // create asm volatile("btsq $63,(%%rsp)":::)
95898 + argvec = rtvec_alloc(0);
95899 + constraintvec = rtvec_alloc(0);
95900 + labelvec = rtvec_alloc(0);
95901 + line = expand_location(RTL_LOCATION(insn)).line;
95902 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95903 + MEM_VOLATILE_P(btsq) = 1;
95904 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95905 + emit_insn_before(btsq, insn);
95906 +}
95907 +
95908 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95909 +static void kernexec_instrument_retaddr_or(rtx insn)
95910 +{
95911 + rtx orq;
95912 + rtvec argvec, constraintvec, labelvec;
95913 + int line;
95914 +
95915 + // create asm volatile("orq %%r10,(%%rsp)":::)
95916 + argvec = rtvec_alloc(0);
95917 + constraintvec = rtvec_alloc(0);
95918 + labelvec = rtvec_alloc(0);
95919 + line = expand_location(RTL_LOCATION(insn)).line;
95920 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95921 + MEM_VOLATILE_P(orq) = 1;
95922 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95923 + emit_insn_before(orq, insn);
95924 +}
95925 +
95926 +/*
95927 + * find all asm level function returns and forcibly set the highest bit of the return address
95928 + */
95929 +static unsigned int execute_kernexec_retaddr(void)
95930 +{
95931 + rtx insn;
95932 +
95933 + // 1. find function returns
95934 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95935 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95936 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95937 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95938 + rtx body;
95939 +
95940 + // is it a retn
95941 + if (!JUMP_P(insn))
95942 + continue;
95943 + body = PATTERN(insn);
95944 + if (GET_CODE(body) == PARALLEL)
95945 + body = XVECEXP(body, 0, 0);
95946 + if (!ANY_RETURN_P(body))
95947 + continue;
95948 + kernexec_instrument_retaddr(insn);
95949 + }
95950 +
95951 +// print_simple_rtl(stderr, get_insns());
95952 +// print_rtl(stderr, get_insns());
95953 +
95954 + return 0;
95955 +}
95956 +
95957 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95958 +{
95959 + const char * const plugin_name = plugin_info->base_name;
95960 + const int argc = plugin_info->argc;
95961 + const struct plugin_argument * const argv = plugin_info->argv;
95962 + int i;
95963 + struct register_pass_info kernexec_reload_pass_info = {
95964 + .pass = &kernexec_reload_pass.pass,
95965 + .reference_pass_name = "ssa",
95966 + .ref_pass_instance_number = 1,
95967 + .pos_op = PASS_POS_INSERT_AFTER
95968 + };
95969 + struct register_pass_info kernexec_fptr_pass_info = {
95970 + .pass = &kernexec_fptr_pass.pass,
95971 + .reference_pass_name = "ssa",
95972 + .ref_pass_instance_number = 1,
95973 + .pos_op = PASS_POS_INSERT_AFTER
95974 + };
95975 + struct register_pass_info kernexec_retaddr_pass_info = {
95976 + .pass = &kernexec_retaddr_pass.pass,
95977 + .reference_pass_name = "pro_and_epilogue",
95978 + .ref_pass_instance_number = 1,
95979 + .pos_op = PASS_POS_INSERT_AFTER
95980 + };
95981 +
95982 + if (!plugin_default_version_check(version, &gcc_version)) {
95983 + error(G_("incompatible gcc/plugin versions"));
95984 + return 1;
95985 + }
95986 +
95987 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95988 +
95989 + if (TARGET_64BIT == 0)
95990 + return 0;
95991 +
95992 + for (i = 0; i < argc; ++i) {
95993 + if (!strcmp(argv[i].key, "method")) {
95994 + if (!argv[i].value) {
95995 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95996 + continue;
95997 + }
95998 + if (!strcmp(argv[i].value, "bts")) {
95999 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
96000 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
96001 + } else if (!strcmp(argv[i].value, "or")) {
96002 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
96003 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
96004 + fix_register("r10", 1, 1);
96005 + } else
96006 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96007 + continue;
96008 + }
96009 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96010 + }
96011 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
96012 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
96013 +
96014 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
96015 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
96016 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
96017 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
96018 +
96019 + return 0;
96020 +}
96021 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
96022 new file mode 100644
96023 index 0000000..b5395ba
96024 --- /dev/null
96025 +++ b/tools/gcc/latent_entropy_plugin.c
96026 @@ -0,0 +1,327 @@
96027 +/*
96028 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
96029 + * Licensed under the GPL v2
96030 + *
96031 + * Note: the choice of the license means that the compilation process is
96032 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96033 + * but for the kernel it doesn't matter since it doesn't link against
96034 + * any of the gcc libraries
96035 + *
96036 + * gcc plugin to help generate a little bit of entropy from program state,
96037 + * used during boot in the kernel
96038 + *
96039 + * TODO:
96040 + * - add ipa pass to identify not explicitly marked candidate functions
96041 + * - mix in more program state (function arguments/return values, loop variables, etc)
96042 + * - more instrumentation control via attribute parameters
96043 + *
96044 + * BUGS:
96045 + * - LTO needs -flto-partition=none for now
96046 + */
96047 +#include "gcc-plugin.h"
96048 +#include "config.h"
96049 +#include "system.h"
96050 +#include "coretypes.h"
96051 +#include "tree.h"
96052 +#include "tree-pass.h"
96053 +#include "flags.h"
96054 +#include "intl.h"
96055 +#include "toplev.h"
96056 +#include "plugin.h"
96057 +//#include "expr.h" where are you...
96058 +#include "diagnostic.h"
96059 +#include "plugin-version.h"
96060 +#include "tm.h"
96061 +#include "function.h"
96062 +#include "basic-block.h"
96063 +#include "gimple.h"
96064 +#include "rtl.h"
96065 +#include "emit-rtl.h"
96066 +#include "tree-flow.h"
96067 +#include "langhooks.h"
96068 +
96069 +#if BUILDING_GCC_VERSION >= 4008
96070 +#define TODO_dump_func 0
96071 +#endif
96072 +
96073 +int plugin_is_GPL_compatible;
96074 +
96075 +static tree latent_entropy_decl;
96076 +
96077 +static struct plugin_info latent_entropy_plugin_info = {
96078 + .version = "201303102320",
96079 + .help = NULL
96080 +};
96081 +
96082 +static unsigned int execute_latent_entropy(void);
96083 +static bool gate_latent_entropy(void);
96084 +
96085 +static struct gimple_opt_pass latent_entropy_pass = {
96086 + .pass = {
96087 + .type = GIMPLE_PASS,
96088 + .name = "latent_entropy",
96089 +#if BUILDING_GCC_VERSION >= 4008
96090 + .optinfo_flags = OPTGROUP_NONE,
96091 +#endif
96092 + .gate = gate_latent_entropy,
96093 + .execute = execute_latent_entropy,
96094 + .sub = NULL,
96095 + .next = NULL,
96096 + .static_pass_number = 0,
96097 + .tv_id = TV_NONE,
96098 + .properties_required = PROP_gimple_leh | PROP_cfg,
96099 + .properties_provided = 0,
96100 + .properties_destroyed = 0,
96101 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96102 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96103 + }
96104 +};
96105 +
96106 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
96107 +{
96108 + if (TREE_CODE(*node) != FUNCTION_DECL) {
96109 + *no_add_attrs = true;
96110 + error("%qE attribute only applies to functions", name);
96111 + }
96112 + return NULL_TREE;
96113 +}
96114 +
96115 +static struct attribute_spec latent_entropy_attr = {
96116 + .name = "latent_entropy",
96117 + .min_length = 0,
96118 + .max_length = 0,
96119 + .decl_required = true,
96120 + .type_required = false,
96121 + .function_type_required = false,
96122 + .handler = handle_latent_entropy_attribute,
96123 +#if BUILDING_GCC_VERSION >= 4007
96124 + .affects_type_identity = false
96125 +#endif
96126 +};
96127 +
96128 +static void register_attributes(void *event_data, void *data)
96129 +{
96130 + register_attribute(&latent_entropy_attr);
96131 +}
96132 +
96133 +static bool gate_latent_entropy(void)
96134 +{
96135 + tree latent_entropy_attr;
96136 +
96137 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
96138 + return latent_entropy_attr != NULL_TREE;
96139 +}
96140 +
96141 +static unsigned HOST_WIDE_INT seed;
96142 +static unsigned HOST_WIDE_INT get_random_const(void)
96143 +{
96144 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
96145 + return seed;
96146 +}
96147 +
96148 +static enum tree_code get_op(tree *rhs)
96149 +{
96150 + static enum tree_code op;
96151 + unsigned HOST_WIDE_INT random_const;
96152 +
96153 + random_const = get_random_const();
96154 +
96155 + switch (op) {
96156 + case BIT_XOR_EXPR:
96157 + op = PLUS_EXPR;
96158 + break;
96159 +
96160 + case PLUS_EXPR:
96161 + if (rhs) {
96162 + op = LROTATE_EXPR;
96163 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
96164 + break;
96165 + }
96166 +
96167 + case LROTATE_EXPR:
96168 + default:
96169 + op = BIT_XOR_EXPR;
96170 + break;
96171 + }
96172 + if (rhs)
96173 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
96174 + return op;
96175 +}
96176 +
96177 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
96178 +{
96179 + gimple_stmt_iterator gsi;
96180 + gimple assign;
96181 + tree addxorrol, rhs;
96182 + enum tree_code op;
96183 +
96184 + op = get_op(&rhs);
96185 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
96186 + assign = gimple_build_assign(local_entropy, addxorrol);
96187 +#if BUILDING_GCC_VERSION <= 4007
96188 + find_referenced_vars_in(assign);
96189 +#endif
96190 +//debug_bb(bb);
96191 + gsi = gsi_after_labels(bb);
96192 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
96193 + update_stmt(assign);
96194 +}
96195 +
96196 +static void perturb_latent_entropy(basic_block bb, tree rhs)
96197 +{
96198 + gimple_stmt_iterator gsi;
96199 + gimple assign;
96200 + tree addxorrol, temp;
96201 +
96202 + // 1. create temporary copy of latent_entropy
96203 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
96204 +#if BUILDING_GCC_VERSION <= 4007
96205 + add_referenced_var(temp);
96206 + mark_sym_for_renaming(temp);
96207 +#endif
96208 +
96209 + // 2. read...
96210 + assign = gimple_build_assign(temp, latent_entropy_decl);
96211 +#if BUILDING_GCC_VERSION <= 4007
96212 + find_referenced_vars_in(assign);
96213 +#endif
96214 + gsi = gsi_after_labels(bb);
96215 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96216 + update_stmt(assign);
96217 +
96218 + // 3. ...modify...
96219 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
96220 + assign = gimple_build_assign(temp, addxorrol);
96221 +#if BUILDING_GCC_VERSION <= 4007
96222 + find_referenced_vars_in(assign);
96223 +#endif
96224 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96225 + update_stmt(assign);
96226 +
96227 + // 4. ...write latent_entropy
96228 + assign = gimple_build_assign(latent_entropy_decl, temp);
96229 +#if BUILDING_GCC_VERSION <= 4007
96230 + find_referenced_vars_in(assign);
96231 +#endif
96232 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96233 + update_stmt(assign);
96234 +}
96235 +
96236 +static unsigned int execute_latent_entropy(void)
96237 +{
96238 + basic_block bb;
96239 + gimple assign;
96240 + gimple_stmt_iterator gsi;
96241 + tree local_entropy;
96242 +
96243 + if (!latent_entropy_decl) {
96244 + struct varpool_node *node;
96245 +
96246 +#if BUILDING_GCC_VERSION <= 4007
96247 + for (node = varpool_nodes; node; node = node->next) {
96248 + tree var = node->decl;
96249 +#else
96250 + FOR_EACH_VARIABLE(node) {
96251 + tree var = node->symbol.decl;
96252 +#endif
96253 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
96254 + continue;
96255 + latent_entropy_decl = var;
96256 +// debug_tree(var);
96257 + break;
96258 + }
96259 + if (!latent_entropy_decl) {
96260 +// debug_tree(current_function_decl);
96261 + return 0;
96262 + }
96263 + }
96264 +
96265 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
96266 +
96267 + // 1. create local entropy variable
96268 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
96269 +#if BUILDING_GCC_VERSION <= 4007
96270 + add_referenced_var(local_entropy);
96271 + mark_sym_for_renaming(local_entropy);
96272 +#endif
96273 +
96274 + // 2. initialize local entropy variable
96275 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
96276 + if (dom_info_available_p(CDI_DOMINATORS))
96277 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
96278 + gsi = gsi_start_bb(bb);
96279 +
96280 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
96281 +// gimple_set_location(assign, loc);
96282 +#if BUILDING_GCC_VERSION <= 4007
96283 + find_referenced_vars_in(assign);
96284 +#endif
96285 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96286 + update_stmt(assign);
96287 + bb = bb->next_bb;
96288 +
96289 + // 3. instrument each BB with an operation on the local entropy variable
96290 + while (bb != EXIT_BLOCK_PTR) {
96291 + perturb_local_entropy(bb, local_entropy);
96292 + bb = bb->next_bb;
96293 + };
96294 +
96295 + // 4. mix local entropy into the global entropy variable
96296 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
96297 + return 0;
96298 +}
96299 +
96300 +static void start_unit_callback(void *gcc_data, void *user_data)
96301 +{
96302 + tree latent_entropy_type;
96303 +
96304 +#if BUILDING_GCC_VERSION >= 4007
96305 + seed = get_random_seed(false);
96306 +#else
96307 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
96308 + seed *= seed;
96309 +#endif
96310 +
96311 + if (in_lto_p)
96312 + return;
96313 +
96314 + // extern volatile u64 latent_entropy
96315 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
96316 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
96317 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
96318 +
96319 + TREE_STATIC(latent_entropy_decl) = 1;
96320 + TREE_PUBLIC(latent_entropy_decl) = 1;
96321 + TREE_USED(latent_entropy_decl) = 1;
96322 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
96323 + DECL_EXTERNAL(latent_entropy_decl) = 1;
96324 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
96325 + DECL_INITIAL(latent_entropy_decl) = NULL;
96326 + lang_hooks.decls.pushdecl(latent_entropy_decl);
96327 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
96328 +// varpool_finalize_decl(latent_entropy_decl);
96329 +// varpool_mark_needed_node(latent_entropy_decl);
96330 +}
96331 +
96332 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96333 +{
96334 + const char * const plugin_name = plugin_info->base_name;
96335 + struct register_pass_info latent_entropy_pass_info = {
96336 + .pass = &latent_entropy_pass.pass,
96337 + .reference_pass_name = "optimized",
96338 + .ref_pass_instance_number = 1,
96339 + .pos_op = PASS_POS_INSERT_BEFORE
96340 + };
96341 +
96342 + if (!plugin_default_version_check(version, &gcc_version)) {
96343 + error(G_("incompatible gcc/plugin versions"));
96344 + return 1;
96345 + }
96346 +
96347 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
96348 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
96349 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
96350 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96351 +
96352 + return 0;
96353 +}
96354 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
96355 new file mode 100644
96356 index 0000000..7982a0c
96357 --- /dev/null
96358 +++ b/tools/gcc/size_overflow_hash.data
96359 @@ -0,0 +1,5893 @@
96360 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
96361 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
96362 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
96363 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
96364 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
96365 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
96366 +padzero_55 padzero 1 55 &sel_read_policyvers_55
96367 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
96368 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
96369 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
96370 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96371 +load_msg_95 load_msg 2 95 NULL
96372 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96373 +init_q_132 init_q 4 132 NULL
96374 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96375 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96376 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96377 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96378 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96379 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96380 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96381 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96382 +br_port_info_size_268 br_port_info_size 0 268 NULL
96383 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96384 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96385 +syslog_print_307 syslog_print 2 307 NULL
96386 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96387 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96388 +next_node_allowed_318 next_node_allowed 1 318 NULL
96389 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96390 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96391 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96392 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96393 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96394 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96395 +pidlist_resize_496 pidlist_resize 2 496 NULL
96396 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96397 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96398 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96399 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
96400 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96401 +dle_count_543 dle_count 0 543 NULL
96402 +devres_alloc_551 devres_alloc 2 551 NULL
96403 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96404 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96405 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96406 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96407 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96408 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96409 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
96410 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96411 +isp1760_register_628 isp1760_register 1-2 628 NULL
96412 +clone_split_bio_633 clone_split_bio 6 633 NULL
96413 +remap_to_cache_640 remap_to_cache 3 640 NULL
96414 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96415 +unlink_queued_645 unlink_queued 3-4 645 NULL
96416 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96417 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96418 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96419 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96420 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96421 +disk_max_parts_719 disk_max_parts 0 719 NULL
96422 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96423 +dvb_video_write_754 dvb_video_write 3 754 NULL
96424 +if_writecmd_815 if_writecmd 2 815 NULL
96425 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96426 +read_fifo_826 read_fifo 3 826 NULL
96427 +um_idi_read_850 um_idi_read 3 850 NULL
96428 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96429 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96430 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96431 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96432 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96433 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96434 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
96435 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
96436 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96437 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
96438 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
96439 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
96440 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96441 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96442 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96443 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96444 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96445 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96446 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96447 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96448 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96449 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
96450 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96451 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96452 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96453 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96454 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96455 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96456 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96457 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96458 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96459 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96460 +nested_get_page_1252 nested_get_page 2 1252 NULL
96461 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96462 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96463 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96464 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96465 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96466 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
96467 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96468 +ffs_1322 ffs 0 1322 NULL
96469 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96470 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96471 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96472 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96473 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96474 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96475 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
96476 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96477 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96478 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96479 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96480 +zone_page_state_1393 zone_page_state 0 1393 NULL
96481 +file_read_actor_1401 file_read_actor 4 1401 NULL
96482 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
96483 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96484 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96485 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96486 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96487 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96488 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96489 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
96490 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96491 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96492 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96493 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96494 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96495 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96496 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96497 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96498 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96499 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96500 +rmap_add_1677 rmap_add 3 1677 NULL
96501 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96502 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96503 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96504 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96505 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96506 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96507 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96508 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96509 +cosa_write_1774 cosa_write 3 1774 NULL
96510 +update_macheader_1775 update_macheader 7 1775 NULL
96511 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96512 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96513 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
96514 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96515 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96516 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96517 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
96518 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96519 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96520 +read_swap_header_1957 read_swap_header 0 1957 NULL
96521 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96522 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96523 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
96524 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96525 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96526 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96527 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96528 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96529 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96530 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96531 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96532 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96533 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96534 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96535 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96536 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96537 +audit_expand_2098 audit_expand 2 2098 NULL
96538 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96539 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96540 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96541 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96542 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96543 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
96544 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96545 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
96546 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
96547 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96548 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96549 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96550 +u32_array_read_2219 u32_array_read 3 2219 NULL
96551 +vhci_write_2224 vhci_write 3 2224 NULL
96552 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96553 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96554 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96555 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96556 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96557 +do_update_counters_2259 do_update_counters 4 2259 NULL
96558 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96559 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96560 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
96561 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96562 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96563 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96564 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96565 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96566 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96567 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96568 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96569 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96570 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96571 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96572 +raid1_size_2419 raid1_size 0-2 2419 NULL
96573 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96574 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96575 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96576 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96577 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
96578 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96579 +update_pmkid_2481 update_pmkid 4 2481 NULL
96580 +wiphy_new_2482 wiphy_new 2 2482 NULL
96581 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96582 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
96583 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96584 +dm_write_2513 dm_write 3 2513 NULL
96585 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96586 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96587 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96588 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
96589 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96590 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96591 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
96592 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96593 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96594 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96595 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96596 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96597 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96598 +__next_cpu_2782 __next_cpu 1 2782 NULL
96599 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
96600 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96601 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
96602 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96603 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96604 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96605 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96606 +mq_map_2871 mq_map 2 2871 NULL
96607 +nla_padlen_2883 nla_padlen 1 2883 NULL
96608 +cmm_write_2896 cmm_write 3 2896 NULL
96609 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96610 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96611 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96612 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96613 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96614 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96615 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96616 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96617 +depth_write_3021 depth_write 3 3021 NULL
96618 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96619 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96620 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96621 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96622 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96623 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
96624 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96625 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96626 +free_coherent_3082 free_coherent 4-2 3082 NULL
96627 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
96628 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
96629 +rb_alloc_3102 rb_alloc 1 3102 NULL
96630 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96631 +print_time_3132 print_time 0 3132 NULL
96632 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96633 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96634 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96635 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96636 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96637 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96638 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96639 +alloc_context_3194 alloc_context 1 3194 NULL
96640 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96641 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96642 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96643 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96644 +key_key_read_3241 key_key_read 3 3241 NULL
96645 +number_3243 number 0 3243 NULL
96646 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96647 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96648 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96649 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96650 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96651 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96652 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96653 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96654 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96655 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96656 +scnprintf_3360 scnprintf 0-2 3360 NULL
96657 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
96658 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96659 +send_stream_3397 send_stream 4 3397 NULL
96660 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96661 +msix_map_region_3411 msix_map_region 3 3411 NULL
96662 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96663 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96664 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96665 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96666 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96667 +map_single_3449 map_single 0-2 3449 NULL
96668 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96669 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96670 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96671 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96672 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96673 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
96674 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96675 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96676 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96677 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96678 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96679 +evtchn_read_3569 evtchn_read 3 3569 NULL
96680 +vc_resize_3585 vc_resize 2-3 3585 NULL
96681 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96682 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96683 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96684 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96685 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96686 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
96687 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96688 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96689 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96690 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96691 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96692 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96693 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96694 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96695 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96696 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96697 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96698 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96699 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96700 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96701 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96702 +get_fd_set_3866 get_fd_set 1 3866 NULL
96703 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96704 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96705 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96706 +nvram_write_3894 nvram_write 3 3894 NULL
96707 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96708 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96709 +vcs_write_3910 vcs_write 3 3910 NULL
96710 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96711 +do_add_counters_3992 do_add_counters 3 3992 NULL
96712 +userspace_status_4004 userspace_status 4 4004 NULL
96713 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96714 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96715 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96716 +mm_populate_4016 mm_populate 1 4016 NULL
96717 +blk_end_request_4024 blk_end_request 3 4024 NULL
96718 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96719 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96720 +read_file_queues_4078 read_file_queues 3 4078 NULL
96721 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96722 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96723 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
96724 +tm6000_read_4151 tm6000_read 3 4151 NULL
96725 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96726 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96727 +get_alua_req_4166 get_alua_req 3 4166 NULL
96728 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96729 +read_file_bool_4180 read_file_bool 3 4180 NULL
96730 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96731 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96732 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96733 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
96734 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
96735 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96736 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96737 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
96738 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96739 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96740 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96741 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96742 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96743 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96744 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96745 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96746 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96747 +memparse_4444 memparse 0 4444 NULL
96748 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96749 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96750 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96751 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96752 +set_link_security_4502 set_link_security 4 4502 NULL
96753 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
96754 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
96755 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96756 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96757 +tty_register_device_4544 tty_register_device 2 4544 NULL
96758 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96759 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96760 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96761 +bch_alloc_4593 bch_alloc 1 4593 NULL
96762 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
96763 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96764 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96765 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96766 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96767 +kone_receive_4690 kone_receive 4 4690 NULL
96768 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96769 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96770 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96771 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96772 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96773 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
96774 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
96775 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96776 +create_subvol_4791 create_subvol 4 4791 NULL
96777 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96778 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96779 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96780 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96781 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96782 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96783 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96784 +sys_ipc_4889 sys_ipc 3 4889 NULL
96785 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96786 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96787 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96788 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96789 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96790 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96791 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96792 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96793 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96794 +do_mincore_5018 do_mincore 0-1 5018 NULL
96795 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96796 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96797 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96798 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96799 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96800 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96801 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96802 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96803 +sound_write_5102 sound_write 3 5102 NULL
96804 +clear_dirty_5105 clear_dirty 3 5105 NULL
96805 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96806 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96807 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96808 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96809 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96810 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96811 +skb_network_header_5203 skb_network_header 0 5203 NULL
96812 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96813 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96814 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96815 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96816 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96817 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96818 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
96819 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
96820 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
96821 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
96822 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96823 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96824 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96825 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96826 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
96827 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96828 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96829 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96830 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96831 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96832 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96833 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96834 +tty_write_5494 tty_write 3 5494 NULL
96835 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96836 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96837 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96838 +spidev_message_5518 spidev_message 3 5518 NULL
96839 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96840 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96841 +le_readq_5557 le_readq 0 5557 NULL
96842 +inw_5558 inw 0 5558 NULL
96843 +fir16_create_5574 fir16_create 3 5574 NULL
96844 +bioset_create_5580 bioset_create 1 5580 NULL
96845 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96846 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96847 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96848 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96849 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96850 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96851 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96852 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96853 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
96854 +get_arg_5694 get_arg 3 5694 NULL
96855 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96856 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
96857 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96858 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96859 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96860 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96861 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96862 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96863 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96864 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96865 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96866 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96867 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96868 +setup_req_5848 setup_req 3 5848 NULL
96869 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96870 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96871 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96872 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
96873 +port_show_regs_5904 port_show_regs 3 5904 NULL
96874 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96875 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96876 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96877 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96878 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96879 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96880 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96881 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96882 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96883 +native_pte_val_5978 native_pte_val 0 5978 NULL
96884 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96885 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96886 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96887 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96888 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96889 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96890 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96891 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96892 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96893 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96894 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96895 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
96896 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
96897 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96898 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96899 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96900 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96901 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96902 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96903 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96904 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
96905 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96906 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96907 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
96908 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96909 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96910 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96911 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
96912 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96913 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96914 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96915 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96916 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
96917 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
96918 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
96919 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
96920 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96921 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
96922 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96923 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96924 +mei_read_6507 mei_read 3 6507 NULL
96925 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96926 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96927 +wdm_read_6549 wdm_read 3 6549 NULL
96928 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96929 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96930 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96931 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96932 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96933 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96934 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96935 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96936 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96937 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96938 +mpeg_read_6708 mpeg_read 3 6708 NULL
96939 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
96940 +video_proc_write_6724 video_proc_write 3 6724 NULL
96941 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96942 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96943 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96944 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96945 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96946 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96947 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96948 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96949 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96950 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96951 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96952 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96953 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96954 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96955 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96956 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96957 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96958 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96959 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96960 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96961 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96962 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96963 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96964 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96965 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96966 +request_key_async_6990 request_key_async 4 6990 NULL
96967 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96968 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96969 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96970 +wimax_msg_7030 wimax_msg 4 7030 NULL
96971 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96972 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96973 +event_enable_read_7074 event_enable_read 3 7074 NULL
96974 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96975 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96976 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96977 +check_header_7108 check_header 0 7108 NULL
96978 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
96979 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
96980 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
96981 +get_param_h_7247 get_param_h 0 7247 NULL
96982 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
96983 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96984 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96985 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96986 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
96987 +mgmt_control_7349 mgmt_control 3 7349 NULL
96988 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96989 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96990 +hweight_long_7388 hweight_long 0-1 7388 NULL
96991 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96992 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96993 +readb_7401 readb 0 7401 NULL
96994 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96995 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96996 +numa_emulation_7466 numa_emulation 2 7466 NULL
96997 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
96998 +garp_request_join_7471 garp_request_join 4 7471 NULL
96999 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
97000 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
97001 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
97002 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
97003 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
97004 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
97005 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
97006 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
97007 +groups_alloc_7614 groups_alloc 1 7614 NULL
97008 +sg_virt_7616 sg_virt 0 7616 NULL
97009 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
97010 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
97011 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
97012 +dev_write_7708 dev_write 3 7708 NULL
97013 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
97014 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
97015 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
97016 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
97017 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
97018 +ioread32be_7773 ioread32be 0 7773 NULL
97019 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
97020 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
97021 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
97022 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
97023 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
97024 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
97025 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
97026 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
97027 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
97028 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
97029 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
97030 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
97031 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
97032 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
97033 +sys_mbind_7990 sys_mbind 5 7990 NULL
97034 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
97035 +vcs_read_8017 vcs_read 3 8017 NULL
97036 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
97037 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
97038 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
97039 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
97040 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
97041 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
97042 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
97043 +venus_lookup_8121 venus_lookup 4 8121 NULL
97044 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
97045 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
97046 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
97047 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
97048 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
97049 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
97050 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
97051 +play_iframe_8219 play_iframe 3 8219 NULL
97052 +create_log_8225 create_log 2 8225 NULL nohasharray
97053 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
97054 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
97055 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
97056 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
97057 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
97058 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
97059 +init_cdev_8274 init_cdev 1 8274 NULL
97060 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
97061 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
97062 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
97063 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
97064 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
97065 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
97066 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
97067 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
97068 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
97069 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
97070 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
97071 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
97072 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
97073 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
97074 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
97075 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
97076 +dev_config_8506 dev_config 3 8506 NULL
97077 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
97078 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
97079 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
97080 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
97081 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
97082 +profile_remove_8556 profile_remove 3 8556 NULL
97083 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
97084 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
97085 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
97086 +tower_write_8580 tower_write 3 8580 NULL
97087 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
97088 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
97089 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
97090 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
97091 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
97092 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
97093 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
97094 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
97095 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
97096 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
97097 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
97098 +arcfb_write_8702 arcfb_write 3 8702 NULL
97099 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
97100 +init_header_8703 init_header 0 8703 &i_size_read_8703
97101 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
97102 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
97103 +f_dupfd_8730 f_dupfd 1 8730 NULL
97104 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
97105 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
97106 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
97107 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
97108 +sys_prctl_8766 sys_prctl 4 8766 NULL
97109 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
97110 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
97111 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
97112 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
97113 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
97114 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
97115 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
97116 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
97117 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
97118 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
97119 +clear_bitset_8840 clear_bitset 2 8840 NULL
97120 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
97121 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
97122 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
97123 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
97124 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
97125 +layout_commit_8926 layout_commit 3 8926 NULL
97126 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
97127 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
97128 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
97129 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
97130 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
97131 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
97132 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
97133 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
97134 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
97135 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
97136 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
97137 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
97138 +nla_put_9042 nla_put 3 9042 NULL
97139 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
97140 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
97141 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
97142 +string_9080 string 0 9080 NULL
97143 +create_queues_9088 create_queues 2-3 9088 NULL
97144 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
97145 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
97146 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
97147 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
97148 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
97149 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
97150 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
97151 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
97152 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
97153 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
97154 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
97155 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
97156 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
97157 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
97158 +get_pfn_9207 get_pfn 1 9207 NULL
97159 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
97160 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
97161 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
97162 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
97163 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
97164 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
97165 +flakey_status_9274 flakey_status 5 9274 NULL
97166 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
97167 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
97168 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
97169 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
97170 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
97171 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
97172 +read_9397 read 3 9397 NULL
97173 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
97174 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
97175 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
97176 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
97177 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
97178 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
97179 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
97180 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
97181 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
97182 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
97183 +lp_write_9511 lp_write 3 9511 NULL
97184 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
97185 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
97186 +read_file_dma_9530 read_file_dma 3 9530 NULL
97187 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
97188 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
97189 +fw_node_create_9559 fw_node_create 2 9559 NULL
97190 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
97191 +kobj_map_9566 kobj_map 2-3 9566 NULL
97192 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
97193 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
97194 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
97195 +do_sync_9604 do_sync 1 9604 NULL
97196 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
97197 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
97198 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
97199 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
97200 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
97201 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
97202 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
97203 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
97204 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
97205 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
97206 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
97207 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
97208 +is_hole_9694 is_hole 2 9694 NULL nohasharray
97209 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
97210 +fnb_9703 fnb 2-3 9703 NULL
97211 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
97212 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
97213 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
97214 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
97215 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
97216 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
97217 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
97218 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
97219 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
97220 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
97221 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
97222 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
97223 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
97224 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
97225 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
97226 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
97227 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
97228 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
97229 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
97230 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
97231 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
97232 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
97233 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
97234 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
97235 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
97236 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
97237 +read_file_misc_9948 read_file_misc 3 9948 NULL
97238 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
97239 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
97240 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
97241 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
97242 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
97243 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
97244 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
97245 +handle_request_10024 handle_request 9 10024 NULL
97246 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
97247 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
97248 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
97249 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
97250 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
97251 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
97252 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
97253 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
97254 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
97255 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
97256 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
97257 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
97258 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
97259 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
97260 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
97261 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
97262 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
97263 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
97264 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
97265 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
97266 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
97267 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
97268 +read_emulate_10310 read_emulate 2-4 10310 NULL
97269 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
97270 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
97271 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
97272 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
97273 +get_dump_page_10338 get_dump_page 1 10338 NULL
97274 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
97275 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
97276 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
97277 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
97278 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
97279 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
97280 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
97281 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
97282 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
97283 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
97284 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
97285 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
97286 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
97287 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
97288 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
97289 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
97290 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
97291 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
97292 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
97293 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
97294 +otp_read_10594 otp_read 2-4-5 10594 NULL
97295 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
97296 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
97297 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
97298 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
97299 +parport_write_10669 parport_write 0 10669 NULL
97300 +inl_10708 inl 0 10708 NULL nohasharray
97301 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
97302 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
97303 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
97304 +spi_sync_10731 spi_sync 0 10731 NULL
97305 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
97306 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
97307 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
97308 +sys_syslog_10746 sys_syslog 3 10746 NULL
97309 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
97310 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
97311 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
97312 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
97313 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
97314 +sys_bind_10799 sys_bind 3 10799 NULL
97315 +compat_put_int_10828 compat_put_int 1 10828 NULL
97316 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
97317 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
97318 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
97319 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
97320 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
97321 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
97322 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
97323 +get_scq_10897 get_scq 2 10897 NULL
97324 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
97325 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
97326 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
97327 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
97328 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
97329 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
97330 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
97331 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
97332 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
97333 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
97334 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
97335 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
97336 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
97337 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
97338 +count_argc_11083 count_argc 0 11083 NULL
97339 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
97340 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
97341 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
97342 +page_offset_11120 page_offset 0 11120 NULL
97343 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
97344 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
97345 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
97346 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
97347 +__swab16p_11220 __swab16p 0 11220 NULL
97348 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
97349 +mmap_region_11247 mmap_region 0-2 11247 NULL
97350 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
97351 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
97352 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
97353 +cru_detect_11272 cru_detect 1 11272 NULL
97354 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
97355 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
97356 +construct_key_11329 construct_key 3 11329 NULL nohasharray
97357 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
97358 +next_segment_11330 next_segment 0-2-1 11330 NULL
97359 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
97360 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
97361 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
97362 +sel_write_create_11353 sel_write_create 3 11353 NULL
97363 +handle_unit_11355 handle_unit 0-1 11355 NULL
97364 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
97365 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
97366 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
97367 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
97368 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
97369 +str_to_user_11411 str_to_user 2 11411 NULL
97370 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
97371 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
97372 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
97373 +trace_options_read_11419 trace_options_read 3 11419 NULL
97374 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
97375 +prepare_image_11424 prepare_image 0 11424 NULL
97376 +vring_size_11426 vring_size 0-1-2 11426 NULL
97377 +bttv_read_11432 bttv_read 3 11432 NULL
97378 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97379 +swp_offset_11475 swp_offset 0 11475 NULL
97380 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97381 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97382 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97383 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97384 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97385 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97386 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97387 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97388 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97389 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97390 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97391 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97392 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97393 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97394 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97395 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97396 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97397 +split_11691 split 2 11691 NULL
97398 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97399 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97400 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97401 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97402 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97403 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97404 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97405 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97406 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97407 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
97408 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97409 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97410 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97411 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97412 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97413 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97414 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
97415 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97416 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97417 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97418 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97419 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97420 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97421 +atmel_read16_11981 atmel_read16 0 11981 NULL
97422 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97423 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97424 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97425 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97426 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97427 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97428 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
97429 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97430 +set_powered_12129 set_powered 4 12129 NULL
97431 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97432 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97433 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97434 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97435 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97436 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97437 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97438 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97439 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97440 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97441 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97442 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97443 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97444 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97445 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97446 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
97447 +receive_copy_12216 receive_copy 3 12216 NULL
97448 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97449 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
97450 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
97451 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
97452 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97453 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97454 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97455 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97456 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97457 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97458 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97459 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97460 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97461 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97462 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97463 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
97464 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97465 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97466 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97467 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97468 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97469 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97470 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97471 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97472 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
97473 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97474 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97475 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
97476 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
97477 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97478 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97479 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97480 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97481 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97482 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97483 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97484 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97485 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97486 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97487 +wb_create_12651 wb_create 1 12651 NULL
97488 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97489 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97490 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97491 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97492 +ivtv_write_12721 ivtv_write 3 12721 NULL
97493 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97494 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97495 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97496 +listxattr_12769 listxattr 3 12769 NULL
97497 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97498 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
97499 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97500 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97501 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97502 +readq_12825 readq 0 12825 NULL
97503 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97504 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
97505 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
97506 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97507 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97508 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97509 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97510 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97511 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97512 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97513 +bm_status_write_12964 bm_status_write 3 12964 NULL
97514 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97515 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
97516 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97517 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97518 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97519 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97520 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97521 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97522 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97523 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97524 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97525 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97526 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97527 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97528 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97529 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97530 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97531 +blk_update_request_13146 blk_update_request 3 13146 NULL
97532 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97533 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97534 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
97535 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97536 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97537 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97538 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
97539 +comedi_read_13199 comedi_read 3 13199 NULL
97540 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97541 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97542 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97543 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
97544 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97545 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
97546 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
97547 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97548 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97549 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97550 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
97551 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97552 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97553 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97554 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97555 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97556 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
97557 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97558 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
97559 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
97560 +cache_ctr_13364 cache_ctr 2 13364 NULL
97561 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97562 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97563 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97564 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97565 +sky2_receive_13407 sky2_receive 2 13407 NULL
97566 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97567 +keyring_read_13438 keyring_read 3 13438 NULL
97568 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97569 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97570 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
97571 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97572 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97573 +core_status_13515 core_status 4 13515 NULL
97574 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97575 +bm_init_13529 bm_init 2 13529 NULL
97576 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
97577 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97578 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97579 +sys_madvise_13569 sys_madvise 1 13569 NULL
97580 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97581 +cache_write_13589 cache_write 3 13589 NULL
97582 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97583 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97584 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97585 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97586 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97587 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
97588 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97589 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97590 +packet_snd_13634 packet_snd 3 13634 NULL
97591 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97592 +cache_downcall_13666 cache_downcall 3 13666 NULL
97593 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97594 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97595 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97596 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97597 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97598 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97599 +random_read_13815 random_read 3 13815 NULL
97600 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97601 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97602 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97603 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97604 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
97605 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97606 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97607 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97608 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97609 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97610 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97611 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97612 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97613 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97614 +com90xx_found_13974 com90xx_found 3 13974 NULL
97615 +qcam_read_13977 qcam_read 3 13977 NULL
97616 +dsp_read_13980 dsp_read 2 13980 NULL
97617 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97618 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97619 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97620 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97621 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97622 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97623 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97624 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97625 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
97626 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97627 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97628 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97629 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97630 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97631 +em_canid_change_14150 em_canid_change 3 14150 NULL
97632 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97633 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97634 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97635 +alloc_async_14208 alloc_async 1 14208 NULL
97636 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97637 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97638 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97639 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
97640 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97641 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
97642 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97643 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97644 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97645 +rr_status_14293 rr_status 5 14293 NULL
97646 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97647 +oo_objects_14319 oo_objects 0 14319 NULL
97648 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97649 +scsi2int_14358 scsi2int 0 14358 NULL
97650 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97651 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97652 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97653 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97654 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97655 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97656 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97657 +block_size_14443 block_size 0 14443 NULL
97658 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97659 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97660 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97661 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97662 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97663 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97664 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97665 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97666 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97667 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97668 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
97669 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
97670 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97671 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
97672 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97673 +dbJoin_14644 dbJoin 0 14644 NULL
97674 +profile_replace_14652 profile_replace 3 14652 NULL
97675 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97676 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97677 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97678 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97679 +get_bio_block_14714 get_bio_block 0 14714 NULL
97680 +vfd_write_14717 vfd_write 3 14717 NULL
97681 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97682 +raid1_resize_14740 raid1_resize 2 14740 NULL
97683 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97684 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97685 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97686 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97687 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97688 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97689 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97690 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97691 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97692 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97693 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
97694 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97695 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97696 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97697 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97698 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97699 +unifi_read_14899 unifi_read 3 14899 NULL
97700 +krealloc_14908 krealloc 2 14908 NULL
97701 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97702 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
97703 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
97704 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97705 +queue_cnt_14951 queue_cnt 0 14951 NULL
97706 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97707 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97708 +setkey_14987 setkey 3 14987 NULL nohasharray
97709 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97710 +vmap_15025 vmap 2 15025 NULL
97711 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97712 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97713 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97714 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97715 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97716 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97717 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97718 +start_port_15124 start_port 0 15124 NULL
97719 +memchr_15126 memchr 0 15126 NULL
97720 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97721 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97722 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97723 +reserve_resources_15194 reserve_resources 3 15194 NULL
97724 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97725 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97726 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97727 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97728 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97729 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97730 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97731 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97732 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97733 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97734 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97735 +ioread16_15342 ioread16 0 15342 NULL
97736 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97737 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97738 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
97739 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97740 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97741 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97742 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97743 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97744 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97745 +get_modalias_15406 get_modalias 2 15406 NULL
97746 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
97747 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97748 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
97749 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97750 +memweight_15450 memweight 2 15450 NULL
97751 +vmalloc_15464 vmalloc 1 15464 NULL
97752 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97753 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97754 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97755 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97756 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97757 +persistent_status_15574 persistent_status 4 15574 NULL
97758 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97759 +vme_user_write_15587 vme_user_write 3 15587 NULL
97760 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97761 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97762 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97763 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97764 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97765 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97766 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97767 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97768 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97769 +fs_path_add_15648 fs_path_add 3 15648 NULL
97770 +xsd_read_15653 xsd_read 3 15653 NULL
97771 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97772 +unix_bind_15668 unix_bind 3 15668 NULL
97773 +dm_read_15674 dm_read 3 15674 NULL
97774 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97775 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97776 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97777 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97778 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97779 +do_test_15766 do_test 1 15766 NULL
97780 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97781 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97782 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97783 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97784 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97785 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97786 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97787 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97788 +table_size_15851 table_size 0-1-2 15851 NULL
97789 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97790 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97791 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97792 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97793 +native_read_msr_15905 native_read_msr 0 15905 NULL
97794 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97795 +power_read_15939 power_read 3 15939 NULL
97796 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97797 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97798 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97799 +frame_alloc_15981 frame_alloc 4 15981 NULL
97800 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97801 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97802 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97803 +got_frame_16028 got_frame 2 16028 NULL
97804 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
97805 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97806 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97807 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97808 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97809 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97810 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97811 +fsm_init_16134 fsm_init 2 16134 NULL
97812 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97813 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97814 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97815 +mapping_level_16188 mapping_level 2 16188 NULL
97816 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97817 +create_table_16213 create_table 2 16213 NULL
97818 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97819 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97820 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
97821 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
97822 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97823 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97824 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97825 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
97826 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97827 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97828 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97829 +account_16283 account 0-2-4 16283 NULL nohasharray
97830 +mirror_status_16283 mirror_status 5 16283 &account_16283
97831 +retry_instruction_16285 retry_instruction 2 16285 NULL
97832 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97833 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97834 +wb_map_16301 wb_map 2 16301 NULL
97835 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97836 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97837 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97838 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97839 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97840 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97841 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97842 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97843 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97844 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97845 +raid10_resize_16537 raid10_resize 2 16537 NULL
97846 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97847 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97848 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97849 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
97850 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
97851 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97852 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97853 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
97854 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97855 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97856 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97857 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97858 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97859 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97860 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97861 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97862 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97863 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97864 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97865 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97866 +st_write_16874 st_write 3 16874 NULL
97867 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97868 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
97869 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97870 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97871 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97872 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97873 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97874 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97875 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97876 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97877 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97878 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97879 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97880 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97881 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97882 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97883 +mac_address_string_17091 mac_address_string 0 17091 NULL
97884 +entry_length_17093 entry_length 0 17093 NULL
97885 +sys_preadv_17100 sys_preadv 3 17100 NULL
97886 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97887 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97888 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97889 +sep_read_17161 sep_read 3 17161 NULL
97890 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97891 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97892 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97893 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97894 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97895 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97896 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97897 +to_oblock_17254 to_oblock 0-1 17254 NULL
97898 +unpack_value_17259 unpack_value 1 17259 NULL
97899 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97900 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97901 +alloc_ep_17269 alloc_ep 1 17269 NULL
97902 +pg_read_17276 pg_read 3 17276 NULL
97903 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97904 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97905 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97906 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97907 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
97908 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97909 +skb_pad_17302 skb_pad 2 17302 NULL
97910 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97911 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97912 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97913 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97914 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97915 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
97916 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97917 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97918 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97919 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97920 +compat_cmd_17465 compat_cmd 2 17465 NULL
97921 +probe_bios_17467 probe_bios 1 17467 NULL
97922 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97923 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97924 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97925 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97926 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97927 +copy_from_user_17559 copy_from_user 3 17559 NULL
97928 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97929 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97930 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97931 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97932 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97933 +osst_execute_17607 osst_execute 7-6 17607 NULL
97934 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97935 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97936 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97937 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97938 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97939 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97940 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
97941 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97942 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97943 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97944 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97945 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97946 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97947 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97948 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97949 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97950 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97951 +count_leafs_17842 count_leafs 0 17842 NULL
97952 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97953 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97954 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97955 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97956 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97957 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97958 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97959 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97960 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97961 +recover_head_17904 recover_head 3 17904 NULL
97962 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97963 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97964 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97965 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97966 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97967 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97968 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97969 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97970 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97971 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97972 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97973 +fill_read_18019 fill_read 0 18019 NULL
97974 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97975 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97976 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97977 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97978 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97979 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97980 +packet_came_18072 packet_came 3 18072 NULL
97981 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
97982 +get_vm_area_18080 get_vm_area 1 18080 NULL
97983 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97984 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97985 +svc_getnl_18120 svc_getnl 0 18120 NULL
97986 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97987 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97988 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97989 +_has_tag_18169 _has_tag 2 18169 NULL
97990 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97991 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97992 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97993 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97994 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97995 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97996 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97997 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97998 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97999 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
98000 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
98001 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
98002 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
98003 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
98004 +um_idi_write_18293 um_idi_write 3 18293 NULL
98005 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
98006 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
98007 +vga_r_18310 vga_r 0 18310 NULL
98008 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
98009 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
98010 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
98011 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
98012 +ep_io_18367 ep_io 0 18367 NULL
98013 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
98014 +__video_register_device_18399 __video_register_device 3 18399 NULL
98015 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
98016 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
98017 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
98018 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
98019 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
98020 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
98021 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
98022 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
98023 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
98024 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
98025 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
98026 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
98027 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
98028 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
98029 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
98030 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
98031 +debug_output_18575 debug_output 3 18575 NULL
98032 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
98033 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
98034 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
98035 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
98036 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
98037 +from_buffer_18625 from_buffer 3 18625 NULL
98038 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
98039 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
98040 +unmap_page_18665 unmap_page 2-3 18665 NULL
98041 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
98042 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
98043 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
98044 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
98045 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
98046 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
98047 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
98048 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
98049 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
98050 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
98051 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
98052 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
98053 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
98054 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
98055 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
98056 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
98057 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
98058 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
98059 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
98060 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
98061 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
98062 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
98063 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
98064 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
98065 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
98066 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
98067 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
98068 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
98069 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
98070 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
98071 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
98072 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
98073 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
98074 +huge_page_size_19008 huge_page_size 0 19008 NULL
98075 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
98076 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
98077 +revalidate_19043 revalidate 2 19043 NULL
98078 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
98079 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
98080 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
98081 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
98082 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
98083 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
98084 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
98085 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
98086 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
98087 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
98088 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
98089 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
98090 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
98091 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
98092 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
98093 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
98094 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
98095 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
98096 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
98097 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
98098 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
98099 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
98100 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
98101 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
98102 +qc_capture_19298 qc_capture 3 19298 NULL
98103 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
98104 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
98105 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
98106 +debug_read_19322 debug_read 3 19322 NULL
98107 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
98108 +read_zero_19366 read_zero 3 19366 NULL
98109 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
98110 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
98111 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
98112 +__phys_addr_19434 __phys_addr 0 19434 NULL
98113 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
98114 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
98115 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
98116 +sky2_read16_19475 sky2_read16 0 19475 NULL
98117 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
98118 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
98119 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
98120 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
98121 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
98122 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
98123 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
98124 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
98125 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
98126 +nfsd_read_19568 nfsd_read 5 19568 NULL
98127 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
98128 +bm_status_read_19583 bm_status_read 3 19583 NULL
98129 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
98130 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
98131 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
98132 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
98133 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
98134 +bio_detain_19690 bio_detain 2 19690 NULL
98135 +read_reg_19723 read_reg 0 19723 NULL
98136 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
98137 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
98138 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
98139 +p9_client_read_19750 p9_client_read 5 19750 NULL
98140 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
98141 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
98142 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
98143 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
98144 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
98145 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
98146 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
98147 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
98148 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
98149 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
98150 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
98151 +__nla_put_19857 __nla_put 3 19857 NULL
98152 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
98153 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
98154 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
98155 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
98156 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
98157 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
98158 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
98159 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
98160 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
98161 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
98162 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
98163 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
98164 +team_options_register_20091 team_options_register 3 20091 NULL
98165 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
98166 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
98167 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
98168 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
98169 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
98170 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
98171 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
98172 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
98173 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
98174 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
98175 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
98176 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
98177 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
98178 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
98179 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
98180 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
98181 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
98182 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
98183 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
98184 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
98185 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
98186 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
98187 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
98188 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
98189 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
98190 +read_buf_20469 read_buf 2 20469 NULL
98191 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
98192 +fast_user_write_20494 fast_user_write 5 20494 NULL
98193 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
98194 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
98195 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
98196 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
98197 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
98198 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
98199 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
98200 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
98201 +venus_create_20555 venus_create 4 20555 NULL
98202 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
98203 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
98204 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
98205 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
98206 +lirc_write_20604 lirc_write 3 20604 NULL
98207 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
98208 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
98209 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
98210 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
98211 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
98212 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
98213 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
98214 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
98215 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
98216 +cpumask_size_20683 cpumask_size 0 20683 NULL
98217 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
98218 +gru_vtop_20689 gru_vtop 2 20689 NULL
98219 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
98220 +__maestro_read_20700 __maestro_read 0 20700 NULL
98221 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
98222 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
98223 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
98224 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
98225 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
98226 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
98227 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
98228 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
98229 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
98230 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
98231 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
98232 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
98233 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
98234 +sys_sendto_20809 sys_sendto 6 20809 NULL
98235 +strndup_user_20819 strndup_user 2 20819 NULL
98236 +calc_layout_20829 calc_layout 3 20829 NULL
98237 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
98238 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
98239 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
98240 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
98241 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
98242 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
98243 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
98244 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
98245 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
98246 +htable_bits_20933 htable_bits 0 20933 NULL
98247 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
98248 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
98249 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
98250 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
98251 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
98252 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
98253 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
98254 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
98255 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
98256 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
98257 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
98258 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
98259 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
98260 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
98261 +multipath_status_21094 multipath_status 5 21094 NULL
98262 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
98263 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
98264 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
98265 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
98266 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
98267 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
98268 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
98269 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
98270 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
98271 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
98272 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
98273 +input_ff_create_21240 input_ff_create 2 21240 NULL
98274 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
98275 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
98276 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
98277 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
98278 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
98279 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
98280 +add_res_range_21310 add_res_range 4 21310 NULL
98281 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
98282 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
98283 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
98284 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
98285 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
98286 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
98287 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
98288 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
98289 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
98290 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
98291 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
98292 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
98293 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
98294 +concat_writev_21451 concat_writev 3 21451 NULL
98295 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
98296 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
98297 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
98298 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
98299 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
98300 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
98301 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
98302 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
98303 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
98304 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
98305 +validate_nnode_21638 validate_nnode 0 21638 NULL
98306 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
98307 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
98308 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
98309 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
98310 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
98311 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
98312 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
98313 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
98314 +vm_brk_21739 vm_brk 1 21739 NULL
98315 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
98316 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
98317 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
98318 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
98319 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
98320 +min_odd_21802 min_odd 0 21802 NULL
98321 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
98322 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
98323 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
98324 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
98325 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
98326 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
98327 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
98328 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
98329 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
98330 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
98331 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
98332 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
98333 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
98334 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
98335 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
98336 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
98337 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
98338 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
98339 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
98340 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
98341 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
98342 +write_opcode_22082 write_opcode 2 22082 NULL
98343 +mem_rw_22085 mem_rw 3 22085 NULL
98344 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
98345 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
98346 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
98347 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
98348 +compat_insn_22142 compat_insn 2 22142 NULL
98349 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
98350 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
98351 +fls_22210 fls 0 22210 NULL
98352 +mem_write_22232 mem_write 3 22232 NULL
98353 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
98354 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
98355 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
98356 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
98357 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
98358 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
98359 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
98360 +extend_brk_22301 extend_brk 0 22301 NULL
98361 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
98362 +get_segment_base_22324 get_segment_base 0 22324 NULL
98363 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
98364 +atomic_read_22342 atomic_read 0 22342 NULL
98365 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
98366 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
98367 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
98368 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
98369 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
98370 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98371 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98372 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98373 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
98374 +zoran_write_22404 zoran_write 3 22404 NULL
98375 +queue_reply_22416 queue_reply 3 22416 NULL
98376 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98377 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98378 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98379 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98380 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
98381 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98382 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98383 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98384 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98385 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
98386 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
98387 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98388 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98389 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98390 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98391 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98392 +snapshot_read_22601 snapshot_read 3 22601 NULL
98393 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
98394 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98395 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98396 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98397 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98398 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98399 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98400 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98401 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98402 +map_22700 map 2 22700 NULL
98403 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98404 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98405 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98406 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98407 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98408 +print_frame_22769 print_frame 0 22769 NULL
98409 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98410 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98411 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
98412 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
98413 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98414 +create_attr_set_22861 create_attr_set 1 22861 NULL
98415 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98416 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98417 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98418 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
98419 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98420 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98421 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98422 +vme_get_size_22964 vme_get_size 0 22964 NULL
98423 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98424 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
98425 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98426 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
98427 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98428 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98429 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98430 +st_status_23032 st_status 5 23032 NULL
98431 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98432 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98433 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
98434 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98435 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98436 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98437 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98438 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98439 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98440 +fls_long_23096 fls_long 0 23096 NULL
98441 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98442 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98443 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98444 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98445 +__clear_user_23118 __clear_user 0 23118 NULL
98446 +dm_write_async_23120 dm_write_async 3 23120 NULL
98447 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98448 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98449 +read_file_ani_23161 read_file_ani 3 23161 NULL
98450 +ioremap_23172 ioremap 1-2 23172 NULL
98451 +usblp_write_23178 usblp_write 3 23178 NULL
98452 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98453 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98454 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98455 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98456 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98457 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98458 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98459 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98460 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98461 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98462 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98463 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98464 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98465 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98466 +doc_probe_23285 doc_probe 1 23285 NULL
98467 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98468 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
98469 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98470 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98471 +page_readlink_23346 page_readlink 3 23346 NULL
98472 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98473 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
98474 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98475 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98476 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98477 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
98478 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98479 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98480 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98481 +event_filter_read_23494 event_filter_read 3 23494 NULL
98482 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
98483 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98484 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98485 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98486 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98487 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98488 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98489 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98490 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
98491 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98492 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98493 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98494 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98495 +sInW_23663 sInW 0 23663 NULL
98496 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98497 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98498 +cx18_read_23699 cx18_read 3 23699 NULL
98499 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98500 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98501 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98502 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98503 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98504 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98505 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98506 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
98507 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
98508 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98509 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
98510 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98511 +p54_init_common_23850 p54_init_common 1 23850 NULL
98512 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98513 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98514 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98515 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98516 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98517 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98518 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98519 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98520 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98521 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98522 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98523 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98524 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98525 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98526 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98527 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98528 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98529 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98530 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98531 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
98532 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98533 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98534 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98535 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98536 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98537 +mpu401_read_24126 mpu401_read 3 24126 NULL
98538 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98539 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98540 +set_discard_24162 set_discard 2 24162 NULL
98541 +adu_read_24177 adu_read 3 24177 NULL
98542 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98543 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98544 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98545 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98546 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98547 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98548 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98549 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98550 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
98551 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
98552 +thin_status_24278 thin_status 5 24278 NULL
98553 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98554 +msg_size_24288 msg_size 0 24288 NULL
98555 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98556 +map_page_24298 map_page 3-4 24298 NULL
98557 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98558 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98559 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98560 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98561 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98562 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98563 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98564 +igetword_24373 igetword 0 24373 NULL
98565 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98566 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98567 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98568 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98569 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
98570 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98571 +smk_user_access_24440 smk_user_access 3 24440 NULL
98572 +page_address_24444 page_address 0 24444 NULL
98573 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98574 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98575 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
98576 +pd_video_read_24510 pd_video_read 3 24510 NULL
98577 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98578 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98579 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98580 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98581 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98582 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98583 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98584 +count_preds_24600 count_preds 0 24600 NULL
98585 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98586 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
98587 +context_alloc_24645 context_alloc 3 24645 NULL
98588 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98589 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98590 +read_fs_24717 read_fs 0 24717 NULL
98591 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98592 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98593 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98594 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98595 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98596 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98597 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98598 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98599 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98600 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98601 +cache_read_24790 cache_read 3 24790 NULL
98602 +unpack_str_24798 unpack_str 0 24798 NULL
98603 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98604 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98605 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98606 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98607 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98608 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98609 +setup_buffering_24872 setup_buffering 3 24872 NULL
98610 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98611 +queues_read_24877 queues_read 3 24877 NULL
98612 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98613 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98614 +next_token_24929 next_token 0 24929 NULL
98615 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98616 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98617 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98618 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98619 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98620 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98621 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98622 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98623 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98624 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98625 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98626 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98627 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98628 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
98629 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98630 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98631 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98632 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98633 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98634 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98635 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
98636 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98637 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98638 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98639 +stripe_status_25259 stripe_status 5 25259 NULL
98640 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98641 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98642 +vfs_writev_25278 vfs_writev 3 25278 NULL
98643 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98644 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98645 +help_25316 help 5 25316 NULL nohasharray
98646 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98647 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98648 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98649 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98650 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98651 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98652 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98653 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98654 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98655 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98656 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98657 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98658 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98659 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98660 +sb_permission_25523 sb_permission 0 25523 NULL
98661 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98662 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98663 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98664 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98665 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98666 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
98667 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98668 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98669 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98670 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
98671 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98672 +__direct_map_25647 __direct_map 5-6 25647 NULL
98673 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98674 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98675 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98676 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98677 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98678 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98679 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98680 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
98681 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98682 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98683 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
98684 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98685 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98686 +sg_read_25799 sg_read 3 25799 NULL
98687 +system_enable_read_25815 system_enable_read 3 25815 NULL
98688 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98689 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
98690 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98691 +parport_read_25855 parport_read 0 25855 NULL
98692 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98693 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98694 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98695 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98696 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98697 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98698 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98699 +rcname_read_25919 rcname_read 3 25919 NULL
98700 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98701 +key_flags_read_25931 key_flags_read 3 25931 NULL
98702 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98703 +flush_25957 flush 2 25957 NULL
98704 +video_register_device_25971 video_register_device 3 25971 NULL
98705 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98706 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98707 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98708 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98709 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98710 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98711 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98712 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98713 +tun_do_read_26047 tun_do_read 5 26047 NULL
98714 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
98715 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98716 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98717 +skb_cow_26138 skb_cow 2 26138 NULL
98718 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98719 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98720 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98721 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98722 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98723 +disk_devt_26180 disk_devt 0 26180 NULL
98724 +get_registers_26187 get_registers 3 26187 NULL
98725 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98726 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98727 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98728 +mce_write_26201 mce_write 3 26201 NULL
98729 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98730 +bio_split_26235 bio_split 2 26235 NULL
98731 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98732 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98733 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98734 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98735 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98736 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98737 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98738 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98739 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98740 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98741 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
98742 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98743 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98744 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98745 +read_vmcore_26501 read_vmcore 3 26501 NULL
98746 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98747 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98748 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98749 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98750 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
98751 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98752 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98753 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98754 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98755 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98756 +pack_value_26625 pack_value 1 26625 NULL
98757 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98758 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98759 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98760 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98761 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98762 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98763 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98764 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98765 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98766 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98767 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98768 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98769 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98770 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
98771 +smk_write_load_26829 smk_write_load 3 26829 NULL
98772 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
98773 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98774 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98775 +scnprint_id_26842 scnprint_id 3 26842 NULL
98776 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98777 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98778 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98779 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98780 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98781 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98782 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98783 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98784 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98785 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98786 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98787 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98788 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98789 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98790 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98791 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98792 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
98793 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98794 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98795 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98796 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98797 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98798 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98799 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98800 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
98801 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98802 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98803 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98804 +pms_capture_27142 pms_capture 4 27142 NULL
98805 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98806 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98807 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98808 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98809 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98810 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98811 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98812 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98813 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98814 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98815 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98816 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98817 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98818 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98819 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98820 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98821 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98822 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98823 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98824 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98825 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98826 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98827 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98828 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98829 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98830 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98831 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98832 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98833 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98834 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98835 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98836 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98837 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98838 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98839 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98840 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98841 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98842 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98843 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98844 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98845 +qword_get_27670 qword_get 0 27670 NULL
98846 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98847 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98848 +evm_write_key_27715 evm_write_key 3 27715 NULL
98849 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98850 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98851 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98852 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98853 +kcalloc_27770 kcalloc 1-2 27770 NULL
98854 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98855 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98856 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98857 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98858 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98859 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98860 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98861 +read_profile_27859 read_profile 3 27859 NULL
98862 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98863 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98864 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98865 +gluebi_write_27905 gluebi_write 3 27905 NULL
98866 +bm_find_next_27929 bm_find_next 2 27929 NULL
98867 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98868 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98869 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98870 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98871 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98872 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98873 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98874 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98875 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98876 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98877 +pool_status_28055 pool_status 5 28055 NULL
98878 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98879 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98880 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98881 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98882 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98883 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98884 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98885 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98886 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98887 +video_read_28148 video_read 3 28148 NULL
98888 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98889 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98890 +vread_28173 vread 0 28173 NULL
98891 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98892 +d_path_28198 d_path 0 28198 NULL
98893 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98894 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
98895 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98896 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98897 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98898 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98899 +usemap_size_28281 usemap_size 0 28281 NULL
98900 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98901 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98902 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98903 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
98904 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98905 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98906 +snapshot_write_28351 snapshot_write 3 28351 NULL
98907 +sys_writev_28384 sys_writev 3 28384 NULL
98908 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98909 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98910 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98911 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98912 +__split_large_page_28429 __split_large_page 2 28429 NULL
98913 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98914 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
98915 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98916 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98917 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98918 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98919 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98920 +max_response_pages_28492 max_response_pages 0 28492 NULL
98921 +clear_discard_28494 clear_discard 2 28494 NULL
98922 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98923 +__next_node_28521 __next_node 1 28521 NULL
98924 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98925 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98926 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98927 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98928 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98929 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
98930 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98931 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98932 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98933 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98934 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98935 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98936 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98937 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98938 +_set_range_28627 _set_range 3 28627 NULL
98939 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98940 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98941 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98942 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98943 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98944 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98945 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98946 +spi_execute_28736 spi_execute 5 28736 NULL
98947 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98948 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98949 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98950 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98951 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98952 +sel_write_member_28800 sel_write_member 3 28800 NULL
98953 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98954 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
98955 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98956 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98957 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98958 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98959 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98960 +to_cblock_28899 to_cblock 0-1 28899 NULL
98961 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98962 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98963 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98964 +push_rx_28939 push_rx 3 28939 NULL
98965 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98966 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98967 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98968 +bin_uuid_28999 bin_uuid 3 28999 NULL
98969 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98970 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98971 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98972 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98973 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98974 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98975 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
98976 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98977 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98978 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98979 +snprintf_29125 snprintf 0 29125 NULL
98980 +iov_shorten_29130 iov_shorten 0 29130 NULL
98981 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98982 +reshape_ring_29147 reshape_ring 2 29147 NULL
98983 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
98984 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98985 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98986 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98987 +__mm_populate_29204 __mm_populate 1 29204 NULL
98988 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98989 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98990 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98991 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98992 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98993 +recover_peb_29238 recover_peb 6-7 29238 NULL
98994 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98995 +block_div_29268 block_div 0-1-2 29268 NULL
98996 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98997 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98998 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98999 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
99000 +tun_put_user_29337 tun_put_user 5 29337 NULL
99001 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
99002 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
99003 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
99004 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
99005 +mempool_create_29437 mempool_create 1 29437 NULL
99006 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
99007 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
99008 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
99009 +do_register_entry_29478 do_register_entry 4 29478 NULL
99010 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
99011 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
99012 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
99013 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
99014 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
99015 +set_brk_29551 set_brk 1 29551 NULL nohasharray
99016 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
99017 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
99018 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
99019 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
99020 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
99021 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
99022 +slots_per_page_29601 slots_per_page 0 29601 NULL
99023 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
99024 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
99025 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
99026 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
99027 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
99028 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
99029 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
99030 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
99031 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
99032 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
99033 +probes_write_29711 probes_write 3 29711 NULL
99034 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
99035 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
99036 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
99037 +dbAlloc_29794 dbAlloc 0 29794 NULL
99038 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
99039 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
99040 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
99041 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
99042 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
99043 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
99044 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
99045 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
99046 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
99047 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
99048 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
99049 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
99050 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
99051 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
99052 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
99053 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
99054 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
99055 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
99056 +drp_wmove_30043 drp_wmove 4 30043 NULL
99057 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
99058 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
99059 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
99060 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
99061 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
99062 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
99063 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
99064 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
99065 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
99066 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
99067 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
99068 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
99069 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
99070 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
99071 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
99072 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
99073 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
99074 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
99075 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
99076 +compat_readv_30273 compat_readv 3 30273 NULL
99077 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
99078 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
99079 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
99080 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
99081 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
99082 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
99083 +resource_from_user_30341 resource_from_user 3 30341 NULL
99084 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
99085 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
99086 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
99087 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
99088 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
99089 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
99090 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
99091 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
99092 +mq_create_30425 mq_create 1 30425 NULL
99093 +enable_write_30456 enable_write 3 30456 NULL
99094 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
99095 +urandom_read_30462 urandom_read 3 30462 NULL
99096 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
99097 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
99098 +write_head_30481 write_head 4 30481 NULL
99099 +adu_write_30487 adu_write 3 30487 NULL
99100 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
99101 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
99102 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
99103 +set_le_30581 set_le 4 30581 NULL
99104 +from_cblock_30582 from_cblock 0-1 30582 NULL
99105 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
99106 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
99107 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
99108 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
99109 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
99110 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
99111 +agp_remap_30665 agp_remap 2 30665 NULL
99112 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
99113 +il_free_pages_30692 il_free_pages 2 30692 NULL
99114 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
99115 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
99116 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
99117 +snapshot_status_30744 snapshot_status 5 30744 NULL
99118 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
99119 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
99120 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
99121 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
99122 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
99123 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
99124 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
99125 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
99126 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
99127 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
99128 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
99129 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
99130 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
99131 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
99132 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
99133 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
99134 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
99135 +sys_mincore_31079 sys_mincore 1 31079 NULL
99136 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
99137 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
99138 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
99139 +depth_read_31112 depth_read 3 31112 NULL
99140 +ssb_read16_31139 ssb_read16 0 31139 NULL
99141 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
99142 +size_inside_page_31141 size_inside_page 0 31141 NULL
99143 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
99144 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
99145 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
99146 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
99147 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
99148 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
99149 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
99150 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
99151 +__read_reg_31216 __read_reg 0 31216 NULL
99152 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
99153 +cyy_readb_31240 cyy_readb 0 31240 NULL
99154 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
99155 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
99156 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
99157 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
99158 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
99159 +command_file_write_31318 command_file_write 3 31318 NULL
99160 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
99161 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
99162 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
99163 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
99164 +inb_31388 inb 0 31388 NULL
99165 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
99166 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
99167 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
99168 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
99169 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
99170 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
99171 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
99172 +do_fcntl_31468 do_fcntl 3 31468 NULL
99173 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
99174 +alg_setkey_31485 alg_setkey 3 31485 NULL
99175 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
99176 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
99177 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
99178 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
99179 +hidraw_write_31536 hidraw_write 3 31536 NULL
99180 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
99181 +usbvision_read_31555 usbvision_read 3 31555 NULL
99182 +normalize_31566 normalize 0-1-2 31566 NULL
99183 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
99184 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
99185 +osst_write_31581 osst_write 3 31581 NULL
99186 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
99187 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
99188 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
99189 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
99190 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
99191 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
99192 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
99193 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
99194 +__lgread_31668 __lgread 4 31668 NULL
99195 +symbol_string_31670 symbol_string 0 31670 NULL
99196 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
99197 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
99198 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
99199 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
99200 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
99201 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
99202 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
99203 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
99204 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
99205 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
99206 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
99207 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
99208 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
99209 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
99210 +get_count_order_31800 get_count_order 0 31800 NULL
99211 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
99212 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
99213 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
99214 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
99215 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
99216 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
99217 +xattr_permission_31907 xattr_permission 0 31907 NULL
99218 +new_dir_31919 new_dir 3 31919 NULL
99219 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
99220 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
99221 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
99222 +vb2_write_31948 vb2_write 3 31948 NULL
99223 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
99224 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
99225 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
99226 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
99227 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
99228 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
99229 +calc_hmac_32010 calc_hmac 3 32010 NULL
99230 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
99231 +aead_len_32021 aead_len 0 32021 NULL
99232 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
99233 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
99234 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
99235 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
99236 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
99237 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
99238 +bio_alloc_32095 bio_alloc 2 32095 NULL
99239 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
99240 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
99241 +disk_status_32120 disk_status 4 32120 NULL
99242 +venus_link_32165 venus_link 5 32165 NULL
99243 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
99244 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
99245 +load_header_32183 load_header 0 32183 NULL
99246 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
99247 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
99248 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
99249 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
99250 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
99251 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
99252 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
99253 +hex_string_32310 hex_string 0 32310 NULL
99254 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
99255 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
99256 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
99257 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
99258 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
99259 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
99260 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
99261 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
99262 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
99263 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
99264 +log_text_32428 log_text 0 32428 NULL
99265 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
99266 +hid_input_report_32458 hid_input_report 4 32458 NULL
99267 +cache_status_32462 cache_status 5 32462 NULL
99268 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
99269 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
99270 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
99271 +disconnect_32521 disconnect 4 32521 NULL
99272 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
99273 +ilo_read_32531 ilo_read 3 32531 NULL
99274 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
99275 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
99276 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
99277 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
99278 +__first_node_32558 __first_node 0 32558 NULL
99279 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
99280 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
99281 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
99282 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
99283 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
99284 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
99285 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
99286 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
99287 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
99288 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
99289 +kvmalloc_32646 kvmalloc 1 32646 NULL
99290 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
99291 +generic_readlink_32654 generic_readlink 3 32654 NULL
99292 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
99293 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
99294 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
99295 +get_arg_page_32746 get_arg_page 2 32746 NULL
99296 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
99297 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
99298 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
99299 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
99300 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
99301 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
99302 +vga_rseq_32848 vga_rseq 0 32848 NULL
99303 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
99304 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
99305 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
99306 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
99307 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
99308 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
99309 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
99310 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
99311 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
99312 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
99313 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
99314 +compat_filldir_32999 compat_filldir 3 32999 NULL
99315 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
99316 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
99317 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
99318 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
99319 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
99320 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
99321 +alloc_tio_33077 alloc_tio 3 33077 NULL
99322 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
99323 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
99324 +write_node_33121 write_node 4 33121 NULL
99325 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
99326 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
99327 +__len_within_target_33132 __len_within_target 0 33132 NULL
99328 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
99329 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
99330 +pp_read_33210 pp_read 3 33210 NULL
99331 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
99332 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
99333 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
99334 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
99335 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
99336 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
99337 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
99338 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
99339 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
99340 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
99341 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
99342 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
99343 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
99344 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
99345 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
99346 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
99347 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
99348 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
99349 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
99350 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
99351 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
99352 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
99353 +create_entry_33479 create_entry 2 33479 NULL
99354 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
99355 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
99356 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
99357 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
99358 +res_counter_read_33499 res_counter_read 4 33499 NULL
99359 +fb_read_33506 fb_read 3 33506 NULL
99360 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
99361 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
99362 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
99363 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
99364 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
99365 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
99366 +dup_array_33551 dup_array 3 33551 NULL
99367 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
99368 +count_subheaders_33591 count_subheaders 0 33591 NULL
99369 +scsi_execute_33596 scsi_execute 5 33596 NULL
99370 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99371 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99372 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99373 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
99374 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
99375 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99376 +inw_p_33668 inw_p 0 33668 NULL
99377 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99378 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99379 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99380 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99381 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99382 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99383 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99384 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99385 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99386 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99387 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99388 +Read_hfc_33755 Read_hfc 0 33755 NULL
99389 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99390 +hashtab_create_33769 hashtab_create 3 33769 NULL
99391 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99392 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99393 +find_next_offset_33804 find_next_offset 3 33804 NULL
99394 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99395 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99396 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99397 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99398 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99399 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99400 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99401 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99402 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
99403 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99404 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99405 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99406 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99407 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99408 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99409 +ppp_write_34034 ppp_write 3 34034 NULL
99410 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99411 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99412 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99413 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99414 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99415 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99416 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99417 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
99418 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99419 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99420 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99421 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99422 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99423 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99424 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99425 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99426 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99427 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99428 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99429 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99430 +__insert_34349 __insert 2-3 34349 NULL
99431 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99432 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99433 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99434 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99435 +ea_read_34378 ea_read 0 34378 NULL
99436 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99437 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99438 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99439 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
99440 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
99441 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99442 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99443 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99444 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99445 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99446 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99447 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99448 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99449 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99450 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99451 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99452 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99453 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99454 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99455 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
99456 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99457 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99458 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99459 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
99460 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99461 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99462 +port_print_34704 port_print 3 34704 NULL
99463 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99464 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99465 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99466 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99467 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99468 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99469 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99470 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99471 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99472 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99473 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99474 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99475 +msg_print_text_34889 msg_print_text 0 34889 NULL
99476 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99477 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99478 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99479 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99480 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99481 +Realloc_34961 Realloc 2 34961 NULL
99482 +mq_lookup_34990 mq_lookup 2 34990 NULL
99483 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99484 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99485 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
99486 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99487 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
99488 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99489 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99490 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99491 +store_ifalias_35088 store_ifalias 4 35088 NULL
99492 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99493 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99494 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99495 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99496 +pointer_35138 pointer 0 35138 NULL
99497 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99498 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99499 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99500 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
99501 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
99502 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
99503 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99504 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99505 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99506 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99507 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
99508 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
99509 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
99510 +set_fd_set_35249 set_fd_set 1 35249 NULL
99511 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99512 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99513 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99514 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99515 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99516 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99517 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99518 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99519 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99520 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99521 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99522 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99523 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99524 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99525 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99526 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99527 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99528 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99529 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99530 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99531 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
99532 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99533 +async_setkey_35521 async_setkey 3 35521 NULL
99534 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99535 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99536 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99537 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99538 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99539 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99540 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
99541 +ReadZReg_35604 ReadZReg 0 35604 NULL
99542 +kernel_readv_35617 kernel_readv 3 35617 NULL
99543 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
99544 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99545 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99546 +store_debug_level_35652 store_debug_level 3 35652 NULL
99547 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99548 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99549 +dm_table_create_35687 dm_table_create 3 35687 NULL
99550 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99551 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99552 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99553 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99554 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99555 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99556 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99557 +fls64_35862 fls64 0 35862 NULL
99558 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99559 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99560 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99561 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99562 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
99563 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99564 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99565 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99566 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99567 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99568 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99569 +acl_alloc_35979 acl_alloc 1 35979 NULL
99570 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99571 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99572 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99573 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99574 +account_shadowed_36048 account_shadowed 2 36048 NULL
99575 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99576 +write_emulate_36065 write_emulate 2-4 36065 NULL
99577 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99578 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99579 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99580 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99581 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99582 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99583 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99584 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99585 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99586 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
99587 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99588 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99589 +twl_set_36154 twl_set 2 36154 NULL
99590 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99591 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99592 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99593 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99594 +is_dirty_36223 is_dirty 2 36223 NULL
99595 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
99596 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99597 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99598 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99599 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99600 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99601 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99602 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99603 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99604 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99605 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99606 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99607 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99608 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
99609 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99610 +lc_create_36332 lc_create 4 36332 NULL
99611 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99612 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99613 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99614 +to_sector_36361 to_sector 0-1 36361 NULL
99615 +tunables_read_36385 tunables_read 3 36385 NULL
99616 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99617 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99618 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99619 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99620 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99621 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99622 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99623 +get_param_l_36518 get_param_l 0 36518 NULL
99624 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99625 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99626 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99627 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99628 +get_entry_len_36549 get_entry_len 0 36549 NULL
99629 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99630 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99631 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99632 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99633 +__erst_read_36579 __erst_read 0 36579 NULL
99634 +put_cmsg_36589 put_cmsg 4 36589 NULL
99635 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99636 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99637 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99638 +format_decode_36638 format_decode 0 36638 NULL
99639 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99640 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99641 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99642 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99643 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99644 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99645 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99646 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99647 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99648 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99649 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99650 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99651 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99652 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99653 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99654 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
99655 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99656 +cm_write_36858 cm_write 3 36858 NULL
99657 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99658 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99659 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
99660 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
99661 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99662 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99663 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99664 +build_key_36931 build_key 1 36931 NULL
99665 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99666 +write_leb_36957 write_leb 5 36957 NULL
99667 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99668 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99669 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99670 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99671 +setxattr_37006 setxattr 4 37006 NULL
99672 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
99673 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
99674 +parse_command_37079 parse_command 2 37079 NULL
99675 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99676 +tun_get_user_37094 tun_get_user 5 37094 NULL
99677 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99678 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
99679 +msg_word_37164 msg_word 0 37164 NULL
99680 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99681 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99682 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99683 +__do_replace_37227 __do_replace 5 37227 NULL
99684 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99685 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99686 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99687 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99688 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
99689 +c101_run_37279 c101_run 2 37279 NULL
99690 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99691 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
99692 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99693 +send_msg_37323 send_msg 4 37323 NULL
99694 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99695 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99696 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99697 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99698 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99699 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99700 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99701 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99702 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99703 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99704 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99705 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99706 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99707 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99708 +__remove_37457 __remove 2 37457 NULL
99709 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99710 +get_est_timing_37484 get_est_timing 0 37484 NULL
99711 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99712 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99713 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99714 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99715 +hdr_size_37536 hdr_size 0 37536 NULL
99716 +a2p_37544 a2p 0-1 37544 NULL
99717 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99718 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99719 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99720 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99721 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
99722 +policy_residency_37629 policy_residency 0 37629 NULL
99723 +check_pt_base_37635 check_pt_base 3 37635 NULL
99724 +alloc_fd_37637 alloc_fd 1 37637 NULL
99725 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99726 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99727 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99728 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99729 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99730 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99731 +nametbl_header_37698 nametbl_header 2 37698 NULL
99732 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99733 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
99734 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
99735 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99736 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99737 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99738 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99739 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99740 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
99741 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99742 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99743 +deny_write_access_37813 deny_write_access 0 37813 NULL
99744 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99745 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99746 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99747 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99748 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99749 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99750 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99751 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
99752 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99753 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99754 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99755 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99756 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99757 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99758 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99759 +vfs_readv_38011 vfs_readv 3 38011 NULL
99760 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99761 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99762 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99763 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
99764 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
99765 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99766 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99767 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99768 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99769 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99770 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99771 +ep0_read_38095 ep0_read 3 38095 NULL
99772 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99773 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
99774 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99775 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99776 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99777 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99778 +cdev_add_38176 cdev_add 2-3 38176 NULL
99779 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99780 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99781 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99782 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99783 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99784 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99785 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
99786 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99787 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99788 +from_dblock_38256 from_dblock 0-1 38256 NULL
99789 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
99790 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99791 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99792 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99793 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99794 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
99795 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
99796 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
99797 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99798 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99799 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99800 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99801 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99802 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99803 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99804 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99805 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99806 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99807 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99808 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99809 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99810 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99811 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99812 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
99813 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99814 +dev_names_read_38509 dev_names_read 3 38509 NULL
99815 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99816 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99817 +set_queue_count_38519 set_queue_count 0 38519 NULL
99818 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
99819 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99820 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99821 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99822 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99823 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99824 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99825 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99826 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99827 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99828 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99829 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99830 +cma_create_area_38642 cma_create_area 2 38642 NULL
99831 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99832 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
99833 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99834 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99835 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99836 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99837 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99838 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
99839 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99840 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99841 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
99842 +udf_readpages_38761 udf_readpages 4 38761 NULL
99843 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99844 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99845 +err_decode_38804 err_decode 2 38804 NULL
99846 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99847 +sys_select_38827 sys_select 1 38827 NULL
99848 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99849 +direct_entry_38836 direct_entry 3 38836 NULL
99850 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99851 +interfaces_38859 interfaces 2 38859 NULL
99852 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99853 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99854 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99855 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99856 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99857 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99858 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99859 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99860 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99861 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99862 +udf_new_block_38999 udf_new_block 4 38999 NULL
99863 +get_nodes_39012 get_nodes 3 39012 NULL
99864 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99865 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99866 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99867 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99868 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99869 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99870 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99871 +ea_foreach_39133 ea_foreach 0 39133 NULL
99872 +generic_permission_39150 generic_permission 0 39150 NULL
99873 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99874 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99875 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99876 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99877 +init_list_set_39188 init_list_set 2-3 39188 NULL
99878 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99879 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99880 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99881 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99882 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99883 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99884 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99885 +drm_order_39244 drm_order 0 39244 NULL
99886 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99887 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99888 +__skb_cow_39254 __skb_cow 2 39254 NULL
99889 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99890 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99891 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99892 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99893 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99894 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99895 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99896 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99897 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99898 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99899 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99900 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
99901 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99902 +__send_to_port_39386 __send_to_port 3 39386 NULL
99903 +user_power_read_39414 user_power_read 3 39414 NULL
99904 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99905 +sys_semop_39457 sys_semop 3 39457 NULL
99906 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99907 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
99908 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99909 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99910 +int_proc_write_39542 int_proc_write 3 39542 NULL
99911 +pp_write_39554 pp_write 3 39554 NULL
99912 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99913 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99914 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99915 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99916 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99917 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99918 +ext_depth_39607 ext_depth 0 39607 NULL
99919 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99920 +sdio_readb_39618 sdio_readb 0 39618 NULL
99921 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99922 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99923 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99924 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99925 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99926 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99927 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99928 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99929 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99930 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99931 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99932 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
99933 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99934 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
99935 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99936 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99937 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99938 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99939 +pkt_add_39897 pkt_add 3 39897 NULL
99940 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99941 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99942 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99943 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99944 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99945 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99946 +__spi_async_39932 __spi_async 0 39932 NULL
99947 +__get_order_39935 __get_order 0 39935 NULL
99948 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99949 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99950 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99951 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99952 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99953 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99954 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99955 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99956 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99957 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99958 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99959 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99960 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99961 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99962 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99963 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99964 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99965 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99966 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99967 +pt_write_40159 pt_write 3 40159 NULL
99968 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99969 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99970 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99971 +allocate_probes_40204 allocate_probes 1 40204 NULL
99972 +compat_put_long_40214 compat_put_long 1 40214 NULL
99973 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99974 +osst_read_40237 osst_read 3 40237 NULL
99975 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99976 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99977 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99978 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99979 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99980 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99981 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
99982 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99983 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99984 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99985 +mmio_read_40348 mmio_read 4 40348 NULL
99986 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99987 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99988 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99989 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99990 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99991 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99992 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99993 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99994 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99995 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99996 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99997 +tty_write_room_40495 tty_write_room 0 40495 NULL
99998 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99999 +sg_phys_40507 sg_phys 0 40507 NULL
100000 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
100001 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
100002 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
100003 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
100004 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
100005 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
100006 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
100007 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
100008 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
100009 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
100010 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
100011 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
100012 +fops_read_40672 fops_read 3 40672 NULL
100013 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
100014 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
100015 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
100016 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
100017 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
100018 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
100019 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
100020 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
100021 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
100022 +card_send_command_40757 card_send_command 3 40757 NULL
100023 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
100024 +pg_write_40766 pg_write 3 40766 NULL
100025 +show_list_40775 show_list 3 40775 NULL
100026 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
100027 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
100028 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
100029 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
100030 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
100031 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
100032 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
100033 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
100034 +read_file_queue_40895 read_file_queue 3 40895 NULL
100035 +waiters_read_40902 waiters_read 3 40902 NULL
100036 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
100037 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
100038 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
100039 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
100040 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
100041 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
100042 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
100043 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
100044 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
100045 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
100046 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
100047 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
100048 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
100049 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
100050 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
100051 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
100052 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
100053 +dma_attach_41094 dma_attach 5-6 41094 NULL
100054 +provide_user_output_41105 provide_user_output 3 41105 NULL
100055 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
100056 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
100057 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
100058 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
100059 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
100060 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
100061 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
100062 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
100063 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
100064 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
100065 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
100066 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
100067 +erst_read_41260 erst_read 0 41260 NULL
100068 +__fprog_create_41263 __fprog_create 2 41263 NULL
100069 +alloc_context_41283 alloc_context 1 41283 NULL
100070 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
100071 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
100072 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
100073 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
100074 +kmp_init_41373 kmp_init 2 41373 NULL
100075 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
100076 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
100077 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
100078 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
100079 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
100080 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
100081 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
100082 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
100083 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
100084 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
100085 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
100086 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
100087 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
100088 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
100089 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
100090 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
100091 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
100092 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
100093 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
100094 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
100095 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
100096 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
100097 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
100098 +vga_io_r_41609 vga_io_r 0 41609 NULL
100099 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
100100 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
100101 +a2mp_send_41615 a2mp_send 4 41615 NULL
100102 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
100103 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
100104 +get_std_timing_41654 get_std_timing 0 41654 NULL
100105 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
100106 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
100107 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
100108 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
100109 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
100110 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
100111 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
100112 +fillonedir_41746 fillonedir 3 41746 NULL
100113 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
100114 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
100115 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
100116 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
100117 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
100118 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
100119 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
100120 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
100121 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
100122 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
100123 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
100124 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
100125 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
100126 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
100127 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
100128 +portnames_read_41958 portnames_read 3 41958 NULL
100129 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
100130 +dst_mtu_41969 dst_mtu 0 41969 NULL
100131 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
100132 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
100133 +lguest_map_42008 lguest_map 1-2 42008 NULL
100134 +pool_allocate_42012 pool_allocate 3 42012 NULL
100135 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
100136 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
100137 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
100138 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
100139 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
100140 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
100141 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
100142 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
100143 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
100144 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
100145 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
100146 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
100147 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
100148 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
100149 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
100150 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
100151 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
100152 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
100153 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
100154 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
100155 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
100156 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
100157 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
100158 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
100159 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
100160 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
100161 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
100162 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
100163 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
100164 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
100165 +free_cblock_42318 free_cblock 2 42318 NULL
100166 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
100167 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
100168 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
100169 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
100170 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
100171 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
100172 +krng_get_random_42420 krng_get_random 3 42420 NULL
100173 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
100174 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
100175 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
100176 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
100177 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
100178 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
100179 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
100180 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
100181 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
100182 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
100183 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
100184 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
100185 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
100186 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
100187 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
100188 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
100189 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
100190 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
100191 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
100192 +map_state_42602 map_state 1 42602 NULL nohasharray
100193 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
100194 +nd_get_link_42603 nd_get_link 0 42603 NULL
100195 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
100196 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
100197 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
100198 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
100199 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
100200 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
100201 +vb2_read_42703 vb2_read 3 42703 NULL
100202 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
100203 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
100204 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
100205 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
100206 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
100207 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
100208 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
100209 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
100210 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
100211 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
100212 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
100213 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
100214 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
100215 +set_arg_42824 set_arg 3 42824 NULL
100216 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
100217 +prandom_u32_42853 prandom_u32 0 42853 NULL
100218 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
100219 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
100220 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
100221 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
100222 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
100223 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
100224 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
100225 +hd_end_request_42904 hd_end_request 2 42904 NULL
100226 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
100227 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
100228 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
100229 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
100230 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
100231 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
100232 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
100233 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
100234 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
100235 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
100236 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
100237 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
100238 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
100239 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
100240 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
100241 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
100242 +uuid_string_43154 uuid_string 0 43154 NULL
100243 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
100244 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
100245 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
100246 +process_measurement_43190 process_measurement 0 43190 NULL
100247 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
100248 +uio_write_43202 uio_write 3 43202 NULL
100249 +iso_callback_43208 iso_callback 3 43208 NULL
100250 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
100251 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
100252 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
100253 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
100254 +fixup_leb_43256 fixup_leb 3 43256 NULL
100255 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
100256 +evtchn_write_43278 evtchn_write 3 43278 NULL
100257 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
100258 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
100259 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
100260 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
100261 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
100262 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
100263 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
100264 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
100265 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
100266 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
100267 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
100268 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
100269 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
100270 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
100271 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
100272 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
100273 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
100274 +do_readlink_43518 do_readlink 2 43518 NULL
100275 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
100276 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
100277 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
100278 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
100279 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
100280 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
100281 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
100282 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
100283 +proc_read_43614 proc_read 3 43614 NULL
100284 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
100285 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
100286 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
100287 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
100288 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
100289 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
100290 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
100291 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
100292 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
100293 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
100294 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
100295 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
100296 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
100297 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
100298 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
100299 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
100300 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
100301 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
100302 +read_flush_43851 read_flush 3 43851 NULL
100303 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
100304 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
100305 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
100306 +SendString_43928 SendString 3 43928 NULL
100307 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
100308 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
100309 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
100310 +nla_reserve_43984 nla_reserve 3 43984 NULL
100311 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
100312 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
100313 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
100314 +emit_flags_44006 emit_flags 4-3 44006 NULL
100315 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
100316 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
100317 +load_discard_44083 load_discard 3 44083 NULL
100318 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
100319 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
100320 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
100321 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
100322 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
100323 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
100324 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
100325 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
100326 +__set_free_44211 __set_free 2 44211 NULL
100327 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
100328 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
100329 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
100330 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
100331 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
100332 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
100333 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
100334 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
100335 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
100336 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
100337 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
100338 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
100339 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
100340 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
100341 +__is_discarded_44359 __is_discarded 2 44359 NULL
100342 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
100343 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
100344 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
100345 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
100346 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
100347 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
100348 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
100349 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
100350 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
100351 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
100352 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
100353 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
100354 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
100355 +spidev_write_44510 spidev_write 3 44510 NULL
100356 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
100357 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
100358 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
100359 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
100360 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
100361 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
100362 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
100363 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
100364 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
100365 +mpi_resize_44674 mpi_resize 2 44674 NULL
100366 +ts_read_44687 ts_read 3 44687 NULL
100367 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
100368 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
100369 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
100370 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
100371 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
100372 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
100373 +set_brk_44749 set_brk 1 44749 NULL
100374 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
100375 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
100376 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
100377 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
100378 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
100379 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
100380 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
100381 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
100382 +sisusb_write_44834 sisusb_write 3 44834 NULL
100383 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100384 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100385 +skb_availroom_44883 skb_availroom 0 44883 NULL
100386 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100387 +do_tty_write_44896 do_tty_write 5 44896 NULL
100388 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100389 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100390 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100391 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100392 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100393 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100394 +sel_write_user_45060 sel_write_user 3 45060 NULL
100395 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100396 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100397 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100398 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100399 +usbdev_read_45114 usbdev_read 3 45114 NULL
100400 +send_to_tty_45141 send_to_tty 3 45141 NULL
100401 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100402 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100403 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100404 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100405 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100406 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100407 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100408 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100409 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100410 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100411 +add_child_45201 add_child 4 45201 NULL
100412 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100413 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100414 +__dirty_45228 __dirty 2 45228 NULL
100415 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100416 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100417 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100418 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100419 +pte_val_45313 pte_val 0 45313 NULL
100420 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100421 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100422 +keymap_store_45406 keymap_store 4 45406 NULL
100423 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
100424 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
100425 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100426 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100427 +__node_remap_45458 __node_remap 4 45458 NULL
100428 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100429 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100430 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100431 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
100432 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100433 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100434 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100435 +copy_macs_45534 copy_macs 4 45534 NULL
100436 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100437 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100438 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100439 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100440 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100441 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100442 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
100443 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100444 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100445 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100446 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100447 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100448 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100449 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100450 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100451 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100452 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100453 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100454 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100455 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100456 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100457 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100458 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100459 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100460 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100461 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100462 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100463 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100464 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100465 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100466 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100467 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100468 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100469 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100470 +isdn_write_45863 isdn_write 3 45863 NULL
100471 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100472 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100473 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100474 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
100475 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100476 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100477 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
100478 +alloc_mr_45935 alloc_mr 1 45935 NULL
100479 +split_large_page_45941 split_large_page 2 45941 NULL
100480 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100481 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100482 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100483 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100484 +get_free_entries_46030 get_free_entries 1 46030 NULL
100485 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100486 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100487 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100488 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100489 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100490 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100491 +slhc_toss_46066 slhc_toss 0 46066 NULL
100492 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100493 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100494 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100495 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100496 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100497 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100498 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100499 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100500 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
100501 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100502 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100503 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100504 +add_conn_list_46197 add_conn_list 3 46197 NULL
100505 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100506 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100507 +dsp_write_46218 dsp_write 2 46218 NULL
100508 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100509 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100510 +ReadReg_46277 ReadReg 0 46277 NULL
100511 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100512 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100513 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100514 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100515 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100516 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100517 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100518 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100519 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100520 +filldir64_46469 filldir64 3 46469 NULL
100521 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100522 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100523 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100524 +kmsg_read_46514 kmsg_read 3 46514 NULL
100525 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100526 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100527 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100528 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100529 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100530 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100531 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100532 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100533 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100534 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100535 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100536 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100537 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100538 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
100539 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100540 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100541 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100542 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100543 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100544 +prepare_copy_46725 prepare_copy 2 46725 NULL
100545 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100546 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
100547 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
100548 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
100549 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100550 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100551 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100552 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100553 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100554 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100555 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100556 +spi_async_46857 spi_async 0 46857 NULL
100557 +vsnprintf_46863 vsnprintf 0 46863 NULL
100558 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100559 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100560 +rvmalloc_46873 rvmalloc 1 46873 NULL
100561 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
100562 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100563 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100564 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100565 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100566 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100567 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
100568 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
100569 +fb_write_46924 fb_write 3 46924 NULL
100570 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100571 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
100572 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100573 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100574 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100575 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100576 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100577 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100578 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100579 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100580 +__map_single_47020 __map_single 3-4-7 47020 NULL
100581 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100582 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
100583 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100584 +fs_path_len_47060 fs_path_len 0 47060 NULL
100585 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100586 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100587 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100588 +mousedev_read_47123 mousedev_read 3 47123 NULL
100589 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100590 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100591 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100592 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100593 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100594 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100595 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100596 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100597 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100598 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
100599 +l2headersize_47238 l2headersize 0 47238 NULL
100600 +options_write_47243 options_write 3 47243 NULL
100601 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100602 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100603 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100604 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100605 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100606 +vsnprintf_47291 vsnprintf 0 47291 NULL
100607 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100608 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100609 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100610 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100611 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100612 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
100613 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
100614 +nametbl_list_47391 nametbl_list 2 47391 NULL
100615 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100616 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100617 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
100618 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100619 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100620 +vzalloc_47421 vzalloc 1 47421 NULL
100621 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100622 +__load_mapping_47460 __load_mapping 2 47460 NULL
100623 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
100624 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
100625 +core_sys_select_47494 core_sys_select 1 47494 NULL
100626 +unlink_simple_47506 unlink_simple 3 47506 NULL
100627 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100628 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100629 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100630 +oz_events_read_47535 oz_events_read 3 47535 NULL
100631 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100632 +read_ldt_47570 read_ldt 2 47570 NULL
100633 +pci_iomap_47575 pci_iomap 3 47575 NULL
100634 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100635 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100636 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100637 +uea_request_47613 uea_request 4 47613 NULL
100638 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100639 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100640 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100641 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100642 +save_microcode_47717 save_microcode 3 47717 NULL
100643 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100644 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100645 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100646 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100647 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100648 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100649 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100650 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100651 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100652 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100653 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100654 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100655 +vhci_read_47878 vhci_read 3 47878 NULL
100656 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100657 +load_mapping_47904 load_mapping 3 47904 NULL
100658 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100659 +comedi_write_47926 comedi_write 3 47926 NULL
100660 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100661 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100662 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100663 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100664 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100665 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100666 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100667 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100668 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100669 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100670 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
100671 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100672 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100673 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100674 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100675 +set_discoverable_48141 set_discoverable 4 48141 NULL
100676 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100677 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100678 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100679 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100680 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100681 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100682 +init_ipath_48187 init_ipath 1 48187 NULL
100683 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100684 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100685 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100686 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100687 +read_file_recv_48232 read_file_recv 3 48232 NULL
100688 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
100689 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100690 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100691 +send_set_info_48288 send_set_info 7 48288 NULL
100692 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100693 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100694 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100695 +hash_setkey_48310 hash_setkey 3 48310 NULL
100696 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100697 +skb_add_data_48363 skb_add_data 3 48363 NULL
100698 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100699 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
100700 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100701 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100702 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100703 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100704 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100705 +send_control_msg_48498 send_control_msg 6 48498 NULL
100706 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100707 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100708 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100709 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100710 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100711 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100712 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100713 +named_distribute_48544 named_distribute 4 48544 NULL
100714 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100715 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100716 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100717 +mtd_read_48655 mtd_read 0 48655 NULL
100718 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100719 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100720 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100721 +altera_drscan_48698 altera_drscan 2 48698 NULL
100722 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100723 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100724 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100725 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100726 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100727 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100728 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100729 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100730 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
100731 +azx_get_position_48841 azx_get_position 0 48841 NULL
100732 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100733 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100734 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100735 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100736 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100737 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100738 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100739 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100740 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
100741 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100742 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100743 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100744 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
100745 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100746 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100747 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100748 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100749 +transient_status_49027 transient_status 4 49027 NULL
100750 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
100751 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
100752 +ubi_read_49061 ubi_read 0 49061 NULL
100753 +scsi_register_49094 scsi_register 2 49094 NULL
100754 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
100755 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100756 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100757 +pt_read_49136 pt_read 3 49136 NULL
100758 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100759 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100760 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100761 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100762 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100763 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100764 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100765 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100766 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100767 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100768 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
100769 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
100770 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100771 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100772 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100773 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100774 +uio_read_49300 uio_read 3 49300 NULL
100775 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100776 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100777 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100778 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100779 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100780 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100781 +px_raw_event_49371 px_raw_event 4 49371 NULL
100782 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100783 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100784 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100785 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100786 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100787 +md_domain_init_49432 md_domain_init 2 49432 NULL
100788 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100789 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100790 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100791 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100792 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100793 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100794 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100795 +smk_write_access_49561 smk_write_access 3 49561 NULL
100796 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100797 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100798 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100799 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100800 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
100801 +heap_init_49617 heap_init 2 49617 NULL
100802 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100803 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100804 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100805 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100806 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100807 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
100808 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100809 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100810 +check_frame_49741 check_frame 0 49741 NULL
100811 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100812 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100813 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
100814 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100815 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100816 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100817 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100818 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100819 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100820 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100821 +add_uuid_49831 add_uuid 4 49831 NULL
100822 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100823 +twl4030_write_49846 twl4030_write 2 49846 NULL
100824 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100825 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100826 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100827 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100828 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100829 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100830 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100831 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100832 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100833 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100834 +__module_alloc_50004 __module_alloc 1 50004 NULL
100835 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100836 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100837 +isdn_read_50021 isdn_read 3 50021 NULL
100838 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
100839 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100840 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100841 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100842 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100843 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100844 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100845 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100846 +read_file_slot_50111 read_file_slot 3 50111 NULL
100847 +copy_items_50140 copy_items 6 50140 NULL
100848 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100849 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100850 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100851 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100852 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100853 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100854 +odev_update_50169 odev_update 2 50169 NULL
100855 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100856 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100857 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100858 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100859 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100860 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100861 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100862 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100863 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100864 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100865 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100866 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100867 +do_launder_page_50329 do_launder_page 0 50329 NULL
100868 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100869 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100870 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100871 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100872 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100873 +tpm_read_50344 tpm_read 3 50344 NULL
100874 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100875 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100876 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100877 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100878 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100879 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100880 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100881 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100882 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
100883 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100884 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100885 +force_mapping_50464 force_mapping 2 50464 NULL
100886 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100887 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100888 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100889 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100890 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100891 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100892 +fat_readpages_50582 fat_readpages 4 50582 NULL
100893 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100894 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100895 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100896 +__ffs_50625 __ffs 0 50625 NULL
100897 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100898 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100899 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100900 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100901 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100902 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100903 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
100904 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
100905 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100906 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100907 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100908 +skb_padto_50759 skb_padto 2 50759 NULL
100909 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100910 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100911 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100912 +tpm_write_50798 tpm_write 3 50798 NULL
100913 +write_flush_50803 write_flush 3 50803 NULL
100914 +dvb_play_50814 dvb_play 3 50814 NULL
100915 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100916 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100917 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100918 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100919 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
100920 +self_check_write_50856 self_check_write 5 50856 NULL
100921 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100922 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100923 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100924 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100925 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100926 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100927 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100928 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100929 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100930 +timeout_write_50991 timeout_write 3 50991 NULL
100931 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
100932 +proc_write_51003 proc_write 3 51003 NULL
100933 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
100934 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100935 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100936 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100937 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100938 +dump_midi_51040 dump_midi 3 51040 NULL
100939 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100940 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100941 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100942 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100943 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100944 +ti_recv_51110 ti_recv 3 51110 NULL
100945 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100946 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100947 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100948 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100949 +set_dirty_51144 set_dirty 3 51144 NULL
100950 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100951 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100952 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100953 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100954 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100955 +tipc_send_51238 tipc_send 4 51238 NULL
100956 +drm_property_create_51239 drm_property_create 4 51239 NULL
100957 +st_read_51251 st_read 3 51251 NULL
100958 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100959 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100960 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100961 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100962 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100963 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100964 +get_cell_51316 get_cell 2 51316 NULL
100965 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100966 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100967 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100968 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100969 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100970 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100971 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100972 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100973 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100974 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
100975 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100976 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100977 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100978 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100979 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100980 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100981 +vaddr_51480 vaddr 0 51480 NULL
100982 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
100983 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100984 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
100985 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100986 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100987 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100988 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100989 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100990 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100991 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
100992 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100993 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100994 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100995 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100996 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100997 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100998 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100999 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
101000 +sel_write_access_51704 sel_write_access 3 51704 NULL
101001 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
101002 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
101003 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
101004 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
101005 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
101006 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
101007 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
101008 +if_write_51756 if_write 3 51756 NULL
101009 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
101010 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
101011 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
101012 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
101013 +ioread32_51847 ioread32 0 51847 NULL nohasharray
101014 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
101015 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
101016 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
101017 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
101018 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
101019 +user_read_51881 user_read 3 51881 NULL
101020 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
101021 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
101022 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
101023 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
101024 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
101025 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
101026 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
101027 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
101028 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
101029 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
101030 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
101031 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
101032 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
101033 +rdmalt_52022 rdmalt 0 52022 NULL
101034 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
101035 +override_release_52032 override_release 2 52032 NULL
101036 +end_port_52042 end_port 0 52042 NULL
101037 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
101038 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
101039 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
101040 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
101041 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
101042 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
101043 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
101044 +retry_count_read_52129 retry_count_read 3 52129 NULL
101045 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
101046 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
101047 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
101048 +htable_size_52148 htable_size 0-1 52148 NULL
101049 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
101050 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
101051 +alix_present_52165 alix_present 1 52165 NULL
101052 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
101053 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
101054 +print_prefix_52176 print_prefix 0 52176 NULL
101055 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
101056 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
101057 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
101058 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
101059 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
101060 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
101061 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
101062 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
101063 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
101064 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
101065 +read_file_reset_52310 read_file_reset 3 52310 NULL
101066 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
101067 +hwflags_read_52318 hwflags_read 3 52318 NULL
101068 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
101069 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
101070 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
101071 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
101072 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
101073 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
101074 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
101075 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
101076 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
101077 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
101078 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
101079 +delay_status_52431 delay_status 5 52431 NULL
101080 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
101081 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
101082 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
101083 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
101084 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
101085 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
101086 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
101087 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
101088 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
101089 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
101090 +from_oblock_52546 from_oblock 0-1 52546 NULL
101091 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
101092 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
101093 +emit_code_52583 emit_code 0-3 52583 NULL
101094 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
101095 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
101096 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
101097 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
101098 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
101099 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
101100 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
101101 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
101102 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
101103 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
101104 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
101105 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
101106 +twlreg_write_52880 twlreg_write 3 52880 NULL
101107 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
101108 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
101109 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
101110 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
101111 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
101112 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
101113 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
101114 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
101115 +send_packet_52960 send_packet 4 52960 NULL
101116 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
101117 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
101118 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
101119 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
101120 +num_node_state_52989 num_node_state 0 52989 NULL
101121 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
101122 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
101123 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
101124 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
101125 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
101126 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
101127 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
101128 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
101129 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
101130 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
101131 +verity_status_53120 verity_status 5 53120 NULL
101132 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
101133 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
101134 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
101135 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
101136 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
101137 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
101138 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
101139 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
101140 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
101141 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
101142 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
101143 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
101144 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
101145 +vm_mmap_53339 vm_mmap 0 53339 NULL
101146 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
101147 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
101148 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
101149 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
101150 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
101151 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
101152 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
101153 +n2_run_53459 n2_run 3 53459 NULL
101154 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
101155 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
101156 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
101157 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
101158 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
101159 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
101160 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
101161 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
101162 +check_acl_53512 check_acl 0 53512 NULL
101163 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
101164 +set_registers_53582 set_registers 3 53582 NULL
101165 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
101166 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
101167 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
101168 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
101169 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
101170 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
101171 +_preload_range_53676 _preload_range 2-3 53676 NULL
101172 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
101173 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
101174 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
101175 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
101176 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
101177 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
101178 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
101179 +wdm_write_53735 wdm_write 3 53735 NULL
101180 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
101181 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
101182 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
101183 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
101184 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
101185 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
101186 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
101187 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
101188 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
101189 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
101190 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
101191 +pms_read_53873 pms_read 3 53873 NULL
101192 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
101193 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
101194 +proc_file_read_53905 proc_file_read 3 53905 NULL
101195 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
101196 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
101197 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
101198 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
101199 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
101200 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
101201 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
101202 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
101203 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
101204 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
101205 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
101206 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
101207 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
101208 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
101209 +_malloc_54077 _malloc 1 54077 NULL
101210 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
101211 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
101212 +create_xattr_54106 create_xattr 5 54106 NULL
101213 +strn_len_54122 strn_len 0 54122 NULL
101214 +isku_receive_54130 isku_receive 4 54130 NULL
101215 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
101216 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
101217 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
101218 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
101219 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
101220 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
101221 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
101222 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
101223 +reada_add_block_54247 reada_add_block 2 54247 NULL
101224 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
101225 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
101226 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
101227 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
101228 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
101229 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
101230 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
101231 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
101232 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
101233 +sprintf_54306 sprintf 0 54306 NULL
101234 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
101235 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
101236 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
101237 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
101238 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
101239 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
101240 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
101241 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
101242 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
101243 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
101244 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
101245 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
101246 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
101247 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
101248 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
101249 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
101250 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
101251 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
101252 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
101253 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
101254 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
101255 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
101256 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
101257 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
101258 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
101259 +viacam_read_54526 viacam_read 3 54526 NULL
101260 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
101261 +setsockopt_54539 setsockopt 5 54539 NULL
101262 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
101263 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
101264 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
101265 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
101266 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
101267 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
101268 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
101269 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
101270 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
101271 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
101272 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
101273 +evm_read_key_54674 evm_read_key 3 54674 NULL
101274 +resource_string_54699 resource_string 0 54699 NULL
101275 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
101276 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
101277 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
101278 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
101279 +kzalloc_54740 kzalloc 1 54740 NULL
101280 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
101281 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
101282 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
101283 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
101284 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
101285 +domain_init_54797 domain_init 2 54797 NULL
101286 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
101287 +get_dev_size_54807 get_dev_size 0 54807 NULL
101288 +nfsd_write_54809 nfsd_write 6 54809 NULL
101289 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
101290 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
101291 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
101292 +write_rio_54837 write_rio 3 54837 NULL
101293 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
101294 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
101295 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
101296 +printer_read_54851 printer_read 3 54851 NULL
101297 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
101298 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
101299 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
101300 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
101301 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
101302 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
101303 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
101304 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
101305 +add_port_54941 add_port 2 54941 NULL
101306 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
101307 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
101308 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
101309 +c4_add_card_54968 c4_add_card 3 54968 NULL
101310 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
101311 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
101312 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
101313 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
101314 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
101315 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
101316 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
101317 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
101318 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
101319 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
101320 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
101321 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
101322 +corrupt_data_55120 corrupt_data 0 55120 NULL
101323 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
101324 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
101325 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
101326 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
101327 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
101328 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
101329 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
101330 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
101331 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
101332 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
101333 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
101334 +dump_command_55220 dump_command 1 55220 NULL
101335 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
101336 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
101337 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
101338 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
101339 +ptrace_request_55288 ptrace_request 3 55288 NULL
101340 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
101341 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
101342 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
101343 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
101344 +do_shmat_55336 do_shmat 5 55336 NULL
101345 +vme_user_read_55338 vme_user_read 3 55338 NULL
101346 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
101347 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
101348 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
101349 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
101350 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
101351 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
101352 +alloc_skb_55439 alloc_skb 1 55439 NULL
101353 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
101354 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
101355 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
101356 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
101357 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
101358 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
101359 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
101360 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
101361 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
101362 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
101363 +ea_get_55522 ea_get 0 55522 NULL
101364 +buffer_size_55534 buffer_size 0 55534 NULL
101365 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
101366 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
101367 +add_partition_55588 add_partition 2 55588 NULL
101368 +free_pages_55603 free_pages 1 55603 NULL
101369 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
101370 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
101371 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
101372 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
101373 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
101374 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
101375 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
101376 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
101377 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
101378 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
101379 +read_oldmem_55658 read_oldmem 3 55658 NULL
101380 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
101381 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
101382 +get_info_55681 get_info 3 55681 NULL
101383 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101384 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101385 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101386 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101387 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
101388 +set_local_name_55757 set_local_name 4 55757 NULL
101389 +strlen_55778 strlen 0 55778 NULL
101390 +set_spte_55783 set_spte 5-4 55783 NULL
101391 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101392 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101393 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101394 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101395 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101396 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101397 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101398 +hsc_write_55875 hsc_write 3 55875 NULL
101399 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101400 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101401 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
101402 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101403 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
101404 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101405 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101406 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101407 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101408 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101409 +__set_discard_56081 __set_discard 2 56081 NULL
101410 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101411 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101412 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101413 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101414 +map_addr_56144 map_addr 7 56144 NULL
101415 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101416 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101417 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101418 +skb_headroom_56200 skb_headroom 0 56200 NULL
101419 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101420 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101421 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101422 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101423 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101424 +fd_copyin_56247 fd_copyin 3 56247 NULL
101425 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101426 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101427 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101428 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101429 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101430 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101431 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101432 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101433 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101434 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101435 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101436 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101437 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101438 +dev_read_56369 dev_read 3 56369 NULL
101439 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101440 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101441 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101442 +store_msg_56417 store_msg 3 56417 NULL
101443 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101444 +fl_create_56435 fl_create 5 56435 NULL
101445 +gnttab_map_56439 gnttab_map 2 56439 NULL
101446 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101447 +set_connectable_56458 set_connectable 4 56458 NULL
101448 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101449 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101450 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101451 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
101452 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101453 +ip_options_get_56538 ip_options_get 4 56538 NULL
101454 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101455 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101456 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101457 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101458 +event_filter_write_56609 event_filter_write 3 56609 NULL
101459 +gather_array_56641 gather_array 3 56641 NULL
101460 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101461 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101462 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101463 +build_map_info_56696 build_map_info 2 56696 NULL
101464 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101465 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101466 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101467 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101468 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101469 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101470 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101471 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101472 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101473 +hash_lookup_56792 hash_lookup 2 56792 NULL
101474 +do_syslog_56807 do_syslog 3 56807 NULL
101475 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101476 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101477 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101478 +wb_lookup_56858 wb_lookup 2 56858 NULL
101479 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101480 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101481 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101482 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101483 +strcspn_56913 strcspn 0 56913 NULL
101484 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101485 +check_header_56930 check_header 2 56930 NULL
101486 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101487 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101488 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101489 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101490 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101491 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
101492 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101493 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101494 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101495 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101496 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101497 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101498 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101499 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101500 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101501 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101502 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101503 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101504 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101505 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101506 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101507 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101508 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101509 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101510 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
101511 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101512 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101513 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101514 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101515 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101516 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101517 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101518 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101519 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101520 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101521 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101522 +fw_file_size_57307 fw_file_size 0 57307 NULL
101523 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101524 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101525 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101526 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101527 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101528 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101529 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101530 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101531 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101532 +read_file_blob_57406 read_file_blob 3 57406 NULL
101533 +enclosure_register_57412 enclosure_register 3 57412 NULL
101534 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101535 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101536 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101537 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101538 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101539 +ReadReg_57453 ReadReg 0 57453 NULL
101540 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101541 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101542 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101543 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101544 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101545 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101546 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101547 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101548 +skb_headlen_57501 skb_headlen 0 57501 NULL
101549 +copy_in_user_57502 copy_in_user 3 57502 NULL
101550 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101551 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101552 +init_tag_map_57515 init_tag_map 3 57515 NULL
101553 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101554 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101555 +inode_permission_57531 inode_permission 0 57531 NULL
101556 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101557 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101558 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101559 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101560 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
101561 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
101562 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101563 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101564 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
101565 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101566 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101567 +mem_read_57631 mem_read 3 57631 NULL
101568 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101569 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101570 +r3964_write_57662 r3964_write 4 57662 NULL
101571 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101572 +__lgwrite_57669 __lgwrite 4 57669 NULL
101573 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101574 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101575 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101576 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101577 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101578 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
101579 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101580 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101581 +ld2_57794 ld2 0 57794 NULL
101582 +ivtv_read_57796 ivtv_read 3 57796 NULL
101583 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101584 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
101585 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101586 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101587 +copy_to_user_57835 copy_to_user 3 57835 NULL
101588 +flash_read_57843 flash_read 3 57843 NULL
101589 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101590 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101591 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101592 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101593 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101594 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101595 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101596 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101597 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101598 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101599 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101600 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101601 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
101602 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101603 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101604 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101605 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101606 +mce_async_out_58056 mce_async_out 3 58056 NULL
101607 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101608 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101609 +cm4040_write_58079 cm4040_write 3 58079 NULL
101610 +udi_log_event_58105 udi_log_event 3 58105 NULL
101611 +savemem_58129 savemem 3 58129 NULL
101612 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101613 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101614 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101615 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101616 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101617 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
101618 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101619 +read_file_debug_58256 read_file_debug 3 58256 NULL
101620 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101621 +profile_load_58267 profile_load 3 58267 NULL
101622 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101623 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101624 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101625 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101626 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101627 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101628 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101629 +next_pidmap_58347 next_pidmap 2 58347 NULL
101630 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101631 +save_hint_58359 save_hint 2 58359 NULL
101632 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101633 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101634 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101635 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101636 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101637 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101638 +capabilities_read_58457 capabilities_read 3 58457 NULL
101639 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101640 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101641 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101642 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101643 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101644 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101645 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
101646 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101647 +__clear_discard_58546 __clear_discard 2 58546 NULL
101648 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101649 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101650 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101651 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101652 +xip_file_read_58592 xip_file_read 3 58592 NULL
101653 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101654 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101655 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101656 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101657 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101658 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101659 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101660 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
101661 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
101662 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101663 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101664 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101665 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
101666 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101667 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101668 +acpi_map_58725 acpi_map 1-2 58725 NULL
101669 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101670 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101671 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101672 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101673 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101674 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
101675 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101676 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101677 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101678 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101679 +ep_read_58813 ep_read 3 58813 NULL
101680 +command_write_58841 command_write 3 58841 NULL
101681 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101682 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101683 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101684 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101685 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101686 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101687 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101688 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101689 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101690 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101691 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
101692 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101693 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
101694 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101695 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101696 +ep_write_59008 ep_write 3 59008 NULL
101697 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101698 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101699 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101700 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101701 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101702 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101703 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101704 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101705 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101706 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101707 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101708 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101709 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101710 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101711 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101712 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101713 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101714 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101715 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101716 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101717 +dt3155_read_59226 dt3155_read 3 59226 NULL
101718 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101719 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101720 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101721 +nla_len_59258 nla_len 0 59258 NULL
101722 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101723 +fd_copyout_59323 fd_copyout 3 59323 NULL
101724 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101725 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101726 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
101727 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
101728 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101729 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101730 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101731 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101732 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101733 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101734 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101735 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101736 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101737 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101738 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101739 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
101740 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101741 +tunables_write_59563 tunables_write 3 59563 NULL
101742 +memdup_user_59590 memdup_user 2 59590 NULL
101743 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101744 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101745 +mtrr_write_59622 mtrr_write 3 59622 NULL
101746 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101747 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101748 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101749 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101750 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101751 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101752 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
101753 +sriov_enable_59689 sriov_enable 2 59689 NULL
101754 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101755 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101756 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101757 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101758 +strnlen_59746 strnlen 0 59746 NULL
101759 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101760 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101761 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101762 +venus_remove_59781 venus_remove 4 59781 NULL
101763 +ipw_write_59807 ipw_write 3 59807 NULL
101764 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101765 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101766 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101767 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101768 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
101769 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101770 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101771 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101772 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
101773 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101774 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101775 +lookup_node_59953 lookup_node 2 59953 NULL
101776 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
101777 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
101778 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
101779 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101780 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101781 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101782 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101783 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
101784 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101785 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101786 +register_device_60015 register_device 2-3 60015 NULL
101787 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101788 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101789 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101790 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101791 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101792 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101793 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101794 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
101795 +compat_writev_60063 compat_writev 3 60063 NULL
101796 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
101797 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101798 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101799 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101800 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101801 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101802 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101803 +init_state_60165 init_state 2 60165 NULL
101804 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101805 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101806 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101807 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101808 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101809 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101810 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101811 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101812 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101813 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
101814 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
101815 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101816 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101817 +printer_write_60276 printer_write 3 60276 NULL
101818 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101819 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101820 +getDataLength_60301 getDataLength 0 60301 NULL
101821 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101822 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101823 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101824 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101825 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
101826 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101827 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101828 +driver_names_read_60399 driver_names_read 3 60399 NULL
101829 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
101830 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101831 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101832 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101833 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101834 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101835 +rx_data_60442 rx_data 4 60442 NULL
101836 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101837 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
101838 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101839 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101840 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101841 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101842 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101843 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101844 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101845 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101846 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101847 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101848 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101849 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101850 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101851 +init_data_container_60709 init_data_container 1 60709 NULL
101852 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101853 +raid_status_60755 raid_status 5 60755 NULL
101854 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101855 +opticon_write_60775 opticon_write 4 60775 NULL
101856 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101857 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101858 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101859 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101860 +generic_writepages_60871 generic_writepages 0 60871 NULL
101861 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101862 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101863 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101864 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101865 +sys_mlock_60932 sys_mlock 1 60932 NULL
101866 +pti_char_write_60960 pti_char_write 3 60960 NULL
101867 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101868 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101869 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101870 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101871 +symtab_init_61050 symtab_init 2 61050 NULL
101872 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101873 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101874 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101875 +get_derived_key_61100 get_derived_key 4 61100 NULL
101876 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101877 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101878 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101879 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101880 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101881 +__vmalloc_61168 __vmalloc 1 61168 NULL
101882 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101883 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101884 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101885 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101886 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101887 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101888 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101889 +sys_add_key_61288 sys_add_key 4 61288 NULL
101890 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101891 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101892 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101893 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101894 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101895 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101896 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101897 +change_xattr_61390 change_xattr 5 61390 NULL
101898 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101899 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101900 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101901 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101902 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101903 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101904 +erst_errno_61526 erst_errno 0 61526 NULL
101905 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101906 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101907 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101908 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101909 +seq_open_private_61589 seq_open_private 3 61589 NULL
101910 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101911 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101912 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101913 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101914 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101915 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101916 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101917 +resize_stripes_61650 resize_stripes 2 61650 NULL
101918 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101919 +insert_one_name_61668 insert_one_name 7 61668 NULL
101920 +lock_loop_61681 lock_loop 1 61681 NULL
101921 +filter_read_61692 filter_read 3 61692 NULL
101922 +iov_length_61716 iov_length 0 61716 NULL
101923 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101924 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101925 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101926 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101927 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101928 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101929 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101930 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101931 +get_fw_name_61874 get_fw_name 3 61874 NULL
101932 +free_init_pages_61875 free_init_pages 2 61875 NULL
101933 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101934 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101935 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101936 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101937 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101938 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101939 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101940 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101941 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101942 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
101943 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101944 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101945 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101946 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101947 +cow_file_range_61979 cow_file_range 3 61979 NULL
101948 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
101949 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101950 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101951 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101952 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101953 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101954 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101955 +do_pselect_62061 do_pselect 1 62061 NULL
101956 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
101957 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101958 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
101959 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101960 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101961 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101962 +ql_status_62135 ql_status 5 62135 NULL
101963 +video_usercopy_62151 video_usercopy 2 62151 NULL
101964 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101965 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101966 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101967 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101968 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101969 +allocate_partition_62245 allocate_partition 4 62245 NULL
101970 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
101971 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101972 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101973 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101974 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101975 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101976 +subseq_list_62332 subseq_list 3-0 62332 NULL
101977 +flash_write_62354 flash_write 3 62354 NULL
101978 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101979 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
101980 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101981 +altera_irscan_62396 altera_irscan 2 62396 NULL
101982 +set_ssp_62411 set_ssp 4 62411 NULL
101983 +unmap_single_62423 unmap_single 2 62423 NULL
101984 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101985 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101986 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101987 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101988 +remove_mapping_62491 remove_mapping 2 62491 NULL
101989 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101990 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101991 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
101992 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
101993 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101994 +debugfs_read_62535 debugfs_read 3 62535 NULL
101995 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101996 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101997 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101998 +get_subdir_62581 get_subdir 3 62581 NULL
101999 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
102000 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
102001 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
102002 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
102003 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
102004 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
102005 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
102006 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
102007 +write_62671 write 3 62671 NULL
102008 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
102009 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
102010 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
102011 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
102012 +rdm_62719 rdm 0 62719 NULL
102013 +key_replays_read_62746 key_replays_read 3 62746 NULL
102014 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
102015 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
102016 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
102017 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
102018 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
102019 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
102020 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
102021 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
102022 +set_swbp_62853 set_swbp 3 62853 NULL
102023 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
102024 +aoechr_write_62883 aoechr_write 3 62883 NULL
102025 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
102026 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
102027 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
102028 +getdqbuf_62908 getdqbuf 1 62908 NULL
102029 +try_async_pf_62914 try_async_pf 3 62914 NULL
102030 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
102031 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
102032 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
102033 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
102034 +unlink1_63059 unlink1 3 63059 NULL
102035 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
102036 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
102037 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
102038 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
102039 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
102040 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
102041 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
102042 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
102043 +vme_master_read_63221 vme_master_read 0 63221 NULL
102044 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
102045 +ptp_read_63251 ptp_read 4 63251 NULL
102046 +raid5_resize_63306 raid5_resize 2 63306 NULL
102047 +proc_info_read_63344 proc_info_read 3 63344 NULL
102048 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
102049 +idmouse_read_63374 idmouse_read 3 63374 NULL
102050 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
102051 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
102052 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
102053 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
102054 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
102055 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
102056 +kone_send_63435 kone_send 4 63435 NULL
102057 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
102058 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
102059 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
102060 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
102061 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
102062 +read_kcore_63488 read_kcore 3 63488 NULL
102063 +save_hint_63497 save_hint 2 63497 NULL
102064 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
102065 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
102066 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
102067 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
102068 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
102069 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
102070 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
102071 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
102072 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
102073 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
102074 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
102075 +module_alloc_63630 module_alloc 1 63630 NULL
102076 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
102077 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
102078 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
102079 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
102080 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
102081 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
102082 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
102083 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
102084 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
102085 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
102086 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
102087 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
102088 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
102089 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
102090 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
102091 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
102092 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
102093 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
102094 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
102095 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
102096 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
102097 +sel_write_load_63830 sel_write_load 3 63830 NULL
102098 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
102099 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
102100 +divas_write_63901 divas_write 3 63901 NULL
102101 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
102102 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
102103 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
102104 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
102105 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
102106 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
102107 +__team_options_register_63941 __team_options_register 3 63941 NULL
102108 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
102109 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
102110 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
102111 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
102112 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
102113 +kmemdup_64015 kmemdup 2 64015 NULL
102114 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
102115 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
102116 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
102117 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
102118 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
102119 +get_u8_64076 get_u8 0 64076 NULL
102120 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
102121 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
102122 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
102123 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
102124 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
102125 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
102126 +init_bch_64130 init_bch 1-2 64130 NULL
102127 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
102128 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
102129 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
102130 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
102131 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
102132 +read_pulse_64227 read_pulse 0-3 64227 NULL
102133 +header_len_64232 header_len 0 64232 NULL
102134 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
102135 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
102136 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
102137 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
102138 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
102139 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
102140 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
102141 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
102142 +ffz_64324 ffz 0 64324 NULL
102143 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
102144 +ts_write_64336 ts_write 3 64336 NULL
102145 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
102146 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
102147 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
102148 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
102149 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
102150 +ilo_write_64378 ilo_write 3 64378 NULL
102151 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
102152 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
102153 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
102154 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
102155 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
102156 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
102157 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
102158 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
102159 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
102160 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
102161 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
102162 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
102163 +cap_capable_64462 cap_capable 0 64462 NULL
102164 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
102165 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
102166 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
102167 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
102168 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
102169 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
102170 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
102171 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
102172 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
102173 +__spi_sync_64561 __spi_sync 0 64561 NULL
102174 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
102175 +fanotify_write_64623 fanotify_write 3 64623 NULL
102176 +to_dblock_64655 to_dblock 0-1 64655 NULL
102177 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
102178 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
102179 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
102180 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
102181 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
102182 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
102183 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
102184 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
102185 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
102186 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
102187 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
102188 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
102189 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
102190 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
102191 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
102192 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
102193 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
102194 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
102195 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
102196 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
102197 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
102198 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
102199 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
102200 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
102201 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
102202 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
102203 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
102204 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
102205 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
102206 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
102207 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
102208 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
102209 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
102210 +pskb_pull_65005 pskb_pull 2 65005 NULL
102211 +unifi_write_65012 unifi_write 3 65012 NULL
102212 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
102213 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
102214 +insert_dent_65034 insert_dent 7 65034 NULL
102215 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
102216 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
102217 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
102218 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
102219 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
102220 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
102221 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
102222 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
102223 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
102224 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
102225 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
102226 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
102227 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
102228 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
102229 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
102230 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
102231 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
102232 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
102233 +get_var_len_65304 get_var_len 0 65304 NULL
102234 +unpack_array_65318 unpack_array 0 65318 NULL
102235 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
102236 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
102237 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
102238 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
102239 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
102240 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
102241 +strchr_65372 strchr 0 65372 NULL
102242 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
102243 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
102244 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
102245 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
102246 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
102247 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
102248 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
102249 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
102250 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
102251 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
102252 +alloc_dr_65495 alloc_dr 2 65495 NULL
102253 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
102254 new file mode 100644
102255 index 0000000..9db0d0e
102256 --- /dev/null
102257 +++ b/tools/gcc/size_overflow_plugin.c
102258 @@ -0,0 +1,2114 @@
102259 +/*
102260 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
102261 + * Licensed under the GPL v2, or (at your option) v3
102262 + *
102263 + * Homepage:
102264 + * http://www.grsecurity.net/~ephox/overflow_plugin/
102265 + *
102266 + * Documentation:
102267 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
102268 + *
102269 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
102270 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
102271 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
102272 + *
102273 + * Usage:
102274 + * $ 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
102275 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
102276 + */
102277 +
102278 +#include "gcc-plugin.h"
102279 +#include "config.h"
102280 +#include "system.h"
102281 +#include "coretypes.h"
102282 +#include "tree.h"
102283 +#include "tree-pass.h"
102284 +#include "intl.h"
102285 +#include "plugin-version.h"
102286 +#include "tm.h"
102287 +#include "toplev.h"
102288 +#include "function.h"
102289 +#include "tree-flow.h"
102290 +#include "plugin.h"
102291 +#include "gimple.h"
102292 +#include "diagnostic.h"
102293 +#include "cfgloop.h"
102294 +
102295 +#if BUILDING_GCC_VERSION >= 4008
102296 +#define TODO_dump_func 0
102297 +#endif
102298 +
102299 +struct size_overflow_hash {
102300 + const struct size_overflow_hash * const next;
102301 + const char * const name;
102302 + const unsigned int param;
102303 +};
102304 +
102305 +#include "size_overflow_hash.h"
102306 +
102307 +enum mark {
102308 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
102309 +};
102310 +
102311 +enum err_code_conditions {
102312 + CAST_ONLY, FROM_CONST
102313 +};
102314 +
102315 +static unsigned int call_count = 0;
102316 +
102317 +#define __unused __attribute__((__unused__))
102318 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102319 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
102320 +#define BEFORE_STMT true
102321 +#define AFTER_STMT false
102322 +#define CREATE_NEW_VAR NULL_TREE
102323 +#define CODES_LIMIT 32
102324 +#define MAX_PARAM 31
102325 +#define MY_STMT GF_PLF_1
102326 +#define NO_CAST_CHECK GF_PLF_2
102327 +#define FROM_ARG true
102328 +#define FROM_RET false
102329 +
102330 +#if BUILDING_GCC_VERSION == 4005
102331 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
102332 +#endif
102333 +
102334 +int plugin_is_GPL_compatible;
102335 +void debug_gimple_stmt(gimple gs);
102336 +
102337 +static tree expand(struct pointer_set_t *visited, tree lhs);
102338 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
102339 +static tree report_size_overflow_decl;
102340 +static const_tree const_char_ptr_type_node;
102341 +static unsigned int handle_function(void);
102342 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
102343 +static tree get_size_overflow_type(gimple stmt, const_tree node);
102344 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
102345 +static void print_missing_msg(tree func, unsigned int argnum);
102346 +
102347 +static struct plugin_info size_overflow_plugin_info = {
102348 + .version = "20130410beta",
102349 + .help = "no-size-overflow\tturn off size overflow checking\n",
102350 +};
102351 +
102352 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102353 +{
102354 + unsigned int arg_count;
102355 + enum tree_code code = TREE_CODE(*node);
102356 +
102357 + switch (code) {
102358 + case FUNCTION_DECL:
102359 + arg_count = type_num_arguments(TREE_TYPE(*node));
102360 + break;
102361 + case FUNCTION_TYPE:
102362 + case METHOD_TYPE:
102363 + arg_count = type_num_arguments(*node);
102364 + break;
102365 + default:
102366 + *no_add_attrs = true;
102367 + error("%s: %qE attribute only applies to functions", __func__, name);
102368 + return NULL_TREE;
102369 + }
102370 +
102371 + for (; args; args = TREE_CHAIN(args)) {
102372 + tree position = TREE_VALUE(args);
102373 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102374 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102375 + *no_add_attrs = true;
102376 + }
102377 + }
102378 + return NULL_TREE;
102379 +}
102380 +
102381 +static const char* get_asm_name(tree node)
102382 +{
102383 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
102384 +}
102385 +
102386 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102387 +{
102388 + unsigned int arg_count, arg_num;
102389 + enum tree_code code = TREE_CODE(*node);
102390 +
102391 + switch (code) {
102392 + case FUNCTION_DECL:
102393 + arg_count = type_num_arguments(TREE_TYPE(*node));
102394 + break;
102395 + case FUNCTION_TYPE:
102396 + case METHOD_TYPE:
102397 + arg_count = type_num_arguments(*node);
102398 + break;
102399 + case FIELD_DECL:
102400 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102401 + if (arg_num != 0) {
102402 + *no_add_attrs = true;
102403 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102404 + }
102405 + return NULL_TREE;
102406 + default:
102407 + *no_add_attrs = true;
102408 + error("%qE attribute only applies to functions", name);
102409 + return NULL_TREE;
102410 + }
102411 +
102412 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102413 + return NULL_TREE;
102414 +
102415 + for (; args; args = TREE_CHAIN(args)) {
102416 + tree position = TREE_VALUE(args);
102417 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102418 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102419 + *no_add_attrs = true;
102420 + }
102421 + }
102422 + return NULL_TREE;
102423 +}
102424 +
102425 +static struct attribute_spec size_overflow_attr = {
102426 + .name = "size_overflow",
102427 + .min_length = 1,
102428 + .max_length = -1,
102429 + .decl_required = true,
102430 + .type_required = false,
102431 + .function_type_required = false,
102432 + .handler = handle_size_overflow_attribute,
102433 +#if BUILDING_GCC_VERSION >= 4007
102434 + .affects_type_identity = false
102435 +#endif
102436 +};
102437 +
102438 +static struct attribute_spec intentional_overflow_attr = {
102439 + .name = "intentional_overflow",
102440 + .min_length = 1,
102441 + .max_length = -1,
102442 + .decl_required = true,
102443 + .type_required = false,
102444 + .function_type_required = false,
102445 + .handler = handle_intentional_overflow_attribute,
102446 +#if BUILDING_GCC_VERSION >= 4007
102447 + .affects_type_identity = false
102448 +#endif
102449 +};
102450 +
102451 +static void register_attributes(void __unused *event_data, void __unused *data)
102452 +{
102453 + register_attribute(&size_overflow_attr);
102454 + register_attribute(&intentional_overflow_attr);
102455 +}
102456 +
102457 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102458 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102459 +{
102460 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102461 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102462 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102463 +
102464 + unsigned int m = 0x57559429;
102465 + unsigned int n = 0x5052acdb;
102466 + const unsigned int *key4 = (const unsigned int *)key;
102467 + unsigned int h = len;
102468 + unsigned int k = len + seed + n;
102469 + unsigned long long p;
102470 +
102471 + while (len >= 8) {
102472 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102473 + len -= 8;
102474 + }
102475 + if (len >= 4) {
102476 + cwmixb(key4[0]) key4 += 1;
102477 + len -= 4;
102478 + }
102479 + if (len)
102480 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102481 + cwmixb(h ^ (k + n));
102482 + return k ^ h;
102483 +
102484 +#undef cwfold
102485 +#undef cwmixa
102486 +#undef cwmixb
102487 +}
102488 +
102489 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102490 +{
102491 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102492 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102493 + return fn ^ codes;
102494 +}
102495 +
102496 +static inline tree get_original_function_decl(tree fndecl)
102497 +{
102498 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102499 + return DECL_ABSTRACT_ORIGIN(fndecl);
102500 + return fndecl;
102501 +}
102502 +
102503 +static inline gimple get_def_stmt(const_tree node)
102504 +{
102505 + gcc_assert(node != NULL_TREE);
102506 + if (TREE_CODE(node) != SSA_NAME)
102507 + return NULL;
102508 + return SSA_NAME_DEF_STMT(node);
102509 +}
102510 +
102511 +static unsigned char get_tree_code(const_tree type)
102512 +{
102513 + switch (TREE_CODE(type)) {
102514 + case ARRAY_TYPE:
102515 + return 0;
102516 + case BOOLEAN_TYPE:
102517 + return 1;
102518 + case ENUMERAL_TYPE:
102519 + return 2;
102520 + case FUNCTION_TYPE:
102521 + return 3;
102522 + case INTEGER_TYPE:
102523 + return 4;
102524 + case POINTER_TYPE:
102525 + return 5;
102526 + case RECORD_TYPE:
102527 + return 6;
102528 + case UNION_TYPE:
102529 + return 7;
102530 + case VOID_TYPE:
102531 + return 8;
102532 + case REAL_TYPE:
102533 + return 9;
102534 + case VECTOR_TYPE:
102535 + return 10;
102536 + case REFERENCE_TYPE:
102537 + return 11;
102538 + case OFFSET_TYPE:
102539 + return 12;
102540 + case COMPLEX_TYPE:
102541 + return 13;
102542 + default:
102543 + debug_tree((tree)type);
102544 + gcc_unreachable();
102545 + }
102546 +}
102547 +
102548 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102549 +{
102550 + gcc_assert(type != NULL_TREE);
102551 +
102552 + while (type && len < CODES_LIMIT) {
102553 + tree_codes[len] = get_tree_code(type);
102554 + len++;
102555 + type = TREE_TYPE(type);
102556 + }
102557 + return len;
102558 +}
102559 +
102560 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102561 +{
102562 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102563 + enum tree_code code = TREE_CODE(type);
102564 + size_t len = 0;
102565 +
102566 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102567 +
102568 + arg = TYPE_ARG_TYPES(type);
102569 + // skip builtins __builtin_constant_p
102570 + if (!arg && DECL_BUILT_IN(fndecl))
102571 + return 0;
102572 +
102573 + if (TREE_CODE_CLASS(code) == tcc_type)
102574 + result = type;
102575 + else
102576 + result = DECL_RESULT(fndecl);
102577 +
102578 + gcc_assert(result != NULL_TREE);
102579 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102580 +
102581 + if (arg == NULL_TREE) {
102582 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102583 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102584 + if (arg_field == NULL_TREE)
102585 + return 0;
102586 + arg = TREE_TYPE(arg_field);
102587 + len = add_type_codes(arg, tree_codes, len);
102588 + gcc_assert(len != 0);
102589 + return len;
102590 + }
102591 +
102592 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102593 + while (arg && len < CODES_LIMIT) {
102594 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102595 + arg = TREE_CHAIN(arg);
102596 + }
102597 +
102598 + gcc_assert(len != 0);
102599 + return len;
102600 +}
102601 +
102602 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102603 +{
102604 + unsigned int hash;
102605 + const struct size_overflow_hash *entry;
102606 + unsigned char tree_codes[CODES_LIMIT];
102607 + size_t len;
102608 + const char *func_name;
102609 +
102610 + fndecl = get_original_function_decl(fndecl);
102611 + len = get_function_decl(fndecl, tree_codes);
102612 + if (len == 0)
102613 + return NULL;
102614 +
102615 + func_name = get_asm_name(fndecl);
102616 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102617 +
102618 + entry = size_overflow_hash[hash];
102619 + while (entry) {
102620 + if (!strcmp(entry->name, func_name))
102621 + return entry;
102622 + entry = entry->next;
102623 + }
102624 +
102625 + return NULL;
102626 +}
102627 +
102628 +static bool is_bool(const_tree node)
102629 +{
102630 + const_tree type;
102631 +
102632 + if (node == NULL_TREE)
102633 + return false;
102634 +
102635 + type = TREE_TYPE(node);
102636 + if (!INTEGRAL_TYPE_P(type))
102637 + return false;
102638 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102639 + return true;
102640 + if (TYPE_PRECISION(type) == 1)
102641 + return true;
102642 + return false;
102643 +}
102644 +
102645 +static bool skip_types(const_tree var)
102646 +{
102647 + tree type;
102648 +
102649 + if (is_gimple_constant(var))
102650 + return true;
102651 +
102652 + switch (TREE_CODE(var)) {
102653 + case ADDR_EXPR:
102654 +#if BUILDING_GCC_VERSION >= 4006
102655 + case MEM_REF:
102656 +#endif
102657 + case ARRAY_REF:
102658 + case BIT_FIELD_REF:
102659 + case INDIRECT_REF:
102660 + case TARGET_MEM_REF:
102661 + return true;
102662 + case PARM_DECL:
102663 + case VAR_DECL:
102664 + case COMPONENT_REF:
102665 + return false;
102666 + default:
102667 + break;
102668 + }
102669 +
102670 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102671 +
102672 + type = TREE_TYPE(var);
102673 + switch (TREE_CODE(type)) {
102674 + case INTEGER_TYPE:
102675 + case ENUMERAL_TYPE:
102676 + return false;
102677 + case BOOLEAN_TYPE:
102678 + return is_bool(var);
102679 + default:
102680 + break;
102681 + }
102682 +
102683 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102684 +
102685 + type = TREE_TYPE(type);
102686 + gcc_assert(type != NULL_TREE);
102687 + switch (TREE_CODE(type)) {
102688 + case RECORD_TYPE:
102689 + case POINTER_TYPE:
102690 + case ARRAY_TYPE:
102691 + return true;
102692 + case VOID_TYPE:
102693 + case INTEGER_TYPE:
102694 + case UNION_TYPE:
102695 + return false;
102696 + default:
102697 + break;
102698 + }
102699 +
102700 + debug_tree((tree)var);
102701 + gcc_unreachable();
102702 +}
102703 +
102704 +static unsigned int find_arg_number(const_tree arg, tree func)
102705 +{
102706 + tree var;
102707 + unsigned int argnum = 1;
102708 +
102709 + if (TREE_CODE(arg) == SSA_NAME)
102710 + arg = SSA_NAME_VAR(arg);
102711 +
102712 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102713 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102714 + continue;
102715 + if (!skip_types(var))
102716 + return argnum;
102717 + }
102718 +
102719 + return 0;
102720 +}
102721 +
102722 +static tree create_new_var(tree type)
102723 +{
102724 + tree new_var = create_tmp_var(type, "cicus");
102725 +
102726 +#if BUILDING_GCC_VERSION <= 4007
102727 + add_referenced_var(new_var);
102728 + mark_sym_for_renaming(new_var);
102729 +#endif
102730 + return new_var;
102731 +}
102732 +
102733 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102734 +{
102735 + gimple assign;
102736 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102737 + tree type = TREE_TYPE(rhs1);
102738 + tree lhs = create_new_var(type);
102739 +
102740 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102741 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102742 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102743 +
102744 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102745 + update_stmt(assign);
102746 + gimple_set_plf(assign, MY_STMT, true);
102747 + return assign;
102748 +}
102749 +
102750 +static tree cast_a_tree(tree type, tree var)
102751 +{
102752 + gcc_assert(type != NULL_TREE);
102753 + gcc_assert(var != NULL_TREE);
102754 + gcc_assert(fold_convertible_p(type, var));
102755 +
102756 + return fold_convert(type, var);
102757 +}
102758 +
102759 +static tree get_lhs(const_gimple stmt)
102760 +{
102761 + switch (gimple_code(stmt)) {
102762 + case GIMPLE_ASSIGN:
102763 + return gimple_get_lhs(stmt);
102764 + case GIMPLE_PHI:
102765 + return gimple_phi_result(stmt);
102766 + case GIMPLE_CALL:
102767 + return gimple_call_lhs(stmt);
102768 + default:
102769 + return NULL_TREE;
102770 + }
102771 +}
102772 +
102773 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102774 +{
102775 + const_gimple def_stmt = get_def_stmt(rhs);
102776 +
102777 + if (force)
102778 + return false;
102779 +
102780 + if (is_gimple_constant(rhs))
102781 + return false;
102782 +
102783 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102784 + return false;
102785 +
102786 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102787 + return false;
102788 +
102789 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102790 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102791 + return false;
102792 +
102793 + return true;
102794 +}
102795 +
102796 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102797 +{
102798 + gimple assign, def_stmt;
102799 +
102800 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102801 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102802 + gcc_unreachable();
102803 +
102804 + def_stmt = get_def_stmt(rhs);
102805 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102806 + return def_stmt;
102807 +
102808 + if (lhs == CREATE_NEW_VAR)
102809 + lhs = create_new_var(dst_type);
102810 +
102811 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102812 +
102813 + if (!gsi_end_p(*gsi)) {
102814 + location_t loc = gimple_location(gsi_stmt(*gsi));
102815 + gimple_set_location(assign, loc);
102816 + }
102817 +
102818 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102819 +
102820 + if (before)
102821 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102822 + else
102823 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102824 + update_stmt(assign);
102825 + gimple_set_plf(assign, MY_STMT, true);
102826 +
102827 + return assign;
102828 +}
102829 +
102830 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102831 +{
102832 + gimple_stmt_iterator gsi;
102833 + tree lhs;
102834 + const_gimple new_stmt;
102835 +
102836 + if (rhs == NULL_TREE)
102837 + return NULL_TREE;
102838 +
102839 + gsi = gsi_for_stmt(stmt);
102840 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102841 +
102842 + lhs = get_lhs(new_stmt);
102843 + gcc_assert(lhs != NULL_TREE);
102844 + return lhs;
102845 +}
102846 +
102847 +static tree cast_to_TI_type(gimple stmt, tree node)
102848 +{
102849 + gimple_stmt_iterator gsi;
102850 + gimple cast_stmt;
102851 + tree type = TREE_TYPE(node);
102852 +
102853 + if (types_compatible_p(type, intTI_type_node))
102854 + return node;
102855 +
102856 + gsi = gsi_for_stmt(stmt);
102857 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102858 + return gimple_get_lhs(cast_stmt);
102859 +}
102860 +
102861 +static void check_function_hash(const_gimple stmt)
102862 +{
102863 + tree func;
102864 + const struct size_overflow_hash *hash;
102865 +
102866 + if (gimple_code(stmt) != GIMPLE_CALL)
102867 + return;
102868 +
102869 + func = gimple_call_fndecl(stmt);
102870 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102871 + if (func == NULL_TREE)
102872 + return;
102873 +
102874 + hash = get_function_hash(func);
102875 + if (!hash)
102876 + print_missing_msg(func, 0);
102877 +}
102878 +
102879 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102880 +{
102881 + tree lhs, new_lhs;
102882 + gimple_stmt_iterator gsi;
102883 +
102884 + if (rhs1 == NULL_TREE) {
102885 + debug_gimple_stmt(oldstmt);
102886 + error("%s: rhs1 is NULL_TREE", __func__);
102887 + gcc_unreachable();
102888 + }
102889 +
102890 + switch (gimple_code(oldstmt)) {
102891 + case GIMPLE_ASM:
102892 + lhs = rhs1;
102893 + break;
102894 + case GIMPLE_CALL:
102895 + lhs = gimple_call_lhs(oldstmt);
102896 + break;
102897 + case GIMPLE_ASSIGN:
102898 + lhs = gimple_get_lhs(oldstmt);
102899 + break;
102900 + default:
102901 + debug_gimple_stmt(oldstmt);
102902 + gcc_unreachable();
102903 + }
102904 +
102905 + gsi = gsi_for_stmt(oldstmt);
102906 + pointer_set_insert(visited, oldstmt);
102907 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102908 + basic_block next_bb, cur_bb;
102909 + const_edge e;
102910 +
102911 + gcc_assert(before == false);
102912 + gcc_assert(stmt_can_throw_internal(oldstmt));
102913 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102914 + gcc_assert(!gsi_end_p(gsi));
102915 +
102916 + cur_bb = gimple_bb(oldstmt);
102917 + next_bb = cur_bb->next_bb;
102918 + e = find_edge(cur_bb, next_bb);
102919 + gcc_assert(e != NULL);
102920 + gcc_assert(e->flags & EDGE_FALLTHRU);
102921 +
102922 + gsi = gsi_after_labels(next_bb);
102923 + gcc_assert(!gsi_end_p(gsi));
102924 +
102925 + before = true;
102926 + oldstmt = gsi_stmt(gsi);
102927 + }
102928 +
102929 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102930 + return new_lhs;
102931 +}
102932 +
102933 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102934 +{
102935 + gimple stmt;
102936 + gimple_stmt_iterator gsi;
102937 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102938 +
102939 + if (gimple_plf(oldstmt, MY_STMT))
102940 + return lhs;
102941 +
102942 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102943 + rhs1 = gimple_assign_rhs1(oldstmt);
102944 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102945 + }
102946 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102947 + rhs2 = gimple_assign_rhs2(oldstmt);
102948 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102949 + }
102950 +
102951 + stmt = gimple_copy(oldstmt);
102952 + gimple_set_location(stmt, gimple_location(oldstmt));
102953 + gimple_set_plf(stmt, MY_STMT, true);
102954 +
102955 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102956 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102957 +
102958 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102959 +
102960 + new_var = create_new_var(size_overflow_type);
102961 + new_var = make_ssa_name(new_var, stmt);
102962 + gimple_set_lhs(stmt, new_var);
102963 +
102964 + if (rhs1 != NULL_TREE)
102965 + gimple_assign_set_rhs1(stmt, rhs1);
102966 +
102967 + if (rhs2 != NULL_TREE)
102968 + gimple_assign_set_rhs2(stmt, rhs2);
102969 +#if BUILDING_GCC_VERSION >= 4007
102970 + if (rhs3 != NULL_TREE)
102971 + gimple_assign_set_rhs3(stmt, rhs3);
102972 +#endif
102973 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102974 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102975 +
102976 + gsi = gsi_for_stmt(oldstmt);
102977 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102978 + update_stmt(stmt);
102979 + pointer_set_insert(visited, oldstmt);
102980 + return gimple_get_lhs(stmt);
102981 +}
102982 +
102983 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102984 +{
102985 + basic_block first_bb;
102986 + gimple assign;
102987 + gimple_stmt_iterator gsi;
102988 +
102989 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102990 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102991 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102992 +
102993 + gsi = gsi_start_bb(first_bb);
102994 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102995 + return gimple_get_lhs(assign);
102996 +}
102997 +
102998 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102999 +{
103000 + gimple_stmt_iterator gsi;
103001 + const_gimple assign;
103002 + gimple def_stmt = get_def_stmt(new_arg);
103003 +
103004 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
103005 + gsi = gsi_after_labels(gimple_bb(def_stmt));
103006 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
103007 + } else {
103008 + gsi = gsi_for_stmt(def_stmt);
103009 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
103010 + }
103011 +
103012 + return gimple_get_lhs(assign);
103013 +}
103014 +
103015 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
103016 +{
103017 + basic_block bb;
103018 + gimple_stmt_iterator gsi;
103019 + const_gimple assign, def_stmt;
103020 +
103021 + def_stmt = get_def_stmt(arg);
103022 + bb = gimple_bb(def_stmt);
103023 + gcc_assert(bb->index != 0);
103024 + gsi = gsi_after_labels(bb);
103025 +
103026 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
103027 + return gimple_get_lhs(assign);
103028 +}
103029 +
103030 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
103031 +{
103032 + tree size_overflow_type;
103033 + const_gimple def_stmt = get_def_stmt(arg);
103034 +
103035 + if (phi_ssa_name != NULL_TREE)
103036 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
103037 +
103038 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
103039 +
103040 + if (new_arg != NULL_TREE) {
103041 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
103042 + return use_phi_ssa_name(phi_ssa_name, new_arg);
103043 + }
103044 +
103045 + switch(gimple_code(def_stmt)) {
103046 + case GIMPLE_PHI:
103047 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
103048 + case GIMPLE_NOP:
103049 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
103050 + default:
103051 + debug_gimple_stmt((gimple)def_stmt);
103052 + gcc_unreachable();
103053 + }
103054 +}
103055 +
103056 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
103057 +{
103058 + basic_block bb;
103059 + gimple phi;
103060 + gimple_seq seq;
103061 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
103062 +
103063 + bb = gsi_bb(gsi);
103064 +
103065 + phi = create_phi_node(result, bb);
103066 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
103067 + seq = phi_nodes(bb);
103068 + gsi = gsi_last(seq);
103069 + gsi_remove(&gsi, false);
103070 +
103071 + gsi = gsi_for_stmt(oldstmt);
103072 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
103073 + gimple_set_bb(phi, bb);
103074 + gimple_set_plf(phi, MY_STMT, true);
103075 + return phi;
103076 +}
103077 +
103078 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
103079 +{
103080 + gimple new_phi = NULL;
103081 + gimple oldstmt = get_def_stmt(orig_result);
103082 + tree phi_ssa_name = NULL_TREE;
103083 + unsigned int i;
103084 +
103085 + pointer_set_insert(visited, oldstmt);
103086 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
103087 + tree arg, new_arg;
103088 +
103089 + arg = gimple_phi_arg_def(oldstmt, i);
103090 +
103091 + new_arg = expand(visited, arg);
103092 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
103093 + if (i == 0) {
103094 + phi_ssa_name = new_arg;
103095 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
103096 + }
103097 +
103098 + gcc_assert(new_phi != NULL);
103099 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
103100 + }
103101 +
103102 + gcc_assert(new_phi != NULL);
103103 + update_stmt(new_phi);
103104 + return gimple_phi_result(new_phi);
103105 +}
103106 +
103107 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
103108 +{
103109 + const_gimple assign;
103110 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103111 + tree origtype = TREE_TYPE(orig_rhs);
103112 +
103113 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
103114 +
103115 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103116 + return gimple_get_lhs(assign);
103117 +}
103118 +
103119 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
103120 +{
103121 + const_tree rhs1, lhs, rhs1_type, lhs_type;
103122 + enum machine_mode lhs_mode, rhs_mode;
103123 + gimple def_stmt = get_def_stmt(no_const_rhs);
103124 +
103125 + if (!gimple_assign_cast_p(def_stmt))
103126 + return false;
103127 +
103128 + rhs1 = gimple_assign_rhs1(def_stmt);
103129 + lhs = gimple_get_lhs(def_stmt);
103130 + rhs1_type = TREE_TYPE(rhs1);
103131 + lhs_type = TREE_TYPE(lhs);
103132 + rhs_mode = TYPE_MODE(rhs1_type);
103133 + lhs_mode = TYPE_MODE(lhs_type);
103134 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
103135 + return false;
103136 +
103137 + return true;
103138 +}
103139 +
103140 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
103141 +{
103142 + tree rhs1 = gimple_assign_rhs1(stmt);
103143 + tree lhs = gimple_get_lhs(stmt);
103144 + const_tree rhs1_type = TREE_TYPE(rhs1);
103145 + const_tree lhs_type = TREE_TYPE(lhs);
103146 +
103147 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
103148 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103149 +
103150 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
103151 +}
103152 +
103153 +static bool no_uses(tree node)
103154 +{
103155 + imm_use_iterator imm_iter;
103156 + use_operand_p use_p;
103157 +
103158 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
103159 + const_gimple use_stmt = USE_STMT(use_p);
103160 + if (use_stmt == NULL)
103161 + return true;
103162 + if (is_gimple_debug(use_stmt))
103163 + continue;
103164 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
103165 + continue;
103166 + return false;
103167 + }
103168 + return true;
103169 +}
103170 +
103171 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
103172 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
103173 +{
103174 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
103175 + gimple def_stmt = get_def_stmt(lhs);
103176 +
103177 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103178 + return false;
103179 +
103180 + rhs1 = gimple_assign_rhs1(def_stmt);
103181 + rhs_type = TREE_TYPE(rhs1);
103182 + lhs_type = TREE_TYPE(lhs);
103183 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
103184 + return false;
103185 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
103186 + return false;
103187 +
103188 + def_stmt = get_def_stmt(rhs1);
103189 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
103190 + return false;
103191 +
103192 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
103193 + return false;
103194 +
103195 + rhs1 = gimple_assign_rhs1(def_stmt);
103196 + rhs2 = gimple_assign_rhs2(def_stmt);
103197 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
103198 + return false;
103199 +
103200 + if (is_gimple_constant(rhs2))
103201 + not_const_rhs = rhs1;
103202 + else
103203 + not_const_rhs = rhs2;
103204 +
103205 + return no_uses(not_const_rhs);
103206 +}
103207 +
103208 +static bool skip_lhs_cast_check(const_gimple stmt)
103209 +{
103210 + const_tree rhs = gimple_assign_rhs1(stmt);
103211 + const_gimple def_stmt = get_def_stmt(rhs);
103212 +
103213 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
103214 + if (gimple_code(def_stmt) == GIMPLE_ASM)
103215 + return true;
103216 +
103217 + if (is_const_plus_unsigned_signed_truncation(rhs))
103218 + return true;
103219 +
103220 + return false;
103221 +}
103222 +
103223 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
103224 +{
103225 + bool cast_lhs, cast_rhs;
103226 + tree lhs = gimple_get_lhs(stmt);
103227 + tree rhs = gimple_assign_rhs1(stmt);
103228 + const_tree lhs_type = TREE_TYPE(lhs);
103229 + const_tree rhs_type = TREE_TYPE(rhs);
103230 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
103231 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
103232 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
103233 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
103234 +
103235 + static bool check_lhs[3][4] = {
103236 + // ss su us uu
103237 + { false, true, true, false }, // lhs > rhs
103238 + { false, false, false, false }, // lhs = rhs
103239 + { true, true, true, true }, // lhs < rhs
103240 + };
103241 +
103242 + static bool check_rhs[3][4] = {
103243 + // ss su us uu
103244 + { true, false, true, true }, // lhs > rhs
103245 + { true, false, true, true }, // lhs = rhs
103246 + { true, false, true, true }, // lhs < rhs
103247 + };
103248 +
103249 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
103250 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
103251 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103252 +
103253 + if (lhs_size > rhs_size) {
103254 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103255 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103256 + } else if (lhs_size == rhs_size) {
103257 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103258 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103259 + } else {
103260 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103261 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103262 + }
103263 +
103264 + if (!cast_lhs && !cast_rhs)
103265 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103266 +
103267 + if (cast_lhs && !skip_lhs_cast_check(stmt))
103268 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
103269 +
103270 + if (cast_rhs)
103271 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
103272 +
103273 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103274 +}
103275 +
103276 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
103277 +{
103278 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
103279 +
103280 + if (gimple_plf(stmt, MY_STMT))
103281 + return lhs;
103282 +
103283 + rhs1 = gimple_assign_rhs1(stmt);
103284 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
103285 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103286 +
103287 + new_rhs1 = expand(visited, rhs1);
103288 +
103289 + if (new_rhs1 == NULL_TREE)
103290 + return create_cast_assign(visited, stmt);
103291 +
103292 + if (gimple_plf(stmt, NO_CAST_CHECK))
103293 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103294 +
103295 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
103296 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
103297 +
103298 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
103299 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
103300 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103301 + }
103302 +
103303 + if (!gimple_assign_cast_p(stmt))
103304 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103305 +
103306 + return create_cast_overflow_check(visited, new_rhs1, stmt);
103307 +}
103308 +
103309 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
103310 +{
103311 + tree rhs1, lhs = gimple_get_lhs(stmt);
103312 + gimple def_stmt = get_def_stmt(lhs);
103313 +
103314 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
103315 + rhs1 = gimple_assign_rhs1(def_stmt);
103316 +
103317 + if (is_gimple_constant(rhs1))
103318 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103319 +
103320 + switch (TREE_CODE(rhs1)) {
103321 + case SSA_NAME:
103322 + return handle_unary_rhs(visited, def_stmt);
103323 + case ARRAY_REF:
103324 + case BIT_FIELD_REF:
103325 + case ADDR_EXPR:
103326 + case COMPONENT_REF:
103327 + case INDIRECT_REF:
103328 +#if BUILDING_GCC_VERSION >= 4006
103329 + case MEM_REF:
103330 +#endif
103331 + case TARGET_MEM_REF:
103332 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103333 + case PARM_DECL:
103334 + case VAR_DECL:
103335 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103336 +
103337 + default:
103338 + debug_gimple_stmt(def_stmt);
103339 + debug_tree(rhs1);
103340 + gcc_unreachable();
103341 + }
103342 +}
103343 +
103344 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
103345 +{
103346 + gimple cond_stmt;
103347 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
103348 +
103349 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
103350 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
103351 + update_stmt(cond_stmt);
103352 +}
103353 +
103354 +static tree create_string_param(tree string)
103355 +{
103356 + tree i_type, a_type;
103357 + const int length = TREE_STRING_LENGTH(string);
103358 +
103359 + gcc_assert(length > 0);
103360 +
103361 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
103362 + a_type = build_array_type(char_type_node, i_type);
103363 +
103364 + TREE_TYPE(string) = a_type;
103365 + TREE_CONSTANT(string) = 1;
103366 + TREE_READONLY(string) = 1;
103367 +
103368 + return build1(ADDR_EXPR, ptr_type_node, string);
103369 +}
103370 +
103371 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
103372 +{
103373 + gimple func_stmt;
103374 + const_gimple def_stmt;
103375 + const_tree loc_line;
103376 + tree loc_file, ssa_name, current_func;
103377 + expanded_location xloc;
103378 + char *ssa_name_buf;
103379 + int len;
103380 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
103381 +
103382 + def_stmt = get_def_stmt(arg);
103383 + xloc = expand_location(gimple_location(def_stmt));
103384 +
103385 + if (!gimple_has_location(def_stmt)) {
103386 + xloc = expand_location(gimple_location(stmt));
103387 + if (!gimple_has_location(stmt))
103388 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103389 + }
103390 +
103391 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103392 +
103393 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103394 + loc_file = create_string_param(loc_file);
103395 +
103396 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103397 + current_func = create_string_param(current_func);
103398 +
103399 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103400 + call_count++;
103401 + 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);
103402 + gcc_assert(len > 0);
103403 + ssa_name = build_string(len + 1, ssa_name_buf);
103404 + free(ssa_name_buf);
103405 + ssa_name = create_string_param(ssa_name);
103406 +
103407 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103408 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103409 +
103410 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103411 +}
103412 +
103413 +static void __unused print_the_code_insertions(const_gimple stmt)
103414 +{
103415 + location_t loc = gimple_location(stmt);
103416 +
103417 + inform(loc, "Integer size_overflow check applied here.");
103418 +}
103419 +
103420 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103421 +{
103422 + basic_block cond_bb, join_bb, bb_true;
103423 + edge e;
103424 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103425 +
103426 + cond_bb = gimple_bb(stmt);
103427 + if (before)
103428 + gsi_prev(&gsi);
103429 + if (gsi_end_p(gsi))
103430 + e = split_block_after_labels(cond_bb);
103431 + else
103432 + e = split_block(cond_bb, gsi_stmt(gsi));
103433 + cond_bb = e->src;
103434 + join_bb = e->dest;
103435 + e->flags = EDGE_FALSE_VALUE;
103436 + e->probability = REG_BR_PROB_BASE;
103437 +
103438 + bb_true = create_empty_bb(cond_bb);
103439 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103440 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103441 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103442 +
103443 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103444 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103445 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103446 +
103447 + if (current_loops != NULL) {
103448 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103449 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103450 + }
103451 +
103452 + insert_cond(cond_bb, arg, cond_code, type_value);
103453 + insert_cond_result(bb_true, stmt, arg, min);
103454 +
103455 +// print_the_code_insertions(stmt);
103456 +}
103457 +
103458 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103459 +{
103460 + const_tree rhs_type = TREE_TYPE(rhs);
103461 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103462 +
103463 + gcc_assert(rhs_type != NULL_TREE);
103464 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103465 + return;
103466 +
103467 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103468 +
103469 + if (is_const_plus_unsigned_signed_truncation(rhs))
103470 + return;
103471 +
103472 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103473 + // typemax (-1) < typemin (0)
103474 + if (TREE_OVERFLOW(type_max))
103475 + return;
103476 +
103477 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103478 +
103479 + cast_rhs_type = TREE_TYPE(cast_rhs);
103480 + type_max_type = TREE_TYPE(type_max);
103481 + type_min_type = TREE_TYPE(type_min);
103482 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103483 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103484 +
103485 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103486 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103487 +}
103488 +
103489 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103490 +{
103491 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103492 + return false;
103493 + if (!is_gimple_constant(rhs))
103494 + return false;
103495 + return true;
103496 +}
103497 +
103498 +static tree get_def_stmt_rhs(const_tree var)
103499 +{
103500 + tree rhs1, def_stmt_rhs1;
103501 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103502 +
103503 + def_stmt = get_def_stmt(var);
103504 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103505 +
103506 + rhs1 = gimple_assign_rhs1(def_stmt);
103507 + rhs1_def_stmt = get_def_stmt(rhs1);
103508 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103509 + return rhs1;
103510 +
103511 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103512 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103513 +
103514 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103515 + case GIMPLE_CALL:
103516 + case GIMPLE_NOP:
103517 + case GIMPLE_ASM:
103518 + case GIMPLE_PHI:
103519 + return def_stmt_rhs1;
103520 + case GIMPLE_ASSIGN:
103521 + return rhs1;
103522 + default:
103523 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103524 + gcc_unreachable();
103525 + }
103526 +}
103527 +
103528 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103529 +{
103530 + tree new_rhs, orig_rhs;
103531 + void (*gimple_assign_set_rhs)(gimple, tree);
103532 + tree rhs1 = gimple_assign_rhs1(stmt);
103533 + tree rhs2 = gimple_assign_rhs2(stmt);
103534 + tree lhs = gimple_get_lhs(stmt);
103535 +
103536 + if (!check_overflow)
103537 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103538 +
103539 + if (change_rhs == NULL_TREE)
103540 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103541 +
103542 + if (new_rhs2 == NULL_TREE) {
103543 + orig_rhs = rhs1;
103544 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103545 + } else {
103546 + orig_rhs = rhs2;
103547 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103548 + }
103549 +
103550 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103551 +
103552 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103553 + gimple_assign_set_rhs(stmt, new_rhs);
103554 + update_stmt(stmt);
103555 +
103556 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103557 +}
103558 +
103559 +static bool is_subtraction_special(const_gimple stmt)
103560 +{
103561 + gimple rhs1_def_stmt, rhs2_def_stmt;
103562 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103563 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103564 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103565 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103566 +
103567 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103568 + return false;
103569 +
103570 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103571 +
103572 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103573 + return false;
103574 +
103575 + rhs1_def_stmt = get_def_stmt(rhs1);
103576 + rhs2_def_stmt = get_def_stmt(rhs2);
103577 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103578 + return false;
103579 +
103580 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103581 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103582 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103583 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103584 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103585 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103586 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103587 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103588 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103589 + return false;
103590 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103591 + return false;
103592 +
103593 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103594 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103595 + return true;
103596 +}
103597 +
103598 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103599 +{
103600 + tree new_rhs1, new_rhs2;
103601 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103602 + gimple assign, stmt = get_def_stmt(lhs);
103603 + tree rhs1 = gimple_assign_rhs1(stmt);
103604 + tree rhs2 = gimple_assign_rhs2(stmt);
103605 +
103606 + if (!is_subtraction_special(stmt))
103607 + return NULL_TREE;
103608 +
103609 + new_rhs1 = expand(visited, rhs1);
103610 + new_rhs2 = expand(visited, rhs2);
103611 +
103612 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103613 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103614 +
103615 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103616 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103617 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103618 + }
103619 +
103620 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103621 + new_lhs = gimple_get_lhs(assign);
103622 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103623 +
103624 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103625 +}
103626 +
103627 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103628 +{
103629 + const_gimple def_stmt;
103630 +
103631 + if (TREE_CODE(rhs) != SSA_NAME)
103632 + return false;
103633 +
103634 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103635 + return false;
103636 +
103637 + def_stmt = get_def_stmt(rhs);
103638 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103639 + return false;
103640 +
103641 + return true;
103642 +}
103643 +
103644 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103645 +{
103646 + tree rhs1, rhs2, new_lhs;
103647 + gimple def_stmt = get_def_stmt(lhs);
103648 + tree new_rhs1 = NULL_TREE;
103649 + tree new_rhs2 = NULL_TREE;
103650 +
103651 + rhs1 = gimple_assign_rhs1(def_stmt);
103652 + rhs2 = gimple_assign_rhs2(def_stmt);
103653 +
103654 + /* no DImode/TImode division in the 32/64 bit kernel */
103655 + switch (gimple_assign_rhs_code(def_stmt)) {
103656 + case RDIV_EXPR:
103657 + case TRUNC_DIV_EXPR:
103658 + case CEIL_DIV_EXPR:
103659 + case FLOOR_DIV_EXPR:
103660 + case ROUND_DIV_EXPR:
103661 + case TRUNC_MOD_EXPR:
103662 + case CEIL_MOD_EXPR:
103663 + case FLOOR_MOD_EXPR:
103664 + case ROUND_MOD_EXPR:
103665 + case EXACT_DIV_EXPR:
103666 + case POINTER_PLUS_EXPR:
103667 + case BIT_AND_EXPR:
103668 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103669 + default:
103670 + break;
103671 + }
103672 +
103673 + new_lhs = handle_integer_truncation(visited, lhs);
103674 + if (new_lhs != NULL_TREE)
103675 + return new_lhs;
103676 +
103677 + if (TREE_CODE(rhs1) == SSA_NAME)
103678 + new_rhs1 = expand(visited, rhs1);
103679 + if (TREE_CODE(rhs2) == SSA_NAME)
103680 + new_rhs2 = expand(visited, rhs2);
103681 +
103682 + if (is_a_neg_overflow(def_stmt, rhs2))
103683 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103684 + if (is_a_neg_overflow(def_stmt, rhs1))
103685 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103686 +
103687 +
103688 + if (is_a_constant_overflow(def_stmt, rhs2))
103689 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103690 + if (is_a_constant_overflow(def_stmt, rhs1))
103691 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103692 +
103693 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103694 +}
103695 +
103696 +#if BUILDING_GCC_VERSION >= 4007
103697 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103698 +{
103699 + if (is_gimple_constant(rhs))
103700 + return cast_a_tree(size_overflow_type, rhs);
103701 + if (TREE_CODE(rhs) != SSA_NAME)
103702 + return NULL_TREE;
103703 + return expand(visited, rhs);
103704 +}
103705 +
103706 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103707 +{
103708 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103709 + gimple def_stmt = get_def_stmt(lhs);
103710 +
103711 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103712 +
103713 + rhs1 = gimple_assign_rhs1(def_stmt);
103714 + rhs2 = gimple_assign_rhs2(def_stmt);
103715 + rhs3 = gimple_assign_rhs3(def_stmt);
103716 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103717 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103718 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103719 +
103720 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103721 +}
103722 +#endif
103723 +
103724 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103725 +{
103726 + const_tree type;
103727 + tree new_type;
103728 +
103729 + gcc_assert(node != NULL_TREE);
103730 +
103731 + type = TREE_TYPE(node);
103732 +
103733 + if (gimple_plf(stmt, MY_STMT))
103734 + return TREE_TYPE(node);
103735 +
103736 + switch (TYPE_MODE(type)) {
103737 + case QImode:
103738 + new_type = intHI_type_node;
103739 + break;
103740 + case HImode:
103741 + new_type = intSI_type_node;
103742 + break;
103743 + case SImode:
103744 + new_type = intDI_type_node;
103745 + break;
103746 + case DImode:
103747 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103748 + new_type = intDI_type_node;
103749 + else
103750 + new_type = intTI_type_node;
103751 + break;
103752 + default:
103753 + debug_tree((tree)node);
103754 + error("%s: unsupported gcc configuration.", __func__);
103755 + gcc_unreachable();
103756 + }
103757 +
103758 + if (TYPE_QUALS(type) != 0)
103759 + return build_qualified_type(new_type, TYPE_QUALS(type));
103760 + return new_type;
103761 +}
103762 +
103763 +static tree expand_visited(gimple def_stmt)
103764 +{
103765 + const_gimple next_stmt;
103766 + gimple_stmt_iterator gsi;
103767 + enum gimple_code code = gimple_code(def_stmt);
103768 +
103769 + if (code == GIMPLE_ASM)
103770 + return NULL_TREE;
103771 +
103772 + gsi = gsi_for_stmt(def_stmt);
103773 + gsi_next(&gsi);
103774 +
103775 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103776 + return NULL_TREE;
103777 + gcc_assert(!gsi_end_p(gsi));
103778 + next_stmt = gsi_stmt(gsi);
103779 +
103780 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103781 + return NULL_TREE;
103782 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103783 +
103784 + return get_lhs(next_stmt);
103785 +}
103786 +
103787 +static tree expand(struct pointer_set_t *visited, tree lhs)
103788 +{
103789 + gimple def_stmt;
103790 +
103791 + if (skip_types(lhs))
103792 + return NULL_TREE;
103793 +
103794 + def_stmt = get_def_stmt(lhs);
103795 +
103796 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103797 + return NULL_TREE;
103798 +
103799 + if (gimple_plf(def_stmt, MY_STMT))
103800 + return lhs;
103801 +
103802 + if (pointer_set_contains(visited, def_stmt))
103803 + return expand_visited(def_stmt);
103804 +
103805 + switch (gimple_code(def_stmt)) {
103806 + case GIMPLE_PHI:
103807 + return handle_phi(visited, lhs);
103808 + case GIMPLE_CALL:
103809 + case GIMPLE_ASM:
103810 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103811 + case GIMPLE_ASSIGN:
103812 + switch (gimple_num_ops(def_stmt)) {
103813 + case 2:
103814 + return handle_unary_ops(visited, def_stmt);
103815 + case 3:
103816 + return handle_binary_ops(visited, lhs);
103817 +#if BUILDING_GCC_VERSION >= 4007
103818 + case 4:
103819 + return handle_ternary_ops(visited, lhs);
103820 +#endif
103821 + }
103822 + default:
103823 + debug_gimple_stmt(def_stmt);
103824 + error("%s: unknown gimple code", __func__);
103825 + gcc_unreachable();
103826 + }
103827 +}
103828 +
103829 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103830 +{
103831 + const_gimple assign;
103832 + tree orig_type = TREE_TYPE(orig_node);
103833 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103834 +
103835 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103836 + return gimple_get_lhs(assign);
103837 +}
103838 +
103839 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103840 +{
103841 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103842 + update_stmt(stmt);
103843 +}
103844 +
103845 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103846 +{
103847 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103848 + update_stmt(stmt);
103849 +}
103850 +
103851 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103852 +{
103853 + tree arg;
103854 + const_tree origarg;
103855 +
103856 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103857 + return true;
103858 +
103859 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103860 + while (origarg && *argnum) {
103861 + (*argnum)--;
103862 + origarg = TREE_CHAIN(origarg);
103863 + }
103864 +
103865 + gcc_assert(*argnum == 0);
103866 +
103867 + gcc_assert(origarg != NULL_TREE);
103868 + *argnum = 0;
103869 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103870 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103871 + return true;
103872 + return false;
103873 +}
103874 +
103875 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103876 +{
103877 + gimple phi = get_def_stmt(result);
103878 + unsigned int i, n = gimple_phi_num_args(phi);
103879 +
103880 + if (!phi)
103881 + return MARK_NO;
103882 +
103883 + pointer_set_insert(visited, phi);
103884 + for (i = 0; i < n; i++) {
103885 + enum mark marked;
103886 + const_tree arg = gimple_phi_arg_def(phi, i);
103887 + marked = pre_expand(visited, search_err_code, arg);
103888 + if (marked != MARK_NO)
103889 + return marked;
103890 + }
103891 + return MARK_NO;
103892 +}
103893 +
103894 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103895 +{
103896 + gimple def_stmt = get_def_stmt(lhs);
103897 + const_tree rhs;
103898 +
103899 + if (!def_stmt)
103900 + return MARK_NO;
103901 +
103902 + rhs = gimple_assign_rhs1(def_stmt);
103903 +
103904 + def_stmt = get_def_stmt(rhs);
103905 + if (is_gimple_constant(rhs))
103906 + search_err_code[FROM_CONST] = true;
103907 +
103908 + return pre_expand(visited, search_err_code, rhs);
103909 +}
103910 +
103911 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103912 +{
103913 + gimple def_stmt = get_def_stmt(lhs);
103914 + const_tree rhs1, rhs2;
103915 + enum mark marked;
103916 +
103917 + if (!def_stmt)
103918 + return MARK_NO;
103919 +
103920 + search_err_code[CAST_ONLY] = false;
103921 +
103922 + rhs1 = gimple_assign_rhs1(def_stmt);
103923 + rhs2 = gimple_assign_rhs2(def_stmt);
103924 + marked = pre_expand(visited, search_err_code, rhs1);
103925 + if (marked != MARK_NO)
103926 + return marked;
103927 + return pre_expand(visited, search_err_code, rhs2);
103928 +}
103929 +
103930 +static const_tree search_field_decl(const_tree comp_ref)
103931 +{
103932 + const_tree field = NULL_TREE;
103933 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103934 +
103935 + for (i = 0; i < len; i++) {
103936 + field = TREE_OPERAND(comp_ref, i);
103937 + if (TREE_CODE(field) == FIELD_DECL)
103938 + break;
103939 + }
103940 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103941 + return field;
103942 +}
103943 +
103944 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103945 +{
103946 + const_tree attr, p;
103947 +
103948 + // 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);
103949 + if (fndecl == NULL_TREE)
103950 + return MARK_NO;
103951 +
103952 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103953 + if (!attr || !TREE_VALUE(attr))
103954 + return MARK_NO;
103955 +
103956 + p = TREE_VALUE(attr);
103957 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103958 + return MARK_TURN_OFF;
103959 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103960 + return MARK_NOT_INTENTIONAL;
103961 + if (argnum == 0) {
103962 + gcc_assert(current_function_decl == fndecl);
103963 + return MARK_NO;
103964 + }
103965 +
103966 + do {
103967 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103968 + return MARK_YES;
103969 + p = TREE_CHAIN(p);
103970 + } while (p);
103971 +
103972 + return MARK_NO;
103973 +}
103974 +
103975 +static void print_missing_msg(tree func, unsigned int argnum)
103976 +{
103977 + unsigned int new_hash;
103978 + size_t len;
103979 + unsigned char tree_codes[CODES_LIMIT];
103980 + location_t loc;
103981 + const char *curfunc;
103982 +
103983 + func = get_original_function_decl(func);
103984 + loc = DECL_SOURCE_LOCATION(func);
103985 + curfunc = get_asm_name(func);
103986 +
103987 + len = get_function_decl(func, tree_codes);
103988 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103989 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103990 +}
103991 +
103992 +static unsigned int search_missing_attribute(const_tree arg)
103993 +{
103994 + unsigned int argnum;
103995 + const struct size_overflow_hash *hash;
103996 + const_tree type = TREE_TYPE(arg);
103997 + tree func = get_original_function_decl(current_function_decl);
103998 +
103999 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
104000 +
104001 + if (TREE_CODE(type) == POINTER_TYPE)
104002 + return 0;
104003 +
104004 + argnum = find_arg_number(arg, func);
104005 + if (argnum == 0)
104006 + return 0;
104007 +
104008 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
104009 + return argnum;
104010 +
104011 + hash = get_function_hash(func);
104012 + if (!hash || !(hash->param & (1U << argnum))) {
104013 + print_missing_msg(func, argnum);
104014 + return 0;
104015 + }
104016 + return argnum;
104017 +}
104018 +
104019 +static enum mark is_already_marked(const_tree lhs)
104020 +{
104021 + unsigned int argnum;
104022 + const_tree fndecl;
104023 +
104024 + argnum = search_missing_attribute(lhs);
104025 + fndecl = get_original_function_decl(current_function_decl);
104026 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
104027 + return MARK_YES;
104028 + return MARK_NO;
104029 +}
104030 +
104031 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
104032 +{
104033 + const_gimple def_stmt;
104034 +
104035 + if (skip_types(lhs))
104036 + return MARK_NO;
104037 +
104038 + if (TREE_CODE(lhs) == PARM_DECL)
104039 + return is_already_marked(lhs);
104040 +
104041 + if (TREE_CODE(lhs) == COMPONENT_REF) {
104042 + const_tree field, attr;
104043 +
104044 + field = search_field_decl(lhs);
104045 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
104046 + if (!attr || !TREE_VALUE(attr))
104047 + return MARK_NO;
104048 + return MARK_YES;
104049 + }
104050 +
104051 + def_stmt = get_def_stmt(lhs);
104052 +
104053 + if (!def_stmt)
104054 + return MARK_NO;
104055 +
104056 + if (pointer_set_contains(visited, def_stmt))
104057 + return MARK_NO;
104058 +
104059 + switch (gimple_code(def_stmt)) {
104060 + case GIMPLE_NOP:
104061 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
104062 + return is_already_marked(lhs);
104063 + return MARK_NO;
104064 + case GIMPLE_PHI:
104065 + return walk_phi(visited, search_err_code, lhs);
104066 + case GIMPLE_CALL:
104067 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
104068 + return MARK_TURN_OFF;
104069 + check_function_hash(def_stmt);
104070 + return MARK_NO;
104071 + case GIMPLE_ASM:
104072 + search_err_code[CAST_ONLY] = false;
104073 + return MARK_NO;
104074 + case GIMPLE_ASSIGN:
104075 + switch (gimple_num_ops(def_stmt)) {
104076 + case 2:
104077 + return walk_unary_ops(visited, search_err_code, lhs);
104078 + case 3:
104079 + return walk_binary_ops(visited, search_err_code, lhs);
104080 + }
104081 + default:
104082 + debug_gimple_stmt((gimple)def_stmt);
104083 + error("%s: unknown gimple code", __func__);
104084 + gcc_unreachable();
104085 + }
104086 +}
104087 +
104088 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
104089 +static bool skip_asm(const_tree arg)
104090 +{
104091 + gimple def_stmt = get_def_stmt(arg);
104092 +
104093 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
104094 + return false;
104095 +
104096 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
104097 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
104098 +}
104099 +
104100 +/*
104101 +0</MARK_YES: no dup, search attributes (so, int)
104102 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
104103 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
104104 +*/
104105 +
104106 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
104107 +{
104108 + struct pointer_set_t *visited;
104109 + enum mark is_marked, is_found;
104110 + location_t loc;
104111 + bool search_err_code[2] = {true, false};
104112 +
104113 + is_marked = mark_status(current_function_decl, 0);
104114 + if (is_marked == MARK_TURN_OFF)
104115 + return true;
104116 +
104117 + is_marked = mark_status(fndecl, argnum + 1);
104118 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
104119 + return true;
104120 +
104121 + visited = pointer_set_create();
104122 + is_found = pre_expand(visited, search_err_code, arg);
104123 + pointer_set_destroy(visited);
104124 +
104125 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
104126 + return true;
104127 +
104128 + if (where == FROM_ARG && skip_asm(arg))
104129 + return true;
104130 +
104131 + if (is_found == MARK_TURN_OFF)
104132 + return true;
104133 +
104134 + if ((is_found == MARK_YES && is_marked == MARK_YES))
104135 + return true;
104136 +
104137 + if (is_found == MARK_YES) {
104138 + loc = DECL_SOURCE_LOCATION(fndecl);
104139 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
104140 + return true;
104141 + }
104142 + return false;
104143 +}
104144 +
104145 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
104146 +{
104147 + struct pointer_set_t *visited;
104148 + tree arg, new_arg;
104149 + bool match;
104150 +
104151 + if (argnum == 0)
104152 + return;
104153 +
104154 + argnum--;
104155 +
104156 + match = get_function_arg(&argnum, fndecl);
104157 + if (!match)
104158 + return;
104159 + gcc_assert(gimple_call_num_args(stmt) > argnum);
104160 + arg = gimple_call_arg(stmt, argnum);
104161 + if (arg == NULL_TREE)
104162 + return;
104163 +
104164 + if (skip_types(arg))
104165 + return;
104166 +
104167 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
104168 + return;
104169 +
104170 + visited = pointer_set_create();
104171 + new_arg = expand(visited, arg);
104172 + pointer_set_destroy(visited);
104173 +
104174 + if (new_arg == NULL_TREE)
104175 + return;
104176 +
104177 + change_function_arg(stmt, arg, argnum, new_arg);
104178 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
104179 +}
104180 +
104181 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
104182 +{
104183 + tree p = TREE_VALUE(attr);
104184 + do {
104185 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
104186 + p = TREE_CHAIN(p);
104187 + } while (p);
104188 +}
104189 +
104190 +static void handle_function_by_hash(gimple stmt, tree fndecl)
104191 +{
104192 + unsigned int num;
104193 + const struct size_overflow_hash *hash;
104194 +
104195 + hash = get_function_hash(fndecl);
104196 + if (!hash)
104197 + return;
104198 +
104199 + for (num = 0; num <= MAX_PARAM; num++)
104200 + if (hash->param & (1U << num))
104201 + handle_function_arg(stmt, fndecl, num);
104202 +}
104203 +
104204 +static bool check_return_value(void)
104205 +{
104206 + const struct size_overflow_hash *hash;
104207 +
104208 + hash = get_function_hash(current_function_decl);
104209 + if (!hash || !(hash->param & 1U << 0))
104210 + return false;
104211 +
104212 + return true;
104213 +}
104214 +
104215 +static void handle_return_value(gimple ret_stmt)
104216 +{
104217 + struct pointer_set_t *visited;
104218 + tree ret, new_ret;
104219 +
104220 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
104221 + return;
104222 +
104223 + ret = gimple_return_retval(ret_stmt);
104224 +
104225 + if (skip_types(ret))
104226 + return;
104227 +
104228 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
104229 + return;
104230 +
104231 + visited = pointer_set_create();
104232 + new_ret = expand(visited, ret);
104233 + pointer_set_destroy(visited);
104234 +
104235 + change_function_return(ret_stmt, ret, new_ret);
104236 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
104237 +}
104238 +
104239 +static void set_plf_false(void)
104240 +{
104241 + basic_block bb;
104242 +
104243 + FOR_ALL_BB(bb) {
104244 + gimple_stmt_iterator si;
104245 +
104246 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
104247 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104248 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
104249 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104250 + }
104251 +}
104252 +
104253 +static unsigned int handle_function(void)
104254 +{
104255 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
104256 + bool check_ret;
104257 +
104258 + set_plf_false();
104259 +
104260 + check_ret = check_return_value();
104261 +
104262 + do {
104263 + gimple_stmt_iterator gsi;
104264 + next = bb->next_bb;
104265 +
104266 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104267 + tree fndecl, attr;
104268 + gimple stmt = gsi_stmt(gsi);
104269 +
104270 + if (check_ret)
104271 + handle_return_value(stmt);
104272 +
104273 + if (!(is_gimple_call(stmt)))
104274 + continue;
104275 + fndecl = gimple_call_fndecl(stmt);
104276 + if (fndecl == NULL_TREE)
104277 + continue;
104278 + if (gimple_call_num_args(stmt) == 0)
104279 + continue;
104280 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
104281 + if (!attr || !TREE_VALUE(attr))
104282 + handle_function_by_hash(stmt, fndecl);
104283 + else
104284 + handle_function_by_attribute(stmt, attr, fndecl);
104285 + gsi = gsi_for_stmt(stmt);
104286 + next = gimple_bb(stmt)->next_bb;
104287 + }
104288 + bb = next;
104289 + } while (bb);
104290 + return 0;
104291 +}
104292 +
104293 +static struct gimple_opt_pass size_overflow_pass = {
104294 + .pass = {
104295 + .type = GIMPLE_PASS,
104296 + .name = "size_overflow",
104297 +#if BUILDING_GCC_VERSION >= 4008
104298 + .optinfo_flags = OPTGROUP_NONE,
104299 +#endif
104300 + .gate = NULL,
104301 + .execute = handle_function,
104302 + .sub = NULL,
104303 + .next = NULL,
104304 + .static_pass_number = 0,
104305 + .tv_id = TV_NONE,
104306 + .properties_required = PROP_cfg,
104307 + .properties_provided = 0,
104308 + .properties_destroyed = 0,
104309 + .todo_flags_start = 0,
104310 + .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
104311 + }
104312 +};
104313 +
104314 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
104315 +{
104316 + tree fntype;
104317 +
104318 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
104319 +
104320 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
104321 + fntype = build_function_type_list(void_type_node,
104322 + const_char_ptr_type_node,
104323 + unsigned_type_node,
104324 + const_char_ptr_type_node,
104325 + const_char_ptr_type_node,
104326 + NULL_TREE);
104327 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
104328 +
104329 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
104330 + TREE_PUBLIC(report_size_overflow_decl) = 1;
104331 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
104332 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
104333 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
104334 +}
104335 +
104336 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104337 +{
104338 + int i;
104339 + const char * const plugin_name = plugin_info->base_name;
104340 + const int argc = plugin_info->argc;
104341 + const struct plugin_argument * const argv = plugin_info->argv;
104342 + bool enable = true;
104343 +
104344 + struct register_pass_info size_overflow_pass_info = {
104345 + .pass = &size_overflow_pass.pass,
104346 + .reference_pass_name = "ssa",
104347 + .ref_pass_instance_number = 1,
104348 + .pos_op = PASS_POS_INSERT_AFTER
104349 + };
104350 +
104351 + if (!plugin_default_version_check(version, &gcc_version)) {
104352 + error(G_("incompatible gcc/plugin versions"));
104353 + return 1;
104354 + }
104355 +
104356 + for (i = 0; i < argc; ++i) {
104357 + if (!strcmp(argv[i].key, "no-size-overflow")) {
104358 + enable = false;
104359 + continue;
104360 + }
104361 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104362 + }
104363 +
104364 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
104365 + if (enable) {
104366 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
104367 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
104368 + }
104369 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104370 +
104371 + return 0;
104372 +}
104373 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
104374 new file mode 100644
104375 index 0000000..ac2901e
104376 --- /dev/null
104377 +++ b/tools/gcc/stackleak_plugin.c
104378 @@ -0,0 +1,327 @@
104379 +/*
104380 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
104381 + * Licensed under the GPL v2
104382 + *
104383 + * Note: the choice of the license means that the compilation process is
104384 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104385 + * but for the kernel it doesn't matter since it doesn't link against
104386 + * any of the gcc libraries
104387 + *
104388 + * gcc plugin to help implement various PaX features
104389 + *
104390 + * - track lowest stack pointer
104391 + *
104392 + * TODO:
104393 + * - initialize all local variables
104394 + *
104395 + * BUGS:
104396 + * - none known
104397 + */
104398 +#include "gcc-plugin.h"
104399 +#include "config.h"
104400 +#include "system.h"
104401 +#include "coretypes.h"
104402 +#include "tree.h"
104403 +#include "tree-pass.h"
104404 +#include "flags.h"
104405 +#include "intl.h"
104406 +#include "toplev.h"
104407 +#include "plugin.h"
104408 +//#include "expr.h" where are you...
104409 +#include "diagnostic.h"
104410 +#include "plugin-version.h"
104411 +#include "tm.h"
104412 +#include "function.h"
104413 +#include "basic-block.h"
104414 +#include "gimple.h"
104415 +#include "rtl.h"
104416 +#include "emit-rtl.h"
104417 +
104418 +#if BUILDING_GCC_VERSION >= 4008
104419 +#define TODO_dump_func 0
104420 +#endif
104421 +
104422 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104423 +
104424 +int plugin_is_GPL_compatible;
104425 +
104426 +static int track_frame_size = -1;
104427 +static const char track_function[] = "pax_track_stack";
104428 +static const char check_function[] = "pax_check_alloca";
104429 +static bool init_locals;
104430 +
104431 +static struct plugin_info stackleak_plugin_info = {
104432 + .version = "201302112000",
104433 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104434 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104435 +};
104436 +
104437 +static bool gate_stackleak_track_stack(void);
104438 +static unsigned int execute_stackleak_tree_instrument(void);
104439 +static unsigned int execute_stackleak_final(void);
104440 +
104441 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104442 + .pass = {
104443 + .type = GIMPLE_PASS,
104444 + .name = "stackleak_tree_instrument",
104445 +#if BUILDING_GCC_VERSION >= 4008
104446 + .optinfo_flags = OPTGROUP_NONE,
104447 +#endif
104448 + .gate = gate_stackleak_track_stack,
104449 + .execute = execute_stackleak_tree_instrument,
104450 + .sub = NULL,
104451 + .next = NULL,
104452 + .static_pass_number = 0,
104453 + .tv_id = TV_NONE,
104454 + .properties_required = PROP_gimple_leh | PROP_cfg,
104455 + .properties_provided = 0,
104456 + .properties_destroyed = 0,
104457 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104458 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104459 + }
104460 +};
104461 +
104462 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104463 + .pass = {
104464 + .type = RTL_PASS,
104465 + .name = "stackleak_final",
104466 +#if BUILDING_GCC_VERSION >= 4008
104467 + .optinfo_flags = OPTGROUP_NONE,
104468 +#endif
104469 + .gate = gate_stackleak_track_stack,
104470 + .execute = execute_stackleak_final,
104471 + .sub = NULL,
104472 + .next = NULL,
104473 + .static_pass_number = 0,
104474 + .tv_id = TV_NONE,
104475 + .properties_required = 0,
104476 + .properties_provided = 0,
104477 + .properties_destroyed = 0,
104478 + .todo_flags_start = 0,
104479 + .todo_flags_finish = TODO_dump_func
104480 + }
104481 +};
104482 +
104483 +static bool gate_stackleak_track_stack(void)
104484 +{
104485 + return track_frame_size >= 0;
104486 +}
104487 +
104488 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104489 +{
104490 + gimple check_alloca;
104491 + tree fntype, fndecl, alloca_size;
104492 +
104493 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104494 + fndecl = build_fn_decl(check_function, fntype);
104495 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104496 +
104497 + // insert call to void pax_check_alloca(unsigned long size)
104498 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104499 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104500 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104501 +}
104502 +
104503 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104504 +{
104505 + gimple track_stack;
104506 + tree fntype, fndecl;
104507 +
104508 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104509 + fndecl = build_fn_decl(track_function, fntype);
104510 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104511 +
104512 + // insert call to void pax_track_stack(void)
104513 + track_stack = gimple_build_call(fndecl, 0);
104514 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104515 +}
104516 +
104517 +#if BUILDING_GCC_VERSION == 4005
104518 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104519 +{
104520 + tree fndecl;
104521 +
104522 + if (!is_gimple_call(stmt))
104523 + return false;
104524 + fndecl = gimple_call_fndecl(stmt);
104525 + if (!fndecl)
104526 + return false;
104527 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104528 + return false;
104529 +// print_node(stderr, "pax", fndecl, 4);
104530 + return DECL_FUNCTION_CODE(fndecl) == code;
104531 +}
104532 +#endif
104533 +
104534 +static bool is_alloca(gimple stmt)
104535 +{
104536 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104537 + return true;
104538 +
104539 +#if BUILDING_GCC_VERSION >= 4007
104540 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104541 + return true;
104542 +#endif
104543 +
104544 + return false;
104545 +}
104546 +
104547 +static unsigned int execute_stackleak_tree_instrument(void)
104548 +{
104549 + basic_block bb, entry_bb;
104550 + bool prologue_instrumented = false, is_leaf = true;
104551 +
104552 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104553 +
104554 + // 1. loop through BBs and GIMPLE statements
104555 + FOR_EACH_BB(bb) {
104556 + gimple_stmt_iterator gsi;
104557 +
104558 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104559 + gimple stmt;
104560 +
104561 + stmt = gsi_stmt(gsi);
104562 +
104563 + if (is_gimple_call(stmt))
104564 + is_leaf = false;
104565 +
104566 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104567 + if (!is_alloca(stmt))
104568 + continue;
104569 +
104570 + // 2. insert stack overflow check before each __builtin_alloca call
104571 + stackleak_check_alloca(&gsi);
104572 +
104573 + // 3. insert track call after each __builtin_alloca call
104574 + stackleak_add_instrumentation(&gsi);
104575 + if (bb == entry_bb)
104576 + prologue_instrumented = true;
104577 + }
104578 + }
104579 +
104580 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104581 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104582 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104583 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104584 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104585 + return 0;
104586 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104587 + return 0;
104588 +
104589 + // 4. insert track call at the beginning
104590 + if (!prologue_instrumented) {
104591 + gimple_stmt_iterator gsi;
104592 +
104593 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104594 + if (dom_info_available_p(CDI_DOMINATORS))
104595 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104596 + gsi = gsi_start_bb(bb);
104597 + stackleak_add_instrumentation(&gsi);
104598 + }
104599 +
104600 + return 0;
104601 +}
104602 +
104603 +static unsigned int execute_stackleak_final(void)
104604 +{
104605 + rtx insn, next;
104606 +
104607 + if (cfun->calls_alloca)
104608 + return 0;
104609 +
104610 + // keep calls only if function frame is big enough
104611 + if (get_frame_size() >= track_frame_size)
104612 + return 0;
104613 +
104614 + // 1. find pax_track_stack calls
104615 + for (insn = get_insns(); insn; insn = next) {
104616 + // 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))
104617 + rtx body;
104618 +
104619 + next = NEXT_INSN(insn);
104620 + if (!CALL_P(insn))
104621 + continue;
104622 + body = PATTERN(insn);
104623 + if (GET_CODE(body) != CALL)
104624 + continue;
104625 + body = XEXP(body, 0);
104626 + if (GET_CODE(body) != MEM)
104627 + continue;
104628 + body = XEXP(body, 0);
104629 + if (GET_CODE(body) != SYMBOL_REF)
104630 + continue;
104631 + if (strcmp(XSTR(body, 0), track_function))
104632 + continue;
104633 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104634 + // 2. delete call
104635 + delete_insn_and_edges(insn);
104636 +#if BUILDING_GCC_VERSION >= 4007
104637 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104638 + insn = next;
104639 + next = NEXT_INSN(insn);
104640 + delete_insn_and_edges(insn);
104641 + }
104642 +#endif
104643 + }
104644 +
104645 +// print_simple_rtl(stderr, get_insns());
104646 +// print_rtl(stderr, get_insns());
104647 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104648 +
104649 + return 0;
104650 +}
104651 +
104652 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104653 +{
104654 + const char * const plugin_name = plugin_info->base_name;
104655 + const int argc = plugin_info->argc;
104656 + const struct plugin_argument * const argv = plugin_info->argv;
104657 + int i;
104658 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104659 + .pass = &stackleak_tree_instrument_pass.pass,
104660 +// .reference_pass_name = "tree_profile",
104661 + .reference_pass_name = "optimized",
104662 + .ref_pass_instance_number = 1,
104663 + .pos_op = PASS_POS_INSERT_BEFORE
104664 + };
104665 + struct register_pass_info stackleak_final_pass_info = {
104666 + .pass = &stackleak_final_rtl_opt_pass.pass,
104667 + .reference_pass_name = "final",
104668 + .ref_pass_instance_number = 1,
104669 + .pos_op = PASS_POS_INSERT_BEFORE
104670 + };
104671 +
104672 + if (!plugin_default_version_check(version, &gcc_version)) {
104673 + error(G_("incompatible gcc/plugin versions"));
104674 + return 1;
104675 + }
104676 +
104677 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104678 +
104679 + for (i = 0; i < argc; ++i) {
104680 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104681 + if (!argv[i].value) {
104682 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104683 + continue;
104684 + }
104685 + track_frame_size = atoi(argv[i].value);
104686 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104687 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104688 + continue;
104689 + }
104690 + if (!strcmp(argv[i].key, "initialize-locals")) {
104691 + if (argv[i].value) {
104692 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104693 + continue;
104694 + }
104695 + init_locals = true;
104696 + continue;
104697 + }
104698 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104699 + }
104700 +
104701 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104702 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104703 +
104704 + return 0;
104705 +}
104706 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104707 new file mode 100644
104708 index 0000000..4fae911
104709 --- /dev/null
104710 +++ b/tools/gcc/structleak_plugin.c
104711 @@ -0,0 +1,277 @@
104712 +/*
104713 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104714 + * Licensed under the GPL v2
104715 + *
104716 + * Note: the choice of the license means that the compilation process is
104717 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104718 + * but for the kernel it doesn't matter since it doesn't link against
104719 + * any of the gcc libraries
104720 + *
104721 + * gcc plugin to forcibly initialize certain local variables that could
104722 + * otherwise leak kernel stack to userland if they aren't properly initialized
104723 + * by later code
104724 + *
104725 + * Homepage: http://pax.grsecurity.net/
104726 + *
104727 + * Usage:
104728 + * $ # for 4.5/4.6/C based 4.7
104729 + * $ 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
104730 + * $ # for C++ based 4.7/4.8+
104731 + * $ 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
104732 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104733 + *
104734 + * TODO: eliminate redundant initializers
104735 + * increase type coverage
104736 + */
104737 +
104738 +#include "gcc-plugin.h"
104739 +#include "config.h"
104740 +#include "system.h"
104741 +#include "coretypes.h"
104742 +#include "tree.h"
104743 +#include "tree-pass.h"
104744 +#include "intl.h"
104745 +#include "plugin-version.h"
104746 +#include "tm.h"
104747 +#include "toplev.h"
104748 +#include "function.h"
104749 +#include "tree-flow.h"
104750 +#include "plugin.h"
104751 +#include "gimple.h"
104752 +#include "diagnostic.h"
104753 +#include "cfgloop.h"
104754 +#include "langhooks.h"
104755 +
104756 +#if BUILDING_GCC_VERSION >= 4008
104757 +#define TODO_dump_func 0
104758 +#endif
104759 +
104760 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104761 +
104762 +// unused type flag in all versions 4.5-4.8
104763 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104764 +
104765 +int plugin_is_GPL_compatible;
104766 +void debug_gimple_stmt(gimple gs);
104767 +
104768 +static struct plugin_info structleak_plugin_info = {
104769 + .version = "201304082245",
104770 + .help = "disable\tdo not activate plugin\n",
104771 +};
104772 +
104773 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104774 +{
104775 + *no_add_attrs = true;
104776 +
104777 + // check for types? for now accept everything linux has to offer
104778 + if (TREE_CODE(*node) != FIELD_DECL)
104779 + return NULL_TREE;
104780 +
104781 + *no_add_attrs = false;
104782 + return NULL_TREE;
104783 +}
104784 +
104785 +static struct attribute_spec user_attr = {
104786 + .name = "user",
104787 + .min_length = 0,
104788 + .max_length = 0,
104789 + .decl_required = false,
104790 + .type_required = false,
104791 + .function_type_required = false,
104792 + .handler = handle_user_attribute,
104793 +#if BUILDING_GCC_VERSION >= 4007
104794 + .affects_type_identity = true
104795 +#endif
104796 +};
104797 +
104798 +static void register_attributes(void *event_data, void *data)
104799 +{
104800 + register_attribute(&user_attr);
104801 +// register_attribute(&force_attr);
104802 +}
104803 +
104804 +static tree get_field_type(tree field)
104805 +{
104806 + return strip_array_types(TREE_TYPE(field));
104807 +}
104808 +
104809 +static bool is_userspace_type(tree type)
104810 +{
104811 + tree field;
104812 +
104813 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104814 + tree fieldtype = get_field_type(field);
104815 + enum tree_code code = TREE_CODE(fieldtype);
104816 +
104817 + if (code == RECORD_TYPE || code == UNION_TYPE)
104818 + if (is_userspace_type(fieldtype))
104819 + return true;
104820 +
104821 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104822 + return true;
104823 + }
104824 + return false;
104825 +}
104826 +
104827 +static void finish_type(void *event_data, void *data)
104828 +{
104829 + tree type = (tree)event_data;
104830 +
104831 + if (TYPE_USERSPACE(type))
104832 + return;
104833 +
104834 + if (is_userspace_type(type))
104835 + TYPE_USERSPACE(type) = 1;
104836 +}
104837 +
104838 +static void initialize(tree var)
104839 +{
104840 + basic_block bb;
104841 + gimple_stmt_iterator gsi;
104842 + tree initializer;
104843 + gimple init_stmt;
104844 +
104845 + // this is the original entry bb before the forced split
104846 + // TODO: check further BBs in case more splits occured before us
104847 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104848 +
104849 + // first check if the variable is already initialized, warn otherwise
104850 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104851 + gimple stmt = gsi_stmt(gsi);
104852 + tree rhs1;
104853 +
104854 + // we're looking for an assignment of a single rhs...
104855 + if (!gimple_assign_single_p(stmt))
104856 + continue;
104857 + rhs1 = gimple_assign_rhs1(stmt);
104858 +#if BUILDING_GCC_VERSION >= 4007
104859 + // ... of a non-clobbering expression...
104860 + if (TREE_CLOBBER_P(rhs1))
104861 + continue;
104862 +#endif
104863 + // ... to our variable...
104864 + if (gimple_get_lhs(stmt) != var)
104865 + continue;
104866 + // if it's an initializer then we're good
104867 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104868 + return;
104869 + }
104870 +
104871 + // these aren't the 0days you're looking for
104872 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
104873 +
104874 + // build the initializer expression
104875 + initializer = build_constructor(TREE_TYPE(var), NULL);
104876 +
104877 + // build the initializer stmt
104878 + init_stmt = gimple_build_assign(var, initializer);
104879 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104880 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104881 + update_stmt(init_stmt);
104882 +}
104883 +
104884 +static unsigned int handle_function(void)
104885 +{
104886 + basic_block bb;
104887 + unsigned int ret = 0;
104888 + tree var;
104889 +
104890 +#if BUILDING_GCC_VERSION == 4005
104891 + tree vars;
104892 +#else
104893 + unsigned int i;
104894 +#endif
104895 +
104896 + // split the first bb where we can put the forced initializers
104897 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104898 + if (dom_info_available_p(CDI_DOMINATORS))
104899 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104900 +
104901 + // enumarate all local variables and forcibly initialize our targets
104902 +#if BUILDING_GCC_VERSION == 4005
104903 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104904 + var = TREE_VALUE(vars);
104905 +#else
104906 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104907 +#endif
104908 + tree type = TREE_TYPE(var);
104909 +
104910 + gcc_assert(DECL_P(var));
104911 + if (!auto_var_in_fn_p(var, current_function_decl))
104912 + continue;
104913 +
104914 + // only care about structure types
104915 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104916 + continue;
104917 +
104918 + // if the type is of interest, examine the variable
104919 + if (TYPE_USERSPACE(type))
104920 + initialize(var);
104921 + }
104922 +
104923 + return ret;
104924 +}
104925 +
104926 +static struct gimple_opt_pass structleak_pass = {
104927 + .pass = {
104928 + .type = GIMPLE_PASS,
104929 + .name = "structleak",
104930 +#if BUILDING_GCC_VERSION >= 4008
104931 + .optinfo_flags = OPTGROUP_NONE,
104932 +#endif
104933 + .gate = NULL,
104934 + .execute = handle_function,
104935 + .sub = NULL,
104936 + .next = NULL,
104937 + .static_pass_number = 0,
104938 + .tv_id = TV_NONE,
104939 + .properties_required = PROP_cfg,
104940 + .properties_provided = 0,
104941 + .properties_destroyed = 0,
104942 + .todo_flags_start = 0,
104943 + .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
104944 + }
104945 +};
104946 +
104947 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104948 +{
104949 + int i;
104950 + const char * const plugin_name = plugin_info->base_name;
104951 + const int argc = plugin_info->argc;
104952 + const struct plugin_argument * const argv = plugin_info->argv;
104953 + bool enable = true;
104954 +
104955 + struct register_pass_info structleak_pass_info = {
104956 + .pass = &structleak_pass.pass,
104957 + .reference_pass_name = "ssa",
104958 + .ref_pass_instance_number = 1,
104959 + .pos_op = PASS_POS_INSERT_AFTER
104960 + };
104961 +
104962 + if (!plugin_default_version_check(version, &gcc_version)) {
104963 + error(G_("incompatible gcc/plugin versions"));
104964 + return 1;
104965 + }
104966 +
104967 + if (strcmp(lang_hooks.name, "GNU C")) {
104968 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104969 + enable = false;
104970 + }
104971 +
104972 + for (i = 0; i < argc; ++i) {
104973 + if (!strcmp(argv[i].key, "disable")) {
104974 + enable = false;
104975 + continue;
104976 + }
104977 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104978 + }
104979 +
104980 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104981 + if (enable) {
104982 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104983 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104984 + }
104985 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104986 +
104987 + return 0;
104988 +}
104989 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104990 index 6789d78..4afd019e 100644
104991 --- a/tools/perf/util/include/asm/alternative-asm.h
104992 +++ b/tools/perf/util/include/asm/alternative-asm.h
104993 @@ -5,4 +5,7 @@
104994
104995 #define altinstruction_entry #
104996
104997 + .macro pax_force_retaddr rip=0, reload=0
104998 + .endm
104999 +
105000 #endif
105001 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
105002 index 96b919d..c49bb74 100644
105003 --- a/tools/perf/util/include/linux/compiler.h
105004 +++ b/tools/perf/util/include/linux/compiler.h
105005 @@ -18,4 +18,12 @@
105006 #define __force
105007 #endif
105008
105009 +#ifndef __size_overflow
105010 +# define __size_overflow(...)
105011 +#endif
105012 +
105013 +#ifndef __intentional_overflow
105014 +# define __intentional_overflow(...)
105015 +#endif
105016 +
105017 #endif
105018 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
105019 index 302681c..3bde377 100644
105020 --- a/virt/kvm/kvm_main.c
105021 +++ b/virt/kvm/kvm_main.c
105022 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
105023
105024 static cpumask_var_t cpus_hardware_enabled;
105025 static int kvm_usage_count = 0;
105026 -static atomic_t hardware_enable_failed;
105027 +static atomic_unchecked_t hardware_enable_failed;
105028
105029 struct kmem_cache *kvm_vcpu_cache;
105030 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
105031
105032 -static __read_mostly struct preempt_ops kvm_preempt_ops;
105033 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
105034 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
105035 +static struct preempt_ops kvm_preempt_ops = {
105036 + .sched_in = kvm_sched_in,
105037 + .sched_out = kvm_sched_out,
105038 +};
105039
105040 struct dentry *kvm_debugfs_dir;
105041
105042 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
105043 /* We can read the guest memory with __xxx_user() later on. */
105044 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
105045 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
105046 - !access_ok(VERIFY_WRITE,
105047 + !__access_ok(VERIFY_WRITE,
105048 (void __user *)(unsigned long)mem->userspace_addr,
105049 mem->memory_size)))
105050 goto out;
105051 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
105052 return 0;
105053 }
105054
105055 -static struct file_operations kvm_vcpu_fops = {
105056 +static file_operations_no_const kvm_vcpu_fops __read_only = {
105057 .release = kvm_vcpu_release,
105058 .unlocked_ioctl = kvm_vcpu_ioctl,
105059 #ifdef CONFIG_COMPAT
105060 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
105061 return 0;
105062 }
105063
105064 -static struct file_operations kvm_vm_fops = {
105065 +static file_operations_no_const kvm_vm_fops __read_only = {
105066 .release = kvm_vm_release,
105067 .unlocked_ioctl = kvm_vm_ioctl,
105068 #ifdef CONFIG_COMPAT
105069 @@ -2662,7 +2667,7 @@ out:
105070 return r;
105071 }
105072
105073 -static struct file_operations kvm_chardev_ops = {
105074 +static file_operations_no_const kvm_chardev_ops __read_only = {
105075 .unlocked_ioctl = kvm_dev_ioctl,
105076 .compat_ioctl = kvm_dev_ioctl,
105077 .llseek = noop_llseek,
105078 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
105079
105080 if (r) {
105081 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
105082 - atomic_inc(&hardware_enable_failed);
105083 + atomic_inc_unchecked(&hardware_enable_failed);
105084 printk(KERN_INFO "kvm: enabling virtualization on "
105085 "CPU%d failed\n", cpu);
105086 }
105087 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
105088
105089 kvm_usage_count++;
105090 if (kvm_usage_count == 1) {
105091 - atomic_set(&hardware_enable_failed, 0);
105092 + atomic_set_unchecked(&hardware_enable_failed, 0);
105093 on_each_cpu(hardware_enable_nolock, NULL, 1);
105094
105095 - if (atomic_read(&hardware_enable_failed)) {
105096 + if (atomic_read_unchecked(&hardware_enable_failed)) {
105097 hardware_disable_all_nolock();
105098 r = -EBUSY;
105099 }
105100 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
105101 kvm_arch_vcpu_put(vcpu);
105102 }
105103
105104 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105105 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105106 struct module *module)
105107 {
105108 int r;
105109 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105110 if (!vcpu_align)
105111 vcpu_align = __alignof__(struct kvm_vcpu);
105112 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
105113 - 0, NULL);
105114 + SLAB_USERCOPY, NULL);
105115 if (!kvm_vcpu_cache) {
105116 r = -ENOMEM;
105117 goto out_free_3;
105118 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105119 if (r)
105120 goto out_free;
105121
105122 + pax_open_kernel();
105123 kvm_chardev_ops.owner = module;
105124 kvm_vm_fops.owner = module;
105125 kvm_vcpu_fops.owner = module;
105126 + pax_close_kernel();
105127
105128 r = misc_register(&kvm_dev);
105129 if (r) {
105130 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105131
105132 register_syscore_ops(&kvm_syscore_ops);
105133
105134 - kvm_preempt_ops.sched_in = kvm_sched_in;
105135 - kvm_preempt_ops.sched_out = kvm_sched_out;
105136 -
105137 r = kvm_init_debug();
105138 if (r) {
105139 printk(KERN_ERR "kvm: create debugfs files failed\n");